Package org.apache.druid.query
Class QueryContext
java.lang.Object
org.apache.druid.query.QueryContext
Immutable holder for query context parameters with typed access methods.
Code builds up a map of context values from serialization or during
planning. Once that map is handed to the
QueryContext, that map
is effectively immutable.
The implementation uses a TreeMap so that the serialized form of a query
lists context values in a deterministic order. Jackson will call
getContext() on the query, which will call asMap() here,
which returns the sorted TreeMap.
The TreeMap is a mutable class. We'd prefer an immutable class, but
we can choose either ordering or immutability. Since the semantics of the context
is that it is immutable once it is placed in a query. Code should NEVER get the
context map from a query and modify it, even if the actual implementation
allows it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowReturnPartialResults(boolean defaultValue) asMap()booleancontainsKey(String key) Check if the given key is set.static QueryContextempty()booleanReturn a value as a genericObject, returningnullif the context value is not set.getBoolean(String key) Return a value as anBoolean, returning {@link null} if the context value is not set.booleangetBoolean(String key, boolean defaultValue) Return a value as anboolean, returning the default value if the context value is not set.longbooleanbooleanbooleanbooleanbooleanboolean<E extends Enum<E>>
EReturn a value as anFloat, returning {@link null} if the context value is not set.floatReturn a value as anfloat, returning the default value if the context value is not set.booleanReturns true ifQueryContexts.CTX_FULL_REPORTis set to true, false if it is set to false or not set.getGranularity(String key, com.fasterxml.jackson.databind.ObjectMapper jsonMapper) getHumanReadableBytes(String key, long defaultBytes) getHumanReadableBytes(String key, HumanReadableBytes defaultValue) intAt or above this threshold, when converting the SEARCH operator to a native expression, use the "scalar_in_array" function rather than a sequence of equals (==) separated by or (||).intAt or above this threshold number of values, when planning SQL queries, use the SQL SCALAR_IN_ARRAY operator rather than a stack of SQL ORs.intintgetInSubQueryThreshold(int defaultValue) Return a value as anInteger, returning {@link null} if the context value is not set.intReturn a value as anint, returning the default value if the context value is not set.longgetLane()Return a value as anLong, returning {@link null} if the context value is not set.longReturn a value as anlong, returning the default value if the context value is not set.longgetMaxQueuedBytes(long defaultValue) longgetMaxSubqueryMemoryBytes(String defaultMemoryBytes) intgetMaxSubqueryRows(int defaultSize) intgetNumRetriesOnMissingSegments(int defaultValue) intgetParallelMergeInitialYieldRows(int defaultValue) intgetParallelMergeParallelism(int defaultValue) intgetParallelMergeSmallBatchRows(int defaultValue) longlonggetPerSegmentTimeout(long defaultPerSegmentTimeout) intintgetPriority(int defaultValue) Return a value as anString, returning {@link null} if the context value is not set.longlonggetTimeout(long defaultTimeout) intintgetUncoveredIntervalsLimit(int defaultValue) getVectorize(QueryContexts.Vectorize defaultValue) getVectorizeVirtualColumns(QueryContexts.Vectorize defaultValue) intintgetVectorSize(int defaultSize) inthashCode()booleanbooleanbooleanisBySegment(boolean defaultValue) booleanbooleanisDebug()booleanbooleanisEmpty()booleanbooleanisFinalize(boolean defaultValue) booleanbooleanisPopulateCache(boolean defaultValue) booleanbooleanisPopulateResultLevelCache(boolean defaultValue) booleanbooleanbooleanbooleanisSerializeDateTimeAsLong(boolean defaultValue) booleanisSerializeDateTimeAsLongInner(boolean defaultValue) booleanbooleanbooleanisUseCache(boolean defaultValue) booleanbooleanisUseNestedForUnknownTypeInSubquery(boolean defaultUseNestedForUnkownTypeInSubquery) booleanbooleanisUseResultLevelCache(boolean defaultValue) static QueryContextoverride(QueryContext queryContext) toString()booleanvoidverifyMaxQueryTimeout(long maxQueryTimeout) voidverifyMaxScatterGatherBytes(long maxScatterGatherBytesLimit)
-
Constructor Details
-
QueryContext
-
-
Method Details
-
empty
-
of
-
isEmpty
public boolean isEmpty() -
asMap
-
containsKey
Check if the given key is set. If the client will then fetch the value, consider using one of theget<Type>(String key)methods instead: they each returnnullif the value is not set. -
get
Return a value as a genericObject, returningnullif the context value is not set. -
getString
Return a value as anString, returning {@link null} if the context value is not set.- Throws:
BadQueryContextException- for an invalid value
-
getString
-
getBoolean
Return a value as anBoolean, returning {@link null} if the context value is not set.- Throws:
BadQueryContextException- for an invalid value
-
getBoolean
Return a value as anboolean, returning the default value if the context value is not set.- Throws:
BadQueryContextException- for an invalid value
-
getInt
Return a value as anInteger, returning {@link null} if the context value is not set.- Throws:
BadQueryContextException- for an invalid value
-
getInt
Return a value as anint, returning the default value if the context value is not set.- Throws:
BadQueryContextException- for an invalid value
-
getLong
Return a value as anLong, returning {@link null} if the context value is not set.- Throws:
BadQueryContextException- for an invalid value
-
getLong
Return a value as anlong, returning the default value if the context value is not set.- Throws:
BadQueryContextException- for an invalid value
-
getFloat
Return a value as anFloat, returning {@link null} if the context value is not set.- Throws:
BadQueryContextException- for an invalid value
-
getFloat
Return a value as anfloat, returning the default value if the context value is not set.- Throws:
BadQueryContextException- for an invalid value
-
getHumanReadableBytes
-
getHumanReadableBytes
-
getEnum
-
getGranularity
public Granularity getGranularity(String key, com.fasterxml.jackson.databind.ObjectMapper jsonMapper) -
isDebug
public boolean isDebug() -
isBySegment
public boolean isBySegment() -
isBySegment
public boolean isBySegment(boolean defaultValue) -
isPopulateCache
public boolean isPopulateCache() -
isPopulateCache
public boolean isPopulateCache(boolean defaultValue) -
isUseCache
public boolean isUseCache() -
isUseCache
public boolean isUseCache(boolean defaultValue) -
isPopulateResultLevelCache
public boolean isPopulateResultLevelCache() -
isPopulateResultLevelCache
public boolean isPopulateResultLevelCache(boolean defaultValue) -
isUseResultLevelCache
public boolean isUseResultLevelCache() -
isUseResultLevelCache
public boolean isUseResultLevelCache(boolean defaultValue) -
isFinalize
public boolean isFinalize(boolean defaultValue) -
isSerializeDateTimeAsLong
public boolean isSerializeDateTimeAsLong(boolean defaultValue) -
isSerializeDateTimeAsLongInner
public boolean isSerializeDateTimeAsLongInner(boolean defaultValue) -
getVectorize
-
getVectorize
-
getVectorizeVirtualColumns
-
getVectorizeVirtualColumns
-
getVectorSize
public int getVectorSize() -
getVectorSize
public int getVectorSize(int defaultSize) -
getMaxSubqueryRows
public int getMaxSubqueryRows(int defaultSize) -
getMaxSubqueryMemoryBytes
-
isUseNestedForUnknownTypeInSubquery
public boolean isUseNestedForUnknownTypeInSubquery(boolean defaultUseNestedForUnkownTypeInSubquery) -
isUseNestedForUnknownTypeInSubquery
public boolean isUseNestedForUnknownTypeInSubquery() -
getUncoveredIntervalsLimit
public int getUncoveredIntervalsLimit() -
getUncoveredIntervalsLimit
public int getUncoveredIntervalsLimit(int defaultValue) -
getPriority
public int getPriority() -
getPriority
public int getPriority(int defaultValue) -
getLane
-
getEnableParallelMerges
public boolean getEnableParallelMerges() -
getParallelMergeInitialYieldRows
public int getParallelMergeInitialYieldRows(int defaultValue) -
getParallelMergeSmallBatchRows
public int getParallelMergeSmallBatchRows(int defaultValue) -
getParallelMergeParallelism
public int getParallelMergeParallelism(int defaultValue) -
getJoinFilterRewriteMaxSize
public long getJoinFilterRewriteMaxSize() -
getEnableJoinFilterPushDown
public boolean getEnableJoinFilterPushDown() -
getEnableJoinFilterRewrite
public boolean getEnableJoinFilterRewrite() -
isSecondaryPartitionPruningEnabled
public boolean isSecondaryPartitionPruningEnabled() -
getMaxQueuedBytes
public long getMaxQueuedBytes(long defaultValue) -
getMaxScatterGatherBytes
public long getMaxScatterGatherBytes() -
getEngine
-
hasTimeout
public boolean hasTimeout() -
getTimeout
public long getTimeout() -
getTimeout
public long getTimeout(long defaultTimeout) -
getTimeoutDuration
-
getDefaultTimeout
public long getDefaultTimeout() -
verifyMaxQueryTimeout
public void verifyMaxQueryTimeout(long maxQueryTimeout) -
getPerSegmentTimeout
public long getPerSegmentTimeout() -
getPerSegmentTimeout
public long getPerSegmentTimeout(long defaultPerSegmentTimeout) -
usePerSegmentTimeout
public boolean usePerSegmentTimeout() -
verifyMaxScatterGatherBytes
public void verifyMaxScatterGatherBytes(long maxScatterGatherBytesLimit) -
getNumRetriesOnMissingSegments
public int getNumRetriesOnMissingSegments(int defaultValue) -
allowReturnPartialResults
public boolean allowReturnPartialResults(boolean defaultValue) -
getEnableJoinFilterRewriteValueColumnFilters
public boolean getEnableJoinFilterRewriteValueColumnFilters() -
getCloneQueryMode
-
getEnableRewriteJoinToFilter
public boolean getEnableRewriteJoinToFilter() -
getEnableJoinLeftScanDirect
public boolean getEnableJoinLeftScanDirect() -
getInSubQueryThreshold
public int getInSubQueryThreshold() -
getInSubQueryThreshold
public int getInSubQueryThreshold(int defaultValue) -
getInFunctionThreshold
public int getInFunctionThreshold()At or above this threshold number of values, when planning SQL queries, use the SQL SCALAR_IN_ARRAY operator rather than a stack of SQL ORs. This speeds up planning for large sets of points because it is opaque to various expensive optimizations. But, because this does bypass certain optimizations, we only do the transformation above a certain threshold. The SCALAR_IN_ARRAY operator is still able to convert toInDimFilterorTypedInFilter. -
getInFunctionExprThreshold
public int getInFunctionExprThreshold()At or above this threshold, when converting the SEARCH operator to a native expression, use the "scalar_in_array" function rather than a sequence of equals (==) separated by or (||). This is typically a lower threshold thangetInFunctionThreshold(), because it does not prevent any SQL planning optimizations, and it speeds up query execution. -
isTimeBoundaryPlanningEnabled
public boolean isTimeBoundaryPlanningEnabled() -
isCatalogValidationEnabled
public boolean isCatalogValidationEnabled() -
isExtendedFilteredSumRewrite
public boolean isExtendedFilteredSumRewrite() -
getFullReport
public boolean getFullReport()Returns true ifQueryContexts.CTX_FULL_REPORTis set to true, false if it is set to false or not set. -
getQueryResourceId
-
getBrokerServiceName
-
equals
-
hashCode
public int hashCode() -
toString
-
isDecoupledMode
public boolean isDecoupledMode() -
override
-
override
-
isPrePlanned
public boolean isPrePlanned() -
isRealtimeSegmentsOnly
public boolean isRealtimeSegmentsOnly()
-