kazuyukitanimura commented on code in PR #7400:
URL: https://github.com/apache/arrow-datafusion/pull/7400#discussion_r1316579368
##########
datafusion/core/src/physical_plan/aggregates/group_values/mod.rs:
##########
@@ -42,6 +43,19 @@ pub trait GroupValues: Send {
/// Emits the group values
fn emit(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>>;
+
+ /// Try to reserve the capacity that at least a single [`RecordBatch`] can
be inserted. The
+ /// accumulator may reserve more space to speculatively avoid frequent
re-allocations. After
+ /// calling try_reserve, capacity will be greater than or equal to
self.len() + additional if
Review Comment:
Updated
##########
datafusion/physical-expr/src/aggregate/groups_accumulator/mod.rs:
##########
@@ -157,4 +161,14 @@ pub trait GroupsAccumulator: Send {
/// in bytes. This function is called once per batch, so it should
/// be `O(n)` to compute, not `O(num_groups)`
fn size(&self) -> usize;
+
+ /// Try to reserve capacity the that at least a single [`RecordBatch`] can
be inserted. The
+ /// accumulator may reserve more space to speculatively avoid frequent
re-allocations. After
+ /// calling try_reserve, capacity will be greater than or equal to
self.len() + additional if
+ /// it returns Ok(()). Does nothing if capacity is already sufficient.
This method preserves
+ /// the contents even if an error occurs.
+ fn try_reserve(&mut self, batch: &RecordBatch) -> Result<(),
TryReserveError>;
+
+ /// clear the contents and shrink the capacity
+ fn clear_shrink(&mut self, batch: &RecordBatch);
Review Comment:
Removed
##########
datafusion/physical-expr/src/aggregate/groups_accumulator/mod.rs:
##########
@@ -157,4 +161,14 @@ pub trait GroupsAccumulator: Send {
/// in bytes. This function is called once per batch, so it should
/// be `O(n)` to compute, not `O(num_groups)`
fn size(&self) -> usize;
+
+ /// Try to reserve capacity the that at least a single [`RecordBatch`] can
be inserted. The
Review Comment:
Applied the "optimistic" approach and removed the upfront reservations.
--
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]