Package org.apache.flink.compiler.plan

Examples of org.apache.flink.compiler.plan.SingleInputPlanNode


    return DriverStrategy.ALL_GROUP_REDUCE;
  }

  @Override
  public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) {
    return new SingleInputPlanNode(node, "GroupReduce ("+node.getPactContract().getName()+")", in, DriverStrategy.ALL_GROUP_REDUCE);
  }
View Full Code Here


      }
     
      // get the optimizer plan nodes
      OptimizerPlanNodeResolver resolver = getOptimizerPlanNodeResolver(plan);
      SinkPlanNode sink = resolver.getNode("Word Counts");
      SingleInputPlanNode reducer = resolver.getNode("Count Words");
      SingleInputPlanNode mapper = resolver.getNode("Tokenize Lines");
     
      // 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(0)));
     
      // check the combiner
      SingleInputPlanNode combiner = (SingleInputPlanNode) reducer.getPredecessor();
      Assert.assertEquals(DriverStrategy.SORTED_GROUP_COMBINE, combiner.getDriverStrategy());
      Assert.assertEquals(l, combiner.getKeys(0));
      Assert.assertEquals(ShipStrategyType.FORWARD, combiner.getInput().getShipStrategy());
     
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }
View Full Code Here

         
          UnaryOperatorNode rebuildWorksetPropertiesNode = new UnaryOperatorNode("Rebuild Workset Properties", FieldList.EMPTY_LIST);
         
          rebuildWorksetPropertiesNode.setDegreeOfParallelism(candidate.getDegreeOfParallelism());
         
          SingleInputPlanNode rebuildWorksetPropertiesPlanNode = new SingleInputPlanNode(rebuildWorksetPropertiesNode, "Rebuild Workset Properties", toNoOp, DriverStrategy.UNARY_NO_OP);
          rebuildWorksetPropertiesPlanNode.initProperties(toNoOp.getGlobalProperties(), toNoOp.getLocalProperties());
          estimator.costOperator(rebuildWorksetPropertiesPlanNode);
           
          GlobalProperties atEndGlobalModified = rebuildWorksetPropertiesPlanNode.getGlobalProperties();
          LocalProperties atEndLocalModified = rebuildWorksetPropertiesPlanNode.getLocalProperties();
           
          if (!(atEndGlobalModified.equals(atEndGlobal) && atEndLocalModified.equals(atEndLocal))) {
            FeedbackPropertiesMeetRequirementsReport report2 = candidate.checkPartialSolutionPropertiesMet(wspn, atEndGlobalModified, atEndLocalModified);
           
            if (report2 != FeedbackPropertiesMeetRequirementsReport.NOT_MET) {
              newCandidates.add(rebuildWorksetPropertiesPlanNode);
            }
          }
         
          // remove the original operator and add the modified candidate
          planDeleter.remove();
         
        }
      }
     
      worksetCandidates.addAll(newCandidates);
    }
   
    if (worksetCandidates.isEmpty()) {
      return;
    }
   
    // sanity check the solution set delta
    for (Iterator<PlanNode> deltaPlans = solutionSetDeltaCandidates.iterator(); deltaPlans.hasNext(); ) {
      SingleInputPlanNode candidate = (SingleInputPlanNode) deltaPlans.next();
      GlobalProperties gp = candidate.getGlobalProperties();
     
      if (gp.getPartitioning() != PartitioningProperty.HASH_PARTITIONED || gp.getPartitioningFields() == null ||
          !gp.getPartitioningFields().equals(this.solutionSetKeyFields))
      {
        throw new CompilerException("Bug: The solution set delta is not partitioned.");
      }
    }
   
    // 5) Create a candidate for the Iteration Node for every remaining plan of the step function.
   
    final GlobalProperties gp = new GlobalProperties();
    gp.setHashPartitioned(this.solutionSetKeyFields);
    gp.addUniqueFieldCombination(this.solutionSetKeyFields);
   
    LocalProperties lp = LocalProperties.EMPTY.addUniqueFields(this.solutionSetKeyFields);
   
    // take all combinations of solution set delta and workset plans
    for (PlanNode solutionSetCandidate : solutionSetDeltaCandidates) {
      for (PlanNode worksetCandidate : worksetCandidates) {
        // check whether they have the same operator at their latest branching point
        if (this.singleRoot.areBranchCompatible(solutionSetCandidate, worksetCandidate)) {
         
          SingleInputPlanNode siSolutionDeltaCandidate = (SingleInputPlanNode) solutionSetCandidate;
          boolean immediateDeltaUpdate;
         
          // check whether we need a dedicated solution set delta operator, or whether we can update on the fly
          if (siSolutionDeltaCandidate.getInput().getShipStrategy() == ShipStrategyType.FORWARD && this.solutionDeltaImmediatelyAfterSolutionJoin) {
            // we do not need this extra node. we can make the predecessor the delta
            // sanity check the node and connection
            if (siSolutionDeltaCandidate.getDriverStrategy() != DriverStrategy.UNARY_NO_OP || siSolutionDeltaCandidate.getInput().getLocalStrategy() != LocalStrategy.NONE) {
              throw new CompilerException("Invalid Solution set delta node.");
            }
           
            solutionSetCandidate = siSolutionDeltaCandidate.getInput().getSource();
            immediateDeltaUpdate = true;
          } else {
            // was not partitioned, we need to keep this node.
            // mark that we materialize the input
            siSolutionDeltaCandidate.getInput().setTempMode(TempMode.PIPELINE_BREAKER);
            immediateDeltaUpdate = false;
          }
         
          WorksetIterationPlanNode wsNode = new WorksetIterationPlanNode(
            this, "WorksetIteration ("+this.getPactContract().getName()+")", solutionSetIn, worksetIn, sspn, wspn, worksetCandidate, solutionSetCandidate);
View Full Code Here

        plan = compileNoStats(p);
      }
     
      OptimizerPlanNodeResolver resolver = getOptimizerPlanNodeResolver(plan);
      SinkPlanNode sink = resolver.getNode("Word Counts");
      SingleInputPlanNode reducer = resolver.getNode("Count Words");
      SingleInputPlanNode mapper = resolver.getNode("Tokenize Lines");
     
      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(0));
      Assert.assertEquals(l, combiner.getKeys(1));
      Assert.assertEquals(ShipStrategyType.FORWARD, combiner.getInput().getShipStrategy());
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

    return DriverStrategy.MAP_PARTITION;
  }

  @Override
  public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) {
    return new SingleInputPlanNode(node, "MapPartition ("+node.getPactContract().getName()+")", in, DriverStrategy.MAP_PARTITION);
  }
