mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +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:
+19
-1
@@ -19,7 +19,10 @@ use napi::bindgen_prelude::*;
|
||||
use napi::threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode};
|
||||
use napi_derive::napi;
|
||||
|
||||
use crate::blob::{BlobFile, BlobRangeRequest, copy_blob_buffers, parse_row_ids, spawn_abortable};
|
||||
use crate::blob::{
|
||||
BlobDescriptorInput, BlobFile, BlobRangeRequest, copy_blob_buffers, parse_row_ids,
|
||||
spawn_abortable,
|
||||
};
|
||||
use crate::error::{NapiErrorExt, convert_error};
|
||||
use crate::index::Index;
|
||||
use crate::iterator::RecordBatchIterator;
|
||||
@@ -626,6 +629,21 @@ impl Table {
|
||||
})
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
pub fn open_blob_file<'env>(
|
||||
&self,
|
||||
env: &'env Env,
|
||||
descriptor: BlobDescriptorInput,
|
||||
signal: Option<AbortSignal>,
|
||||
) -> napi::Result<PromiseRaw<'env, BlobFile>> {
|
||||
let descriptor = descriptor.into_descriptor()?;
|
||||
let table = self.inner_ref()?.clone();
|
||||
spawn_abortable(env, signal, async move {
|
||||
let file = table.open_blob_file(&descriptor).await.default_error()?;
|
||||
Ok(BlobFile::new(file))
|
||||
})
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
pub fn vector_search(&self, vector: Float32Array) -> napi::Result<VectorQuery> {
|
||||
self.query()?.nearest_to(vector)
|
||||
|
||||
Reference in New Issue
Block a user