public abstract class OptimizerNode extends Object implements Visitable<OptimizerNode>, EstimateProvider, DumpableNode<OptimizerNode>
| Modifier and Type | Class and Description |
|---|---|
static class |
OptimizerNode.UnclosedBranchDescriptor |
| Modifier and Type | Field and Description |
|---|---|
protected List<PlanNode> |
cachedPlans |
protected Set<OptimizerNode> |
closedBranchingNodes |
protected int |
costWeight |
protected long |
estimatedNumRecords |
protected long |
estimatedOutputSize |
protected List<OptimizerNode> |
hereJoinedBranches |
protected int |
id |
static int |
MAX_DYNAMIC_PATH_COST_WEIGHT |
protected boolean |
onDynamicPath |
protected List<OptimizerNode.UnclosedBranchDescriptor> |
openBranches |
protected int[][] |
remappedKeys |
protected Set<FieldSet> |
uniqueFields |
| Modifier | Constructor and Description |
|---|---|
|
OptimizerNode(Operator<?> op)
Creates a new node for the optimizer plan.
|
protected |
OptimizerNode(OptimizerNode toCopy) |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
accept(Visitor<OptimizerNode> visitor)
This method implements the visit of a depth-first graph traversing visitor.
|
void |
addBroadcastConnection(String name,
PactConnection broadcastConnection)
Adds the broadcast connection identified by the given
name to this node. |
protected void |
addClosedBranch(OptimizerNode alreadyClosed) |
protected void |
addClosedBranches(Set<OptimizerNode> alreadyClosed) |
void |
addOutgoingConnection(PactConnection pactConnection)
Adds a new outgoing connection to this node.
|
protected boolean |
areBranchCompatible(PlanNode plan1,
PlanNode plan2)
Checks whether to candidate plans for the sub-plan of this node are comparable.
|
void |
clearInterestingProperties() |
abstract void |
computeInterestingPropertiesForInputs(CostEstimator estimator)
Tells the node to compute the interesting properties for its inputs.
|
protected abstract void |
computeOperatorSpecificDefaultEstimates(DataStatistics statistics) |
void |
computeOutputEstimates(DataStatistics statistics)
Causes this node to compute its output estimates (such as number of rows, size in bytes)
based on the inputs and the compiler hints.
|
abstract void |
computeUnclosedBranchStack()
This method causes the node to compute the description of open branches in its sub-plan.
|
protected List<OptimizerNode.UnclosedBranchDescriptor> |
computeUnclosedBranchStackForBroadcastInputs(List<OptimizerNode.UnclosedBranchDescriptor> branchesSoFar) |
void |
computeUnionOfInterestingPropertiesFromSuccessors()
Computes all the interesting properties that are relevant to this node.
|
List<FieldSet> |
createUniqueFieldsForNode()
An optional method where nodes can describe which fields will be unique in their output.
|
abstract List<PlanNode> |
getAlternativePlans(CostEstimator estimator)
Computes the plan alternatives for this node, an implicitly for all nodes that are children of
this node.
|
protected List<OptimizerNode.UnclosedBranchDescriptor> |
getBranchesForParent(PactConnection toParent) |
List<String> |
getBroadcastConnectionNames()
Return the list of names associated with broadcast inputs for this node.
|
List<PactConnection> |
getBroadcastConnections()
Return the list of inputs associated with broadcast variables for this node.
|
Set<OptimizerNode> |
getClosedBranchingNodes() |
protected int[] |
getConstantKeySet(int input)
Returns the key columns for the specific input, if all keys are preserved
by this node.
|
int |
getCostWeight() |
int |
getDegreeOfParallelism()
Gets the degree of parallelism for the contract represented by this optimizer node.
|
Iterable<DumpableConnection<OptimizerNode>> |
getDumpableInputs() |
float |
getEstimatedAvgWidthPerOutputRecord()
Gets the estimated number of bytes per record.
|
long |
getEstimatedNumRecords()
Gets the estimated number of records in the output of this node.
|
long |
getEstimatedOutputSize()
Gets the estimated output size from this node.
|
int |
getId()
Gets the ID of this node.
|
abstract List<PactConnection> |
getIncomingConnections()
This method needs to be overridden by subclasses to return the children.
|
InterestingProperties |
getInterestingProperties()
Gets the properties that are interesting for this node to produce.
|
int |
getMaxDepth() |
long |
getMinimalMemoryAcrossAllSubTasks()
Gets the amount of memory that all subtasks of this task have jointly available.
|
abstract String |
getName()
Gets the name of this node.
|
List<OptimizerNode.UnclosedBranchDescriptor> |
getOpenBranches() |
OptimizerNode |
getOptimizerNode() |
List<PactConnection> |
getOutgoingConnections()
The list of outgoing connections from this node to succeeding tasks.
|
Operator<?> |
getPactContract()
Gets the object that specifically describes the contract of this node.
|
PlanNode |
getPlanNode() |
Iterable<OptimizerNode> |
getPredecessors()
Gets an iterator over the predecessors.
|
int[] |
getRemappedKeys(int input) |
Set<FieldSet> |
getUniqueFields()
Gets the FieldSets which are unique in the output of the node.
|
boolean |
hasUnclosedBranches() |
boolean |
haveAllOutputConnectionInterestingProperties()
Checks, if all outgoing connections have their interesting properties set from their target nodes.
|
void |
identifyDynamicPath(int costWeight) |
void |
initId(int id)
Sets the ID of this node.
|
boolean |
isBranching()
Checks whether this node has branching output.
|
abstract boolean |
isFieldConstant(int input,
int fieldNumber)
Checks whether a field is modified by the user code or whether it is kept unchanged.
|
boolean |
isOnDynamicPath() |
protected boolean |
mergeLists(List<OptimizerNode.UnclosedBranchDescriptor> child1open,
List<OptimizerNode.UnclosedBranchDescriptor> child2open,
List<OptimizerNode.UnclosedBranchDescriptor> result)
The node IDs are assigned in graph-traversal order (pre-order), hence, each list is sorted by ID in ascending order and
all consecutive lists start with IDs in ascending order.
|
protected void |
prunePlanAlternatives(List<PlanNode> plans) |
protected void |
prunePlanAlternativesWithCommonBranching(List<PlanNode> plans) |
protected void |
readStubAnnotations()
Reads all stub annotations, i.e.
|
protected void |
readUniqueFieldsAnnotation() |
protected void |
removeClosedBranches(List<OptimizerNode.UnclosedBranchDescriptor> openList) |
void |
setBroadcastInputs(Map<Operator<?>,OptimizerNode> operatorToNode)
This function is for plan translation purposes.
|
void |
setDegreeOfParallelism(int degreeOfParallelism)
Sets the degree of parallelism for the contract represented by this optimizer node.
|
void |
setEstimatedNumRecords(long estimatedNumRecords) |
void |
setEstimatedOutputSize(long estimatedOutputSize) |
abstract void |
setInput(Map<Operator<?>,OptimizerNode> contractToNode)
This function is for plan translation purposes.
|
String |
toString() |
public static final int MAX_DYNAMIC_PATH_COST_WEIGHT
protected List<OptimizerNode.UnclosedBranchDescriptor> openBranches
protected Set<OptimizerNode> closedBranchingNodes
protected List<OptimizerNode> hereJoinedBranches
protected long estimatedOutputSize
protected long estimatedNumRecords
protected int id
protected int costWeight
protected boolean onDynamicPath
protected int[][] remappedKeys
public OptimizerNode(Operator<?> op)
op - The operator that the node represents.protected OptimizerNode(OptimizerNode toCopy)
public abstract String getName()
public abstract void setInput(Map<Operator<?>,OptimizerNode> contractToNode)
In addition, the nodes must set the shipping strategy of the connection, if a suitable optimizer hint is found.
contractToNode - The map to translate the contracts to their corresponding optimizer nodes.public void setBroadcastInputs(Map<Operator<?>,OptimizerNode> operatorToNode) throws CompilerException
PactConnection
for each one of the broadcast inputs associated with the Operator referenced by this node.
The PactConnections must set its shipping strategy type to BROADCAST.
operatorToNode - The map associating operators with their corresponding optimizer nodes.CompilerExceptionpublic abstract List<PactConnection> getIncomingConnections()
public abstract void computeInterestingPropertiesForInputs(CostEstimator estimator)
estimator - The CostEstimator instance to use for plan cost estimation.public abstract void computeUnclosedBranchStack()
openBranches field to a stack of unclosed branches, the
latest one top. A branch is considered closed, if some later node sees all of the branching node's outputs,
no matter if there have been more branches to different paths in the meantime.protected List<OptimizerNode.UnclosedBranchDescriptor> computeUnclosedBranchStackForBroadcastInputs(List<OptimizerNode.UnclosedBranchDescriptor> branchesSoFar)
public abstract List<PlanNode> getAlternativePlans(CostEstimator estimator)
getAlternatives() on its children
to get their plan alternatives, and build its own alternatives on top of those.estimator - The cost estimator used to estimate the costs of each plan alternative.public abstract void accept(Visitor<OptimizerNode> visitor)
preVisit() method, then hand the visitor to their children, and finally call
the postVisit() method.accept in interface Visitable<OptimizerNode>visitor - The graph traversing visitor.Visitable.accept(org.apache.flink.util.Visitor)public abstract boolean isFieldConstant(int input,
int fieldNumber)
input - The input number.fieldNumber - The position of the field.public Iterable<OptimizerNode> getPredecessors()
DumpableNodegetPredecessors in interface DumpableNode<OptimizerNode>public int getId()
public void initId(int id)
id - The id for this node.public void addBroadcastConnection(String name, PactConnection broadcastConnection)
name to this node.broadcastConnection - The connection to add.public List<String> getBroadcastConnectionNames()
public List<PactConnection> getBroadcastConnections()
public void addOutgoingConnection(PactConnection pactConnection)
pactConnection - The connection to add.public List<PactConnection> getOutgoingConnections()
public Operator<?> getPactContract()
public int getDegreeOfParallelism()
-1, then the system will take
the default number of parallel instances.public void setDegreeOfParallelism(int degreeOfParallelism)
-1, then the system will take
the default number of parallel instances.degreeOfParallelism - The degree of parallelism to set.IllegalArgumentException - If the degree of parallelism is smaller than one and not -1.public long getMinimalMemoryAcrossAllSubTasks()
public boolean isOnDynamicPath()
public void identifyDynamicPath(int costWeight)
public int getCostWeight()
public int getMaxDepth()
public InterestingProperties getInterestingProperties()
public long getEstimatedOutputSize()
EstimateProvidergetEstimatedOutputSize in interface EstimateProviderpublic long getEstimatedNumRecords()
EstimateProvidergetEstimatedNumRecords in interface EstimateProviderpublic void setEstimatedOutputSize(long estimatedOutputSize)
public void setEstimatedNumRecords(long estimatedNumRecords)
public float getEstimatedAvgWidthPerOutputRecord()
EstimateProvidergetEstimatedAvgWidthPerOutputRecord in interface EstimateProviderpublic boolean isBranching()
public boolean haveAllOutputConnectionInterestingProperties()
public void computeUnionOfInterestingPropertiesFromSuccessors()
public void clearInterestingProperties()
public void computeOutputEstimates(DataStatistics statistics)
statistics - The statistics object which may be accessed to get statistical information.
The parameter may be null, if no statistics are available.protected abstract void computeOperatorSpecificDefaultEstimates(DataStatistics statistics)
protected void readStubAnnotations()
protected void readUniqueFieldsAnnotation()
protected int[] getConstantKeySet(int input)
public List<FieldSet> createUniqueFieldsForNode()
public Set<FieldSet> getUniqueFields()
protected void prunePlanAlternativesWithCommonBranching(List<PlanNode> plans)
public boolean hasUnclosedBranches()
public Set<OptimizerNode> getClosedBranchingNodes()
public List<OptimizerNode.UnclosedBranchDescriptor> getOpenBranches()
protected List<OptimizerNode.UnclosedBranchDescriptor> getBranchesForParent(PactConnection toParent)
protected void removeClosedBranches(List<OptimizerNode.UnclosedBranchDescriptor> openList)
protected void addClosedBranches(Set<OptimizerNode> alreadyClosed)
protected void addClosedBranch(OptimizerNode alreadyClosed)
protected boolean areBranchCompatible(PlanNode plan1, PlanNode plan2)
plan1 - plan2 - protected final boolean mergeLists(List<OptimizerNode.UnclosedBranchDescriptor> child1open, List<OptimizerNode.UnclosedBranchDescriptor> child2open, List<OptimizerNode.UnclosedBranchDescriptor> result)
public OptimizerNode getOptimizerNode()
getOptimizerNode in interface DumpableNode<OptimizerNode>public PlanNode getPlanNode()
getPlanNode in interface DumpableNode<OptimizerNode>public Iterable<DumpableConnection<OptimizerNode>> getDumpableInputs()
getDumpableInputs in interface DumpableNode<OptimizerNode>public int[] getRemappedKeys(int input)
Copyright © 2014 The Apache Software Foundation. All rights reserved.