feat(nodejs): open source-bearing blob descriptors (#5238)

Add `Table.openBlobFile` and `Table.openBlobFiles` for source-bearing
SQL `blob_descriptor` results, matching the existing Rust and Python
APIs.

The TypeScript methods forward the descriptor to the shared Rust opener
instead of reimplementing routing. That keeps the 10 MiB direct-read
threshold, pinned snapshot identity, resolver refresh, and 503
single-shot proxy fallback identical to `fetchBlobFiles` and the other
public Blob V2 entries. Descriptor fields remain the snake_case shape
returned by Arrow/SQL; the wrapper converts unsigned 64-bit values to
`bigint` at the NAPI boundary and returns `null` for null descriptors.
Existing custom `Table` subclasses keep working through a default "not
supported" implementation.

Validation:
- `pnpm tsc`
- `pnpm lint`
- `pnpm test --runInBand __test__/blob_open.test.ts
__test__/blob_ranges.test.ts __test__/remote_blob_snapshot.test.ts` — 65
passed
- focused Rust core tests for direct opens, threshold routing, snapshot
preservation, and 503 fallback — passed

The docs also update the TypeScript cross-row range table and example;
`fetchBlobRanges` was already implemented but was still documented as
unavailable.
This commit is contained in:
Xuanwo
2026-11-27 00:16:29 +08:00
committed by GitHub
parent 85dcf3a3c5
commit 1c0118015c
14 changed files with 692 additions and 36 deletions
+61
View File
@@ -1229,6 +1229,67 @@ rows depending on how they match.
***
### openBlobFile()
```ts
openBlobFile(_descriptor, _options?): Promise<null | BlobFile>
```
Opens a lazy handle from a source-bearing SQL `blob_descriptor` result.
The descriptor's source pins the table version, branch, column and row
identity, so opening does not change this table's checkout. Null
descriptors return `null`. Payload bytes load only when the returned
handle is read. Pass BlobReadOptions.signal to cancel the open.
#### Parameters
* **\_descriptor**: `null` \| [`BlobDescriptor`](../interfaces/BlobDescriptor.md)
* **\_options?**: [`BlobReadOptions`](../type-aliases/BlobReadOptions.md)
#### Returns
`Promise`&lt;`null` \| [`BlobFile`](BlobFile.md)&gt;
#### Example
```ts
const rows = await table
.query()
.select({ video: "blob_descriptor(video)" })
.toArray();
const handle = await table.openBlobFile(rows[0].video);
if (handle) {
const header = await handle.readRange(0n, 16n);
await handle.close();
}
```
***
### openBlobFiles()
```ts
openBlobFiles(descriptors, options?): AsyncGenerator<null | BlobFile, any, unknown>
```
Opens source-bearing descriptors in iteration order, preserving nulls.
Handles open lazily as the iterable advances. Close each non-null handle
after use.
#### Parameters
* **descriptors**: `Iterable`&lt;`null` \| [`BlobDescriptor`](../interfaces/BlobDescriptor.md)&gt;
* **options?**: [`BlobReadOptions`](../type-aliases/BlobReadOptions.md)
#### Returns
`AsyncGenerator`&lt;`null` \| [`BlobFile`](BlobFile.md), `any`, `unknown`&gt;
***
### optimize()
```ts
+2
View File
@@ -63,6 +63,8 @@
- [AddDataOptions](interfaces/AddDataOptions.md)
- [AddResult](interfaces/AddResult.md)
- [AlterColumnsResult](interfaces/AlterColumnsResult.md)
- [BlobDescriptor](interfaces/BlobDescriptor.md)
- [BlobDescriptorSource](interfaces/BlobDescriptorSource.md)
- [BranchColumnChange](interfaces/BranchColumnChange.md)
- [BranchColumnSummary](interfaces/BranchColumnSummary.md)
- [BranchDiff](interfaces/BranchDiff.md)
+59
View File
@@ -0,0 +1,59 @@
[**@lancedb/lancedb**](../README.md) • **Docs**
***
[@lancedb/lancedb](../globals.md) / BlobDescriptor
# Interface: BlobDescriptor
A source-bearing Blob V2 descriptor accepted by [Table.openBlobFile](../classes/Table.md#openblobfile).
Query results expose these fields as an Arrow struct. The source pins the
table version, branch, column and row identity used to open the handle.
## Properties
### blob\_id
```ts
blob_id: number;
```
***
### blob\_uri
```ts
blob_uri: string;
```
***
### kind
```ts
kind: number;
```
***
### position
```ts
position: number | bigint;
```
***
### size
```ts
size: number | bigint;
```
***
### source
```ts
source: BlobDescriptorSource;
```
@@ -0,0 +1,66 @@
[**@lancedb/lancedb**](../README.md) • **Docs**
***
[@lancedb/lancedb](../globals.md) / BlobDescriptorSource
# Interface: BlobDescriptorSource
A source-bearing Blob V2 descriptor returned by the SQL `blob_descriptor`
function. Field names match the descriptor object/Arrow struct shape.
## Properties
### branch?
```ts
optional branch: null | string;
```
***
### column
```ts
column: string;
```
***
### committed\_at\_micros
```ts
committed_at_micros: number | bigint;
```
***
### row\_is\_address
```ts
row_is_address: boolean;
```
***
### row\_reference
```ts
row_reference: number | bigint;
```
***
### uri
```ts
uri: string;
```
***
### version
```ts
version: number | bigint;
```