use of org.apache.flink.api.java.tuple.Tuple3 in project flink by apache.
the class JoinITCase method testProjectJoinOnATuple2Input.
@Test
public void testProjectJoinOnATuple2Input() throws Exception {
/*
* Project join on a tuple input 2
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.get5TupleDataSet(env);
DataSet<Tuple6<String, String, Long, Long, Long, Integer>> joinDs = ds1.join(ds2).where(1).equalTo(1).projectSecond(3).projectFirst(2, 1).projectSecond(4, 1).projectFirst(0);
List<Tuple6<String, String, Long, Long, Long, Integer>> result = joinDs.collect();
String expected = "Hallo,Hi,1,1,1,1\n" + "Hallo Welt,Hello,2,2,2,2\n" + "Hallo Welt,Hello world,2,2,2,3\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.api.java.tuple.Tuple3 in project flink by apache.
the class JoinITCase method testJoinWithBroadcastSet.
@Test
public void testJoinWithBroadcastSet() throws Exception {
/*
* Join with broadcast set
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Integer> intDs = CollectionDataSets.getIntegerDataSet(env);
DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.get3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
DataSet<Tuple3<String, String, Integer>> joinDs = ds1.join(ds2).where(1).equalTo(4).with(new T3T5BCJoin()).withBroadcastSet(intDs, "ints");
List<Tuple3<String, String, Integer>> result = joinDs.collect();
String expected = "Hi,Hallo,55\n" + "Hi,Hallo Welt wie,55\n" + "Hello,Hallo Welt,55\n" + "Hello world,Hallo Welt,55\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.api.java.tuple.Tuple3 in project flink by apache.
the class MapITCase method test.
@Test
public void test() throws Exception {
/*
* Test mapper if UDF returns input object - increment first field of a tuple
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.get3TupleDataSet(env);
DataSet<Tuple3<Integer, Long, String>> inputObjMapDs = ds.map(new Mapper7());
List<Tuple3<Integer, Long, String>> result = inputObjMapDs.collect();
String expected = "2,1,Hi\n" + "3,2,Hello\n" + "4,2,Hello world\n" + "5,3,Hello world, how are you?\n" + "6,3,I am fine.\n" + "7,3,Luke Skywalker\n" + "8,4,Comment#1\n" + "9,4,Comment#2\n" + "10,4,Comment#3\n" + "11,4,Comment#4\n" + "12,5,Comment#5\n" + "13,5,Comment#6\n" + "14,5,Comment#7\n" + "15,5,Comment#8\n" + "16,5,Comment#9\n" + "17,6,Comment#10\n" + "18,6,Comment#11\n" + "19,6,Comment#12\n" + "20,6,Comment#13\n" + "21,6,Comment#14\n" + "22,6,Comment#15\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.api.java.tuple.Tuple3 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.api.java.tuple.Tuple3 in project flink by apache.
the class DistinctITCase method testCorrectnessOfDistinctOnTuples.
@Test
public void testCorrectnessOfDistinctOnTuples() throws Exception {
/*
* check correctness of distinct on tuples
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple3<Integer, Long, String>> distinctDs = ds.union(ds).distinct();
List<Tuple3<Integer, Long, String>> result = distinctDs.collect();
String expected = "1,1,Hi\n" + "2,2,Hello\n" + "3,2,Hello world\n";
compareResultAsTuples(result, expected);
}
Aggregations