refactor(sdk)!: flatten Optimize options across bindings

BREAKING CHANGE: Pass Optimize settings as Python keyword arguments or one flat TypeScript OptimizeOptions object. Remove data_options/dataOptions wrappers and OptimizeDataOptions, accept Rust OptimizeOptions directly, retain OptimizeOverrides for field presence, and rename index-maintenance options to IndexOptimizeOptions.
This commit is contained in:
ChilePiquin
2026-11-19 15:40:25 -08:00
parent c3c26b8c6e
commit ba2e7f650b
35 changed files with 617 additions and 534 deletions
+4 -4
View File
@@ -1085,13 +1085,13 @@ supported. Pruning old versions and index optimization are silently
skipped there instead of being attempted, so this call resolves
successfully with placeholder statistics (not completed work) once the
compaction job has been submitted; it does not wait for that job to finish.
`dataOptions` can tune the four per-job settings documented in
[OptimizeDataOptions](../interfaces/OptimizeDataOptions.md). Older-server errors are propagated without
The flat options tune the four per-job settings documented in
[OptimizeOptions](../interfaces/OptimizeOptions.md). Older-server errors are propagated without
retrying with the settings removed.
#### Parameters
* **options?**: `Partial`<[`OptimizeOptions`](../interfaces/OptimizeOptions.md)>
* **options?**: [`OptimizeOptions`](../interfaces/OptimizeOptions.md)
#### Returns
@@ -1117,7 +1117,7 @@ Reopen with db.openJob<OptimizeResult>(job.id!). A wait timeout does not cancel
#### Parameters
* **\_options?**: [`OptimizeDataOptions`](../interfaces/OptimizeDataOptions.md)
* **\_options?**: [`OptimizeOptions`](../interfaces/OptimizeOptions.md)
#### Returns
-1
View File
@@ -126,7 +126,6 @@
- [NativeOAuthConfig](interfaces/NativeOAuthConfig.md)
- [OAuthConfig](interfaces/OAuthConfig.md)
- [OpenTableOptions](interfaces/OpenTableOptions.md)
- [OptimizeDataOptions](interfaces/OptimizeDataOptions.md)
- [OptimizeOptions](interfaces/OptimizeOptions.md)
- [OptimizeResult](interfaces/OptimizeResult.md)
- [OptimizeStats](interfaces/OptimizeStats.md)
@@ -1,49 +0,0 @@
[**@lancedb/lancedb**](../README.md) • **Docs**
***
[@lancedb/lancedb](../globals.md) / OptimizeDataOptions
# Interface: OptimizeDataOptions
Per-invocation compaction settings. Values must be safe integers.
## Properties
### batchSize?
```ts
optional batchSize: number;
```
Positive scanner batch size in rows.
***
### ioBufferSize?
```ts
optional ioBufferSize: number;
```
Scanner I/O read-ahead budget in bytes; zero disables byte-based I/O backpressure.
***
### maxSourceRows?
```ts
optional maxSourceRows: number;
```
Positive live-source-row budget across whole tasks; an oversized first task can produce no work.
***
### targetRowsPerFragment?
```ts
optional targetRowsPerFragment: number;
```
Positive target rows per output fragment; also affects candidate selection.
+44 -45
View File
@@ -6,6 +6,9 @@
# Interface: OptimizeOptions
Flat Optimize settings for submission and durable jobs.
Remote jobs support data rewrites; cleanup options are Embedded-only.
## Properties
### action?
@@ -14,70 +17,66 @@
optional action: "rewrite_data";
```
Run only data compaction, preserving versions and skipping separate index
maintenance. Omit for Embedded's full maintenance cycle. Cannot be combined
with cleanup options. Enterprise always submits data compaction only.
Run only data rewriting, retaining history and skipping separate index maintenance.
***
### cleanupOlderThan
### batchSize?
```ts
cleanupOlderThan: Date;
optional batchSize: number;
```
If set then all versions older than the given date
be removed. The current version will never be removed.
The default is 7 days
#### Example
```ts
// Delete all versions older than 1 day
const olderThan = new Date();
olderThan.setDate(olderThan.getDate() - 1));
tbl.optimize({cleanupOlderThan: olderThan});
// Delete versions committed before this point. Versions created by the
// optimize call itself are newer than the cutoff and will be retained.
tbl.optimize({cleanupOlderThan: new Date()});
```
Positive scanner batch size in rows.
***
### dataOptions?
### cleanupOlderThan?
```ts
optional dataOptions: OptimizeDataOptions;
optional cleanupOlderThan: Date;
```
Compaction settings for this invocation. Omitted remote values inherit table
tuning, then deployment/built-in defaults.
Remote tables require a server supporting these SQL options; settings do
not change table policy. This is not a runtime or total-memory limit.
#### Example
```ts
await tbl.optimize({ dataOptions: {
targetRowsPerFragment: 1000, maxSourceRows: 5000,
ioBufferSize: 64 * 1024 * 1024, batchSize: 128,
} });
```
Embedded: remove versions committed before this cutoff. Defaults to seven days ago.
Cannot be combined with action="rewrite_data" or used with durable Optimize jobs.
***
### deleteUnverified
### deleteUnverified?
```ts
deleteUnverified: boolean;
optional deleteUnverified: boolean;
```
Because they may be part of an in-progress transaction, files newer than
7 days old are not deleted by default. If you are sure that there are no
in-progress transactions, then you can set this to true to delete all
files older than `cleanupOlderThan`.
Embedded: also remove unverified files. Only enable when no other process
can be writing this dataset. Defaults to false; unavailable for durable jobs.
**WARNING**: This should only be set to true if you can guarantee that
no other process is currently working on this dataset. Otherwise the
dataset could be put into a corrupted state.
***
### ioBufferSize?
```ts
optional ioBufferSize: number;
```
Scanner read-ahead budget in bytes; zero disables byte-based backpressure.
***
### maxSourceRows?
```ts
optional maxSourceRows: number;
```
Positive live-source-row budget across whole rewrite tasks.
***
### targetRowsPerFragment?
```ts
optional targetRowsPerFragment: number;
```
Positive target rows per output fragment. Omitted remote values inherit table policy.
+6 -8
View File
@@ -377,7 +377,7 @@ warning-only no-op; the former `compact_files()` method is removed.
`optimize` submits a durable compaction job and returns once that submission is
accepted, not once compaction itself finishes. Pruning and index optimization
are not yet supported remotely, so it silently skips them and returns with
zeroed pruning statistics. Remote `data_options` support per-job
zeroed pruning statistics. Remote Optimize supports per-job
`target_rows_per_fragment`, `max_source_rows`, `io_buffer_size`, and `batch_size`
on compatible servers. Other non-default settings raise `NotImplementedError`
before submission; older-server errors are returned without dropping options.
@@ -390,12 +390,10 @@ unchanged. Table `enabled` controls automatic scheduling; explicit manual runs
remain allowed.
```python
table.optimize(data_options={
"target_rows_per_fragment": 100_000,
"max_source_rows": 1_000_000,
"io_buffer_size": 64 * 1024 * 1024,
"batch_size": 1024,
})
table.optimize(target_rows_per_fragment=100_000,
max_source_rows=1_000_000,
io_buffer_size=64 * 1024 * 1024,
batch_size=1024)
```
Removed Tantivy options produce the same explanatory errors on both backends.
@@ -409,7 +407,7 @@ code that used the former LanceDB Enterprise-only argument order.
::: lancedb.table.Table
::: lancedb.table.OptimizeDataOptions
::: lancedb.table.OptimizeOptions
::: lancedb.table.FragmentStatistics