22 namespace Lucene.Net.Search
31 private int nrScorers;
34 protected internal System.Collections.Generic.IList<
Scorer> subScorers;
37 private int minimumNrMatchers;
54 private int currentDoc = - 1;
57 protected internal int nrMatchers = - 1;
59 private float currentScore = System.Single.NaN;
75 nrScorers = subScorers.Count;
77 if (minimumNrMatchers <= 0)
79 throw new System.ArgumentException(
"Minimum nr of matchers must be positive");
83 throw new System.ArgumentException(
"There must be at least 2 subScorers");
86 this.minimumNrMatchers = minimumNrMatchers;
87 this.subScorers = subScorers;
103 private void InitScorerDocQueue()
106 foreach(
Scorer se
in subScorers)
108 if (se.
NextDoc() != NO_MORE_DOCS)
111 scorerDocQueue.Insert(se);
121 while (NextDoc() != NO_MORE_DOCS)
138 public override bool Score(
Collector collector,
int max,
int firstDocID)
142 while (currentDoc < max)
145 if (NextDoc() == NO_MORE_DOCS)
153 public override int NextDoc()
155 if (scorerDocQueue.Size() < minimumNrMatchers || !AdvanceAfterCurrent())
157 currentDoc = NO_MORE_DOCS;
181 protected internal virtual bool AdvanceAfterCurrent()
186 currentDoc = scorerDocQueue.TopDoc();
187 currentScore = scorerDocQueue.TopScore();
192 if (!scorerDocQueue.TopNextAndAdjustElsePop())
194 if (scorerDocQueue.Size() == 0)
199 if (scorerDocQueue.TopDoc() != currentDoc)
203 currentScore += scorerDocQueue.TopScore();
208 if (nrMatchers >= minimumNrMatchers)
212 else if (scorerDocQueue.Size() < minimumNrMatchers)
223 public override float Score()
228 public override int DocID()
236 public virtual int NrMatchers()
251 public override int Advance(
int target)
253 if (scorerDocQueue.Size() < minimumNrMatchers)
255 return currentDoc = NO_MORE_DOCS;
257 if (target <= currentDoc)
263 if (scorerDocQueue.TopDoc() >= target)
265 return AdvanceAfterCurrent()?currentDoc:(currentDoc = NO_MORE_DOCS);
267 else if (!scorerDocQueue.TopSkipToAndAdjustElsePop(target))
269 if (scorerDocQueue.Size() < minimumNrMatchers)
271 return currentDoc = NO_MORE_DOCS;