Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builder style API for creating RuntimeEnv #12137

Closed
alamb opened this issue Aug 23, 2024 · 3 comments · Fixed by #12151
Closed

Builder style API for creating RuntimeEnv #12137

alamb opened this issue Aug 23, 2024 · 3 comments · Fixed by #12151
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@alamb
Copy link
Contributor

alamb commented Aug 23, 2024

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

@alamb alamb added enhancement New feature or request good first issue Good for newcomers labels Aug 23, 2024
@alamb
Copy link
Contributor Author

alamb commented Aug 23, 2024

I think this would be fairly straightforward to add and learn how to use the DataFusion APIs

@theirix
Copy link
Contributor

theirix commented Aug 24, 2024

take

@alamb
Copy link
Contributor Author

alamb commented Aug 25, 2024

take

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants