Skip to content

feat(blob): read blobs from explicitly opened handles - #10171

Merged
Xuanwo merged 7 commits into
lance-format:mainfrom
sarwarbhuiyan:feat/blob-reads-from-handles
Nov 13, 2026
Merged

Xuanwo merged 7 commits into
lance-format:mainfrom
sarwarbhuiyan:feat/blob-reads-from-handles

Conversation

@sarwarbhuiyan

@sarwarbhuiyan sarwarbhuiyan commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Bulk reads from already opened BlobFile handles can now reuse the bounded Blob read planner without taking descriptors again. Rust exposes lance::blob::read_blob_files and read_blob_file_ranges; Python exposes the same APIs at the lance module level. This addresses the handle-input portion of #6178.

Requests retain their input identity, including NULL and empty values, with ordered results by default. Defaults come from the first non-null handle's own store and can be overridden. Empty and all-NULL inputs perform no I/O. Handles keep their source and ranges across dataset commits while their backing files remain available; External objects retain their provider's consistency semantics. Public Rust and Python docs state that handles already closed when the read stream is created are rejected; closing a handle afterwards does not cancel reads already planned.

Payload grouping distinguishes ObjectStore Arc instances and object paths, so stores with matching prefixes cannot share credentials, cache state, or payloads accidentally. Execution schedulers are shared across paths within the same store instance; cached schedulers retain that Arc, preventing address reuse while the execution is alive. Handle and row-selector reads use the same bounded executor, with no placeholder row addresses in the internal execution path.

The branch is merged with current main (4344ec32), preserving the incoming Blob raw-reader schema normalization from #10946 and the session/version stub additions; the original two contributor commits remain in history. Validation on the integrated tree: 373 targeted Rust Blob tests passed (233 dataset::blob, 140 dataset::tests::dataset_blob), including all 11 new handle cases; 146 lance doctests passed, including both new public examples; full-workspace ci Clippy and formatting passed. Python: 292 test_blob.py cases passed, including all 17 new handle cases; uv run make lint passed. The docs site builds; external integration docs were absent and stayed on their placeholders. Live S3/MinIO credential isolation and latency benchmarks have not been run; request-count tests do not establish a latency claim.

Formal approval is still pending.

sarwarbhuiyan and others added 2 commits October 19, 2026 18:52
`read_blobs` and `read_blob_ranges` take the blob column's descriptors
from the dataset on every execution before they can read payloads. On
object storage that is a separate request the payload reads wait for. A
`BlobFile` from `take_blobs` already holds its descriptor, but reading
through handles meant one `BlobFile` call at a time, outside the planner.

Add `Dataset::read_blob_files` (whole blobs) and
`Dataset::read_blob_file_ranges` (blob-local ranges), backed by a new
`ReadBlobFilesBuilder`. Handles become planner entries directly, so the
read issues only payload requests, grouped by backing object, coalesced
across handles and batched by the I/O buffer like the row selectors.
`None` (a null blob from `take_blobs`) yields `data: None`. Results are
`ReadBlobFile { request_index, data }` because a null handle has no row
address to report. Ranges are checked against handle sizes and closed
handles are rejected before any I/O. Handles are not checked against the
builder's dataset or version: they name immutable files, so they keep
returning the bytes of the version they were taken from.

The three builders now share one plan/execute/totalize helper.

Refs lance-format#6178

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Expose `Dataset.read_blob_files(blob_files)` and
`Dataset.read_blob_file_ranges(requests)`, thin wrappers over the Rust
`read_blob_files` / `read_blob_file_ranges` builders. They take the
`BlobFile` handles returned by `take_blobs` (or `None` for null blobs)
and return one `(request_index, data)` pair per request, accepting the
same `io_buffer_size` and `preserve_order` options as `read_blobs`.

Callers that read the same blobs repeatedly, such as Zarr shard reads
that fetch an index and then chunk ranges, can take handles once and
skip the descriptor request `read_blobs` and `read_blob_ranges` issue on
every call.

Refs lance-format#6178

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added A-python Python bindings A-docs Documentation enhancement New feature or request labels Oct 20, 2026
@Xuanwo Xuanwo changed the title feat(blob): read planned blobs through caller-held BlobFile handles feat(blob): read blobs from explicitly opened handles Nov 12, 2026
@Xuanwo
Xuanwo marked this pull request as ready for review November 12, 2026 08:17

@claude claude 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.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Nov 12, 2026
Xuanwo added a commit that referenced this pull request Nov 12, 2026
Controlled services need to reject stored External Blob references
outside registered storage bases before URI resolution or size probing,
while immutable payload caches must not return stale External data.

Add an opt-in Session policy for unregistered External reads and logical
reference writes. Embedded sessions retain the existing Allow default.
Provider filtering removes selected schemes and clears cached bindings;
it does not revoke previously issued handles. Policy-aware writes report
that remote tables require registered storage bases. Explicit Ingest and
low-level file APIs retain their existing contracts.

Add an External-store wrapper hook that derives a view from the resolved
store, preserving credentials, endpoints, connection pools and provider
state. Immutable cache wrappers can bypass their cache for External
reads while retaining ordinary Managed behavior. A weak cache reuses
live External views without a reference cycle, and source/scheduler
identity prevents stores or wrapper views with matching prefixes from
being combined.

Behavioral validation covers rejection before source access, filtered
local providers, registered-base matching, repeated locator batches
sharing one executor, fresh External reads after overwrite, and zero
origin reads for warm Managed payloads. The final reviewed delta passed
483 IO and 227 Blob tests; earlier 189 Dataset IO cases and two doctests
remain applicable. The integrated tree adds only the upstream
SAFETY-comment fix from #10980; full root Clippy passed on the
integrated PR head (`cargo clippy --all --tests --benches --profile ci
-j 4 -- -D warnings`, exit 0). Hosted CI and formal approval remain
pending.

Service adoption must propagate the policy when rebuilding Sessions and
implement the External hook in its immutable cache wrapper. Production
RAM/NVMe, cloud credentials and REST/SQL integration are separate
downstream work. This PR does not establish that those service
boundaries are already enforced. It overlaps the internal read keys in
#10171; a separately reviewed integration candidate with that PR
retained Arc-instance-plus-path scheduler identity and row-independent
entries and passed 605 Blob tests (0 failures). This does not claim
downstream Sophon adoption or a merged prerequisite.
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Nov 12, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-changes Latest Gatekeeper recommendation requests changes. and removed K-changes Latest Gatekeeper recommendation requests changes. labels Nov 12, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 12, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 13, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Gate recommendation: approve.

The integrated revision preserves store-instance scheduler sharing and payload isolation. The clarified handle lifecycle and null-request positions match the read path.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 13, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving the accepted source semantics: reads resolve through each handle's own payload location without re-reading descriptors; null/duplicate/unordered/range requests keep request identity; already-closed handles are rejected before payload I/O; schedulers stay per store instance with payload grouping keyed by store identity and path. Re-ran the 10 focused handle-read tests and cargo fmt --all --check on the merged candidate tree (live main 5a26f39 + this head), all passed. Formal approval was the only outstanding blocker.

@Xuanwo
Xuanwo merged commit 5707b21 into lance-format:main Nov 13, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docs Documentation A-python Python bindings enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants