ashish-kumar-sharma commented on a change in pull request #1527: URL: https://github.com/apache/hive/pull/1527#discussion_r506560970
########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java ########## @@ -749,6 +797,52 @@ public void refreshUniqueConstraints(List<SQLUniqueConstraint> constraints) { } } + public void refreshDefaultConstraints(List<SQLDefaultConstraint> constraints) { + Map<String, SQLDefaultConstraint> newConstraints = new ConcurrentHashMap<>(); + try { + tableLock.writeLock().lock(); + int size = 0; + for (SQLDefaultConstraint constraint : constraints) { + if (compareAndSetMemberCacheUpdated(MemberName.DEFAULT_CONSTRAINT_CACHE, true, false)) { + LOG.debug("Skipping default constraint cache update for table: " + getTable().getTableName() + + "; the default constraint are already refreshed."); + return; + } + newConstraints.put(constraint.getDc_name().toLowerCase(), constraint); + size += getObjectSize(SQLUniqueConstraint.class, constraint); + } + defaultConstraintCache = newConstraints; + updateMemberSize(MemberName.DEFAULT_CONSTRAINT_CACHE, size, SizeMode.Snapshot); + LOG.debug("Default constraints refresh in cache was successful for {}.{}.{}", this.getTable().getCatName(), + this.getTable().getDbName(), this.getTable().getTableName()); + } finally { + tableLock.writeLock().unlock(); + } + } + + public void refreshCheckConstraints(List<SQLCheckConstraint> constraints) { + Map<String, SQLCheckConstraint> newConstraints = new ConcurrentHashMap<>(); + try { + tableLock.writeLock().lock(); + int size = 0; + for (SQLCheckConstraint constraint : constraints) { + if (compareAndSetMemberCacheUpdated(MemberName.CHECK_CONSTRAINT_CACHE, true, false)) { + LOG.debug("Skipping check constraint cache update for table: " + getTable().getTableName() + + "; the check constraint are already refreshed."); + return; + } + newConstraints.put(constraint.getDc_name().toLowerCase(), constraint); + size += getObjectSize(SQLCheckConstraint.class, constraint); + } + checkConstraintCache = newConstraints; + updateMemberSize(MemberName.CHECK_CONSTRAINT_CACHE, size, SizeMode.Snapshot); + LOG.debug("Unique constraints refresh in cache was successful for {}.{}.{}", this.getTable().getCatName(), Review comment: Done ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java ########## @@ -1669,33 +1763,47 @@ public boolean populateTableInCache(Table table, TableCacheObjects cacheObjects) tblWrapper.setMemberCacheUpdated(MemberName.PARTITION_COL_STATS_CACHE, false); tblWrapper.setMemberCacheUpdated(MemberName.AGGR_COL_STATS_CACHE, false); - if (cacheObjects.getPrimaryKeys() != null) { - if(!tblWrapper.cachePrimaryKeys(cacheObjects.getPrimaryKeys(), true)) { + if (CollectionUtils.isNotEmpty(cacheObjects.getTableConstraints().getPrimaryKeys())) { + if (!tblWrapper.cachePrimaryKeys(cacheObjects.getTableConstraints().getPrimaryKeys(), true)) { + return false; + } + } + tblWrapper.setMemberCacheUpdated(MemberName.PRIMARY_KEY_CACHE, false); + + if (CollectionUtils.isNotEmpty(cacheObjects.getTableConstraints().getForeignKeys())) { Review comment: Done ---------------------------------------------------------------- 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