コード例 #1
0
ファイル: TermScorer.cs プロジェクト: mindis/Transformalize
        // 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
ファイル: TermScorer.cs プロジェクト: mindis/Transformalize
		// 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;
		}
コード例 #3
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);
 }
コード例 #4
0
 /// <summary>Scores and collects all matching documents.</summary>
 /// <param name="collector">The collector to which all matching documents are passed through.</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
 /// <summary>Expert: Collects matching documents in a range.  Hook for optimization.
 /// Note that <see cref="NextDoc()" /> 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>
 /// <param name="firstDocID"></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);
 }
コード例 #7
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);
        }
コード例 #8
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;
		}
コード例 #9
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);
				}
			}
		}
コード例 #10
0
	    /// <summary>Expert: Collects matching documents in a range.  Hook for optimization.
	    /// Note that <see cref="NextDoc()" /> 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>
	    /// <param name="firstDocID"></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
		/// <summary>Scores and collects all matching documents.</summary>
		/// <param name="collector">The collector to which all matching documents are passed through.</param>
		public override void  Score(Collector collector)
		{
			collector.SetScorer(this);
			while (NextDoc() != NO_MORE_DOCS)
			{
				collector.Collect(currentDoc);
			}
		}
コード例 #12
0
 public override void  SetScorer(Scorer scorer)
 {
     collector.SetScorer(scorer);
 }