feat(python): allow a metadata cache for LanceFileReader / LanceFileSession
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- database, performance
Research direction
Read python/src/file.rs around the LanceFileReader::open_with_store call and the Python definitions of LanceFileSession and LanceFileReader in python/python/lance/file.py. Trace how lance.Session exposes its metadata cache and how file readers receive it; the Rust cache type and no_cache() call are identified in the issue. Done means file readers can opt into a shared session cache while the default remains uncached, with coverage for the Python API.
Written by the indexing model from the issue text.
Description
Problem
Lance is increasingly used purely as a file format inside other table formats or directly. In that setting there is no Lance manifest / LanceDataset, so the only Python read entry points are LanceFileReader and LanceFileSession.open_reader().
The Python binding opens the Rust FileReader with a hard-coded zero-capacity cache: python/src/file.rs#L887 — &LanceCache::no_cache().
As a result, random access (take_rows / small read_range) re-fetches page metadata from object storage on every call (find_cache_misses), and every new reader re-reads the footer / column metadata.
There is currently no Python parameter to change this. The cache knobs (lance.Session(metadata_cache_size_bytes=..., metadata_cache_backend=...)) are only reachable through lance.dataset(), and LanceFileSession only shares the object store (#4670).
Proposal
Add an opt-in metadata cache to the Python file API. The default stays unchanged (no cache).
The preferred option reuses the existing lance.Session, so cache sizing, cache backends and observability (size_bytes()) are the same as on the dataset path:
import lance
from lance.file import LanceFileSession, LanceFileReader
session = lance.Session(metadata_cache_size_bytes=1 << 30)
# Readers opened from a file session share the session's metadata cache
fs = LanceFileSession(base_uri, storage_options=opts, session=session)
reader = fs.open_reader("data/xxx.lance")
reader.take_rows([3, 42, 7])
# Standalone readers can share the same cache
reader = LanceFileReader(uri, storage_options=opts, session=session)
session.size_bytes() # observe cache usage
- Alternative: a plain
metadata_cache_size_bytes=argument onLanceFileSession. - Implementation sketch: keep the session's metadata cache (
Arc<LanceCache>) in the PythonLanceFileSession/LanceFileReader, and pass it instead ofLanceCache::no_cache()inLanceFileReader::open_with_store. Cache keys are already prefixed by file path, so one cache can be shared safely across files.
Happy to send a PR if the direction looks acceptable.
- Dominant language
- Rust
- Stars
- 7.2k
- Forks
- 900
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 392
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lance-format/lance
-
feature performance
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
lance-format/lance#10137 ·
Maintainers usually reply within 3 days
-
Upgrade DataFusion for the unparser stack-overflow fixMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
lance-format/lance#8225 ·
Maintainers usually reply within 3 days
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 84/100
lance-format/lance#6425 · 2 comments ·
Maintainers usually reply within 3 days
-
Expose compute_pq_distanceMay be free again A pull request for this issue was closed without being merged. Openenhancement
Difficulty 1/5 1-3 hours Newbie friendliness 62/100
lance-format/lance#5675 · 1 comment ·
Maintainers usually reply within 3 days
-
documentation
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
lance-format/lance#5240 ·
Maintainers usually reply within 3 days
All issues in lance-format/lance
Similar issues
-
component:benchmark
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
agentic-os-org/ANOLISA#9177 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
oracle/rust-oracledb#61 ·
-
bug priority-medium to-agent
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 2 days
-
Databricks tool-only response crashes in resolve_reasoning_and_content with KeyError: contentPossibly taken @1divyanshdev claimed this today. Openllm translation
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
BerriAI/litellm#48637 · 2 comments ·
Maintainers usually reply within 1 day