[ https://issues.apache.org/jira/browse/HIVE-22015?focusedWorklogId=454384&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-454384 ]
ASF GitHub Bot logged work on HIVE-22015: ----------------------------------------- Author: ASF GitHub Bot Created on: 03/Jul/20 11:14 Start Date: 03/Jul/20 11:14 Worklog Time Spent: 10m Work Description: 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 454384) Time Spent: 2.5h (was: 2h 20m) > [CachedStore] Cache table constraints in CachedStore > ---------------------------------------------------- > > Key: HIVE-22015 > URL: https://issues.apache.org/jira/browse/HIVE-22015 > Project: Hive > Issue Type: Sub-task > Reporter: Daniel Dai > Assignee: Adesh Kumar Rao > Priority: Major > Labels: pull-request-available > Time Spent: 2.5h > Remaining Estimate: 0h > > Currently table constraints are not cached. Hive will pull all constraints > from tables involved in query, which results multiple db reads (including > get_primary_keys, get_foreign_keys, get_unique_constraints, etc). The effort > to cache this is small as it's just another table component. -- This message was sent by Atlassian Jira (v8.3.4#803005)