@Test(expected = CompositeType.InvalidFieldReferenceException.class) public void testFailPojoInvalidField() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<CustomType> pojoDs = env .fromCollection(pojoData); // must not work pojoDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("myInt", Order.ASCENDING) .sortLocalOutput("notThere", Order.DESCENDING); }
@Test(expected = CompositeType.InvalidFieldReferenceException.class) public void testFailTupleInv() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env .fromCollection(emptyTupleData, tupleTypeInfo); // must not work tupleDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("notThere", Order.ASCENDING) .sortLocalOutput("f4", Order.DESCENDING); }
@Test(expected = IndexOutOfBoundsException.class) public void testFailTupleIndexOutOfBounds() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env .fromCollection(emptyTupleData, tupleTypeInfo); // must not work tupleDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput(3, Order.ASCENDING) .sortLocalOutput(5, Order.DESCENDING); }
@Test(expected = InvalidProgramException.class) public void testArrayOrderFull() { List<Object[]> arrayData = new ArrayList<>(); arrayData.add(new Object[0]); final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Object[]> pojoDs = env .fromCollection(arrayData); // must not work pojoDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("*", Order.ASCENDING); }
@Test public void testTupleTwoOrderExp() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env .fromCollection(emptyTupleData, tupleTypeInfo); // should work try { tupleDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("f1", Order.ASCENDING) .sortLocalOutput("f4", Order.DESCENDING); } catch (Exception e) { Assert.fail(); } }
@Test public void testTupleTwoOrderIdx() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env .fromCollection(emptyTupleData, tupleTypeInfo); // should work try { tupleDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput(0, Order.ASCENDING) .sortLocalOutput(3, Order.DESCENDING); } catch (Exception e) { Assert.fail(); } }
@Test public void testPojoTwoOrder() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<CustomType> pojoDs = env .fromCollection(pojoData); // should work try { pojoDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("myLong", Order.ASCENDING) .sortLocalOutput("myString", Order.DESCENDING); } catch (Exception e) { Assert.fail(); } }
public void testTupleSingleOrderExpFull() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env .fromCollection(emptyTupleData, tupleTypeInfo); // should not work tupleDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("*", Order.ANY); }
@Test public void testTupleTwoOrderMixed() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env .fromCollection(emptyTupleData, tupleTypeInfo); // should work try { tupleDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput(4, Order.ASCENDING) .sortLocalOutput("f2", Order.DESCENDING); } catch (Exception e) { Assert.fail(); } }
@Test(expected = InvalidProgramException.class) public void testFailPojoIdx() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<CustomType> pojoDs = env .fromCollection(pojoData); // must not work pojoDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput(1, Order.DESCENDING); }
@Test(expected = InvalidProgramException.class) public void testPojoSingleOrderFull() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<CustomType> pojoDs = env .fromCollection(pojoData); // must not work pojoDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("*", Order.ASCENDING); }
@Test(expected = InvalidProgramException.class) public void testFailPrimitiveOrder2() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Long> longDs = env .generateSequence(0, 2); // must not work longDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("0", Order.ASCENDING); }
@Test(expected = InvalidProgramException.class) public void testFailPrimitiveOrder3() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Long> longDs = env .generateSequence(0, 2); // must not work longDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("nope", Order.ASCENDING); }
@Test(expected = InvalidProgramException.class) public void testFailPrimitiveOrder1() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Long> longDs = env .generateSequence(0, 2); // must not work longDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput(0, Order.ASCENDING); }
@Test public void testTupleSingleOrderIdx() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env .fromCollection(emptyTupleData, tupleTypeInfo); // should work try { tupleDs.writeAsText("/tmp/willNotHappen").sortLocalOutput(0, Order.ANY); } catch (Exception e) { Assert.fail(); } }
@Test public void testPrimitiveOrder() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Long> longDs = env .generateSequence(0, 2); // should work try { longDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("*", Order.ASCENDING); } catch (Exception e) { Assert.fail(); } }
@Test public void testPojoSingleOrder() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<CustomType> pojoDs = env .fromCollection(pojoData); // should work try { pojoDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("myString", Order.ASCENDING); } catch (Exception e) { Assert.fail(); } }
@Test public void testTupleSingleOrderExp() { final ExecutionEnvironment env = ExecutionEnvironment .getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env .fromCollection(emptyTupleData, tupleTypeInfo); // should work try { tupleDs.writeAsText("/tmp/willNotHappen") .sortLocalOutput("f0", Order.ANY); } catch (Exception e) { Assert.fail(); } }
@Test public void testIntSortingParallelism1() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Integer> ds = CollectionDataSets.getIntegerDataSet(env); ds.writeAsText(resultPath).sortLocalOutput("*", Order.DESCENDING).setParallelism(1); env.execute(); String expected = "5\n5\n5\n5\n5\n4\n4\n4\n4\n3\n3\n3\n2\n2\n1\n"; compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath); }
@Test public void testPojoSortingSingleParallelism1() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env); ds.writeAsText(resultPath).sortLocalOutput("number", Order.ASCENDING).setParallelism(1); env.execute(); String expected = "1 First (10,100,1000,One) 10100\n" + "2 First_ (10,105,1000,One) 10200\n" + "3 First (11,102,3000,One) 10200\n" + "4 First_ (11,106,1000,One) 10300\n" + "5 First (11,102,2000,One) 10100\n" + "6 Second_ (20,200,2000,Two) 10100\n" + "7 Third (31,301,2000,Three) 10200\n" + "8 Third_ (30,300,1000,Three) 10100\n"; compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath); }