Package org.apache.druid.query
Class BaseQuery<T>
- java.lang.Object
-
- org.apache.druid.query.BaseQuery<T>
-
- All Implemented Interfaces:
Query<T>
- Direct Known Subclasses:
DataSourceMetadataQuery,GroupByQuery,ScanQuery,SearchQuery,SegmentMetadataQuery,TimeBoundaryQuery,TimeseriesQuery,TopNQuery,WindowOperatorQuery
public abstract class BaseQuery<T> extends Object implements Query<T>
-
-
Field Summary
Fields Modifier and Type Field Description static StringQUERY_IDstatic StringSQL_QUERY_IDstatic StringSUB_QUERY_ID-
Fields inherited from interface org.apache.druid.query.Query
DATASOURCE_METADATA, GROUP_BY, SCAN, SEARCH, SEGMENT_METADATA, SELECT, TIME_BOUNDARY, TIMESERIES, TOPN, WINDOW_OPERATOR
-
-
Constructor Summary
Constructors Constructor Description BaseQuery(DataSource dataSource, QuerySegmentSpec querySegmentSpec, boolean descending, Map<String,Object> context)BaseQuery(DataSource dataSource, QuerySegmentSpec querySegmentSpec, boolean descending, Map<String,Object> context, Granularity granularity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidcheckInterrupted()static Map<String,Object>computeOverriddenContext(Map<String,Object> context, Map<String,Object> overrides)protected Map<String,Object>computeOverridenContext(Map<String,Object> overrides)Deprecated.usecomputeOverriddenContext(getContext(), overrides))instead.QueryContextcontext()Returns the query context as aQueryContext, which provides convenience methods for accessing typed context values.booleanequals(Object o)Map<String,Object>getContext()Returns the context as an (immutable) map.DataSourcegetDataSource()org.joda.time.DurationgetDuration()GranularitygetGranularity()StringgetId()List<org.joda.time.Interval>getIntervals()QuerySegmentSpecgetQuerySegmentSpec()static QuerySegmentSpecgetQuerySegmentSpecForLookUp(BaseQuery<?> query)com.google.common.collect.Ordering<T>getResultOrdering()Default implementation ofQuery.getResultOrdering()that usesOrdering.natural().QueryRunner<T>getRunner(QuerySegmentWalker walker)StringgetSubQueryId()Returns the subQueryId of this query.org.joda.time.DateTimeZonegetTimezone()inthashCode()booleanisDescending()Query<T>withId(String id)Query<T>withSqlQueryId(String sqlQueryId)Query<T>withSubQueryId(String subQueryId)Returns a copy of this query with a new subQueryId (seeQuery.getSubQueryId().-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.query.Query
getContextBoolean, getContextHumanReadableBytes, getContextValue, getFilter, getMostSpecificId, getRequiredColumns, getSqlQueryId, getType, getVirtualColumns, hasFilters, optimizeForSegment, withDataSource, withDefaultSubQueryId, withLane, withOverriddenContext, withPriority, withQuerySegmentSpec
-
-
-
-
Field Detail
-
QUERY_ID
public static final String QUERY_ID
- See Also:
- Constant Field Values
-
SUB_QUERY_ID
public static final String SUB_QUERY_ID
- See Also:
- Constant Field Values
-
SQL_QUERY_ID
public static final String SQL_QUERY_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BaseQuery
public BaseQuery(DataSource dataSource, QuerySegmentSpec querySegmentSpec, boolean descending, Map<String,Object> context)
-
BaseQuery
public BaseQuery(DataSource dataSource, QuerySegmentSpec querySegmentSpec, boolean descending, Map<String,Object> context, Granularity granularity)
-
-
Method Detail
-
checkInterrupted
public static void checkInterrupted()
-
getDataSource
public DataSource getDataSource()
- Specified by:
getDataSourcein interfaceQuery<T>
-
isDescending
public boolean isDescending()
- Specified by:
isDescendingin interfaceQuery<T>
-
getQuerySegmentSpec
public QuerySegmentSpec getQuerySegmentSpec()
-
getRunner
public QueryRunner<T> getRunner(QuerySegmentWalker walker)
-
getQuerySegmentSpecForLookUp
public static QuerySegmentSpec getQuerySegmentSpecForLookUp(BaseQuery<?> query)
-
getIntervals
public List<org.joda.time.Interval> getIntervals()
- Specified by:
getIntervalsin interfaceQuery<T>
-
getDuration
public org.joda.time.Duration getDuration()
- Specified by:
getDurationin interfaceQuery<T>
-
getGranularity
public Granularity getGranularity()
- Specified by:
getGranularityin interfaceQuery<T>
-
getTimezone
public org.joda.time.DateTimeZone getTimezone()
- Specified by:
getTimezonein interfaceQuery<T>
-
getContext
public Map<String,Object> getContext()
Description copied from interface:QueryReturns the context as an (immutable) map.- Specified by:
getContextin interfaceQuery<T>
-
context
public QueryContext context()
Description copied from interface:QueryReturns the query context as aQueryContext, which provides convenience methods for accessing typed context values. The returned instance is a view on top of the context provided byQuery.getContext().The default implementation is for backward compatibility. Derived classes should store and return the
QueryContextdirectly.
-
computeOverridenContext
@Deprecated protected Map<String,Object> computeOverridenContext(Map<String,Object> overrides)
Deprecated.usecomputeOverriddenContext(getContext(), overrides))instead. This method may be removed in the next minor or major version of Druid.
-
computeOverriddenContext
public static Map<String,Object> computeOverriddenContext(Map<String,Object> context, Map<String,Object> overrides)
-
getResultOrdering
public com.google.common.collect.Ordering<T> getResultOrdering()
Default implementation ofQuery.getResultOrdering()that usesOrdering.natural(). If your query result type T is not Comparable, you must override this method.- Specified by:
getResultOrderingin interfaceQuery<T>
-
withSubQueryId
public Query<T> withSubQueryId(String subQueryId)
Description copied from interface:QueryReturns a copy of this query with a new subQueryId (seeQuery.getSubQueryId().- Specified by:
withSubQueryIdin interfaceQuery<T>
-
getSubQueryId
@Nullable public String getSubQueryId()
Description copied from interface:QueryReturns the subQueryId of this query. This is set by ClientQuerySegmentWalker (the entry point for the Broker's query stack) on any subqueries that it issues. It is null for the main query.- Specified by:
getSubQueryIdin interfaceQuery<T>
-
withSqlQueryId
public Query<T> withSqlQueryId(String sqlQueryId)
- Specified by:
withSqlQueryIdin interfaceQuery<T>
-
-