Package org.apache.flink.compiler

Examples of org.apache.flink.compiler.CompilerException


    this.configuration = config;
   
    // instantiate the address to the job manager
    final String address = config.getString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, null);
    if (address == null) {
      throw new CompilerException("Cannot find address to job manager's RPC service in the global configuration.");
    }
   
    final int port = GlobalConfiguration.getInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, ConfigConstants.DEFAULT_JOB_MANAGER_IPC_PORT);
    if (port < 0) {
      throw new CompilerException("Cannot find port to job manager's RPC service in the global configuration.");
    }

    this.userCodeClassLoader = userCodeClassLoader;
    this.compiler = new PactCompiler(new DataStatistics(), new DefaultCostEstimator());
  }
View Full Code Here


                p2.parameterizeChannel(c1, dopChange1);
              }
            } else {
              // this should never happen, as it implies both realize a different strategy, which is
              // excluded by the check that the required strategies must match
              throw new CompilerException("Bug in Plan Enumeration for Union Node.");
            }
          }
         
          instantiate(operator, c1, c2, broadcastPlanChannels, outputPlans, estimator, igps, igps, noLocalProps, noLocalProps);
        }
View Full Code Here

      } else if (PactCompiler.HINT_LOCAL_STRATEGY_NESTEDLOOP_STREAMED_OUTER_FIRST.equals(localStrategy)) {
        fixedDriverStrat = new CrossStreamOuterFirstDescriptor(allowBCfirst, allowBCsecond);
      } else if (PactCompiler.HINT_LOCAL_STRATEGY_NESTEDLOOP_STREAMED_OUTER_SECOND.equals(localStrategy)) {
        fixedDriverStrat = new CrossStreamOuterSecondDescriptor(allowBCfirst, allowBCsecond);
      } else {
        throw new CompilerException("Invalid local strategy hint for cross contract: " + localStrategy);
      }
     
      this.dataProperties = Collections.singletonList(fixedDriverStrat);
    }
    else if (operation instanceof CrossOperatorBase.CrossWithSmall) {
View Full Code Here

    // serializer
    if (isBroadcastChannel) {
      config.setBroadcastInputSerializer(channel.getSerializer(), inputNum);
     
      if (channel.getLocalStrategy() != LocalStrategy.NONE || (channel.getTempMode() != null && channel.getTempMode() != TempMode.NONE)) {
        throw new CompilerException("Found local strategy or temp mode on a broadcast variable channel.");
      } else {
        return;
      }
    } else {
      config.setInputSerializer(channel.getSerializer(), inputNum);
    }
   
    // local strategy
    if (channel.getLocalStrategy() != LocalStrategy.NONE) {
      config.setInputLocalStrategy(inputNum, channel.getLocalStrategy());
      if (channel.getLocalStrategyComparator() != null) {
        config.setInputComparator(channel.getLocalStrategyComparator(), inputNum);
      }
    }
   
    assignLocalStrategyResources(channel, config, inputNum);
   
    // materialization / caching
    if (channel.getTempMode() != null) {
      final TempMode tm = channel.getTempMode();

      boolean needsMemory = false;
      if (tm.breaksPipeline()) {
        config.setInputAsynchronouslyMaterialized(inputNum, true);
        needsMemory = true;
      }
      if (tm.isCached()) {
        config.setInputCached(inputNum, true);
        needsMemory = true;
      }
     
      if (needsMemory) {
        // sanity check
        if (tm == null || tm == TempMode.NONE || channel.getRelativeTempMemory() <= 0) {
          throw new CompilerException("Bug in compiler: Inconsistent description of input materialization.");
        }
        config.setRelativeInputMaterializationMemory(inputNum, channel.getRelativeTempMemory());
      }
    }
  }
