private static <T, B extends CopyableIterator<T>> void testReducePerformance (B iterator, TypeInformation<T> typeInfo, CombineHint hint, int numRecords, boolean print) throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.getConfig().enableObjectReuse(); @SuppressWarnings("unchecked") DataSet<T> output = env.fromParallelCollection(new SplittableRandomIterator<T, B>(numRecords, iterator), typeInfo) .groupBy("0") .reduce(new SumReducer()).setCombineHint(hint); long start = System.currentTimeMillis(); System.out.println(output.count()); long end = System.currentTimeMillis(); if (print) { System.out.println("=== Time for " + iterator.getClass().getSimpleName() + " with hint " + hint.toString() + ": " + (end - start) + "ms ==="); } }
/** * 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); }
/** * This test validates that an InvalidProgramException is thrown when minBy * 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.minBy(0); }
/** * 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); }
/** * 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.minBy(5); }
/** * 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); }
/** * 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); }
/** * 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.minBy(-1); }
/** * 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.minBy(1, 2, 3, 4, -1); }
/** * 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(); } }
/** * This test validates that no exceptions is thrown when an empty grouping * calls minBy(). */ @Test public void testMinByKeyFieldsGrouping() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0); // should work try { groupDs.minBy(4, 0, 1, 2, 3); } catch (Exception e) { Assert.fail(); } }