public class TimeLimitingCollector extends Collector
TimeLimitingCollector is used to timeout search requests that
take longer than the maximum allowed search time limit. After this time is
exceeded, the search thread is stopped by throwing a
TimeLimitingCollector.TimeExceededException.| Modifier and Type | Class and Description |
|---|---|
static class |
TimeLimitingCollector.TimeExceededException
Thrown when elapsed search time exceeds allowed search time.
|
| Modifier and Type | Field and Description |
|---|---|
boolean |
DEFAULT_GREEDY
Default for
isGreedy(). |
static int |
DEFAULT_RESOLUTION
Default timer resolution.
|
| Constructor and Description |
|---|
TimeLimitingCollector(Collector collector,
long timeAllowed)
Create a TimeLimitedCollector wrapper over another
Collector with a specified timeout. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsDocsOutOfOrder()
Return
true if this collector does not
require the matching docIDs to be delivered in int sort
order (smallest to largest) to Collector.collect(int). |
void |
collect(int doc)
Calls
Collector.collect(int) on the decorated Collector
unless the allowed time has passed, in which case it throws an exception. |
static long |
getResolution()
Return the timer resolution.
|
boolean |
isGreedy()
Checks if this time limited collector is greedy in collecting the last hit.
|
void |
setGreedy(boolean greedy)
Sets whether this time limited collector is greedy.
|
void |
setNextReader(IndexReader reader,
int base)
Called before collecting from each IndexReader.
|
static void |
setResolution(long newResolution)
Set the timer resolution.
|
void |
setScorer(Scorer scorer)
Called before successive calls to
Collector.collect(int). |
public static final int DEFAULT_RESOLUTION
setResolution(long),
Constant Field Valuespublic boolean DEFAULT_GREEDY
isGreedy().isGreedy()public TimeLimitingCollector(Collector collector, long timeAllowed)
Collector with a specified timeout.collector - the wrapped CollectortimeAllowed - max time allowed for collecting hits after which TimeLimitingCollector.TimeExceededException is thrownpublic static long getResolution()
setResolution(long)public static void setResolution(long newResolution)
public boolean isGreedy()
TimeLimitingCollector.TimeExceededException
without allowing the wrapped collector to collect current doc. A greedy one would
first allow the wrapped hit collector to collect current doc and only then
throw a TimeLimitingCollector.TimeExceededException.setGreedy(boolean)public void setGreedy(boolean greedy)
greedy - true to make this time limited greedyisGreedy()public void collect(int doc)
throws IOException
Collector.collect(int) on the decorated Collector
unless the allowed time has passed, in which case it throws an exception.collect in class CollectorTimeLimitingCollector.TimeExceededException - if the time allowed has exceeded.IOExceptionpublic void setNextReader(IndexReader reader, int base) throws IOException
CollectorCollector.collect(int) will correspond to reader.
Add docBase to the current IndexReaders internal document id to re-base ids
in Collector.collect(int).setNextReader in class Collectorreader - next IndexReaderIOExceptionpublic void setScorer(Scorer scorer) throws IOException
CollectorCollector.collect(int). Implementations
that need the score of the current document (passed-in to
Collector.collect(int)), should save the passed-in Scorer and call
scorer.score() when needed.setScorer in class CollectorIOExceptionpublic boolean acceptsDocsOutOfOrder()
Collectortrue if this collector does not
require the matching docIDs to be delivered in int sort
order (smallest to largest) to Collector.collect(int).
Most Lucene Query implementations will visit
matching docIDs in order. However, some queries
(currently limited to certain cases of BooleanQuery) can achieve faster searching if the
Collector allows them to deliver the
docIDs out of order.
Many collectors don't mind getting docIDs out of
order, so it's important to return true
here.
acceptsDocsOutOfOrder in class CollectorCopyright © 2000-2012 Apache Software Foundation. All Rights Reserved.