19 using Lucene.Net.Support;
22 namespace Lucene.Net.Search
32 private void InitBlock()
34 greedy = DEFAULT_GREEDY;
40 public const int DEFAULT_RESOLUTION = 20;
45 public bool DEFAULT_GREEDY =
false;
47 private static uint resolution = DEFAULT_RESOLUTION;
64 private volatile uint time = 0;
71 internal TimerThread():base(
"TimeLimitedCollector timer thread")
73 this.IsBackground =
true;
76 override public void Run()
81 time += Lucene.Net.Search.TimeLimitingCollector.resolution;
82 System.Threading.Thread.Sleep(
new System.TimeSpan((System.Int64) 10000 * Lucene.Net.Search.TimeLimitingCollector.resolution));
88 public long Milliseconds
98 private long timeAllowed;
99 private long timeElapsed;
100 private int lastDocCollected;
101 internal TimeExceededException(
long timeAllowed,
long timeElapsed,
int lastDocCollected):base(
"Elapsed time: " + timeElapsed +
"Exceeded allowed search time: " + timeAllowed +
" ms.")
103 this.timeAllowed = timeAllowed;
104 this.timeElapsed = timeElapsed;
105 this.lastDocCollected = lastDocCollected;
109 public virtual long TimeAllowed
111 get {
return timeAllowed; }
115 public virtual long TimeElapsed
117 get {
return timeElapsed; }
121 public virtual int LastDocCollected
123 get {
return lastDocCollected; }
130 private static readonly TimerThread TIMER_THREAD =
new TimerThread();
133 private long timeout;
146 this.collector = collector;
147 t0 = TIMER_THREAD.Milliseconds;
148 this.timeout = t0 + timeAllowed;
165 public static long Resolution
167 get {
return resolution; }
171 resolution = (uint)System.Math.Max(value, 5);
181 public virtual bool IsGreedy
183 get {
return greedy; }
184 set { this.greedy = value; }
194 public override void Collect(
int doc)
196 long time = TIMER_THREAD.Milliseconds;
208 collector.Collect(doc);
211 public override void SetNextReader(
IndexReader reader,
int base_Renamed)
213 collector.SetNextReader(reader, base_Renamed);
214 this.docBase = base_Renamed;
217 public override void SetScorer(
Scorer scorer)
219 collector.SetScorer(scorer);
222 public override bool AcceptsDocsOutOfOrder
224 get {
return collector.AcceptsDocsOutOfOrder; }
230 TIMER_THREAD.Start();