[ https://issues.apache.org/jira/browse/HIVE-22015?focusedWorklogId=457105&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-457105 ]
ASF GitHub Bot logged work on HIVE-22015: ----------------------------------------- Author: ASF GitHub Bot Created on: 10/Jul/20 12:01 Start Date: 10/Jul/20 12:01 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_r452799879 ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java ########## @@ -261,44 +283,57 @@ public int getObjectSize(Class<?> clazz, Object obj) { private Map<String, String> parameters; private byte[] sdHash; private int otherSize; - private int tableColStatsCacheSize; - private int partitionCacheSize; - private int partitionColStatsCacheSize; - private int aggrColStatsCacheSize; + + // Arrays to hold the size/updated bit of cached objects. + // These arrays are to be referenced using MemberName enum only. + private int[] memberObjectsSize = new int[MemberName.values().length]; + private AtomicBoolean[] memberCacheUpdated = new AtomicBoolean[MemberName.values().length]; private ReentrantReadWriteLock tableLock = new ReentrantReadWriteLock(true); // For caching column stats for an unpartitioned table // Key is column name and the value is the col stat object private Map<String, ColumnStatisticsObj> tableColStatsCache = new ConcurrentHashMap<String, ColumnStatisticsObj>(); - private AtomicBoolean isTableColStatsCacheDirty = new AtomicBoolean(false); // For caching partition objects // Ket is partition values and the value is a wrapper around the partition object private Map<String, PartitionWrapper> partitionCache = new ConcurrentHashMap<String, PartitionWrapper>(); - private AtomicBoolean isPartitionCacheDirty = new AtomicBoolean(false); // For caching column stats for a partitioned table // Key is aggregate of partition values, column name and the value is the col stat object private Map<String, ColumnStatisticsObj> partitionColStatsCache = new ConcurrentHashMap<String, ColumnStatisticsObj>(); - private AtomicBoolean isPartitionColStatsCacheDirty = new AtomicBoolean(false); // For caching aggregate column stats for all and all minus default partition // Key is column name and the value is a list of 2 col stat objects // (all partitions and all but default) private Map<String, List<ColumnStatisticsObj>> aggrColStatsCache = new ConcurrentHashMap<String, List<ColumnStatisticsObj>>(); - private AtomicBoolean isAggrPartitionColStatsCacheDirty = new AtomicBoolean(false); + + private Map<String, SQLPrimaryKey> primaryKeyCache = new ConcurrentHashMap<>(); + + private Map<String, SQLForeignKey> foreignKeyCache = new ConcurrentHashMap<>(); + + private Map<String, SQLNotNullConstraint> notNullConstraintCache = new ConcurrentHashMap<>(); + + private Map<String, SQLUniqueConstraint> uniqueConstraintCache = new ConcurrentHashMap<>(); TableWrapper(Table t, byte[] sdHash, String location, Map<String, String> parameters) { this.t = t; this.sdHash = sdHash; this.location = location; this.parameters = parameters; - this.tableColStatsCacheSize = 0; - this.partitionCacheSize = 0; - this.partitionColStatsCacheSize = 0; - this.aggrColStatsCacheSize = 0; + for(MemberName mn : MemberName.values()) { + this.memberObjectsSize[mn.getValue()] = 0; Review comment: Java treats enum as objects. Array indexes can be integers only. Therefore, I have to use mn.getValue() only. PS: Enum also provides `ordinal` method that returns the position of enum member, but that can cause issues if order is changed. So, I decided to go ahead with creating own getValue() method. ---------------------------------------------------------------- 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: 457105) Time Spent: 3h 50m (was: 3h 40m) > [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 50m > 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)