-
Notifications
You must be signed in to change notification settings - Fork 12
feat: expose shared session APIs #63
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ use lance_core::Result; | |
| use crate::error::{ffi_try, swallow_unwind}; | ||
| use crate::helpers; | ||
| use crate::runtime::block_on; | ||
| use crate::session::LanceSession; | ||
| use crate::stream_guard::guarded_ffi_stream_from_reader; | ||
|
|
||
| /// Opaque handle representing an opened Lance dataset. | ||
|
|
@@ -121,15 +122,48 @@ pub unsafe extern "C" fn lance_dataset_open( | |
| version: u64, | ||
| ) -> *mut LanceDataset { | ||
| ffi_try!( | ||
| unsafe { open_dataset_inner(uri, storage_options, version) }, | ||
| unsafe { open_dataset_inner(uri, storage_options, version, None) }, | ||
| null | ||
| ) | ||
| } | ||
|
|
||
| /// Open a Lance dataset using a shared session. | ||
| /// | ||
| /// The dataset retains shared ownership of the session state, so the caller | ||
| /// may close the session handle after this function returns successfully. | ||
| #[unsafe(no_mangle)] | ||
| pub unsafe extern "C" fn lance_dataset_open_with_session( | ||
| uri: *const c_char, | ||
| storage_options: *const *const c_char, | ||
| version: u64, | ||
| session: *const LanceSession, | ||
| ) -> *mut LanceDataset { | ||
| ffi_try!( | ||
| unsafe { open_dataset_with_session_inner(uri, storage_options, version, session) }, | ||
| null | ||
| ) | ||
| } | ||
|
|
||
| unsafe fn open_dataset_with_session_inner( | ||
| uri: *const c_char, | ||
| storage_options: *const *const c_char, | ||
| version: u64, | ||
| session: *const LanceSession, | ||
| ) -> Result<*mut LanceDataset> { | ||
| if session.is_null() { | ||
| return Err(lance_core::Error::invalid_input_source( | ||
| "session must not be NULL".into(), | ||
| )); | ||
| } | ||
| let session = unsafe { &*session }; | ||
| unsafe { open_dataset_inner(uri, storage_options, version, Some(session)) } | ||
| } | ||
|
|
||
| unsafe fn open_dataset_inner( | ||
| uri: *const c_char, | ||
| storage_options: *const *const c_char, | ||
| version: u64, | ||
| session: Option<&LanceSession>, | ||
| ) -> Result<*mut LanceDataset> { | ||
| let uri_str = unsafe { helpers::parse_c_string(uri)? } | ||
| .ok_or_else(|| lance_core::Error::invalid_input_source("uri must not be NULL".into()))?; | ||
|
|
@@ -143,6 +177,9 @@ unsafe fn open_dataset_inner( | |
| if version != 0 { | ||
| builder = builder.with_version(version); | ||
| } | ||
| if let Some(session) = session { | ||
| builder = builder.with_session(session.inner.clone()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This passes the same session into a builder that has just accepted per-open storage options, but the pinned Lance caches do not incorporate those options or effective store identity. In This is the same limitation previously noted as a risk, but upstream #7721 supplies the concrete same-URI/cross-account failure path: one dataset observed the other account's index UUID or foreign metadata. Its store-aware namespace change closed unmerged, and the pinned source still retains the URI-only keys. Please establish isolation before exposing this combination: reject same-session/same-URI reuse when the effective storage binding differs, or move to an upstream revision that namespaces every store-bound cache by binding. Using separate sessions is safe for callers, but leaving this as documentation would still make the public API permit cross-binding cache reuse. |
||
| } | ||
|
|
||
| let dataset = block_on(builder.load())?; | ||
| let handle = LanceDataset { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.