sankarh commented on a change in pull request #1109:
URL: https://github.com/apache/hive/pull/1109#discussion_r452816142



##########
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:
       In second thought, I think ordinal is better as we freshly load cache 
entries during HMS startup. So, the ordering doesn't matter. However, setting 
values can be a problem if someone pass incorrect value or remove an element 
without updating other values.




----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to