mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-14 15:52:26 +00:00
this PR blob v2 field helpers and reads to the Node SDK.
`blob()` marks a field as blob v2 and lets you set the storage
thresholds. Inputs can be bytes, a URI, or a data/uri struct.
Queries return descriptors. `fetchBlobs()` reads the bytes by row ID,
and `fetchBlobFiles()` gives you lazy handles for full or range reads.
`blobColumns()` lists the blob fields, including nested ones.
Fetch uses the table’s current checkout. It preserves order, duplicates,
and nulls. Holding row IDs across compaction still requires stable row
IDs.
```javascript
const db = await connect("./data");
const video = await readFile("clip.mp4");
const table = await db.createTable(
"videos",
[{ id: 1n, video }],
{
schema: new Schema([
new Field("id", new Int64()),
blob("video"),
]),
},
);
const rows = await table.query().select(["id"]).withRowId().toArray();
const rowIds = rows.map((row) => row._rowid as bigint);
const bytes = await table.fetchBlobs("video", rowIds);
const [handle] = await table.fetchBlobFiles("video", rowIds);
const header = await handle!.readRange(0n, 65536n);
```
### Testing
- cover input validation, thresholds, nested fields, fetch ordering,
nulls, and range reads.
873 B
873 B
@lancedb/lancedb • Docs
@lancedb/lancedb / BlobFile
Class: BlobFile
A lazy handle to blob bytes. Create one with Table.fetchBlobFiles.
Methods
read()
read(): Promise<Buffer>
Reads from the cursor to the end and advances the cursor.
A second call returns an empty buffer. BlobFile.readRange does not move the cursor.
Returns
Promise<Buffer>
readRange()
readRange(start, end): Promise<Buffer>
Reads the half-open byte range [start, end).
Fails when end is past the blob size. Does not move the cursor.
Parameters
-
start:
bigint -
end:
bigint
Returns
Promise<Buffer>
size()
size(): bigint
Returns the blob size in bytes.
Returns
bigint