Skip to content

chore: Update api docs for SessionContext, TaskContext, etc #6106

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

Merged
merged 3 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions datafusion/core/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,29 @@ impl SessionContext {
Ok(())
}

/// Creates a new `SessionContext` using the provided session configuration.
/// Creates a new `SessionContext` using the provided
/// [`SessionConfig`] and a new [`RuntimeEnv`].
///
/// See [`Self::with_config_rt`] for more details on resource
/// limits.
pub fn with_config(config: SessionConfig) -> Self {
let runtime = Arc::new(RuntimeEnv::default());
Self::with_config_rt(config, runtime)
}

/// Creates a new `SessionContext` using the provided [`SessionConfig`] and [`RuntimeEnv`].
/// Creates a new `SessionContext` using the provided
/// [`SessionConfig`] and a [`RuntimeEnv`].
///
/// # Resource Limits
///
/// By default, each new `SessionContext` creates a new
/// `RuntimeEnv`, and therefore will not enforce memory or disk
/// limits for queries run on different `SessionContext`s.
///
/// To enforce resource limits (e.g. to limit the total amount of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thanks

/// memory used) across all DataFusion queries in a process,
/// all `SessionContext`'s should be configured with the
/// same `RuntimeEnv`.
pub fn with_config_rt(config: SessionConfig, runtime: Arc<RuntimeEnv>) -> Self {
let state = SessionState::with_config_rt(config, runtime);
Self::with_state(state)
Expand Down Expand Up @@ -1270,7 +1286,8 @@ pub fn default_session_builder(config: SessionConfig) -> SessionState {
}

impl SessionState {
/// Returns new SessionState using the provided configuration and runtime
/// Returns new [`SessionState`] using the provided
/// [`SessionConfig`] and [`RuntimeEnv`].
pub fn with_config_rt(config: SessionConfig, runtime: Arc<RuntimeEnv>) -> Self {
let catalog_list = Arc::new(MemoryCatalogList::new()) as Arc<dyn CatalogList>;
Self::with_config_rt_and_catalog_list(config, runtime, catalog_list)
Expand Down
9 changes: 4 additions & 5 deletions datafusion/execution/src/runtime_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ use std::sync::Arc;
use url::Url;

#[derive(Clone)]
/// Execution runtime environment.
/// Execution runtime environment that manages system resources such
/// as memory, disk and storage.
///
/// A [`RuntimeEnv`] can be created from a [`RuntimeConfig`] and
/// stores state to be shared across multiple sessions. In most
/// applications there will be a single [`RuntimeEnv`]
/// with the following capaibilties:
/// A [`RuntimeEnv`] is created from a [`RuntimeConfig`] and has the
/// following resource management functionality:
///
/// * [`MemoryPool`]: Manage memory
/// * [`DiskManager`]: Manage temporary files on local disk
Expand Down