wrapped intermediate extended stat with a box to limit memory usage

This commit is contained in:
Giovanni Cuccu
2024-05-18 17:14:40 +02:00
parent ac29ab7e9e
commit 5b4aa9f393
2 changed files with 4 additions and 4 deletions

View File

@@ -216,7 +216,7 @@ pub(crate) fn empty_from_req(req: &Aggregation) -> IntermediateAggregationResult
IntermediateStats::default(),
)),
ExtendedStats(_) => IntermediateAggregationResult::Metric(
IntermediateMetricResult::ExtendedStats(IntermediateExtendedStats::default()),
IntermediateMetricResult::ExtendedStats(Box::new(IntermediateExtendedStats::default())),
),
Sum(_) => IntermediateAggregationResult::Metric(IntermediateMetricResult::Sum(
IntermediateSum::default(),
@@ -286,7 +286,7 @@ pub enum IntermediateMetricResult {
/// Intermediate stats result.
Stats(IntermediateStats),
/// Intermediate stats result.
ExtendedStats(IntermediateExtendedStats),
ExtendedStats(Box<IntermediateExtendedStats>),
/// Intermediate sum result.
Sum(IntermediateSum),
/// Intermediate top_hits result
@@ -358,7 +358,7 @@ impl IntermediateMetricResult {
IntermediateMetricResult::ExtendedStats(extended_stats_left),
IntermediateMetricResult::ExtendedStats(extended_stats_right),
) => {
extended_stats_left.merge_fruits(extended_stats_right);
extended_stats_left.merge_fruits(*extended_stats_right);
}
(IntermediateMetricResult::Sum(sum_left), IntermediateMetricResult::Sum(sum_right)) => {
sum_left.merge_fruits(sum_right);

View File

@@ -770,7 +770,7 @@ impl SegmentAggregationCollector for SegmentExtendedStatsCollector {
let name = agg_with_accessor.aggs.keys[self.accessor_idx].to_string();
results.push(
name,
IntermediateAggregationResult::Metric(IntermediateMetricResult::ExtendedStats(self.extended_stats)),
IntermediateAggregationResult::Metric(IntermediateMetricResult::ExtendedStats(Box::new(self.extended_stats))),
)?;
Ok(())