[ 
https://issues.apache.org/jira/browse/HIVE-23695?focusedWorklogId=501602&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-501602
 ]

ASF GitHub Bot logged work on HIVE-23695:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/Oct/20 15:46
            Start Date: 16/Oct/20 15:46
    Worklog Time Spent: 10m 
      Work Description: 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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 501602)
    Time Spent: 1h 20m  (was: 1h 10m)

> [CachedStore] Add check/default constraints in CachedStore
> ----------------------------------------------------------
>
>                 Key: HIVE-23695
>                 URL: https://issues.apache.org/jira/browse/HIVE-23695
>             Project: Hive
>          Issue Type: Sub-task
>          Components: Standalone Metastore
>            Reporter: Adesh Kumar Rao
>            Assignee: Ashish Sharma
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.0.0
>
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> This is blocked by HIVE-23618 (notification events are not generated for 
> default/unique constraints, hence created a separate sub-task from 
> HIVE-22015).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to