Search in sources :

Example 16 with POJO

use of org.apache.flink.test.operators.util.CollectionDataSets.POJO in project flink by apache.

the class JoinITCase 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.join(ds2).where("nestedPojo.longNumber", "number", "nestedTupleWithCustom.f0").equalTo("f6", "f0", "f2");
    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.operators.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 17 with POJO

use of org.apache.flink.test.operators.util.CollectionDataSets.POJO in project flink by apache.

the class DistinctITCase method testCorrectnessOfDistinctOnPojos.

@Test
public void testCorrectnessOfDistinctOnPojos() throws Exception {
    /*
         * check correctness of distinct on Pojos
         */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
    DataSet<Integer> reduceDs = ds.distinct("nestedPojo.longNumber").map(new Mapper2());
    List<Integer> result = reduceDs.collect();
    String expected = "10000\n20000\n30000\n";
    compareResultAsText(result, expected);
}
Also used : POJO(org.apache.flink.test.operators.util.CollectionDataSets.POJO) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 18 with POJO

use of org.apache.flink.test.operators.util.CollectionDataSets.POJO in project flink by apache.

the class DistinctITCase method testDistinctOnFullPojo.

@Test
public void testDistinctOnFullPojo() throws Exception {
    /*
         * distinct on full Pojo
         */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
    DataSet<Integer> reduceDs = ds.distinct().map(new Mapper1());
    List<Integer> result = reduceDs.collect();
    String expected = "10000\n20000\n30000\n";
    compareResultAsText(result, expected);
}
Also used : POJO(org.apache.flink.test.operators.util.CollectionDataSets.POJO) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 19 with POJO

use of org.apache.flink.test.operators.util.CollectionDataSets.POJO in project flink by apache.

the class PartitionITCase method testHashPartitionWithKeyExpression.

@Test
public void testHashPartitionWithKeyExpression() throws Exception {
    /*
         * Test hash partition with key expression
         */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    env.setParallelism(3);
    DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
    DataSet<Long> uniqLongs = ds.partitionByHash("nestedPojo.longNumber").setParallelism(4).mapPartition(new UniqueNestedPojoLongMapper());
    List<Long> result = uniqLongs.collect();
    String expected = "10000\n" + "20000\n" + "30000\n";
    compareResultAsText(result, expected);
}
Also used : POJO(org.apache.flink.test.operators.util.CollectionDataSets.POJO) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 20 with POJO

use of org.apache.flink.test.operators.util.CollectionDataSets.POJO in project flink by apache.

the class PartitionITCase method testRangePartitionWithKeyExpression.

@Test
public void testRangePartitionWithKeyExpression() throws Exception {
    /*
         * Test range partition with key expression
         */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    env.setParallelism(3);
    DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
    DataSet<Long> uniqLongs = ds.partitionByRange("nestedPojo.longNumber").setParallelism(4).mapPartition(new UniqueNestedPojoLongMapper());
    List<Long> result = uniqLongs.collect();
    String expected = "10000\n" + "20000\n" + "30000\n";
    compareResultAsText(result, expected);
}
Also used : POJO(org.apache.flink.test.operators.util.CollectionDataSets.POJO) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Aggregations

ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)20 POJO (org.apache.flink.test.operators.util.CollectionDataSets.POJO)20 Test (org.junit.Test)20 Tuple7 (org.apache.flink.api.java.tuple.Tuple7)15 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)12 CustomType (org.apache.flink.test.operators.util.CollectionDataSets.CustomType)3 Tuple1 (org.apache.flink.api.java.tuple.Tuple1)1