@Override protected org.apache.flink.api.common.operators.SingleInputOperator<T, T, ?> translateToDataFlow(Operator<T> input) { // All the translation magic happens when the iteration end is encountered. throw new InvalidProgramException("A data set that is part of an iteration was used as a sink or action." + " Did you forget to close the iteration?"); } }
public void setDetachedPlan(FlinkPlan plan) { if (detachedPlan == null) { detachedPlan = plan; } else { throw new InvalidProgramException(DetachedJobExecutionResult.DETACHED_MESSAGE + DetachedJobExecutionResult.EXECUTE_TWICE_MESSAGE); } }
@Override public JobID getJobID() { throw new InvalidProgramException(DETACHED_MESSAGE + JOB_RESULT_MESSAGE); } }
@Override public CrossOperator<I1, I2, OUT> withForwardedFieldsFirst(String... forwardedFieldsFirst) { throw new InvalidProgramException("The semantic properties (forwarded fields) are automatically calculated."); }
@Override public Map<String, Object> getAllAccumulatorResults() { throw new InvalidProgramException(DETACHED_MESSAGE + JOB_RESULT_MESSAGE); }
private <T> TypeComparator<T> getTypeComparator(ExecutionConfig executionConfig, TypeInformation<T> inputType, int[] inputKeys, boolean[] inputSortDirections) { if (!(inputType instanceof CompositeType)) { throw new InvalidProgramException("Input types of coGroup must be composite types."); } return ((CompositeType<T>) inputType).createComparator(inputKeys, inputSortDirections, 0, executionConfig); }
/** * The purpose of this method is solely to check whether the data type to be processed * is in fact a tuple type. */ @Override public void setInputType(TypeInformation<?> type, ExecutionConfig executionConfig) { if (!type.isTupleType()) { throw new InvalidProgramException("The " + CsvOutputFormat.class.getSimpleName() + " can only be used to write tuple data sets."); } } }
public void checkJoinKeyFields(int[] keyFields) { int[] ssKeys = deltaIteration.keys.computeLogicalKeyPositions(); 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) + ")."); } } }
public static void ensureSerializable(Object obj) { try { InstantiationUtil.serializeObject(obj); } catch (Exception e) { throw new InvalidProgramException("Object " + obj + " is not serializable", e); } }
public Grouping(DataSet<T> set, Keys<T> keys) { if (set == null || keys == null) { throw new NullPointerException(); } if (keys.isEmpty()) { throw new InvalidProgramException("The grouping keys must not be empty."); } this.inputDataSet = set; this.keys = keys; }
private TypeComparator<IN> getTypeComparator(TypeInformation<IN> typeInfo, int[] sortColumns, boolean[] sortOrderings, ExecutionConfig executionConfig) { if (typeInfo instanceof CompositeType) { return ((CompositeType<IN>) typeInfo).createComparator(sortColumns, sortOrderings, 0, executionConfig); } else if (typeInfo instanceof AtomicType) { return ((AtomicType<IN>) typeInfo).createComparator(sortOrderings[0], executionConfig); } throw new InvalidProgramException("Input type of GroupReduce must be one of composite types or atomic types."); }
/** * Returns a new set containing the first n elements in this grouped {@link DataSet}. * * @param n The desired number of elements for each group. * @return A GroupReduceOperator that represents the DataSet containing the elements. */ public GroupReduceOperator<T, T> first(int n) { if (n < 1) { throw new InvalidProgramException("Parameter n of first(n) must be at least 1."); } return reduceGroup(new FirstReducer<T>(n)); }
private void ensureSortableKey(int field) throws InvalidProgramException { if (!Keys.ExpressionKeys.isSortKey(field, getType())) { throw new InvalidProgramException("Selected sort key is not a sortable type"); } }
/** * Returns a new set containing the first n elements in this grouped and sorted {@link DataSet}. * @param n The desired number of elements for each group. * @return A GroupReduceOperator that represents the DataSet containing the elements. */ public GroupReduceOperator<T, T> first(int n) { if (n < 1) { throw new InvalidProgramException("Parameter n of first(n) must be at least 1."); } return reduceGroup(new FirstReducer<T>(n)); }
@SuppressWarnings("unchecked") private <T> TypeComparator<T> getTypeComparator(ExecutionConfig executionConfig, TypeInformation<T> inputType, int[] inputKeys, boolean[] inputSortDirections) { if (inputType instanceof CompositeType) { return ((CompositeType<T>) inputType).createComparator(inputKeys, inputSortDirections, 0, executionConfig); } else if (inputType instanceof AtomicType) { return ((AtomicType<T>) inputType).createComparator(inputSortDirections[0], executionConfig); } throw new InvalidProgramException("Input type of coGroup must be one of composite types or atomic types."); }
private <K> void ensureSortableKey(Keys.SelectorFunctionKeys<T, K> sortKey) { if (!sortKey.getKeyType().isSortKeyType()) { throw new InvalidProgramException("Selected sort key is not a sortable type"); } }
/** * Returns a new set containing the first n elements in this {@link DataSet}. * * @param n The desired number of elements. * @return A ReduceGroupOperator that represents the DataSet containing the elements. */ public GroupReduceOperator<T, T> first(int n) { if (n < 1) { throw new InvalidProgramException("Parameter n of first(n) must be at least 1."); } return reduceGroup(new FirstReducer<T>(n)); }
private TypeComparator<IN> getTypeComparator(TypeInformation<IN> typeInfo, int[] sortColumns, boolean[] sortOrderings, ExecutionConfig executionConfig) { if (typeInfo instanceof CompositeType) { return ((CompositeType<IN>) typeInfo).createComparator(sortColumns, sortOrderings, 0, executionConfig); } else if (typeInfo instanceof AtomicType) { return ((AtomicType<IN>) typeInfo).createComparator(sortOrderings[0], executionConfig); } throw new InvalidProgramException("Input type of GroupCombine must be one of composite types or atomic types."); }
public SortedGrouping(DataSet<T> set, Keys<T> keys, int field, Order order) { super(set, keys); if (!Keys.ExpressionKeys.isSortKey(field, inputDataSet.getType())) { throw new InvalidProgramException("Selected sort key is not a sortable type"); } // use int-based expression key to properly resolve nested tuples for grouping ExpressionKeys<T> ek = new ExpressionKeys<>(field, inputDataSet.getType()); this.groupSortKeyPositions = ek.computeLogicalKeyPositions(); this.groupSortOrders = new Order[groupSortKeyPositions.length]; Arrays.fill(this.groupSortOrders, order); }
public SortedGrouping(DataSet<T> set, Keys<T> keys, String field, Order order) { super(set, keys); if (!Keys.ExpressionKeys.isSortKey(field, inputDataSet.getType())) { throw new InvalidProgramException("Selected sort key is not a sortable type"); } // resolve String-field to int using the expression keys ExpressionKeys<T> ek = new ExpressionKeys<>(field, inputDataSet.getType()); this.groupSortKeyPositions = ek.computeLogicalKeyPositions(); this.groupSortOrders = new Order[groupSortKeyPositions.length]; Arrays.fill(this.groupSortOrders, order); // if field == "*" }