use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class SortPartitionITCase method testSortPartitionByTwoFieldExpressions.
@Test
public void testSortPartitionByTwoFieldExpressions() throws Exception {
/*
* Test sort partition on two field expressions
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(2);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds = CollectionDataSets.get5TupleDataSet(env);
List<Tuple1<Boolean>> result = ds.map(new IdMapper<Tuple5<Integer, Long, Integer, String, Long>>()).setParallelism(// parallelize input
2).sortPartition("f4", Order.ASCENDING).sortPartition("f2", Order.DESCENDING).mapPartition(new OrderCheckMapper<>(new Tuple5Checker())).distinct().collect();
String expected = "(true)\n";
compareResultAsText(result, expected);
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class SumMinMaxITCase method testGroupedAggregate.
@Test
public void testGroupedAggregate() throws Exception {
/*
* Grouped Aggregate
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.get3TupleDataSet(env);
DataSet<Tuple2<Long, Integer>> aggregateDs = ds.groupBy(1).sum(0).project(1, 0);
List<Tuple2<Long, Integer>> result = aggregateDs.collect();
String expected = "1,1\n" + "2,5\n" + "3,15\n" + "4,34\n" + "5,65\n" + "6,111\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class SumMinMaxITCase method testSumMaxAndProject.
@Test
public void testSumMaxAndProject() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.get3TupleDataSet(env);
DataSet<Tuple2<Integer, Long>> sumDs = ds.sum(0).andMax(1).project(0, 1);
List<Tuple2<Integer, Long>> result = sumDs.collect();
String expected = "231,6\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class SumMinMaxITCase method testNestedAggregate.
@Test
public void testNestedAggregate() throws Exception {
/*
* Nested Aggregate
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.get3TupleDataSet(env);
DataSet<Tuple1<Integer>> aggregateDs = ds.groupBy(1).min(0).min(0).project(0);
List<Tuple1<Integer>> result = aggregateDs.collect();
String expected = "1\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class FromElementsTest method fromElementsWithBaseTypeTest2.
@Test(expected = IllegalArgumentException.class)
public void fromElementsWithBaseTypeTest2() {
ExecutionEnvironment executionEnvironment = ExecutionEnvironment.getExecutionEnvironment();
executionEnvironment.fromElements(SubType.class, new SubType(1, "Java"), new ParentType(1, "hello"));
}
Aggregations