Search in sources :

Example 1 with Tuple7

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

the class CoGroupITCase method testCoGroupFieldSelectorAndComplicatedKeySelector.

@Test
public void testCoGroupFieldSelectorAndComplicatedKeySelector() throws Exception {
    /*
		 * CoGroup field-selector (expression keys) + key selector function
		 * The key selector is unnecessary complicated (Tuple1) ;)
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<POJO> ds = CollectionDataSets.getSmallPojoDataSet(env);
    DataSet<Tuple7<Integer, String, Integer, Integer, Long, String, Long>> ds2 = CollectionDataSets.getSmallTuplebasedDataSet(env);
    DataSet<CustomType> coGroupDs = ds.coGroup(ds2).where(new KeySelector6()).equalTo(6).with(new CoGroup3());
    List<CustomType> result = coGroupDs.collect();
    String expected = "-1,20000,Flink\n" + "-1,10000,Flink\n" + "-1,30000,Flink\n";
    compareResultAsText(result, expected);
}
Also used : CustomType(org.apache.flink.test.javaApiOperators.util.CollectionDataSets.CustomType) POJO(org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple7(org.apache.flink.api.java.tuple.Tuple7) Test(org.junit.Test)

Example 2 with Tuple7

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

the class CoGroupITCase method testCoGroupOnTwoCustomTypeInputsWithExpressionKeyAndFieldSelector.

@Test
public void testCoGroupOnTwoCustomTypeInputsWithExpressionKeyAndFieldSelector() throws Exception {
    /*
		 * CoGroup on two custom type inputs using expression keys
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<POJO> ds = CollectionDataSets.getSmallPojoDataSet(env);
    DataSet<Tuple7<Integer, String, Integer, Integer, Long, String, Long>> ds2 = CollectionDataSets.getSmallTuplebasedDataSet(env);
    DataSet<CustomType> coGroupDs = ds.coGroup(ds2).where("nestedPojo.longNumber").equalTo(6).with(new CoGroup1());
    List<CustomType> result = coGroupDs.collect();
    String expected = "-1,20000,Flink\n" + "-1,10000,Flink\n" + "-1,30000,Flink\n";
    compareResultAsText(result, expected);
}
Also used : CustomType(org.apache.flink.test.javaApiOperators.util.CollectionDataSets.CustomType) POJO(org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple7(org.apache.flink.api.java.tuple.Tuple7) Test(org.junit.Test)

Example 3 with Tuple7

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

the class JoinITCase method testJoinNestedPojoAgainstTupleSelectedUsingInteger.

@Test
public void testJoinNestedPojoAgainstTupleSelectedUsingInteger() throws Exception {
    /*
		 * Join nested pojo against tuple (selected as an integer)
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<POJO> ds1 = CollectionDataSets.getSmallPojoDataSet(env);
    DataSet<Tuple7<Integer, String, Integer, Integer, Long, String, Long>> ds2 = CollectionDataSets.getSmallTuplebasedDataSet(env);
    DataSet<Tuple2<POJO, Tuple7<Integer, String, Integer, Integer, Long, String, Long>>> joinDs = // <--- difference!
    ds1.join(ds2).where("nestedPojo.longNumber").equalTo(6);
    List<Tuple2<POJO, Tuple7<Integer, String, Integer, Integer, Long, String, Long>>> result = joinDs.collect();
    String expected = "1 First (10,100,1000,One) 10000,(1,First,10,100,1000,One,10000)\n" + "2 Second (20,200,2000,Two) 20000,(2,Second,20,200,2000,Two,20000)\n" + "3 Third (30,300,3000,Three) 30000,(3,Third,30,300,3000,Three,30000)\n";
    compareResultAsTuples(result, expected);
}
Also used : POJO(org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple7(org.apache.flink.api.java.tuple.Tuple7) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Test(org.junit.Test)

Example 4 with Tuple7

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

the class JoinITCase method testNestedIntoTupleIntoPojo.

@Test
public void testNestedIntoTupleIntoPojo() throws Exception {
    /*
		 * nested into tuple into pojo
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<POJO> ds1 = CollectionDataSets.getSmallPojoDataSet(env);
    DataSet<Tuple7<Integer, String, Integer, Integer, Long, String, Long>> ds2 = CollectionDataSets.getSmallTuplebasedDataSet(env);
    DataSet<Tuple2<POJO, Tuple7<Integer, String, Integer, Integer, Long, String, Long>>> joinDs = ds1.join(ds2).where("nestedTupleWithCustom.f0", "nestedTupleWithCustom.f1.myInt", "nestedTupleWithCustom.f1.myLong").equalTo("f2", "f3", "f4");
    env.setParallelism(1);
    List<Tuple2<POJO, Tuple7<Integer, String, Integer, Integer, Long, String, Long>>> result = joinDs.collect();
    String expected = "1 First (10,100,1000,One) 10000,(1,First,10,100,1000,One,10000)\n" + "2 Second (20,200,2000,Two) 20000,(2,Second,20,200,2000,Two,20000)\n" + "3 Third (30,300,3000,Three) 30000,(3,Third,30,300,3000,Three,30000)\n";
    compareResultAsTuples(result, expected);
}
Also used : POJO(org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple7(org.apache.flink.api.java.tuple.Tuple7) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Test(org.junit.Test)

Example 5 with Tuple7

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

the class OuterJoinITCase method testNestedIntoTuple.

@Test
public void testNestedIntoTuple() throws Exception {
    /*
		 * nested into tuple
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<POJO> ds1 = CollectionDataSets.getSmallPojoDataSet(env);
    DataSet<Tuple7<Integer, String, Integer, Integer, Long, String, Long>> ds2 = CollectionDataSets.getSmallTuplebasedDataSet(env);
    DataSet<Tuple2<POJO, Tuple7<Integer, String, Integer, Integer, Long, String, Long>>> joinDs = ds1.fullOuterJoin(ds2).where("nestedPojo.longNumber", "number", "nestedTupleWithCustom.f0").equalTo("f6", "f0", "f2").with(new ProjectBothFunction<POJO, Tuple7<Integer, String, Integer, Integer, Long, String, Long>>());
    env.setParallelism(1);
    List<Tuple2<POJO, Tuple7<Integer, String, Integer, Integer, Long, String, Long>>> result = joinDs.collect();
    String expected = "1 First (10,100,1000,One) 10000,(1,First,10,100,1000,One,10000)\n" + "2 Second (20,200,2000,Two) 20000,(2,Second,20,200,2000,Two,20000)\n" + "3 Third (30,300,3000,Three) 30000,(3,Third,30,300,3000,Three,30000)\n";
    compareResultAsTuples(result, expected);
}
Also used : POJO(org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple7(org.apache.flink.api.java.tuple.Tuple7) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Test(org.junit.Test)

Aggregations

Tuple7 (org.apache.flink.api.java.tuple.Tuple7)32 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)31 Test (org.junit.Test)31 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)24 POJO (org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO)15 POJO (org.apache.flink.test.operators.util.CollectionDataSets.POJO)15 CustomType (org.apache.flink.test.javaApiOperators.util.CollectionDataSets.CustomType)3 CustomType (org.apache.flink.test.operators.util.CollectionDataSets.CustomType)3 lombok.val (lombok.val)1 Plan (org.apache.flink.api.common.Plan)1 FieldList (org.apache.flink.api.common.operators.util.FieldList)1 DiscardingOutputFormat (org.apache.flink.api.java.io.DiscardingOutputFormat)1 Channel (org.apache.flink.optimizer.plan.Channel)1 DualInputPlanNode (org.apache.flink.optimizer.plan.DualInputPlanNode)1 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)1 SinkPlanNode (org.apache.flink.optimizer.plan.SinkPlanNode)1 IdentityCoGrouper (org.apache.flink.optimizer.testfunctions.IdentityCoGrouper)1