Package eu.stratosphere.compiler.plan

Examples of eu.stratosphere.compiler.plan.Channel


    final Costs totalCosts = new Costs();
    final long availableMemory = n.getGuaranteedAvailableMemory();
   
    // add the shipping strategy costs
    for (Iterator<Channel> channels = n.getInputs(); channels.hasNext(); ) {
      final Channel channel = channels.next();
      final Costs costs = new Costs();
     
      // Plans that apply the same strategies, but at different points
      // are equally expensive. For example, if a partitioning can be
      // pushed below a Map function there is often no difference in plan
      // costs between the pushed down version and the version that partitions
      // after the Mapper. However, in those cases, we want the expensive
      // strategy to appear later in the plan, as data reduction often occurs
      // by large factors, while blowup is rare and typically by smaller fractions.
      // We achieve this by adding a penalty to small penalty to the FORWARD strategy,
      // weighted by the current plan depth (steps to the earliest data source).
      // that way, later FORWARDS are more expensive than earlier forwards.
      // Note that this only applies to the heuristic costs.
     
      switch (channel.getShipStrategy()) {
      case NONE:
        throw new CompilerException(
          "Cannot determine costs: Shipping strategy has not been set for an input.");
      case FORWARD:
//        costs.addHeuristicNetworkCost(channel.getMaxDepth());
        break;
      case PARTITION_LOCAL_HASH:
        break;
      case PARTITION_RANDOM:
        addRandomPartitioningCost(channel, costs);
        break;
      case PARTITION_HASH:
        addHashPartitioningCost(channel, costs);
        break;
      case PARTITION_RANGE:
        addRangePartitionCost(channel, costs);
        break;
      case BROADCAST:
        addBroadcastCost(channel, channel.getReplicationFactor(), costs);
        break;
      default:
        throw new CompilerException("Unknown shipping strategy for input: " + channel.getShipStrategy());
      }
     
      switch (channel.getLocalStrategy()) {
      case NONE:
        break;
      case SORT:
      case COMBININGSORT:
        addLocalSortCost(channel, availableMemory, costs);
        break;
      default:
        throw new CompilerException("Unsupported local strategy for input: " + channel.getLocalStrategy());
      }
     
      if (channel.getTempMode() != null && channel.getTempMode() != TempMode.NONE) {
        addArtificialDamCost(channel, 0, costs);
      }
     
      // adjust with the cost weight factor
      if (channel.isOnDynamicPath()) {
        costs.multiplyWith(channel.getCostWeight());
      }
     
      totalCosts.addCosts(costs);
    }
   
    Channel firstInput = null;
    Channel secondInput = null;
    Costs driverCosts = new Costs();
   
    // get the inputs, if we have some
    {
      Iterator<Channel> channels = n.getInputs();
View Full Code Here


        in.setLocalStrategy(LocalStrategy.COMBININGSORT, in.getLocalStrategyKeys(), in.getLocalStrategySortOrder());
      }
      return new SingleInputPlanNode(node, "Reduce("+node.getPactContract().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);
      // create an input node for combine with same DOP as input node
      GroupReduceNode combinerNode = ((GroupReduceNode) node).getCombinerUtilityNode();
      combinerNode.setDegreeOfParallelism(in.getSource().getDegreeOfParallelism());
      combinerNode.setSubtasksPerInstance(in.getSource().getSubtasksPerInstance());
     
      SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getPactContract().getName()+")", toCombiner, DriverStrategy.SORTED_GROUP_COMBINE, this.keyList);
      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(LocalStrategy.COMBININGSORT, in.getLocalStrategyKeys(), in.getLocalStrategySortOrder());
      return new SingleInputPlanNode(node, "Reduce ("+node.getPactContract().getName()+")", toReducer, DriverStrategy.SORTED_GROUP_REDUCE, this.keyList);
    }
  }
