use std::sync::Arc;
use arrow::datatypes::SchemaRef;
use arrow::record_batch::RecordBatch;
use datafusion_common::Result;
use crate::aggregates::AggregateExec;
use super::common::{AggregateHashTable, HashAggregateAccumulator, PartialReduceMarker};
impl AggregateHashTable<PartialReduceMarker> {
pub(in crate::aggregates) fn new(
agg: &AggregateExec,
partition: usize,
output_schema: SchemaRef,
batch_size: usize,
) -> Result<Self> {
Self::new_with_filters(
agg,
partition,
Arc::clone(&output_schema),
output_schema,
batch_size,
vec![None; agg.aggr_expr.len()],
)
}
pub(in crate::aggregates) fn next_output_batch(
&mut self,
) -> Result<Option<RecordBatch>> {
self.next_output_batch_inner(HashAggregateAccumulator::state)
}
pub(in crate::aggregates) fn aggregate_batch(
&mut self,
batch: &RecordBatch,
) -> Result<()> {
self.aggregate_batch_inner(batch, HashAggregateAccumulator::merge_batch)
}
pub(in crate::aggregates) fn start_output(&mut self) -> Result<()> {
self.start_outputting();
Ok(())
}
}