ashish-kumar-sharma commented on a change in pull request #1527:
URL: https://github.com/apache/hive/pull/1527#discussion_r506560659
##########
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);
Review comment:
done
##########
File path:
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
##########
@@ -909,82 +906,137 @@ private void updateTableColStats(RawStore rawStore,
String catName, String dbNam
}
private void updateTableForeignKeys(RawStore rawStore, String catName,
String dbName, String tblName) {
+ catName = StringUtils.normalizeIdentifier(catName);
+ dbName = StringUtils.normalizeIdentifier(dbName);
+ tblName = StringUtils.normalizeIdentifier(tblName);
LOG.debug("CachedStore: updating cached foreign keys objects for
catalog: {}, database: {}, table: {}", catName,
- dbName, tblName);
+ dbName, tblName);
List<SQLForeignKey> fks = null;
try {
Deadline.startTimer("getForeignKeys");
fks = rawStore.getForeignKeys(catName, null, null, dbName, tblName);
Deadline.stopTimer();
} catch (MetaException e) {
- LOG.info("Updating CachedStore: unable to update foreign keys of
catalog: " + catName + ", database: "
- + dbName + ", table: " + tblName, e);
+ LOG.info("Updating CachedStore: unable to update foreign keys of
catalog: " + catName + ", database: " + dbName
+ + ", table: " + tblName, e);
}
if (fks != null) {
-
sharedCache.refreshForeignKeysInCache(StringUtils.normalizeIdentifier(catName),
- StringUtils.normalizeIdentifier(dbName),
StringUtils.normalizeIdentifier(tblName), fks);
- LOG.debug("CachedStore: updated cached foreign keys objects for
catalog: {}, database: {}, table: {}",
- catName, dbName, tblName);
+ sharedCache.refreshForeignKeysInCache(catName, dbName, tblName, fks);
+ LOG.debug("CachedStore: updated cached foreign keys objects for
catalog: {}, database: {}, table: {}", catName,
+ dbName, tblName);
}
}
private void updateTableNotNullConstraints(RawStore rawStore, String
catName, String dbName, String tblName) {
+ catName = StringUtils.normalizeIdentifier(catName);
+ dbName = StringUtils.normalizeIdentifier(dbName);
+ tblName = StringUtils.normalizeIdentifier(tblName);
LOG.debug("CachedStore: updating cached not null constraints for
catalog: {}, database: {}, table: {}", catName,
- dbName, tblName);
+ dbName, tblName);
List<SQLNotNullConstraint> nns = null;
try {
Deadline.startTimer("getNotNullConstraints");
nns = rawStore.getNotNullConstraints(catName, dbName, tblName);
Deadline.stopTimer();
} catch (MetaException e) {
LOG.info("Updating CachedStore: unable to update not null constraints
of catalog: " + catName + ", database: "
- + dbName + ", table: " + tblName, e);
+ + dbName + ", table: " + tblName, e);
}
if (nns != null) {
-
sharedCache.refreshNotNullConstraintsInCache(StringUtils.normalizeIdentifier(catName),
- StringUtils.normalizeIdentifier(dbName),
StringUtils.normalizeIdentifier(tblName), nns);
- LOG.debug("CachedStore: updated cached not null constraints for
catalog: {}, database: {}, table: {}",
- catName, dbName, tblName);
+ sharedCache.refreshNotNullConstraintsInCache(catName, dbName, tblName,
nns);
+ LOG.debug("CachedStore: updated cached not null constraints for
catalog: {}, database: {}, table: {}", catName,
+ dbName, tblName);
}
}
private void updateTableUniqueConstraints(RawStore rawStore, String
catName, String dbName, String tblName) {
+ catName = StringUtils.normalizeIdentifier(catName);
+ dbName = StringUtils.normalizeIdentifier(dbName);
+ tblName = StringUtils.normalizeIdentifier(tblName);
LOG.debug("CachedStore: updating cached unique constraints for catalog:
{}, database: {}, table: {}", catName,
- dbName, tblName);
+ dbName, tblName);
List<SQLUniqueConstraint> ucs = null;
try {
Deadline.startTimer("getUniqueConstraints");
ucs = rawStore.getUniqueConstraints(catName, dbName, tblName);
Deadline.stopTimer();
} catch (MetaException e) {
- LOG.info("Updating CachedStore: unable to update unique constraints of
catalog: " + catName + ", database: "
- + dbName + ", table: " + tblName, e);
+ LOG.info(
+ "Updating CachedStore: unable to update unique constraints of
catalog: " + catName + ", database: " + dbName
+ + ", table: " + tblName, e);
}
if (ucs != null) {
-
sharedCache.refreshUniqueConstraintsInCache(StringUtils.normalizeIdentifier(catName),
- StringUtils.normalizeIdentifier(dbName),
StringUtils.normalizeIdentifier(tblName), ucs);
- LOG.debug("CachedStore: updated cached unique constraints for catalog:
{}, database: {}, table: {}",
- catName, dbName, tblName);
+ sharedCache.refreshUniqueConstraintsInCache(catName, dbName, tblName,
ucs);
+ LOG.debug("CachedStore: updated cached unique constraints for catalog:
{}, database: {}, table: {}", catName,
+ dbName, tblName);
}
}
private void updateTablePrimaryKeys(RawStore rawStore, String catName,
String dbName, String tblName) {
+ catName = StringUtils.normalizeIdentifier(catName);
+ dbName = StringUtils.normalizeIdentifier(dbName);
+ tblName = StringUtils.normalizeIdentifier(tblName);
LOG.debug("CachedStore: updating cached primary keys objects for
catalog: {}, database: {}, table: {}", catName,
- dbName, tblName);
+ dbName, tblName);
List<SQLPrimaryKey> pks = null;
try {
Deadline.startTimer("getPrimaryKeys");
pks = rawStore.getPrimaryKeys(catName, dbName, tblName);
Deadline.stopTimer();
} catch (MetaException e) {
- LOG.info("Updating CachedStore: unable to update primary keys of
catalog: " + catName + ", database: "
- + dbName + ", table: " + tblName, e);
+ LOG.info("Updating CachedStore: unable to update primary keys of
catalog: " + catName + ", database: " + dbName
+ + ", table: " + tblName, e);
}
if (pks != null) {
-
sharedCache.refreshPrimaryKeysInCache(StringUtils.normalizeIdentifier(catName),
- StringUtils.normalizeIdentifier(dbName),
StringUtils.normalizeIdentifier(tblName), pks);
- LOG.debug("CachedStore: updated cached primary keys objects for
catalog: {}, database: {}, table: {}",
+ sharedCache.refreshPrimaryKeysInCache(catName, dbName, tblName, pks);
+ LOG.debug("CachedStore: updated cached primary keys objects for
catalog: {}, database: {}, table: {}", catName,
+ dbName, tblName);
+ }
+ }
+
+ private void updateTableDefaultConstraints(RawStore rawStore, String
catName, String dbName, String tblName) {
+ catName = StringUtils.normalizeIdentifier(catName);
+ dbName = StringUtils.normalizeIdentifier(dbName);
+ tblName = StringUtils.normalizeIdentifier(tblName);
+ LOG.debug("CachedStore: updating cached default Constraint objects for
catalog: {}, database: {}, table: {}",
catName, dbName, tblName);
+ List<SQLDefaultConstraint> dc = null;
+ try {
+ Deadline.startTimer("getDefaultConstraints");
+ dc = rawStore.getDefaultConstraints(catName, dbName, tblName);
+ Deadline.stopTimer();
+ } catch (MetaException e) {
+ LOG.info(
+ "Updating CachedStore: unable to update default Constraint of
catalog: " + catName + ", database: " + dbName
+ + ", table: " + tblName, e);
+ }
+ if (dc != null) {
+ sharedCache.refreshDefaultConstraintsInCache(catName, dbName, tblName,
dc);
+ LOG.debug("CachedStore: updated cached default constraint objects for
catalog: {}, database: {}, table: {}",
+ catName, dbName, tblName);
+ }
+ }
+
+ private void updateTableCheckConstraints(RawStore rawStore, String
catName, String dbName, String tblName) {
+ catName = StringUtils.normalizeIdentifier(catName);
+ dbName = StringUtils.normalizeIdentifier(dbName);
+ tblName = StringUtils.normalizeIdentifier(tblName);
+ LOG.debug("CachedStore: updating cached check constraint objects for
catalog: {}, database: {}, table: {}",
+ catName, dbName, tblName);
+ List<SQLCheckConstraint> cc = null;
+ try {
+ Deadline.startTimer("getCheckConstraint");
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]