示例#1
0
        // firstDocID is ignored since nextDoc() sets 'doc'
        public /*protected internal*/ override bool Score(Collector c, int end, int firstDocID)
        {
            c.SetScorer(this);
            while (doc < end)
            {
                // for docs in window
                c.Collect(doc);                 // collect score

                if (++pointer >= pointerMax)
                {
                    pointerMax = termDocs.Read(docs, freqs);                     // refill buffers
                    if (pointerMax != 0)
                    {
                        pointer = 0;
                    }
                    else
                    {
                        termDocs.Close();                         // close stream
                        doc = System.Int32.MaxValue;              // set to sentinel value
                        return(false);
                    }
                }
                doc = docs[pointer];
            }
            return(true);
        }
示例#2
0
 public override void  SetScorer(Scorer scorer)
 {
     // Set a ScoreCachingWrappingScorer in case the wrapped Collector will call
     // score() also.
     this.scorer = new ScoreCachingWrappingScorer(scorer);
     c.SetScorer(this.scorer);
 }
示例#3
0
 /// <summary>Scores and collects all matching documents.</summary>
 /// <param name="collector">The collector to which all matching documents are passed through.
 /// <br/>When this method is used the {@link #Explain(int)} method should not be used.
 /// </param>
 public override void  Score(Collector collector)
 {
     collector.SetScorer(this);
     while ((doc = countingSumScorer.NextDoc()) != NO_MORE_DOCS)
     {
         collector.Collect(doc);
     }
 }
示例#4
0
 /// <summary>Scores and collects all matching documents.</summary>
 /// <param name="collector">The collector to which all matching documents are passed through.
 /// <br/>When this method is used the {@link #Explain(int)} method should not be used.
 /// </param>
 public override void  Score(Collector collector)
 {
     collector.SetScorer(this);
     while (NextDoc() != NO_MORE_DOCS)
     {
         collector.Collect(currentDoc);
     }
 }
示例#5
0
        private void  SearchWithFilter(IndexReader reader, Weight weight, Filter filter, Collector collector)
        {
            System.Diagnostics.Debug.Assert(filter != null);

            Scorer scorer = weight.Scorer(reader, true, false);

            if (scorer == null)
            {
                return;
            }

            int docID = scorer.DocID();

            System.Diagnostics.Debug.Assert(docID == -1 || docID == DocIdSetIterator.NO_MORE_DOCS);

            // CHECKME: use ConjunctionScorer here?
            DocIdSet filterDocIdSet = filter.GetDocIdSet(reader);

            if (filterDocIdSet == null)
            {
                // this means the filter does not accept any documents.
                return;
            }

            DocIdSetIterator filterIter = filterDocIdSet.Iterator();

            if (filterIter == null)
            {
                // this means the filter does not accept any documents.
                return;
            }
            int filterDoc = filterIter.NextDoc();
            int scorerDoc = scorer.Advance(filterDoc);

            collector.SetScorer(scorer);
            while (true)
            {
                if (scorerDoc == filterDoc)
                {
                    // Check if scorer has exhausted, only before collecting.
                    if (scorerDoc == DocIdSetIterator.NO_MORE_DOCS)
                    {
                        break;
                    }
                    collector.Collect(scorerDoc);
                    filterDoc = filterIter.NextDoc();
                    scorerDoc = scorer.Advance(filterDoc);
                }
                else if (scorerDoc > filterDoc)
                {
                    filterDoc = filterIter.Advance(scorerDoc);
                }
                else
                {
                    scorerDoc = scorer.Advance(filterDoc);
                }
            }
        }
示例#6
0
文件: Scorer.cs 项目: carrie901/mono
		/// <summary>Scores and collects all matching documents.</summary>
		/// <param name="collector">The collector to which all matching documents are passed.
		/// <br/>When this method is used the {@link #Explain(int)} method should not be used.
		/// </param>
		public virtual void  Score(Collector collector)
		{
			collector.SetScorer(this);
			int doc;
			while ((doc = NextDoc()) != NO_MORE_DOCS)
			{
				collector.Collect(doc);
			}
		}
示例#7
0
文件: Scorer.cs 项目: vernon016/mono
        /// <summary>Scores and collects all matching documents.</summary>
        /// <param name="collector">The collector to which all matching documents are passed.
        /// <br/>When this method is used the {@link #Explain(int)} method should not be used.
        /// </param>
        public virtual void  Score(Collector collector)
        {
            collector.SetScorer(this);
            int doc;

            while ((doc = NextDoc()) != NO_MORE_DOCS)
            {
                collector.Collect(doc);
            }
        }
示例#8
0
 public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
 {
     doc = firstDocID;
     collector.SetScorer(this);
     while (doc < max)
     {
         collector.Collect(doc);
         doc = countingSumScorer.NextDoc();
     }
     return(doc != NO_MORE_DOCS);
 }
