public interface CacheStrategy<T,CacheType,QueryType extends Query<T>>
QueryToolChest.getCacheStrategy(QueryType).| Modifier and Type | Interface and Description |
|---|---|
static interface |
CacheStrategy.AddToResultFunction |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
computeCacheKey(QueryType query)
Computes the per-segment cache key for the given query.
|
byte[] |
computeResultLevelCacheKey(QueryType query)
Computes the result-level cache key for the given query.
|
static void |
fetchAggregatorsFromCache(List<AggregatorFactory> aggregators,
Iterator<Object> resultIter,
boolean isResultLevelCache,
CacheStrategy.AddToResultFunction addToResultFunction)
Helper function used by TopN, GroupBy, Timeseries queries in
pullFromCache(boolean). |
com.fasterxml.jackson.core.type.TypeReference<CacheType> |
getCacheObjectClazz()
Returns the class type of what is used in the cache
|
boolean |
isCacheable(QueryType query,
boolean willMergeRunners)
Returns whether the given query is cacheable or not.
|
com.google.common.base.Function<T,CacheType> |
prepareForCache(boolean isResultLevelCache)
Returns a function that converts from the QueryType's result type to something cacheable.
|
default com.google.common.base.Function<T,CacheType> |
prepareForSegmentLevelCache() |
com.google.common.base.Function<CacheType,T> |
pullFromCache(boolean isResultLevelCache)
A function that does the inverse of the operation that the function prepareForCache returns
|
default com.google.common.base.Function<CacheType,T> |
pullFromSegmentLevelCache() |
boolean isCacheable(QueryType query, boolean willMergeRunners)
willMergeRunners parameter can be used for distinguishing the caller is a broker or a data node.query - the query to be cachedwillMergeRunners - indicates that QueryRunnerFactory.mergeRunners(QueryProcessingPool, Iterable) will be
called on the cached by-segment resultsbyte[] computeCacheKey(QueryType query)
QueryRunnerFactory.createRunner(org.apache.druid.segment.Segment)).query - the query to be cachedbyte[] computeResultLevelCacheKey(QueryType query)
computeCacheKey(QueryType) for the
same query.query - the query to be cachedcom.fasterxml.jackson.core.type.TypeReference<CacheType> getCacheObjectClazz()
com.google.common.base.Function<T,CacheType> prepareForCache(boolean isResultLevelCache)
The resulting function must be thread-safe.
isResultLevelCache - indicates whether the function is invoked for result-level caching or segment-level cachingcom.google.common.base.Function<CacheType,T> pullFromCache(boolean isResultLevelCache)
isResultLevelCache - indicates whether the function is invoked for result-level caching or segment-level cachingdefault com.google.common.base.Function<T,CacheType> prepareForSegmentLevelCache()
default com.google.common.base.Function<CacheType,T> pullFromSegmentLevelCache()
static void fetchAggregatorsFromCache(List<AggregatorFactory> aggregators, Iterator<Object> resultIter, boolean isResultLevelCache, CacheStrategy.AddToResultFunction addToResultFunction)
pullFromCache(boolean).
When using the result level cache, the agg values seen here are
finalized values generated by AggregatorFactory.finalizeComputation().
These finalized values are deserialized from the cache as generic Objects, which will
later be reserialized and returned to the user without further modification.
Because the agg values are deserialized as generic Objects, the values are subject to the same
type consistency issues handled by DimensionHandlerUtils.convertObjectToType() in the pullFromCache implementations
for dimension values (e.g., a Float would become Double).Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.