public class Optimizer extends Object
The basic principle is taken from optimizer works in systems such as Volcano/Cascades and Selinger/System-R/DB2. The optimizer walks from the sinks down, generating interesting properties, and ascends from the sources generating alternative plans, pruning against the interesting properties.
The optimizer also assigns the memory to the individual tasks. This is currently done in a very simple fashion: All sub-tasks that need memory (e.g. reduce or join) are given an equal share of memory.
Modifier and Type | Field and Description |
---|---|
static String |
HINT_LOCAL_STRATEGY
Compiler hint key for the operator's local strategy.
|
static String |
HINT_LOCAL_STRATEGY_COMBINING_SORT
Value for the local strategy compiler hint that enforces a sort based local strategy.
|
static String |
HINT_LOCAL_STRATEGY_HASH_BUILD_FIRST
Value for the local strategy compiler hint that enforces a hash based local strategy.
|
static String |
HINT_LOCAL_STRATEGY_HASH_BUILD_SECOND
Value for the local strategy compiler hint that enforces a hash based local strategy.
|
static String |
HINT_LOCAL_STRATEGY_MERGE
Value for the local strategy compiler hint that enforces a merge based local strategy.
|
static String |
HINT_LOCAL_STRATEGY_NESTEDLOOP_BLOCKED_OUTER_FIRST
Value for the local strategy compiler hint that chooses the outer side of the
nested-loop local strategy.
|
static String |
HINT_LOCAL_STRATEGY_NESTEDLOOP_BLOCKED_OUTER_SECOND
Value for the local strategy compiler hint that chooses the outer side of the
nested-loop local strategy.
|
static String |
HINT_LOCAL_STRATEGY_NESTEDLOOP_STREAMED_OUTER_FIRST
Value for the local strategy compiler hint that chooses the outer side of the
nested-loop local strategy.
|
static String |
HINT_LOCAL_STRATEGY_NESTEDLOOP_STREAMED_OUTER_SECOND
Value for the local strategy compiler hint that chooses the outer side of the
nested-loop local strategy.
|
static String |
HINT_LOCAL_STRATEGY_SORT
Value for the local strategy compiler hint that enforces a sort based local strategy.
|
static String |
HINT_LOCAL_STRATEGY_SORT_BOTH_MERGE
Value for the local strategy compiler hint that enforces a sort merge based local
strategy on both inputs with subsequent merging of inputs.
|
static String |
HINT_LOCAL_STRATEGY_SORT_FIRST_MERGE
Value for the local strategy compiler hint that enforces a sort merge based local
strategy.
|
static String |
HINT_LOCAL_STRATEGY_SORT_SECOND_MERGE
Value for the local strategy compiler hint that enforces a sort merge based local
strategy.
|
static String |
HINT_SHIP_STRATEGY
Compiler hint key for the input channel's shipping strategy.
|
static String |
HINT_SHIP_STRATEGY_BROADCAST
Value for the shipping strategy compiler hint that enforces a broadcast strategy on
the input channel.
|
static String |
HINT_SHIP_STRATEGY_FIRST_INPUT
Compiler hint key for the first input channel's shipping strategy.
|
static String |
HINT_SHIP_STRATEGY_FORWARD
Value for the shipping strategy compiler hint that enforces a Forward strategy on the
input channel, i.e. no redistribution of any kind.
|
static String |
HINT_SHIP_STRATEGY_REPARTITION
Value for the shipping strategy compiler hint that enforces a random repartition strategy.
|
static String |
HINT_SHIP_STRATEGY_REPARTITION_HASH
Value for the shipping strategy compiler hint that enforces a hash-partition strategy.
|
static String |
HINT_SHIP_STRATEGY_REPARTITION_RANGE
Value for the shipping strategy compiler hint that enforces a range-partition strategy.
|
static String |
HINT_SHIP_STRATEGY_SECOND_INPUT
Compiler hint key for the second input channel's shipping strategy.
|
static org.slf4j.Logger |
LOG
The log handle that is used by the compiler to log messages.
|
Constructor and Description |
---|
Optimizer(Configuration config)
Creates a new optimizer instance.
|
Optimizer(CostEstimator estimator,
Configuration config)
Creates a new optimizer instance.
|
Optimizer(DataStatistics stats,
Configuration config)
Creates a new optimizer instance that uses the statistics object to determine properties
about the input.
|
Optimizer(DataStatistics stats,
CostEstimator estimator,
Configuration config)
Creates a new optimizer instance that uses the statistics object to determine properties
about the input.
|
Modifier and Type | Method and Description |
---|---|
OptimizedPlan |
compile(Plan program)
Translates the given program to an OptimizedPlan, where all nodes have their local strategy
assigned and all channels have a shipping strategy assigned.
|
static List<DataSinkNode> |
createPreOptimizedPlan(Plan program)
This function performs only the first step to the compilation process - the creation of the
optimizer representation of the plan.
|
int |
getDefaultParallelism() |
void |
setDefaultParallelism(int defaultParallelism) |
public static final String HINT_SHIP_STRATEGY
public static final String HINT_SHIP_STRATEGY_FIRST_INPUT
public static final String HINT_SHIP_STRATEGY_SECOND_INPUT
public static final String HINT_SHIP_STRATEGY_FORWARD
public static final String HINT_SHIP_STRATEGY_REPARTITION
public static final String HINT_SHIP_STRATEGY_REPARTITION_HASH
public static final String HINT_SHIP_STRATEGY_REPARTITION_RANGE
public static final String HINT_SHIP_STRATEGY_BROADCAST
public static final String HINT_LOCAL_STRATEGY
This hint is ignored by operators that do not have a local strategy (such as Map), or by operators that have no choice in their local strategy (such as Cross).
public static final String HINT_LOCAL_STRATEGY_SORT
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_COMBINING_SORT
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_SORT_BOTH_MERGE
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_SORT_FIRST_MERGE
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_SORT_SECOND_MERGE
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_MERGE
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_HASH_BUILD_FIRST
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_HASH_BUILD_SECOND
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_NESTEDLOOP_STREAMED_OUTER_FIRST
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_NESTEDLOOP_STREAMED_OUTER_SECOND
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_NESTEDLOOP_BLOCKED_OUTER_FIRST
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final String HINT_LOCAL_STRATEGY_NESTEDLOOP_BLOCKED_OUTER_SECOND
HINT_LOCAL_STRATEGY
,
Constant Field Valuespublic static final org.slf4j.Logger LOG
public Optimizer(Configuration config)
public Optimizer(DataStatistics stats, Configuration config)
stats
- The statistics to be used to determine the input properties.public Optimizer(CostEstimator estimator, Configuration config)
The optimizer uses the given cost estimator to compute the costs of the individual operations.
estimator
- The cost estimator to use to cost the individual operations.public Optimizer(DataStatistics stats, CostEstimator estimator, Configuration config)
The optimizer uses the given cost estimator to compute the costs of the individual operations.
stats
- The statistics to be used to determine the input properties.estimator
- The CostEstimator to use to cost the individual operations.public int getDefaultParallelism()
public void setDefaultParallelism(int defaultParallelism)
public OptimizedPlan compile(Plan program) throws CompilerException
For more details on the optimization phase, see the comments for compile(org.apache.flink.api.common.Plan,
org.apache.flink.optimizer.postpass.OptimizerPostPass)
.
program
- The program to be translated.CompilerException
- Thrown, if the plan is invalid or the optimizer encountered an
inconsistent situation during the compilation process.public static List<DataSinkNode> createPreOptimizedPlan(Plan program)
program
- The plan to generate the optimizer representation for.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.