[
https://issues.apache.org/jira/browse/HIVE-24259?focusedWorklogId=505141&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-505141
]
ASF GitHub Bot logged work on HIVE-24259:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 27/Oct/20 10:14
Start Date: 27/Oct/20 10:14
Worklog Time Spent: 10m
Work Description: adesh-rao commented on a change in pull request #1610:
URL: https://github.com/apache/hive/pull/1610#discussion_r512564828
##########
File path:
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
##########
@@ -2836,14 +2836,32 @@ long getPartsFound() {
@Override
public SQLAllTableConstraints getAllTableConstraints(String catName, String
dbName, String tblName)
throws MetaException, NoSuchObjectException {
- SQLAllTableConstraints sqlAllTableConstraints = new
SQLAllTableConstraints();
- sqlAllTableConstraints.setPrimaryKeys(getPrimaryKeys(catName, dbName,
tblName));
- sqlAllTableConstraints.setForeignKeys(getForeignKeys(catName, null, null,
dbName, tblName));
- sqlAllTableConstraints.setUniqueConstraints(getUniqueConstraints(catName,
dbName, tblName));
-
sqlAllTableConstraints.setDefaultConstraints(getDefaultConstraints(catName,
dbName, tblName));
- sqlAllTableConstraints.setCheckConstraints(getCheckConstraints(catName,
dbName, tblName));
-
sqlAllTableConstraints.setNotNullConstraints(getNotNullConstraints(catName,
dbName, tblName));
- return sqlAllTableConstraints;
+
+ catName = StringUtils.normalizeIdentifier(catName);
+ dbName = StringUtils.normalizeIdentifier(dbName);
+ tblName = StringUtils.normalizeIdentifier(tblName);
+ if (!shouldCacheTable(catName, dbName, tblName) || (canUseEvents &&
rawStore.isActiveTransaction())) {
+ return rawStore.getAllTableConstraints(catName, dbName, tblName);
+ }
+
+ Table tbl = sharedCache.getTableFromCache(catName, dbName, tblName);
+ if (tbl == null) {
+ // The table containing the constraints is not yet loaded in cache
+ return rawStore.getAllTableConstraints(catName, dbName, tblName);
+ }
+ SQLAllTableConstraints constraints =
sharedCache.listCachedAllTableConstraints(catName, dbName, tblName);
+
+ // if any of the constraint value is missing then there might be the case
of partial constraints are stored in cached.
+ // So fall back to raw store for correct values
+ if (constraints != null &&
CollectionUtils.isNotEmpty(constraints.getPrimaryKeys()) && CollectionUtils
Review comment:
Also, what if the table just has primary keys and no other constraints?
nonEmpty(otherConstraints) will return true and we will not cache anything?
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 505141)
Time Spent: 50m (was: 40m)
> [CachedStore] Optimise getAlltableConstraint from 6 cache calls to 1
> --------------------------------------------------------------------
>
> Key: HIVE-24259
> URL: https://issues.apache.org/jira/browse/HIVE-24259
> Project: Hive
> Issue Type: Sub-task
> Reporter: Ashish Sharma
> Assignee: Ashish Sharma
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 50m
> Remaining Estimate: 0h
>
> Description -
> currently inorder to get all constraint form the cachedstore. 6 different
> call is made to the store. Instead combine that 6 call in 1
--
This message was sent by Atlassian Jira
(v8.3.4#803005)