java.lang.Object | ||
↳ | org.apache.lucene.search.Collector | |
↳ | org.apache.lucene.search.TimeLimitingCollector |
The 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
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
TimeLimitingCollector.TimeExceededException | Thrown when elapsed search time exceeds allowed search time. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | DEFAULT_RESOLUTION | Default timer resolution. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DEFAULT_GREEDY | Default for isGreedy() . |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a TimeLimitedCollector wrapper over another
Collector with a specified timeout. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return
true if this collector does not
require the matching docIDs to be delivered in int sort
order (smallest to largest) to collect(int) . | |||||||||||
Calls
collect(int) on the decorated Collector
unless the allowed time has passed, in which case it throws an exception. | |||||||||||
Return the timer resolution.
| |||||||||||
Checks if this time limited collector is greedy in collecting the last hit.
| |||||||||||
Sets whether this time limited collector is greedy.
| |||||||||||
Called before collecting from each IndexReader.
| |||||||||||
Set the timer resolution.
| |||||||||||
Called before successive calls to
collect(int) . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.lucene.search.Collector
| |||||||||||
From class
java.lang.Object
|
Create a TimeLimitedCollector wrapper over another Collector
with a specified timeout.
collector | the wrapped Collector |
---|---|
timeAllowed | max time allowed for collecting hits after which TimeLimitingCollector.TimeExceededException is thrown
|
Return true
if this collector does not
require the matching docIDs to be delivered in int sort
order (smallest to largest) to 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.
Calls collect(int)
on the decorated Collector
unless the allowed time has passed, in which case it throws an exception.
TimeLimitingCollector.TimeExceededException | if the time allowed has exceeded. |
---|---|
IOException |
Checks if this time limited collector is greedy in collecting the last hit.
A non greedy collector, upon a timeout, would throw a 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
.
Sets whether this time limited collector is greedy.
greedy | true to make this time limited greedy |
---|
Called before collecting from each IndexReader. All doc ids in
collect(int)
will correspond to reader.
Add docBase to the current IndexReaders internal document id to re-base ids
in collect(int)
.
reader | next IndexReader |
---|
IOException |
---|
Set the timer resolution.
The default timer resolution is 20 milliseconds.
This means that a search required to take no longer than
800 milliseconds may be stopped after 780 to 820 milliseconds.
Note that:
Called before successive calls to collect(int)
. Implementations
that need the score of the current document (passed-in to
collect(int)
), should save the passed-in Scorer and call
scorer.score() when needed.
IOException |
---|