use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class FromElementsTest method fromElementsWithBaseTypeTest1.
@Test
public void fromElementsWithBaseTypeTest1() {
ExecutionEnvironment executionEnvironment = ExecutionEnvironment.getExecutionEnvironment();
executionEnvironment.fromElements(ParentType.class, new SubType(1, "Java"), new ParentType(1, "hello"));
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class AggregateOperatorTest method testFieldsAggregate.
@Test
public void testFieldsAggregate() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should work
try {
tupleDs.aggregate(Aggregations.SUM, 1);
} catch (Exception e) {
Assert.fail();
}
// should not work: index out of bounds
try {
tupleDs.aggregate(Aggregations.SUM, 10);
Assert.fail();
} catch (IllegalArgumentException iae) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
// should not work: not applied to tuple dataset
DataSet<Long> longDs = env.fromCollection(emptyLongData, BasicTypeInfo.LONG_TYPE_INFO);
try {
longDs.aggregate(Aggregations.MIN, 1);
Assert.fail();
} catch (InvalidProgramException uoe) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class AggregateOperatorTest method testAggregationTypes.
@Test
public void testAggregationTypes() {
try {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should work: multiple aggregates
tupleDs.aggregate(Aggregations.SUM, 0).and(Aggregations.MIN, 4);
// should work: nested aggregates
tupleDs.aggregate(Aggregations.MIN, 2).aggregate(Aggregations.SUM, 1);
// should not work: average on string
try {
tupleDs.aggregate(Aggregations.SUM, 2);
Assert.fail();
} catch (UnsupportedAggregationTypeException iae) {
// we're good here
}
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class CoGroupOperatorTest method testCoGroupKeyFields4.
@Test(expected = IndexOutOfBoundsException.class)
public void testCoGroupKeyFields4() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo);
DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds2 = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should not work, cogroup key out of range
ds1.coGroup(ds2).where(5).equalTo(0);
}
use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.
the class CoGroupOperatorTest method testCoGroupKeyExpressions4Nested.
@Test(expected = IllegalArgumentException.class)
public void testCoGroupKeyExpressions4Nested() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
// should not work, cogroup key non-existent
ds1.coGroup(ds2).where("nested.myNonExistent").equalTo("nested.myInt");
}
Aggregations