View Full Code Here

      // verify the strategies
      Assert.assertEquals(ShipStrategyType.FORWARD, mapper.getInput().getShipStrategy());
      Assert.assertEquals(ShipStrategyType.PARTITION_HASH, reducer.getInput().getShipStrategy());
      Assert.assertEquals(ShipStrategyType.FORWARD, sink.getInput().getShipStrategy());
     
      Channel c = reducer.getInput();
      Assert.assertEquals(LocalStrategy.COMBININGSORT, c.getLocalStrategy());
      FieldList l = new FieldList(0);
      Assert.assertEquals(l, c.getShipStrategyKeys());
      Assert.assertEquals(l, c.getLocalStrategyKeys());
      Assert.assertTrue(Arrays.equals(c.getLocalStrategySortOrder(), reducer.getSortOrders()));
     
      // check the combiner
      SingleInputPlanNode combiner = (SingleInputPlanNode) reducer.getPredecessor();
      Assert.assertEquals(DriverStrategy.SORTED_GROUP_COMBINE, combiner.getDriverStrategy());
      Assert.assertEquals(l, combiner.getKeys());
View Full Code Here

     
      Assert.assertEquals(ShipStrategyType.FORWARD, mapper.getInput().getShipStrategy());
      Assert.assertEquals(ShipStrategyType.PARTITION_RANGE, reducer.getInput().getShipStrategy());
      Assert.assertEquals(ShipStrategyType.FORWARD, sink.getInput().getShipStrategy());
     
      Channel c = reducer.getInput();
      Assert.assertEquals(LocalStrategy.COMBININGSORT, c.getLocalStrategy());
      FieldList l = new FieldList(0);
      Assert.assertEquals(l, c.getShipStrategyKeys());
      Assert.assertEquals(l, c.getLocalStrategyKeys());
     
      // check that the sort orders are descending
      Assert.assertFalse(c.getShipStrategySortOrder()[0]);
      Assert.assertFalse(c.getLocalStrategySortOrder()[0]);
     
      // check the combiner
      SingleInputPlanNode combiner = (SingleInputPlanNode) reducer.getPredecessor();
      Assert.assertEquals(DriverStrategy.SORTED_GROUP_COMBINE, combiner.getDriverStrategy());
      Assert.assertEquals(l, combiner.getKeys());
View Full Code Here

     
      @Override
      public boolean preVisit(PlanNode visitable) {
        if (visitable instanceof SingleInputPlanNode && visitable.getPactContract() instanceof ReduceOperator) {
          for (Iterator<Channel> inputs = visitable.getInputs(); inputs.hasNext();) {
            final Channel inConn = inputs.next();
            Assert.assertTrue("Reduce should just forward the input if it is already partitioned",
                inConn.getShipStrategy() == ShipStrategyType.FORWARD);
          }
          //just check latest ReduceNode
          return false;
        }
        return true;
View Full Code Here

       
        /* Test on the union output connections
         * It must be under the GroupOperator and the strategy should be forward
         */
        if (visitable instanceof SingleInputPlanNode && visitable.getPactContract() instanceof GroupReduceOperatorBase){
          final Channel inConn = ((SingleInputPlanNode) visitable).getInput();
          Assert.assertTrue("Union should just forward the Partitioning",
              inConn.getShipStrategy() == ShipStrategyType.FORWARD );
          Assert.assertTrue("Union Node should be under Group operator",
              inConn.getSource() instanceof NAryUnionPlanNode );
        }
       
        /* Test on the union input connections
         * Must be NUM_INPUTS input connections, all FlatMapOperators with a own partitioning strategy(propably hash)
         */
        if (visitable instanceof NAryUnionPlanNode) {
          int numberInputs = 0;
          for (Iterator<Channel> inputs = visitable.getInputs(); inputs.hasNext(); numberInputs++) {
            final Channel inConn = inputs.next();
            PlanNode inNode = inConn.getSource();
            Assert.assertTrue("Input of Union should be FlatMapOperators",
                inNode.getPactContract() instanceof FlatMapOperatorBase);
            Assert.assertTrue("Shipment strategy under union should partition the data",
                inConn.getShipStrategy() == ShipStrategyType.PARTITION_HASH);
          }
         
          Assert.assertTrue("NAryUnion should have " + NUM_INPUTS + " inputs", numberInputs == NUM_INPUTS);
          return false;
        }
View Full Code Here

     
      @Override
      public boolean preVisit(PlanNode visitable) {
        if (visitable instanceof DualInputPlanNode) {
          DualInputPlanNode node = (DualInputPlanNode) visitable;
          Channel c1 = node.getInput1();
          Channel c2 = node.getInput2();
         
          Assert.assertEquals("Incompatible shipping strategy chosen for match", ShipStrategyType.FORWARD, c1.getShipStrategy());
          Assert.assertEquals("Incompatible shipping strategy chosen for match", ShipStrategyType.PARTITION_HASH, c2.getShipStrategy());
          return false;
        }
        return true;
      }
     
View Full Code Here

   
    // verify the strategies
    Assert.assertEquals(ShipStrategyType.FORWARD, sinkNode.getInput().getShipStrategy());
    Assert.assertEquals(ShipStrategyType.PARTITION_HASH, reducer.getInput().getShipStrategy());
   
    Channel c = reducer.getInput();
    Assert.assertEquals(LocalStrategy.SORT, c.getLocalStrategy());
   
    FieldList ship = new FieldList(2);
    FieldList local = new FieldList(2);
    local.add(5);
    Assert.assertEquals(ship, c.getShipStrategyKeys());
    Assert.assertEquals(local, c.getLocalStrategyKeys());
    Assert.assertTrue(c.getLocalStrategySortOrder()[0] == reducer.getSortOrders()[0]);
   
    // check that we indeed sort descending
    Assert.assertTrue(c.getLocalStrategySortOrder()[1] == groupOrder.getFieldSortDirections()[0]);
  }
