Exemplo n.º 1
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));
            }
Exemplo n.º 2
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));
            }
Exemplo n.º 3
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));
                }
            }
Exemplo n.º 4
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));
                }
            }
Exemplo n.º 5
0
            /// <summary>
            /// Returns a filtered <see cref="BulkScorer"/> based on this
            /// strategy.  this is an optional method: the default
            /// implementation just calls <see cref="FilteredScorer(AtomicReaderContext, Weight, DocIdSet)"/> and
            /// wraps that into a <see cref="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="scoreDocsInOrder"> <c>true</c> to score docs in order </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));
            }
Exemplo n.º 6
0
 /// <summary>
 /// Returns a filtered <see cref="Scorer"/> based on this strategy.
 /// </summary>
 /// <param name="context">
 ///          the <see cref="AtomicReaderContext"/> for which to return the <see cref="Scorer"/>. </param>
 /// <param name="weight"> the <see cref="FilteredQuery"/> <see cref="Weight"/> to create the filtered scorer. </param>
 /// <param name="docIdSet"> the filter <see cref="DocIdSet"/> to apply </param>
 /// <returns> a filtered scorer
 /// </returns>
 /// <exception cref="System.IO.IOException"> if an <see cref="System.IO.IOException"/> occurs </exception>
 public abstract Scorer FilteredScorer(AtomicReaderContext context, Weight weight, DocIdSet docIdSet);
Exemplo n.º 7
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");
 }
Exemplo n.º 8
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));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Constructor. </summary>
 /// <param name="innerSet"> Underlying <see cref="DocIdSet"/> </param>
 public FilteredDocIdSet(DocIdSet innerSet)
 {
     this.innerSet = innerSet;
 }