View Full Code Here

    // ------------ finalize the head config with the final outputs and the sync gate ------------
    final int numStepFunctionOuts = headConfig.getNumOutputs();
    final int numFinalOuts = headFinalOutputConfig.getNumOutputs();
   
    if (numStepFunctionOuts == 0) {
      throw new CompilerException("The iteration has no operation inside the step function.");
    }
   
    headConfig.setIterationHeadFinalOutputConfig(headFinalOutputConfig);
    headConfig.setIterationHeadIndexOfSyncOutput(numStepFunctionOuts + numFinalOuts);
    final double relativeMemForBackChannel = bulkNode.getRelativeMemoryPerSubTask();
    if (relativeMemForBackChannel <= 0) {
      throw new CompilerException("Bug: No memory has been assigned to the iteration back channel.");
    }
    headConfig.setRelativeBackChannelMemory(relativeMemForBackChannel);
   
    // --------------------------- create the sync task ---------------------------
    final AbstractJobVertex sync = new AbstractJobVertex("Sync(" + bulkNode.getNodeName() + ")");
    sync.setInvokableClass(IterationSynchronizationSinkTask.class);
    sync.setParallelism(1);
    this.auxVertices.add(sync);
   
    final TaskConfig syncConfig = new TaskConfig(sync.getConfiguration());
    syncConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, headVertex.getParallelism());

    // set the number of iteration / convergence criterion for the sync
    final int maxNumIterations = bulkNode.getIterationNode().getIterationContract().getMaximumNumberOfIterations();
    if (maxNumIterations < 1) {
      throw new CompilerException("Cannot create bulk iteration with unspecified maximum number of iterations.");
    }
    syncConfig.setNumberOfIterations(maxNumIterations);
   
    // connect the sync task
    sync.connectNewDataSetAsInput(headVertex, DistributionPattern.POINTWISE);
   
    // ----------------------------- create the iteration tail ------------------------------
   
    final PlanNode rootOfTerminationCriterion = bulkNode.getRootOfTerminationCriterion();
    final PlanNode rootOfStepFunction = bulkNode.getRootOfStepFunction();
    final TaskConfig tailConfig;
   
    AbstractJobVertex rootOfStepFunctionVertex = (AbstractJobVertex) this.vertices.get(rootOfStepFunction);
    if (rootOfStepFunctionVertex == null) {
      // last op is chained
      final TaskInChain taskInChain = this.chainedTasks.get(rootOfStepFunction);
      if (taskInChain == null) {
        throw new CompilerException("Bug: Tail of step function not found as vertex or chained task.");
      }
      rootOfStepFunctionVertex = (AbstractJobVertex) taskInChain.getContainingVertex();

      // the fake channel is statically typed to pact record. no data is sent over this channel anyways.
      tailConfig = taskInChain.getTaskConfig();
    } else {
      tailConfig = new TaskConfig(rootOfStepFunctionVertex.getConfiguration());
    }
   
    tailConfig.setIsWorksetUpdate();
   
    // No following termination criterion
    if (rootOfStepFunction.getOutgoingChannels().isEmpty()) {
     
      rootOfStepFunctionVertex.setInvokableClass(IterationTailPactTask.class);
     
      tailConfig.setOutputSerializer(bulkNode.getSerializerForIterationChannel());
    }
   
   
    // create the fake output task for termination criterion, if needed
    final TaskConfig tailConfigOfTerminationCriterion;
    // If we have a termination criterion and it is not an intermediate node
    if(rootOfTerminationCriterion != null && rootOfTerminationCriterion.getOutgoingChannels().isEmpty()) {
      AbstractJobVertex rootOfTerminationCriterionVertex = (AbstractJobVertex) this.vertices.get(rootOfTerminationCriterion);
     
     
      if (rootOfTerminationCriterionVertex == null) {
        // last op is chained
        final TaskInChain taskInChain = this.chainedTasks.get(rootOfTerminationCriterion);
        if (taskInChain == null) {
          throw new CompilerException("Bug: Tail of termination criterion not found as vertex or chained task.");
        }
        rootOfTerminationCriterionVertex = (AbstractJobVertex) taskInChain.getContainingVertex();

        // the fake channel is statically typed to pact record. no data is sent over this channel anyways.
        tailConfigOfTerminationCriterion = taskInChain.getTaskConfig();
      } else {
        tailConfigOfTerminationCriterion = new TaskConfig(rootOfTerminationCriterionVertex.getConfiguration());
      }
     
      rootOfTerminationCriterionVertex.setInvokableClass(IterationTailPactTask.class);
      // Hack
      tailConfigOfTerminationCriterion.setIsSolutionSetUpdate();
      tailConfigOfTerminationCriterion.setOutputSerializer(bulkNode.getSerializerForIterationChannel());
     
      // tell the head that it needs to wait for the solution set updates
      headConfig.setWaitForSolutionSetUpdate();
    }
   
    // ------------------- register the aggregators -------------------
    AggregatorRegistry aggs = bulkNode.getIterationNode().getIterationContract().getAggregators();
    Collection<AggregatorWithName<?>> allAggregators = aggs.getAllRegisteredAggregators();
   
    headConfig.addIterationAggregators(allAggregators);
    syncConfig.addIterationAggregators(allAggregators);
   
    String convAggName = aggs.getConvergenceCriterionAggregatorName();
    ConvergenceCriterion<?> convCriterion = aggs.getConvergenceCriterion();
   
    if (convCriterion != null || convAggName != null) {
      if (convCriterion == null) {
        throw new CompilerException("Error: Convergence criterion aggregator set, but criterion is null.");
      }
      if (convAggName == null) {
        throw new CompilerException("Error: Aggregator convergence criterion set, but aggregator is null.");
      }
     
      syncConfig.setConvergenceCriterion(convAggName, convCriterion);
    }
  }
