Package org.apache.flink.compiler.plan

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


      throw new CompilerException("Error in compiler: more than one best plan was created!");
    }

    // check if the best plan's root is a data sink (single sink plan)
    // if so, directly take it. if it is a sink joiner node, get its contained sinks
    PlanNode bestPlanRoot = bestPlan.get(0);
    List<SinkPlanNode> bestPlanSinks = new ArrayList<SinkPlanNode>(4);

    if (bestPlanRoot instanceof SinkPlanNode) {
      bestPlanSinks.add((SinkPlanNode) bestPlanRoot);
    } else if (bestPlanRoot instanceof SinkJoinerPlanNode) {
View Full Code Here


    }
  }
 
  private void traverseChannel(Channel channel) {
   
    PlanNode source = channel.getSource();
    Operator<?> javaOp = source.getPactContract();
   
//    if (!(javaOp instanceof BulkIteration) && !(javaOp instanceof JavaPlanNode)) {
//      throw new RuntimeException("Wrong operator type found in post pass: " + javaOp);
//    }

    TypeInformation<?> type = javaOp.getOperatorInfo().getOutputType();


    if(javaOp instanceof GroupReduceOperatorBase &&
        (source.getDriverStrategy() == DriverStrategy.SORTED_GROUP_COMBINE || source.getDriverStrategy() == DriverStrategy.ALL_GROUP_COMBINE)) {
      GroupReduceOperatorBase<?, ?, ?> groupNode = (GroupReduceOperatorBase<?, ?, ?>) javaOp;
      type = groupNode.getInput().getOperatorInfo().getOutputType();
    }
    else if(javaOp instanceof PlanUnwrappingReduceGroupOperator &&
        source.getDriverStrategy().equals(DriverStrategy.SORTED_GROUP_COMBINE)) {
      PlanUnwrappingReduceGroupOperator<?, ?, ?> groupNode = (PlanUnwrappingReduceGroupOperator<?, ?, ?>) javaOp;
      type = groupNode.getInput().getOperatorInfo().getOutputType();
    }
   
    // the serializer always exists
View Full Code Here

  }

  protected void instantiateCandidate(OperatorDescriptorSingle dps, Channel in, List<Set<? extends NamedChannel>> broadcastPlanChannels,
      List<PlanNode> target, CostEstimator estimator, RequestedGlobalProperties globPropsReq, RequestedLocalProperties locPropsReq)
  {
    final PlanNode inputSource = in.getSource();
   
    for (List<NamedChannel> broadcastChannelsCombination: Sets.cartesianProduct(broadcastPlanChannels)) {
     
      boolean validCombination = true;
      boolean requiresPipelinebreaker = false;
     
      // check whether the broadcast inputs use the same plan candidate at the branching point
      for (int i = 0; i < broadcastChannelsCombination.size(); i++) {
        NamedChannel nc = broadcastChannelsCombination.get(i);
        PlanNode bcSource = nc.getSource();
       
        // check branch compatibility against input
        if (!areBranchCompatible(bcSource, inputSource)) {
          validCombination = false;
          break;
        }
       
        // check branch compatibility against all other broadcast variables
        for (int k = 0; k < i; k++) {
          PlanNode otherBcSource = broadcastChannelsCombination.get(k).getSource();
         
          if (!areBranchCompatible(bcSource, otherBcSource)) {
            validCombination = false;
            break;
          }
        }
       
        // check if there is a common predecessor and whether there is a dam on the way to all common predecessors
        if (this.hereJoinedBranches != null) {
          for (OptimizerNode brancher : this.hereJoinedBranches) {
            PlanNode candAtBrancher = in.getSource().getCandidateAtBranchPoint(brancher);
           
            if (candAtBrancher == null) {
              // closed branch between two broadcast variables
              continue;
            }
View Full Code Here

      Comparator<PlanNode> sorter = new Comparator<PlanNode>() {
       
        @Override
        public int compare(PlanNode o1, PlanNode o2) {
          for (int i = 0; i < branchDeterminers.length; i++) {
            PlanNode n1 = o1.getCandidateAtBranchPoint(branchDeterminers[i]);
            PlanNode n2 = o2.getCandidateAtBranchPoint(branchDeterminers[i]);
            int hash1 = System.identityHashCode(n1);
            int hash2 = System.identityHashCode(n2);
           
            if (hash1 != hash2) {
              return hash1 - hash2;
            }
          }
          return 0;
        }
      };
      Collections.sort(plans, sorter);
     
      List<PlanNode> result = new ArrayList<PlanNode>();
      List<PlanNode> turn = new ArrayList<PlanNode>();
     
      final PlanNode[] determinerChoice = new PlanNode[branchDeterminers.length];

      while (!plans.isEmpty()) {
        // take one as the determiner
        turn.clear();
        PlanNode determiner = plans.remove(plans.size() - 1);
        turn.add(determiner);
       
        for (int i = 0; i < determinerChoice.length; i++) {
          determinerChoice[i] = determiner.getCandidateAtBranchPoint(branchDeterminers[i]);
        }

        // go backwards through the plans and find all that are equal
        boolean stillEqual = true;
        for (int k = plans.size() - 1; k >= 0 && stillEqual; k--) {
          PlanNode toCheck = plans.get(k);
         
          for (int i = 0; i < branchDeterminers.length; i++) {
            PlanNode checkerChoice = toCheck.getCandidateAtBranchPoint(branchDeterminers[i]);
         
            if (checkerChoice != determinerChoice[i]) {
              // not the same anymore
              stillEqual = false;
              break;
View Full Code Here

   
    final PlanNode[][] toKeep = new PlanNode[gps.length][];
    final PlanNode[] cheapestForGlobal = new PlanNode[gps.length];
   
   
    PlanNode cheapest = null; // the overall cheapest plan

    // go over all plans from the list
    for (PlanNode candidate : plans) {
      // check if that plan is the overall cheapest
      if (cheapest == null || (cheapest.getCumulativeCosts().compareTo(candidate.getCumulativeCosts()) > 0)) {
        cheapest = candidate;
      }

      // find the interesting global properties that this plan matches
      for (int i = 0; i < gps.length; i++) {
        if (gps[i].isMetBy(candidate.getGlobalProperties())) {
          // the candidate meets the global property requirements. That means
          // it has a chance that its local properties are re-used (they would be
          // destroyed if global properties need to be established)
         
          if (cheapestForGlobal[i] == null || (cheapestForGlobal[i].getCumulativeCosts().compareTo(candidate.getCumulativeCosts()) > 0)) {
            cheapestForGlobal[i] = candidate;
          }
         
          final PlanNode[] localMatches;
          if (toKeep[i] == null) {
            localMatches = new PlanNode[lps.length];
            toKeep[i] = localMatches;
          } else {
            localMatches = toKeep[i];
          }
         
          for (int k = 0; k < lps.length; k++) {
            if (lps[k].isMetBy(candidate.getLocalProperties())) {
              final PlanNode previous = localMatches[k];
              if (previous == null || previous.getCumulativeCosts().compareTo(candidate.getCumulativeCosts()) > 0) {
                // this one is cheaper!
                localMatches[k] = candidate;
              }
            }
          }
        }
      }
    }

    // all plans are set now
    plans.clear();

    // add the cheapest plan
    if (cheapest != null) {
      plans.add(cheapest);
      cheapest.setPruningMarker(); // remember that that plan is in the set
    }
   
    // skip the top down delta cost check for now (TODO: implement this)
    // add all others, which are optimal for some interesting properties
    for (int i = 0; i < gps.length; i++) {
      if (toKeep[i] != null) {
        final PlanNode[] localMatches = toKeep[i];
        for (int k = 0; k < localMatches.length; k++) {
          final PlanNode n = localMatches[k];
          if (n != null && !n.isPruneMarkerSet()) {
            n.setPruningMarker();
            plans.add(n);
          }
        }
      }
      if (cheapestForGlobal[i] != null) {
        final PlanNode n = cheapestForGlobal[i];
        if (!n.isPruneMarkerSet()) {
          n.setPruningMarker();
          plans.add(n);
        }
      }
    }
  }
View Full Code Here

    if (this.hereJoinedBranches == null || this.hereJoinedBranches.isEmpty()) {
      return true;
    }

    for (OptimizerNode joinedBrancher : hereJoinedBranches) {
      final PlanNode branch1Cand = plan1.getCandidateAtBranchPoint(joinedBrancher);
      final PlanNode branch2Cand = plan2.getCandidateAtBranchPoint(joinedBrancher);
     
      if (branch1Cand != null && branch2Cand != null && branch1Cand != branch2Cand) {
        return false;
      }
    }
View Full Code Here

        }
       
        // check whether this node is a child of a node with the same contract (aka combiner)
        boolean shouldAdd = true;
        for (Iterator<PlanNode> iter = list.iterator(); iter.hasNext();) {
          PlanNode in = iter.next();
          if (in.getOriginalOptimizerNode().getPactContract() == c) {
            // is this the child or is our node the child
            if (in instanceof SingleInputPlanNode && n instanceof SingleInputPlanNode) {
              SingleInputPlanNode thisNode = (SingleInputPlanNode) n;
              SingleInputPlanNode otherNode = (SingleInputPlanNode) in;
             
View Full Code Here

    public <T extends PlanNode> T getNode(String name, Class<? extends RichFunction> stubClass) {
      List<PlanNode> nodes = this.map.get(name);
      if (nodes == null || nodes.isEmpty()) {
        throw new RuntimeException("No node found with the given name and stub class.");
      } else {
        PlanNode found = null;
        for (PlanNode node : nodes) {
          if (node.getClass() == stubClass) {
            if (found == null) {
              found = node;
            } else {
View Full Code Here

TOP

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

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.