[ https://issues.apache.org/jira/browse/HIVE-22015?focusedWorklogId=457096&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-457096 ]
ASF GitHub Bot logged work on HIVE-22015: ----------------------------------------- Author: ASF GitHub Bot Created on: 10/Jul/20 11:11 Start Date: 10/Jul/20 11:11 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_r452779486 ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java ########## @@ -470,6 +484,107 @@ boolean cachePartitions(Iterable<Partition> parts, SharedCache sharedCache, bool } } + boolean cachePrimaryKeys(List<SQLPrimaryKey> primaryKeys, boolean fromPrewarm) { + return cacheConstraints(primaryKeys, fromPrewarm, MemberName.PRIMARY_KEY_CACHE); + } + + boolean cacheForeignKeys(List<SQLForeignKey> foreignKeys, boolean fromPrewarm) { + return cacheConstraints(foreignKeys, fromPrewarm, MemberName.FOREIGN_KEY_CACHE); + } + + boolean cacheUniqueConstraints(List<SQLUniqueConstraint> uniqueConstraints, boolean fromPrewarm) { + return cacheConstraints(uniqueConstraints, fromPrewarm, MemberName.UNIQUE_CONSTRAINT_CACHE); + } + + boolean cacheNotNullConstraints(List<SQLNotNullConstraint> notNullConstraints, boolean fromPrewarm) { + return cacheConstraints(notNullConstraints, fromPrewarm, MemberName.NOTNULL_CONSTRAINT_CACHE); + } + + // Common method to cache constraints + private boolean cacheConstraints(List constraintsList, + boolean fromPrewarm, + MemberName mn) { + if (constraintsList == null || constraintsList.isEmpty()) { + return true; + } + try { + tableLock.writeLock().lock(); + final int[] size = {0}; Review comment: This is being used inside lambda function. It requires the variable to be used as final. Because of this, I can't use int or Integer. So I chose int array instead. ---------------------------------------------------------------- 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: 457096) Time Spent: 3h 40m (was: 3.5h) > [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: 3h 40m > 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)