Ejemplo n.º 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;
		}
Ejemplo n.º 2
0
 /// <summary>Lower-level search API.
 ///
 /// <p/><see cref="Collector.Collect(int)" /> is called for every matching document.
 ///
 /// <p/>Applications should only use this if they need <i>all</i> of the matching
 /// documents. The high-level search API (<see cref="Searcher.Search(Query, int)" />
 /// ) is usually more efficient, as it skips non-high-scoring hits.
 /// <p/>Note: The <c>score</c> passed to this method is a raw score.
 /// In other words, the score will not necessarily be a float whose value is
 /// between 0 and 1.
 /// </summary>
 /// <throws>  BooleanQuery.TooManyClauses </throws>
 public virtual void  Search(Query query, Collector results)
 {
     Search(CreateWeight(query), null, results);
 }
Ejemplo n.º 3
0
 public abstract void  Search(Weight weight, Filter filter, Collector results);
Ejemplo n.º 4
0
		/// <summary> Create a TimeLimitedCollector wrapper over another <see cref="Collector" /> with a specified timeout.</summary>
		/// <param name="collector">the wrapped <see cref="Collector" />
		/// </param>
		/// <param name="timeAllowed">max time allowed for collecting hits after which <see cref="TimeExceededException" /> is thrown
		/// </param>
		public TimeLimitingCollector(Collector collector, long timeAllowed)
		{
			InitBlock();
			this.collector = collector;
			t0 = TIMER_THREAD.Milliseconds;
			this.timeout = t0 + timeAllowed;
		}
Ejemplo n.º 5
0
 public override void  Search(Weight weight, Filter filter, Collector results)
 {
     throw new System.NotSupportedException();
 }
Ejemplo n.º 6
0
		public override void  Score(Collector collector)
		{
			Score(collector, System.Int32.MaxValue, NextDoc());
		}
		public PositiveScoresOnlyCollector(Collector c)
		{
			this.c = c;
		}
Ejemplo n.º 8
0
		/// <summary>Lower-level search API.
		/// 
		/// <p/><see cref="Collector.Collect(int)" /> is called for every matching document.
		/// 
		/// <p/>Applications should only use this if they need <i>all</i> of the matching
		/// documents. The high-level search API (<see cref="Searcher.Search(Query, int)" />
		/// ) is usually more efficient, as it skips non-high-scoring hits.
		/// <p/>Note: The <c>score</c> passed to this method is a raw score.
		/// In other words, the score will not necessarily be a float whose value is
		/// between 0 and 1.
		/// </summary>
		/// <throws>  BooleanQuery.TooManyClauses </throws>
		public virtual void  Search(Query query, Collector results)
		{
			Search(CreateWeight(query), null, results);
		}
Ejemplo n.º 9
0
		/// <summary>Lower-level search API.
		/// 
		/// <p/><see cref="Collector.Collect(int)" /> is called for every matching
		/// document.
		/// <br/>Collector-based access to remote indexes is discouraged.
		/// 
		/// <p/>Applications should only use this if they need <i>all</i> of the
		/// matching documents.  The high-level search API (<see cref="Searcher.Search(Query, Filter, int)" />)
		/// is usually more efficient, as it skips
		/// non-high-scoring hits.
		/// 
		/// </summary>
		/// <param name="query">to match documents
		/// </param>
		/// <param name="filter">if non-null, used to permit documents to be collected.
		/// </param>
		/// <param name="results">to receive hits
		/// </param>
		/// <throws>  BooleanQuery.TooManyClauses </throws>
		public virtual void  Search(Query query, Filter filter, Collector results)
		{
			Search(CreateWeight(query), filter, results);
		}
Ejemplo n.º 10
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);
				}
			}
		}
Ejemplo n.º 11
0
		public abstract void  Search(Weight weight, Filter filter, Collector results);
Ejemplo n.º 12
0
		public override void  Search(Weight weight, Filter filter, Collector collector)
		{
			
			if (filter == null)
			{
				for (int i = 0; i < subReaders.Length; i++)
				{
					// search each subreader
					collector.SetNextReader(subReaders[i], docStarts[i]);
					Scorer scorer = weight.Scorer(subReaders[i], !collector.AcceptsDocsOutOfOrder, true);
					if (scorer != null)
					{
						scorer.Score(collector);
					}
				}
			}
			else
			{
				for (int i = 0; i < subReaders.Length; i++)
				{
					// search each subreader
					collector.SetNextReader(subReaders[i], docStarts[i]);
					SearchWithFilter(subReaders[i], weight, filter, collector);
				}
			}
		}
Ejemplo n.º 13
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;
		}
Ejemplo n.º 14
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);
			}
		}
Ejemplo n.º 15
0
 /// <summary>Lower-level search API.
 ///
 /// <p/><see cref="Collector.Collect(int)" /> is called for every matching
 /// document.
 /// <br/>Collector-based access to remote indexes is discouraged.
 ///
 /// <p/>Applications should only use this if they need <i>all</i> of the
 /// matching documents.  The high-level search API (<see cref="Searcher.Search(Query, Filter, int)" />)
 /// is usually more efficient, as it skips
 /// non-high-scoring hits.
 ///
 /// </summary>
 /// <param name="query">to match documents
 /// </param>
 /// <param name="filter">if non-null, used to permit documents to be collected.
 /// </param>
 /// <param name="results">to receive hits
 /// </param>
 /// <throws>  BooleanQuery.TooManyClauses </throws>
 public virtual void  Search(Query query, Filter filter, Collector results)
 {
     Search(CreateWeight(query), filter, results);
 }
Ejemplo n.º 16
0
			public SubScorer(Scorer scorer, bool required, bool prohibited, Collector collector, SubScorer next)
			{
				this.scorer = scorer;
				this.required = required;
				this.prohibited = prohibited;
				this.collector = collector;
				this.next = next;
			}
 public PositiveScoresOnlyCollector(Collector c)
 {
     this.c = c;
 }
Ejemplo n.º 18
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;
		}
Ejemplo n.º 19
0
		/// <summary>Lower-level search API.
		/// 
		/// <p/><see cref="Collector.Collect(int)" /> is called for every matching document.
		/// 
		/// <p/>Applications should only use this if they need <i>all</i> of the
		/// matching documents.  The high-level search API (<see cref="Searcher.Search(Query, int)" />)
		/// is usually more efficient, as it skips
		/// non-high-scoring hits.
		/// <p/>This method cannot be parallelized, because <see cref="Collector"/>
		/// supports no concurrent access.
		/// </summary>
		/// <param name="weight">to match documents
		/// </param>
		/// <param name="filter">if non-null, a bitset used to eliminate some documents
		/// </param>
		/// <param name="collector">to receive hits
		/// 
		/// TODO: parallelize this one too
		/// </param>
		public override void  Search(Weight weight, Filter filter, Collector collector)
		{
			for (int i = 0; i < searchables.Length; i++)
			{
				
				int start = starts[i];
				
				Collector hc = new AnonymousClassCollector1(collector, start, this);
				
				searchables[i].Search(weight, filter, hc);
			}
		}
Ejemplo n.º 20
0
			public override void  Search(Weight weight, Filter filter, Collector results)
			{
				throw new System.NotSupportedException();
			}