From a690896190da8dfd9e15b5facca86cbb6818ef56 Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Fri, 12 Jun 2026 08:18:47 +0200 Subject: [PATCH] clarify counts/term_counts field docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Spell out that `counts` is the flattened per-term × time-bucket grid (each term's own contiguous slice) and that `term_counts` is only needed when the per-term total can't be derived from that grid (i.e. with hard bounds). --- src/aggregation/bucket/term_agg/term_histogram.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/aggregation/bucket/term_agg/term_histogram.rs b/src/aggregation/bucket/term_agg/term_histogram.rs index c50df4fa3..4e661bed6 100644 --- a/src/aggregation/bucket/term_agg/term_histogram.rs +++ b/src/aggregation/bucket/term_agg/term_histogram.rs @@ -41,13 +41,16 @@ const MAX_FUSED_GRID_BUCKETS: usize = 16384; /// general path. #[derive(Debug)] pub(crate) struct SegmentTermHistogramCollector { - /// `[num_terms]` total doc count per term bucket (independent of the histogram bounds). - /// `u32` is enough: a per-segment count can't exceed the segment's doc count (`DocId` is - /// `u32`); the fused path is only taken when `num_docs < u32::MAX` (see - /// `maybe_build_collector`). + /// The counts, indexed by term id. + /// + /// Only used when we can't derive the term counts from `counts`. term_counts: Vec, - /// Flat row-major `[num_terms * num_time_buckets]` histogram counters (`u32`, see + /// Flattened `[num_terms * num_time_buckets]` histogram counters (`u32`, see /// `term_counts`). + /// + /// Each term id get its own contiguous slice of `num_time_buckets` histogram counter. + /// When we count all docs (#nofilter), we can derive the per-term total as the sum over that + /// term's slice. counts: Vec, /// Histogram buckets per term (the dense time-range length). num_time_buckets: usize,