Example #1
0
 public ConstantBulkScorer(ConstantScoreQuery outerInstance, BulkScorer bulkScorer, Weight weight, float theScore)
 {
     this.outerInstance = outerInstance;
     this.bulkScorer    = bulkScorer;
     this.weight        = weight;
     this.theScore      = theScore;
 }
Example #2
0
 /// <summary>
 /// Lower-level search API.
 ///
 /// <para/>
 /// <seealso cref="ICollector.Collect(int)"/> is called for every document.
 ///
 /// <para/>
 /// NOTE: this method executes the searches on all given leaves exclusively.
 /// To search across all the searchers leaves use <see cref="m_leafContexts"/>.
 /// </summary>
 /// <param name="leaves">
 ///          The searchers leaves to execute the searches on </param>
 /// <param name="weight">
 ///          To match documents </param>
 /// <param name="collector">
 ///          To receive hits </param>
 /// <exception cref="BooleanQuery.TooManyClausesException"> If a query would exceed
 ///         <see cref="BooleanQuery.MaxClauseCount"/> clauses. </exception>
 protected virtual void Search(IList <AtomicReaderContext> leaves, Weight weight, ICollector collector)
 {
     // TODO: should we make this
     // threaded...?  the Collector could be sync'd?
     // always use single thread:
     foreach (AtomicReaderContext ctx in leaves) // search each subreader
     {
         try
         {
             collector.SetNextReader(ctx);
         }
         catch (CollectionTerminatedException)
         {
             // there is no doc of interest in this reader context
             // continue with the following leaf
             continue;
         }
         BulkScorer scorer = weight.GetBulkScorer(ctx, !collector.AcceptsDocsOutOfOrder, ctx.AtomicReader.LiveDocs);
         if (scorer != null)
         {
             try
             {
                 scorer.Score(collector);
             }
             catch (CollectionTerminatedException)
             {
                 // collection was terminated prematurely
                 // continue with the following leaf
             }
         }
     }
 }
Example #3
0
 public override BulkScorer GetBulkScorer(AtomicReaderContext context, bool scoreDocsInOrder, IBits acceptDocs)
 {
     //DocIdSetIterator disi;
     if (outerInstance.m_filter != null)
     {
         if (Debugging.AssertsEnabled)
         {
             Debugging.Assert(outerInstance.m_query == null);
         }
         return(base.GetBulkScorer(context, scoreDocsInOrder, acceptDocs));
     }
     else
     {
         if (Debugging.AssertsEnabled)
         {
             Debugging.Assert(outerInstance.m_query != null && innerWeight != null);
         }
         BulkScorer bulkScorer = innerWeight.GetBulkScorer(context, scoreDocsInOrder, acceptDocs);
         if (bulkScorer == null)
         {
             return(null);
         }
         return(new ConstantBulkScorer(outerInstance, bulkScorer, this, queryWeight));
     }
 }
Example #4
0
 public SubScorer(BulkScorer scorer, bool required, bool prohibited, ICollector collector, SubScorer next)
 {
     if (required)
     {
         throw new System.ArgumentException("this scorer cannot handle required=true");
     }
     this.Scorer = scorer;
     this.More   = true;
     // TODO: re-enable this if BQ ever sends us required clauses
     //this.required = required;
     this.Prohibited = prohibited;
     this.Collector  = collector;
     this.Next       = next;
 }
Example #5
0
            public override BulkScorer GetBulkScorer(AtomicReaderContext context, bool scoreDocsInOrder, IBits acceptDocs)
            {
                if (scoreDocsInOrder || outerInstance.m_minNrShouldMatch > 1)
                {
                    // TODO: (LUCENE-4872) in some cases BooleanScorer may be faster for minNrShouldMatch
                    // but the same is even true of pure conjunctions...
                    return(base.GetBulkScorer(context, scoreDocsInOrder, acceptDocs));
                }

                IList <BulkScorer> prohibited = new List <BulkScorer>();
                IList <BulkScorer> optional   = new List <BulkScorer>();

                using (IEnumerator <BooleanClause> cIter = outerInstance.clauses.GetEnumerator())
                {
                    foreach (Weight w in m_weights)
                    {
                        cIter.MoveNext();
                        BooleanClause c         = cIter.Current;
                        BulkScorer    subScorer = w.GetBulkScorer(context, false, acceptDocs);
                        if (subScorer == null)
                        {
                            if (c.IsRequired)
                            {
                                return(null);
                            }
                        }
                        else if (c.IsRequired)
                        {
                            // TODO: there are some cases where BooleanScorer
                            // would handle conjunctions faster than
                            // BooleanScorer2...
                            return(base.GetBulkScorer(context, scoreDocsInOrder, acceptDocs));
                        }
                        else if (c.IsProhibited)
                        {
                            prohibited.Add(subScorer);
                        }
                        else
                        {
                            optional.Add(subScorer);
                        }
                    }
                }

                // Check if we can and should return a BooleanScorer
                return(new BooleanScorer(this, disableCoord, outerInstance.m_minNrShouldMatch, optional, prohibited, m_maxCoord));
            }