private void Count(ValueSource valueSource, IList <MatchingDocs> matchingDocs) { Int64Range[] ranges = (Int64Range[])this.m_ranges; Int64RangeCounter counter = new Int64RangeCounter(ranges); int missingCount = 0; foreach (MatchingDocs hits in matchingDocs) { FunctionValues fv = valueSource.GetValues(Collections.EmptyMap <string, object>(), hits.Context); m_totCount += hits.TotalHits; IBits bits; if (m_fastMatchFilter != null) { DocIdSet dis = m_fastMatchFilter.GetDocIdSet(hits.Context, null); if (dis is null) { // No documents match continue; } bits = dis.Bits; if (bits is null) { throw new ArgumentException("fastMatchFilter does not implement DocIdSet.Bits"); } } else { bits = null; } DocIdSetIterator docs = hits.Bits.GetIterator(); int doc; while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (bits != null && bits.Get(doc) == false) { doc++; continue; } // Skip missing docs: if (fv.Exists(doc)) { counter.Add(fv.Int64Val(doc)); } else { missingCount++; } } } int x = counter.FillCounts(m_counts); missingCount += x; //System.out.println("totCount " + totCount + " missingCount " + counter.missingCount); m_totCount -= missingCount; }
private void Count(ValueSource valueSource, IEnumerable <MatchingDocs> matchingDocs) { DoubleRange[] ranges = (DoubleRange[])this.m_ranges; Int64Range[] longRanges = new Int64Range[ranges.Length]; for (int i = 0; i < ranges.Length; i++) { DoubleRange range = ranges[i]; longRanges[i] = new Int64Range(range.Label, NumericUtils.DoubleToSortableInt64(range.minIncl), true, NumericUtils.DoubleToSortableInt64(range.maxIncl), true); } Int64RangeCounter counter = new Int64RangeCounter(longRanges); int missingCount = 0; foreach (MatchingDocs hits in matchingDocs) { FunctionValues fv = valueSource.GetValues(new Dictionary <string, object>(), hits.Context); m_totCount += hits.TotalHits; IBits bits; if (m_fastMatchFilter != null) { DocIdSet dis = m_fastMatchFilter.GetDocIdSet(hits.Context, null); if (dis == null) { // No documents match continue; } bits = dis.Bits; if (bits == null) { throw new System.ArgumentException("fastMatchFilter does not implement DocIdSet.bits"); } } else { bits = null; } DocIdSetIterator docs = hits.Bits.GetIterator(); int doc; while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (bits != null && bits.Get(doc) == false) { doc++; continue; } // Skip missing docs: if (fv.Exists(doc)) { counter.Add(NumericUtils.DoubleToSortableInt64(fv.DoubleVal(doc))); } else { missingCount++; } } } missingCount += counter.FillCounts(m_counts); m_totCount -= missingCount; }