View Full Code Here

    // verify the strategies
    Assert.assertEquals(ShipStrategyType.FORWARD, sinkNode.getInput().getShipStrategy());
    Assert.assertEquals(ShipStrategyType.PARTITION_HASH, coGroupNode.getInput1().getShipStrategy());
    Assert.assertEquals(ShipStrategyType.PARTITION_HASH, coGroupNode.getInput2().getShipStrategy());
   
    Channel c1 = coGroupNode.getInput1();
    Channel c2 = coGroupNode.getInput2();
   
    Assert.assertEquals(LocalStrategy.SORT, c1.getLocalStrategy());
    Assert.assertEquals(LocalStrategy.SORT, c2.getLocalStrategy());
   
    FieldList ship1 = new FieldList(new int[] {3, 0});
    FieldList ship2 = new FieldList(new int[] {6, 0});
   
    FieldList local1 = new FieldList(new int[] {3, 0, 5});
    FieldList local2 = new FieldList(new int[] {6, 0, 1, 4});
   
    Assert.assertEquals(ship1, c1.getShipStrategyKeys());
    Assert.assertEquals(ship2, c2.getShipStrategyKeys());
    Assert.assertEquals(local1, c1.getLocalStrategyKeys());
    Assert.assertEquals(local2, c2.getLocalStrategyKeys());
   
    Assert.assertTrue(c1.getLocalStrategySortOrder()[0] == coGroupNode.getSortOrders()[0]);
    Assert.assertTrue(c1.getLocalStrategySortOrder()[1] == coGroupNode.getSortOrders()[1]);
    Assert.assertTrue(c2.getLocalStrategySortOrder()[0] == coGroupNode.getSortOrders()[0]);
    Assert.assertTrue(c2.getLocalStrategySortOrder()[1] == coGroupNode.getSortOrders()[1]);
   
    // check that the local group orderings are correct
    Assert.assertTrue(c1.getLocalStrategySortOrder()[2] == groupOrder1.getFieldSortDirections()[0]);
    Assert.assertTrue(c2.getLocalStrategySortOrder()[2] == groupOrder2.getFieldSortDirections()[0]);
    Assert.assertTrue(c2.getLocalStrategySortOrder()[3] == groupOrder2.getFieldSortDirections()[1]);
  }
View Full Code Here

    try {
      OptimizedPlan oPlan = compileNoStats(plan);
      OptimizerPlanNodeResolver resolver = new OptimizerPlanNodeResolver(oPlan);
     
      DualInputPlanNode crossPlanNode = resolver.getNode("Cross");
      Channel in1 = crossPlanNode.getInput1();
      Channel in2 = crossPlanNode.getInput2();
     
      assertEquals(ShipStrategyType.FORWARD, in1.getShipStrategy());
      assertEquals(ShipStrategyType.BROADCAST, in2.getShipStrategy());
    } catch(CompilerException ce) {
      ce.printStackTrace();
      fail("The pact compiler is unable to compile this plan correctly.");
    }
  }
View Full Code Here

TOP

Related Classes of eu.stratosphere.compiler.plan.Channel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.