Class FragmentContextImpl
- All Implemented Interfaces:
AutoCloseable,ExchangeFragmentContext,ExecutorFragmentContext,FragmentContext,RootFragmentContext,UdfUtilities
FragmentContext: A context provided to non-exchange operators.ExchangeFragmentContext: A context provided to exchange operators.RootFragmentContext: A context provided to fragment roots.ExecutorFragmentContext: A context used by the Drillbit.
FragmentContext) to least restrictive
(ExecutorFragmentContext).
Since FragmentContextImpl implements all of the interfaces listed
above, the facade pattern is used in order to cast a
FragmentContextImpl object to the desired interface where-ever it is
needed. The facade pattern is powerful since it allows us to easily create
minimal context objects to be used in unit tests. Without the use of
interfaces and the facade pattern we would have to create a complete
FragmentContextImpl object to unit test any part of the code that
depends on a context.
General guideline: Use the most narrow interface for the task. For example, "internal" operators don't need visibility to the networking functionality. Using the narrow interface allows unit testing without using mocking libraries. Often, the surrounding structure already has exposed the most narrow interface. If there are opportunities to clean up older code, we can do so as needed to make testing easier.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.drill.exec.ops.FragmentContext
FragmentContext.ExecutorState -
Field Summary
Fields inherited from interface org.apache.drill.exec.ops.UdfUtilities
INJECTABLE_GETTER_METHODS -
Constructor Summary
ConstructorsConstructorDescriptionFragmentContextImpl(DrillbitContext dbContext, BitControl.PlanFragment fragment, FunctionImplementationRegistry funcRegistry) Create a FragmentContext instance for non-root fragment.FragmentContextImpl(DrillbitContext dbContext, BitControl.PlanFragment fragment, QueryContext queryContext, UserClientConnection connection, FunctionImplementationRegistry funcRegistry) Create a FragmentContext instance for root fragment.FragmentContextImpl(DrillbitContext dbContext, BitControl.PlanFragment fragment, UserClientConnection connection, FunctionImplementationRegistry funcRegistry) TODO: Remove this constructor when removing the SimpleRootExec (DRILL-2097). -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRuntimeFilter(RuntimeFilterWritable runtimeFilter) Add a RuntimeFilter when the RuntimeFilter receiver belongs to the same MinorFragment.voidclose()voidGet an instance of alias registry provider for obtaining aliases.Deprecated.getBits()protected BufferManagerReturns the Drill configuration for this run.getConstantValueHolder(String value, TypeProtos.MinorType type, com.google.common.base.Function<DrillBuf, ValueHolder> holderInitializer) Works with value holders cache which holds constant value and its wrapper by type.Get the context information such as: - query start time - root fragment timezone - query userName - system userName - default schema name in current session at the time of query.The Drillbit context allows UDFs to view storage information and other pieces of information about the running system.Return the set of execution controls used to inject faults into running code for testing.org.apache.calcite.schema.SchemaPlusThe FragmentHandle for this FragmentGet instance of Metastore registry to obtain Metastore instance if needed.getNewChildAllocator(String operatorName, int operatorId, long initialReservation, long maximumReservation) Returns a read-only version of the session options.A partition explorer allows UDFs to view the sub-partitions below a particular partition.Returns the root allocator for the Drillbit.getRuntimeFilter(long rfIdentifier) getRuntimeFilter(long rfIdentifier, long maxWaitTime, TimeUnit timeUnit) Get the RuntimeFilter with a blocking wait, if the waiting option is enabled.Returns the statement type (e.g.getStats()booleanbooleanbooleanbooleannewOperatorContext(PhysicalOperator popConfig) newOperatorContext(PhysicalOperator popConfig, OperatorStats stats) voidrequestMemory(RecordBatch requestor) An operator is experiencing memory pressure.voidsetBuffers(IncomingBuffers buffers) voidsetExecutorState(FragmentContext.ExecutorState executorState) voidMethods inherited from class org.apache.drill.exec.ops.BaseFragmentContext
getFunctionRegistry, getImplementationClass, getImplementationClass, getImplementationClass, getImplementationClass, getManagedBuffer, getManagedBuffer, getManagedBufferManager, replaceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.drill.exec.ops.FragmentContext
getFunctionRegistry, getImplementationClass, getImplementationClass, getImplementationClass, getImplementationClass, getManagedBuffer, getManagedBuffer, getManagedBufferManager, replace
-
Constructor Details
-
FragmentContextImpl
public FragmentContextImpl(DrillbitContext dbContext, BitControl.PlanFragment fragment, FunctionImplementationRegistry funcRegistry) throws ExecutionSetupException Create a FragmentContext instance for non-root fragment.- Parameters:
dbContext- DrillbitContextfragment- Fragment implementationfuncRegistry- FunctionImplementationRegistry- Throws:
ExecutionSetupException- when unable to init fragment context
-
FragmentContextImpl
public FragmentContextImpl(DrillbitContext dbContext, BitControl.PlanFragment fragment, QueryContext queryContext, UserClientConnection connection, FunctionImplementationRegistry funcRegistry) throws ExecutionSetupException Create a FragmentContext instance for root fragment.- Parameters:
dbContext- DrillbitContextfragment- Fragment implementationqueryContext- QueryContextconnection- UserClientConnectionfuncRegistry- FunctionImplementationRegistry- Throws:
ExecutionSetupException- when unable to init fragment context
-
FragmentContextImpl
public FragmentContextImpl(DrillbitContext dbContext, BitControl.PlanFragment fragment, UserClientConnection connection, FunctionImplementationRegistry funcRegistry) throws ExecutionSetupException TODO: Remove this constructor when removing the SimpleRootExec (DRILL-2097). This is kept only to avoid modifying the long list of test files.- Throws:
ExecutionSetupException
-
-
Method Details
-
getOptions
Description copied from interface:FragmentContextReturns a read-only version of the session options.- Specified by:
getOptionsin interfaceFragmentContext- Returns:
- the session options
-
getPlanReader
- Specified by:
getPlanReaderin interfaceExecutorFragmentContext
-
getClusterCoordinator
- Specified by:
getClusterCoordinatorin interfaceExecutorFragmentContext
-
setBuffers
- Specified by:
setBuffersin interfaceExecutorFragmentContext
-
getProfileStoreContext
- Specified by:
getProfileStoreContextin interfaceExecutorFragmentContext
-
getUserConnections
public Set<Map.Entry<UserServer.BitToUserConnection,UserServer.BitToUserConnectionConfig>> getUserConnections()- Specified by:
getUserConnectionsin interfaceExecutorFragmentContext
-
setExecutorState
- Specified by:
setExecutorStatein interfaceRootFragmentContext
-
fail
-
getFullRootSchema
public org.apache.calcite.schema.SchemaPlus getFullRootSchema()- Specified by:
getFullRootSchemain interfaceFragmentContext
-
getStats
- Specified by:
getStatsin interfaceRootFragmentContext
-
getBits
- Specified by:
getBitsin interfaceExecutorFragmentContext
-
getContextInformation
Description copied from interface:UdfUtilitiesGet the context information such as: - query start time - root fragment timezone - query userName - system userName - default schema name in current session at the time of query.- Specified by:
getContextInformationin interfaceUdfUtilities- Returns:
- - ContextInformation
-
getDrillbitContext
Description copied from interface:UdfUtilitiesThe Drillbit context allows UDFs to view storage information and other pieces of information about the running system. See the http_get implementation for details.- Specified by:
getDrillbitContextin interfaceUdfUtilities- Returns:
- - an object for accessing drillbit information such as storage configs.
-
getResultSetLoader
- Specified by:
getResultSetLoaderin interfaceUdfUtilities
-
getForemanEndpoint
- Specified by:
getForemanEndpointin interfaceExecutorFragmentContext
-
getEndpoint
- Specified by:
getEndpointin interfaceExecutorFragmentContext
-
getController
- Specified by:
getControllerin interfaceExchangeFragmentContext
-
getOperatorCreatorRegistry
- Specified by:
getOperatorCreatorRegistryin interfaceExecutorFragmentContext
-
getScanDecodeExecutor
- Specified by:
getScanDecodeExecutorin interfaceFragmentContext
-
getScanExecutor
- Specified by:
getScanExecutorin interfaceFragmentContext
-
getHandle
The FragmentHandle for this Fragment- Specified by:
getHandlein interfaceFragmentContext- Returns:
- FragmentHandle
-
getFragIdString
- Specified by:
getFragIdStringin interfaceFragmentContext
-
isUserAuthenticationEnabled
public boolean isUserAuthenticationEnabled()- Specified by:
isUserAuthenticationEnabledin interfaceExecutorFragmentContext
-
addRuntimeFilter
Description copied from interface:FragmentContextAdd a RuntimeFilter when the RuntimeFilter receiver belongs to the same MinorFragment.- Specified by:
addRuntimeFilterin interfaceFragmentContext- Parameters:
runtimeFilter- runtime filter
-
getRuntimeFilter
- Specified by:
getRuntimeFilterin interfaceFragmentContext
-
getRuntimeFilter
public RuntimeFilterWritable getRuntimeFilter(long rfIdentifier, long maxWaitTime, TimeUnit timeUnit) Description copied from interface:FragmentContextGet the RuntimeFilter with a blocking wait, if the waiting option is enabled.- Specified by:
getRuntimeFilterin interfaceFragmentContext- Parameters:
rfIdentifier- runtime filter identifiermaxWaitTime- max wait timetimeUnit- time unit- Returns:
- the RFW or null
-
getAllocator
Deprecated.Get this fragment's allocator.- Specified by:
getAllocatorin interfaceFragmentContext- Returns:
- the allocator
-
getRootAllocator
Description copied from interface:ExecutorFragmentContextReturns the root allocator for the Drillbit.- Specified by:
getRootAllocatorin interfaceExecutorFragmentContext
-
getNewChildAllocator
public BufferAllocator getNewChildAllocator(String operatorName, int operatorId, long initialReservation, long maximumReservation) throws OutOfMemoryException - Specified by:
getNewChildAllocatorin interfaceFragmentContext- Throws:
OutOfMemoryException
-
isOverMemoryLimit
public boolean isOverMemoryLimit() -
getCompiler
- Specified by:
getCompilerin interfaceFragmentContext
-
getUserDataTunnel
- Specified by:
getUserDataTunnelin interfaceExchangeFragmentContext
-
getDataTunnel
- Specified by:
getDataTunnelin interfaceExchangeFragmentContext
-
getBuffers
- Specified by:
getBuffersin interfaceExchangeFragmentContext
-
newOperatorContext
public OperatorContext newOperatorContext(PhysicalOperator popConfig, OperatorStats stats) throws OutOfMemoryException - Specified by:
newOperatorContextin interfaceFragmentContext- Throws:
OutOfMemoryException
-
newOperatorContext
- Specified by:
newOperatorContextin interfaceFragmentContext- Throws:
OutOfMemoryException
-
getConfig
Description copied from interface:FragmentContextReturns the Drill configuration for this run. Note that the config is global and immutable.- Specified by:
getConfigin interfaceFragmentContext- Returns:
- the Drill configuration
-
getExecutorState
- Specified by:
getExecutorStatein interfaceFragmentContext
-
getExecutionControls
Description copied from interface:FragmentContextReturn the set of execution controls used to inject faults into running code for testing.- Specified by:
getExecutionControlsin interfaceFragmentContext- Returns:
- the execution controls
-
getQueryUserName
- Specified by:
getQueryUserNamein interfaceFragmentContext- Overrides:
getQueryUserNamein classBaseFragmentContext
-
getQueryId
- Specified by:
getQueryIdin interfaceFragmentContext- Overrides:
getQueryIdin classBaseFragmentContext- Returns:
- ID
UUIDof the current query
-
getQueryIdString
- Specified by:
getQueryIdStringin interfaceFragmentContext- Overrides:
getQueryIdStringin classBaseFragmentContext- Returns:
- The string representation of the ID
UUIDof the current query
-
isImpersonationEnabled
public boolean isImpersonationEnabled()- Specified by:
isImpersonationEnabledin interfaceFragmentContext
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceFragmentContext
-
getPartitionExplorer
Description copied from interface:UdfUtilitiesA partition explorer allows UDFs to view the sub-partitions below a particular partition. This allows for the implementation of UDFs to query against the partition information, without having to read the actual data contained in the partition. This interface is designed for UDFs that take only constant inputs, as this interface will only be useful if we can evaluate the constant UDF at planning time. Any function defined to use this interface that is not evaluated at planning time by the constant folding rule will be querying the storage plugin for meta-data for each record processed. Be sure to check the query plans to see that this expression has already been evaluated during planning if you write UDFs against this interface. SeeDirectoryExplorersfor example usages of this interface.- Specified by:
getPartitionExplorerin interfaceUdfUtilities- Returns:
- - an object for exploring partitions of all available schemas
-
getConstantValueHolder
public ValueHolder getConstantValueHolder(String value, TypeProtos.MinorType type, com.google.common.base.Function<DrillBuf, ValueHolder> holderInitializer) Description copied from interface:UdfUtilitiesWorks with value holders cache which holds constant value and its wrapper by type. If value is absent uses holderInitializer to create holder and adds it to cache.- Specified by:
getConstantValueHolderin interfaceUdfUtilities- Returns:
- - a wrapper object for an constant value.
-
getExecutor
- Specified by:
getExecutorin interfaceFragmentContext
-
waitForSendComplete
public void waitForSendComplete()- Specified by:
waitForSendCompletein interfaceExchangeFragmentContext
-
getWorkEventBus
- Specified by:
getWorkEventBusin interfaceExecutorFragmentContext
-
isBuffersDone
public boolean isBuffersDone() -
getBufferManager
- Specified by:
getBufferManagerin classBaseFragmentContext
-
getSQLStatementType
Description copied from interface:FragmentContextReturns the statement type (e.g. SELECT, CTAS, ANALYZE) from the query context.- Specified by:
getSQLStatementTypein interfaceFragmentContext- Overrides:
getSQLStatementTypein classBaseFragmentContext- Returns:
- query statement type
QueryContext.SqlStatementType, if known.
-
getMetastoreRegistry
Description copied from interface:FragmentContextGet instance of Metastore registry to obtain Metastore instance if needed.- Specified by:
getMetastoreRegistryin interfaceFragmentContext- Returns:
- Metastore registry
-
getAliasRegistryProvider
Description copied from interface:FragmentContextGet an instance of alias registry provider for obtaining aliases.- Specified by:
getAliasRegistryProviderin interfaceFragmentContext- Returns:
- alias registry provider
-
requestMemory
Description copied from interface:FragmentContextAn operator is experiencing memory pressure. Asks the fragment executor to poll all operators to release an optional memory (such as by spilling.) The request is advisory. The caller should again try to allocate memory, and if the second request fails, throw anOutOfMemoryException.- Specified by:
requestMemoryin interfaceFragmentContext
-