Package org.apache.lucene.search
Class TimeLimitingCollector
- java.lang.Object
-
- org.apache.lucene.search.TimeLimitingCollector
-
- All Implemented Interfaces:
Collector
@Deprecated public class TimeLimitingCollector extends Object implements Collector
Deprecated.UseIndexSearcher.setTimeout(QueryTimeout)to time out queries.TheTimeLimitingCollectoris 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 aTimeLimitingCollector.TimeExceededException.- See Also:
ExitableDirectoryReader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTimeLimitingCollector.TimeExceededExceptionDeprecated.Thrown when elapsed search time exceeds allowed search time.static classTimeLimitingCollector.TimerThreadDeprecated.Thread used to timeout search requests.
-
Constructor Summary
Constructors Constructor Description TimeLimitingCollector(Collector collector, Counter clock, long ticksAllowed)Deprecated.Create a TimeLimitedCollector wrapper over anotherCollectorwith a specified timeout.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static CountergetGlobalCounter()Deprecated.Returns the global TimerThreadsCounterstatic TimeLimitingCollector.TimerThreadgetGlobalTimerThread()Deprecated.Returns the globalTimeLimitingCollector.TimerThread.LeafCollectorgetLeafCollector(LeafReaderContext context)Deprecated.Create a newcollectorto collect the given context.booleanisGreedy()Deprecated.Checks if this time limited collector is greedy in collecting the last hit.ScoreModescoreMode()Deprecated.Indicates what features are required from the scorer.voidsetBaseline()Deprecated.Syntactic sugar forsetBaseline(long)usingCounter.get()on the clock passed to the constructor.voidsetBaseline(long clockTime)Deprecated.Sets the baseline for this collector.voidsetCollector(Collector collector)Deprecated.This is so the same timer can be used with a multi-phase search process such as grouping.voidsetGreedy(boolean greedy)Deprecated.Sets whether this time limited collector is greedy.
-
-
-
Constructor Detail
-
TimeLimitingCollector
public TimeLimitingCollector(Collector collector, Counter clock, long ticksAllowed)
Deprecated.Create a TimeLimitedCollector wrapper over anotherCollectorwith a specified timeout.- Parameters:
collector- the wrappedCollectorclock- the timer clockticksAllowed- max time allowed for collecting hits after whichTimeLimitingCollector.TimeExceededExceptionis thrown
-
-
Method Detail
-
setBaseline
public void setBaseline(long clockTime)
Deprecated.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 clock = ...; long baseline = clock.get(); // ... prepare search TimeLimitingCollector collector = new TimeLimitingCollector(c, clock, numTicks); collector.setBaseline(baseline); indexSearcher.search(query, collector);
- See Also:
setBaseline()
-
setBaseline
public void setBaseline()
Deprecated.Syntactic sugar forsetBaseline(long)usingCounter.get()on the clock passed to the constructor.
-
isGreedy
public boolean isGreedy()
Deprecated.Checks if this time limited collector is greedy in collecting the last hit. A non greedy collector, upon a timeout, would throw aTimeLimitingCollector.TimeExceededExceptionwithout 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 aTimeLimitingCollector.TimeExceededException. However, if the timeout is detected ingetLeafCollector(org.apache.lucene.index.LeafReaderContext)then no current document is collected.- See Also:
setGreedy(boolean)
-
setGreedy
public void setGreedy(boolean greedy)
Deprecated.Sets whether this time limited collector is greedy.- Parameters:
greedy- true to make this time limited greedy- See Also:
isGreedy()
-
getLeafCollector
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException
Deprecated.Description copied from interface:CollectorCreate a newcollectorto collect the given context.- Specified by:
getLeafCollectorin interfaceCollector- Parameters:
context- next atomic reader context- Throws:
IOException
-
scoreMode
public ScoreMode scoreMode()
Deprecated.Description copied from interface:CollectorIndicates what features are required from the scorer.
-
setCollector
public void setCollector(Collector collector)
Deprecated.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.- Parameters:
collector- The actual collector performing search functionality
-
getGlobalCounter
public static Counter getGlobalCounter()
Deprecated.Returns the global TimerThreadsCounterInvoking this creates may create a new instance of
TimeLimitingCollector.TimerThreadiff the globalTimeLimitingCollector.TimerThreadhas never been accessed before. The thread returned from this method is started on creation and will be alive unless you stop theTimeLimitingCollector.TimerThreadviaTimeLimitingCollector.TimerThread.stopTimer().- Returns:
- the global TimerThreads
Counter - WARNING: This API is experimental and might change in incompatible ways in the next release.
-
getGlobalTimerThread
public static TimeLimitingCollector.TimerThread getGlobalTimerThread()
Deprecated.Returns the globalTimeLimitingCollector.TimerThread.Invoking this creates may create a new instance of
TimeLimitingCollector.TimerThreadiff the globalTimeLimitingCollector.TimerThreadhas never been accessed before. The thread returned from this method is started on creation and will be alive unless you stop theTimeLimitingCollector.TimerThreadviaTimeLimitingCollector.TimerThread.stopTimer().- Returns:
- the global
TimeLimitingCollector.TimerThread - WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-