Class FragmentContextImpl

java.lang.Object
org.apache.drill.exec.ops.BaseFragmentContext
org.apache.drill.exec.ops.FragmentContextImpl
All Implemented Interfaces:
AutoCloseable, ExchangeFragmentContext, ExecutorFragmentContext, FragmentContext, RootFragmentContext, UdfUtilities

public class FragmentContextImpl extends BaseFragmentContext implements ExecutorFragmentContext
This is the core Context which implements all the Context interfaces: The interfaces above expose resources to varying degrees. They are ordered from most restrictive (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.