Skip to content

Builder style API for creating RuntimeEnv #12137

@alamb

Description

@alamb

Is your feature request related to a problem or challenge?

While making a reproducer #12136, I found configuring the SessionContext to use a memory limit and disk manager quite akward

Here is what I had to do

    let mem_limit = 10 * 1024 * 1024;
    let pool = FairSpillPool::new(mem_limit);
    let config = RuntimeConfig::new()
        .with_memory_pool(Arc::new(pool))
        .with_disk_manager(DiskManagerConfig::new());

    let runtime_env = RuntimeEnv::new(config)?;
    let builder = SessionStateBuilder::new().with_runtime_env(Arc::new(runtime_env));

    let ctx = SessionContext::new_with_state(builder.build());

Describe the solution you'd like

It would be nice to have the configurations be more of a builder style

Perhaps the example from above could look something more like the following (with some examples):

    let mem_limit = 10 * 1024 * 1024;

    let runtime_env = RuntimeConfig::new()
        .with_memory_pool(Arc::new(FairSpillPool::new(mem_limit)))
        .with_disk_manager(DiskManagerConfig::new());
        // Change: add a build method to RuntimeConfig to 
        .builder(); 

    let builder = SessionStateBuilder::new()
      .with_runtime_env(Arc::new(runtime_env));

    let ctx = SessionContext::new_with_state(builder.build());

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions