Create a new `SessionContext` with specified disk limit, memory pool limit, and spill compression codec
(
disk_limit: u64,
memory_pool_limit: usize,
spill_compression: SpillCompression,
)
| 556 | |
| 557 | // Create a new `SessionContext` with specified disk limit, memory pool limit, and spill compression codec |
| 558 | async fn setup_context( |
| 559 | disk_limit: u64, |
| 560 | memory_pool_limit: usize, |
| 561 | spill_compression: SpillCompression, |
| 562 | ) -> Result<SessionContext> { |
| 563 | let disk_manager = DiskManagerBuilder::default() |
| 564 | .with_mode(DiskManagerMode::OsTmpDirectory) |
| 565 | .with_max_temp_directory_size(disk_limit) |
| 566 | .build()?; |
| 567 | |
| 568 | let runtime = RuntimeEnvBuilder::new() |
| 569 | .with_memory_pool(Arc::new(FairSpillPool::new(memory_pool_limit))) |
| 570 | .build_arc() |
| 571 | .unwrap(); |
| 572 | |
| 573 | let runtime = Arc::new(RuntimeEnv { |
| 574 | memory_pool: runtime.memory_pool.clone(), |
| 575 | disk_manager: Arc::new(disk_manager), |
| 576 | cache_manager: runtime.cache_manager.clone(), |
| 577 | object_store_registry: runtime.object_store_registry.clone(), |
| 578 | #[cfg(feature = "parquet_encryption")] |
| 579 | parquet_encryption_factory_registry: runtime |
| 580 | .parquet_encryption_factory_registry |
| 581 | .clone(), |
| 582 | }); |
| 583 | |
| 584 | let config = SessionConfig::new() |
| 585 | .with_sort_spill_reservation_bytes(64 * 1024) // 256KB |
| 586 | .with_sort_in_place_threshold_bytes(0) |
| 587 | .with_spill_compression(spill_compression) |
| 588 | .with_batch_size(64) // To reduce test memory usage |
| 589 | .with_target_partitions(1); |
| 590 | |
| 591 | Ok(SessionContext::new_with_config_rt(config, runtime)) |
| 592 | } |
| 593 | |
| 594 | /// If the spilled bytes exceed the disk limit, the query should fail |
| 595 | /// (specified by `max_temp_directory_size` in `DiskManager`) |
no test coverage detected
searching dependent graphs…