Skip to content

Commit

Permalink
HIVE-23820: add tableId in getTable request
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish-kumar-sharma committed Apr 9, 2021
1 parent af5f983 commit 086ab19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,6 @@ public Table getTable(final String dbName, final String tableName, boolean throw
validWriteIdList = AcidUtils.getTableValidWriteIdListWithTxnList(conf, dbName, tableName);
}
request.setValidWriteIdList(validWriteIdList != null ? validWriteIdList.toString() : null);
request.setId(-1);
}
tTable = getMSC().getTable(request);
} catch (NoSuchObjectException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2079,10 +2079,16 @@ protected GetTableResult getTableInternal(GetTableRequest req) throws TException
Map<Object, Object> queryCache = getQueryCache();
if (queryCache != null) {
// Retrieve or populate cache
CacheKey cacheKeyTableId = new CacheKey(KeyType.TABLE_ID,req.getCatName(),req.getDbName(),req.getTblName());
long tableId = (long) queryCache.getOrDefault(cacheKeyTableId, -1);
req.setId(tableId);
CacheKey cacheKey = new CacheKey(KeyType.TABLE, req);
GetTableResult v = (GetTableResult) queryCache.get(cacheKey);
if (v == null) {
v = super.getTableInternal(req);
if(tableId == -1) {
queryCache.put(cacheKeyTableId, v.getTable().getId());
}
queryCache.put(cacheKey, v);
} else {
LOG.debug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ public enum KeyType {
// GetValidWriteIdsResponse <-- getValidWriteIdsInternal(GetValidWriteIdsRequest rqst)
// Stored individually as:
// TableValidWriteIds <-- String fullTableName, String validTxnList, long writeId
VALID_WRITE_IDS(TableValidWriteIds.class, String.class, long.class);
VALID_WRITE_IDS(TableValidWriteIds.class, String.class, long.class),
// TableId <- String fullTableName
TABLE_ID(Long.class, String.class);

private final List<Class<?>> keyClasses;
private final Class<?> valueClass;
Expand Down

0 comments on commit 086ab19

Please sign in to comment.