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.ObjectManages contextual information required during the optimization of aWayangPlan.A single
Operatorcan 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 classOptimizationContext.LoopContextMaintainsOptimizationContexts for the iterations of aLoopSubplan.classOptimizationContext.OperatorContextRepresents a single optimization context of anOperator.
-
Field Summary
Fields Modifier and Type Field Description protected OptimizationContext.LoopContexthostLoopContextThe instance in that this instance is nested - ornullif it is top-level.protected JobjobTheJobwhoseWayangPlanis to be optimized.protected org.apache.logging.log4j.Loggerlogger
-
Constructor Summary
Constructors Modifier Constructor Description OptimizationContext(Job job)Create a new, plain instance.protectedOptimizationContext(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
TheJobwhoseWayangPlanis to be optimized.
-
hostLoopContext
protected final OptimizationContext.LoopContext hostLoopContext
The instance in that this instance is nested - ornullif 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 singleOperatorof 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.OperatorContexts for theoperatorthat is executed once within this instance. Also add its encasedOperators. Potentially invokeaddOneTimeLoop(OperatorContext)as well.
-
addOneTimeOperators
public void addOneTimeOperators(OperatorContainer container)
-
addOneTimeLoop
public abstract void addOneTimeLoop(OptimizationContext.OperatorContext operatorContext)
AddOptimizationContexts for theloopthat is executed once within this instance.
-
getOperatorContext
public abstract OptimizationContext.OperatorContext getOperatorContext(Operator operator)
Return theOptimizationContext.OperatorContextof theoperator.- Parameters:
operator- a one-timeOperator(i.e., not in a nested loop)- Returns:
- the
OptimizationContext.OperatorContextfor theOperatorornullif none
-
getNestedLoopContext
public abstract OptimizationContext.LoopContext getNestedLoopContext(LoopSubplan loopSubplan)
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
public OptimizationContext.LoopContext getLoopContext()
Retrieve theOptimizationContext.LoopContextin which this instance resides.- Returns:
- the
OptimizationContext.LoopContextornullif 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.OperatorContexts.
-
getConfiguration
public Configuration getConfiguration()
-
getLocalOperatorContexts
public abstract java.util.Map<Operator,OptimizationContext.OperatorContext> 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
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 theDefaultOptimizationContexts represented by this instance.- Returns:
- a
Collectionof saidDefaultOptimizationContexts
-
getJob
public Job getJob()
Provide theJobwhose 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 expectedClassof the retrieved value- Returns:
- the value associated with the key or else
null
-
-