diff --git a/docs/src/js/globals.md b/docs/src/js/globals.md index 0f582b10f..09afacec5 100644 --- a/docs/src/js/globals.md +++ b/docs/src/js/globals.md @@ -104,6 +104,7 @@ - [UpdateResult](interfaces/UpdateResult.md) - [Version](interfaces/Version.md) - [WriteExecutionOptions](interfaces/WriteExecutionOptions.md) +- [WriteProgress](interfaces/WriteProgress.md) ## Type Aliases diff --git a/docs/src/js/interfaces/AddDataOptions.md b/docs/src/js/interfaces/AddDataOptions.md index 187721c00..3c787b4fd 100644 --- a/docs/src/js/interfaces/AddDataOptions.md +++ b/docs/src/js/interfaces/AddDataOptions.md @@ -19,3 +19,39 @@ mode: "append" | "overwrite"; If "append" (the default) then the new data will be added to the table If "overwrite" then the new data will replace the existing data in the table. + +*** + +### progress() + +```ts +progress: (progress) => void; +``` + +Optional callback invoked periodically with write progress. + +The callback is fired once per batch written and once more with +`done: true` when the write completes. Calls are non-blocking — if the +callback is slow, intermediate updates may be dropped to avoid stalling +the write. + +Errors thrown from the callback are logged with `console.warn` and +swallowed — they do not abort the write. + +#### Parameters + +* **progress**: [`WriteProgress`](WriteProgress.md) + +#### Returns + +`void` + +#### Example + +```ts +await table.add(data, { + progress: (p) => { + console.log(`${p.outputRows}/${p.totalRows ?? "?"} rows`); + }, +}); +``` diff --git a/docs/src/js/interfaces/WriteProgress.md b/docs/src/js/interfaces/WriteProgress.md new file mode 100644 index 000000000..e547b91a1 --- /dev/null +++ b/docs/src/js/interfaces/WriteProgress.md @@ -0,0 +1,84 @@ +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / WriteProgress + +# Interface: WriteProgress + +Progress snapshot for a write operation, delivered to the `progress` +callback passed to [Table.add](../classes/Table.md#add). + +## Properties + +### activeTasks + +```ts +activeTasks: number; +``` + +Number of parallel write tasks currently in flight. + +*** + +### done + +```ts +done: boolean; +``` + +`true` for the final callback; `false` otherwise. + +*** + +### elapsedSeconds + +```ts +elapsedSeconds: number; +``` + +Wall-clock seconds since the write started. + +*** + +### outputBytes + +```ts +outputBytes: number; +``` + +Number of bytes written so far. + +*** + +### outputRows + +```ts +outputRows: number; +``` + +Number of rows written so far. + +*** + +### totalRows? + +```ts +optional totalRows: number; +``` + +Total rows expected, when the input source reports it. + +Always set on the final callback (the one with `done: true`), falling +back to the actual number of rows written when the source could not +report a row count up front. + +*** + +### totalTasks + +```ts +totalTasks: number; +``` + +Total number of parallel write tasks (the write parallelism).