()
| 270 | |
| 271 | #[test] |
| 272 | fn test_work_table() { |
| 273 | let work_table = WorkTable::new("test".into()); |
| 274 | // Can't take from empty work_table |
| 275 | assert!(work_table.take().is_err()); |
| 276 | |
| 277 | let pool = Arc::new(UnboundedMemoryPool::default()) as _; |
| 278 | let reservation = MemoryConsumer::new("test_work_table").register(&pool); |
| 279 | |
| 280 | // Update batch to work_table |
| 281 | let array: ArrayRef = Arc::new((0..5).collect::<Int32Array>()); |
| 282 | let batch = RecordBatch::try_from_iter(vec![("col", array)]).unwrap(); |
| 283 | reservation.try_grow(100).unwrap(); |
| 284 | work_table.update(ReservedBatches::new(vec![batch.clone()], reservation)); |
| 285 | // Take from work_table |
| 286 | let reserved_batches = work_table.take().unwrap(); |
| 287 | assert_eq!(reserved_batches.batches, vec![batch.clone()]); |
| 288 | |
| 289 | // Consume the batch by the MemoryStream |
| 290 | let memory_stream = |
| 291 | MemoryStream::try_new(reserved_batches.batches, batch.schema(), None) |
| 292 | .unwrap() |
| 293 | .with_reservation(reserved_batches.reservation); |
| 294 | |
| 295 | // Should still be reserved |
| 296 | assert_eq!(pool.reserved(), 100); |
| 297 | |
| 298 | // The reservation should be freed after drop the memory_stream |
| 299 | drop(memory_stream); |
| 300 | assert_eq!(pool.reserved(), 0); |
| 301 | } |
| 302 | |
| 303 | #[tokio::test] |
| 304 | async fn test_work_table_exec() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…