示例#9
0
文件: Scorer.cs 项目: vernon016/mono
        /// <summary> Expert: Collects matching documents in a range. Hook for optimization.
        /// Note, <code>firstDocID</code> is added to ensure that {@link #NextDoc()}
        /// was called before this method.
        ///
        /// </summary>
        /// <param name="collector">The collector to which all matching documents are passed.
        /// </param>
        /// <param name="max">Do not score documents past this.
        /// </param>
        /// <param name="firstDocID">
        /// The first document ID (ensures {@link #NextDoc()} is called before
        /// this method.
        /// </param>
        /// <returns> true if more matching documents may remain.
        /// </returns>
        public /*protected internal*/ virtual bool Score(Collector collector, int max, int firstDocID)
        {
            collector.SetScorer(this);
            int doc = firstDocID;

            while (doc < max)
            {
                collector.Collect(doc);
                doc = NextDoc();
            }
            return(doc != NO_MORE_DOCS);
        }
示例#10
0
 /// <summary>Expert: Collects matching documents in a range.  Hook for optimization.
 /// Note that {@link #Next()} must be called once before this method is called
 /// for the first time.
 /// </summary>
 /// <param name="collector">The collector to which all matching documents are passed through.
 /// </param>
 /// <param name="max">Do not score documents past this.
 /// </param>
 /// <returns> true if more matching documents may remain.
 /// </returns>
 public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
 {
     // firstDocID is ignored since nextDoc() sets 'currentDoc'
     collector.SetScorer(this);
     while (currentDoc < max)
     {
         collector.Collect(currentDoc);
         if (NextDoc() == NO_MORE_DOCS)
         {
             return(false);
         }
     }
     return(true);
 }
示例#11
0
		public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
		{
			doc = firstDocID;
			collector.SetScorer(this);
			while (doc < max)
			{
				collector.Collect(doc);
				doc = countingSumScorer.NextDoc();
			}
			return doc != NO_MORE_DOCS;
		}
示例#12
0
文件: Scorer.cs 项目: carrie901/mono
		/// <summary> Expert: Collects matching documents in a range. Hook for optimization.
		/// Note, <code>firstDocID</code> is added to ensure that {@link #NextDoc()}
		/// was called before this method.
		/// 
		/// </summary>
		/// <param name="collector">The collector to which all matching documents are passed.
		/// </param>
		/// <param name="max">Do not score documents past this.
		/// </param>
		/// <param name="firstDocID">
		/// The first document ID (ensures {@link #NextDoc()} is called before
		/// this method.
		/// </param>
		/// <returns> true if more matching documents may remain.
		/// </returns>
		public /*protected internal*/ virtual bool Score(Collector collector, int max, int firstDocID)
		{
			collector.SetScorer(this);
			int doc = firstDocID;
			while (doc < max)
			{
				collector.Collect(doc);
				doc = NextDoc();
			}
			return doc != NO_MORE_DOCS;
		}
示例#13
0
		// firstDocID is ignored since nextDoc() initializes 'current'
		public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
		{
			bool more;
			Bucket tmp;
			BucketScorer bs = new BucketScorer();
			// The internal loop will set the score and doc before calling collect.
			collector.SetScorer(bs);
			do 
			{
				bucketTable.first = null;
				
				while (current != null)
				{
					// more queued 
					
					// check prohibited & required
					if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask)
					{
						
						if (current.doc >= max)
						{
							tmp = current;
							current = current.next;
							tmp.next = bucketTable.first;
							bucketTable.first = tmp;
							continue;
						}
						
						if (current.coord >= minNrShouldMatch)
						{
							bs.score = current.score * coordFactors[current.coord];
							bs.doc = current.doc;
							collector.Collect(current.doc);
						}
					}
					
					current = current.next; // pop the queue
				}
				
				if (bucketTable.first != null)
				{
					current = bucketTable.first;
					bucketTable.first = current.next;
					return true;
				}
				
				// refill the queue
				more = false;
				end += BucketTable.SIZE;
				for (SubScorer sub = scorers; sub != null; sub = sub.next)
				{
					int subScorerDocID = sub.scorer.DocID();
					if (subScorerDocID != NO_MORE_DOCS)
					{
						more |= sub.scorer.Score(sub.collector, end, subScorerDocID);
					}
				}
				current = bucketTable.first;
			}
			while (current != null || more);
			
			return false;
		}
示例#14
0
		// firstDocID is ignored since nextDoc() sets 'doc'
		public /*protected internal*/ override bool Score(Collector c, int end, int firstDocID)
		{
			c.SetScorer(this);
			while (doc < end)
			{
				// for docs in window
				c.Collect(doc); // collect score
				
				if (++pointer >= pointerMax)
				{
					pointerMax = termDocs.Read(docs, freqs); // refill buffers
					if (pointerMax != 0)
					{
						pointer = 0;
					}
					else
					{
						termDocs.Close(); // close stream
						doc = System.Int32.MaxValue; // set to sentinel value
						return false;
					}
				}
				doc = docs[pointer];
			}
			return true;
		}