View Full Code Here

    {
      final int numStepFunctionOuts = headConfig.getNumOutputs();
      final int numFinalOuts = headFinalOutputConfig.getNumOutputs();
     
      if (numStepFunctionOuts == 0) {
        throw new CompilerException("The workset iteration has no operation on the workset inside the step function.");
      }
     
      headConfig.setIterationHeadFinalOutputConfig(headFinalOutputConfig);
      headConfig.setIterationHeadIndexOfSyncOutput(numStepFunctionOuts + numFinalOuts);
      final double relativeMemory = iterNode.getRelativeMemoryPerSubTask();
      if (relativeMemory <= 0) {
        throw new CompilerException("Bug: No memory has been assigned to the workset iteration.");
      }
     
      headConfig.setIsWorksetIteration();
      headConfig.setRelativeBackChannelMemory(relativeMemory / 2);
      headConfig.setRelativeSolutionSetMemory(relativeMemory / 2);
     
      // set the solution set serializer and comparator
      headConfig.setSolutionSetSerializer(iterNode.getSolutionSetSerializer());
      headConfig.setSolutionSetComparator(iterNode.getSolutionSetComparator());
    }
   
    // --------------------------- create the sync task ---------------------------
    final TaskConfig syncConfig;
    {
      final AbstractJobVertex sync = new AbstractJobVertex("Sync (" + iterNode.getNodeName() + ")");
      sync.setInvokableClass(IterationSynchronizationSinkTask.class);
      sync.setParallelism(1);
      this.auxVertices.add(sync);
     
      syncConfig = new TaskConfig(sync.getConfiguration());
      syncConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, headVertex.getParallelism());
 
      // set the number of iteration / convergence criterion for the sync
      final int maxNumIterations = iterNode.getIterationNode().getIterationContract().getMaximumNumberOfIterations();
      if (maxNumIterations < 1) {
        throw new CompilerException("Cannot create workset iteration with unspecified maximum number of iterations.");
      }
      syncConfig.setNumberOfIterations(maxNumIterations);
     
      // connect the sync task
      sync.connectNewDataSetAsInput(headVertex, DistributionPattern.POINTWISE);
    }
   
    // ----------------------------- create the iteration tails -----------------------------
    // ----------------------- for next workset and solution set delta-----------------------

    {
      // we have three possible cases:
      // 1) Two tails, one for workset update, one for solution set update
      // 2) One tail for workset update, solution set update happens in an intermediate task
      // 3) One tail for solution set update, workset update happens in an intermediate task
     
      final PlanNode nextWorksetNode = iterNode.getNextWorkSetPlanNode();
      final PlanNode solutionDeltaNode = iterNode.getSolutionSetDeltaPlanNode();
     
      final boolean hasWorksetTail = nextWorksetNode.getOutgoingChannels().isEmpty();
      final boolean hasSolutionSetTail = (!iterNode.isImmediateSolutionSetUpdate()) || (!hasWorksetTail);
     
      {
        // get the vertex for the workset update
        final TaskConfig worksetTailConfig;
        AbstractJobVertex nextWorksetVertex = (AbstractJobVertex) this.vertices.get(nextWorksetNode);
        if (nextWorksetVertex == null) {
          // nextWorksetVertex is chained
          TaskInChain taskInChain = this.chainedTasks.get(nextWorksetNode);
          if (taskInChain == null) {
            throw new CompilerException("Bug: Next workset node not found as vertex or chained task.");
          }
          nextWorksetVertex = (AbstractJobVertex) taskInChain.getContainingVertex();
          worksetTailConfig = taskInChain.getTaskConfig();
        } else {
          worksetTailConfig = new TaskConfig(nextWorksetVertex.getConfiguration());
        }
       
        // mark the node to perform workset updates
        worksetTailConfig.setIsWorksetIteration();
        worksetTailConfig.setIsWorksetUpdate();
       
        if (hasWorksetTail) {
          nextWorksetVertex.setInvokableClass(IterationTailPactTask.class);
         
          worksetTailConfig.setOutputSerializer(iterNode.getWorksetSerializer());
        }
      }
      {
        final TaskConfig solutionDeltaConfig;
        AbstractJobVertex solutionDeltaVertex = (AbstractJobVertex) this.vertices.get(solutionDeltaNode);
        if (solutionDeltaVertex == null) {
          // last op is chained
          TaskInChain taskInChain = this.chainedTasks.get(solutionDeltaNode);
          if (taskInChain == null) {
            throw new CompilerException("Bug: Solution Set Delta not found as vertex or chained task.");
          }
          solutionDeltaVertex = (AbstractJobVertex) taskInChain.getContainingVertex();
          solutionDeltaConfig = taskInChain.getTaskConfig();
        } else {
          solutionDeltaConfig = new TaskConfig(solutionDeltaVertex.getConfiguration());
        }
       
        solutionDeltaConfig.setIsWorksetIteration();
        solutionDeltaConfig.setIsSolutionSetUpdate();
       
        if (hasSolutionSetTail) {
          solutionDeltaVertex.setInvokableClass(IterationTailPactTask.class);
         
          solutionDeltaConfig.setOutputSerializer(iterNode.getSolutionSetSerializer());
         
          // tell the head that it needs to wait for the solution set updates
          headConfig.setWaitForSolutionSetUpdate();
        }
        else {
          // no tail, intermediate update. must be immediate update
          if (!iterNode.isImmediateSolutionSetUpdate()) {
            throw new CompilerException("A solution set update without dedicated tail is not set to perform immediate updates.");
          }
          solutionDeltaConfig.setIsSolutionSetUpdateWithoutReprobe();
        }
      }
    }
   
    // ------------------- register the aggregators -------------------
    AggregatorRegistry aggs = iterNode.getIterationNode().getIterationContract().getAggregators();
    Collection<AggregatorWithName<?>> allAggregators = aggs.getAllRegisteredAggregators();
   
    for (AggregatorWithName<?> agg : allAggregators) {
      if (agg.getName().equals(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME)) {
        throw new CompilerException("User defined aggregator used the same name as built-in workset " +
            "termination check aggregator: " + WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME);
      }
    }
   
    headConfig.addIterationAggregators(allAggregators);
    syncConfig.addIterationAggregators(allAggregators);
   
    String convAggName = aggs.getConvergenceCriterionAggregatorName();
    ConvergenceCriterion<?> convCriterion = aggs.getConvergenceCriterion();
   
    if (convCriterion != null || convAggName != null) {
      throw new CompilerException("Error: Cannot use custom convergence criterion with workset iteration. Workset iterations have implicit convergence criterion where workset is empty.");
    }
   
    headConfig.addIterationAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME, new LongSumAggregator());
    syncConfig.addIterationAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME, new LongSumAggregator());
    syncConfig.setConvergenceCriterion(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME, new WorksetEmptyConvergenceCriterion());
