You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/06/28 11:59:52 UTC

lucene-solr:branch_6x: LUCENE-7356: SearchGroup tweaks (initialCapacity, size==0 vs. isEmpty)

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 03bbf7ce8 -> 0c43ae2b5


LUCENE-7356: SearchGroup tweaks (initialCapacity, size==0 vs. isEmpty)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/0c43ae2b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/0c43ae2b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/0c43ae2b

Branch: refs/heads/branch_6x
Commit: 0c43ae2b5c2a13e16a14897335ea6facf7a3db43
Parents: 03bbf7c
Author: Christine Poerschke <cp...@apache.org>
Authored: Tue Jun 28 11:03:03 2016 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Tue Jun 28 12:59:15 2016 +0100

----------------------------------------------------------------------
 lucene/CHANGES.txt                                           | 2 ++
 .../java/org/apache/lucene/search/grouping/SearchGroup.java  | 8 ++++----
 2 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0c43ae2b/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index e0fb45a..f6ec714 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -60,6 +60,8 @@ Optimizations
 
 * LUCENE-7330, LUCENE-7339: Speed up conjunction queries. (Adrien Grand)
 
+* LUCENE-7356: SearchGroup tweaks. (Christine Poerschke)
+
 Other
 
 * LUCENE-4787: Fixed some highlighting javadocs. (Michael Dodsworth via Adrien

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0c43ae2b/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
----------------------------------------------------------------------
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 c9d7fa0..b3a43cb 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
@@ -288,11 +288,11 @@ public class SearchGroup<GROUP_VALUE_TYPE> {
       }
 
       // Pull merged topN groups:
-      final List<SearchGroup<T>> newTopGroups = new ArrayList<>();
+      final List<SearchGroup<T>> newTopGroups = new ArrayList<>(topN);
 
       int count = 0;
 
-      while(queue.size() != 0) {
+      while(!queue.isEmpty()) {
         final MergedGroup<T> group = queue.pollFirst();
         group.processed = true;
         //System.out.println("  pop: shards=" + group.shards + " group=" + (group.groupValue == null ? "null" : (((BytesRef) group.groupValue).utf8ToString())) + " sortValues=" + Arrays.toString(group.topValues));
@@ -314,7 +314,7 @@ public class SearchGroup<GROUP_VALUE_TYPE> {
         }
       }
 
-      if (newTopGroups.size() == 0) {
+      if (newTopGroups.isEmpty()) {
         return null;
       } else {
         return newTopGroups;
@@ -333,7 +333,7 @@ public class SearchGroup<GROUP_VALUE_TYPE> {
    */
   public static <T> Collection<SearchGroup<T>> merge(List<Collection<SearchGroup<T>>> topGroups, int offset, int topN, Sort groupSort)
     throws IOException {
-    if (topGroups.size() == 0) {
+    if (topGroups.isEmpty()) {
       return null;
     } else {
       return new GroupMerger<T>(groupSort).merge(topGroups, offset, topN);