use of org.apache.flink.test.operators.util.CollectionDataSets.CustomType in project flink by apache.
the class MapITCase method testTypeConversionMapperCustomToTuple.
@Test
public void testTypeConversionMapperCustomToTuple() throws Exception {
/*
* Test type conversion mapper (Custom -> Tuple)
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<CustomType> ds = CollectionDataSets.getCustomTypeDataSet(env);
DataSet<Tuple3<Integer, Long, String>> typeConversionMapDs = ds.map(new Mapper3());
List<Tuple3<Integer, Long, String>> result = typeConversionMapDs.collect();
String expected = "1,0,Hi\n" + "2,1,Hello\n" + "2,2,Hello world\n" + "3,3,Hello world, how are you?\n" + "3,4,I am fine.\n" + "3,5,Luke Skywalker\n" + "4,6,Comment#1\n" + "4,7,Comment#2\n" + "4,8,Comment#3\n" + "4,9,Comment#4\n" + "5,10,Comment#5\n" + "5,11,Comment#6\n" + "5,12,Comment#7\n" + "5,13,Comment#8\n" + "5,14,Comment#9\n" + "6,15,Comment#10\n" + "6,16,Comment#11\n" + "6,17,Comment#12\n" + "6,18,Comment#13\n" + "6,19,Comment#14\n" + "6,20,Comment#15\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.test.operators.util.CollectionDataSets.CustomType in project flink by apache.
the class GroupReduceITCase method testCorrectnessOfAllGroupReduceForCustomTypes.
@Test
public void testCorrectnessOfAllGroupReduceForCustomTypes() throws Exception {
/*
* check correctness of all-groupreduce for custom types
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<CustomType> ds = CollectionDataSets.getCustomTypeDataSet(env);
DataSet<CustomType> reduceDs = ds.reduceGroup(new AllAddingCustomTypeGroupReduce());
List<CustomType> result = reduceDs.collect();
String expected = "91,210,Hello!";
compareResultAsText(result, expected);
}
Aggregations