feat(python): expose BlobFile.read_ranges - #8319
Merged
Merged
Conversation
Expose the existing Rust BlobFile::read_ranges as a sync vectored read on the Python BlobFile. Each range is an (offset, length) pair matching read_range; results are returned in input order while the underlying physical requests may be reordered, coalesced, or split by the scan scheduler. Also add the previously missing read_range entry to the LanceBlobFile type stub.
keunhong
force-pushed
the
python-blobfile-read-ranges
branch
from
August 7, 2026 01:12
c832b13 to
b64ab51
Compare
Xuanwo
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lance.BlobFilegained a positionedread_range(offset, length)(cursor-untouched, GIL-released). Consumers that sample sparse ranges from large blobs — e.g. ML dataloaders fetching 64 spread video frames out of a 1024-frame blob — currently must build caller-side thread pools overread_rangeto avoid serial object-store round trips. The RustBlobFilealready has the right primitive:read_ranges(&[Range<u64>]), which returns results in input order and lets theScanSchedulerreorder/coalesce/split the physical requests. Only the Python binding is missing. This change exposes it: one vectored call replaces N caller-side threads and gives the scheduler the whole access pattern at once.Changes
python/src/dataset/blob.rs): newLanceBlobFile.read_rangesmirroring theread_rangepattern —(offset, length)pairs converted toRange<u64>with per-range overflow checks, GIL released across the await via the background executor,PyBytesbuilt after the call returns.python/python/lance/blob.py):BlobFile.read_ranges(ranges: list[tuple[int, int]]) -> list[bytes]— results in input order; out-of-bounds ranges raiseValueError, matchingread_range.__init__.pyi): addedread_rangesand the previously missingread_rangeentry onLanceBlobFile.python/python/tests/test_blob.py): parity with sequentialread_range(empty / empty-ranges / non-monotonic / duplicated+overlapping, parametrized), literal input-order preservation, cursor invariance (including afterseek), and out-of-bounds/overflow pinned toValueErrorwith the same messages the dataset-levelread_blob_rangestests pin.Purely additive — no Rust-core changes, no new dependencies, no async Python API.
Verification
python/tests/test_blob.pypasses (177 tests).read_rangeon 50 randomized range sets (up to 68 shuffled, duplicated, overlapping ranges over a 4 KB blob), cursor invariant throughout.uv run make formatidempotent;uv run make lint(ruff + pyright + rustfmt + clippy-D warnings) clean; all pre-commit hooks pass.