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 TypeClassDescriptionclass
MaintainsOptimizationContext
s for the iterations of aLoopSubplan
.class
Represents a single optimization context of anOperator
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final OptimizationContext.LoopContext
The instance in that this instance is nested - ornull
if it is top-level.protected final Job
TheJob
whoseWayangPlan
is to be optimized.protected final org.apache.logging.log4j.Logger
-
Constructor Summary
ConstructorsModifierConstructorDescriptionOptimizationContext
(Job job) Create a new, plain instance.protected
OptimizationContext
(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 void
addOneTimeLoop
(OptimizationContext.OperatorContext operatorContext) AddOptimizationContext
s for theloop
that is executed once within this instance.abstract OptimizationContext.OperatorContext
addOneTimeOperator
(Operator operator) AddOptimizationContext.OperatorContext
s for theoperator
that is executed once within this instance.void
addOneTimeOperators
(OperatorContainer container) abstract void
CallsOptimizationContext.OperatorContext.clearMarks()
for all nestedOptimizationContext.OperatorContext
s.getBase()
abstract List<DefaultOptimizationContext>
Get theDefaultOptimizationContext
s represented by this instance.int
getJob()
Provide theJob
whose optimization is supported by this instance.abstract Map<Operator,
OptimizationContext.OperatorContext> Retrieve theOptimizationContext.LoopContext
in which this instance resides.abstract OptimizationContext.LoopContext
getNestedLoopContext
(LoopSubplan loopSubplan) Retrieve theOptimizationContext.LoopContext
for theloopSubplan
.abstract OptimizationContext.OperatorContext
getOperatorContext
(Operator operator) Return theOptimizationContext.OperatorContext
of theoperator
.Get the top-level parent containing this instance.boolean
boolean
abstract boolean
abstract void
putIntoJobCache
(String key, Object value) Stores a value into theJob
-global cache.queryJobCache
(String key) Queries theJob
-global cache.<T> T
queryJobCache
(String key, Class<T> resultClass) Queries theJob
-global cache.
-
Field Details
-
logger
protected final org.apache.logging.log4j.Logger logger -
job
TheJob
whoseWayangPlan
is to be optimized. -
hostLoopContext
The instance in that this instance is nested - ornull
if it is top-level.
-
-
Constructor Details
-
OptimizationContext
Create a new, plain instance. -
OptimizationContext
Creates a new instance. Useful for testing.- Parameters:
operator
- the singleOperator
of 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.OperatorContext
s for theoperator
that is executed once within this instance. Also add its encasedOperator
s. Potentially invokeaddOneTimeLoop(OperatorContext)
as well. -
addOneTimeOperators
-
addOneTimeLoop
AddOptimizationContext
s for theloop
that is executed once within this instance. -
getOperatorContext
Return theOptimizationContext.OperatorContext
of theoperator
.- Parameters:
operator
- a one-timeOperator
(i.e., not in a nested loop)- Returns:
- the
OptimizationContext.OperatorContext
for theOperator
ornull
if none
-
getNestedLoopContext
Retrieve theOptimizationContext.LoopContext
for 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.LoopContext
in which this instance resides.- Returns:
- the
OptimizationContext.LoopContext
ornull
if 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.OperatorContext
s. -
getConfiguration
-
getLocalOperatorContexts
- Returns:
- the
OptimizationContext.OperatorContext
s of this instance (exclusive of any base instance)
-
isTimeEstimatesComplete
public abstract boolean isTimeEstimatesComplete()- Returns:
- whether there is a
TimeEstimate
for 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 theDefaultOptimizationContext
s represented by this instance.- Returns:
- a
Collection
of saidDefaultOptimizationContext
s
-
getJob
Provide theJob
whose 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 expectedClass
of the retrieved value- Returns:
- the value associated with the key or else
null
-