Join extends CompositeOperator<Join> { public Join withJoinCondition(final BooleanExpression joinCondition) { this.setJoinCondition(joinCondition); return this; }  @Override void addImplementation(final SopremoModule module); @Override boolean equals(final Object obj); BooleanExpression getJoinCondition(); int[] getOuterJoinIndices(); EvaluationExpression getOuterJoinSources(); EvaluationExpression getResultProjection(); @Override int hashCode(); @Property @Name(preposition = "where") void setJoinCondition(final BooleanExpression joinCondition); void setOuterJoinIndices(final int... outerJoinIndices); @Property @Name(verb = "preserve") void setOuterJoinSources(final EvaluationExpression outerJoinSources); @Property @Name(preposition = "into") void setResultProjection(final EvaluationExpression resultProjection); @Override String toString(); Join withJoinCondition(final BooleanExpression joinCondition); Join withOuterJoinIndices(final int... outerJoinIndices); Join withOuterJoinSources(final EvaluationExpression outerJoinSources); Join withResultProjection(final EvaluationExpression resultProjection);  }
@Test public void shouldPerformAntiJoin() { final SopremoTestPlan sopremoPlan = new SopremoTestPlan(2, 1); final AndExpression condition = new AndExpression(new ElementInSetExpression(createPath("0", "DeptName"), Quantor.EXISTS_NOT_IN, createPath("1", "Name"))); final Join join = new Join().withJoinCondition(condition); join.setInputs(sopremoPlan.getInputOperators(0, 2)); sopremoPlan.getOutputOperator(0).setInputs(join); sopremoPlan.getInput(0).addObject("Name", "Harry", "EmpId", 3415, "DeptName", "Finance").addObject("Name", "Sally", "EmpId", 2241, "DeptName", "Sales") .addObject("Name", "George", "EmpId", 3401, "DeptName", "Finance").addObject("Name", "Harriet", "EmpId", 2202, "DeptName", "Production"); sopremoPlan.getInput(1).addObject("Name", "Sales", "Manager", "Harriet").addObject("Name", "Production", "Manager", "Charles"); sopremoPlan.getExpectedOutput(0).addArray( JsonUtil.createObjectNode("Name", "Harry", "EmpId", 3415, "DeptName", "Finance")) .addArray(JsonUtil.createObjectNode("Name", "George", "EmpId", 3401, "DeptName", "Finance")); sopremoPlan.run(); }
@Test public void shouldPerformEquiJoin() { final SopremoTestPlan sopremoPlan = new SopremoTestPlan(2, 1); final AndExpression condition = new AndExpression(new ComparativeExpression(createPath("0", "id"), BinaryOperator.EQUAL, createPath("1", "userid"))); final Join join = new Join().withJoinCondition(condition); join.setInputs(sopremoPlan.getInputOperators(0, 2)); sopremoPlan.getOutputOperator(0).setInputs(join); sopremoPlan.getInput(0). addObject("name", "Jon Doe", "password", "asdf1234", "id", 1). addObject("name", "Jane Doe", "password", "qwertyui", "id", 2). addObject("name", "Max Mustermann", "password", "q1w2e3r4", "id", 3); sopremoPlan.getInput(1).addObject("userid", 1, "url", "code.google.com/p/jaql/").addObject("userid", 2, "url", "www.cnn.com") .addObject("userid", 1, "url", "java.sun.com/javase/6/docs/api/"); sopremoPlan .getExpectedOutput(0) .addArray(JsonUtil.createObjectNode("name", "Jon Doe", "password", "asdf1234", "id", 1), JsonUtil.createObjectNode("userid", 1, "url", "code.google.com/p/jaql/")) .addArray(JsonUtil.createObjectNode("name", "Jon Doe", "password", "asdf1234", "id", 1), JsonUtil.createObjectNode("userid", 1, "url", "java.sun.com/javase/6/docs/api/")) .addArray(JsonUtil.createObjectNode("name", "Jane Doe", "password", "qwertyui", "id", 2), JsonUtil.createObjectNode("userid", 2, "url", "www.cnn.com")); sopremoPlan.run(); }
@Test public void shouldPerformSemiJoin() { final SopremoTestPlan sopremoPlan = new SopremoTestPlan(2, 1); final AndExpression condition = new AndExpression(new ElementInSetExpression(createPath("0", "DeptName"), Quantor.EXISTS_IN, createPath( "1", "Name"))); final Join join = new Join().withJoinCondition(condition); join.setInputs(sopremoPlan.getInputOperators(0, 2)); sopremoPlan.getOutputOperator(0).setInputs(join); sopremoPlan.getInput(0).addObject("Name", "Harry", "EmpId", 3415, "DeptName", "Finance").addObject("Name", "Sally", "EmpId", 2241, "DeptName", "Sales") .addObject("Name", "George", "EmpId", 3401, "DeptName", "Finance").addObject("Name", "Harriet", "EmpId", 2202, "DeptName", "Production"); sopremoPlan.getInput(1).addObject("Name", "Sales", "Manager", "Harriet").addObject("Name", "Production", "Manager", "Charles"); sopremoPlan.getExpectedOutput(0).addArray( JsonUtil.createObjectNode("Name", "Sally", "EmpId", 2241, "DeptName", "Sales")) .addArray(JsonUtil.createObjectNode("Name", "Harriet", "EmpId", 2202, "DeptName", "Production")); sopremoPlan.run(); }
@Test public void shouldPerformThetaJoin() { final SopremoTestPlan sopremoPlan = new SopremoTestPlan(2, 1); final AndExpression condition = new AndExpression(new ComparativeExpression(createPath("0", "id"), BinaryOperator.LESS, createPath("1", "userid"))); final Join join = new Join().withJoinCondition(condition); join.setInputs(sopremoPlan.getInputOperators(0, 2)); sopremoPlan.getOutputOperator(0).setInputs(join); sopremoPlan.getInput(0).addObject("name", "Jon Doe", "password", "asdf1234", "id", 1).addObject("name", "Jane Doe", "password", "qwertyui", "id", 2) .addObject("name", "Max Mustermann", "password", "q1w2e3r4", "id", 3); sopremoPlan.getInput(1).addObject("userid", 1, "url", "code.google.com/p/jaql/").addObject("userid", 2, "url", "www.cnn.com") .addObject("userid", 4, "url", "www.nbc.com").addObject("userid", 1, "url", "java.sun.com/javase/6/docs/api/"); sopremoPlan .getExpectedOutput(0) .addArray(JsonUtil.createObjectNode("name", "Jon Doe", "password", "asdf1234", "id", 1), JsonUtil.createObjectNode("userid", 2, "url", "www.cnn.com")) .addArray(JsonUtil.createObjectNode("name", "Jon Doe", "password", "asdf1234", "id", 1), JsonUtil.createObjectNode("userid", 4, "url", "www.nbc.com")) .addArray(JsonUtil.createObjectNode("name", "Jane Doe", "password", "qwertyui", "id", 2), JsonUtil.createObjectNode("userid", 4, "url", "www.nbc.com")) .addArray(JsonUtil.createObjectNode("name", "Max Mustermann", "password", "q1w2e3r4", "id", 3), JsonUtil.createObjectNode("userid", 4, "url", "www.nbc.com")); sopremoPlan.run(); }