Пример #1
0
  @Override
  public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) {
    if (in.getShipStrategy() == ShipStrategyType.FORWARD) {
      // locally connected, directly instantiate
      return new SingleInputPlanNode(
          node, "Reduce (" + node.getPactContract().getName() + ")", in, DriverStrategy.ALL_REDUCE);
    } else {
      // non forward case.plug in a combiner
      Channel toCombiner = new Channel(in.getSource());
      toCombiner.setShipStrategy(ShipStrategyType.FORWARD);

      // create an input node for combine with same DOP as input node
      ReduceNode combinerNode = ((ReduceNode) node).getCombinerUtilityNode();
      combinerNode.setDegreeOfParallelism(in.getSource().getDegreeOfParallelism());
      combinerNode.setSubtasksPerInstance(in.getSource().getSubtasksPerInstance());

      SingleInputPlanNode combiner =
          new SingleInputPlanNode(
              combinerNode,
              "Combine (" + node.getPactContract().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());
      toReducer.setLocalStrategy(
          in.getLocalStrategy(), in.getLocalStrategyKeys(), in.getLocalStrategySortOrder());
      return new SingleInputPlanNode(
          node,
          "Reduce(" + node.getPactContract().getName() + ")",
          toReducer,
          DriverStrategy.ALL_REDUCE);
    }
  }
 @Override
 public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) {
   return new SingleInputPlanNode(
       node, "Map (" + node.getPactContract().getName() + ")", in, DriverStrategy.COLLECTOR_MAP);
 }