|
18 | 18 | //! Vectorized [`GroupsAccumulator`] |
19 | 19 |
|
20 | 20 | use arrow::array::{ArrayRef, BooleanArray}; |
21 | | -use datafusion_common::{not_impl_err, Result}; |
| 21 | +use datafusion_common::{not_impl_err, DataFusionError, Result}; |
22 | 22 |
|
23 | 23 | /// Describes how many rows should be emitted during grouping. |
24 | 24 | #[derive(Debug, Clone, Copy)] |
@@ -250,4 +250,30 @@ pub trait GroupsAccumulator: Send { |
250 | 250 | /// This function is called once per batch, so it should be `O(n)` to |
251 | 251 | /// compute, not `O(num_groups)` |
252 | 252 | 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 | + } |
253 | 279 | } |
0 commit comments