Java Code Examples for org.apache.flink.api.java.operators.UnsortedGrouping#maxBy()
The following examples show how to use
org.apache.flink.api.java.operators.UnsortedGrouping#maxBy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaxByOperatorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * This test validates that no exceptions is thrown when an empty grouping * calls maxBy(). */ @Test public void testMaxByKeyFieldsGrouping() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should work try { groupDs.maxBy(4, 0, 1, 2, 3); } catch (Exception e) { Assert.fail(); } }
Example 2
Source File: MaxByOperatorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * This test validates that an InvalidProgramException is thrown when maxBy * is used on a custom data type. */ @Test(expected = InvalidProgramException.class) public void testCustomKeyFieldsGrouping() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); this.customTypeData.add(new CustomType()); UnsortedGrouping<CustomType> groupDs = env.fromCollection(customTypeData).groupBy(0); // should not work: groups on custom type groupDs.maxBy(0); }
Example 3
Source File: MaxByOperatorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * This test validates that an index which is out of bounds throws an * IndexOutOfBoundsException. */ @Test(expected = IndexOutOfBoundsException.class) public void testOutOfTupleBoundsGrouping1() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should not work, key out of tuple bounds groupDs.maxBy(5); }
Example 4
Source File: MaxByOperatorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * This test validates that an index which is out of bounds throws an * IndexOutOfBoundsException. */ @Test(expected = IndexOutOfBoundsException.class) public void testOutOfTupleBoundsGrouping2() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should not work, key out of tuple bounds groupDs.maxBy(-1); }
Example 5
Source File: MaxByOperatorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * This test validates that an index which is out of bounds throws an * IndexOutOfBoundsException. */ @Test(expected = IndexOutOfBoundsException.class) public void testOutOfTupleBoundsGrouping3() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should not work, key out of tuple bounds groupDs.maxBy(1, 2, 3, 4, -1); }
Example 6
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that no exceptions is thrown when an empty grouping * calls maxBy(). */ @Test public void testMaxByKeyFieldsGrouping() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should work try { groupDs.maxBy(4, 0, 1, 2, 3); } catch (Exception e) { Assert.fail(); } }
Example 7
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that an InvalidProgramException is thrown when maxBy * is used on a custom data type. */ @Test(expected = InvalidProgramException.class) public void testCustomKeyFieldsGrouping() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); this.customTypeData.add(new CustomType()); UnsortedGrouping<CustomType> groupDs = env.fromCollection(customTypeData).groupBy(0); // should not work: groups on custom type groupDs.maxBy(0); }
Example 8
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that an index which is out of bounds throws an * IndexOutOfBoundsException. */ @Test(expected = IndexOutOfBoundsException.class) public void testOutOfTupleBoundsGrouping1() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should not work, key out of tuple bounds groupDs.maxBy(5); }
Example 9
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that an index which is out of bounds throws an * IndexOutOfBoundsException. */ @Test(expected = IndexOutOfBoundsException.class) public void testOutOfTupleBoundsGrouping2() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should not work, key out of tuple bounds groupDs.maxBy(-1); }
Example 10
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that an index which is out of bounds throws an * IndexOutOfBoundsException. */ @Test(expected = IndexOutOfBoundsException.class) public void testOutOfTupleBoundsGrouping3() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should not work, key out of tuple bounds groupDs.maxBy(1, 2, 3, 4, -1); }
Example 11
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that no exceptions is thrown when an empty grouping * calls maxBy(). */ @Test public void testMaxByKeyFieldsGrouping() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should work try { groupDs.maxBy(4, 0, 1, 2, 3); } catch (Exception e) { Assert.fail(); } }
Example 12
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that an InvalidProgramException is thrown when maxBy * is used on a custom data type. */ @Test(expected = InvalidProgramException.class) public void testCustomKeyFieldsGrouping() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); this.customTypeData.add(new CustomType()); UnsortedGrouping<CustomType> groupDs = env.fromCollection(customTypeData).groupBy(0); // should not work: groups on custom type groupDs.maxBy(0); }
Example 13
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that an index which is out of bounds throws an * IndexOutOfBoundsException. */ @Test(expected = IndexOutOfBoundsException.class) public void testOutOfTupleBoundsGrouping1() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should not work, key out of tuple bounds groupDs.maxBy(5); }
Example 14
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that an index which is out of bounds throws an * IndexOutOfBoundsException. */ @Test(expected = IndexOutOfBoundsException.class) public void testOutOfTupleBoundsGrouping2() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should not work, key out of tuple bounds groupDs.maxBy(-1); }
Example 15
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test validates that an index which is out of bounds throws an * IndexOutOfBoundsException. */ @Test(expected = IndexOutOfBoundsException.class) public void testOutOfTupleBoundsGrouping3() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should not work, key out of tuple bounds groupDs.maxBy(1, 2, 3, 4, -1); }
Example 16
Source File: MaxByOperatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * Validates that no ClassCastException happens * should not fail e.g. like in FLINK-8255. */ @Test(expected = InvalidProgramException.class) public void testMaxByRowTypeInfoKeyFieldsForUnsortedGrouping() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); TypeInformation[] types = new TypeInformation[]{Types.INT, Types.INT}; String[] fieldNames = new String[]{"id", "value"}; RowTypeInfo rowTypeInfo = new RowTypeInfo(types, fieldNames); UnsortedGrouping groupDs = env.fromCollection(Collections.singleton(new Row(2)), rowTypeInfo).groupBy(0); groupDs.maxBy(1); }