org.apache.flink.optimizer.costs.Costs Java Examples
The following examples show how to use
org.apache.flink.optimizer.costs.Costs.
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: NAryUnionPlanNode.java From flink with Apache License 2.0 | 5 votes |
/** * @param template */ public NAryUnionPlanNode(BinaryUnionNode template, List<Channel> inputs, GlobalProperties gProps, Costs cumulativeCosts) { super(template, "Union", DriverStrategy.NONE); this.inputs = inputs; this.globalProps = gProps; this.localProps = new LocalProperties(); this.nodeCosts = new Costs(); this.cumulativeCosts = cumulativeCosts; }
Example #2
Source File: PlanNode.java From flink with Apache License 2.0 | 5 votes |
/** * Sets the basic cost for this node to the given value, and sets the cumulative costs * to those costs plus the cost shares of all inputs (regular and broadcast). * * @param nodeCosts The already knows costs for this node * (this cost a produces by a concrete {@code OptimizerNode} subclass. */ public void setCosts(Costs nodeCosts) { // set the node costs this.nodeCosts = nodeCosts; // the cumulative costs are the node costs plus the costs of all inputs this.cumulativeCosts = nodeCosts.clone(); // add all the normal inputs for (PlanNode pred : getPredecessors()) { Costs parentCosts = pred.getCumulativeCostsShare(); if (parentCosts != null) { this.cumulativeCosts.addCosts(parentCosts); } else { throw new CompilerException("Trying to set the costs of an operator before the predecessor costs are computed."); } } // add all broadcast variable inputs if (this.broadcastInputs != null) { for (NamedChannel nc : this.broadcastInputs) { Costs bcInputCost = nc.getSource().getCumulativeCostsShare(); if (bcInputCost != null) { this.cumulativeCosts.addCosts(bcInputCost); } else { throw new CompilerException("Trying to set the costs of an operator before the broadcast input costs are computed."); } } } }
Example #3
Source File: PlanNode.java From flink with Apache License 2.0 | 5 votes |
public Costs getCumulativeCostsShare() { if (this.cumulativeCosts == null) { return null; } else { Costs result = cumulativeCosts.clone(); if (this.template.getOutgoingConnections() != null) { int outDegree = this.template.getOutgoingConnections().size(); if (outDegree > 0) { result.divideBy(outDegree); } } return result; } }
Example #4
Source File: SinkJoinerPlanNode.java From flink with Apache License 2.0 | 5 votes |
public void setCosts(Costs nodeCosts) { // the plan enumeration logic works as for regular two-input-operators, which is important // because of the branch handling logic. it does pick redistributing network channels // between the sink and the sink joiner, because sinks joiner has a different parallelism than the sink. // we discard any cost and simply use the sum of the costs from the two children. Costs totalCosts = getInput1().getSource().getCumulativeCosts().clone(); totalCosts.addCosts(getInput2().getSource().getCumulativeCosts()); super.setCosts(totalCosts); }
Example #5
Source File: NAryUnionPlanNode.java From flink with Apache License 2.0 | 5 votes |
/** * @param template */ public NAryUnionPlanNode(BinaryUnionNode template, List<Channel> inputs, GlobalProperties gProps, Costs cumulativeCosts) { super(template, "Union", DriverStrategy.NONE); this.inputs = inputs; this.globalProps = gProps; this.localProps = new LocalProperties(); this.nodeCosts = new Costs(); this.cumulativeCosts = cumulativeCosts; }
Example #6
Source File: BulkIterationPlanNode.java From flink with Apache License 2.0 | 5 votes |
public void setCosts(Costs nodeCosts) { // add the costs from the step function nodeCosts.addCosts(this.rootOfStepFunction.getCumulativeCosts()); // add the costs for the termination criterion, if it exists // the costs are divided at branches, so we can simply add them up if (rootOfTerminationCriterion != null) { nodeCosts.addCosts(this.rootOfTerminationCriterion.getCumulativeCosts()); } super.setCosts(nodeCosts); }
Example #7
Source File: WorksetIterationPlanNode.java From flink with Apache License 2.0 | 5 votes |
public void setCosts(Costs nodeCosts) { // add the costs from the step function nodeCosts.addCosts(this.solutionSetDeltaPlanNode.getCumulativeCostsShare()); nodeCosts.addCosts(this.nextWorkSetPlanNode.getCumulativeCostsShare()); super.setCosts(nodeCosts); }
Example #8
Source File: AllReduceProperties.java From flink with Apache License 2.0 | 5 votes |
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { if (in.getShipStrategy() == ShipStrategyType.FORWARD) { // locally connected, directly instantiate return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", in, DriverStrategy.ALL_REDUCE); } else { // non forward case.plug in a combiner Channel toCombiner = new Channel(in.getSource()); toCombiner.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); // create an input node for combine with same parallelism as input node ReduceNode combinerNode = ((ReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator().getName()+")", toCombiner, DriverStrategy.ALL_REDUCE); combiner.setCosts(new Costs(0, 0)); combiner.initProperties(toCombiner.getGlobalProperties(), toCombiner.getLocalProperties()); Channel toReducer = new Channel(combiner); toReducer.setShipStrategy(in.getShipStrategy(), in.getShipStrategyKeys(), in.getShipStrategySortOrder(), in.getDataExchangeMode()); toReducer.setLocalStrategy(in.getLocalStrategy(), in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", toReducer, DriverStrategy.ALL_REDUCE); } }
Example #9
Source File: AllGroupWithPartialPreGroupProperties.java From flink with Apache License 2.0 | 5 votes |
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { if (in.getShipStrategy() == ShipStrategyType.FORWARD) { // locally connected, directly instantiate return new SingleInputPlanNode(node, "GroupReduce ("+node.getOperator().getName()+")", in, DriverStrategy.ALL_GROUP_REDUCE); } else { // non forward case.plug in a combiner Channel toCombiner = new Channel(in.getSource()); toCombiner.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); // create an input node for combine with same parallelism as input node GroupReduceNode combinerNode = ((GroupReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator().getName()+")", toCombiner, DriverStrategy.ALL_GROUP_REDUCE_COMBINE); combiner.setCosts(new Costs(0, 0)); combiner.initProperties(toCombiner.getGlobalProperties(), toCombiner.getLocalProperties()); Channel toReducer = new Channel(combiner); toReducer.setShipStrategy(in.getShipStrategy(), in.getShipStrategyKeys(), in.getShipStrategySortOrder(), in.getDataExchangeMode()); toReducer.setLocalStrategy(in.getLocalStrategy(), in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); return new SingleInputPlanNode(node, "GroupReduce ("+node.getOperator().getName()+")", toReducer, DriverStrategy.ALL_GROUP_REDUCE); } }
Example #10
Source File: PlanNode.java From flink with Apache License 2.0 | 5 votes |
/** * Sets the basic cost for this node to the given value, and sets the cumulative costs * to those costs plus the cost shares of all inputs (regular and broadcast). * * @param nodeCosts The already knows costs for this node * (this cost a produces by a concrete {@code OptimizerNode} subclass. */ public void setCosts(Costs nodeCosts) { // set the node costs this.nodeCosts = nodeCosts; // the cumulative costs are the node costs plus the costs of all inputs this.cumulativeCosts = nodeCosts.clone(); // add all the normal inputs for (PlanNode pred : getPredecessors()) { Costs parentCosts = pred.getCumulativeCostsShare(); if (parentCosts != null) { this.cumulativeCosts.addCosts(parentCosts); } else { throw new CompilerException("Trying to set the costs of an operator before the predecessor costs are computed."); } } // add all broadcast variable inputs if (this.broadcastInputs != null) { for (NamedChannel nc : this.broadcastInputs) { Costs bcInputCost = nc.getSource().getCumulativeCostsShare(); if (bcInputCost != null) { this.cumulativeCosts.addCosts(bcInputCost); } else { throw new CompilerException("Trying to set the costs of an operator before the broadcast input costs are computed."); } } } }
Example #11
Source File: PlanNode.java From flink with Apache License 2.0 | 5 votes |
public Costs getCumulativeCostsShare() { if (this.cumulativeCosts == null) { return null; } else { Costs result = cumulativeCosts.clone(); if (this.template.getOutgoingConnections() != null) { int outDegree = this.template.getOutgoingConnections().size(); if (outDegree > 0) { result.divideBy(outDegree); } } return result; } }
Example #12
Source File: SinkJoinerPlanNode.java From flink with Apache License 2.0 | 5 votes |
public void setCosts(Costs nodeCosts) { // the plan enumeration logic works as for regular two-input-operators, which is important // because of the branch handling logic. it does pick redistributing network channels // between the sink and the sink joiner, because sinks joiner has a different parallelism than the sink. // we discard any cost and simply use the sum of the costs from the two children. Costs totalCosts = getInput1().getSource().getCumulativeCosts().clone(); totalCosts.addCosts(getInput2().getSource().getCumulativeCosts()); super.setCosts(totalCosts); }
Example #13
Source File: BulkIterationPlanNode.java From flink with Apache License 2.0 | 5 votes |
public void setCosts(Costs nodeCosts) { // add the costs from the step function nodeCosts.addCosts(this.rootOfStepFunction.getCumulativeCosts()); // add the costs for the termination criterion, if it exists // the costs are divided at branches, so we can simply add them up if (rootOfTerminationCriterion != null) { nodeCosts.addCosts(this.rootOfTerminationCriterion.getCumulativeCosts()); } super.setCosts(nodeCosts); }
Example #14
Source File: WorksetIterationPlanNode.java From flink with Apache License 2.0 | 5 votes |
public void setCosts(Costs nodeCosts) { // add the costs from the step function nodeCosts.addCosts(this.solutionSetDeltaPlanNode.getCumulativeCostsShare()); nodeCosts.addCosts(this.nextWorkSetPlanNode.getCumulativeCostsShare()); super.setCosts(nodeCosts); }
Example #15
Source File: AllGroupWithPartialPreGroupProperties.java From flink with Apache License 2.0 | 5 votes |
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { if (in.getShipStrategy() == ShipStrategyType.FORWARD) { // locally connected, directly instantiate return new SingleInputPlanNode(node, "GroupReduce ("+node.getOperator().getName()+")", in, DriverStrategy.ALL_GROUP_REDUCE); } else { // non forward case.plug in a combiner Channel toCombiner = new Channel(in.getSource()); toCombiner.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); // create an input node for combine with same parallelism as input node GroupReduceNode combinerNode = ((GroupReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator().getName()+")", toCombiner, DriverStrategy.ALL_GROUP_REDUCE_COMBINE); combiner.setCosts(new Costs(0, 0)); combiner.initProperties(toCombiner.getGlobalProperties(), toCombiner.getLocalProperties()); Channel toReducer = new Channel(combiner); toReducer.setShipStrategy(in.getShipStrategy(), in.getShipStrategyKeys(), in.getShipStrategySortOrder(), in.getDataExchangeMode()); toReducer.setLocalStrategy(in.getLocalStrategy(), in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); return new SingleInputPlanNode(node, "GroupReduce ("+node.getOperator().getName()+")", toReducer, DriverStrategy.ALL_GROUP_REDUCE); } }
Example #16
Source File: AllGroupWithPartialPreGroupProperties.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { if (in.getShipStrategy() == ShipStrategyType.FORWARD) { // locally connected, directly instantiate return new SingleInputPlanNode(node, "GroupReduce ("+node.getOperator().getName()+")", in, DriverStrategy.ALL_GROUP_REDUCE); } else { // non forward case.plug in a combiner Channel toCombiner = new Channel(in.getSource()); toCombiner.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); // create an input node for combine with same parallelism as input node GroupReduceNode combinerNode = ((GroupReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator().getName()+")", toCombiner, DriverStrategy.ALL_GROUP_REDUCE_COMBINE); combiner.setCosts(new Costs(0, 0)); combiner.initProperties(toCombiner.getGlobalProperties(), toCombiner.getLocalProperties()); Channel toReducer = new Channel(combiner); toReducer.setShipStrategy(in.getShipStrategy(), in.getShipStrategyKeys(), in.getShipStrategySortOrder(), in.getDataExchangeMode()); toReducer.setLocalStrategy(in.getLocalStrategy(), in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); return new SingleInputPlanNode(node, "GroupReduce ("+node.getOperator().getName()+")", toReducer, DriverStrategy.ALL_GROUP_REDUCE); } }
Example #17
Source File: AllReduceProperties.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { if (in.getShipStrategy() == ShipStrategyType.FORWARD) { // locally connected, directly instantiate return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", in, DriverStrategy.ALL_REDUCE); } else { // non forward case.plug in a combiner Channel toCombiner = new Channel(in.getSource()); toCombiner.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); // create an input node for combine with same parallelism as input node ReduceNode combinerNode = ((ReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator().getName()+")", toCombiner, DriverStrategy.ALL_REDUCE); combiner.setCosts(new Costs(0, 0)); combiner.initProperties(toCombiner.getGlobalProperties(), toCombiner.getLocalProperties()); Channel toReducer = new Channel(combiner); toReducer.setShipStrategy(in.getShipStrategy(), in.getShipStrategyKeys(), in.getShipStrategySortOrder(), in.getDataExchangeMode()); toReducer.setLocalStrategy(in.getLocalStrategy(), in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", toReducer, DriverStrategy.ALL_REDUCE); } }
Example #18
Source File: WorksetIterationPlanNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public void setCosts(Costs nodeCosts) { // add the costs from the step function nodeCosts.addCosts(this.solutionSetDeltaPlanNode.getCumulativeCostsShare()); nodeCosts.addCosts(this.nextWorkSetPlanNode.getCumulativeCostsShare()); super.setCosts(nodeCosts); }
Example #19
Source File: BulkIterationPlanNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public void setCosts(Costs nodeCosts) { // add the costs from the step function nodeCosts.addCosts(this.rootOfStepFunction.getCumulativeCosts()); // add the costs for the termination criterion, if it exists // the costs are divided at branches, so we can simply add them up if (rootOfTerminationCriterion != null) { nodeCosts.addCosts(this.rootOfTerminationCriterion.getCumulativeCosts()); } super.setCosts(nodeCosts); }
Example #20
Source File: NAryUnionPlanNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * @param template */ public NAryUnionPlanNode(BinaryUnionNode template, List<Channel> inputs, GlobalProperties gProps, Costs cumulativeCosts) { super(template, "Union", DriverStrategy.NONE); this.inputs = inputs; this.globalProps = gProps; this.localProps = new LocalProperties(); this.nodeCosts = new Costs(); this.cumulativeCosts = cumulativeCosts; }
Example #21
Source File: SinkJoinerPlanNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public void setCosts(Costs nodeCosts) { // the plan enumeration logic works as for regular two-input-operators, which is important // because of the branch handling logic. it does pick redistributing network channels // between the sink and the sink joiner, because sinks joiner has a different parallelism than the sink. // we discard any cost and simply use the sum of the costs from the two children. Costs totalCosts = getInput1().getSource().getCumulativeCosts().clone(); totalCosts.addCosts(getInput2().getSource().getCumulativeCosts()); super.setCosts(totalCosts); }
Example #22
Source File: PlanNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public Costs getCumulativeCostsShare() { if (this.cumulativeCosts == null) { return null; } else { Costs result = cumulativeCosts.clone(); if (this.template.getOutgoingConnections() != null) { int outDegree = this.template.getOutgoingConnections().size(); if (outDegree > 0) { result.divideBy(outDegree); } } return result; } }
Example #23
Source File: PlanNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Sets the basic cost for this node to the given value, and sets the cumulative costs * to those costs plus the cost shares of all inputs (regular and broadcast). * * @param nodeCosts The already knows costs for this node * (this cost a produces by a concrete {@code OptimizerNode} subclass. */ public void setCosts(Costs nodeCosts) { // set the node costs this.nodeCosts = nodeCosts; // the cumulative costs are the node costs plus the costs of all inputs this.cumulativeCosts = nodeCosts.clone(); // add all the normal inputs for (PlanNode pred : getPredecessors()) { Costs parentCosts = pred.getCumulativeCostsShare(); if (parentCosts != null) { this.cumulativeCosts.addCosts(parentCosts); } else { throw new CompilerException("Trying to set the costs of an operator before the predecessor costs are computed."); } } // add all broadcast variable inputs if (this.broadcastInputs != null) { for (NamedChannel nc : this.broadcastInputs) { Costs bcInputCost = nc.getSource().getCumulativeCostsShare(); if (bcInputCost != null) { this.cumulativeCosts.addCosts(bcInputCost); } else { throw new CompilerException("Trying to set the costs of an operator before the broadcast input costs are computed."); } } } }
Example #24
Source File: AllReduceProperties.java From flink with Apache License 2.0 | 5 votes |
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { if (in.getShipStrategy() == ShipStrategyType.FORWARD) { // locally connected, directly instantiate return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", in, DriverStrategy.ALL_REDUCE); } else { // non forward case.plug in a combiner Channel toCombiner = new Channel(in.getSource()); toCombiner.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); // create an input node for combine with same parallelism as input node ReduceNode combinerNode = ((ReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator().getName()+")", toCombiner, DriverStrategy.ALL_REDUCE); combiner.setCosts(new Costs(0, 0)); combiner.initProperties(toCombiner.getGlobalProperties(), toCombiner.getLocalProperties()); Channel toReducer = new Channel(combiner); toReducer.setShipStrategy(in.getShipStrategy(), in.getShipStrategyKeys(), in.getShipStrategySortOrder(), in.getDataExchangeMode()); toReducer.setLocalStrategy(in.getLocalStrategy(), in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", toReducer, DriverStrategy.ALL_REDUCE); } }
Example #25
Source File: GroupReduceWithCombineProperties.java From flink with Apache License 2.0 | 4 votes |
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { if (in.getShipStrategy() == ShipStrategyType.FORWARD) { if(in.getSource().getOptimizerNode() instanceof PartitionNode) { LOG.warn("Cannot automatically inject combiner for GroupReduceFunction. Please add an explicit combiner with combineGroup() in front of the partition operator."); } // adjust a sort (changes grouping, so it must be for this driver to combining sort if (in.getLocalStrategy() == LocalStrategy.SORT) { if (!in.getLocalStrategyKeys().isValidUnorderedPrefix(this.keys)) { throw new RuntimeException("Bug: Inconsistent sort for group strategy."); } in.setLocalStrategy(LocalStrategy.COMBININGSORT, in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); } return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", in, DriverStrategy.SORTED_GROUP_REDUCE, this.keyList); } else { // non forward case. all local properties are killed anyways, so we can safely plug in a combiner Channel toCombiner = new Channel(in.getSource()); toCombiner.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); // create an input node for combine with same parallelism as input node GroupReduceNode combinerNode = ((GroupReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator() .getName()+")", toCombiner, DriverStrategy.SORTED_GROUP_COMBINE); combiner.setCosts(new Costs(0, 0)); combiner.initProperties(toCombiner.getGlobalProperties(), toCombiner.getLocalProperties()); // set sorting comparator key info combiner.setDriverKeyInfo(in.getLocalStrategyKeys(), in.getLocalStrategySortOrder(), 0); // set grouping comparator key info combiner.setDriverKeyInfo(this.keyList, 1); Channel toReducer = new Channel(combiner); toReducer.setShipStrategy(in.getShipStrategy(), in.getShipStrategyKeys(), in.getShipStrategySortOrder(), in.getDataExchangeMode()); if (in.getShipStrategy() == ShipStrategyType.PARTITION_RANGE) { toReducer.setDataDistribution(in.getDataDistribution()); } toReducer.setLocalStrategy(LocalStrategy.COMBININGSORT, in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", toReducer, DriverStrategy.SORTED_GROUP_REDUCE, this.keyList); } }
Example #26
Source File: GroupReduceWithCombineProperties.java From flink with Apache License 2.0 | 4 votes |
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { if (in.getShipStrategy() == ShipStrategyType.FORWARD) { if(in.getSource().getOptimizerNode() instanceof PartitionNode) { LOG.warn("Cannot automatically inject combiner for GroupReduceFunction. Please add an explicit combiner with combineGroup() in front of the partition operator."); } // adjust a sort (changes grouping, so it must be for this driver to combining sort if (in.getLocalStrategy() == LocalStrategy.SORT) { if (!in.getLocalStrategyKeys().isValidUnorderedPrefix(this.keys)) { throw new RuntimeException("Bug: Inconsistent sort for group strategy."); } in.setLocalStrategy(LocalStrategy.COMBININGSORT, in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); } return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", in, DriverStrategy.SORTED_GROUP_REDUCE, this.keyList); } else { // non forward case. all local properties are killed anyways, so we can safely plug in a combiner Channel toCombiner = new Channel(in.getSource()); toCombiner.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); // create an input node for combine with same parallelism as input node GroupReduceNode combinerNode = ((GroupReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator() .getName()+")", toCombiner, DriverStrategy.SORTED_GROUP_COMBINE); combiner.setCosts(new Costs(0, 0)); combiner.initProperties(toCombiner.getGlobalProperties(), toCombiner.getLocalProperties()); // set sorting comparator key info combiner.setDriverKeyInfo(in.getLocalStrategyKeys(), in.getLocalStrategySortOrder(), 0); // set grouping comparator key info combiner.setDriverKeyInfo(this.keyList, 1); Channel toReducer = new Channel(combiner); toReducer.setShipStrategy(in.getShipStrategy(), in.getShipStrategyKeys(), in.getShipStrategySortOrder(), in.getDataExchangeMode()); if (in.getShipStrategy() == ShipStrategyType.PARTITION_RANGE) { toReducer.setDataDistribution(in.getDataDistribution()); } toReducer.setLocalStrategy(LocalStrategy.COMBININGSORT, in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", toReducer, DriverStrategy.SORTED_GROUP_REDUCE, this.keyList); } }
Example #27
Source File: GroupReduceWithCombineProperties.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { if (in.getShipStrategy() == ShipStrategyType.FORWARD) { if(in.getSource().getOptimizerNode() instanceof PartitionNode) { LOG.warn("Cannot automatically inject combiner for GroupReduceFunction. Please add an explicit combiner with combineGroup() in front of the partition operator."); } // adjust a sort (changes grouping, so it must be for this driver to combining sort if (in.getLocalStrategy() == LocalStrategy.SORT) { if (!in.getLocalStrategyKeys().isValidUnorderedPrefix(this.keys)) { throw new RuntimeException("Bug: Inconsistent sort for group strategy."); } in.setLocalStrategy(LocalStrategy.COMBININGSORT, in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); } return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", in, DriverStrategy.SORTED_GROUP_REDUCE, this.keyList); } else { // non forward case. all local properties are killed anyways, so we can safely plug in a combiner Channel toCombiner = new Channel(in.getSource()); toCombiner.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); // create an input node for combine with same parallelism as input node GroupReduceNode combinerNode = ((GroupReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator() .getName()+")", toCombiner, DriverStrategy.SORTED_GROUP_COMBINE); combiner.setCosts(new Costs(0, 0)); combiner.initProperties(toCombiner.getGlobalProperties(), toCombiner.getLocalProperties()); // set sorting comparator key info combiner.setDriverKeyInfo(in.getLocalStrategyKeys(), in.getLocalStrategySortOrder(), 0); // set grouping comparator key info combiner.setDriverKeyInfo(this.keyList, 1); Channel toReducer = new Channel(combiner); toReducer.setShipStrategy(in.getShipStrategy(), in.getShipStrategyKeys(), in.getShipStrategySortOrder(), in.getDataExchangeMode()); if (in.getShipStrategy() == ShipStrategyType.PARTITION_RANGE) { toReducer.setDataDistribution(in.getDataDistribution()); } toReducer.setLocalStrategy(LocalStrategy.COMBININGSORT, in.getLocalStrategyKeys(), in.getLocalStrategySortOrder()); return new SingleInputPlanNode(node, "Reduce ("+node.getOperator().getName()+")", toReducer, DriverStrategy.SORTED_GROUP_REDUCE, this.keyList); } }
Example #28
Source File: PlanNode.java From Flink-CEPplus with Apache License 2.0 | 2 votes |
/** * Gets the cumulative costs of this nose. The cumulative costs are the sum of the costs * of this node and of all nodes in the subtree below this node. * * @return The cumulative costs, or null, if not yet set. */ public Costs getCumulativeCosts() { return this.cumulativeCosts; }
Example #29
Source File: PlanNode.java From Flink-CEPplus with Apache License 2.0 | 2 votes |
/** * Gets the costs incurred by this node. The costs reflect also the costs incurred by the shipping strategies * of the incoming connections. * * @return The node-costs, or null, if not yet set. */ public Costs getNodeCosts() { return this.nodeCosts; }
Example #30
Source File: PlanNode.java From flink with Apache License 2.0 | 2 votes |
/** * Gets the cumulative costs of this nose. The cumulative costs are the sum of the costs * of this node and of all nodes in the subtree below this node. * * @return The cumulative costs, or null, if not yet set. */ public Costs getCumulativeCosts() { return this.cumulativeCosts; }