rubenada commented on a change in pull request #1101: [CALCITE-2909] Optimize
Enumerable SemiJoin with lazy computation of innerLookup (Ruben Quesada Lopez)
URL: https://github.com/apache/calcite/pull/1101#discussion_r268195878
##########
File path:
linq4j/src/main/java/org/apache/calcite/linq4j/EnumerableDefaults.java
##########
@@ -1298,11 +1298,11 @@ private void closeInner() {
final EqualityComparer<TKey> comparer) {
return new AbstractEnumerable<TSource>() {
public Enumerator<TSource> enumerator() {
- final Enumerable<TKey> innerLookup =
- comparer == null
- ? inner.select(innerKeySelector).distinct()
- : inner.select(innerKeySelector).distinct(comparer);
-
+ // CALCITE-2909 Delay the computation of the innerLookup until the
moment when we are sure
+ // that it will be really needed, i.e. when the first outer enumerator
item is processed
+ final Enumerable<TKey> innerLookup = comparer == null
+ ? Linq4j.lazyEnumerable(() ->
inner.select(innerKeySelector).distinct())
+ : Linq4j.lazyEnumerable(() ->
inner.select(innerKeySelector).distinct(comparer));
Review comment:
No problem @asereda-gs , yours was an interesting approach too
----------------------------------------------------------------
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