Skip to content

feat(csr)!: load stored csrs without writing them - #191

Merged
prrao87 merged 1 commit into
mainfrom
feat/csr-load-only
Nov 21, 2026
Merged

prrao87 merged 1 commit into
mainfrom
feat/csr-load-only

Conversation

@prrao87

@prrao87 prrao87 commented Nov 21, 2026

Copy link
Copy Markdown
Member

Why

Closes #180. Some clients only read graphs that another process writes, such as a graph browser over published Lance tables, and must never change the source datasets. On main the only way to load a stored CSR is persist_csr=True, and that same option writes _lance_csr/<version>.arrow into the dataset whenever the engine has to build. Two smaller problems came with it. On read-only storage the engine compressed the whole file before discovering that the write fails, which cost about 1.6 s on the LANL graph in the issue. And the failure was only logged through Rust's log crate, so Python and Node callers never saw it.

What changed

persist_csr gains a load-only value next to the existing booleans:

Python Node Rust Loads stored files Writes files
False false PersistCsr::Off no no
"load" "load" PersistCsr::Load yes never
True true PersistCsr::LoadAndStore yes after every full build
  • A load-only engine builds in memory when no stored file is usable. Rebuilds from checkout_latest() and optimize_csr() aren't stored either, and delete_stored_csr() refuses (ValueError in Python, InvalidArgument in Node).
  • With storing on, the engine writes and deletes an empty .write-probe in _lance_csr before encoding. Read-only storage now fails there in milliseconds instead of after the encode.
  • A failed write is reported as store_error (storeError in Node) in csr_stats(). It stays set while the engine keeps that CSR. Python also emits a RuntimeWarning and Node a LanceCsrWarning process warning when a new error appears after creating the engine, checkout_latest(), optimize_csr() or optimize_datasets().
  • The CSR guide and the Rust and TypeScript pages describe load-only engines and correct the old claim that a read-only dataset "is built as without the option".

Breaking for Rust only. EngineOptions::persist_csr changes from bool to PersistCsr, so persist_csr: true becomes persist_csr: PersistCsr::LoadAndStore. Python and Node callers that pass booleans see no change.

Validation

  • New Rust test: a load-only miss writes nothing, a stored file loads, delete_stored_csr() refuses, and a dataset that can't be written fails at the probe with store_error set.
  • Python and Node tests cover the same cases, plus the warnings and rejected values. The Python read-only test now checks the warning and store_error.
  • cargo test --workspace, the Python suite with doctests (1,748 passed, 1 skipped) and the Node suite (87 passed) pass locally.
  • cargo fmt, cargo clippy --workspace --all-targets -- -D warnings, Clippy on the Node crate, make lint, npm run lint, the regenerated TypeDoc reference, zensical build --strict and typos pass.
  • Benchmarks weren't run. The change doesn't touch query planning or execution, and an engine without persist_csr takes the same path as before. The only new cost is one empty write and delete per stored full build.
  • CI is pending.

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Deploying lance-csr with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8d4e929
Status: ✅  Deploy successful!
Preview URL: https://09a5d8dc.lance-csr.pages.dev
Branch Preview URL: https://feat-csr-load-only.lance-csr.pages.dev

View logs

Add persist_csr="load" (PersistCsr::Load in Rust, persistCsr: "load" in
Node): an engine loads a stored CSR when it can and otherwise builds in
memory, never writing to its datasets. delete_stored_csr() refuses on such
an engine.

With storing on, check that _lance_csr takes writes before encoding the
file, so read-only storage no longer pays for an encode it can't upload.
A failed write is now reported as store_error in csr_stats() and as a
Python RuntimeWarning or a Node process warning.

Closes #180.
@prrao87
prrao87 marked this pull request as ready for review November 21, 2026 21:25
@prrao87
prrao87 merged commit d69cef7 into main Nov 21, 2026
10 checks passed
@prrao87
prrao87 deleted the feat/csr-load-only branch November 21, 2026 21:26
prrao87 added a commit that referenced this pull request Nov 21, 2026
Minor bump: #191 is a breaking change (marked feat(csr)!), and #187 adds
graph export and dataset maintenance APIs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Load a stored CSR without ever writing one

1 participant