Esempio n. 1
0
        public override DocIdSet GetDocIdSet(IndexReader reader)
        {
            object coreKey    = reader.GetFieldCacheKey();
            object delCoreKey = reader.HasDeletions() ? reader.GetDeletesCacheKey() : coreKey;

            object cached = cache.Get(reader, coreKey, delCoreKey);

            if (cached != null)
            {
                hitCount++;
                if (cached is DocIdSet)
                {
                    return((DocIdSet)cached);
                }
                else
                {
                    return(new DocIdBitSet((System.Collections.BitArray)cached));
                }
            }
            missCount++;
            // cache miss
            DocIdSet docIdSet = DocIdSetToCache(filter.GetDocIdSet(reader), reader);

            if (docIdSet != null)
            {
                cache.Put(coreKey, delCoreKey, docIdSet);
            }

            return(docIdSet);
        }
Esempio n. 2
0
            public override Explanation Explain(IndexReader ir, int i)
            {
                Explanation inner = weight.Explain(ir, i);

                if (Enclosing_Instance.GetBoost() != 1)
                {
                    Explanation preBoost = inner;
                    inner = new Explanation(inner.GetValue() * Enclosing_Instance.GetBoost(), "product of:");
                    inner.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
                    inner.AddDetail(preBoost);
                }
                Filter           f                = Enclosing_Instance.filter;
                DocIdSet         docIdSet         = f.GetDocIdSet(ir);
                DocIdSetIterator docIdSetIterator = docIdSet == null?DocIdSet.EMPTY_DOCIDSET.Iterator() : docIdSet.Iterator();

                if (docIdSetIterator == null)
                {
                    docIdSetIterator = DocIdSet.EMPTY_DOCIDSET.Iterator();
                }
                if (docIdSetIterator.Advance(i) == i)
                {
                    return(inner);
                }
                else
                {
                    Explanation result = new Explanation(0.0f, "failure to match filter: " + f.ToString());
                    result.AddDetail(inner);
                    return(result);
                }
            }
Esempio n. 3
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);
                }
            }
        }
Esempio n. 4
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);
				}
			}
		}