From 26a589e5fdf41b638e13ea462d4df8b05e0ca0df Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Mon, 20 Apr 2026 20:25:35 +0200 Subject: [PATCH] agg fix: compute memory consumption only for current bucket --- src/aggregation/bucket/term_agg.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/aggregation/bucket/term_agg.rs b/src/aggregation/bucket/term_agg.rs index 9c2bc0153..fe47eede2 100644 --- a/src/aggregation/bucket/term_agg.rs +++ b/src/aggregation/bucket/term_agg.rs @@ -809,7 +809,7 @@ impl SegmentAggregationCollector docs: &[crate::DocId], agg_data: &mut AggregationsSegmentCtx, ) -> crate::Result<()> { - let mem_pre = self.get_memory_consumption(); + let mem_pre = self.get_memory_consumption(parent_bucket_id); let req_data = &mut self.terms_req_data; @@ -853,7 +853,7 @@ impl SegmentAggregationCollector } } - let mem_delta = self.get_memory_consumption() - mem_pre; + let mem_delta = self.get_memory_consumption(parent_bucket_id) - mem_pre; if mem_delta > 0 { agg_data .context @@ -946,11 +946,8 @@ where TermMap: TermAggregationMap, B: SubAggBuffer, { - fn get_memory_consumption(&self) -> usize { - self.parent_buckets - .iter() - .map(|b| b.get_memory_consumption()) - .sum() + fn get_memory_consumption(&self, parent_bucket_id: BucketId) -> usize { + self.parent_buckets[parent_bucket_id as usize].get_memory_consumption() } #[inline]