Lucene++ - a full-featured, c++ search engine
API Documentation
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 TimeExceededException
.
More...
#include <TimeLimitingCollector.h>
Public Member Functions | |
TimeLimitingCollector (const CollectorPtr &collector, int64_t timeAllowed) | |
Create a TimeLimitedCollector wrapper over another Collector with a specified timeout. More... | |
virtual | ~TimeLimitingCollector () |
virtual String | getClassName () |
boost::shared_ptr< TimeLimitingCollector > | shared_from_this () |
bool | isGreedy () |
Checks if this time limited collector is greedy in collecting the last hit. A non greedy collector, upon a timeout, would throw a TimeExceeded 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 TimeExceeded exception. More... | |
void | setGreedy (bool greedy) |
Sets whether this time limited collector is greedy. More... | |
virtual void | collect (int32_t doc) |
Calls Collector#collect(int) on the decorated Collector unless the allowed time has passed, in which case it throws an exception. More... | |
virtual void | setNextReader (const IndexReaderPtr &reader, int32_t docBase) |
Called before collecting from each IndexReader. All doc ids in collect(int32_t) will correspond to reader. Add docBase to the current IndexReaders internal document id to re-base ids in collect(int32_t) . More... | |
virtual void | setScorer (const ScorerPtr &scorer) |
Called before successive calls to collect(int32_t) . Implementations that need the score of the current document (passed-in to collect(int32_t) ), should save the passed-in Scorer and call scorer.score() when needed. More... | |
virtual bool | acceptsDocsOutOfOrder () |
Return true if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) to collect . More... | |
![]() | |
virtual | ~Collector () |
virtual String | getClassName () |
boost::shared_ptr< Collector > | shared_from_this () |
virtual void | setScorer (const ScorerPtr &scorer)=0 |
Called before successive calls to collect(int32_t) . Implementations that need the score of the current document (passed-in to collect(int32_t) ), should save the passed-in Scorer and call scorer.score() when needed. More... | |
virtual void | collect (int32_t doc)=0 |
Called once for every document matching a query, with the unbased document number. More... | |
virtual void | setNextReader (const IndexReaderPtr &reader, int32_t docBase)=0 |
Called before collecting from each IndexReader. All doc ids in collect(int32_t) will correspond to reader. Add docBase to the current IndexReaders internal document id to re-base ids in collect(int32_t) . More... | |
virtual bool | acceptsDocsOutOfOrder ()=0 |
Return true if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) to collect . More... | |
![]() | |
virtual | ~LuceneObject () |
virtual void | initialize () |
Called directly after instantiation to create objects that depend on this object being fully constructed. More... | |
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr()) |
Return clone of this object. More... | |
virtual int32_t | hashCode () |
Return hash code for this object. More... | |
virtual bool | equals (const LuceneObjectPtr &other) |
Return whether two objects are equal. More... | |
virtual int32_t | compareTo (const LuceneObjectPtr &other) |
Compare two objects. More... | |
virtual String | toString () |
Returns a string representation of the object. More... | |
![]() | |
virtual | ~LuceneSync () |
virtual SynchronizePtr | getSync () |
Return this object synchronize lock. More... | |
virtual LuceneSignalPtr | getSignal () |
Return this object signal. More... | |
virtual void | lock (int32_t timeout=0) |
Lock this object using an optional timeout. More... | |
virtual void | unlock () |
Unlock this object. More... | |
virtual bool | holdsLock () |
Returns true if this object is currently locked by current thread. More... | |
virtual void | wait (int32_t timeout=0) |
Wait for signal using an optional timeout. More... | |
virtual void | notifyAll () |
Notify all threads waiting for signal. More... | |
Static Public Member Functions | |
static String | _getClassName () |
static int64_t | getResolution () |
Return the timer resolution. More... | |
static void | setResolution (int64_t newResolution) |
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: More... | |
static void | stopTimer () |
Stop timer thread. More... | |
![]() | |
static String | _getClassName () |
Data Fields | |
bool | DEFAULT_GREEDY |
Default for isGreedy() . More... | |
Static Public Attributes | |
static const int32_t | DEFAULT_RESOLUTION |
Default timer resolution. More... | |
Static Protected Member Functions | |
static TimerThreadPtr | TIMER_THREAD () |
Initialize a single static timer thread to be used by all TimeLimitedCollector instances. More... | |
Protected Attributes | |
bool | greedy |
int64_t | t0 |
int64_t | timeout |
CollectorPtr | collector |
int32_t | docBase |
![]() | |
SynchronizePtr | objectLock |
LuceneSignalPtr | objectSignal |
Static Protected Attributes | |
static int64_t | resolution |
Additional Inherited Members | |
![]() | |
LuceneObject () | |
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 TimeExceededException
.
Lucene::TimeLimitingCollector::TimeLimitingCollector | ( | const CollectorPtr & | collector, |
int64_t | timeAllowed | ||
) |
|
virtual |
|
inlinestatic |
|
virtual |
Return true if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) to collect
.
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.
Implements Lucene::Collector.
|
virtual |
Calls Collector#collect(int)
on the decorated Collector
unless the allowed time has passed, in which case it throws an exception.
Implements Lucene::Collector.
|
inlinevirtual |
Reimplemented from Lucene::Collector.
|
static |
Return the timer resolution.
bool Lucene::TimeLimitingCollector::isGreedy | ( | ) |
Checks if this time limited collector is greedy in collecting the last hit. A non greedy collector, upon a timeout, would throw a TimeExceeded 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 TimeExceeded exception.
void Lucene::TimeLimitingCollector::setGreedy | ( | bool | greedy | ) |
Sets whether this time limited collector is greedy.
greedy | true to make this time limited greedy |
|
virtual |
Called before collecting from each IndexReader. All doc ids in collect(int32_t)
will correspond to reader. Add docBase to the current IndexReaders internal document id to re-base ids in collect(int32_t)
.
reader | next IndexReader |
docBase |
Implements Lucene::Collector.
|
static |
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:
|
virtual |
Called before successive calls to collect(int32_t)
. Implementations that need the score of the current document (passed-in to collect(int32_t)
), should save the passed-in Scorer and call scorer.score() when needed.
Implements Lucene::Collector.
|
inline |
|
static |
Stop timer thread.
|
staticprotected |
Initialize a single static timer thread to be used by all TimeLimitedCollector instances.
|
protected |
bool Lucene::TimeLimitingCollector::DEFAULT_GREEDY |
Default for isGreedy()
.
|
static |
Default timer resolution.
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |