MCPcopy Create free account
hub / github.com/apache/datafusion / test_work_table

Function test_work_table

datafusion/physical-plan/src/work_table.rs:272–301  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 8

newFunction · 0.85
intoMethod · 0.45
registerMethod · 0.45
try_growMethod · 0.45
updateMethod · 0.45
takeMethod · 0.45
with_reservationMethod · 0.45
schemaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…