From 828d00a3c7671b1f2dc3101e88c2614d9e8da54a Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Sun, 18 Jul 2010 22:02:34 +0000 Subject: [PATCH] LUCENE-2549: Fix TimeLimitingCollector#TimeExceededException to record the absolute docid git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@965299 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ .../apache/lucene/search/TimeLimitingCollector.java | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) 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