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

This commit is contained in:
Christine Poerschke 2016-06-28 11:03:03 +01:00
parent 9cbd54087c
commit e0c45f400f
2 changed files with 6 additions and 4 deletions

View File

@ -70,6 +70,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

View File

@ -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);