Skip to content

Commit cc37eba

Browse files
committed
define the needed methods in GroupAccumulator and GroupValues.
1 parent 7317198 commit cc37eba

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

datafusion/expr-common/src/groups_accumulator.rs

+26
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,30 @@ pub trait GroupsAccumulator: Send {
250250
/// This function is called once per batch, so it should be `O(n)` to
251251
/// compute, not `O(num_groups)`
252252
fn size(&self) -> usize;
253+
254+
/// Returns `true` if this accumulator supports blocked groups.
255+
fn supports_blocked_groups(&self) -> bool {
256+
false
257+
}
258+
259+
/// Alter the block size in the accumulator
260+
///
261+
/// If the target block size is `None`, it will use a single big
262+
/// block(can think it a `Vec`) to manage the state.
263+
///
264+
/// If the target block size` is `Some(blk_size)`, it will try to
265+
/// set the block size to `blk_size`, and the try will only success
266+
/// when the accumulator has supported blocked mode.
267+
///
268+
/// NOTICE: After altering block size, all data in previous will be cleared.
269+
///
270+
fn alter_block_size(&mut self, block_size: Option<usize>) -> Result<()> {
271+
if block_size.is_some() {
272+
return Err(DataFusionError::NotImplemented(
273+
"this accumulator doesn't support blocked mode yet".to_string(),
274+
));
275+
}
276+
277+
Ok(())
278+
}
253279
}

datafusion/physical-plan/src/aggregates/group_values/mod.rs

+26
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,32 @@ pub(crate) trait GroupValues: Send {
110110

111111
/// Clear the contents and shrink the capacity to the size of the batch (free up memory usage)
112112
fn clear_shrink(&mut self, batch: &RecordBatch);
113+
114+
/// Returns `true` if this accumulator supports blocked groups.
115+
fn supports_blocked_groups(&self) -> bool {
116+
false
117+
}
118+
119+
/// Alter the block size in the `group values`
120+
///
121+
/// If the target block size is `None`, it will use a single big
122+
/// block(can think it a `Vec`) to manage the state.
123+
///
124+
/// If the target block size` is `Some(blk_size)`, it will try to
125+
/// set the block size to `blk_size`, and the try will only success
126+
/// when the `group values` has supported blocked mode.
127+
///
128+
/// NOTICE: After altering block size, all data in previous will be cleared.
129+
///
130+
fn alter_block_size(&mut self, block_size: Option<usize>) -> Result<()> {
131+
if block_size.is_some() {
132+
return Err(DataFusionError::NotImplemented(
133+
"this group values doesn't support blocked mode yet".to_string(),
134+
));
135+
}
136+
137+
Ok(())
138+
}
113139
}
114140

115141
/// Return a specialized implementation of [`GroupValues`] for the given schema.

0 commit comments

Comments
 (0)