Search in sources :

Example 1 with Tuple3

use of org.apache.flink.api.java.tuple.Tuple3 in project flink by apache.

the class CrossITCase method testCorrectnessOfCrossIfUDFReturnsLeftInputObject.

@Test
public void testCorrectnessOfCrossIfUDFReturnsLeftInputObject() throws Exception {
    /*
		 * check correctness of cross if UDF returns left input object
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
    DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
    DataSet<Tuple3<Integer, Long, String>> crossDs = ds.cross(ds2).with(new Tuple3ReturnLeft());
    List<Tuple3<Integer, Long, String>> result = crossDs.collect();
    String expected = "1,1,Hi\n" + "1,1,Hi\n" + "1,1,Hi\n" + "2,2,Hello\n" + "2,2,Hello\n" + "2,2,Hello\n" + "3,2,Hello world\n" + "3,2,Hello world\n" + "3,2,Hello world\n";
    compareResultAsTuples(result, expected);
}
Also used : Tuple5(org.apache.flink.api.java.tuple.Tuple5) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple3(org.apache.flink.api.java.tuple.Tuple3) Test(org.junit.Test)

Example 2 with Tuple3

use of org.apache.flink.api.java.tuple.Tuple3 in project flink by apache.

the class CrossITCase method testCorrectnessOfCrossIfUDFReturnsRightInputObject.

@Test
public void testCorrectnessOfCrossIfUDFReturnsRightInputObject() throws Exception {
    /*
		 * check correctness of cross if UDF returns right input object
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
    DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
    DataSet<Tuple5<Integer, Long, Integer, String, Long>> crossDs = ds.cross(ds2).with(new Tuple5ReturnRight());
    List<Tuple5<Integer, Long, Integer, String, Long>> result = crossDs.collect();
    String expected = "1,1,0,Hallo,1\n" + "1,1,0,Hallo,1\n" + "1,1,0,Hallo,1\n" + "2,2,1,Hallo Welt,2\n" + "2,2,1,Hallo Welt,2\n" + "2,2,1,Hallo Welt,2\n" + "2,3,2,Hallo Welt wie,1\n" + "2,3,2,Hallo Welt wie,1\n" + "2,3,2,Hallo Welt wie,1\n";
    compareResultAsTuples(result, expected);
}
Also used : Tuple5(org.apache.flink.api.java.tuple.Tuple5) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple3(org.apache.flink.api.java.tuple.Tuple3) Test(org.junit.Test)

Example 3 with Tuple3

use of org.apache.flink.api.java.tuple.Tuple3 in project flink by apache.

the class CrossITCase method testCorrectnessOfCrossATupleInputAndACustomTypeInput.

@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);
}
Also used : CustomType(org.apache.flink.test.javaApiOperators.util.CollectionDataSets.CustomType) Tuple5(org.apache.flink.api.java.tuple.Tuple5) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple3(org.apache.flink.api.java.tuple.Tuple3) Test(org.junit.Test)

Example 4 with Tuple3

use of org.apache.flink.api.java.tuple.Tuple3 in project flink by apache.

the class CrossITCase method testProjectCrossOnATupleInput2.

@Test
public void testProjectCrossOnATupleInput2() throws Exception {
    /*
		 * project cross on a tuple input 2
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
    DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
    DataSet<Tuple6<String, String, Long, Long, Long, Integer>> crossDs = ds.cross(ds2).projectSecond(3).projectFirst(2, 1).projectSecond(4, 1).projectFirst(0);
    List<Tuple6<String, String, Long, Long, Long, Integer>> result = crossDs.collect();
    String expected = "Hallo,Hi,1,1,1,1\n" + "Hallo Welt,Hi,1,2,2,1\n" + "Hallo Welt wie,Hi,1,1,3,1\n" + "Hallo,Hello,2,1,1,2\n" + "Hallo Welt,Hello,2,2,2,2\n" + "Hallo Welt wie,Hello,2,1,3,2\n" + "Hallo,Hello world,2,1,1,3\n" + "Hallo Welt,Hello world,2,2,2,3\n" + "Hallo Welt wie,Hello world,2,1,3,3\n";
    compareResultAsTuples(result, expected);
}
Also used : Tuple5(org.apache.flink.api.java.tuple.Tuple5) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple6(org.apache.flink.api.java.tuple.Tuple6) Tuple3(org.apache.flink.api.java.tuple.Tuple3) Test(org.junit.Test)

Example 5 with Tuple3

use of org.apache.flink.api.java.tuple.Tuple3 in project flink by apache.

the class CrossITCase method testCorrectnessOfDefaultCross.

@Test
public void testCorrectnessOfDefaultCross() throws Exception {
    /*
		 * check correctness of default cross
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
    DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
    DataSet<Tuple2<Tuple3<Integer, Long, String>, Tuple5<Integer, Long, Integer, String, Long>>> crossDs = ds.cross(ds2);
    List<Tuple2<Tuple3<Integer, Long, String>, Tuple5<Integer, Long, Integer, String, Long>>> result = crossDs.collect();
    String expected = "(1,1,Hi),(2,2,1,Hallo Welt,2)\n" + "(1,1,Hi),(1,1,0,Hallo,1)\n" + "(1,1,Hi),(2,3,2,Hallo Welt wie,1)\n" + "(2,2,Hello),(2,2,1,Hallo Welt,2)\n" + "(2,2,Hello),(1,1,0,Hallo,1)\n" + "(2,2,Hello),(2,3,2,Hallo Welt wie,1)\n" + "(3,2,Hello world),(2,2,1,Hallo Welt,2)\n" + "(3,2,Hello world),(1,1,0,Hallo,1)\n" + "(3,2,Hello world),(2,3,2,Hallo Welt wie,1)\n";
    compareResultAsTuples(result, expected);
}
Also used : Tuple5(org.apache.flink.api.java.tuple.Tuple5) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Tuple3(org.apache.flink.api.java.tuple.Tuple3) Test(org.junit.Test)

Aggregations

Tuple3 (org.apache.flink.api.java.tuple.Tuple3)559 Test (org.junit.Test)506 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)415 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)182 Plan (org.apache.flink.api.common.Plan)89 Tuple5 (org.apache.flink.api.java.tuple.Tuple5)74 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)63 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)55 SinkPlanNode (org.apache.flink.optimizer.plan.SinkPlanNode)53 OneInputTransformation (org.apache.flink.streaming.api.transformations.OneInputTransformation)43 TimeWindow (org.apache.flink.streaming.api.windowing.windows.TimeWindow)43 DualInputPlanNode (org.apache.flink.optimizer.plan.DualInputPlanNode)38 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)37 IOException (java.io.IOException)32 ArrayList (java.util.ArrayList)31 Configuration (org.apache.flink.configuration.Configuration)29 EventTimeTrigger (org.apache.flink.streaming.api.windowing.triggers.EventTimeTrigger)27 FieldSet (org.apache.flink.api.common.operators.util.FieldSet)24 TypeHint (org.apache.flink.api.common.typeinfo.TypeHint)24 Tuple1 (org.apache.flink.api.java.tuple.Tuple1)21