mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
Merge branch 'merge-insert-source-stats' into merge-insert-source-stats-bindings
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "lancedb-nodejs"
|
||||
edition.workspace = true
|
||||
version = "0.42.0-beta.9"
|
||||
version = "0.42.0-beta.10"
|
||||
publish = false
|
||||
license.workspace = true
|
||||
description.workspace = true
|
||||
|
||||
@@ -682,6 +682,7 @@ describe("remote connection", () => {
|
||||
const job = await table.refreshColumnAsync("embedding", {
|
||||
where: "id % 2 = 0",
|
||||
batchSize: 16,
|
||||
maxConcurrency: 3,
|
||||
gpuClass: "a10g",
|
||||
gpuCount: 2,
|
||||
errorPolicy: "skip",
|
||||
@@ -693,6 +694,17 @@ describe("remote connection", () => {
|
||||
});
|
||||
expect(job.id).toBe("j-9");
|
||||
await table.refreshColumnAsync("embedding");
|
||||
await table.refreshColumnAsync("embedding", {
|
||||
resourceBudget: {
|
||||
cpuMillis: 8_000,
|
||||
memoryBytes: 16 * 1024 ** 3,
|
||||
},
|
||||
});
|
||||
await expect(
|
||||
table.refreshColumnAsync("embedding", {
|
||||
maxConcurrency: true as unknown as number,
|
||||
}),
|
||||
).rejects.toThrow();
|
||||
// Invalid options reject before any request is sent.
|
||||
for (const [options, message] of [
|
||||
[{ maxFailedRows: -1 }, "maxFailedRows"],
|
||||
@@ -700,8 +712,83 @@ describe("remote connection", () => {
|
||||
[{ where: " " }, "where"],
|
||||
[{ maxFailedFraction: 2 }, "max_failed_fraction"],
|
||||
[{ rowTimeoutSeconds: 0 }, "row_timeout_seconds"],
|
||||
[{ maxConcurrency: 1.5 }, "maxConcurrency"],
|
||||
[{ maxConcurrency: 0 }, "maxConcurrency"],
|
||||
[{ maxConcurrency: -1 }, "maxConcurrency"],
|
||||
[{ maxConcurrency: 2 ** 32 }, "maxConcurrency"],
|
||||
[{ maxConcurrency: Number.NaN }, "maxConcurrency"],
|
||||
[{ maxConcurrency: Number.POSITIVE_INFINITY }, "maxConcurrency"],
|
||||
[{ numWorkers: 0 }, "num_workers"],
|
||||
[{ gpuCount: 0 }, "gpu_count"],
|
||||
[
|
||||
{
|
||||
resourceBudget: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
},
|
||||
gpuCount: 1,
|
||||
},
|
||||
"gpu_count cannot be combined with resource_budget",
|
||||
],
|
||||
[
|
||||
{
|
||||
resourceBudget: {
|
||||
cpuMillis: 0,
|
||||
memoryBytes: 1_024,
|
||||
},
|
||||
},
|
||||
"resourceBudget.cpuMillis",
|
||||
],
|
||||
[
|
||||
{
|
||||
resourceBudget: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
gpuCount: 1.5,
|
||||
},
|
||||
},
|
||||
"resourceBudget.gpuCount",
|
||||
],
|
||||
[
|
||||
{
|
||||
resourceBudget: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
gpuCount: -1,
|
||||
},
|
||||
},
|
||||
"resourceBudget.gpuCount",
|
||||
],
|
||||
[
|
||||
{
|
||||
resourceBudget: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
gpuCount: 2 ** 32,
|
||||
},
|
||||
},
|
||||
"resourceBudget.gpuCount",
|
||||
],
|
||||
[
|
||||
{
|
||||
resourceBudget: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
gpuCount: Number.NaN,
|
||||
},
|
||||
},
|
||||
"resourceBudget.gpuCount",
|
||||
],
|
||||
[
|
||||
{
|
||||
resourceBudget: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
gpuCount: Number.POSITIVE_INFINITY,
|
||||
},
|
||||
},
|
||||
"resourceBudget.gpuCount",
|
||||
],
|
||||
] as const) {
|
||||
await expect(
|
||||
table.refreshColumnAsync("embedding", options),
|
||||
@@ -712,12 +799,21 @@ describe("remote connection", () => {
|
||||
expect(bodies).toEqual([
|
||||
JSON.parse(
|
||||
`{"column": "embedding", "where": "id % 2 = 0", "batch_size": 16,
|
||||
"gpu_class": "a10g", "gpu_count": 2, "error_policy": "skip",
|
||||
"max_concurrency": 3, "gpu_class": "a10g", "gpu_count": 2,
|
||||
"error_policy": "skip",
|
||||
"max_failed_fraction": 0.01, "max_failed_rows": 50,
|
||||
"row_timeout_seconds": 30, "init_timeout_seconds": 120,
|
||||
"max_executor_processes_per_worker": 2}`,
|
||||
),
|
||||
{ column: "embedding" },
|
||||
JSON.parse(
|
||||
`{"column": "embedding",
|
||||
"resource_budget": {
|
||||
"cpu_millis": 8000,
|
||||
"memory_bytes": 17179869184,
|
||||
"gpu_count": 0
|
||||
}}`,
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -5696,6 +5696,14 @@ describe("computed columns", () => {
|
||||
await expect(
|
||||
table.refreshColumnAsync("x", { errorPolicy: "skip" }),
|
||||
).rejects.toThrow("error_policy requires a LanceDB Enterprise refresh");
|
||||
await expect(
|
||||
table.refreshColumnAsync("x", { maxConcurrency: 4 }),
|
||||
).rejects.toThrow("max_concurrency requires a LanceDB Enterprise refresh");
|
||||
await expect(
|
||||
table.refreshColumnAsync("x", {
|
||||
resourceBudget: { cpuMillis: 1_000, memoryBytes: 1_024 },
|
||||
}),
|
||||
).rejects.toThrow("resource_budget requires a LanceDB Enterprise refresh");
|
||||
});
|
||||
|
||||
it("records Function errors only on remote tables", async () => {
|
||||
|
||||
@@ -57,6 +57,7 @@ export {
|
||||
AddResult,
|
||||
AddColumnsResult,
|
||||
RefreshColumnOptions,
|
||||
FunctionWorkerResourceBudget,
|
||||
RefreshColumnResult,
|
||||
FunctionErrors,
|
||||
FunctionErrorsOptions,
|
||||
|
||||
+20
-5
@@ -722,15 +722,30 @@ export abstract class Table {
|
||||
* @param {RefreshColumnOptions} options Refresh options, mirroring the SQL
|
||||
* `REFRESH COLUMN ... WHERE ... WITH (...)` form: `where` narrows the rows,
|
||||
* `errorPolicy`, `maxFailedFraction`, `maxFailedRows`, `rowTimeoutSeconds`
|
||||
* and `initTimeoutSeconds` govern failing rows, and `batchSize`,
|
||||
* `gpuClass`, `gpuCount`, `numWorkers` and `maxExecutorProcessesPerWorker`
|
||||
* size the workers. All are LanceDB Enterprise only; a LanceDB Embedded
|
||||
* refresh rejects every option other than `batchSize`, `gpuClass` and
|
||||
* `gpuCount`.
|
||||
* and `initTimeoutSeconds` govern failing rows. `batchSize`, `gpuClass`,
|
||||
* `maxConcurrency`, `resourceBudget` and
|
||||
* `maxExecutorProcessesPerWorker` size registered Function refreshes.
|
||||
* `maxConcurrency` overrides the registered default for this logical
|
||||
* execution only and is a positive integer; it is not an account-wide
|
||||
* quota. A `resourceBudget` requires `cpuMillis` and
|
||||
* `memoryBytes`; its `gpuCount` defaults to zero for a CPU-only Function.
|
||||
* The budget applies only to this explicit refresh and does not configure
|
||||
* a later automatic refresh.
|
||||
* `gpuCount` at the top level is the shorthand that preserves the
|
||||
* deployment defaults for CPU and memory, and cannot be combined with
|
||||
* `resourceBudget`. `numWorkers` applies only to expression columns; use
|
||||
* `resourceBudget` for registered Functions. All are LanceDB Enterprise
|
||||
* only; a LanceDB Embedded refresh rejects every option other than
|
||||
* `batchSize`, `gpuClass` and `gpuCount`.
|
||||
* @example
|
||||
* ```ts
|
||||
* const job = await table.refreshColumnAsync("embedding", {
|
||||
* where: "published_at > '2026-01-01'",
|
||||
* resourceBudget: {
|
||||
* cpuMillis: 8000,
|
||||
* memoryBytes: 16 * 1024 ** 3,
|
||||
* },
|
||||
* maxConcurrency: 4,
|
||||
* errorPolicy: "skip",
|
||||
* maxFailedFraction: 0.01,
|
||||
* rowTimeoutSeconds: 30,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-darwin-arm64",
|
||||
"version": "0.42.0-beta.9",
|
||||
"version": "0.42.0-beta.10",
|
||||
"os": ["darwin"],
|
||||
"cpu": ["arm64"],
|
||||
"main": "lancedb.darwin-arm64.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-arm64-gnu",
|
||||
"version": "0.42.0-beta.9",
|
||||
"version": "0.42.0-beta.10",
|
||||
"os": ["linux"],
|
||||
"cpu": ["arm64"],
|
||||
"main": "lancedb.linux-arm64-gnu.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-arm64-musl",
|
||||
"version": "0.42.0-beta.9",
|
||||
"version": "0.42.0-beta.10",
|
||||
"os": ["linux"],
|
||||
"cpu": ["arm64"],
|
||||
"main": "lancedb.linux-arm64-musl.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-x64-gnu",
|
||||
"version": "0.42.0-beta.9",
|
||||
"version": "0.42.0-beta.10",
|
||||
"os": ["linux"],
|
||||
"cpu": ["x64"],
|
||||
"main": "lancedb.linux-x64-gnu.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-x64-musl",
|
||||
"version": "0.42.0-beta.9",
|
||||
"version": "0.42.0-beta.10",
|
||||
"os": ["linux"],
|
||||
"cpu": ["x64"],
|
||||
"main": "lancedb.linux-x64-musl.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-win32-arm64-msvc",
|
||||
"version": "0.42.0-beta.9",
|
||||
"version": "0.42.0-beta.10",
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-win32-x64-msvc",
|
||||
"version": "0.42.0-beta.9",
|
||||
"version": "0.42.0-beta.10",
|
||||
"os": ["win32"],
|
||||
"cpu": ["x64"],
|
||||
"main": "lancedb.win32-x64-msvc.node",
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
"ann"
|
||||
],
|
||||
"private": false,
|
||||
"version": "0.42.0-beta.9",
|
||||
"version": "0.42.0-beta.10",
|
||||
"main": "dist/index.js",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
|
||||
+73
-2
@@ -9,7 +9,8 @@ use lancedb::ipc::{ipc_file_to_batches, ipc_file_to_schema};
|
||||
use lancedb::table::{
|
||||
AddDataMode, ColumnAlteration as LanceColumnAlteration,
|
||||
FieldMetadataUpdate as LanceFieldMetadataUpdate, FtsToken as LanceDbFtsToken,
|
||||
NewColumnTransform, Ref, Table as LanceDbTable,
|
||||
FunctionWorkerResourceBudget as LanceFunctionWorkerResourceBudget, NewColumnTransform, Ref,
|
||||
Table as LanceDbTable,
|
||||
};
|
||||
use napi::Env;
|
||||
use napi::bindgen_prelude::*;
|
||||
@@ -1586,9 +1587,60 @@ pub struct FunctionErrorsOptions {
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
/// Aggregate worker resources for one Enterprise Function refresh.
|
||||
#[napi(object)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FunctionWorkerResourceBudget {
|
||||
/// Aggregate CPU budget in millicores; 1000 is one CPU.
|
||||
pub cpu_millis: f64,
|
||||
/// Aggregate memory budget in bytes.
|
||||
pub memory_bytes: f64,
|
||||
/// Aggregate GPU budget. Omitted means zero, a CPU-only refresh.
|
||||
pub gpu_count: Option<f64>,
|
||||
}
|
||||
|
||||
fn resource_budget_integer(value: f64, name: &str) -> napi::Result<u64> {
|
||||
const MAX_SAFE_INTEGER: f64 = 9_007_199_254_740_991.0;
|
||||
if !value.is_finite() || value.fract() != 0.0 || !(1.0..=MAX_SAFE_INTEGER).contains(&value) {
|
||||
return Err(napi::Error::from_reason(format!(
|
||||
"{name} must be a positive safe integer"
|
||||
)));
|
||||
}
|
||||
Ok(value as u64)
|
||||
}
|
||||
|
||||
fn resource_budget_gpu_count(value: Option<f64>) -> napi::Result<u32> {
|
||||
let Some(value) = value else {
|
||||
return Ok(0);
|
||||
};
|
||||
if !value.is_finite() || value.fract() != 0.0 || !(0.0..=u32::MAX as f64).contains(&value) {
|
||||
return Err(napi::Error::from_reason(
|
||||
"resourceBudget.gpuCount must be an integer between 0 and 4294967295",
|
||||
));
|
||||
}
|
||||
Ok(value as u32)
|
||||
}
|
||||
|
||||
fn positive_u32(value: Option<f64>, name: &str) -> napi::Result<Option<u32>> {
|
||||
value
|
||||
.map(|value| {
|
||||
if !value.is_finite()
|
||||
|| value.fract() != 0.0
|
||||
|| !(1.0..=u32::MAX as f64).contains(&value)
|
||||
{
|
||||
return Err(napi::Error::from_reason(format!(
|
||||
"{name} must be an integer between 1 and 4294967295"
|
||||
)));
|
||||
}
|
||||
Ok(value as u32)
|
||||
})
|
||||
.transpose()
|
||||
}
|
||||
|
||||
/// Options for `Table.refreshColumn` and `Table.refreshColumnAsync`. Every
|
||||
/// option is LanceDB Enterprise only; a LanceDB Embedded refresh ignores
|
||||
/// `batchSize`, `gpuClass` and `gpuCount` and rejects the rest.
|
||||
/// `batchSize`, `gpuClass` and `gpuCount` and rejects the rest, including
|
||||
/// `resourceBudget`.
|
||||
#[napi(object)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct RefreshColumnOptions {
|
||||
@@ -1597,8 +1649,14 @@ pub struct RefreshColumnOptions {
|
||||
pub where_clause: Option<String>,
|
||||
/// Maximum rows per Function call; must be greater than zero.
|
||||
pub batch_size: Option<u32>,
|
||||
/// Override the registered Function's maximum concurrent user-code calls
|
||||
/// for this logical execution.
|
||||
pub max_concurrency: Option<f64>,
|
||||
/// GPU class for Function workers.
|
||||
pub gpu_class: Option<String>,
|
||||
/// Complete aggregate CPU and memory budget for a registered Function
|
||||
/// refresh. `gpuCount` inside the budget defaults to zero.
|
||||
pub resource_budget: Option<FunctionWorkerResourceBudget>,
|
||||
/// Positive aggregate GPU budget for Function workers.
|
||||
pub gpu_count: Option<u32>,
|
||||
/// `"fail"` (default) stops on a row error; `"skip"` writes null and
|
||||
@@ -1627,7 +1685,20 @@ impl TryFrom<RefreshColumnOptions> for lancedb::table::RefreshColumnOptions {
|
||||
let mut options = Self::default();
|
||||
options.where_clause = value.where_clause;
|
||||
options.batch_size = value.batch_size.map(|size| size as usize);
|
||||
options.max_concurrency = positive_u32(value.max_concurrency, "maxConcurrency")?;
|
||||
options.gpu_class = value.gpu_class;
|
||||
options.resource_budget = value
|
||||
.resource_budget
|
||||
.map(|budget| {
|
||||
Ok::<_, napi::Error>(
|
||||
LanceFunctionWorkerResourceBudget::new(
|
||||
resource_budget_integer(budget.cpu_millis, "resourceBudget.cpuMillis")?,
|
||||
resource_budget_integer(budget.memory_bytes, "resourceBudget.memoryBytes")?,
|
||||
)
|
||||
.with_gpu_count(resource_budget_gpu_count(budget.gpu_count)?),
|
||||
)
|
||||
})
|
||||
.transpose()?;
|
||||
options.gpu_count = value.gpu_count;
|
||||
options.error_policy = match value.error_policy.as_deref() {
|
||||
None => None,
|
||||
|
||||
Reference in New Issue
Block a user