mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-27 04:53:59 +00:00
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:
@@ -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`<`null` \| [`BlobFile`](BlobFile.md)>
|
||||
|
||||
#### 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`<`null` \| [`BlobDescriptor`](../interfaces/BlobDescriptor.md)>
|
||||
|
||||
* **options?**: [`BlobReadOptions`](../type-aliases/BlobReadOptions.md)
|
||||
|
||||
#### Returns
|
||||
|
||||
`AsyncGenerator`<`null` \| [`BlobFile`](BlobFile.md), `any`, `unknown`>
|
||||
|
||||
***
|
||||
|
||||
### optimize()
|
||||
|
||||
```ts
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
```
|
||||
Reference in New Issue
Block a user