@Test(expected = InvalidProgramException.class) public void testCoGroupKeyAtomicInvalidExpression6() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Integer> ds1 = env.fromElements(0, 0, 0); DataSet<ArrayList<Integer>> ds2 = env.fromElements(new ArrayList<Integer>()); ds1.coGroup(ds2).where("*").equalTo("*"); }
@Test(expected = InvalidProgramException.class) public void testCoGroupKeyExpressions3Nested() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<CustomType> ds1 = env.fromCollection(customTypeData); DataSet<CustomType> ds2 = env.fromCollection(customTypeData); // should not work, incompatible number of cogroup keys ds1.coGroup(ds2).where("nested.myInt", "nested.myString").equalTo("nested.myString"); }
@Test(expected = IllegalArgumentException.class) public void testCoGroupKeyExpressions4() { 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("myNonExistent").equalTo("myInt"); }
@Test(expected = InvalidProgramException.class) public void testCoGroupKeyExpressions2() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<CustomType> ds1 = env.fromCollection(customTypeData); DataSet<CustomType> ds2 = env.fromCollection(customTypeData); // should not work, incompatible cogroup key types ds1.coGroup(ds2).where("myInt").equalTo("myString"); }
@Test public void testCoGroupWithAtomicType2() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Integer> ds1 = env.fromElements(0, 1, 2); DataSet<Tuple3<Integer, Long, String>> ds2 = CollectionDataSets.getSmall3TupleDataSet(env); DataSet<Tuple3<Integer, Long, String>> coGroupDs = ds1.coGroup(ds2).where("*").equalTo(0).with(new CoGroupAtomic2()); List<Tuple3<Integer, Long, String>> result = coGroupDs.collect(); String expected = "(1,1,Hi)\n" + "(2,2,Hello)"; compareResultAsText(result, expected); }
@Test(expected = InvalidProgramException.class) public void testCoGroupKeyExpressions2Nested() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<CustomType> ds1 = env.fromCollection(customTypeData); DataSet<CustomType> ds2 = env.fromCollection(customTypeData); // should not work, incompatible cogroup key types ds1.coGroup(ds2).where("nested.myInt").equalTo("nested.myString"); }
@Test public void testCoGroupKeyAtomicExpression1() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<CustomType> ds1 = env.fromCollection(customTypeData); DataSet<Integer> ds2 = env.fromElements(0, 0, 1); ds1.coGroup(ds2).where("myInt").equalTo("*"); }
@Test(expected = InvalidProgramException.class) public void testCoGroupKeyExpressions3() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<CustomType> ds1 = env.fromCollection(customTypeData); DataSet<CustomType> ds2 = env.fromCollection(customTypeData); // should not work, incompatible number of cogroup keys ds1.coGroup(ds2).where("myInt", "myString").equalTo("myString"); }
@Test(expected = IndexOutOfBoundsException.class) public void testCoGroupKeyFields5() { 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, negative key field position ds1.coGroup(ds2).where(-1).equalTo(-1); }
@Test(expected = InvalidProgramException.class) public void testCoGroupKeyFields3() { 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, incompatible number of cogroup keys ds1.coGroup(ds2).where(0, 1).equalTo(2); }
@Test(expected = InvalidProgramException.class) public void testCoGroupKeyFields2() { 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, incompatible cogroup key types ds1.coGroup(ds2).where(0).equalTo(2); }
@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"); }
@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); }
@Test public void testCoGroupKeyFields1() { 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 work try { ds1.coGroup(ds2).where(0).equalTo(0); } catch (Exception e) { Assert.fail(); } }
@Test public void testCoGroupKeyExpressions1() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<CustomType> ds1 = env.fromCollection(customTypeData); DataSet<CustomType> ds2 = env.fromCollection(customTypeData); // should work try { ds1.coGroup(ds2).where("myInt").equalTo("myInt"); } catch (Exception e) { Assert.fail(); } }
@Test(expected = InvalidProgramException.class) public void testCoGroupKeyFields6() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo); DataSet<CustomType> ds2 = env.fromCollection(customTypeData); // should not work, cogroup key fields on custom type ds1.coGroup(ds2).where(4).equalTo(0); }
@Test public void testCoGroupWithAtomicType1() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env); DataSet<Integer> ds2 = env.fromElements(0, 1, 2); DataSet<Tuple3<Integer, Long, String>> coGroupDs = ds1.coGroup(ds2).where(0).equalTo("*").with(new CoGroupAtomic1()); List<Tuple3<Integer, Long, String>> result = coGroupDs.collect(); String expected = "(1,1,Hi)\n" + "(2,2,Hello)"; compareResultAsText(result, expected); }
@Test(expected = InvalidProgramException.class) public void testCoGroupKeyAtomicInvalidExpression3() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<CustomType> ds1 = env.fromCollection(customTypeData); DataSet<Integer> ds2 = env.fromElements(0, 0, 1); ds1.coGroup(ds2).where("myInt").equalTo("invalidKey"); }
@Test public void testCoGroupKeyAtomicExpression2() { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Integer> ds1 = env.fromElements(0, 0, 1); DataSet<CustomType> ds2 = env.fromCollection(customTypeData); ds1.coGroup(ds2).where("*").equalTo("myInt"); }
/** * Return the out-degree of all vertices in the graph. * * @return A DataSet of {@code Tuple2<vertexId, outDegree>} */ public DataSet<Tuple2<K, LongValue>> outDegrees() { return vertices.coGroup(edges).where(0).equalTo(0).with(new CountNeighborsCoGroup<>()) .name("Out-degree"); }