Search in sources :

Example 1 with TableStatsResult

use of org.apache.hadoop.hive.metastore.api.TableStatsResult 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);
}
Also used : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) TableStatsResult(org.apache.hadoop.hive.metastore.api.TableStatsResult) ArrayList(java.util.ArrayList) ValidTxnWriteIdList(org.apache.hadoop.hive.common.ValidTxnWriteIdList) ValidTxnList(org.apache.hadoop.hive.common.ValidTxnList) ValidWriteIdList(org.apache.hadoop.hive.common.ValidWriteIdList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) TableStatsRequest(org.apache.hadoop.hive.metastore.api.TableStatsRequest)

Example 2 with TableStatsResult

use of org.apache.hadoop.hive.metastore.api.TableStatsResult 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);
}
Also used : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) TableStatsResult(org.apache.hadoop.hive.metastore.api.TableStatsResult) List(java.util.List) ArrayList(java.util.ArrayList) TableStatsRequest(org.apache.hadoop.hive.metastore.api.TableStatsRequest)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 ColumnStatisticsObj (org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj)2 TableStatsRequest (org.apache.hadoop.hive.metastore.api.TableStatsRequest)2 TableStatsResult (org.apache.hadoop.hive.metastore.api.TableStatsResult)2 ImmutableList (com.google.common.collect.ImmutableList)1 ValidTxnList (org.apache.hadoop.hive.common.ValidTxnList)1 ValidTxnWriteIdList (org.apache.hadoop.hive.common.ValidTxnWriteIdList)1 ValidWriteIdList (org.apache.hadoop.hive.common.ValidWriteIdList)1