Skip to content

Apache Lucene open-source search software

LUCENE-2549: Fix TimeLimitingCollector#TimeExceededException to record the absolute docid

Uwe Schindler828d00a3c767
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 407aee33b82..8f2b7308743 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -437,6 +437,9 @@ Bug fixes
and float were not affected.
(Yonik Seeley, Uwe Schindler)
+* LUCENE-2549: Fix TimeLimitingCollector#TimeExceededException to record
+ the absolute docid. (Uwe Schindler)
+
New features
* LUCENE-2128: Parallelized fetching document frequencies during weight
diff --git a/lucene/src/java/org/apache/lucene/search/TimeLimitingCollector.java b/lucene/src/java/org/apache/lucene/search/TimeLimitingCollector.java
index 8a94ac38151..405f1a09901 100644
--- a/lucene/src/java/org/apache/lucene/search/TimeLimitingCollector.java
+++ b/lucene/src/java/org/apache/lucene/search/TimeLimitingCollector.java
@@ -111,7 +111,7 @@ public class TimeLimitingCollector extends Collector {
public long getTimeElapsed() {
return timeElapsed;
}
- /** Returns last doc that was collected when the search time exceeded. */
+ /** Returns last doc (absolute doc id) that was collected when the search time exceeded. */
public int getLastDocCollected() {
return lastDocCollected;
}
@@ -129,6 +129,8 @@ public class TimeLimitingCollector extends Collector {
private final long t0;
private final long timeout;
private final Collector collector;
+
+ private int docBase;
/**
* Create a TimeLimitedCollector wrapper over another {@link Collector} with a specified timeout.
@@ -200,19 +202,20 @@ public class TimeLimitingCollector extends Collector {
long time = TIMER_THREAD.getMilliseconds();
if (timeout < time) {
if (greedy) {
- //System.out.println(this+" greedy: before failing, collecting doc: "+doc+" "+(time-t0));
+ //System.out.println(this+" greedy: before failing, collecting doc: "+(docBase + doc)+" "+(time-t0));
collector.collect(doc);
}
- //System.out.println(this+" failing on: "+doc+" "+(time-t0));
- throw new TimeExceededException( timeout-t0, time-t0, doc );
+ //System.out.println(this+" failing on: "+(docBase + doc)+" "+(time-t0));
+ throw new TimeExceededException( timeout-t0, time-t0, docBase + doc );
}
- //System.out.println(this+" collecting: "+doc+" "+(time-t0));
+ //System.out.println(this+" collecting: "+(docBase + doc)+" "+(time-t0));
collector.collect(doc);
}
@Override
public void setNextReader(IndexReader reader, int base) throws IOException {
collector.setNextReader(reader, base);
+ this.docBase = base;
}
@Override