(&mut self)
| 256 | |
| 257 | impl<T: ArrowNumericType> Accumulator for MedianAccumulator<T> { |
| 258 | fn state(&mut self) -> Result<Vec<ScalarValue>> { |
| 259 | // Convert `all_values` to `ListArray` and return a single List ScalarValue |
| 260 | |
| 261 | // Build offsets |
| 262 | let offsets = |
| 263 | OffsetBuffer::new(ScalarBuffer::from(vec![0, self.all_values.len() as i32])); |
| 264 | |
| 265 | // Build inner array |
| 266 | let values_array = PrimitiveArray::<T>::new( |
| 267 | ScalarBuffer::from(std::mem::take(&mut self.all_values)), |
| 268 | None, |
| 269 | ) |
| 270 | .with_data_type(self.data_type.clone()); |
| 271 | |
| 272 | // Build the result list array |
| 273 | let list_array = ListArray::new( |
| 274 | Arc::new(Field::new_list_field(self.data_type.clone(), true)), |
| 275 | offsets, |
| 276 | Arc::new(values_array), |
| 277 | None, |
| 278 | ); |
| 279 | |
| 280 | Ok(vec![ScalarValue::List(Arc::new(list_array))]) |
| 281 | } |
| 282 | |
| 283 | fn update_batch(&mut self, values: &[ArrayRef]) -> Result<()> { |
| 284 | let values = values[0].as_primitive::<T>(); |
nothing calls this directly
no test coverage detected