use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class OpenIterationTest method testSinkInOpenBulkIteration.
@Test
public void testSinkInOpenBulkIteration() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Long> input = env.generateSequence(1, 10);
IterativeDataSet<Long> iteration = input.iterate(10);
DataSet<Long> mapped = iteration.map(new IdentityMapper<Long>());
mapped.output(new DiscardingOutputFormat<Long>());
try {
env.createProgramPlan();
fail("should throw an exception");
} catch (InvalidProgramException e) {
// expected
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class OpenIterationTest method testSinkOnWorksetDeltaIteration.
@Test
public void testSinkOnWorksetDeltaIteration() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
@SuppressWarnings("unchecked") DataSet<Tuple2<Long, Long>> input = env.fromElements(new Tuple2<Long, Long>(0L, 0L));
DeltaIteration<Tuple2<Long, Long>, Tuple2<Long, Long>> iteration = input.iterateDelta(input, 10, 0);
DataSet<Tuple2<Long, Long>> mapped = iteration.getWorkset().map(new IdentityMapper<Tuple2<Long, Long>>());
mapped.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());
try {
env.createProgramPlan();
fail("should throw an exception");
} catch (InvalidProgramException e) {
// expected
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class OpenIterationTest method testSinkInClosedBulkIteration.
@Test
public void testSinkInClosedBulkIteration() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Long> input = env.generateSequence(1, 10);
IterativeDataSet<Long> iteration = input.iterate(10);
DataSet<Long> mapped = iteration.map(new IdentityMapper<Long>());
iteration.closeWith(mapped).output(new DiscardingOutputFormat<Long>());
mapped.output(new DiscardingOutputFormat<Long>());
Plan p = env.createProgramPlan();
try {
compileNoStats(p);
fail("should throw an exception");
} catch (InvalidProgramException e) {
// expected
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class ExistingSavepoint method readKeyedState.
/**
* Read keyed state from an operator in a {@code Savepoint}.
*
* @param uid The uid of the operator.
* @param function The {@link KeyedStateReaderFunction} that is called for each key in state.
* @param <K> The type of the key in state.
* @param <OUT> The output type of the transform function.
* @return A {@code DataSet} of objects read from keyed state.
* @throws IOException If the savepoint does not contain operator state with the given uid.
*/
public <K, OUT> DataSource<OUT> readKeyedState(String uid, KeyedStateReaderFunction<K, OUT> function) throws IOException {
TypeInformation<K> keyTypeInfo;
TypeInformation<OUT> outType;
try {
keyTypeInfo = TypeExtractor.createTypeInfo(KeyedStateReaderFunction.class, function.getClass(), 0, null, null);
} catch (InvalidTypesException e) {
throw new InvalidProgramException("The key type of the KeyedStateReaderFunction could not be automatically determined. Please use " + "Savepoint#readKeyedState(String, KeyedStateReaderFunction, TypeInformation, TypeInformation) instead.", e);
}
try {
outType = TypeExtractor.getUnaryOperatorReturnType(function, KeyedStateReaderFunction.class, 0, 1, TypeExtractor.NO_INDEX, keyTypeInfo, Utils.getCallLocationName(), false);
} catch (InvalidTypesException e) {
throw new InvalidProgramException("The output type of the KeyedStateReaderFunction could not be automatically determined. Please use " + "Savepoint#readKeyedState(String, KeyedStateReaderFunction, TypeInformation, TypeInformation) instead.", e);
}
return readKeyedState(uid, function, keyTypeInfo, outType);
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class SavepointReader method readKeyedState.
/**
* Read keyed state from an operator in a {@code Savepoint}.
*
* @param uid The uid of the operator.
* @param function The {@link KeyedStateReaderFunction} that is called for each key in state.
* @param <K> The type of the key in state.
* @param <OUT> The output type of the transform function.
* @return A {@code DataStream} of objects read from keyed state.
* @throws IOException If the savepoint does not contain operator state with the given uid.
*/
public <K, OUT> DataStream<OUT> readKeyedState(String uid, KeyedStateReaderFunction<K, OUT> function) throws IOException {
TypeInformation<K> keyTypeInfo;
TypeInformation<OUT> outType;
try {
keyTypeInfo = TypeExtractor.createTypeInfo(KeyedStateReaderFunction.class, function.getClass(), 0, null, null);
} catch (InvalidTypesException e) {
throw new InvalidProgramException("The key type of the KeyedStateReaderFunction could not be automatically determined. Please use " + "Savepoint#readKeyedState(String, KeyedStateReaderFunction, TypeInformation, TypeInformation) instead.", e);
}
try {
outType = TypeExtractor.getUnaryOperatorReturnType(function, KeyedStateReaderFunction.class, 0, 1, TypeExtractor.NO_INDEX, keyTypeInfo, Utils.getCallLocationName(), false);
} catch (InvalidTypesException e) {
throw new InvalidProgramException("The output type of the KeyedStateReaderFunction could not be automatically determined. Please use " + "Savepoint#readKeyedState(String, KeyedStateReaderFunction, TypeInformation, TypeInformation) instead.", e);
}
return readKeyedState(uid, function, keyTypeInfo, outType);
}
Aggregations