yanlin-Lynn commented on a change in pull request #1496: [CALCITE-3400] Add 
support for interpretering left/right/semi/anti/full join
URL: https://github.com/apache/calcite/pull/1496#discussion_r334738569
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/interpreter/JoinNode.java
 ##########
 @@ -47,28 +50,120 @@ public JoinNode(Compiler compiler, Join rel) {
   }
 
   public void run() throws InterruptedException {
-    List<Row> rightList = null;
-    final int leftCount = rel.getLeft().getRowType().getFieldCount();
-    final int rightCount = rel.getRight().getRowType().getFieldCount();
-    context.values = new Object[rel.getRowType().getFieldCount()];
-    Row left;
-    Row right;
-    while ((left = leftSource.receive()) != null) {
-      System.arraycopy(left.getValues(), 0, context.values, 0, leftCount);
-      if (rightList == null) {
-        rightList = new ArrayList<>();
-        while ((right = rightSource.receive()) != null) {
-          rightList.add(right);
+
+    final int fieldCount = rel.getLeft().getRowType().getFieldCount()
+        + rel.getRight().getRowType().getFieldCount();
+    context.values = new Object[fieldCount];
+
+    // source for the outer relation of nested loop
+    Source outerSource = leftSource;
+    // source for the inner relation of nested loop
+    Source innerSource = rightSource;
+    if (rel.getJoinType() == JoinRelType.RIGHT) {
+      outerSource = rightSource;
+      innerSource = leftSource;
+    }
+
+    Row baseRow = null;
+    List<Row> joinRows = null;
+    Set<Row> matchRowSet = new HashSet<>();
+    while ((baseRow = outerSource.receive()) != null) {
+      if (joinRows == null) {
+        joinRows = new ArrayList<Row>();
+        Row joinRow = null;
+        while ((joinRow = innerSource.receive()) != null) {
+          joinRows.add(joinRow);
 
 Review comment:
   Oops, I miss that.
   And the parameter of `doJoin` and `doSend` should also be updated, right?
   I'll update them together.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to