You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/12/02 23:35:10 UTC

[GitHub] [calcite] julianhyde commented on a change in pull request #1614: [CALCITE-3546] Improve EnumerableDefaults nested loop join

julianhyde commented on a change in pull request #1614: [CALCITE-3546] Improve EnumerableDefaults nested loop join
URL: https://github.com/apache/calcite/pull/1614#discussion_r352916519
 
 

 ##########
 File path: linq4j/src/main/java/org/apache/calcite/linq4j/EnumerableDefaults.java
 ##########
 @@ -1803,7 +1803,21 @@ private boolean innerHasNext() {
       final Predicate2<TSource, TInner> predicate,
       Function2<TSource, TInner, TResult> resultSelector,
       final JoinType joinType) {
-    // Building the result as a list is easy but hogs memory. We should iterate.
+    if (!joinType.generatesNullsOnLeft()) {
+      return nestedLoopJoinOptimized(outer, inner, predicate, resultSelector, joinType);
+    }
+    return nestedLoopJoinAsList(outer, inner, predicate, resultSelector, joinType);
+  }
+
+  /**
+   * Implementation of nested loop join that builds the complete result as a list
+   * and then returns it. This is an easy-to-implement solution, but hogs memory.
+   */
+  private static <TSource, TInner, TResult> Enumerable<TResult> nestedLoopJoinAsList(
+      final Enumerable<TSource> outer, final Enumerable<TInner> inner,
+      final Predicate2<TSource, TInner> predicate,
+      Function2<TSource, TInner, TResult> resultSelector,
+      final JoinType joinType) {
 
 Review comment:
   By the way, {{class EnumerableDefaults}} exists because a java before JDK 8 did not allow default implementations of interface methods.
   
   Now that has changed we could consider removing {{EnumerableDefaults}}.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services