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 String
QUERY_ID
static String
SQL_QUERY_ID
static String
SUB_QUERY_ID
-
Fields inherited from interface org.apache.druid.query.Query
DATASOURCE_METADATA, GROUP_BY, SCAN, SEARCH, SEGMENT_METADATA, SELECT, TIME_BOUNDARY, TIMESERIES, TOPN, UNION_QUERY, WINDOW_OPERATOR
-
-
Constructor Summary
Constructors Constructor Description BaseQuery(DataSource dataSource, QuerySegmentSpec querySegmentSpec, Map<String,Object> context)
BaseQuery(DataSource dataSource, QuerySegmentSpec querySegmentSpec, Map<String,Object> context, Granularity granularity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
checkInterrupted()
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.QueryContext
context()
Returns the query context as aQueryContext
, which provides convenience methods for accessing typed context values.boolean
equals(Object o)
Map<String,Object>
getContext()
Returns the context as an (immutable) map.DataSource
getDataSource()
org.joda.time.Duration
getDuration()
Granularity
getGranularity()
String
getId()
List<org.joda.time.Interval>
getIntervals()
QuerySegmentSpec
getQuerySegmentSpec()
static QuerySegmentSpec
getQuerySegmentSpecForLookUp(BaseQuery<?> query)
com.google.common.collect.Ordering<T>
getResultOrdering()
Default implementation ofQuery.getResultOrdering()
that usesOrdering.natural()
.QueryRunner<T>
getRunner(QuerySegmentWalker walker)
String
getSubQueryId()
Returns the subQueryId of this query.org.joda.time.DateTimeZone
getTimezone()
int
hashCode()
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, getDataSourceAnalysis, getFilter, getMostSpecificId, getRequiredColumns, getResultRowSignature, getResultRowSignature, getSingleInterval, 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, Map<String,Object> context)
-
BaseQuery
public BaseQuery(DataSource dataSource, QuerySegmentSpec querySegmentSpec, Map<String,Object> context, Granularity granularity)
-
-
Method Detail
-
checkInterrupted
public static void checkInterrupted()
-
getDataSource
public DataSource getDataSource()
- Specified by:
getDataSource
in 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:
getIntervals
in interfaceQuery<T>
-
getDuration
public org.joda.time.Duration getDuration()
- Specified by:
getDuration
in interfaceQuery<T>
-
getGranularity
public Granularity getGranularity()
- Specified by:
getGranularity
in interfaceQuery<T>
-
getTimezone
public org.joda.time.DateTimeZone getTimezone()
- Specified by:
getTimezone
in interfaceQuery<T>
-
getContext
public Map<String,Object> getContext()
Description copied from interface:Query
Returns the context as an (immutable) map.- Specified by:
getContext
in interfaceQuery<T>
-
context
public QueryContext context()
Description copied from interface:Query
Returns 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
QueryContext
directly.
-
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:
getResultOrdering
in interfaceQuery<T>
-
withSubQueryId
public Query<T> withSubQueryId(String subQueryId)
Description copied from interface:Query
Returns a copy of this query with a new subQueryId (seeQuery.getSubQueryId()
.- Specified by:
withSubQueryId
in interfaceQuery<T>
-
getSubQueryId
@Nullable public String getSubQueryId()
Description copied from interface:Query
Returns 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:
getSubQueryId
in interfaceQuery<T>
-
withSqlQueryId
public Query<T> withSqlQueryId(String sqlQueryId)
- Specified by:
withSqlQueryId
in interfaceQuery<T>
-
-