final int NUM_ITERATIONS = 13;
final int DEFAULT_DOP= 133;
final int ITERATION_DOP = 77;
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
// ------------ construct the test program ------------------
{
env.setDegreeOfParallelism(DEFAULT_DOP);
@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, NUM_ITERATIONS, ITERATION_KEYS);
iteration.name(ITERATION_NAME).parallelism(ITERATION_DOP);
iteration.registerAggregator(AGGREGATOR_NAME, LongSumAggregator.class);
// test that multiple workset consumers are supported
DataSet<Tuple2<Double, String>> worksetSelfJoin =
iteration.getWorkset()
.map(new IdentityMapper<Tuple2<Double,String>>())
.join(iteration.getWorkset()).where(1).equalTo(1).projectFirst(0, 1).types(Double.class, String.class);
DataSet<Tuple3<Double, Long, String>> joined = worksetSelfJoin.join(iteration.getSolutionSet()).where(1).equalTo(2).with(new SolutionWorksetJoin());
DataSet<Tuple3<Double, Long, String>> result = iteration.closeWith(
joined,
joined.map(new NextWorksetMapper()).name(BEFORE_NEXT_WORKSET_MAP));
result.print();
result.writeAsText("/dev/null");
}
Plan p = env.createProgramPlan(JOB_NAME);
// ------------- validate the plan ----------------
assertEquals(JOB_NAME, p.getJobName());
assertEquals(DEFAULT_DOP, p.getDefaultParallelism());