ashish-kumar-sharma commented on a change in pull request #1610:
URL: https://github.com/apache/hive/pull/1610#discussion_r575929152
##########
File path:
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java
##########
@@ -715,154 +747,105 @@ public void removeConstraint(String name) {
}
}
- public void refreshPrimaryKeys(List<SQLPrimaryKey> keys) {
- Map<String, SQLPrimaryKey> newKeys = new ConcurrentHashMap<>();
+ public void refreshAllTableConstraints(SQLAllTableConstraints constraints)
{
try {
tableLock.writeLock().lock();
- int size = 0;
- for (SQLPrimaryKey key : keys) {
- if (compareAndSetMemberCacheUpdated(MemberName.PRIMARY_KEY_CACHE,
true, false)) {
- LOG.debug("Skipping primary key cache update for table: " +
getTable().getTableName()
- + "; the primary keys are already refreshed.");
- return;
- }
- String pkName = StringUtils.normalizeIdentifier(key.getPk_name());
- key.setPk_name(pkName);
- newKeys.put(pkName, key);
- size += getObjectSize(SQLPrimaryKey.class, key);
- }
- primaryKeyCache = newKeys;
- updateMemberSize(MemberName.PRIMARY_KEY_CACHE, size,
SizeMode.Snapshot);
- LOG.debug("Primary keys refresh in cache was successful for {}.{}.{}",
- this.getTable().getCatName(), this.getTable().getDbName(),
this.getTable().getTableName());
+ this.isConstraintsValid =
+ refreshConstraint(constraints.getPrimaryKeys(),
MemberName.PRIMARY_KEY_CACHE) && refreshConstraint(
+ constraints.getForeignKeys(), MemberName.FOREIGN_KEY_CACHE) &&
refreshConstraint(
+ constraints.getUniqueConstraints(),
MemberName.UNIQUE_CONSTRAINT_CACHE) && refreshConstraint(
+ constraints.getDefaultConstraints(),
MemberName.DEFAULT_CONSTRAINT_CACHE) && refreshConstraint(
+ constraints.getNotNullConstraints(),
MemberName.NOTNULL_CONSTRAINT_CACHE) && refreshConstraint(
+ constraints.getCheckConstraints(),
MemberName.CHECK_CONSTRAINT_CACHE);
} finally {
tableLock.writeLock().unlock();
}
}
- public void refreshForeignKeys(List<SQLForeignKey> keys) {
- Map<String, SQLForeignKey> newKeys = new ConcurrentHashMap<>();
- try {
- tableLock.writeLock().lock();
- int size = 0;
- for (SQLForeignKey key : keys) {
- if (compareAndSetMemberCacheUpdated(MemberName.FOREIGN_KEY_CACHE,
true, false)) {
- LOG.debug("Skipping foreign key cache update for table: " +
getTable().getTableName()
- + "; the foreign keys are already refreshed.");
- return;
+ private boolean refreshConstraint(List constraints, MemberName mn) {
Review comment:
Yes
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]