feat: expose shared session APIs - #63
Conversation
There was a problem hiding this comment.
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.
| 0 | ||
| ); | ||
| assert!( | ||
| after_second.metadata_cache_hits > after_first.metadata_cache_hits, |
There was a problem hiding this comment.
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.
| */ | ||
| int32_t lance_session_get_cache_stats( | ||
| const LanceSession* session, | ||
| LanceSessionCacheStats* out_stats |
There was a problem hiding this comment.
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.
| */ | ||
| typedef struct LanceSessionCacheStats { | ||
| uint64_t index_cache_hits; | ||
| uint64_t index_cache_misses; |
There was a problem hiding this comment.
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.
|
|
||
| /// 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( |
There was a problem hiding this comment.
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.
Summary
LanceSessionwith configurable index and metadata cache limitslance_dataset_open_with_sessionwhile preserving the existing open API