View Full Code Here

      } else if (PactCompiler.HINT_LOCAL_STRATEGY_HASH_BUILD_FIRST.equals(localStrategy)) {
        fixedDriverStrat = new HashJoinBuildFirstProperties(this.keys1, this.keys2);
      } else if (PactCompiler.HINT_LOCAL_STRATEGY_HASH_BUILD_SECOND.equals(localStrategy)) {
        fixedDriverStrat = new HashJoinBuildSecondProperties(this.keys1, this.keys2);
      } else {
        throw new CompilerException("Invalid local strategy hint for match contract: " + localStrategy);
      }
      ArrayList<OperatorDescriptorDual> list = new ArrayList<OperatorDescriptorDual>();
      list.add(fixedDriverStrat);
      return list;
    }
    else {
      ArrayList<OperatorDescriptorDual> list = new ArrayList<OperatorDescriptorDual>();
     
      joinHint = joinHint == null ? JoinHint.OPTIMIZER_CHOOSES : joinHint;
     
      switch (joinHint) {
        case BROADCAST_HASH_FIRST:
          list.add(new HashJoinBuildFirstProperties(this.keys1, this.keys2, true, false, false));
          break;
        case BROADCAST_HASH_SECOND:
          list.add(new HashJoinBuildSecondProperties(this.keys1, this.keys2, false, true, false));
          break;
        case REPARTITION_HASH_FIRST:
          list.add(new HashJoinBuildFirstProperties(this.keys1, this.keys2, false, false, true));
          break;
        case REPARTITION_HASH_SECOND:
          list.add(new HashJoinBuildSecondProperties(this.keys1, this.keys2, false, false, true));
          break;
        case REPARTITION_SORT_MERGE:
          list.add(new SortMergeJoinDescriptor(this.keys1, this.keys2, false, false, true));
          break;
        case OPTIMIZER_CHOOSES:
          list.add(new SortMergeJoinDescriptor(this.keys1, this.keys2));
          list.add(new HashJoinBuildFirstProperties(this.keys1, this.keys2));
          list.add(new HashJoinBuildSecondProperties(this.keys1, this.keys2));
          break;
        default:
          throw new CompilerException("Unrecognized join hint: " + joinHint);
      }
     
      return list;
    }
  }