示例#15
0
		/// <summary>Expert: Collects matching documents in a range.  Hook for optimization.
		/// Note that {@link #Next()} must be called once before this method is called
		/// for the first time.
		/// </summary>
		/// <param name="collector">The collector to which all matching documents are passed through.
		/// </param>
		/// <param name="max">Do not score documents past this.
		/// </param>
		/// <returns> true if more matching documents may remain.
		/// </returns>
		public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
		{
			// firstDocID is ignored since nextDoc() sets 'currentDoc'
			collector.SetScorer(this);
			while (currentDoc < max)
			{
				collector.Collect(currentDoc);
				if (NextDoc() == NO_MORE_DOCS)
				{
					return false;
				}
			}
			return true;
		}
示例#16
0
        // firstDocID is ignored since nextDoc() initializes 'current'
        public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
        {
            bool         more;
            Bucket       tmp;
            BucketScorer bs = new BucketScorer();

            // The internal loop will set the score and doc before calling collect.
            collector.SetScorer(bs);
            do
            {
                bucketTable.first = null;

                while (current != null)
                {
                    // more queued

                    // check prohibited & required
                    if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask)
                    {
                        if (current.doc >= max)
                        {
                            tmp               = current;
                            current           = current.next;
                            tmp.next          = bucketTable.first;
                            bucketTable.first = tmp;
                            continue;
                        }

                        if (current.coord >= minNrShouldMatch)
                        {
                            bs.score = current.score * coordFactors[current.coord];
                            bs.doc   = current.doc;
                            collector.Collect(current.doc);
                        }
                    }

                    current = current.next;                     // pop the queue
                }

                if (bucketTable.first != null)
                {
                    current           = bucketTable.first;
                    bucketTable.first = current.next;
                    return(true);
                }

                // refill the queue
                more = false;
                end += BucketTable.SIZE;
                for (SubScorer sub = scorers; sub != null; sub = sub.next)
                {
                    int subScorerDocID = sub.scorer.DocID();
                    if (subScorerDocID != NO_MORE_DOCS)
                    {
                        more |= sub.scorer.Score(sub.collector, end, subScorerDocID);
                    }
                }
                current = bucketTable.first;
            }while (current != null || more);

            return(false);
        }
示例#17
0
		/// <summary>Scores and collects all matching documents.</summary>
		/// <param name="collector">The collector to which all matching documents are passed through.
		/// <br/>When this method is used the {@link #Explain(int)} method should not be used.
		/// </param>
		public override void  Score(Collector collector)
		{
			collector.SetScorer(this);
			while (NextDoc() != NO_MORE_DOCS)
			{
				collector.Collect(currentDoc);
			}
		}
示例#18
0
		/// <summary>Scores and collects all matching documents.</summary>
		/// <param name="collector">The collector to which all matching documents are passed through.
		/// <br/>When this method is used the {@link #Explain(int)} method should not be used.
		/// </param>
		public override void  Score(Collector collector)
		{
			collector.SetScorer(this);
			while ((doc = countingSumScorer.NextDoc()) != NO_MORE_DOCS)
			{
				collector.Collect(doc);
			}
		}
示例#19
0
 public override void  SetScorer(Scorer scorer)
 {
     collector.SetScorer(scorer);
 }
示例#20
0
		private void  SearchWithFilter(IndexReader reader, Weight weight, Filter filter, Collector collector)
		{
			
			System.Diagnostics.Debug.Assert(filter != null);
			
			Scorer scorer = weight.Scorer(reader, true, false);
			if (scorer == null)
			{
				return ;
			}
			
			int docID = scorer.DocID();
			System.Diagnostics.Debug.Assert(docID == - 1 || docID == DocIdSetIterator.NO_MORE_DOCS);
			
			// CHECKME: use ConjunctionScorer here?
			DocIdSet filterDocIdSet = filter.GetDocIdSet(reader);
			if (filterDocIdSet == null)
			{
				// this means the filter does not accept any documents.
				return ;
			}
			
			DocIdSetIterator filterIter = filterDocIdSet.Iterator();
			if (filterIter == null)
			{
				// this means the filter does not accept any documents.
				return ;
			}
			int filterDoc = filterIter.NextDoc();
			int scorerDoc = scorer.Advance(filterDoc);
			
			collector.SetScorer(scorer);
			while (true)
			{
				if (scorerDoc == filterDoc)
				{
					// Check if scorer has exhausted, only before collecting.
					if (scorerDoc == DocIdSetIterator.NO_MORE_DOCS)
					{
						break;
					}
					collector.Collect(scorerDoc);
					filterDoc = filterIter.NextDoc();
					scorerDoc = scorer.Advance(filterDoc);
				}
				else if (scorerDoc > filterDoc)
				{
					filterDoc = filterIter.Advance(scorerDoc);
				}
				else
				{
					scorerDoc = scorer.Advance(filterDoc);
				}
			}
		}