Skip to content

feat: expose shared session APIs - #63

Open
Jay-ju wants to merge 1 commit into
lance-format:mainfrom
Jay-ju:session-api
Open

feat: expose shared session APIs#63
Jay-ju wants to merge 1 commit into
lance-format:mainfrom
Jay-ju:session-api

Conversation

@Jay-ju

@Jay-ju Jay-ju commented Aug 23, 2026

Copy link
Copy Markdown

Summary

  • expose an opaque LanceSession with configurable index and metadata cache limits
  • allow datasets to share a session through lance_dataset_open_with_session while preserving the existing open API
  • expose cache hit, miss, entry, and retained-byte statistics
  • add C++ RAII wrappers, documentation, and lifecycle/cache reuse coverage

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Gate recommendation: approve with a non-blocking risk.

The explicit session handle matches the upstream Lance ownership model, preserves the existing open APIs, and correctly demonstrates metadata-cache reuse and lifetime independence across Rust, C, and C++.

A non-blocking risk remains in the pinned upstream implementation: cache namespaces include the dataset URI but not object-store options. If one session opens the same URI against different physical endpoints, separate sessions are the safe mitigation until store identity is incorporated into the upstream cache key.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Aug 23, 2026
Comment thread tests/c_api_test.rs
0
);
assert!(
after_second.metadata_cache_hits > after_first.metadata_cache_hits,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

metadata_cache_hits only increases here if manifest resolution actually goes through the metadata cache (i.e. manifest_location.size is Some). If resolve_latest_location ever returns size == None for this backend, both opens bypass the cache and this assertion could flake.

Comment thread include/lance/lance.h
*/
int32_t lance_session_get_cache_stats(
const LanceSession* session,
LanceSessionCacheStats* out_stats

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Param name mismatch: this header names it out_stats, but the Rust extern "C" def in src/session.rs:81 names it out. CLAUDE.md asks for consistent param names across bindings — a future cbindgen regen from the Rust side would silently rename this.

Comment thread include/lance/lance.h
*/
typedef struct LanceSessionCacheStats {
uint64_t index_cache_hits;
uint64_t index_cache_misses;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Doc says size=0 "disables" the cache, but Session::new(0, 0, ...) upstream builds a zero-capacity cache (with_capacity(0)), not a guaranteed no-op — it can still transiently accept an insert before eviction. Worth softening the wording or verifying the guarantee.

Comment thread include/lance/lance.hpp

/// Open a dataset with caches owned by `session`. The returned dataset
/// remains valid if the Session wrapper is destroyed first.
static Dataset open_with_session(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This duplicates the ~10-line storage_opts NULL-terminated array construction from Dataset::open verbatim. Worth factoring into a shared private helper so future fixes (e.g. NUL-handling) don't need to be applied at every call site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants