Java Code Examples for org.apache.flink.test.operators.util.CollectionDataSets#getSmallCustomTypeDataSet()

The following examples show how to use org.apache.flink.test.operators.util.CollectionDataSets#getSmallCustomTypeDataSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrossITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorrectnessOfCrossATupleInputAndACustomTypeInput() throws Exception {
	/*
	 * check correctness of cross a tuple input and a custom type input
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds = CollectionDataSets.getSmall5TupleDataSet(env);
	DataSet<CustomType> ds2 = CollectionDataSets.getSmallCustomTypeDataSet(env);
	DataSet<Tuple3<Integer, Long, String>> crossDs = ds.cross(ds2).with(new MixedCross());

	List<Tuple3<Integer, Long, String>> result = crossDs.collect();

	String expected = "2,0,HalloHi\n" +
			"3,0,HalloHello\n" +
			"3,0,HalloHello world\n" +
			"3,0,Hallo WeltHi\n" +
			"4,1,Hallo WeltHello\n" +
			"4,2,Hallo WeltHello world\n" +
			"3,0,Hallo Welt wieHi\n" +
			"4,2,Hallo Welt wieHello\n" +
			"4,4,Hallo Welt wieHello world\n";

	compareResultAsTuples(result, expected);
}
 
Example 2
Source File: OuterJoinITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: OuterJoinITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);

}
 
Example 4
Source File: CrossITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorrectnessOfCrossATupleInputAndACustomTypeInput() throws Exception {
	/*
	 * check correctness of cross a tuple input and a custom type input
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds = CollectionDataSets.getSmall5TupleDataSet(env);
	DataSet<CustomType> ds2 = CollectionDataSets.getSmallCustomTypeDataSet(env);
	DataSet<Tuple3<Integer, Long, String>> crossDs = ds.cross(ds2).with(new MixedCross());

	List<Tuple3<Integer, Long, String>> result = crossDs.collect();

	String expected = "2,0,HalloHi\n" +
			"3,0,HalloHello\n" +
			"3,0,HalloHello world\n" +
			"3,0,Hallo WeltHi\n" +
			"4,1,Hallo WeltHello\n" +
			"4,2,Hallo WeltHello world\n" +
			"3,0,Hallo Welt wieHi\n" +
			"4,2,Hallo Welt wieHello\n" +
			"4,4,Hallo Welt wieHello world\n";

	compareResultAsTuples(result, expected);
}
 
Example 5
Source File: CrossITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 6
Source File: JoinITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaultJoinOnTwoCustomTypeInputsWithKeyExtractors() throws Exception {
	/*
	 * (Default) Join on two custom type inputs with key extractors
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CustomType> ds1 = CollectionDataSets.getCustomTypeDataSet(env);
	DataSet<CustomType> ds2 = CollectionDataSets.getSmallCustomTypeDataSet(env);

	DataSet<Tuple2<CustomType, CustomType>> joinDs =
			ds1.join(ds2)
					.where(new KeySelector5())
					.equalTo(new KeySelector6());

	List<Tuple2<CustomType, CustomType>> result = joinDs.collect();

	String expected = "1,0,Hi,1,0,Hi\n" +
			"2,1,Hello,2,1,Hello\n" +
			"2,1,Hello,2,2,Hello world\n" +
			"2,2,Hello world,2,1,Hello\n" +
			"2,2,Hello world,2,2,Hello world\n";

	compareResultAsTuples(result, expected);
}
 
Example 7
Source File: JoinITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testJoinOnACustomTypeInputWithKeyExtractorAndATupleInputWithKeyFieldSelector()
		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.get3TupleDataSet(env);
	DataSet<Tuple2<String, String>> joinDs =
			ds1.join(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";

	compareResultAsTuples(result, expected);

}
 
Example 8
Source File: OuterJoinITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 9
Source File: OuterJoinITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);

}
 
Example 10
Source File: JoinITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testJoinOnACustomTypeInputWithKeyExtractorAndATupleInputWithKeyFieldSelector()
		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.get3TupleDataSet(env);
	DataSet<Tuple2<String, String>> joinDs =
			ds1.join(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";

	compareResultAsTuples(result, expected);

}
 
Example 11
Source File: CrossITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 12
Source File: JoinITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaultJoinOnTwoCustomTypeInputsWithKeyExtractors() throws Exception {
	/*
	 * (Default) Join on two custom type inputs with key extractors
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CustomType> ds1 = CollectionDataSets.getCustomTypeDataSet(env);
	DataSet<CustomType> ds2 = CollectionDataSets.getSmallCustomTypeDataSet(env);

	DataSet<Tuple2<CustomType, CustomType>> joinDs =
			ds1.join(ds2)
					.where(new KeySelector5())
					.equalTo(new KeySelector6());

	List<Tuple2<CustomType, CustomType>> result = joinDs.collect();

	String expected = "1,0,Hi,1,0,Hi\n" +
			"2,1,Hello,2,1,Hello\n" +
			"2,1,Hello,2,2,Hello world\n" +
			"2,2,Hello world,2,1,Hello\n" +
			"2,2,Hello world,2,2,Hello world\n";

	compareResultAsTuples(result, expected);
}
 
Example 13
Source File: JoinITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testJoinOnACustomTypeInputWithKeyExtractorAndATupleInputWithKeyFieldSelector()
		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.get3TupleDataSet(env);
	DataSet<Tuple2<String, String>> joinDs =
			ds1.join(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";

	compareResultAsTuples(result, expected);

}
 
Example 14
Source File: OuterJoinITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 15
Source File: OuterJoinITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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);

}
 
Example 16
Source File: CrossITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorrectnessOfCrossATupleInputAndACustomTypeInput() throws Exception {
	/*
	 * check correctness of cross a tuple input and a custom type input
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds = CollectionDataSets.getSmall5TupleDataSet(env);
	DataSet<CustomType> ds2 = CollectionDataSets.getSmallCustomTypeDataSet(env);
	DataSet<Tuple3<Integer, Long, String>> crossDs = ds.cross(ds2).with(new MixedCross());

	List<Tuple3<Integer, Long, String>> result = crossDs.collect();

	String expected = "2,0,HalloHi\n" +
			"3,0,HalloHello\n" +
			"3,0,HalloHello world\n" +
			"3,0,Hallo WeltHi\n" +
			"4,1,Hallo WeltHello\n" +
			"4,2,Hallo WeltHello world\n" +
			"3,0,Hallo Welt wieHi\n" +
			"4,2,Hallo Welt wieHello\n" +
			"4,4,Hallo Welt wieHello world\n";

	compareResultAsTuples(result, expected);
}
 
Example 17
Source File: CrossITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 18
Source File: JoinITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaultJoinOnTwoCustomTypeInputsWithKeyExtractors() throws Exception {
	/*
	 * (Default) Join on two custom type inputs with key extractors
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CustomType> ds1 = CollectionDataSets.getCustomTypeDataSet(env);
	DataSet<CustomType> ds2 = CollectionDataSets.getSmallCustomTypeDataSet(env);

	DataSet<Tuple2<CustomType, CustomType>> joinDs =
			ds1.join(ds2)
					.where(new KeySelector5())
					.equalTo(new KeySelector6());

	List<Tuple2<CustomType, CustomType>> result = joinDs.collect();

	String expected = "1,0,Hi,1,0,Hi\n" +
			"2,1,Hello,2,1,Hello\n" +
			"2,1,Hello,2,2,Hello world\n" +
			"2,2,Hello world,2,1,Hello\n" +
			"2,2,Hello world,2,2,Hello world\n";

	compareResultAsTuples(result, expected);
}