use of org.apache.flink.test.javaApiOperators.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);
}
use of org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO in project flink by apache.
the class SortPartitionITCase method testSortPartitionPojoByNestedFieldExpression.
@Test
public void testSortPartitionPojoByNestedFieldExpression() throws Exception {
/*
* Test sort partition on field expression
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(3);
DataSet<POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
List<Tuple1<Boolean>> result = ds.map(new IdMapper<POJO>()).setParallelism(// parallelize input
1).sortPartition("nestedTupleWithCustom.f1.myString", Order.ASCENDING).sortPartition("number", Order.DESCENDING).mapPartition(new OrderCheckMapper<>(new PojoChecker())).distinct().collect();
String expected = "(true)\n";
compareResultAsText(result, expected);
}
use of org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO 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);
}
use of org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO 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);
}
use of org.apache.flink.test.javaApiOperators.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);
}
Aggregations