use of org.apache.hadoop.hive.metastore.api.TableStatsRequest in project hive by apache.
the class SessionHiveMetaStoreClient method getTableColumnStatisticsInternal.
@Override
protected TableStatsResult getTableColumnStatisticsInternal(TableStatsRequest rqst) throws TException {
Map<Object, Object> queryCache = getQueryCache();
if (queryCache != null) {
MapWrapper cache = new MapWrapper(queryCache);
// 1) Retrieve from the cache those ids present, gather the rest
Pair<List<ColumnStatisticsObj>, List<String>> p = getTableColumnStatisticsCache(cache, rqst, null);
List<String> colStatsMissing = p.getRight();
List<ColumnStatisticsObj> colStats = p.getLeft();
// 2) If they were all present in the cache, return
if (colStatsMissing.isEmpty()) {
return new TableStatsResult(colStats);
}
// 3) If they were not, gather the remaining
TableStatsRequest newRqst = new TableStatsRequest(rqst);
newRqst.setColNames(colStatsMissing);
TableStatsResult r = super.getTableColumnStatisticsInternal(newRqst);
// 4) Populate the cache
List<ColumnStatisticsObj> newColStats = loadTableColumnStatisticsCache(cache, r, rqst, null);
// 5) Sort result (in case there is any assumption) and return
return computeTableColumnStatisticsFinal(rqst, colStats, newColStats);
}
return super.getTableColumnStatisticsInternal(rqst);
}
use of org.apache.hadoop.hive.metastore.api.TableStatsRequest in project hive by apache.
the class HiveMetaStoreClientWithLocalCache method getTableColumnStatisticsInternal.
@Override
protected TableStatsResult getTableColumnStatisticsInternal(TableStatsRequest req) throws TException {
if (isCacheEnabledAndInitialized()) {
TableWatermark watermark = new TableWatermark(getValidWriteIdList(req.getDbName(), req.getTblName()), getTable(req.getDbName(), req.getTblName()).getId());
if (watermark.isValid()) {
CacheWrapper cache = new CacheWrapper(mscLocalCache);
// 1) Retrieve from the cache those ids present, gather the rest
Pair<List<ColumnStatisticsObj>, List<String>> p = getTableColumnStatisticsCache(cache, req, watermark);
List<String> colStatsMissing = p.getRight();
List<ColumnStatisticsObj> colStats = p.getLeft();
// 2) If they were all present in the cache, return
if (colStatsMissing.isEmpty()) {
return new TableStatsResult(colStats);
}
// 3) If they were not, gather the remaining
TableStatsRequest newRqst = new TableStatsRequest(req);
newRqst.setColNames(colStatsMissing);
TableStatsResult r = super.getTableColumnStatisticsInternal(newRqst);
// 4) Populate the cache
List<ColumnStatisticsObj> newColStats = loadTableColumnStatisticsCache(cache, r, req, watermark);
// 5) Sort result (in case there is any assumption) and return
TableStatsResult result = computeTableColumnStatisticsFinal(req, colStats, newColStats);
if (LOG.isDebugEnabled() && recordStats) {
LOG.debug(cacheObjName + ": " + mscLocalCache.stats().toString());
}
return result;
}
}
return super.getTableColumnStatisticsInternal(req);
}
Aggregations