use of org.apache.flink.test.util.PointFormatter in project flink by apache.
the class IterationWithChainingITCase method testProgram.
@Override
protected void testProgram() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(4);
DataSet<Tuple2<Integer, CoordVector>> initialInput = env.readFile(new PointInFormat(), dataPath).setParallelism(1).name("Input");
IterativeDataSet<Tuple2<Integer, CoordVector>> iteration = initialInput.iterate(2).name("Loop");
DataSet<Tuple2<Integer, CoordVector>> identity = iteration.groupBy(0).reduceGroup(new GroupReduceFunction<Tuple2<Integer, CoordVector>, Tuple2<Integer, CoordVector>>() {
@Override
public void reduce(Iterable<Tuple2<Integer, CoordVector>> values, Collector<Tuple2<Integer, CoordVector>> out) throws Exception {
for (Tuple2<Integer, CoordVector> value : values) {
out.collect(value);
}
}
}).map(new MapFunction<Tuple2<Integer, CoordVector>, Tuple2<Integer, CoordVector>>() {
@Override
public Tuple2<Integer, CoordVector> map(Tuple2<Integer, CoordVector> value) throws Exception {
return value;
}
});
iteration.closeWith(identity).writeAsFormattedText(resultPath, new PointFormatter());
env.execute("Iteration with chained map test");
compareResultsByLinesInMemory(DATA_POINTS, resultPath);
}
use of org.apache.flink.test.util.PointFormatter in project flink by apache.
the class IterationWithUnionITCase method testProgram.
@Override
protected void testProgram() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple2<Integer, CoordVector>> initialInput = env.readFile(new PointInFormat(), this.dataPath).setParallelism(1);
IterativeDataSet<Tuple2<Integer, CoordVector>> iteration = initialInput.iterate(2);
DataSet<Tuple2<Integer, CoordVector>> result = iteration.union(iteration).map(new IdentityMapper());
iteration.closeWith(result).writeAsFormattedText(this.resultPath, new PointFormatter());
env.execute();
}
Aggregations