Package org.apache.flink.api.common

Examples of org.apache.flink.api.common.InvalidProgramException


  /**
   * Creates a new local environment.
   */
  public LocalEnvironment() {
    if(!ExecutionEnvironment.localExecutionIsAllowed()) {
      throw new InvalidProgramException("The LocalEnvironment cannot be used when submitting a program through a client.");
    }
  }
View Full Code Here


          allFields[i] = i;
        }
        keys = new Keys.ExpressionKeys<T>(allFields, input.getType(), true);
      }
      else {
        throw new InvalidProgramException("Distinction on all fields is only possible on tuple data types.");
      }
    }
   
   
    // FieldPositionKeys can only be applied on Tuples
    if (keys instanceof Keys.ExpressionKeys && !(input.getType() instanceof CompositeType)) {
      throw new InvalidProgramException("Distinction on field positions is only possible on composite type DataSets.");
    }
   
    this.keys = keys;
  }
View Full Code Here

    }

    Matcher matcher = PATTERN_ANNOTATION.matcher(s);

    if (!matcher.matches()) {
      throw new InvalidProgramException("Unrecognized annotation string format.");
    }

    Matcher forwardMatcher = PATTERN_FORWARD.matcher(s);
    while (forwardMatcher.find()) {
      int sourceField = Integer.valueOf(forwardMatcher.group(2));
View Full Code Here

  private static FieldSet readFieldSetFromString(String s, TypeInformation<?> inType, TypeInformation<?> outType) {
    Matcher matcher = PATTERN_LIST.matcher(s);

    if (!matcher.matches()) {
      throw new InvalidProgramException("Unrecognized annotation string format.");
    }

    matcher = PATTERN_DIGIT.matcher(s);
    FieldSet fs = FieldSet.EMPTY_SET;
View Full Code Here

    super(Validate.notNull(input), input.getType());
   
    Validate.notNull(function);
   
    if (!input.getType().isTupleType()) {
      throw new InvalidProgramException("Aggregating on field positions is only possible on tuple data types.");
    }
   
    TupleTypeInfoBase<?> inType = (TupleTypeInfoBase<?>) input.getType();
   
    if (field < 0 || field >= inType.getArity()) {
View Full Code Here

    super(Validate.notNull(input).getDataSet(), input.getDataSet().getType());
   
    Validate.notNull(function);
   
    if (!input.getDataSet().getType().isTupleType()) {
      throw new InvalidProgramException("Aggregating on field positions is only possible on tuple data types.");
    }
   
    TupleTypeInfoBase<?> inType = (TupleTypeInfoBase<?>) input.getDataSet().getType();
   
    if (field < 0 || field >= inType.getArity()) {
View Full Code Here

    if (input1 instanceof SolutionSetPlaceHolder) {
      if (keys1 instanceof ExpressionKeys) {
        int[] positions = ((ExpressionKeys<?>) keys1).computeLogicalKeyPositions();
        ((SolutionSetPlaceHolder<?>) input1).checkJoinKeyFields(positions);
      } else {
        throw new InvalidProgramException("Currently, the solution set may only be CoGrouped with using tuple field positions.");
      }
    }
    if (input2 instanceof SolutionSetPlaceHolder) {
      if (keys2 instanceof ExpressionKeys) {
        int[] positions = ((ExpressionKeys<?>) keys2).computeLogicalKeyPositions();
        ((SolutionSetPlaceHolder<?>) input2).checkJoinKeyFields(positions);
      } else {
        throw new InvalidProgramException("Currently, the solution set may only be CoGrouped with using tuple field positions.");
      }
    }

    this.keys1 = keys1;
    this.keys2 = keys2;
View Full Code Here

   
    String name = getName() != null ? getName() : function.getClass().getName();
    try {
      keys1.areCompatible(keys2);
    } catch (IncompatibleKeysException e) {
      throw new InvalidProgramException("The types of the key fields do not match.", e);
    }

    if (keys1 instanceof Keys.SelectorFunctionKeys
        && keys2 instanceof Keys.SelectorFunctionKeys) {

      @SuppressWarnings("unchecked")
      Keys.SelectorFunctionKeys<I1, ?> selectorKeys1 =
          (Keys.SelectorFunctionKeys<I1, ?>) keys1;
      @SuppressWarnings("unchecked")
      Keys.SelectorFunctionKeys<I2, ?> selectorKeys2 =
          (Keys.SelectorFunctionKeys<I2, ?>) keys2;

      PlanBothUnwrappingCoGroupOperator<I1, I2, OUT, ?> po =
          translateSelectorFunctionCoGroup(selectorKeys1, selectorKeys2, function,
          getInput1Type(), getInput2Type(), getResultType(), name, input1, input2);

      // set dop
      po.setDegreeOfParallelism(this.getParallelism());

      return po;

    }
    else if (keys2 instanceof Keys.SelectorFunctionKeys) {

      int[] logicalKeyPositions1 = keys1.computeLogicalKeyPositions();

      @SuppressWarnings("unchecked")
      Keys.SelectorFunctionKeys<I2, ?> selectorKeys2 = (Keys.SelectorFunctionKeys<I2, ?>) keys2;

      PlanRightUnwrappingCoGroupOperator<I1, I2, OUT, ?> po =
          translateSelectorFunctionCoGroupRight(logicalKeyPositions1, selectorKeys2, function,
              getInput1Type(), getInput2Type(), getResultType(), name, input1, input2);

      // set dop
      po.setDegreeOfParallelism(this.getParallelism());

      return po;
    }
    else if (keys1 instanceof Keys.SelectorFunctionKeys) {

      @SuppressWarnings("unchecked")
      Keys.SelectorFunctionKeys<I1, ?> selectorKeys1 = (Keys.SelectorFunctionKeys<I1, ?>) keys1;

      int[] logicalKeyPositions2 = keys2.computeLogicalKeyPositions();

      PlanLeftUnwrappingCoGroupOperator<I1, I2, OUT, ?> po =
          translateSelectorFunctionCoGroupLeft(selectorKeys1, logicalKeyPositions2, function,
              getInput1Type(), getInput2Type(), getResultType(), name, input1, input2);

      // set dop
      po.setDegreeOfParallelism(this.getParallelism());

      return po;
    }
    else if ( keys1 instanceof Keys.ExpressionKeys && keys2 instanceof Keys.ExpressionKeys)
      {
      try {
        keys1.areCompatible(keys2);
      } catch (IncompatibleKeysException e) {
        throw new InvalidProgramException("The types of the key fields do not match.", e);
      }

      int[] logicalKeyPositions1 = keys1.computeLogicalKeyPositions();
      int[] logicalKeyPositions2 = keys2.computeLogicalKeyPositions();
     
View Full Code Here

    }

    public void checkJoinKeyFields(int[] keyFields) {
      int[] ssKeys = containingIteration.getSolutionSetKeyFields();
      if (!Arrays.equals(ssKeys, keyFields)) {
        throw new InvalidProgramException("The solution can only be joined/co-grouped with the same keys as the elements are identified with (here: " + Arrays.toString(ssKeys) + ").");
      }
    }
View Full Code Here

   *        FileDataSink that is checked.
   */
  private void checkFileDataSink(FileDataSinkBase<?> fileSink) {
    String path = fileSink.getFilePath();
    if (path == null) {
      throw new InvalidProgramException("File path of FileDataSink is null.");
    }
    if (path.length() == 0) {
      throw new InvalidProgramException("File path of FileDataSink is empty string.");
    }
   
    try {
      Path p = new Path(path);
      String scheme = p.toUri().getScheme();
     
      if (scheme == null) {
        throw new InvalidProgramException("File path \"" + path + "\" of FileDataSink has no file system scheme (like 'file:// or hdfs://').");
      }
    } catch (Exception e) {
      throw new InvalidProgramException("File path \"" + path + "\" of FileDataSink is an invalid path: " + e.getMessage());
    }
    checkDataSink(fileSink);
  }
View Full Code Here

TOP

Related Classes of org.apache.flink.api.common.InvalidProgramException

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.