use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class DeltaIterationTranslationTest method testRejectWhenSolutionSetKeysDontMatchJoin.
@Test
public void testRejectWhenSolutionSetKeysDontMatchJoin() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
@SuppressWarnings("unchecked") DataSet<Tuple3<Double, Long, String>> initialSolutionSet = env.fromElements(new Tuple3<Double, Long, String>(3.44, 5L, "abc"));
@SuppressWarnings("unchecked") DataSet<Tuple2<Double, String>> initialWorkSet = env.fromElements(new Tuple2<Double, String>(1.23, "abc"));
DeltaIteration<Tuple3<Double, Long, String>, Tuple2<Double, String>> iteration = initialSolutionSet.iterateDelta(initialWorkSet, 10, 1);
try {
iteration.getWorkset().join(iteration.getSolutionSet()).where(1).equalTo(2);
fail("Accepted invalid program.");
} catch (InvalidProgramException e) {
// all good!
}
try {
iteration.getSolutionSet().join(iteration.getWorkset()).where(2).equalTo(1);
fail("Accepted invalid program.");
} catch (InvalidProgramException e) {
// all good!
}
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class OpenIterationTest method testOperationOnSolutionSet.
@Test
public void testOperationOnSolutionSet() {
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.getSolutionSet().map(new IdentityMapper<Tuple2<Long, Long>>());
DataSet<Tuple2<Long, Long>> joined = iteration.getWorkset().join(mapped).where(0).equalTo(0).projectFirst(1).projectSecond(0);
iteration.closeWith(joined, joined).output(new DiscardingOutputFormat<Tuple2<Long, 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 OpenIterationTest method testSinkOnSolutionSetDeltaIteration.
@Test
public void testSinkOnSolutionSetDeltaIteration() {
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.getSolutionSet().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 FirstNOperatorTest method testGroupedSortedFirstN.
@Test
public void testGroupedSortedFirstN() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should work
try {
tupleDs.groupBy(2).sortGroup(4, Order.ASCENDING).first(1);
} catch (Exception e) {
Assert.fail();
}
// should work
try {
tupleDs.groupBy(1, 3).sortGroup(4, Order.ASCENDING).first(10);
} catch (Exception e) {
Assert.fail();
}
// should not work n == 0
try {
tupleDs.groupBy(0).sortGroup(4, Order.ASCENDING).first(0);
Assert.fail();
} catch (InvalidProgramException ipe) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
// should not work n == -1
try {
tupleDs.groupBy(2).sortGroup(4, Order.ASCENDING).first(-1);
Assert.fail();
} catch (InvalidProgramException ipe) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class FirstNOperatorTest method testUngroupedFirstN.
@Test
public void testUngroupedFirstN() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should work
try {
tupleDs.first(1);
} catch (Exception e) {
Assert.fail();
}
// should work
try {
tupleDs.first(10);
} catch (Exception e) {
Assert.fail();
}
// should not work n == 0
try {
tupleDs.first(0);
Assert.fail();
} catch (InvalidProgramException ipe) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
// should not work n == -1
try {
tupleDs.first(-1);
Assert.fail();
} catch (InvalidProgramException ipe) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
}
Aggregations