use of org.apache.flink.test.operators.util.CollectionDataSets.CustomType in project flink by apache.
the class JoinITCase method testJoinOnATupleInputWithKeyFieldSelectorAndACustomTypeInputWithKeyExtractor.
@Test
public void testJoinOnATupleInputWithKeyFieldSelectorAndACustomTypeInputWithKeyExtractor() 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.getCustomTypeDataSet(env);
DataSet<Tuple2<String, String>> joinDs = ds1.join(ds2).where(1).equalTo(new KeySelector2()).with(new T3CustJoin());
List<Tuple2<String, String>> result = joinDs.collect();
String expected = "Hi,Hello\n" + "Hello,Hello world\n" + "Hello world,Hello world\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.test.operators.util.CollectionDataSets.CustomType in project flink by apache.
the class FilterITCase method testFilterOnCustomType.
@Test
public void testFilterOnCustomType() throws Exception {
/*
* Test filter on custom type
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<CustomType> ds = CollectionDataSets.getCustomTypeDataSet(env);
DataSet<CustomType> filterDs = ds.filter(new Filter6());
List<CustomType> result = filterDs.collect();
String expected = "3,3,Hello world, how are you?\n" + "3,4,I am fine.\n" + "3,5,Luke Skywalker\n";
compareResultAsText(result, expected);
}
use of org.apache.flink.test.operators.util.CollectionDataSets.CustomType in project flink by apache.
the class CrossITCase method testCorrectnessOfCrossOnTwoCustomTypeInputs.
@Test
public void testCorrectnessOfCrossOnTwoCustomTypeInputs() throws Exception {
/*
* check correctness of cross on two custom type inputs
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<CustomType> ds = CollectionDataSets.getSmallCustomTypeDataSet(env);
DataSet<CustomType> ds2 = CollectionDataSets.getSmallCustomTypeDataSet(env);
DataSet<CustomType> crossDs = ds.cross(ds2).with(new CustomTypeCross());
List<CustomType> result = crossDs.collect();
String expected = "1,0,HiHi\n" + "2,1,HiHello\n" + "2,2,HiHello world\n" + "2,1,HelloHi\n" + "4,2,HelloHello\n" + "4,3,HelloHello world\n" + "2,2,Hello worldHi\n" + "4,3,Hello worldHello\n" + "4,4,Hello worldHello world";
compareResultAsText(result, expected);
}
use of org.apache.flink.test.operators.util.CollectionDataSets.CustomType in project flink by apache.
the class OuterJoinITCase method testJoinWithMixedKeyTypes1.
@Test
public void testJoinWithMixedKeyTypes1() 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<CustomType> ds1 = CollectionDataSets.getSmallCustomTypeDataSet(env);
DataSet<Tuple3<Integer, Long, String>> ds2 = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple2<String, String>> joinDs = ds1.fullOuterJoin(ds2).where(new KeySelector1()).equalTo(0).with(new CustT3Join());
List<Tuple2<String, String>> result = joinDs.collect();
String expected = "Hi,Hi\n" + "Hello,Hello\n" + "Hello world,Hello\n" + "null,Hello world\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.test.operators.util.CollectionDataSets.CustomType in project flink by apache.
the class JoinITCase method testDefaultJoinOnTwoCustomTypeInputsWithInnerClassKeyExtractorsDisabledClosureCleaner.
@Test
public void testDefaultJoinOnTwoCustomTypeInputsWithInnerClassKeyExtractorsDisabledClosureCleaner() throws Exception {
/*
* (Default) Join on two custom type inputs with key extractors, check if disabling closure cleaning works
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
env.getConfig().disableClosureCleaner();
DataSet<CustomType> ds1 = CollectionDataSets.getCustomTypeDataSet(env);
DataSet<CustomType> ds2 = CollectionDataSets.getSmallCustomTypeDataSet(env);
boolean correctExceptionTriggered = false;
try {
DataSet<Tuple2<CustomType, CustomType>> joinDs = ds1.join(ds2).where(new KeySelector<CustomType, Integer>() {
@Override
public Integer getKey(CustomType value) {
return value.myInt;
}
}).equalTo(new KeySelector<CustomType, Integer>() {
@Override
public Integer getKey(CustomType value) throws Exception {
return value.myInt;
}
});
} catch (InvalidProgramException ex) {
correctExceptionTriggered = (ex.getCause() instanceof java.io.NotSerializableException);
}
Assert.assertTrue(correctExceptionTriggered);
}
Aggregations