View Full Code Here

    Ordering prod2 = produced2.getOrdering();
   
    if (prod1 == null || prod2 == null || prod1.getNumberOfFields() < numRelevantFields ||
        prod2.getNumberOfFields() < prod2.getNumberOfFields())
    {
      throw new CompilerException("The given properties do not meet this operators requirements.");
    }
     
    for (int i = 0; i < numRelevantFields; i++) {
      if (prod1.getOrder(i) != prod2.getOrder(i)) {
        return false;
View Full Code Here

  @Override
  public DualInputPlanNode instantiate(Channel in1, Channel in2, TwoInputNode node) {
    boolean[] inputOrders = in1.getLocalProperties().getOrdering() == null ? null : in1.getLocalProperties().getOrdering().getFieldSortDirections();
   
    if (inputOrders == null || inputOrders.length < this.keys1.size()) {
      throw new CompilerException("BUG: The input strategy does not sufficiently describe the sort orders for a CoGroup operator.");
    } else if (inputOrders.length > this.keys1.size()) {
      boolean[] tmp = new boolean[this.keys1.size()];
      System.arraycopy(inputOrders, 0, tmp, 0, tmp.length);
      inputOrders = tmp;
    }
View Full Code Here

   */
  public BulkIterationNode(BulkIterationBase<?> iteration) {
    super(iteration);
   
    if (iteration.getMaximumNumberOfIterations() <= 0) {
      throw new CompilerException("BulkIteration must have a maximum number of iterations specified.");
    }
   
    int numIters = iteration.getMaximumNumberOfIterations();
   
    this.costWeight = (numIters > 0 && numIters < OptimizerNode.MAX_DYNAMIC_PATH_COST_WEIGHT) ?
View Full Code Here

TOP

Related Classes of org.apache.flink.compiler.CompilerException

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.