Package org.apache.wayang.core.optimizer
Class OptimizationContext
- java.lang.Object
-
- org.apache.wayang.core.optimizer.OptimizationContext
-
- Direct Known Subclasses:
AggregateOptimizationContext
,DefaultOptimizationContext
public abstract class OptimizationContext extends java.lang.Object
Manages contextual information required during the optimization of aWayangPlan
.A single
Operator
can have multiple contexts in aWayangPlan
- namely if it appears in a loop. We manage these contexts in a hierarchical fashion.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
OptimizationContext.LoopContext
MaintainsOptimizationContext
s for the iterations of aLoopSubplan
.class
OptimizationContext.OperatorContext
Represents a single optimization context of anOperator
.
-
Field Summary
Fields Modifier and Type Field Description protected OptimizationContext.LoopContext
hostLoopContext
The instance in that this instance is nested - ornull
if it is top-level.protected Job
job
TheJob
whoseWayangPlan
is to be optimized.protected org.apache.logging.log4j.Logger
logger
-
Constructor Summary
Constructors Modifier Constructor Description OptimizationContext(Job job)
Create a new, plain instance.protected
OptimizationContext(Job job, OptimizationContext base, OptimizationContext.LoopContext hostLoopContext, int iterationNumber, ChannelConversionGraph channelConversionGraph, java.util.List<PlanEnumerationPruningStrategy> pruningStrategies)
Base constructor.OptimizationContext(Job job, Operator operator)
Creates a new instance.
-
Method Summary
-
-
-
Field Detail
-
logger
protected final org.apache.logging.log4j.Logger logger
-
job
protected final Job job
TheJob
whoseWayangPlan
is to be optimized.
-
hostLoopContext
protected final OptimizationContext.LoopContext hostLoopContext
The instance in that this instance is nested - ornull
if it is top-level.
-
-
Constructor Detail
-
OptimizationContext
public OptimizationContext(Job job)
Create a new, plain instance.
-
OptimizationContext
public OptimizationContext(Job job, Operator operator)
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, java.util.List<PlanEnumerationPruningStrategy> pruningStrategies)
Base constructor.
-
-
Method Detail
-
addOneTimeOperator
public abstract OptimizationContext.OperatorContext addOneTimeOperator(Operator operator)
AddOptimizationContext.OperatorContext
s for theoperator
that is executed once within this instance. Also add its encasedOperator
s. Potentially invokeaddOneTimeLoop(OperatorContext)
as well.
-
addOneTimeOperators
public void addOneTimeOperators(OperatorContainer container)
-
addOneTimeLoop
public abstract void addOneTimeLoop(OptimizationContext.OperatorContext operatorContext)
AddOptimizationContext
s for theloop
that is executed once within this instance.
-
getOperatorContext
public abstract OptimizationContext.OperatorContext getOperatorContext(Operator operator)
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
public abstract OptimizationContext.LoopContext getNestedLoopContext(LoopSubplan loopSubplan)
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
public OptimizationContext.LoopContext getLoopContext()
Retrieve theOptimizationContext.LoopContext
in which this instance resides.- Returns:
- the
OptimizationContext.LoopContext
ornull
if none
-
getParent
public OptimizationContext getParent()
- Returns:
- if this instance describes an iteration within a
LoopSubplan
, return the instance in which this instance is nested
-
getNextIterationContext
public OptimizationContext getNextIterationContext()
-
clearMarks
public abstract void clearMarks()
CallsOptimizationContext.OperatorContext.clearMarks()
for all nestedOptimizationContext.OperatorContext
s.
-
getConfiguration
public Configuration getConfiguration()
-
getLocalOperatorContexts
public abstract java.util.Map<Operator,OptimizationContext.OperatorContext> 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
public ChannelConversionGraph getChannelConversionGraph()
-
getBase
public OptimizationContext getBase()
-
mergeToBase
public abstract void mergeToBase()
-
getPruningStrategies
public java.util.List<PlanEnumerationPruningStrategy> getPruningStrategies()
-
getRootParent
public OptimizationContext getRootParent()
Get the top-level parent containing this instance.- Returns:
- the top-level parent, which can also be this instance
-
getDefaultOptimizationContexts
public abstract java.util.List<DefaultOptimizationContext> getDefaultOptimizationContexts()
Get theDefaultOptimizationContext
s represented by this instance.- Returns:
- a
Collection
of saidDefaultOptimizationContext
s
-
getJob
public Job getJob()
Provide theJob
whose optimization is supported by this instance.- Returns:
- the
Job
-
putIntoJobCache
public java.lang.Object putIntoJobCache(java.lang.String key, java.lang.Object value)
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
public java.lang.Object queryJobCache(java.lang.String key)
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
public <T> T queryJobCache(java.lang.String key, java.lang.Class<T> resultClass)
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
-
-