private void SumValues(IList <MatchingDocs> matchingDocs, bool keepScores, ValueSource valueSource) { FakeScorer scorer = new FakeScorer(); IDictionary context = new Dictionary <string, Scorer>(); if (keepScores) { context["scorer"] = scorer; } Int32sRef scratch = new Int32sRef(); foreach (MatchingDocs hits in matchingDocs) { OrdinalsReader.OrdinalsSegmentReader ords = ordinalsReader.GetReader(hits.Context); int scoresIdx = 0; float[] scores = hits.Scores; FunctionValues functionValues = valueSource.GetValues(context, hits.Context); DocIdSetIterator docs = hits.Bits.GetIterator(); int doc; while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { ords.Get(doc, scratch); if (keepScores) { scorer.docID = doc; scorer.score = scores[scoresIdx++]; } float value = (float)functionValues.DoubleVal(doc); for (int i = 0; i < scratch.Length; i++) { m_values[scratch.Int32s[i]] += value; } } } Rollup(); }
private void Count(IList <FacetsCollector.MatchingDocs> matchingDocs) { Int32sRef scratch = new Int32sRef(); foreach (FacetsCollector.MatchingDocs hits in matchingDocs) { OrdinalsReader.OrdinalsSegmentReader ords = ordinalsReader.GetReader(hits.Context); DocIdSetIterator docs = hits.Bits.GetIterator(); int doc; while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { ords.Get(doc, scratch); for (int i = 0; i < scratch.Length; i++) { m_values[scratch.Int32s[scratch.Offset + i]]++; } } } Rollup(); }