2010YOUY01 commented on code in PR #27743:
URL: https://github.com/apache/datafusion/pull/27743#discussion_r4694508982


##########
datafusion/physical-plan/src/aggregates/grouped_hash_stream.rs:
##########
@@ -1,1874 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for 
additional information regarding copyright ownership
-// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) 
under one or more contributor license agreements
-
-//! Legacy hash aggregation.
-//!
-//! # Deprecation
-//!
-//! [`GroupedHashAggregateStream`] handled every grouped execution path before
-//! they were split into dedicated streams. It is no longer planned by default:
-//! it is only reachable by setting
-//! `datafusion.execution.enable_migration_aggregate` to `false`. It is kept as
-//! a fallback in case of major bugs in the new streams, and will be deleted
-//! after the 56.0.0 release together with that option.
-//!
-//! New features and improvements should go into the dedicated streams instead.
-//!
-//! See issue for details: <https://github.com/apache/datafusion/issues/22710>
-
-use std::sync::Arc;
-use std::task::{Context, Poll};
-use std::vec;
-
-use super::aggregate_hash_table::{accumulator_phases, 
create_group_accumulator};
-use super::order::GroupClustering;
-use super::skip_partial::SkipAggregationProbe;
-use super::{AggregateExec, format_human_display};
-use crate::aggregates::group_values::{
-    AccumulatorPhase, AggregateAccumulatorMetrics, AggregateArgumentMetrics,
-    GroupByMetrics, GroupValues, aggregate_sub_metrics, new_group_values,
-};
-use crate::aggregates::order::GroupClusteringFull;
-use crate::aggregates::{
-    AggregateInputMode, AggregateMode, AggregateOutputMode, PhysicalGroupBy,
-    aggregate_metric_label, create_schema, evaluate_group_by, 
evaluate_optional,
-    group_id_array, max_duplicate_ordinal,
-};
-use crate::metrics::{BaselineMetrics, MetricBuilder, MetricCategory, 
RecordOutput};
-use crate::sorts::streaming_merge::{SortedSpillFile, StreamingMergeBuilder};
-use crate::spill::spill_manager::{GetSlicedSize, SpillManager};
-use crate::stream::EmptyRecordBatchStream;
-use crate::{PhysicalExpr, aggregates, metrics};
-use crate::{RecordBatchStream, SendableRecordBatchStream};
-
-use arrow::array::*;
-use arrow::datatypes::SchemaRef;
-use datafusion_common::{
-    DataFusionError, Result, assert_eq_or_internal_err, assert_or_internal_err,
-    internal_err, resources_datafusion_err,
-};
-use datafusion_execution::TaskContext;
-use datafusion_execution::memory_pool::proxy::VecAllocExt;
-use datafusion_execution::memory_pool::{
-    MemoryConsumer, MemoryPool, MemoryReservation, MergeMemoryPool,
-};
-use datafusion_expr::{EmitTo, GroupsAccumulator};
-use datafusion_physical_expr::PhysicalSortExpr;
-use datafusion_physical_expr::expressions::Column;
-use datafusion_physical_expr_common::sort_expr::LexOrdering;
-use datafusion_physical_expr_common::utils::evaluate_expressions_to_arrays;
-
-use crate::sorts::IncrementalSortIterator;
-use datafusion_common::utils::memory::get_record_batch_memory_size;
-use futures::ready;
-use futures::stream::{Stream, StreamExt};
-use log::debug;
-
-#[derive(Debug, Clone)]
-/// This object tracks the aggregation phase (input/output)
-pub(crate) enum ExecutionState {
-    ReadingInput,
-    /// When producing output, the remaining rows to output are stored
-    /// here and are sliced off as needed in batch_size chunks
-    ProducingOutput(RecordBatch),
-    /// Produce intermediate aggregate state for each input row without
-    /// aggregation.
-    ///
-    /// See "partial aggregation" discussion on [`GroupedHashAggregateStream`]
-    SkippingAggregation,
-    /// All input has been consumed and all groups have been emitted
-    Done,
-}
-
-/// This encapsulates the spilling state
-struct SpillState {
-    // ========================================================================
-    // PROPERTIES:
-    // These fields are initialized at the start and remain constant throughout
-    // the execution.
-    // ========================================================================
-    /// Sorting expression for spilling batches
-    spill_expr: LexOrdering,
-
-    /// Schema for spilling batches
-    spill_schema: SchemaRef,
-
-    /// aggregate_arguments for merging spilled data
-    merging_aggregate_arguments: Vec<Vec<Arc<dyn PhysicalExpr>>>,
-
-    /// GROUP BY expressions for merging spilled data
-    merging_group_by: PhysicalGroupBy,
-
-    /// Manages the process of spilling and reading back intermediate data
-    spill_manager: SpillManager,
-
-    // ========================================================================
-    // STATES:
-    // Fields changes during execution. Can be buffer, or state flags that
-    // influence the execution in parent `GroupedHashAggregateStream`
-    // ========================================================================
-    /// If data has previously been spilled, the locations of the
-    /// spill files (in Arrow IPC format)
-    spills: Vec<SortedSpillFile>,
-
-    /// true when streaming merge is in progress
-    is_stream_merging: bool,
-
-    // ========================================================================
-    // METRICS:
-    // ========================================================================
-    /// Peak memory used for buffered data.
-    /// Calculated as sum of peak memory values across partitions
-    peak_mem_used: metrics::Gauge,
-    // Metrics related to spilling are managed inside `spill_manager`
-}
-
-/// Controls the behavior when an out-of-memory condition occurs.
-#[derive(PartialEq, Debug)]
-enum OutOfMemoryMode {
-    /// When out of memory occurs, spill state to disk
-    Spill,
-    /// When out of memory occurs, attempt to emit group values early
-    EmitEarly,
-    /// When out of memory occurs, immediately report the error
-    ReportError,
-}
-
-/// HashTable based Grouping Aggregator

Review Comment:
   I tried to preserve this documentation in a separate PR:
   - https://github.com/apache/datafusion/pull/27748



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to