Lucene++ - a full-featured, c++ search engine
API Documentation


Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
Lucene::TimeLimitingCollector Class Reference

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>

+ Inheritance diagram for Lucene::TimeLimitingCollector:

Public Member Functions

 TimeLimitingCollector (const CollectorPtr &collector, int64_t timeAllowed)
 Create a TimeLimitedCollector wrapper over another Collector with a specified timeout.
 
virtual ~TimeLimitingCollector ()
 
virtual String getClassName ()
 
boost::shared_ptr< TimeLimitingCollectorshared_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.
 
void setGreedy (bool greedy)
 Sets whether this time limited collector is greedy.
 
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.
 
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).
 
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.
 
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.
 
- Public Member Functions inherited from Lucene::Collector
virtual ~Collector ()
 
boost::shared_ptr< Collectorshared_from_this ()
 
- Public Member Functions inherited from Lucene::LuceneObject
virtual ~LuceneObject ()
 
virtual void initialize ()
 Called directly after instantiation to create objects that depend on this object being fully constructed.
 
virtual LuceneObjectPtr clone (const LuceneObjectPtr &other=LuceneObjectPtr())
 Return clone of this object.
 
virtual int32_t hashCode ()
 Return hash code for this object.
 
virtual bool equals (const LuceneObjectPtr &other)
 Return whether two objects are equal.
 
virtual int32_t compareTo (const LuceneObjectPtr &other)
 Compare two objects.
 
virtual String toString ()
 Returns a string representation of the object.
 
- Public Member Functions inherited from Lucene::LuceneSync
virtual ~LuceneSync ()
 
virtual SynchronizePtr getSync ()
 Return this object synchronize lock.
 
virtual LuceneSignalPtr getSignal ()
 Return this object signal.
 
virtual void lock (int32_t timeout=0)
 Lock this object using an optional timeout.
 
virtual void unlock ()
 Unlock this object.
 
virtual bool holdsLock ()
 Returns true if this object is currently locked by current thread.
 
virtual void wait (int32_t timeout=0)
 Wait for signal using an optional timeout.
 
virtual void notifyAll ()
 Notify all threads waiting for signal.
 

Static Public Member Functions

static String _getClassName ()
 
static int64_t getResolution ()
 Return the timer resolution.
 
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:
 
static void stopTimer ()
 Stop timer thread.
 
- Static Public Member Functions inherited from Lucene::Collector
static String _getClassName ()
 

Data Fields

bool DEFAULT_GREEDY
 Default for isGreedy().
 

Static Public Attributes

static const int32_t DEFAULT_RESOLUTION
 Default timer resolution.
 

Static Protected Member Functions

static TimerThreadPtr TIMER_THREAD ()
 Initialize a single static timer thread to be used by all TimeLimitedCollector instances.
 

Protected Attributes

bool greedy
 
int64_t t0
 
int64_t timeout
 
CollectorPtr collector
 
int32_t docBase
 
- Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr objectLock
 
LuceneSignalPtr objectSignal
 

Static Protected Attributes

static int64_t resolution
 

Additional Inherited Members

- Protected Member Functions inherited from Lucene::LuceneObject
 LuceneObject ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ TimeLimitingCollector()

Lucene::TimeLimitingCollector::TimeLimitingCollector ( const CollectorPtr collector,
int64_t  timeAllowed 
)

Create a TimeLimitedCollector wrapper over another Collector with a specified timeout.

Parameters
collectorthe wrapped Collector
timeAllowedmax time allowed for collecting hits after which TimeExceeded exception is thrown

◆ ~TimeLimitingCollector()

virtual Lucene::TimeLimitingCollector::~TimeLimitingCollector ( )
virtual

Member Function Documentation

◆ _getClassName()

static String Lucene::TimeLimitingCollector::_getClassName ( )
inlinestatic

◆ acceptsDocsOutOfOrder()

virtual bool Lucene::TimeLimitingCollector::acceptsDocsOutOfOrder ( )
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.

◆ collect()

virtual void Lucene::TimeLimitingCollector::collect ( int32_t  doc)
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.

◆ getClassName()

virtual String Lucene::TimeLimitingCollector::getClassName ( )
inlinevirtual

Reimplemented from Lucene::Collector.

◆ getResolution()

static int64_t Lucene::TimeLimitingCollector::getResolution ( )
static

Return the timer resolution.

See also
setResolution(int64_t)

◆ isGreedy()

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.

See also
#setGreedy(boolean)

◆ setGreedy()

void Lucene::TimeLimitingCollector::setGreedy ( bool  greedy)

Sets whether this time limited collector is greedy.

Parameters
greedytrue to make this time limited greedy
See also
isGreedy()

◆ setNextReader()

virtual void Lucene::TimeLimitingCollector::setNextReader ( const IndexReaderPtr reader,
int32_t  docBase 
)
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).

Parameters
readernext IndexReader
docBase

Implements Lucene::Collector.

◆ setResolution()

static void Lucene::TimeLimitingCollector::setResolution ( int64_t  newResolution)
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:

  • Finer (smaller) resolution is more accurate but less efficient.
  • Setting resolution to less than 5 milliseconds will be silently modified to 5 milliseconds.
  • Setting resolution smaller than current resolution might take effect only after current resolution. (Assume current resolution of 20 milliseconds is modified to 5 milliseconds, then it can take up to 20 milliseconds for the change to have effect.

◆ setScorer()

virtual void Lucene::TimeLimitingCollector::setScorer ( const ScorerPtr scorer)
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.

◆ shared_from_this()

boost::shared_ptr< TimeLimitingCollector > Lucene::TimeLimitingCollector::shared_from_this ( )
inline

◆ stopTimer()

static void Lucene::TimeLimitingCollector::stopTimer ( )
static

Stop timer thread.

◆ TIMER_THREAD()

static TimerThreadPtr Lucene::TimeLimitingCollector::TIMER_THREAD ( )
staticprotected

Initialize a single static timer thread to be used by all TimeLimitedCollector instances.

Field Documentation

◆ collector

CollectorPtr Lucene::TimeLimitingCollector::collector
protected

◆ DEFAULT_GREEDY

bool Lucene::TimeLimitingCollector::DEFAULT_GREEDY

Default for isGreedy().

See also
isGreedy()

◆ DEFAULT_RESOLUTION

const int32_t Lucene::TimeLimitingCollector::DEFAULT_RESOLUTION
static

Default timer resolution.

See also
setResolution(int64_t)

◆ docBase

int32_t Lucene::TimeLimitingCollector::docBase
protected

◆ greedy

bool Lucene::TimeLimitingCollector::greedy
protected

◆ resolution

int64_t Lucene::TimeLimitingCollector::resolution
staticprotected

◆ t0

int64_t Lucene::TimeLimitingCollector::t0
protected

◆ timeout

int64_t Lucene::TimeLimitingCollector::timeout
protected

The documentation for this class was generated from the following file:

clucene.sourceforge.net