use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class ReduceITCase method testAllReduceForCustomTypes.
@Test
public void testAllReduceForCustomTypes() throws Exception {
/*
* All-reduce for custom types
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<CustomType> ds = CollectionDataSets.getCustomTypeDataSet(env);
DataSet<CustomType> reduceDs = ds.reduce(new AllAddingCustomTypeReduce());
List<CustomType> result = reduceDs.collect();
String expected = "91,210,Hello!";
compareResultAsText(result, expected);
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class SampleITCase method verifySamplerWithFraction.
private void verifySamplerWithFraction(boolean withReplacement, double fraction, long seed) throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
FlatMapOperator<Tuple3<Integer, Long, String>, String> ds = getSourceDataSet(env);
MapPartitionOperator<String, String> sampled = DataSetUtils.sample(ds, withReplacement, fraction, seed);
List<String> result = sampled.collect();
containsResultAsText(result, getSourceStrings());
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class SampleITCase method verifySamplerWithFixedSize.
private void verifySamplerWithFixedSize(boolean withReplacement, int numSamples, long seed) throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
FlatMapOperator<Tuple3<Integer, Long, String>, String> ds = getSourceDataSet(env);
DataSet<String> sampled = DataSetUtils.sampleWithSize(ds, withReplacement, numSamples, seed);
List<String> result = sampled.collect();
assertEquals(numSamples, result.size());
containsResultAsText(result, getSourceStrings());
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class SortPartitionITCase method testSortPartitionByFieldExpression.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSortPartitionByFieldExpression() throws Exception {
/*
* Test sort partition on field expression
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(4);
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.get3TupleDataSet(env);
List<Tuple1<Boolean>> result = ds.map(new IdMapper()).setParallelism(// parallelize input
4).sortPartition("f1", Order.DESCENDING).mapPartition(new OrderCheckMapper<>(new Tuple3Checker())).distinct().collect();
String expected = "(true)\n";
compareResultAsText(result, expected);
}
use of org.apache.flink.api.java.ExecutionEnvironment 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);
}
Aggregations