org.apache.flink.optimizer.costs.CostEstimator Java Examples
The following examples show how to use
org.apache.flink.optimizer.costs.CostEstimator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Optimizer.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Creates a new optimizer instance that uses the statistics object to determine properties about the input. * Given those statistics, the optimizer can make better choices for the execution strategies. * * The optimizer uses the given cost estimator to compute the costs of the individual operations. * * @param stats * The statistics to be used to determine the input properties. * @param estimator * The <tt>CostEstimator</tt> to use to cost the individual operations. */ public Optimizer(DataStatistics stats, CostEstimator estimator, Configuration config) { this.statistics = stats; this.costEstimator = estimator; // determine the default parallelism this.defaultParallelism = config.getInteger(CoreOptions.DEFAULT_PARALLELISM); if (defaultParallelism < 1) { this.defaultParallelism = CoreOptions.DEFAULT_PARALLELISM.defaultValue(); LOG.warn("Config value {} for option {} is invalid. Ignoring and using a value of {}.", defaultParallelism, CoreOptions.DEFAULT_PARALLELISM.key(), defaultParallelism); } }
Example #2
Source File: Optimizer.java From flink with Apache License 2.0 | 6 votes |
/** * Creates a new optimizer instance that uses the statistics object to determine properties about the input. * Given those statistics, the optimizer can make better choices for the execution strategies. * * The optimizer uses the given cost estimator to compute the costs of the individual operations. * * @param stats * The statistics to be used to determine the input properties. * @param estimator * The <tt>CostEstimator</tt> to use to cost the individual operations. */ public Optimizer(DataStatistics stats, CostEstimator estimator, Configuration config) { this.statistics = stats; this.costEstimator = estimator; // determine the default parallelism this.defaultParallelism = config.getInteger(CoreOptions.DEFAULT_PARALLELISM); if (defaultParallelism < 1) { this.defaultParallelism = CoreOptions.DEFAULT_PARALLELISM.defaultValue(); LOG.warn("Config value {} for option {} is invalid. Ignoring and using a value of {}.", defaultParallelism, CoreOptions.DEFAULT_PARALLELISM.key(), defaultParallelism); } }
Example #3
Source File: DataSinkNode.java From flink with Apache License 2.0 | 6 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { final InterestingProperties iProps = new InterestingProperties(); { final RequestedGlobalProperties partitioningProps = new RequestedGlobalProperties(); iProps.addGlobalProperties(partitioningProps); } { final Ordering localOrder = getOperator().getLocalOrder(); final RequestedLocalProperties orderProps = new RequestedLocalProperties(); if (localOrder != null) { orderProps.setOrdering(localOrder); } iProps.addLocalProperties(orderProps); } this.input.setInterestingProperties(iProps); }
Example #4
Source File: SingleInputNode.java From flink with Apache License 2.0 | 6 votes |
protected void addLocalCandidates(Channel template, List<Set<? extends NamedChannel>> broadcastPlanChannels, RequestedGlobalProperties rgps, List<PlanNode> target, CostEstimator estimator) { for (RequestedLocalProperties ilp : this.inConn.getInterestingProperties().getLocalProperties()) { final Channel in = template.clone(); ilp.parameterizeChannel(in); // instantiate a candidate, if the instantiated local properties meet one possible local property set outer: for (OperatorDescriptorSingle dps: getPossibleProperties()) { for (RequestedLocalProperties ilps : dps.getPossibleLocalProperties()) { if (ilps.isMetBy(in.getLocalProperties())) { in.setRequiredLocalProps(ilps); instantiateCandidate(dps, in, broadcastPlanChannels, target, estimator, rgps, ilp); break outer; } } } } }
Example #5
Source File: Optimizer.java From flink with Apache License 2.0 | 6 votes |
/** * Creates a new optimizer instance that uses the statistics object to determine properties about the input. * Given those statistics, the optimizer can make better choices for the execution strategies. * * The optimizer uses the given cost estimator to compute the costs of the individual operations. * * @param stats * The statistics to be used to determine the input properties. * @param estimator * The <tt>CostEstimator</tt> to use to cost the individual operations. */ public Optimizer(DataStatistics stats, CostEstimator estimator, Configuration config) { this.statistics = stats; this.costEstimator = estimator; // determine the default parallelism this.defaultParallelism = config.getInteger(CoreOptions.DEFAULT_PARALLELISM); if (defaultParallelism < 1) { this.defaultParallelism = CoreOptions.DEFAULT_PARALLELISM.defaultValue(); LOG.warn("Config value {} for option {} is invalid. Ignoring and using a value of {}.", defaultParallelism, CoreOptions.DEFAULT_PARALLELISM.key(), defaultParallelism); } }
Example #6
Source File: SingleInputNode.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
protected void addLocalCandidates(Channel template, List<Set<? extends NamedChannel>> broadcastPlanChannels, RequestedGlobalProperties rgps, List<PlanNode> target, CostEstimator estimator) { for (RequestedLocalProperties ilp : this.inConn.getInterestingProperties().getLocalProperties()) { final Channel in = template.clone(); ilp.parameterizeChannel(in); // instantiate a candidate, if the instantiated local properties meet one possible local property set outer: for (OperatorDescriptorSingle dps: getPossibleProperties()) { for (RequestedLocalProperties ilps : dps.getPossibleLocalProperties()) { if (ilps.isMetBy(in.getLocalProperties())) { in.setRequiredLocalProps(ilps); instantiateCandidate(dps, in, broadcastPlanChannels, target, estimator, rgps, ilp); break outer; } } } } }
Example #7
Source File: DataSinkNode.java From flink with Apache License 2.0 | 6 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { final InterestingProperties iProps = new InterestingProperties(); { final RequestedGlobalProperties partitioningProps = new RequestedGlobalProperties(); iProps.addGlobalProperties(partitioningProps); } { final Ordering localOrder = getOperator().getLocalOrder(); final RequestedLocalProperties orderProps = new RequestedLocalProperties(); if (localOrder != null) { orderProps.setOrdering(localOrder); } iProps.addLocalProperties(orderProps); } this.input.setInterestingProperties(iProps); }
Example #8
Source File: SingleInputNode.java From flink with Apache License 2.0 | 6 votes |
protected void addLocalCandidates(Channel template, List<Set<? extends NamedChannel>> broadcastPlanChannels, RequestedGlobalProperties rgps, List<PlanNode> target, CostEstimator estimator) { for (RequestedLocalProperties ilp : this.inConn.getInterestingProperties().getLocalProperties()) { final Channel in = template.clone(); ilp.parameterizeChannel(in); // instantiate a candidate, if the instantiated local properties meet one possible local property set outer: for (OperatorDescriptorSingle dps: getPossibleProperties()) { for (RequestedLocalProperties ilps : dps.getPossibleLocalProperties()) { if (ilps.isMetBy(in.getLocalProperties())) { in.setRequiredLocalProps(ilps); instantiateCandidate(dps, in, broadcastPlanChannels, target, estimator, rgps, ilp); break outer; } } } } }
Example #9
Source File: DataSinkNode.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { final InterestingProperties iProps = new InterestingProperties(); { final RequestedGlobalProperties partitioningProps = new RequestedGlobalProperties(); iProps.addGlobalProperties(partitioningProps); } { final Ordering localOrder = getOperator().getLocalOrder(); final RequestedLocalProperties orderProps = new RequestedLocalProperties(); if (localOrder != null) { orderProps.setOrdering(localOrder); } iProps.addLocalProperties(orderProps); } this.input.setInterestingProperties(iProps); }
Example #10
Source File: BinaryUnionNode.java From flink with Apache License 2.0 | 5 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { final InterestingProperties props = getInterestingProperties(); // if no other properties exist, add the pruned trivials back if (props.getGlobalProperties().isEmpty()) { props.addGlobalProperties(new RequestedGlobalProperties()); } props.addLocalProperties(new RequestedLocalProperties()); this.input1.setInterestingProperties(props.clone()); this.input2.setInterestingProperties(props.clone()); this.channelProps = props.getGlobalProperties(); }
Example #11
Source File: SingleInputNode.java From flink with Apache License 2.0 | 5 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { // get what we inherit and what is preserved by our user code final InterestingProperties props = getInterestingProperties().filterByCodeAnnotations(this, 0); // add all properties relevant to this node for (OperatorDescriptorSingle dps : getPossibleProperties()) { for (RequestedGlobalProperties gp : dps.getPossibleGlobalProperties()) { if (gp.getPartitioning().isPartitionedOnKey()) { // make sure that among the same partitioning types, we do not push anything down that has fewer key fields for (RequestedGlobalProperties contained : props.getGlobalProperties()) { if (contained.getPartitioning() == gp.getPartitioning() && gp.getPartitionedFields().isValidSubset(contained.getPartitionedFields())) { props.getGlobalProperties().remove(contained); break; } } } props.addGlobalProperties(gp); } for (RequestedLocalProperties lp : dps.getPossibleLocalProperties()) { props.addLocalProperties(lp); } } this.inConn.setInterestingProperties(props); for (DagConnection conn : getBroadcastConnections()) { conn.setInterestingProperties(new InterestingProperties()); } }
Example #12
Source File: TwoInputNode.java From flink with Apache License 2.0 | 5 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { // get what we inherit and what is preserved by our user code final InterestingProperties props1 = getInterestingProperties().filterByCodeAnnotations(this, 0); final InterestingProperties props2 = getInterestingProperties().filterByCodeAnnotations(this, 1); // add all properties relevant to this node for (OperatorDescriptorDual dpd : getProperties()) { for (GlobalPropertiesPair gp : dpd.getPossibleGlobalProperties()) { // input 1 props1.addGlobalProperties(gp.getProperties1()); // input 2 props2.addGlobalProperties(gp.getProperties2()); } for (LocalPropertiesPair lp : dpd.getPossibleLocalProperties()) { // input 1 props1.addLocalProperties(lp.getProperties1()); // input 2 props2.addLocalProperties(lp.getProperties2()); } } this.input1.setInterestingProperties(props1); this.input2.setInterestingProperties(props2); for (DagConnection conn : getBroadcastConnections()) { conn.setInterestingProperties(new InterestingProperties()); } }
Example #13
Source File: AbstractPartialSolutionNode.java From flink with Apache License 2.0 | 5 votes |
@Override public List<PlanNode> getAlternativePlans(CostEstimator estimator) { if (this.cachedPlans != null) { return this.cachedPlans; } else { throw new IllegalStateException(); } }
Example #14
Source File: TwoInputNode.java From flink with Apache License 2.0 | 5 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { // get what we inherit and what is preserved by our user code final InterestingProperties props1 = getInterestingProperties().filterByCodeAnnotations(this, 0); final InterestingProperties props2 = getInterestingProperties().filterByCodeAnnotations(this, 1); // add all properties relevant to this node for (OperatorDescriptorDual dpd : getProperties()) { for (GlobalPropertiesPair gp : dpd.getPossibleGlobalProperties()) { // input 1 props1.addGlobalProperties(gp.getProperties1()); // input 2 props2.addGlobalProperties(gp.getProperties2()); } for (LocalPropertiesPair lp : dpd.getPossibleLocalProperties()) { // input 1 props1.addLocalProperties(lp.getProperties1()); // input 2 props2.addLocalProperties(lp.getProperties2()); } } this.input1.setInterestingProperties(props1); this.input2.setInterestingProperties(props2); for (DagConnection conn : getBroadcastConnections()) { conn.setInterestingProperties(new InterestingProperties()); } }
Example #15
Source File: SingleInputNode.java From flink with Apache License 2.0 | 5 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { // get what we inherit and what is preserved by our user code final InterestingProperties props = getInterestingProperties().filterByCodeAnnotations(this, 0); // add all properties relevant to this node for (OperatorDescriptorSingle dps : getPossibleProperties()) { for (RequestedGlobalProperties gp : dps.getPossibleGlobalProperties()) { if (gp.getPartitioning().isPartitionedOnKey()) { // make sure that among the same partitioning types, we do not push anything down that has fewer key fields for (RequestedGlobalProperties contained : props.getGlobalProperties()) { if (contained.getPartitioning() == gp.getPartitioning() && gp.getPartitionedFields().isValidSubset(contained.getPartitionedFields())) { props.getGlobalProperties().remove(contained); break; } } } props.addGlobalProperties(gp); } for (RequestedLocalProperties lp : dps.getPossibleLocalProperties()) { props.addLocalProperties(lp); } } this.inConn.setInterestingProperties(props); for (DagConnection conn : getBroadcastConnections()) { conn.setInterestingProperties(new InterestingProperties()); } }
Example #16
Source File: BinaryUnionNode.java From flink with Apache License 2.0 | 5 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { final InterestingProperties props = getInterestingProperties(); // if no other properties exist, add the pruned trivials back if (props.getGlobalProperties().isEmpty()) { props.addGlobalProperties(new RequestedGlobalProperties()); } props.addLocalProperties(new RequestedLocalProperties()); this.input1.setInterestingProperties(props.clone()); this.input2.setInterestingProperties(props.clone()); this.channelProps = props.getGlobalProperties(); }
Example #17
Source File: AbstractPartialSolutionNode.java From flink with Apache License 2.0 | 5 votes |
@Override public List<PlanNode> getAlternativePlans(CostEstimator estimator) { if (this.cachedPlans != null) { return this.cachedPlans; } else { throw new IllegalStateException(); } }
Example #18
Source File: AbstractPartialSolutionNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public List<PlanNode> getAlternativePlans(CostEstimator estimator) { if (this.cachedPlans != null) { return this.cachedPlans; } else { throw new IllegalStateException(); } }
Example #19
Source File: BinaryUnionNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { final InterestingProperties props = getInterestingProperties(); // if no other properties exist, add the pruned trivials back if (props.getGlobalProperties().isEmpty()) { props.addGlobalProperties(new RequestedGlobalProperties()); } props.addLocalProperties(new RequestedLocalProperties()); this.input1.setInterestingProperties(props.clone()); this.input2.setInterestingProperties(props.clone()); this.channelProps = props.getGlobalProperties(); }
Example #20
Source File: SingleInputNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { // get what we inherit and what is preserved by our user code final InterestingProperties props = getInterestingProperties().filterByCodeAnnotations(this, 0); // add all properties relevant to this node for (OperatorDescriptorSingle dps : getPossibleProperties()) { for (RequestedGlobalProperties gp : dps.getPossibleGlobalProperties()) { if (gp.getPartitioning().isPartitionedOnKey()) { // make sure that among the same partitioning types, we do not push anything down that has fewer key fields for (RequestedGlobalProperties contained : props.getGlobalProperties()) { if (contained.getPartitioning() == gp.getPartitioning() && gp.getPartitionedFields().isValidSubset(contained.getPartitionedFields())) { props.getGlobalProperties().remove(contained); break; } } } props.addGlobalProperties(gp); } for (RequestedLocalProperties lp : dps.getPossibleLocalProperties()) { props.addLocalProperties(lp); } } this.inConn.setInterestingProperties(props); for (DagConnection conn : getBroadcastConnections()) { conn.setInterestingProperties(new InterestingProperties()); } }
Example #21
Source File: TwoInputNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { // get what we inherit and what is preserved by our user code final InterestingProperties props1 = getInterestingProperties().filterByCodeAnnotations(this, 0); final InterestingProperties props2 = getInterestingProperties().filterByCodeAnnotations(this, 1); // add all properties relevant to this node for (OperatorDescriptorDual dpd : getProperties()) { for (GlobalPropertiesPair gp : dpd.getPossibleGlobalProperties()) { // input 1 props1.addGlobalProperties(gp.getProperties1()); // input 2 props2.addGlobalProperties(gp.getProperties2()); } for (LocalPropertiesPair lp : dpd.getPossibleLocalProperties()) { // input 1 props1.addLocalProperties(lp.getProperties1()); // input 2 props2.addLocalProperties(lp.getProperties2()); } } this.input1.setInterestingProperties(props1); this.input2.setInterestingProperties(props2); for (DagConnection conn : getBroadcastConnections()) { conn.setInterestingProperties(new InterestingProperties()); } }
Example #22
Source File: TwoInputNode.java From flink with Apache License 2.0 | 4 votes |
protected void instantiate(OperatorDescriptorDual operator, Channel in1, Channel in2, List<Set<? extends NamedChannel>> broadcastPlanChannels, List<PlanNode> target, CostEstimator estimator, RequestedGlobalProperties globPropsReq1, RequestedGlobalProperties globPropsReq2, RequestedLocalProperties locPropsReq1, RequestedLocalProperties locPropsReq2) { final PlanNode inputSource1 = in1.getSource(); final PlanNode inputSource2 = in2.getSource(); for (List<NamedChannel> broadcastChannelsCombination: Sets.cartesianProduct(broadcastPlanChannels)) { boolean validCombination = true; // check whether the broadcast inputs use the same plan candidate at the branching point for (int i = 0; i < broadcastChannelsCombination.size(); i++) { NamedChannel nc = broadcastChannelsCombination.get(i); PlanNode bcSource = nc.getSource(); if (!(areBranchCompatible(bcSource, inputSource1) || areBranchCompatible(bcSource, inputSource2))) { validCombination = false; break; } // check branch compatibility against all other broadcast variables for (int k = 0; k < i; k++) { PlanNode otherBcSource = broadcastChannelsCombination.get(k).getSource(); if (!areBranchCompatible(bcSource, otherBcSource)) { validCombination = false; break; } } } if (!validCombination) { continue; } placePipelineBreakersIfNecessary(operator.getStrategy(), in1, in2); DualInputPlanNode node = operator.instantiate(in1, in2, this); node.setBroadcastInputs(broadcastChannelsCombination); SemanticProperties semPropsGlobalPropFiltering = getSemanticPropertiesForGlobalPropertyFiltering(); GlobalProperties gp1 = in1.getGlobalProperties().clone() .filterBySemanticProperties(semPropsGlobalPropFiltering, 0); GlobalProperties gp2 = in2.getGlobalProperties().clone() .filterBySemanticProperties(semPropsGlobalPropFiltering, 1); GlobalProperties combined = operator.computeGlobalProperties(gp1, gp2); SemanticProperties semPropsLocalPropFiltering = getSemanticPropertiesForLocalPropertyFiltering(); LocalProperties lp1 = in1.getLocalProperties().clone() .filterBySemanticProperties(semPropsLocalPropFiltering, 0); LocalProperties lp2 = in2.getLocalProperties().clone() .filterBySemanticProperties(semPropsLocalPropFiltering, 1); LocalProperties locals = operator.computeLocalProperties(lp1, lp2); node.initProperties(combined, locals); node.updatePropertiesWithUniqueSets(getUniqueFields()); target.add(node); } }
Example #23
Source File: SingleInputNode.java From flink with Apache License 2.0 | 4 votes |
protected void instantiateCandidate(OperatorDescriptorSingle dps, Channel in, List<Set<? extends NamedChannel>> broadcastPlanChannels, List<PlanNode> target, CostEstimator estimator, RequestedGlobalProperties globPropsReq, RequestedLocalProperties locPropsReq) { final PlanNode inputSource = in.getSource(); for (List<NamedChannel> broadcastChannelsCombination: Sets.cartesianProduct(broadcastPlanChannels)) { boolean validCombination = true; boolean requiresPipelinebreaker = false; // check whether the broadcast inputs use the same plan candidate at the branching point for (int i = 0; i < broadcastChannelsCombination.size(); i++) { NamedChannel nc = broadcastChannelsCombination.get(i); PlanNode bcSource = nc.getSource(); // check branch compatibility against input if (!areBranchCompatible(bcSource, inputSource)) { validCombination = false; break; } // check branch compatibility against all other broadcast variables for (int k = 0; k < i; k++) { PlanNode otherBcSource = broadcastChannelsCombination.get(k).getSource(); if (!areBranchCompatible(bcSource, otherBcSource)) { validCombination = false; break; } } // check if there is a common predecessor and whether there is a dam on the way to all common predecessors if (in.isOnDynamicPath() && this.hereJoinedBranches != null) { for (OptimizerNode brancher : this.hereJoinedBranches) { PlanNode candAtBrancher = in.getSource().getCandidateAtBranchPoint(brancher); if (candAtBrancher == null) { // closed branch between two broadcast variables continue; } SourceAndDamReport res = in.getSource().hasDamOnPathDownTo(candAtBrancher); if (res == NOT_FOUND) { throw new CompilerException("Bug: Tracing dams for deadlock detection is broken."); } else if (res == FOUND_SOURCE) { requiresPipelinebreaker = true; break; } else if (res == FOUND_SOURCE_AND_DAM) { // good } else { throw new CompilerException(); } } } } if (!validCombination) { continue; } if (requiresPipelinebreaker) { in.setTempMode(in.getTempMode().makePipelineBreaker()); } final SingleInputPlanNode node = dps.instantiate(in, this); node.setBroadcastInputs(broadcastChannelsCombination); // compute how the strategy affects the properties GlobalProperties gProps = in.getGlobalProperties().clone(); LocalProperties lProps = in.getLocalProperties().clone(); gProps = dps.computeGlobalProperties(gProps); lProps = dps.computeLocalProperties(lProps); // filter by the user code field copies gProps = gProps.filterBySemanticProperties(getSemanticPropertiesForGlobalPropertyFiltering(), 0); lProps = lProps.filterBySemanticProperties(getSemanticPropertiesForLocalPropertyFiltering(), 0); // apply node.initProperties(gProps, lProps); node.updatePropertiesWithUniqueSets(getUniqueFields()); target.add(node); } }
Example #24
Source File: DataSinkNode.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public List<PlanNode> getAlternativePlans(CostEstimator estimator) { // check if we have a cached version if (this.cachedPlans != null) { return this.cachedPlans; } // calculate alternative sub-plans for predecessor List<? extends PlanNode> subPlans = getPredecessorNode().getAlternativePlans(estimator); List<PlanNode> outputPlans = new ArrayList<PlanNode>(); final int parallelism = getParallelism(); final int inDop = getPredecessorNode().getParallelism(); final ExecutionMode executionMode = this.input.getDataExchangeMode(); final boolean dopChange = parallelism != inDop; final boolean breakPipeline = this.input.isBreakingPipeline(); InterestingProperties ips = this.input.getInterestingProperties(); for (PlanNode p : subPlans) { for (RequestedGlobalProperties gp : ips.getGlobalProperties()) { for (RequestedLocalProperties lp : ips.getLocalProperties()) { Channel c = new Channel(p); gp.parameterizeChannel(c, dopChange, executionMode, breakPipeline); lp.parameterizeChannel(c); c.setRequiredLocalProps(lp); c.setRequiredGlobalProps(gp); // no need to check whether the created properties meet what we need in case // of ordering or global ordering, because the only interesting properties we have // are what we require outputPlans.add(new SinkPlanNode(this, "DataSink ("+this.getOperator().getName()+")" ,c)); } } } // cost and prune the plans for (PlanNode node : outputPlans) { estimator.costOperator(node); } prunePlanAlternatives(outputPlans); this.cachedPlans = outputPlans; return outputPlans; }
Example #25
Source File: DataSourceNode.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { // no children, so nothing to compute }
Example #26
Source File: DataSourceNode.java From flink with Apache License 2.0 | 4 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { // no children, so nothing to compute }
Example #27
Source File: DataSinkNode.java From flink with Apache License 2.0 | 4 votes |
@Override public List<PlanNode> getAlternativePlans(CostEstimator estimator) { // check if we have a cached version if (this.cachedPlans != null) { return this.cachedPlans; } // calculate alternative sub-plans for predecessor List<? extends PlanNode> subPlans = getPredecessorNode().getAlternativePlans(estimator); List<PlanNode> outputPlans = new ArrayList<PlanNode>(); final int parallelism = getParallelism(); final int inDop = getPredecessorNode().getParallelism(); final ExecutionMode executionMode = this.input.getDataExchangeMode(); final boolean dopChange = parallelism != inDop; final boolean breakPipeline = this.input.isBreakingPipeline(); InterestingProperties ips = this.input.getInterestingProperties(); for (PlanNode p : subPlans) { for (RequestedGlobalProperties gp : ips.getGlobalProperties()) { for (RequestedLocalProperties lp : ips.getLocalProperties()) { Channel c = new Channel(p); gp.parameterizeChannel(c, dopChange, executionMode, breakPipeline); lp.parameterizeChannel(c); c.setRequiredLocalProps(lp); c.setRequiredGlobalProps(gp); // no need to check whether the created properties meet what we need in case // of ordering or global ordering, because the only interesting properties we have // are what we require outputPlans.add(new SinkPlanNode(this, "DataSink ("+this.getOperator().getName()+")" ,c)); } } } // cost and prune the plans for (PlanNode node : outputPlans) { estimator.costOperator(node); } prunePlanAlternatives(outputPlans); this.cachedPlans = outputPlans; return outputPlans; }
Example #28
Source File: SingleInputNode.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
protected void instantiateCandidate(OperatorDescriptorSingle dps, Channel in, List<Set<? extends NamedChannel>> broadcastPlanChannels, List<PlanNode> target, CostEstimator estimator, RequestedGlobalProperties globPropsReq, RequestedLocalProperties locPropsReq) { final PlanNode inputSource = in.getSource(); for (List<NamedChannel> broadcastChannelsCombination: Sets.cartesianProduct(broadcastPlanChannels)) { boolean validCombination = true; boolean requiresPipelinebreaker = false; // check whether the broadcast inputs use the same plan candidate at the branching point for (int i = 0; i < broadcastChannelsCombination.size(); i++) { NamedChannel nc = broadcastChannelsCombination.get(i); PlanNode bcSource = nc.getSource(); // check branch compatibility against input if (!areBranchCompatible(bcSource, inputSource)) { validCombination = false; break; } // check branch compatibility against all other broadcast variables for (int k = 0; k < i; k++) { PlanNode otherBcSource = broadcastChannelsCombination.get(k).getSource(); if (!areBranchCompatible(bcSource, otherBcSource)) { validCombination = false; break; } } // check if there is a common predecessor and whether there is a dam on the way to all common predecessors if (in.isOnDynamicPath() && this.hereJoinedBranches != null) { for (OptimizerNode brancher : this.hereJoinedBranches) { PlanNode candAtBrancher = in.getSource().getCandidateAtBranchPoint(brancher); if (candAtBrancher == null) { // closed branch between two broadcast variables continue; } SourceAndDamReport res = in.getSource().hasDamOnPathDownTo(candAtBrancher); if (res == NOT_FOUND) { throw new CompilerException("Bug: Tracing dams for deadlock detection is broken."); } else if (res == FOUND_SOURCE) { requiresPipelinebreaker = true; break; } else if (res == FOUND_SOURCE_AND_DAM) { // good } else { throw new CompilerException(); } } } } if (!validCombination) { continue; } if (requiresPipelinebreaker) { in.setTempMode(in.getTempMode().makePipelineBreaker()); } final SingleInputPlanNode node = dps.instantiate(in, this); node.setBroadcastInputs(broadcastChannelsCombination); // compute how the strategy affects the properties GlobalProperties gProps = in.getGlobalProperties().clone(); LocalProperties lProps = in.getLocalProperties().clone(); gProps = dps.computeGlobalProperties(gProps); lProps = dps.computeLocalProperties(lProps); // filter by the user code field copies gProps = gProps.filterBySemanticProperties(getSemanticPropertiesForGlobalPropertyFiltering(), 0); lProps = lProps.filterBySemanticProperties(getSemanticPropertiesForLocalPropertyFiltering(), 0); // apply node.initProperties(gProps, lProps); node.updatePropertiesWithUniqueSets(getUniqueFields()); target.add(node); } }
Example #29
Source File: TwoInputNode.java From flink with Apache License 2.0 | 4 votes |
protected void addLocalCandidates(Channel template1, Channel template2, List<Set<? extends NamedChannel>> broadcastPlanChannels, RequestedGlobalProperties rgps1, RequestedGlobalProperties rgps2, List<PlanNode> target, LocalPropertiesPair[] validLocalCombinations, CostEstimator estimator) { for (RequestedLocalProperties ilp1 : this.input1.getInterestingProperties().getLocalProperties()) { final Channel in1 = template1.clone(); ilp1.parameterizeChannel(in1); for (RequestedLocalProperties ilp2 : this.input2.getInterestingProperties().getLocalProperties()) { final Channel in2 = template2.clone(); ilp2.parameterizeChannel(in2); for (OperatorDescriptorDual dps: getProperties()) { for (LocalPropertiesPair lpp : dps.getPossibleLocalProperties()) { if (lpp.getProperties1().isMetBy(in1.getLocalProperties()) && lpp.getProperties2().isMetBy(in2.getLocalProperties()) ) { // valid combination // for non trivial local properties, we need to check that they are co compatible // (such as when some sort order is requested, that both are the same sort order if (dps.areCoFulfilled(lpp.getProperties1(), lpp.getProperties2(), in1.getLocalProperties(), in2.getLocalProperties())) { // copy, because setting required properties and instantiation may // change the channels and should not affect prior candidates Channel in1Copy = in1.clone(); in1Copy.setRequiredLocalProps(lpp.getProperties1()); Channel in2Copy = in2.clone(); in2Copy.setRequiredLocalProps(lpp.getProperties2()); // all right, co compatible instantiate(dps, in1Copy, in2Copy, broadcastPlanChannels, target, estimator, rgps1, rgps2, ilp1, ilp2); break; } // else cannot use this pair, fall through the loop and try the next one } } } } } }
Example #30
Source File: BulkIterationNode.java From flink with Apache License 2.0 | 4 votes |
@Override public void computeInterestingPropertiesForInputs(CostEstimator estimator) { final InterestingProperties intProps = getInterestingProperties().clone(); if (this.terminationCriterion != null) { // first propagate through termination Criterion. since it has no successors, it has no // interesting properties this.terminationCriterionRootConnection.setInterestingProperties(new InterestingProperties()); this.terminationCriterion.accept(new InterestingPropertyVisitor(estimator)); } // we need to make 2 interesting property passes, because the root of the step function needs also // the interesting properties as generated by the partial solution // give our own interesting properties (as generated by the iterations successors) to the step function and // make the first pass this.rootConnection.setInterestingProperties(intProps); this.nextPartialSolution.accept(new InterestingPropertyVisitor(estimator)); // take the interesting properties of the partial solution and add them to the root interesting properties InterestingProperties partialSolutionIntProps = this.partialSolution.getInterestingProperties(); intProps.getGlobalProperties().addAll(partialSolutionIntProps.getGlobalProperties()); intProps.getLocalProperties().addAll(partialSolutionIntProps.getLocalProperties()); // clear all interesting properties to prepare the second traversal // this clears only the path down from the next partial solution. The paths down // from the termination criterion (before they meet the paths down from the next partial solution) // remain unaffected by this step this.rootConnection.clearInterestingProperties(); this.nextPartialSolution.accept(InterestingPropertiesClearer.INSTANCE); // 2nd pass this.rootConnection.setInterestingProperties(intProps); this.nextPartialSolution.accept(new InterestingPropertyVisitor(estimator)); // now add the interesting properties of the partial solution to the input final InterestingProperties inProps = this.partialSolution.getInterestingProperties().clone(); inProps.addGlobalProperties(new RequestedGlobalProperties()); inProps.addLocalProperties(new RequestedLocalProperties()); this.inConn.setInterestingProperties(inProps); }