Search in sources :

Example 1 with CacheEntry

use of org.apache.hadoop.hive.ql.cache.results.QueryResultsCache.CacheEntry in project hive by apache.

the class Driver method postExecutionCacheActions.

private void postExecutionCacheActions() throws Exception {
    if (cacheUsage != null) {
        if (cacheUsage.getStatus() == CacheUsage.CacheStatus.QUERY_USING_CACHE) {
            // Using a previously cached result.
            CacheEntry cacheEntry = cacheUsage.getCacheEntry();
            // Reader count already incremented during cache lookup.
            // Save to usedCacheEntry to ensure reader is released after query.
            this.usedCacheEntry = cacheEntry;
        } else if (cacheUsage.getStatus() == CacheUsage.CacheStatus.CAN_CACHE_QUERY_RESULTS && cacheUsage.getCacheEntry() != null && plan.getFetchTask() != null) {
            // Save results to the cache for future queries to use.
            PerfLogger perfLogger = SessionState.getPerfLogger();
            perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.SAVE_TO_RESULTS_CACHE);
            boolean savedToCache = QueryResultsCache.getInstance().setEntryValid(cacheUsage.getCacheEntry(), plan.getFetchTask().getWork());
            LOG.info("savedToCache: {}", savedToCache);
            if (savedToCache) {
                useFetchFromCache(cacheUsage.getCacheEntry());
                // setEntryValid() already increments the reader count. Set usedCacheEntry so it gets released.
                this.usedCacheEntry = cacheUsage.getCacheEntry();
            }
            perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.SAVE_TO_RESULTS_CACHE);
        }
    }
}
Also used : PerfLogger(org.apache.hadoop.hive.ql.log.PerfLogger) CacheEntry(org.apache.hadoop.hive.ql.cache.results.QueryResultsCache.CacheEntry)

Aggregations

CacheEntry (org.apache.hadoop.hive.ql.cache.results.QueryResultsCache.CacheEntry)1 PerfLogger (org.apache.hadoop.hive.ql.log.PerfLogger)1