@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { // create in input node for combine with the same parallelism as input node GroupReduceNode combinerNode = new GroupReduceNode((GroupReduceOperatorBase<?, ?, ?>) node.getOperator()); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getOperator().getName()+")", in, DriverStrategy.SORTED_GROUP_COMBINE); // sorting key info combiner.setDriverKeyInfo(in.getLocalStrategyKeys(), in.getLocalStrategySortOrder(), 0); // set grouping comparator key info combiner.setDriverKeyInfo(this.keyList, 1); return combiner; }
private List<OperatorDescriptorSingle> initPossibleProperties(Partitioner<?> customPartitioner) { final Configuration conf = getOperator().getParameters(); final String localStrategy = conf.getString(Optimizer.HINT_LOCAL_STRATEGY, null); if (!isCombineable()) { Optimizer.LOG.warn("Strategy hint for GroupReduce '" + getOperator().getName() + "' requires combinable reduce, but user function is not marked combinable."); useCombiner = isCombineable(); if (getOperator() != null) { groupOrder = getOperator().getGroupOrder(); if (groupOrder != null && groupOrder.getNumberOfFields() == 0) { groupOrder = null;
public GroupReduceNode getCombinerUtilityNode() { if (this.combinerUtilityNode == null) { this.combinerUtilityNode = new GroupReduceNode(this); // we conservatively assume the combiner returns the same data size as it consumes this.combinerUtilityNode.estimatedOutputSize = getPredecessorNode().getEstimatedOutputSize(); this.combinerUtilityNode.estimatedNumRecords = getPredecessorNode().getEstimatedNumRecords(); } return this.combinerUtilityNode; } }
/** * Creates a new optimizer node for the given operator. * * @param operator The reduce operation. */ public GroupReduceNode(GroupReduceOperatorBase<?, ?, ?> operator) { super(operator); this.operatorName = "GroupReduce"; if (this.keys == null) { // case of a key-less reducer. force a parallelism of 1 setParallelism(1); } this.possibleProperties = initPossibleProperties(operator.getCustomPartitioner()); }
@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); } }
/** * Checks, whether a combiner function has been given for the function encapsulated * by this reduce contract. * * @return True, if a combiner has been given, false otherwise. */ public boolean isCombineable() { return getOperator().isCombinable(); }
n = new GroupReduceNode((GroupReduceOperatorBase<?, ?, ?>) c);
when(op.getParameters()).thenReturn(new Configuration()); GroupReduceNode node = new GroupReduceNode(op); SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();
GroupReduceNode combinerNode = ((GroupReduceNode) node).getCombinerUtilityNode(); combinerNode.setParallelism(in.getSource().getParallelism());
/** * Creates a new optimizer node for the given operator. * * @param operator The reduce operation. */ public GroupReduceNode(GroupReduceOperatorBase<?, ?, ?> operator) { super(operator); this.operatorName = "GroupReduce"; if (this.keys == null) { // case of a key-less reducer. force a parallelism of 1 setParallelism(1); } this.possibleProperties = initPossibleProperties(operator.getCustomPartitioner()); }
@Override protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() { // Local properties for GroupReduce may only be preserved on key fields. SingleInputSemanticProperties origProps = getOperator().getSemanticProperties(); SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties(); FieldSet readSet = origProps.getReadFields(0); if(readSet != null) { filteredProps.addReadFields(readSet); } // only add forward field information for key fields if(this.keys != null) { for (int f : this.keys) { FieldSet targets = origProps.getForwardingTargetFields(0, f); for (int t : targets) { filteredProps.addForwardedField(f, t); } } } return filteredProps; }
n = new GroupReduceNode((GroupReduceOperatorBase<?, ?, ?>) c);
final UnaryOperatorInformation sicOperatorInformation = new UnaryOperatorInformation(isdTypeInformation, sourceOutputType); final GroupReduceOperatorBase sicOperatorBase = new GroupReduceOperatorBase(sampleInCoordinator, sicOperatorInformation, SIC_NAME); final GroupReduceNode sicNode = new GroupReduceNode(sicOperatorBase); final Channel sicChannel = new Channel(sipPlanNode, TempMode.NONE); sicChannel.setShipStrategy(ShipStrategyType.FORWARD, DataExchangeMode.PIPELINED); final SingleInputPlanNode sicPlanNode = new SingleInputPlanNode(sicNode, SIC_NAME, sicChannel, DriverStrategy.ALL_GROUP_REDUCE); sicNode.setParallelism(1); sicPlanNode.setParallelism(1); sicPlanNode.initProperties(new GlobalProperties(), new LocalProperties());
@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); } }
public GroupReduceNode getCombinerUtilityNode() { if (this.combinerUtilityNode == null) { this.combinerUtilityNode = new GroupReduceNode(this); // we conservatively assume the combiner returns the same data size as it consumes this.combinerUtilityNode.estimatedOutputSize = getPredecessorNode().getEstimatedOutputSize(); this.combinerUtilityNode.estimatedNumRecords = getPredecessorNode().getEstimatedNumRecords(); } return this.combinerUtilityNode; } }
/** * Creates a new optimizer node for the given operator. * * @param operator The reduce operation. */ public GroupReduceNode(GroupReduceOperatorBase<?, ?, ?> operator) { super(operator); this.operatorName = "GroupReduce"; if (this.keys == null) { // case of a key-less reducer. force a parallelism of 1 setParallelism(1); } this.possibleProperties = initPossibleProperties(operator.getCustomPartitioner()); }
private List<OperatorDescriptorSingle> initPossibleProperties(Partitioner<?> customPartitioner) { final Configuration conf = getOperator().getParameters(); final String localStrategy = conf.getString(Optimizer.HINT_LOCAL_STRATEGY, null); if (!isCombineable()) { Optimizer.LOG.warn("Strategy hint for GroupReduce '" + getOperator().getName() + "' requires combinable reduce, but user function is not marked combinable."); useCombiner = isCombineable(); if (getOperator() != null) { groupOrder = getOperator().getGroupOrder(); if (groupOrder != null && groupOrder.getNumberOfFields() == 0) { groupOrder = null;
/** * Checks, whether a combiner function has been given for the function encapsulated * by this reduce contract. * * @return True, if a combiner has been given, false otherwise. */ public boolean isCombineable() { return getOperator().isCombinable(); }
n = new GroupReduceNode((GroupReduceOperatorBase<?, ?, ?>) c);
@Override public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) { // create in input node for combine with the same parallelism as input node GroupReduceNode combinerNode = new GroupReduceNode((GroupReduceOperatorBase<?, ?, ?>) node.getOperator()); combinerNode.setParallelism(in.getSource().getParallelism()); SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine("+node.getOperator().getName()+")", in, DriverStrategy.SORTED_GROUP_COMBINE); // sorting key info combiner.setDriverKeyInfo(in.getLocalStrategyKeys(), in.getLocalStrategySortOrder(), 0); // set grouping comparator key info combiner.setDriverKeyInfo(this.keyList, 1); return combiner; }