adesh-rao commented on a change in pull request #1109:
URL: https://github.com/apache/hive/pull/1109#discussion_r449528675
##########
File path:
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java
##########
@@ -514,6 +655,130 @@ public boolean containsPartition(List<String> partVals) {
return containsPart;
}
+ public void removeConstraint(String name) {
+ try {
+ tableLock.writeLock().lock();
+ Object constraint = null;
+ MemberName mn = null;
+ Class constraintClass = null;
+ if (this.primaryKeyCache.containsKey(name)) {
+ constraint = this.primaryKeyCache.remove(name);
+ mn = MemberName.PRIMARY_KEY_CACHE;
+ this.memberCacheDirty[mn.ordinal()].set(true);
+ constraintClass = SQLPrimaryKey.class;
+ } else if (this.foreignKeyCache.containsKey(name)) {
+ constraint = this.foreignKeyCache.remove(name);
+ mn = MemberName.FOREIGN_KEY_CACHE;
+ this.memberCacheDirty[mn.ordinal()].set(true);
+ constraintClass = SQLForeignKey.class;
+ } else if (this.notNullConstraintCache.containsKey(name)) {
+ constraint = this.notNullConstraintCache.remove(name);
+ mn = MemberName.NOTNULL_CONSTRAINT_CACHE;
+ this.memberCacheDirty[mn.ordinal()].set(true);
+ constraintClass = SQLNotNullConstraint.class;
+ } else if (this.uniqueConstraintCache.containsKey(name)) {
+ constraint = this.uniqueConstraintCache.remove(name);
+ mn = MemberName.UNIQUE_CONSTRAINT_CACHE;
+ this.memberCacheDirty[mn.ordinal()].set(true);
+ constraintClass = SQLUniqueConstraint.class;
+ }
+
+ if(constraint == null) {
+ LOG.debug("Constraint: " + name + " does not exist in cache.");
+ return;
+ }
+ int size = getObjectSize(constraintClass, constraint);
+ updateMemberSize(mn, -1 * size, SizeMode.Delta);
+
+ } finally {
+ tableLock.writeLock().unlock();
+ }
+ }
+
+ public void refreshPrimaryKeys(List<SQLPrimaryKey> keys) {
+ Map<String, SQLPrimaryKey> newKeys = new ConcurrentHashMap<>();
+ try {
+ tableLock.writeLock().lock();
+ int size = 0;
+ for (SQLPrimaryKey key : keys) {
+ if
(this.memberCacheDirty[MemberName.PRIMARY_KEY_CACHE.ordinal()].compareAndSet(true,
false)) {
Review comment:
Updated the name of the variable. This is used during refreshOperation.
If a particular Object cache is set to true, means it was updated after the
last refresh operation and should be refreshed now, otherwise, current refresh
operation will not modify/refresh the cache.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]