Class 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.
Inheritance
Implements
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public class TimeLimitingCollector : object, ICollector
Constructors
| Improve this Doc View SourceTimeLimitingCollector(ICollector, Counter, Int64)
Create a TimeLimitingCollector wrapper over another ICollector with a specified timeout.
Declaration
public TimeLimitingCollector(ICollector collector, Counter clock, long ticksAllowed)
Parameters
Type | Name | Description |
---|---|---|
ICollector | collector | The wrapped ICollector |
Counter | clock | The timer clock |
System.Int64 | ticksAllowed | Max time allowed for collecting hits after which TimeLimitingCollector.TimeExceededException is thrown |
Properties
| Improve this Doc View SourceAcceptsDocsOutOfOrder
Declaration
public virtual bool AcceptsDocsOutOfOrder { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
GlobalCounter
Returns the global TimeLimitingCollector.TimerThread's Counter
Invoking this creates may create a new instance of TimeLimitingCollector.TimerThread iff the global TimeLimitingCollector.TimerThread has never been accessed before. The thread returned from this method is started on creation and will be alive unless you stop the TimeLimitingCollector.TimerThread via StopTimer().
Declaration
public static Counter GlobalCounter { get; }
Property Value
Type | Description |
---|---|
Counter | the global TimerThreads Counter |
GlobalTimerThread
Returns the global TimeLimitingCollector.TimerThread.
Invoking this creates may create a new instance of TimeLimitingCollector.TimerThread iff the global TimeLimitingCollector.TimerThread has never been accessed before. The thread returned from this method is started on creation and will be alive unless you stop the TimeLimitingCollector.TimerThread via StopTimer().
Declaration
public static TimeLimitingCollector.TimerThread GlobalTimerThread { get; }
Property Value
Type | Description |
---|---|
TimeLimitingCollector.TimerThread | the global TimeLimitingCollector.TimerThread |
IsGreedy
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.
Declaration
public virtual bool IsGreedy { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceCollect(Int32)
Calls Collect(Int32) on the decorated ICollector unless the allowed time has passed, in which case it throws an exception.
Declaration
public virtual void Collect(int doc)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | doc |
Exceptions
Type | Condition |
---|---|
TimeLimitingCollector.TimeExceededException | If the time allowed has exceeded. |
SetBaseline()
Syntactic sugar for SetBaseline(Int64) using Get() on the clock passed to the constructor.
Declaration
public virtual void SetBaseline()
SetBaseline(Int64)
Sets the baseline for this collector. By default the collectors baseline is initialized once the first reader is passed to the collector. To include operations executed in prior to the actual document collection set the baseline through this method in your prelude.
Example usage:
// Counter is in the Lucene.Net.Util namespace
Counter clock = Counter.NewCounter(true);
long baseline = clock.Get();
// ... prepare search
TimeLimitingCollector collector = new TimeLimitingCollector(c, clock, numTicks);
collector.SetBaseline(baseline);
indexSearcher.Search(query, collector);
Declaration
public virtual void SetBaseline(long clockTime)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | clockTime |
See Also
| Improve this Doc View SourceSetCollector(ICollector)
This is so the same timer can be used with a multi-phase search process such as grouping. We don't want to create a new TimeLimitingCollector for each phase because that would reset the timer for each phase. Once time is up subsequent phases need to timeout quickly.
Declaration
public virtual void SetCollector(ICollector collector)
Parameters
Type | Name | Description |
---|---|---|
ICollector | collector | The actual collector performing search functionality. |
SetNextReader(AtomicReaderContext)
Declaration
public virtual void SetNextReader(AtomicReaderContext context)
Parameters
Type | Name | Description |
---|---|---|
AtomicReaderContext | context |
SetScorer(Scorer)
Declaration
public virtual void SetScorer(Scorer scorer)
Parameters
Type | Name | Description |
---|---|---|
Scorer | scorer |