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

Loading...
Searching...
No Matches
TimeLimitingCollector.h
Go to the documentation of this file.
1
2// Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3// Distributable under the terms of either the Apache License (Version 2.0)
4// or the GNU Lesser General Public License.
6
7#ifndef TIMELIMITINGCOLLECTOR_H
8#define TIMELIMITINGCOLLECTOR_H
9
10#include "Collector.h"
11
12 namespace Lucene {
13
17 class LPPAPI TimeLimitingCollector : public Collector {
18 public:
22 TimeLimitingCollector(const CollectorPtr& collector, int64_t timeAllowed);
23
24 virtual ~TimeLimitingCollector();
25
26 LUCENE_CLASS(TimeLimitingCollector);
27
28 public:
31 static const int32_t DEFAULT_RESOLUTION;
32
35 bool DEFAULT_GREEDY;
36
37 protected:
38 static int64_t resolution;
39 bool greedy;
40
41 int64_t t0;
42 int64_t timeout;
43 CollectorPtr collector;
44
45 int32_t docBase;
46
47 public:
50 static int64_t getResolution();
51
63 static void setResolution(int64_t newResolution);
64
66 static void stopTimer();
67
73 bool isGreedy();
74
78 void setGreedy(bool greedy);
79
82 virtual void collect(int32_t doc);
83
84 virtual void setNextReader(const IndexReaderPtr& reader, int32_t docBase);
85 virtual void setScorer(const ScorerPtr& scorer);
86 virtual bool acceptsDocsOutOfOrder();
87
88 protected:
90 static TimerThreadPtr TIMER_THREAD();
91
92 friend class TimerThread;
93};
94
95}
96
97#endif
Collector.h
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Lucene::Collector
Collectors are primarily meant to be used to gather raw results from a search, and implement sorting ...
Definition Collector.h:100
Lucene::TimeLimitingCollector
The TimeLimitingCollector is used to timeout search requests that take longer than the maximum allowe...
Definition TimeLimitingCollector.h:17
Lucene::TimeLimitingCollector::setGreedy
void setGreedy(bool greedy)
Sets whether this time limited collector is greedy.
Lucene::TimeLimitingCollector::stopTimer
static void stopTimer()
Stop timer thread.
Lucene::TimeLimitingCollector::acceptsDocsOutOfOrder
virtual bool acceptsDocsOutOfOrder()
Return true if this collector does not require the matching docIDs to be delivered in int sort order ...
Lucene::TimeLimitingCollector::TIMER_THREAD
static TimerThreadPtr TIMER_THREAD()
Initialize a single static timer thread to be used by all TimeLimitedCollector instances.
Lucene::TimeLimitingCollector::greedy
bool greedy
Definition TimeLimitingCollector.h:39
Lucene::TimeLimitingCollector::setResolution
static void setResolution(int64_t newResolution)
Set the timer resolution. The default timer resolution is 20 milliseconds. This means that a search r...
Lucene::TimeLimitingCollector::~TimeLimitingCollector
virtual ~TimeLimitingCollector()
Lucene::TimeLimitingCollector::getResolution
static int64_t getResolution()
Return the timer resolution.
Lucene::TimeLimitingCollector::resolution
static int64_t resolution
Definition TimeLimitingCollector.h:38
Lucene::TimeLimitingCollector::collect
virtual void collect(int32_t doc)
Calls Collector#collect(int) on the decorated Collector unless the allowed time has passed,...
Lucene::TimeLimitingCollector::docBase
int32_t docBase
Definition TimeLimitingCollector.h:45
Lucene::TimeLimitingCollector::DEFAULT_RESOLUTION
static const int32_t DEFAULT_RESOLUTION
Default timer resolution.
Definition TimeLimitingCollector.h:31
Lucene::TimeLimitingCollector::timeout
int64_t timeout
Definition TimeLimitingCollector.h:42
Lucene::TimeLimitingCollector::collector
CollectorPtr collector
Definition TimeLimitingCollector.h:43
Lucene::TimeLimitingCollector::setScorer
virtual void setScorer(const ScorerPtr &scorer)
Called before successive calls to collect(int32_t). Implementations that need the score of the curren...
Lucene::TimeLimitingCollector::setNextReader
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 re...
Lucene::TimeLimitingCollector::TimeLimitingCollector
TimeLimitingCollector(const CollectorPtr &collector, int64_t timeAllowed)
Create a TimeLimitedCollector wrapper over another Collector with a specified timeout.
Lucene::TimeLimitingCollector::DEFAULT_GREEDY
bool DEFAULT_GREEDY
Default for isGreedy().
Definition TimeLimitingCollector.h:35
Lucene::TimeLimitingCollector::t0
int64_t t0
Definition TimeLimitingCollector.h:41
Lucene::TimeLimitingCollector::isGreedy
bool isGreedy()
Checks if this time limited collector is greedy in collecting the last hit. A non greedy collector,...
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::TimerThreadPtr
boost::shared_ptr< TimerThread > TimerThreadPtr
Definition LuceneTypes.h:470
Lucene::CollectorPtr
boost::shared_ptr< Collector > CollectorPtr
Definition LuceneTypes.h:295
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition LuceneTypes.h:157
Lucene::ScorerPtr
boost::shared_ptr< Scorer > ScorerPtr
Definition LuceneTypes.h:429

clucene.sourceforge.net