Open asfimport opened 8 years ago
Christine Poerschke (@cpoerschke) (migrated from JIRA)
proposed EarlyTerminatingSortingCollector constructor change:
+ final private boolean aaa; // as yet unnamed flag
+ `@Deprecated`
public EarlyTerminatingSortingCollector(Collector in, Sort sort, int numDocsToCollect) {
- ...
+ this(in, sort, numDocsToCollect, false);
+ }
+ public EarlyTerminatingSortingCollector(Collector in, Sort sort, int numDocsToCollect, boolean aaa) {
+ ...
this.aaa = aaa;
}
proposed EarlyTerminatingSortingCollector method change:
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
...
if (...) {
// segment is sorted, can early-terminate
return new FilterLeafCollector(super.getLeafCollector(context)) {
private int numCollected;
`@Override`
public void collect(int doc) throws IOException {
super.collect(doc);
- if (++numCollected >= numDocsToCollect) {
+ if (aaa) {
+ final Boolean zzz = gotAndKeptAtLeast(numDocsToCollect);
+ if (Boolean.TRUE.equals(zzz) {
+ terminatedEarly.set(true);
+ throw new CollectionTerminatedException();+
+ }
+ } else if (++numCollected >= numDocsToCollect) {
terminatedEarly.set(true);
throw new CollectionTerminatedException();
}
}
};
} else {
return super.getLeafCollector(context);
}
}
proposed LeafCollector interface extension:
public interface LeafCollector {
...
// Return null to indicate "don't know".
Boolean gotAndKeptAtLeast(int numDocs);
...
}
outline AbstractFirstPassGroupingCollector change:
public abstract class AbstractFirstPassGroupingCollector ... {
...
Boolean gotAndKeptAtLeast(int numDocs) {
return (groupMap == null ? null : (groupMap.size() >= numDocs));
}
...
}
outline AbstractSecondPassGroupingCollector change:
public abstract class AbstractSecondPassGroupingCollector ... {
...
Boolean gotAndKeptAtLeast(int numDocs) {
Boolean gak = null;
for (SearchGroupDocs<GROUP_VALUE_TYPE> groupDocs : groupMap.values()) {
gak = groupDocs.leafCollector.gotAndKeptAtLeast(maxDocsPerGroup);
if (!Boolean.TRUE.equals(gak)) {
return gak;
}
}
return gak;
}
...
}
I think something like this should work, what do you think?
Michael McCandless (@mikemccand) (migrated from JIRA)
It's a little spooky we need to make so many API changes to so many collectors ... can we maybe instead just have a custom collector that knows how to early terminate specifically for grouping collectors?
Currently grouped searches must not use the early terminating sorting collector because the wrong results would be returned. This ticket proposes to change the
EarlyTerminatingSortingCollector
class and probably theLeafCollector
interface to support early termination for grouped searches.Illustration (aaa is an as yet unnamed boolean flag):
Migrated from LUCENE-7341 by Christine Poerschke (@cpoerschke), 1 vote, updated Jun 17 2016