use of org.apache.flink.test.javaApiOperators.util.CollectionDataSets.CustomType in project flink by apache.
the class OuterJoinITCase method testJoinWithMixedKeyTypes2.
@Test
public void testJoinWithMixedKeyTypes2() throws Exception {
/*
* Join on a tuple input with key field selector and a custom type input with key extractor
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<CustomType> ds2 = CollectionDataSets.getSmallCustomTypeDataSet(env);
DataSet<Tuple2<String, String>> joinDs = ds1.fullOuterJoin(ds2).where(1).equalTo(new KeySelector2()).with(new T3CustJoin());
List<Tuple2<String, String>> result = joinDs.collect();
String expected = "null,Hi\n" + "Hi,Hello\n" + "Hello,Hello world\n" + "Hello world,Hello world\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.test.javaApiOperators.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);
}
use of org.apache.flink.test.javaApiOperators.util.CollectionDataSets.CustomType in project flink by apache.
the class GroupReduceITCase method testCorrectnessOfGroupReduceOnCustomTypeWithKeyExtractorAndCombine.
@Test
public void testCorrectnessOfGroupReduceOnCustomTypeWithKeyExtractorAndCombine() throws Exception {
/*
* check correctness of groupReduce on custom type with key extractor and combine
*/
org.junit.Assume.assumeTrue(mode != TestExecutionMode.COLLECTION);
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<CustomType> ds = CollectionDataSets.getCustomTypeDataSet(env);
DataSet<CustomType> reduceDs = ds.groupBy(new KeySelector3()).reduceGroup(new CustomTypeGroupReduceWithCombine());
List<CustomType> result = reduceDs.collect();
String expected = "1,0,test1\n" + "2,3,test2\n" + "3,12,test3\n" + "4,30,test4\n" + "5,60,test5\n" + "6,105,test6\n";
compareResultAsText(result, expected);
}
use of org.apache.flink.test.javaApiOperators.util.CollectionDataSets.CustomType in project flink by apache.
the class GroupReduceITCase method testPojoKeySelectorGroupSort.
@Test
public void testPojoKeySelectorGroupSort() throws Exception {
/*
* check correctness of sorted groupReduce on custom type with keyselector sorting
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<CustomType> ds = CollectionDataSets.getCustomTypeDataSet(env);
DataSet<CustomType> reduceDs = ds.groupBy(new TwoTuplePojoExtractor()).sortGroup(new StringPojoExtractor(), Order.DESCENDING).reduceGroup(new CustomTypeSortedGroupReduce());
List<CustomType> result = reduceDs.collect();
String expected = "1,0,Hi\n" + "2,3,Hello world-Hello\n" + "3,12,Luke Skywalker-I am fine.-Hello world, how are you?\n" + "4,30,Comment#4-Comment#3-Comment#2-Comment#1\n" + "5,60,Comment#9-Comment#8-Comment#7-Comment#6-Comment#5\n" + "6,105,Comment#15-Comment#14-Comment#13-Comment#12-Comment#11-Comment#10\n";
compareResultAsText(result, expected);
}
use of org.apache.flink.test.javaApiOperators.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);
}
Aggregations