示例#1
0
 /// <summary>
 /// Constructor. </summary>
 /// <param name="innerSet"> Underlying DocIdSet </param>
 /// <param name="acceptDocs"> Allowed docs, all docids not in this set will not be returned by this DocIdSet </param>
 public BitsFilteredDocIdSet(DocIdSet innerSet, Bits acceptDocs)
     : base(innerSet)
 {
     if (acceptDocs == null)
     {
         throw new System.NullReferenceException("acceptDocs is null");
     }
     this.AcceptDocs = acceptDocs;
 }
		internal virtual int GetDocIdSetSize(DocIdSet docIdSet)
		{
			int size = 0;
			DocIdSetIterator it = docIdSet.Iterator();
			while (it.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
			{
				size++;
			}
			return size;
		}
示例#3
0
			public GeoHashFilteredDocIdSet(DocIdSet innerSet, string[] geoHashValues, Dictionary<string, double> distanceLookupCache, double lat, double lng, int docBase, double distance, Dictionary<int, double> distances) : base(innerSet)
			{
				_geoHashValues = geoHashValues;
				_distances = distances;
				_distance = distance;
				_docBase = docBase;
				_lng = lng;
				_lat = lat;
				_distanceLookupCache = distanceLookupCache;
			}
        private HashSet<int> DocIdSetToHashSet(DocIdSet docs)
        {
            var result = new HashSet<int>();
                var iterator = docs.Iterator();

                int docId;
                while ((docId = iterator.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                    result.Add(docId);

                return result;
        }
示例#5
0
			public LatLongFilteredDocIdSet(DocIdSet innerSet, double[] latIndex, double[] lngIndex, Dictionary<string, double> distanceLookupCache, double lat, double lng, double distance, int docBase, Dictionary<int, double> distances)
				: base(innerSet)
			{
				_latIndex = latIndex;
				_distances = distances;
				_docBase = docBase;
				_distance = distance;
				_lng = lng;
				_lat = lat;
				_distanceLookupCache = distanceLookupCache;
				_lngIndex = lngIndex;
			}
			public LatLongFilteredDocIdSet(DocIdSet innerSet, double[] latIndex, double[] lngIndex, Dictionary<string, double> distanceLookupCache, double lat, double lng, double distance, int docBase, Dictionary<int, double> distances)
                : base(innerSet, (int docid) => /* was: public override Match */
                {
                    double x = latIndex[docid];
                    double y = lngIndex[docid];

                    string ck = x + "," + y;
                    double cachedDistance = distanceLookupCache.ContainsKey(ck) ? distanceLookupCache[ck] : 0;

                    double d;
                    if (cachedDistance > 0)
                    {
                        d = cachedDistance;
                    }
                    else
                    {
                        d = DistanceUtils.GetInstance().GetDistanceMi(lat, lng, x, y);
                        distanceLookupCache[ck] = d;
                    }

                    if (d < distance)
                    {
                        // Save distances, so they can be pulled for
                        // sorting after filtering is done:
                        distances[docid + docBase] = d;
                        return true;
                    }

                    return false;
                })
			{
				_latIndex = latIndex;
				_distances = distances;
				_docBase = docBase;
				_distance = distance;
				_lng = lng;
				_lat = lat;
				_distanceLookupCache = distanceLookupCache;
				_lngIndex = lngIndex;
			}
			public GeoHashFilteredDocIdSet(DocIdSet innerSet, string[] geoHashValues, Dictionary<string, double> distanceLookupCache, double lat, double lng, int docBase, double distance, Dictionary<int, double> distances) 
                : base(innerSet , (docid) => /* was: public override Match */
			{
				String geoHash = geoHashValues[docid];
				double[] coords = GeoHashUtils.Decode(geoHash);
				double x = coords[0];
				double y = coords[1];

                Double cachedDistance = 0;
                distanceLookupCache.TryGetValue(geoHash, out cachedDistance);
				double d;

				if (cachedDistance > 0)
				{
					d = cachedDistance;
				}
				else
				{
					d = DistanceUtils.GetInstance().GetDistanceMi(lat, lng, x, y);
					distanceLookupCache[geoHash] = d;
				}

				if (d < distance)
				{
					distances[docid + docBase] = d;
					return true;
				}
				
				return false;
			})
			{
				_geoHashValues = geoHashValues;
				_distances = distances;
				_distance = distance;
				_docBase = docBase;
				_lng = lng;
				_lat = lat;
				_distanceLookupCache = distanceLookupCache;
			}
        protected override DocIdSet DocIdSetToCache(DocIdSet docIdSet, AtomicReader reader)
        {
            if (docIdSet == null)
            {
                return EMPTY_DOCIDSET;
            }

            if (docIdSet is FixedBitSet)
            {
                // this is different from CachingWrapperFilter: even when the DocIdSet is
                // cacheable, we convert it to a FixedBitSet since we require all the
                // cached filters to be FixedBitSets
                return docIdSet;
            }

            DocIdSetIterator it = docIdSet.GetIterator();
            if (it == null)
            {
                return EMPTY_DOCIDSET;
            }
            FixedBitSet copy = new FixedBitSet(reader.MaxDoc);
            copy.Or(it);
            return copy;
        }
 /// <summary> Constructor.</summary>
 /// <param name="innerSet">Underlying DocIdSet
 /// </param>
 public FilteredDocIdSet(DocIdSet innerSet)
 {
     _innerSet = innerSet;
 }
示例#10
0
 /// <summary>
 /// Convenience wrapper method: If {@code acceptDocs == null} it returns the original set without wrapping. </summary>
 /// <param name="set"> Underlying DocIdSet. If {@code null}, this method returns {@code null} </param>
 /// <param name="acceptDocs"> Allowed docs, all docids not in this set will not be returned by this DocIdSet.
 /// If {@code null}, this method returns the original set without wrapping. </param>
 public static DocIdSet Wrap(DocIdSet set, Bits acceptDocs)
 {
     return (set == null || acceptDocs == null) ? set : new BitsFilteredDocIdSet(set, acceptDocs);
 }
 /// <summary>
 /// Sole constructor.
 /// </summary>
 public MatchingDocs(AtomicReaderContext context, DocIdSet bits, int totalHits, float[] scores)
 {
     this.Context = context;
     this.Bits = bits;
     this.Scores = scores;
     this.TotalHits = totalHits;
 }
示例#12
0
 public NotDocIdSet(DocIdSet docSet, int maxVal)
 {
     innerSet = docSet;
     max = maxVal;
 }
		/// <summary> Constructor.</summary>
		/// <param name="innerSet">Underlying DocIdSet
		/// </param>
		public FilteredDocIdSet(DocIdSet innerSet,Func<int,bool> match)
		{
			_innerSet = innerSet;
            this.Match = match;
		}
示例#14
0
 public override BulkScorer FilteredBulkScorer(AtomicReaderContext context, Weight weight, bool scoreDocsInOrder, DocIdSet docIdSet) // ignored (we always top-score in order)
 {
     Bits filterAcceptDocs = docIdSet.GetBits();
     if (filterAcceptDocs == null)
     {
         // Filter does not provide random-access Bits; we
         // must fallback to leapfrog:
         return LEAP_FROG_QUERY_FIRST_STRATEGY.FilteredBulkScorer(context, weight, scoreDocsInOrder, docIdSet);
     }
     Scorer scorer = weight.Scorer(context, null);
     return scorer == null ? null : new QueryFirstBulkScorer(scorer, filterAcceptDocs);
 }
		private IList<PositionInfo> positions; //Spans spans;
		
		/// <summary> </summary>
		/// <param name="docIdSet">The DocIdSet for the Filter
		/// </param>
		/// <param name="positions">A List of <see cref="Lucene.Net.Search.SpanFilterResult.PositionInfo" /> objects
		/// </param>
		public SpanFilterResult(DocIdSet docIdSet, IList<PositionInfo> positions)
		{
			this.docIdSet = docIdSet;
			this.positions = positions;
		}
示例#16
0
 public ValueSourceFilteredDocIdSet(DocIdSet innerSet, FunctionValues values, ValueSourceFilter caller)
     : base(innerSet)
 {
     this.enclosingFilter = caller;
     this.values = values;
 }
示例#17
0
 public FilteredDocIdSetAnonymousInnerClassHelper2(FilterAnonymousInnerClassHelper2 outerInstance, DocIdSet innerNullIteratorSet)
     : base(innerNullIteratorSet)
 {
     this.OuterInstance = outerInstance;
 }
示例#18
0
            public override BulkScorer FilteredBulkScorer(AtomicReaderContext context, Weight weight, bool scoreDocsInOrder, DocIdSet docIdSet) // ignored (we always top-score in order)
            {
                IBits filterAcceptDocs = docIdSet.Bits;

                if (filterAcceptDocs == null)
                {
                    // Filter does not provide random-access Bits; we
                    // must fallback to leapfrog:
                    return(LEAP_FROG_QUERY_FIRST_STRATEGY.FilteredBulkScorer(context, weight, scoreDocsInOrder, docIdSet));
                }
                Scorer scorer = weight.GetScorer(context, null);

                return(scorer == null ? null : new QueryFirstBulkScorer(scorer, filterAcceptDocs));
            }
示例#19
0
            public override Scorer FilteredScorer(AtomicReaderContext context, Weight weight, DocIdSet docIdSet)
            {
                IBits filterAcceptDocs = docIdSet.Bits;

                if (filterAcceptDocs == null)
                {
                    // Filter does not provide random-access Bits; we
                    // must fallback to leapfrog:
                    return(LEAP_FROG_QUERY_FIRST_STRATEGY.FilteredScorer(context, weight, docIdSet));
                }
                Scorer scorer = weight.GetScorer(context, null);

                return(scorer == null ? null : new QueryFirstScorer(weight, filterAcceptDocs, scorer));
            }
示例#20
0
 /// <summary>
 /// Constructor. </summary>
 /// <param name="innerSet"> Underlying <see cref="DocIdSet"/> </param>
 /// <param name="acceptDocs"> Allowed docs, all docids not in this set will not be returned by this <see cref="DocIdSet"/> </param>
 public BitsFilteredDocIdSet(DocIdSet innerSet, IBits acceptDocs)
     : base(innerSet)
 {
     this.acceptDocs = acceptDocs ?? throw new ArgumentNullException(nameof(acceptDocs), "acceptDocs can not be null"); // LUCENENET specific - changed from IllegalArgumentException to ArgumentNullException (.NET convention)
 }
示例#21
0
 /// <summary>
 /// Convenience wrapper method: If <c>acceptDocs == null</c> it returns the original set without wrapping. </summary>
 /// <param name="set"> Underlying DocIdSet. If <c>null</c>, this method returns <c>null</c> </param>
 /// <param name="acceptDocs"> Allowed docs, all docids not in this set will not be returned by this <see cref="DocIdSet"/>.
 /// If <c>null</c>, this method returns the original set without wrapping. </param>
 public static DocIdSet Wrap(DocIdSet set, IBits acceptDocs)
 {
     return((set == null || acceptDocs == null) ? set : new BitsFilteredDocIdSet(set, acceptDocs));
 }
示例#22
0
 public AnonymousFilteredDocIdSet(DocIdSet innerSet, IndexReader r) : base(innerSet)
 {
     this.r = r;
 }
示例#23
0
 public FilteredDocIdSetAnonymousInnerClassHelper(TestDocIdSet outerInstance, DocIdSet innerSet)
     : base(innerSet)
 {
     this.OuterInstance = outerInstance;
 }
示例#24
0
 /// <summary> Constructor.</summary>
 /// <param name="innerSet">Underlying DocIdSet
 /// </param>
 public FilteredDocIdSet(DocIdSet innerSet)
 {
     _innerSet = innerSet;
 }
示例#25
0
 public override Scorer FilteredScorer(AtomicReaderContext context, Weight weight, DocIdSet docIdSet)
 {
     Bits filterAcceptDocs = docIdSet.GetBits();
     if (filterAcceptDocs == null)
     {
         // Filter does not provide random-access Bits; we
         // must fallback to leapfrog:
         return LEAP_FROG_QUERY_FIRST_STRATEGY.FilteredScorer(context, weight, docIdSet);
     }
     Scorer scorer = weight.Scorer(context, null);
     return scorer == null ? null : new QueryFirstScorer(weight, filterAcceptDocs, scorer);
 }
示例#26
0
 public JustCompileFilteredDocIdSet(DocIdSet innerSet)
     : base(innerSet)
 {
 }
 public RandomAccessAndFilterSet(RandomAccessDocIdSet[] randomAccessDocIdSets, DocIdSet andDocIdSet)
 {
     this.randomAccessDocIdSets = randomAccessDocIdSets;
     this.andDocIdSet = andDocIdSet;
 }
示例#28
0
        /// <summary>
        /// Get the id set for the filter.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>The filter set to use.</returns>
        public override DocIdSet GetDocIdSet(IndexReader reader)
        {
            OpenBitSetDISI res = null;

            if (shouldFilters != null)
            {
                for (int i = 0; i < shouldFilters.Count; i++)
                {
                    if (res == null)
                    {
                        res = new OpenBitSetDISI(GetDISI(shouldFilters, i, reader), reader.MaxDoc());
                    }
                    else
                    {
                        DocIdSet dis = ((Filter)shouldFilters[i]).GetDocIdSet(reader);
                        if (dis is OpenBitSet)
                        {
                            // optimized case for OpenBitSets
                            res.Or((OpenBitSet)dis);
                        }
                        else
                        {
                            res.InPlaceOr(GetDISI(shouldFilters, i, reader));
                        }
                    }
                }
            }

            if (notFilters != null)
            {
                for (int i = 0; i < notFilters.Count; i++)
                {
                    if (res == null)
                    {
                        res = new OpenBitSetDISI(GetDISI(notFilters, i, reader), reader.MaxDoc());
                        res.Flip(0, reader.MaxDoc()); // NOTE: may set bits on deleted docs
                    }
                    else
                    {
                        DocIdSet dis = ((Filter)notFilters[i]).GetDocIdSet(reader);
                        if (dis is OpenBitSet)
                        {
                            // optimized case for OpenBitSets
                            res.AndNot((OpenBitSet)dis);
                        }
                        else
                        {
                            res.InPlaceNot(GetDISI(notFilters, i, reader));
                        }
                    }
                }
            }

            if (mustFilters != null)
            {
                for (int i = 0; i < mustFilters.Count; i++)
                {
                    if (res == null)
                    {
                        res = new OpenBitSetDISI(GetDISI(mustFilters, i, reader), reader.MaxDoc());
                    }
                    else
                    {
                        DocIdSet dis = ((Filter)mustFilters[i]).GetDocIdSet(reader);
                        if (dis is OpenBitSet)
                        {
                            // optimized case for OpenBitSets
                            res.And((OpenBitSet)dis);
                        }
                        else
                        {
                            res.InPlaceAnd(GetDISI(mustFilters, i, reader));
                        }
                    }
                }
            }

            if (res != null)
            {
                return(FinalResult(res, reader.MaxDoc()));
            }

            else
            {
                //TODO: 2.- change return DocIdSet.EMPTY_DOCIDSET;
                return(null);
            }
        }
示例#29
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private void doChain(org.apache.lucene.util.FixedBitSet result, int logic, org.apache.lucene.search.DocIdSet dis) throws java.io.IOException
        private void doChain(FixedBitSet result, int logic, DocIdSet dis)
        {
            if (dis is FixedBitSet)
            {
                // optimized case for FixedBitSets
                switch (logic)
                {
                    case OR:
                        result.Or((FixedBitSet)dis);
                        break;
                    case AND:
                        result.And((FixedBitSet)dis);
                        break;
                    case ANDNOT:
                        result.AndNot((FixedBitSet)dis);
                        break;
                    case XOR:
                        result.Xor((FixedBitSet)dis);
                        break;
                    default:
                        doChain(result, DEFAULT, dis);
                        break;
                }
            }
            else
            {
                DocIdSetIterator disi;
                if (dis == null)
                {
                    disi = DocIdSetIterator.Empty();
                }
                else
                {
                    disi = dis.GetIterator() ?? DocIdSetIterator.Empty();
                }

                switch (logic)
                {
                    case OR:
                        result.Or(disi);
                        break;
                    case AND:
                        result.And(disi);
                        break;
                    case ANDNOT:
                        result.AndNot(disi);
                        break;
                    case XOR:
                        result.Xor(disi);
                        break;
                    default:
                        doChain(result, DEFAULT, dis);
                        break;
                }
            }
        }
示例#30
0
 /// <summary>
 /// Returns a filtered <seealso cref="Scorer"/> based on this strategy.
 /// </summary>
 /// <param name="context">
 ///          the <seealso cref="AtomicReaderContext"/> for which to return the <seealso cref="Scorer"/>. </param>
 /// <param name="weight"> the <seealso cref="FilteredQuery"/> <seealso cref="Weight"/> to create the filtered scorer. </param>
 /// <param name="docIdSet"> the filter <seealso cref="DocIdSet"/> to apply </param>
 /// <returns> a filtered scorer
 /// </returns>
 /// <exception cref="IOException"> if an <seealso cref="IOException"/> occurs </exception>
 public abstract Scorer FilteredScorer(AtomicReaderContext context, Weight weight, DocIdSet docIdSet);
示例#31
0
 public FilteredDocIdSetAnonymousClass2(FilterAnonymousClass2 outerInstance, DocIdSet innerNullIteratorSet)
     : base(innerNullIteratorSet)
 {
     this.outerInstance = outerInstance;
 }
示例#32
0
            /// <summary>
            /// Returns a filtered <seealso cref="BulkScorer"/> based on this
            /// strategy.  this is an optional method: the default
            /// implementation just calls <seealso cref="#filteredScorer"/> and
            /// wraps that into a BulkScorer.
            /// </summary>
            /// <param name="context">
            ///          the <seealso cref="AtomicReaderContext"/> for which to return the <seealso cref="Scorer"/>. </param>
            /// <param name="weight"> the <seealso cref="FilteredQuery"/> <seealso cref="Weight"/> to create the filtered scorer. </param>
            /// <param name="docIdSet"> the filter <seealso cref="DocIdSet"/> to apply </param>
            /// <returns> a filtered top scorer </returns>
            public virtual BulkScorer FilteredBulkScorer(AtomicReaderContext context, Weight weight, bool scoreDocsInOrder, DocIdSet docIdSet)
            {
                Scorer scorer = FilteredScorer(context, weight, docIdSet);

                if (scorer == null)
                {
                    return(null);
                }
                // this impl always scores docs in order, so we can
                // ignore scoreDocsInOrder:
                return(new Weight.DefaultBulkScorer(scorer));
            }
		/// <summary> </summary>
		/// <param name="docIdSet">The DocIdSet for the Filter
		/// </param>
		/// <param name="positions">A List of {@link Lucene.Net.Search.SpanFilterResult.PositionInfo} objects
		/// </param>
		public SpanFilterResult(DocIdSet docIdSet, System.Collections.IList positions)
		{
			this.docIdSet = docIdSet;
			this.positions = positions;
		}
示例#34
0
            public override Scorer FilteredScorer(AtomicReaderContext context, Weight weight, DocIdSet docIdSet)
            {
                DocIdSetIterator filterIter = docIdSet.GetIterator();

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

                int firstFilterDoc = filterIter.NextDoc();

                if (firstFilterDoc == DocIdSetIterator.NO_MORE_DOCS)
                {
                    return(null);
                }

                IBits filterAcceptDocs = docIdSet.Bits;
                // force if RA is requested
                bool useRandomAccess = filterAcceptDocs != null && UseRandomAccess(filterAcceptDocs, firstFilterDoc);

                if (useRandomAccess)
                {
                    // if we are using random access, we return the inner scorer, just with other acceptDocs
                    return(weight.GetScorer(context, filterAcceptDocs));
                }
                else
                {
                    Debug.Assert(firstFilterDoc > -1);
                    // we are gonna advance() this scorer, so we set inorder=true/toplevel=false
                    // we pass null as acceptDocs, as our filter has already respected acceptDocs, no need to do twice
                    Scorer scorer = weight.GetScorer(context, null);
                    // TODO once we have way to figure out if we use RA or LeapFrog we can remove this scorer
                    return((scorer == null) ? null : new PrimaryAdvancedLeapFrogScorer(weight, firstFilterDoc, filterIter, scorer));
                }
            }
示例#35
0
 public FilteredDocIdSetAnonymousClass(TestDocIdSet outerInstance, DocIdSet innerSet)
     : base(innerSet)
 {
     this.outerInstance = outerInstance;
 }
示例#36
0
            public override Scorer FilteredScorer(AtomicReaderContext context, Weight weight, DocIdSet docIdSet)
            {
                DocIdSetIterator filterIter = docIdSet.GetIterator();

                if (filterIter == null)
                {
                    // this means the filter does not accept any documents.
                    return(null);
                }
                // we pass null as acceptDocs, as our filter has already respected acceptDocs, no need to do twice
                Scorer scorer = weight.GetScorer(context, null);

                if (scorer == null)
                {
                    return(null);
                }

                if (scorerFirst)
                {
                    return(new LeapFrogScorer(weight, scorer, filterIter, scorer));
                }
                else
                {
                    return(new LeapFrogScorer(weight, filterIter, scorer, scorer));
                }
            }
示例#37
0
		static DocIdSet()
		{
			EMPTY_DOCIDSET = new AnonymousClassDocIdSet();
		}
示例#38
0
        private void doChain(OpenBitSetDISI result, int logic, DocIdSet dis)
        {

            if (dis is OpenBitSet)
            {
                // optimized case for OpenBitSets
                switch (logic)
                {
                    case OR:
                        result.Or((OpenBitSet)dis);
                        break;
                    case AND:
                        result.And((OpenBitSet)dis);
                        break;
                    case ANDNOT:
                        result.AndNot((OpenBitSet)dis);
                        break;
                    case XOR:
                        result.Xor((OpenBitSet)dis);
                        break;
                    default:
                        doChain(result, DEFAULT, dis);
                        break;
                }
            }
            else
            {
                DocIdSetIterator disi;
                if (dis == null)
                {
                    disi = DocIdSet.EMPTY_DOCIDSET.Iterator();
                }
                else
                {
                    disi = dis.Iterator();
                    if (disi == null)
                    {
                        disi = DocIdSet.EMPTY_DOCIDSET.Iterator();
                    }
                }

                switch (logic)
                {
                    case OR:
                        result.InPlaceOr(disi);
                        break;
                    case AND:
                        result.InPlaceAnd(disi);
                        break;
                    case ANDNOT:
                        result.InPlaceNot(disi);
                        break;
                    case XOR:
                        result.InPlaceXor(disi);
                        break;
                    default:
                        doChain(result, DEFAULT, dis);
                        break;
                }
            }
        }
        public virtual DocIdSet Parse(SelectionNode[] selectionNodes, SelectionNode[] notSelectionNodes, int maxDoc)
        {
            DocIdSet docSet = null;
            DocIdSet selSet = null;

            if (selectionNodes != null && selectionNodes.Length > 0)
            {
                List<DocIdSet> selSetList = new List<DocIdSet>(selectionNodes.Length);
                foreach (SelectionNode selectionNode in selectionNodes)
                {
                    DocIdSet ds = selectionNode.DocSet;

                    if (ds != null)
                    {
                        selSetList.Add(ds);
                    }
                }

                if (selSetList.Count > 0)
                {
                    if (selSetList.Count == 1)
                    {
                        selSet = selSetList[0];
                    }
                    else
                    {
                        selSet = new AndDocIdSet(selSetList);
                    }
                }
            }

            DocIdSet notSelSet = null;

            if (notSelectionNodes != null && notSelectionNodes.Length > 0)
            {
                List<DocIdSet> notSelSetList = new List<DocIdSet>(notSelectionNodes.Length);
                foreach (SelectionNode selectionNode in notSelectionNodes)
                {
                    DocIdSet ds = selectionNode.DocSet;

                    if (ds != null)
                    {
                        notSelSetList.Add(ds);
                    }

                    if (notSelSetList.Count > 0)
                    {
                        if (notSelSetList.Count == 1)
                        {
                            notSelSet = notSelSetList[0];
                        }
                        else
                        {
                            notSelSet = new OrDocIdSet(notSelSetList);
                        }
                    }
                }
            }

            if (notSelSet != null)
            {
                notSelSet = new NotDocIdSet(notSelSet, maxDoc);
            }

            if (selSet != null && notSelSet != null)
            {
                DocIdSet[] sets = new DocIdSet[] { selSet, notSelSet };
                docSet = new AndDocIdSet(sets.ToList());
            }
            else if (selSet != null)
            {
                docSet = selSet;
            }
            else if (notSelSet != null)
            {
                docSet = notSelSet;
            }

            return docSet;
        }
示例#40
0
 public FilteredDocIdSetAnonymousInnerClassHelper(TestDocIdSet outerInstance, DocIdSet innerSet)
     : base(innerSet)
 {
     this.OuterInstance = outerInstance;
 }
		/// <summary>Provide the DocIdSet to be cached, using the DocIdSet provided
		/// by the wrapped Filter.
		/// This implementation returns the given DocIdSet.
		/// </summary>
		protected internal virtual DocIdSet DocIdSetToCache(DocIdSet docIdSet, IndexReader reader)
		{
			if (docIdSet.IsCacheable())
			{
				return docIdSet;
			}
			else
			{
				DocIdSetIterator it = docIdSet.Iterator();
				// null is allowed to be returned by iterator(),
				// in this case we wrap with the empty set,
				// which is cacheable.
				return (it == null) ? DocIdSet.EMPTY_DOCIDSET : new OpenBitSetDISI(it, reader.MaxDoc());
			}
		}
示例#42
0
 /// <summary>
 /// Constructor. </summary>
 /// <param name="innerSet"> Underlying <see cref="DocIdSet"/> </param>
 public FilteredDocIdSet(DocIdSet innerSet)
 {
     this.innerSet = innerSet;
 }
		public virtual void  AssertContainsDocId(System.String msg, DocIdSet docIdSet, int docId)
		{
			DocIdSetIterator it = docIdSet.Iterator();
			Assert.IsTrue(it.Advance(docId) != DocIdSetIterator.NO_MORE_DOCS, msg);
			Assert.IsTrue(it.DocID() == docId, msg);
		}
示例#44
0
            public override Scorer FilteredScorer(AtomicReaderContext context, Weight weight, DocIdSet docIdSet)
            {
                DocIdSetIterator filterIter = docIdSet.GetIterator();
                if (filterIter == null)
                {
                    // this means the filter does not accept any documents.
                    return null;
                }

                int firstFilterDoc = filterIter.NextDoc();
                if (firstFilterDoc == DocIdSetIterator.NO_MORE_DOCS)
                {
                    return null;
                }

                Bits filterAcceptDocs = docIdSet.GetBits();
                // force if RA is requested
                bool useRandomAccess = filterAcceptDocs != null && UseRandomAccess(filterAcceptDocs, firstFilterDoc);
                if (useRandomAccess)
                {
                    // if we are using random access, we return the inner scorer, just with other acceptDocs
                    return weight.Scorer(context, filterAcceptDocs);
                }
                else
                {
                    Debug.Assert(firstFilterDoc > -1);
                    // we are gonna advance() this scorer, so we set inorder=true/toplevel=false
                    // we pass null as acceptDocs, as our filter has already respected acceptDocs, no need to do twice
                    Scorer scorer = weight.Scorer(context, null);
                    // TODO once we have way to figure out if we use RA or LeapFrog we can remove this scorer
                    return (scorer == null) ? null : new PrimaryAdvancedLeapFrogScorer(weight, firstFilterDoc, filterIter, scorer);
                }
            }
示例#45
0
 public FilteredDocIdSetAnonymousInnerClassHelper2(FilterAnonymousInnerClassHelper2 outerInstance, DocIdSet innerNullIteratorSet)
     : base(innerNullIteratorSet)
 {
     this.OuterInstance = outerInstance;
 }
示例#46
0
            public override Scorer FilteredScorer(AtomicReaderContext context, Weight weight, DocIdSet docIdSet)
            {
                DocIdSetIterator filterIter = docIdSet.GetIterator();
                if (filterIter == null)
                {
                    // this means the filter does not accept any documents.
                    return null;
                }
                // we pass null as acceptDocs, as our filter has already respected acceptDocs, no need to do twice
                Scorer scorer = weight.Scorer(context, null);
                if (scorer == null)
                {
                    return null;
                }

                if (ScorerFirst)
                {
                    return new LeapFrogScorer(weight, scorer, filterIter, scorer);
                }
                else
                {
                    return new LeapFrogScorer(weight, filterIter, scorer, scorer);
                }
            }
示例#47
0
			public JustCompileFilteredDocIdSet(DocIdSet innerSet):base(innerSet)
			{
			}
 /// <summary></summary>
 /// <param name="docIdSet">The DocIdSet for the Filter</param>
 /// <param name="positions">A List of {@link Lucene.Net.Search.SpanFilterResult.PositionInfo} objects</param>
 public SpanFilterResult(DocIdSet docIdSet, System.Collections.IList positions)
 {
     this.docIdSet  = docIdSet;
     this.positions = positions;
 }