Пример #1
0
 public override bool Next()
 {
     if (firstTime)
     {
         if (!exclScorer.Next())
         {
             exclScorer = null;                     // exhausted at start
         }
         firstTime = false;
     }
     if (reqScorer == null)
     {
         return(false);
     }
     if (!reqScorer.Next())
     {
         reqScorer = null;                 // exhausted, nothing left
         return(false);
     }
     if (exclScorer == null)
     {
         return(true);                // reqScorer.next() already returned true
     }
     return(ToNonExcluded());
 }
Пример #2
0
 /// <summary>Scores and collects all matching documents.</summary>
 /// <param name="hc">The collector to which all matching documents are passed through
 /// {@link HitCollector#Collect(int, float)}.
 /// <br>When this method is used the {@link #Explain(int)} method should not be used.
 /// </param>
 public override void  Score(HitCollector hc)
 {
     if (allowDocsOutOfOrder && requiredScorers.Count == 0 && prohibitedScorers.Count < 32)
     {
         // fall back to BooleanScorer, scores documents somewhat out of order
         BooleanScorer bs = new BooleanScorer(GetSimilarity(), minNrShouldMatch);
         System.Collections.IEnumerator si = optionalScorers.GetEnumerator();
         while (si.MoveNext())
         {
             bs.Add((Scorer)si.Current, false, false);
         }
         si = prohibitedScorers.GetEnumerator();
         while (si.MoveNext())
         {
             bs.Add((Scorer)si.Current, false, true);
         }
         bs.Score(hc);
     }
     else
     {
         if (countingSumScorer == null)
         {
             InitCountingSumScorer();
         }
         while (countingSumScorer.Next())
         {
             hc.Collect(countingSumScorer.Doc(), Score());
         }
     }
 }
Пример #3
0
 /// <summary>Scores and collects all matching documents.</summary>
 /// <param name="hc">The collector to which all matching documents are passed through
 /// {@link HitCollector#Collect(int, float)}.
 /// <br>When this method is used the {@link #Explain(int)} method should not be used.
 /// </param>
 public override void  Score(HitCollector hc)
 {
     if (countingSumScorer == null)
     {
         InitCountingSumScorer();
     }
     while (countingSumScorer.Next())
     {
         hc.Collect(countingSumScorer.Doc(), Score());
     }
 }
Пример #4
0
 public SubScorer(Scorer scorer, bool required, bool prohibited, HitCollector collector, SubScorer next)
 {
     this.scorer     = scorer;
     this.done       = !scorer.Next();
     this.required   = required;
     this.prohibited = prohibited;
     this.collector  = collector;
     this.next       = next;
 }
		/// <summary>Add the scorer for a subquery</summary>
		/// <param name="scorer">the scorer of a subquery of our associated DisjunctionMaxQuery
		/// </param>
		public virtual void  Add(Scorer scorer)
		{
			if (scorer.Next())
			{
				// Initialize and retain only if it produces docs
				subScorers.Add(scorer);
				more = true;
			}
		}
Пример #6
0
			public SubScorer(Scorer scorer, bool required, bool prohibited, HitCollector collector, SubScorer next)
			{
				this.scorer = scorer;
				this.done = !scorer.Next();
				this.required = required;
				this.prohibited = prohibited;
				this.collector = collector;
				this.next = next;
			}
 /// <summary>Add the scorer for a subquery</summary>
 /// <param name="scorer">the scorer of a subquery of our associated DisjunctionMaxQuery
 /// </param>
 public virtual void  Add(Scorer scorer)
 {
     if (scorer.Next())
     {
         // Initialize and retain only if it produces docs
         subScorers.Add(scorer);
         more = true;
     }
 }
Пример #8
0
        /// <summary>Advance all subscorers after the current document determined by the
        /// top of the <code>scorerQueue</code>.
        /// Repeat until at least the minimum number of subscorers match on the same
        /// document and all subscorers are after that document or are exhausted.
        /// <br>On entry the <code>scorerQueue</code> has at least <code>minimumNrMatchers</code>
        /// available. At least the scorer with the minimum document number will be advanced.
        /// </summary>
        /// <returns> true iff there is a match.
        /// <br>In case there is a match, </code>currentDoc</code>, </code>currentSumScore</code>,
        /// and </code>nrMatchers</code> describe the match.
        ///
        /// </returns>
        /// <todo>  Investigate whether it is possible to use skipTo() when </todo>
        /// <summary> the minimum number of matchers is bigger than one, ie. try and use the
        /// character of ConjunctionScorer for the minimum number of matchers.
        /// </summary>
        protected internal virtual bool AdvanceAfterCurrent()
        {
            do
            {
                // repeat until minimum nr of matchers
                Scorer top = (Scorer)scorerQueue.Top();
                currentDoc   = top.Doc();
                currentScore = top.Score();
                nrMatchers   = 1;
                do
                {
                    // Until all subscorers are after currentDoc
                    if (top.Next())
                    {
                        scorerQueue.AdjustTop();
                    }
                    else
                    {
                        scorerQueue.Pop();
                        if (scorerQueue.Size() < (minimumNrMatchers - nrMatchers))
                        {
                            // Not enough subscorers left for a match on this document,
                            // and also no more chance of any further match.
                            return(false);
                        }
                        if (scorerQueue.Size() == 0)
                        {
                            break;                             // nothing more to advance, check for last match.
                        }
                    }
                    top = (Scorer)scorerQueue.Top();
                    if (top.Doc() != currentDoc)
                    {
                        break;                         // All remaining subscorers are after currentDoc.
                    }
                    else
                    {
                        currentScore += top.Score();
                        nrMatchers++;
                    }
                }while (true);

                if (nrMatchers >= minimumNrMatchers)
                {
                    return(true);
                }
                else if (scorerQueue.Size() < minimumNrMatchers)
                {
                    return(false);
                }
            }while (true);
        }
Пример #9
0
 /// <summary>Called the first time next() or skipTo() is called to
 /// initialize <code>scorerQueue</code>.
 /// </summary>
 private void  InitScorerQueue()
 {
     System.Collections.IEnumerator si = subScorers.GetEnumerator();
     scorerQueue = new ScorerQueue(this, nrScorers);
     while (si.MoveNext())
     {
         Scorer se = (Scorer)si.Current;
         if (se.Next())
         {
             // doc() method will be used in scorerQueue.
             scorerQueue.Insert(se);
         }
     }
 }
Пример #10
0
        public override bool Next()
        {
            bool more;

            do
            {
                while (bucketTable.first != null)
                {
                    // more queued
                    current           = bucketTable.first;
                    bucketTable.first = current.next;                     // pop the queue

                    // check prohibited & required
                    if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask)
                    {
                        return(true);
                    }
                }

                // refill the queue
                more = false;
                end += BucketTable.SIZE;
                for (SubScorer sub = scorers; sub != null; sub = sub.next)
                {
                    Scorer scorer = sub.scorer;
                    while (!sub.done && scorer.Doc() < end)
                    {
                        sub.collector.Collect(scorer.Doc(), scorer.Score());
                        sub.done = !scorer.Next();
                    }
                    if (!sub.done)
                    {
                        more = true;
                    }
                }
            }while (bucketTable.first != null || more);

            return(false);
        }
Пример #11
0
 public override bool Next()
 {
     return(scorer.Next());
 }