Package org.apache.wayang.core.optimizer
Class OptimizationContext
java.lang.Object
org.apache.wayang.core.optimizer.OptimizationContext
- Direct Known Subclasses:
AggregateOptimizationContext,DefaultOptimizationContext
Manages contextual information required during the optimization of a
WayangPlan.
A single Operator can have multiple contexts in a WayangPlan - namely if it appears in a loop.
We manage these contexts in a hierarchical fashion.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassMaintainsOptimizationContexts for the iterations of aLoopSubplan.classRepresents a single optimization context of anOperator. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final OptimizationContext.LoopContextThe instance in that this instance is nested - ornullif it is top-level.protected final JobTheJobwhoseWayangPlanis to be optimized.protected final org.apache.logging.log4j.Logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionOptimizationContext(Job job) Create a new, plain instance.protectedOptimizationContext(Job job, OptimizationContext base, OptimizationContext.LoopContext hostLoopContext, int iterationNumber, ChannelConversionGraph channelConversionGraph, List<PlanEnumerationPruningStrategy> pruningStrategies) Base constructor.OptimizationContext(Job job, Operator operator) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddOneTimeLoop(OptimizationContext.OperatorContext operatorContext) AddOptimizationContexts for theloopthat is executed once within this instance.abstract OptimizationContext.OperatorContextaddOneTimeOperator(Operator operator) AddOptimizationContext.OperatorContexts for theoperatorthat is executed once within this instance.voidaddOneTimeOperators(OperatorContainer container) abstract voidCallsOptimizationContext.OperatorContext.clearMarks()for all nestedOptimizationContext.OperatorContexts.getBase()abstract List<DefaultOptimizationContext>Get theDefaultOptimizationContexts represented by this instance.intgetJob()Provide theJobwhose optimization is supported by this instance.abstract Map<Operator,OptimizationContext.OperatorContext> Retrieve theOptimizationContext.LoopContextin which this instance resides.abstract OptimizationContext.LoopContextgetNestedLoopContext(LoopSubplan loopSubplan) Retrieve theOptimizationContext.LoopContextfor theloopSubplan.abstract OptimizationContext.OperatorContextgetOperatorContext(Operator operator) Return theOptimizationContext.OperatorContextof theoperator.Get the top-level parent containing this instance.booleanbooleanabstract booleanabstract voidputIntoJobCache(String key, Object value) Stores a value into theJob-global cache.queryJobCache(String key) Queries theJob-global cache.<T> TqueryJobCache(String key, Class<T> resultClass) Queries theJob-global cache.
-
Field Details
-
logger
protected final org.apache.logging.log4j.Logger logger -
job
TheJobwhoseWayangPlanis to be optimized. -
hostLoopContext
The instance in that this instance is nested - ornullif it is top-level.
-
-
Constructor Details
-
OptimizationContext
Create a new, plain instance. -
OptimizationContext
Creates a new instance. Useful for testing.- Parameters:
operator- the singleOperatorof this instance
-
OptimizationContext
protected OptimizationContext(Job job, OptimizationContext base, OptimizationContext.LoopContext hostLoopContext, int iterationNumber, ChannelConversionGraph channelConversionGraph, List<PlanEnumerationPruningStrategy> pruningStrategies) Base constructor.
-
-
Method Details
-
addOneTimeOperator
AddOptimizationContext.OperatorContexts for theoperatorthat is executed once within this instance. Also add its encasedOperators. Potentially invokeaddOneTimeLoop(OperatorContext)as well. -
addOneTimeOperators
-
addOneTimeLoop
AddOptimizationContexts for theloopthat is executed once within this instance. -
getOperatorContext
Return theOptimizationContext.OperatorContextof theoperator.- Parameters:
operator- a one-timeOperator(i.e., not in a nested loop)- Returns:
- the
OptimizationContext.OperatorContextfor theOperatorornullif none
-
getNestedLoopContext
Retrieve theOptimizationContext.LoopContextfor theloopSubplan. -
getIterationNumber
public int getIterationNumber()- Returns:
- if this instance describes an iteration within a
LoopSubplan, return the number of that iteration (starting at0); otherwise-1
-
isInitialIteration
public boolean isInitialIteration()- Returns:
- whether this instance is the first iteration within a
OptimizationContext.LoopContext; this instance must be embedded in aOptimizationContext.LoopContext
-
isFinalIteration
public boolean isFinalIteration()- Returns:
- whether this instance is the final iteration within a
OptimizationContext.LoopContext; this instance must be embedded in aOptimizationContext.LoopContext
-
getLoopContext
Retrieve theOptimizationContext.LoopContextin which this instance resides.- Returns:
- the
OptimizationContext.LoopContextornullif none
-
getParent
- Returns:
- if this instance describes an iteration within a
LoopSubplan, return the instance in which this instance is nested
-
getNextIterationContext
-
clearMarks
public abstract void clearMarks()CallsOptimizationContext.OperatorContext.clearMarks()for all nestedOptimizationContext.OperatorContexts. -
getConfiguration
-
getLocalOperatorContexts
- Returns:
- the
OptimizationContext.OperatorContexts of this instance (exclusive of any base instance)
-
isTimeEstimatesComplete
public abstract boolean isTimeEstimatesComplete()- Returns:
- whether there is a
TimeEstimatefor eachExecutionOperator
-
getChannelConversionGraph
-
getBase
-
mergeToBase
public abstract void mergeToBase() -
getPruningStrategies
-
getRootParent
Get the top-level parent containing this instance.- Returns:
- the top-level parent, which can also be this instance
-
getDefaultOptimizationContexts
Get theDefaultOptimizationContexts represented by this instance.- Returns:
- a
Collectionof saidDefaultOptimizationContexts
-
getJob
Provide theJobwhose optimization is supported by this instance.- Returns:
- the
Job
-
putIntoJobCache
Stores a value into theJob-global cache.- Parameters:
key- identifies the valuevalue- the value- Returns:
- the value previously associated with the key or else
null
-
queryJobCache
Queries theJob-global cache.- Parameters:
key- that is associated with the value to be retrieved- Returns:
- the value associated with the key or else
null
-
queryJobCache
Queries theJob-global cache.- Parameters:
key- that is associated with the value to be retrievedresultClass- the expectedClassof the retrieved value- Returns:
- the value associated with the key or else
null
-