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 2020/12/10 13:57:26 UTC

[groovy] branch master updated: Tweak inner hash join further

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 842cfaf  Tweak inner hash join further
842cfaf is described below

commit 842cfaf0fb0a1fd23a0b1a52f815ec7b5cf41874
Author: Daniel Sun <su...@apache.org>
AuthorDate: Thu Dec 10 21:54:12 2020 +0800

    Tweak inner hash join further
---
 .../collection/runtime/QueryableCollection.java    |  2 +-
 .../runtime/QueryableCollectionTest.groovy         | 24 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

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 207db88..42e25c4 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
@@ -122,7 +122,7 @@ class QueryableCollection<T> implements Queryable<T>, Serializable {
                     .flatMap(entry -> {
                         List<U> candidateList = entry.getValue();
                         return candidateList.stream()
-                                .filter(c -> otherFields.equals(fieldsExtractor2.apply(c)))
+                                .filter(c -> Objects.equals(otherFields, fieldsExtractor2.apply(c)))
                                 .map(c -> tuple(p, c));
                     });
 
diff --git a/subprojects/groovy-ginq/src/test/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollectionTest.groovy b/subprojects/groovy-ginq/src/test/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollectionTest.groovy
index 20764e1..af89bf2 100644
--- a/subprojects/groovy-ginq/src/test/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollectionTest.groovy
+++ b/subprojects/groovy-ginq/src/test/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollectionTest.groovy
@@ -88,6 +88,30 @@ class QueryableCollectionTest {
     }
 
     @Test
+    void testInnerHashJoin3() {
+        def nums1 = [1, 2, 3]
+        def nums2 = [2, 3, 4, null]
+        def result = from(nums1).innerHashJoin(from(nums2), a -> a, b -> b).toList()
+        assert [[2, 2], [3, 3]] == result
+    }
+
+    @Test
+    void testInnerHashJoin4() {
+        def nums1 = [1, 2, 3, null]
+        def nums2 = [2, 3, 4]
+        def result = from(nums1).innerHashJoin(from(nums2), a -> a, b -> b).toList()
+        assert [[2, 2], [3, 3]] == result
+    }
+
+    @Test
+    void testInnerHashJoin5() {
+        def nums1 = [1, 2, 3, null]
+        def nums2 = [2, 3, 4, null]
+        def result = from(nums1).innerHashJoin(from(nums2), a -> a, b -> b).toList()
+        assert [[2, 2], [3, 3], [null, null]] == result
+    }
+
+    @Test
     void testLeftJoin0() {
         def nums1 = [1, 2, 3]
         def nums2 = [1, 2, 3]