mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +00:00
feat(python): open blob files by row offset (#5356)
Open seekable Blob files by row position with `table.take_blob_files(column, offsets, *, buffer_size=None)` on synchronous and asynchronous Embedded and Enterprise tables. Results follow the requested order, duplicate offsets have independent cursors, and NULL and empty values stay distinct. An invalid offset rejects the entire batch. Enterprise resolves positions and descriptors together and verifies one snapshot across descriptor queries, location resolution, and authenticated byte reads. Eligible ranges use the existing presigned read path when the gateway advertises it. Refs [OSS-2881](https://linear.app/lancedb/issue/OSS-2881). ## Validation - On Enterprise 1.16.0, the same locked wheel passed both sync and async reads of 1,025 distinct offsets after a deletion. The offsets matched an independent ordered query, and the two descriptor chunks and subsequent authenticated requests matched the pinned version and snapshot identity. - Both APIs returned byte-for-byte matches for 37-byte proxy reads and a 32 MiB presigned object-store read. The large reads used zero gateway byte requests. An independent range check returned two object-store HTTP 206 responses with matching physical ranges and bytes. - The wheel passed 23 focused Python tests. The Rust library check and all 81 Enterprise Blob module tests passed, including nested NULL and strict snapshot echo cases. Runtime evidence is from commit `f56c359ba7874cd75c52169491166a941251510f` with Lance `16.0.0-beta.6`, wheel SHA-256 `9abbbfe584513432547d237dcf7b684b479b35cad07c48cd9899d381f0e80423`. The merge preview with `main` at `ff556729` is clean. [#5352](https://github.com/lancedb/lancedb/pull/5352) updates the integration dependencies to Lance `16.0.0-beta.7` and `object_store` `0.14.2`. Those pins are outside the tested wheel's coverage. The synthetic test table was removed from the catalog. Its physical storage cleanup is tracked separately.
This commit is contained in:
@@ -795,7 +795,26 @@ Hybrid byte queries require matching snapshot provenance from both responses.
|
||||
|
||||
#### Read blobs on demand {#multimodal-read-blobs}
|
||||
|
||||
Query the rows you want and pass their `_rowid` values to a fetch method.
|
||||
When you have row positions, Python's `take_blob_files` opens seekable handles
|
||||
from the table's visible snapshot. This example reads the header at position 5
|
||||
and closes the file afterward.
|
||||
|
||||
```python
|
||||
[video] = table.take_blob_files("video", [5], buffer_size=0)
|
||||
if video is not None:
|
||||
with video:
|
||||
header = video.read(4096)
|
||||
```
|
||||
|
||||
Offsets are zero-based among live rows and may change when the table advances.
|
||||
Results follow the input order. Duplicate offsets have independent cursors,
|
||||
null blobs return `None`, and empty blobs return a file of size zero. A negative
|
||||
or out-of-range offset rejects the whole batch. On an async table, use
|
||||
`await table.take_blob_files(...)` and `await file.aread()` for asynchronous reads.
|
||||
Enterprise supports Blob V2 columns on native tables with a gateway that
|
||||
verifies query snapshots. Realtime/MemWAL tables are unsupported.
|
||||
|
||||
When selecting rows with a query, pass their `_rowid` values to a fetch method.
|
||||
`fetch_blob_files` opens a seekable handle and loads bytes only when you read.
|
||||
The Python example opens the JPEG from the ingest step and reads its EXIF
|
||||
Make tag with Pillow. TypeScript and Rust read the first bytes from the handle.
|
||||
|
||||
Reference in New Issue
Block a user