public override void Collect(int doc) { if (m_curDocs == null) { // Cache was too large cachedScorer.score = scorer.GetScore(); cachedScorer.doc = doc; m_other.Collect(doc); return; } // Allocate a bigger array or abort caching if (m_upto == m_curDocs.Length) { m_base += m_upto; // Compute next array length - don't allocate too big arrays int nextLength = 8 * m_curDocs.Length; if (nextLength > MAX_ARRAY_SIZE) { nextLength = MAX_ARRAY_SIZE; } if (m_base + nextLength > m_maxDocsToCache) { // try to allocate a smaller array nextLength = m_maxDocsToCache - m_base; if (nextLength <= 0) { // Too many docs to collect -- clear cache m_curDocs = null; curScores = null; m_cachedSegs.Clear(); m_cachedDocs.Clear(); cachedScores.Clear(); cachedScorer.score = scorer.GetScore(); cachedScorer.doc = doc; m_other.Collect(doc); return; } } m_curDocs = new int[nextLength]; m_cachedDocs.Add(m_curDocs); curScores = new float[nextLength]; cachedScores.Add(curScores); m_upto = 0; } m_curDocs[m_upto] = doc; cachedScorer.score = curScores[m_upto] = scorer.GetScore(); m_upto++; cachedScorer.doc = doc; m_other.Collect(doc); }
public virtual void Collect(int doc) { if (scorer.GetScore() > 0) { c.Collect(doc); } }
public override float GetScore() { coordinator.nrMatchers = 0; float sum = countingSumScorer.GetScore(); return(sum * coordinator.coordFactors[coordinator.nrMatchers]); }
public override float GetScore() { int doc = scorer.DocID; if (doc != curDoc) { curScore = scorer.GetScore(); curDoc = doc; } return(curScore); }
protected override void AfterNext() { Scorer sub = m_subScorers[0]; m_doc = sub.DocID; if (m_doc != NO_MORE_DOCS) { m_score = sub.GetScore(); m_nrMatchers = 1; CountMatches(1); CountMatches(2); } }
public void Collect(int doc) { BucketTable table = bucketTable; int i = doc & BucketTable.MASK; Bucket bucket = table.buckets[i]; if (bucket.Doc != doc) // invalid bucket { bucket.Doc = doc; // set doc bucket.Score = scorer.GetScore(); // initialize score bucket.Bits = mask; // initialize mask bucket.Coord = 1; // initialize coord bucket.Next = table.first; // push onto valid list table.first = bucket; } // valid bucket else { bucket.Score += scorer.GetScore(); // increment score bucket.Bits |= mask; // add bits in mask bucket.Coord++; // increment coord } }
public override float GetScore() { int doc = DocID; if (doc >= lastScoredDoc) { if (doc > lastScoredDoc) { lastDocScore = scorer.GetScore(); lastScoredDoc = doc; } outerInstance.coordinator.nrMatchers++; } return(lastDocScore); }
/// <summary> /// Returns the score of the current document matching the query. /// Initially invalid, until <see cref="NextDoc()"/> is called the first time. </summary> /// <returns> The score of the required scorer, eventually increased by the score /// of the optional scorer when it also matches the current document. </returns> public override float GetScore() { // TODO: sum into a double and cast to float if we ever send required clauses to BS1 int curDoc = reqScorer.DocID; float reqScore = reqScorer.GetScore(); if (optScorer == null) { return(reqScore); } int optScorerDoc = optScorer.DocID; if (optScorerDoc < curDoc && (optScorerDoc = optScorer.Advance(curDoc)) == NO_MORE_DOCS) { optScorer = null; return(reqScore); } return(optScorerDoc == curDoc ? reqScore + optScorer.GetScore() : reqScore); }
public override sealed float GetScore() { return(scorer.GetScore()); }
/// <summary> /// Returns the score of the current document matching the query. /// Initially invalid, until <see cref="NextDoc()"/> is called the first time. </summary> /// <returns> The score of the required scorer. </returns> public override float GetScore() { return(reqScorer.GetScore()); // reqScorer may be null when next() or skipTo() already return false }
public override TopDocs Rescore(IndexSearcher searcher, TopDocs firstPassTopDocs, int topN) { ScoreDoc[] hits = (ScoreDoc[])firstPassTopDocs.ScoreDocs.Clone(); Array.Sort(hits, Comparer <ScoreDoc> .Create((a, b) => a.Doc - b.Doc)); IList <AtomicReaderContext> leaves = searcher.IndexReader.Leaves; Weight weight = searcher.CreateNormalizedWeight(query); // Now merge sort docIDs from hits, with reader's leaves: int hitUpto = 0; int readerUpto = -1; int endDoc = 0; int docBase = 0; Scorer scorer = null; while (hitUpto < hits.Length) { ScoreDoc hit = hits[hitUpto]; int docID = hit.Doc; AtomicReaderContext readerContext = null; while (docID >= endDoc) { readerUpto++; readerContext = leaves[readerUpto]; endDoc = readerContext.DocBase + readerContext.Reader.MaxDoc; } if (readerContext != null) { // We advanced to another segment: docBase = readerContext.DocBase; scorer = weight.GetScorer(readerContext, null); } int targetDoc = docID - docBase; int actualDoc = scorer.DocID; if (actualDoc < targetDoc) { actualDoc = scorer.Advance(targetDoc); } if (actualDoc == targetDoc) { // Query did match this doc: hit.Score = Combine(hit.Score, true, scorer.GetScore()); } else { // Query did not match this doc: if (Debugging.AssertsEnabled) { Debugging.Assert(actualDoc > targetDoc); } hit.Score = Combine(hit.Score, false, 0.0f); } hitUpto++; } // TODO: we should do a partial sort (of only topN) // instead, but typically the number of hits is // smallish: Array.Sort(hits, Comparer <ScoreDoc> .Create((a, b) => { // Sort by score descending, then docID ascending: if (a.Score > b.Score) { return(-1); } else if (a.Score < b.Score) { return(1); } else { // this subtraction can't overflow int // because docIDs are >= 0: return(a.Doc - b.Doc); } })); if (topN < hits.Length) { ScoreDoc[] subset = new ScoreDoc[topN]; Array.Copy(hits, 0, subset, 0, topN); hits = subset; } return(new TopDocs(firstPassTopDocs.TotalHits, hits, hits[0].Score)); }