public abstract class QueryToolChest<ResultType,QueryType extends Query<ResultType>> extends Object
Constructor and Description |
---|
QueryToolChest() |
Modifier and Type | Method and Description |
---|---|
<T extends LogicalSegment> |
filterSegments(QueryType query,
List<T> segments)
This method is called to allow the query to prune segments that it does not believe need to actually
be queried.
|
<T> CacheStrategy<ResultType,T,QueryType> |
getCacheStrategy(QueryType query)
Returns a CacheStrategy to be used to load data into the cache and remove it from the cache.
|
abstract com.fasterxml.jackson.core.type.TypeReference<ResultType> |
getResultTypeReference()
Returns a TypeReference object that is just passed through to Jackson in order to deserialize
the results of this type of query.
|
abstract com.metamx.emitter.service.ServiceMetricEvent.Builder |
makeMetricBuilder(QueryType query)
Creates a builder that is used to generate a metric for this specific query type.
|
com.google.common.base.Function<ResultType,ResultType> |
makePostComputeManipulatorFn(QueryType query,
MetricManipulationFn fn)
Generally speaking this is the exact same thing as makePreComputeManipulatorFn.
|
abstract com.google.common.base.Function<ResultType,ResultType> |
makePreComputeManipulatorFn(QueryType query,
MetricManipulationFn fn)
Creates a Function that can take in a ResultType and return a new ResultType having applied
the MetricManipulatorFn to each of the metrics.
|
abstract QueryRunner<ResultType> |
mergeResults(QueryRunner<ResultType> runner)
This method wraps a QueryRunner.
|
QueryRunner<ResultType> |
postMergeQueryDecoration(QueryRunner<ResultType> runner)
Wraps a QueryRunner.
|
QueryRunner<ResultType> |
preMergeQueryDecoration(QueryRunner<ResultType> runner)
Wraps a QueryRunner.
|
public abstract QueryRunner<ResultType> mergeResults(QueryRunner<ResultType> runner)
runner
- A QueryRunner that provides a series of ResultType objects in time order (ascending or descending)public abstract com.metamx.emitter.service.ServiceMetricEvent.Builder makeMetricBuilder(QueryType query)
query
- The query that is being processedpublic abstract com.google.common.base.Function<ResultType,ResultType> makePreComputeManipulatorFn(QueryType query, MetricManipulationFn fn)
This exists because the QueryToolChest is the only thing that understands the internal serialization format of ResultType, so it's primary responsibility is to "decompose" that structure and apply the given function to all metrics.
This function is called very early in the processing pipeline on the Broker.
query
- The Query that is currently being processedfn
- The function that should be applied to all metrics in the resultspublic com.google.common.base.Function<ResultType,ResultType> makePostComputeManipulatorFn(QueryType query, MetricManipulationFn fn)
This should never actually be overridden and it should be removed as quickly as possible.
query
- The Query that is currently being processedfn
- The function that should be applied to all metrics in the resultspublic abstract com.fasterxml.jackson.core.type.TypeReference<ResultType> getResultTypeReference()
public <T> CacheStrategy<ResultType,T,QueryType> getCacheStrategy(QueryType query)
This is optional. If it returns null, caching is effectively disabled for the query.
T
- The type of object that will be stored in the cachequery
- The query whose results might be cachedpublic QueryRunner<ResultType> preMergeQueryDecoration(QueryRunner<ResultType> runner)
In fact, the return value of this method is always passed to mergeResults, so it is equivalent to just implement this functionality as extra decoration on the QueryRunner during mergeResults().
In the interests of potentially simplifying these interfaces, the recommendation is to actually not override this method and instead apply anything that might be needed here in the mergeResults() call.
runner
- The runner to be wrappedpublic QueryRunner<ResultType> postMergeQueryDecoration(QueryRunner<ResultType> runner)
In fact, the input value of this method is always the return value from mergeResults, so it is equivalent to just implement this functionality as extra decoration on the QueryRunner during mergeResults().
In the interests of potentially simplifying these interfaces, the recommendation is to actually not override this method and instead apply anything that might be needed here in the mergeResults() call.
runner
- The runner to be wrappedpublic <T extends LogicalSegment> List<T> filterSegments(QueryType query, List<T> segments)
T
- A Generic parameter because Java is coolquery
- The query being processedsegments
- The list of candidate segments to be queriedCopyright © 2011–2017. All rights reserved.