.joinWithTiny(nations) .where(3).equalTo(0) .projectFirst(0, 1, 2).projectSecond(1).projectFirst(4);
private void createJoinOperation(DatasizeHint mode, INFO info) { DataSet op1 = (DataSet) sets.get(info.parentID); DataSet op2 = (DataSet) sets.get(info.otherID); if (info.types != null && (info.projections == null || info.projections.length == 0)) { sets.put(info.setID, applyJoinOperation(op1, op2, info.keys1, info.keys2, mode, info)); } else { DefaultJoin defaultResult = createDefaultJoin(op1, op2, info.keys1, info.keys2, mode); if (info.projections.length == 0) { sets.put(info.setID, defaultResult.name("DefaultJoin")); } else { ProjectJoin project = null; for (ProjectionEntry pe : info.projections) { switch (pe.side) { case FIRST: project = project == null ? defaultResult.projectFirst(pe.keys) : project.projectFirst(pe.keys); break; case SECOND: project = project == null ? defaultResult.projectSecond(pe.keys) : project.projectSecond(pe.keys); break; } } sets.put(info.setID, project.name("ProjectJoin")); } } }
.joinWithTiny(nations) .where(3).equalTo(0) .projectFirst(0, 1, 2).projectSecond(1).projectFirst(4);
.joinWithTiny(nations) .where(3).equalTo(0) .projectFirst(0, 1, 2).projectSecond(1).projectFirst(4);
.joinWithTiny(nations) .where(3).equalTo(0) .projectFirst(0,1,2).projectSecond(1).projectFirst(4);
.projectSecond(1).<Tuple2<Long, Long>>projectFirst(1).name("Join Candidate Id With Neighbor")
.projectFirst(2) .projectSecond(0, 0, 3) .projectFirst(0, 4) .projectSecond(2);
@Test public void testProjectJoinOnATuple2Input() throws Exception { /* * Project join on a tuple input 2 */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env); DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.get5TupleDataSet(env); DataSet<Tuple6<String, String, Long, Long, Long, Integer>> joinDs = ds1.join(ds2) .where(1) .equalTo(1) .projectSecond(3) .projectFirst(2, 1) .projectSecond(4, 1) .projectFirst(0); List<Tuple6<String, String, Long, Long, Long, Integer>> result = joinDs.collect(); String expected = "Hallo,Hi,1,1,1,1\n" + "Hallo Welt,Hello,2,2,2,2\n" + "Hallo Welt,Hello world,2,2,2,3\n"; compareResultAsTuples(result, expected); }
@Test public void testProjectOnATuple1Input() throws Exception { /* * Project join on a tuple input 1 */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env); DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.get5TupleDataSet(env); DataSet<Tuple6<String, Long, String, Integer, Long, Long>> joinDs = ds1.join(ds2) .where(1) .equalTo(1) .projectFirst(2, 1) .projectSecond(3) .projectFirst(0) .projectSecond(4, 1); List<Tuple6<String, Long, String, Integer, Long, Long>> result = joinDs.collect(); String expected = "Hi,1,Hallo,1,1,1\n" + "Hello,2,Hallo Welt,2,2,2\n" + "Hello world,2,Hallo Welt,3,2,2\n"; compareResultAsTuples(result, expected); }
@Test public void testJoinProjection5() { 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.join(ds2).where(0).equalTo(0) .projectSecond(0, 2) .projectFirst(1, 4) .projectFirst(1); } catch (Exception e) { Assert.fail(); } }
@Test public void testJoinProjection4() { 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.join(ds2).where(0).equalTo(0) .projectFirst(0, 2) .projectSecond(1, 4) .projectFirst(1); } catch (Exception e) { Assert.fail(); } }
@Test public void testJoinProjection27() { 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.join(ds2).where(0).equalTo(0) .projectSecond() .projectFirst(1, 4); } catch (Exception e) { Assert.fail(); } }
@Test public void testJoinProjection7() { 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.join(ds2).where(0).equalTo(0) .projectSecond() .projectFirst(1, 4); } catch (Exception e) { Assert.fail(); } }
@Test(expected = IndexOutOfBoundsException.class) public void testJoinProjection13() { 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, index out of range ds1.join(ds2).where(0).equalTo(0) .projectSecond(0) .projectFirst(5); }
@Test(expected = IndexOutOfBoundsException.class) public void testJoinProjection33() { 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, index out of range ds1.join(ds2).where(0).equalTo(0) .projectSecond(-1) .projectFirst(3); }
public void testJoinProjection12() { 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 ds1.join(ds2).where(0).equalTo(0) .projectSecond(2) .projectFirst(1); }