You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2026/03/30 19:19:25 UTC
(lucene) branch main updated: Simplify SearchGroup#equals and SearchGroup.MergedGroup#equals (#15888)
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new f2b01e5ff57 Simplify SearchGroup#equals and SearchGroup.MergedGroup#equals (#15888)
f2b01e5ff57 is described below
commit f2b01e5ff57368664a1e93ccb16310db4e685b38
Author: gaobinlong <gb...@amazon.com>
AuthorDate: Tue Mar 31 03:19:19 2026 +0800
Simplify SearchGroup#equals and SearchGroup.MergedGroup#equals (#15888)
* Simplify SearchGroup#equals
Signed-off-by: Binlong Gao <gb...@amazon.com>
* Simplify SearchGroup.MergedGroup#equals
Signed-off-by: Binlong Gao <gb...@amazon.com>
---------
Signed-off-by: Binlong Gao <gb...@amazon.com>
---
.../apache/lucene/search/grouping/SearchGroup.java | 24 +++-------------------
1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java b/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
index 0d2528f05fc..863924d42c2 100644
--- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
+++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
@@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
+import java.util.Objects;
import java.util.TreeSet;
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.Pruning;
@@ -62,17 +63,7 @@ public class SearchGroup<T> {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- SearchGroup<?> that = (SearchGroup<?>) o;
-
- if (groupValue == null) {
- if (that.groupValue != null) {
- return false;
- }
- } else if (!groupValue.equals(that.groupValue)) {
- return false;
- }
-
- return true;
+ return Objects.equals(groupValue, ((SearchGroup<?>) o).groupValue);
}
@Override
@@ -141,16 +132,7 @@ public class SearchGroup<T> {
// same groupValue
assert neverEquals(_other);
- if (_other instanceof MergedGroup) {
- MergedGroup<?> other = (MergedGroup<?>) _other;
- if (groupValue == null) {
- return other.groupValue == null;
- } else {
- return groupValue.equals(other.groupValue);
- }
- } else {
- return false;
- }
+ return _other instanceof MergedGroup<?> other && Objects.equals(groupValue, other.groupValue);
}
@Override