mirror of https://github.com/apache/lucene.git
SOLR-2564: add pollLast to deal with performance regression due to Java5/Java6 difference between modules and Solr
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1138735 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0333b8caf0
commit
a7a7108ec8
|
@ -43,7 +43,8 @@ abstract public class AbstractFirstPassGroupingCollector<GROUP_VALUE_TYPE> exten
|
|||
private final int compIDXEnd;
|
||||
|
||||
// Set once we reach topNGroups unique groups:
|
||||
private TreeSet<CollectedSearchGroup<GROUP_VALUE_TYPE>> orderedGroups;
|
||||
/** @lucene.internal */
|
||||
protected TreeSet<CollectedSearchGroup<GROUP_VALUE_TYPE>> orderedGroups;
|
||||
private int docBase;
|
||||
private int spareSlot;
|
||||
|
||||
|
@ -214,8 +215,7 @@ abstract public class AbstractFirstPassGroupingCollector<GROUP_VALUE_TYPE> exten
|
|||
// the bottom group with this new group.
|
||||
|
||||
// java 6-only: final CollectedSearchGroup bottomGroup = orderedGroups.pollLast();
|
||||
final CollectedSearchGroup<GROUP_VALUE_TYPE> bottomGroup = orderedGroups.last();
|
||||
orderedGroups.remove(bottomGroup);
|
||||
final CollectedSearchGroup<GROUP_VALUE_TYPE> bottomGroup = pollLast();
|
||||
assert orderedGroups.size() == topNGroups -1;
|
||||
|
||||
groupMap.remove(bottomGroup.groupValue);
|
||||
|
@ -350,9 +350,14 @@ abstract public class AbstractFirstPassGroupingCollector<GROUP_VALUE_TYPE> exten
|
|||
* @return a copy of the specified group value
|
||||
*/
|
||||
protected abstract GROUP_VALUE_TYPE copyDocGroupValue(GROUP_VALUE_TYPE groupValue, GROUP_VALUE_TYPE reuse);
|
||||
|
||||
|
||||
|
||||
protected CollectedSearchGroup<GROUP_VALUE_TYPE> pollLast() {
|
||||
// java 6-only: final CollectedSearchGroup bottomGroup = orderedGroups.pollLast();
|
||||
final CollectedSearchGroup<GROUP_VALUE_TYPE> bottomGroup = orderedGroups.last();
|
||||
orderedGroups.remove(bottomGroup);
|
||||
return bottomGroup;
|
||||
}
|
||||
}
|
||||
|
||||
class CollectedSearchGroup<T> extends SearchGroup<T> {
|
||||
int topDoc;
|
||||
int comparatorSlot;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.lucene.search.grouping;
|
||||
|
||||
/** @lucene.internal */
|
||||
public class CollectedSearchGroup<T> extends SearchGroup<T> {
|
||||
int topDoc;
|
||||
int comparatorSlot;
|
||||
}
|
|
@ -628,7 +628,7 @@ public class Grouping {
|
|||
}
|
||||
|
||||
sort = sort == null ? Sort.RELEVANCE : sort;
|
||||
firstPass = new TermFirstPassGroupingCollector(groupBy, sort, actualGroupsToFind);
|
||||
firstPass = new TermFirstPassGroupingCollectorJava6(groupBy, sort, actualGroupsToFind);
|
||||
return firstPass;
|
||||
}
|
||||
|
||||
|
@ -996,6 +996,22 @@ public class Grouping {
|
|||
filler = docValues.getValueFiller();
|
||||
mval = filler.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CollectedSearchGroup<MutableValue> pollLast() {
|
||||
return orderedGroups.pollLast();
|
||||
}
|
||||
}
|
||||
|
||||
static class TermFirstPassGroupingCollectorJava6 extends TermFirstPassGroupingCollector {
|
||||
public TermFirstPassGroupingCollectorJava6(String groupField, Sort groupSort, int topNGroups) throws IOException {
|
||||
super(groupField, groupSort, topNGroups);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CollectedSearchGroup<BytesRef> pollLast() {
|
||||
return orderedGroups.pollLast();
|
||||
}
|
||||
}
|
||||
|
||||
static class FunctionSecondPassGroupingCollector extends AbstractSecondPassGroupingCollector<MutableValue> {
|
||||
|
|
Loading…
Reference in New Issue