Package org.apache.druid.query.topn
Class TopNQuery
- java.lang.Object
-
- org.apache.druid.query.BaseQuery<Result<TopNResultValue>>
-
- org.apache.druid.query.topn.TopNQuery
-
- All Implemented Interfaces:
Query<Result<TopNResultValue>>
public class TopNQuery extends BaseQuery<Result<TopNResultValue>>
-
-
Field Summary
Fields Modifier and Type Field Description static String
TOPN
-
Fields inherited from class org.apache.druid.query.BaseQuery
QUERY_ID, SQL_QUERY_ID, SUB_QUERY_ID
-
Fields inherited from interface org.apache.druid.query.Query
DATASOURCE_METADATA, GROUP_BY, SCAN, SEARCH, SEGMENT_METADATA, SELECT, TIME_BOUNDARY, TIMESERIES, WINDOW_OPERATOR
-
-
Constructor Summary
Constructors Constructor Description TopNQuery(DataSource dataSource, VirtualColumns virtualColumns, DimensionSpec dimensionSpec, TopNMetricSpec topNMetricSpec, int threshold, QuerySegmentSpec querySegmentSpec, DimFilter dimFilter, Granularity granularity, List<AggregatorFactory> aggregatorSpecs, List<PostAggregator> postAggregatorSpecs, Map<String,Object> context)
-
Method Summary
-
Methods inherited from class org.apache.druid.query.BaseQuery
checkInterrupted, computeOverriddenContext, computeOverridenContext, context, getContext, getDataSource, getDuration, getGranularity, getId, getIntervals, getQuerySegmentSpec, getQuerySegmentSpecForLookUp, getResultOrdering, getRunner, getSubQueryId, getTimezone, isDescending, withId, withSqlQueryId, withSubQueryId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.druid.query.Query
getContextBoolean, getContextHumanReadableBytes, getContextValue, getMostSpecificId, getSqlQueryId, withDefaultSubQueryId, withLane, withPriority
-
-
-
-
Field Detail
-
TOPN
public static final String TOPN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TopNQuery
public TopNQuery(DataSource dataSource, VirtualColumns virtualColumns, DimensionSpec dimensionSpec, TopNMetricSpec topNMetricSpec, int threshold, QuerySegmentSpec querySegmentSpec, DimFilter dimFilter, Granularity granularity, List<AggregatorFactory> aggregatorSpecs, List<PostAggregator> postAggregatorSpecs, Map<String,Object> context)
-
-
Method Detail
-
hasFilters
public boolean hasFilters()
-
getFilter
public DimFilter getFilter()
-
getType
public String getType()
-
getVirtualColumns
public VirtualColumns getVirtualColumns()
-
getDimensionSpec
public DimensionSpec getDimensionSpec()
-
getTopNMetricSpec
public TopNMetricSpec getTopNMetricSpec()
-
getThreshold
public int getThreshold()
-
getAggregatorSpecs
public List<AggregatorFactory> getAggregatorSpecs()
-
getPostAggregatorSpecs
public List<PostAggregator> getPostAggregatorSpecs()
-
getRequiredColumns
@Nullable public Set<String> getRequiredColumns()
Description copied from interface:Query
Returns the set of columns that this query will need to access out of its datasource. This method does not "look into" what the datasource itself is doing. For example, if a query is built on aQueryDataSource
, this method will not return the columns used by that subquery. As another example, if a query is built on aJoinDataSource
, this method will not return the columns from the underlying datasources that are used by the join condition, unless those columns are also used by this query in other ways. Returns null if the set of required columns cannot be known ahead of time.
-
initTopNAlgorithmSelector
public void initTopNAlgorithmSelector(TopNAlgorithmSelector selector)
-
withQuerySegmentSpec
public TopNQuery withQuerySegmentSpec(QuerySegmentSpec querySegmentSpec)
Description copied from interface:Query
Returns a new query, identical to this one, but with a different associatedQuerySegmentSpec
. This often changes the behavior ofQuery.getRunner(QuerySegmentWalker)
, since most queries inherit that method fromBaseQuery
, which implements it by callingQuerySegmentSpec.lookup(org.apache.druid.query.Query<T>, org.apache.druid.query.QuerySegmentWalker)
.
-
withDimensionSpec
public TopNQuery withDimensionSpec(DimensionSpec spec)
-
withAggregatorSpecs
public TopNQuery withAggregatorSpecs(List<AggregatorFactory> aggregatorSpecs)
-
withPostAggregatorSpecs
public TopNQuery withPostAggregatorSpecs(List<PostAggregator> postAggs)
-
withDataSource
public Query<Result<TopNResultValue>> withDataSource(DataSource dataSource)
-
optimizeForSegment
public Query<Result<TopNResultValue>> optimizeForSegment(PerSegmentQueryOptimizationContext optimizationContext)
-
withThreshold
public TopNQuery withThreshold(int threshold)
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classBaseQuery<Result<TopNResultValue>>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBaseQuery<Result<TopNResultValue>>
-
-