You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/07/21 16:52:02 UTC

[groovy] branch master updated: Tweak hash-join of GINQ

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new ebf559c  Tweak hash-join of GINQ
ebf559c is described below

commit ebf559cd7d6dd717ac87b55da7d1ddd7d5b468f8
Author: Daniel Sun <su...@apache.org>
AuthorDate: Thu Jul 22 00:51:38 2021 +0800

    Tweak hash-join of GINQ
---
 .../provider/collection/runtime/QueryableCollection.java  | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
index cbce2d2..233d3bd 100644
--- a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
+++ b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
@@ -547,17 +547,14 @@ class QueryableCollection<T> implements Queryable<T>, Serializable {
         final Object otherFields = fieldsExtractor1.apply(p);
         final Integer h = hash(otherFields);
 
-        Stream<Map.Entry<Integer, List<Candidate<U>>>> stream = hashTable.entrySet().stream();
+        List<Candidate<U>> candidateList = hashTable.get(h);
+        if (null == candidateList) return Stream.empty();
+
+        Stream<Candidate<U>> stream = candidateList.stream();
         if (isParallel()) stream = stream.parallel();
 
-        return stream
-                .filter(entry -> h.equals(entry.getKey()))
-                .flatMap(entry -> {
-                    List<Candidate<U>> candidateList = entry.getValue();
-                    return candidateList.stream()
-                            .filter(c -> Objects.equals(otherFields, c.extracted))
-                            .map(c -> tuple(p, c.original));
-                });
+        return stream.filter(c -> Objects.equals(otherFields, c.extracted))
+                     .map(c -> tuple(p, c.original));
     }
 
     @Override