Skip to content

Commit

Permalink
Minor: allow to build RuntimeEnv from RuntimeConfig (apache#12151)
Browse files Browse the repository at this point in the history
* Allow to build RuntimeEnv from RuntimeConfig

* Fix formatting
  • Loading branch information
theirix authored Aug 26, 2024
1 parent 7d49fb3 commit ed12f11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 5 additions & 4 deletions datafusion/core/tests/fuzz_cases/sort_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use arrow::{
compute::SortOptions,
record_batch::RecordBatch,
};
use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
use datafusion::execution::runtime_env::RuntimeConfig;
use datafusion::physical_plan::expressions::PhysicalSortExpr;
use datafusion::physical_plan::memory::MemoryExec;
use datafusion::physical_plan::sorts::sort::SortExec;
Expand Down Expand Up @@ -136,9 +136,10 @@ impl SortTest {
.sort_spill_reservation_bytes,
);

let runtime_config = RuntimeConfig::new()
.with_memory_pool(Arc::new(GreedyMemoryPool::new(pool_size)));
let runtime = Arc::new(RuntimeEnv::new(runtime_config).unwrap());
let runtime_env = RuntimeConfig::new()
.with_memory_pool(Arc::new(GreedyMemoryPool::new(pool_size)))
.build();
let runtime = Arc::new(runtime_env.unwrap());
SessionContext::new_with_config_rt(session_config, runtime)
} else {
SessionContext::new_with_config(session_config)
Expand Down
5 changes: 5 additions & 0 deletions datafusion/execution/src/runtime_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,9 @@ impl RuntimeConfig {
pub fn with_temp_file_path(self, path: impl Into<PathBuf>) -> Self {
self.with_disk_manager(DiskManagerConfig::new_specified(vec![path.into()]))
}

/// Build a `RuntimeEnv` object from the configuration
pub fn build(self) -> Result<RuntimeEnv> {
RuntimeEnv::new(self)
}
}

0 comments on commit ed12f11

Please sign in to comment.