View Full Code Here

     
      final OptimizerPlanNodeResolver or = getOptimizerPlanNodeResolver(plan);
     
      // get the nodes from the final plan
      final SinkPlanNode sink = or.getNode("Output");
      final SingleInputPlanNode reducer = or.getNode("AggLio");
      final SingleInputPlanNode combiner = reducer.getPredecessor() instanceof SingleInputPlanNode ?
          (SingleInputPlanNode) reducer.getPredecessor() : null;
      final DualInputPlanNode join = or.getNode("JoinLiO");
      final SingleInputPlanNode filteringMapper = or.getNode("FilterO");
     
      // verify the optimizer choices
      checkStandardStrategies(filteringMapper, join, combiner, reducer, sink);
      Assert.assertTrue(checkRepartitionShipStrategies(join, reducer, combiner));
      Assert.assertTrue(checkHashJoinStrategies(join, reducer, true) || checkHashJoinStrategies(join, reducer, false));
View Full Code Here

      final OptimizedPlan plan = compileWithStats(p);
      final OptimizerPlanNodeResolver or = getOptimizerPlanNodeResolver(plan);
     
      // get the nodes from the final plan
      final SinkPlanNode sink = or.getNode("Output");
      final SingleInputPlanNode reducer = or.getNode("AggLio");
      final SingleInputPlanNode combiner = reducer.getPredecessor() instanceof SingleInputPlanNode ?
          (SingleInputPlanNode) reducer.getPredecessor() : null;
      final DualInputPlanNode join = or.getNode("JoinLiO");
      final SingleInputPlanNode filteringMapper = or.getNode("FilterO");
     
      checkStandardStrategies(filteringMapper, join, combiner, reducer, sink);
     
      // check the possible variants and that the variant ia allowed in this specific setting
      if (checkBroadcastShipStrategies(join, reducer, combiner)) {
View Full Code Here

  @Override
  public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) {
    if (in.getShipStrategy() == ShipStrategyType.FORWARD ||
        (node.getBroadcastConnections() != null && !node.getBroadcastConnections().isEmpty()))
    {
      return new SingleInputPlanNode(node, "Reduce ("+node.getPactContract().getName()+")", in, DriverStrategy.SORTED_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
      ReduceNode combinerNode = ((ReduceNode) node).getCombinerUtilityNode();
      combinerNode.setDegreeOfParallelism(in.getSource().getDegreeOfParallelism());

      SingleInputPlanNode combiner = new SingleInputPlanNode(combinerNode, "Combine ("+node.getPactContract().getName()+")", toCombiner, DriverStrategy.SORTED_PARTIAL_REDUCE, 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.SORT, in.getLocalStrategyKeys(), in.getLocalStrategySortOrder());
      return new SingleInputPlanNode(node, "Reduce("+node.getPactContract().getName()+")", toReducer, DriverStrategy.SORTED_REDUCE, this.keyList);
    }
  }
View Full Code Here

    return DriverStrategy.FLAT_MAP;
  }

  @Override
  public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) {
    return new SingleInputPlanNode(node, "Filter ("+node.getPactContract().getName()+")", in, DriverStrategy.FLAT_MAP);
  }
View Full Code Here

    return DriverStrategy.FLAT_MAP;
  }

  @Override
  public SingleInputPlanNode instantiate(Channel in, SingleInputNode node) {
    return new SingleInputPlanNode(node, "FlatMap ("+node.getPactContract().getName()+")", in, DriverStrategy.FLAT_MAP);
  }
View Full Code Here

TOP

Related Classes of org.apache.flink.compiler.plan.SingleInputPlanNode

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.