mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
fix(sdk): align Optimize behavior and inherit Embedded policy
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
"""Results of durable remote Optimize jobs."""
|
||||
"""Results of durable Enterprise Optimize jobs."""
|
||||
|
||||
from dataclasses import dataclass, fields
|
||||
import json
|
||||
@@ -10,7 +10,7 @@ from typing import Optional
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class OptimizeResult:
|
||||
"""Actual committed outcome of one remote Optimize data rewrite.
|
||||
"""Actual committed outcome of one Enterprise Optimize data rewrite.
|
||||
|
||||
``rows_failed`` counts planned live rows that were not committed, including
|
||||
partial progress. ``more_work`` means a bounded run left eligible work for
|
||||
|
||||
@@ -1131,10 +1131,12 @@ class RemoteTable(Table):
|
||||
def optimize_async(self, **options: Unpack[OptimizeOptions]) -> Job[OptimizeResult]:
|
||||
return Job(LOOP.run(self._table.optimize_async(**options)))
|
||||
|
||||
def optimize(self, **options: Unpack[OptimizeOptions]) -> OptimizeStats:
|
||||
def optimize(
|
||||
self, *, retrain: bool = False, **options: Unpack[OptimizeOptions]
|
||||
) -> OptimizeStats:
|
||||
"""Compact the table's data files via a durable, asynchronous
|
||||
Enterprise job. Pruning old versions and index optimization are not
|
||||
yet supported remotely, so this call skips them and returns
|
||||
yet supported in Enterprise, so this call skips them and returns
|
||||
successfully with placeholder statistics once the compaction job
|
||||
has been submitted; it does not wait for that job to finish. The
|
||||
per-job options ``target_rows_per_fragment``, ``max_source_rows``,
|
||||
@@ -1144,9 +1146,7 @@ class RemoteTable(Table):
|
||||
before submission. Errors from older servers are propagated without
|
||||
retrying with the settings removed.
|
||||
"""
|
||||
tuning, cleanup, delete_unverified, retrain, action = _split_optimize_options(
|
||||
options
|
||||
)
|
||||
tuning, cleanup, delete_unverified, action = _split_optimize_options(options)
|
||||
return LOOP.run(
|
||||
self._table._do_optimize(
|
||||
_optimize_cleanup_since_ms(cleanup, retrain),
|
||||
|
||||
@@ -357,12 +357,12 @@ class OptimizeOptions(TypedDict, total=False):
|
||||
|
||||
Cleanup controls apply to Embedded convenience Optimize. Durable jobs
|
||||
reject cleanup and separate index-maintenance requests before submission.
|
||||
Unspecified options use Lance's defaults for local tables. Remote tables
|
||||
Unspecified options use Lance's defaults for Embedded tables. Enterprise tables
|
||||
forward ``target_rows_per_fragment``, ``max_source_rows``, ``io_buffer_size``,
|
||||
and ``batch_size`` as per-job SQL options; other non-default settings are
|
||||
unsupported. Omitted remote options inherit table tuning, then deployment/built-in
|
||||
defaults. The server must support these SQL options. These settings do not
|
||||
change table policy.
|
||||
unsupported. Omitted Enterprise options inherit table tuning, then
|
||||
deployment/built-in defaults. The server must support these SQL options.
|
||||
These settings do not change table policy.
|
||||
|
||||
Compaction planning is row based. Lowering ``target_rows_per_fragment``
|
||||
based on the expected row size can bound later compaction passes once
|
||||
@@ -449,16 +449,16 @@ class OptimizeOptions(TypedDict, total=False):
|
||||
"""Deprecated nested rewrite settings; pass the settings as flat keywords."""
|
||||
|
||||
cleanup_older_than: Optional[timedelta]
|
||||
"""Embedded version-retention age; unsupported by remote Optimize jobs."""
|
||||
"""Embedded version-retention age; unsupported by Enterprise Optimize jobs."""
|
||||
|
||||
delete_unverified: bool
|
||||
"""Allow Embedded cleanup of unverified files; default False."""
|
||||
|
||||
retrain: bool
|
||||
"""Deprecated convenience argument; unsupported by durable Optimize jobs."""
|
||||
|
||||
action: Optional[Literal["rewrite_data"]]
|
||||
"""Select only data rewriting; omit for Embedded's full maintenance cycle."""
|
||||
"""Convenience calls: omit for Embedded's full maintenance cycle;
|
||||
Enterprise submits rewriting only. Jobs and previews always cover rewriting.
|
||||
The only explicit action currently supported is ``rewrite_data``.
|
||||
"""
|
||||
|
||||
|
||||
# Deprecated compatibility name; use OptimizeOptions for new code.
|
||||
@@ -471,7 +471,6 @@ def _split_optimize_options(
|
||||
Optional[Dict[str, Any]],
|
||||
Optional[timedelta],
|
||||
bool,
|
||||
bool,
|
||||
Optional[Literal["rewrite_data"]],
|
||||
]:
|
||||
"""Validate the public flat request and extract maintenance controls."""
|
||||
@@ -507,11 +506,10 @@ def _split_optimize_options(
|
||||
tuning.update(legacy)
|
||||
cleanup_older_than = tuning.pop("cleanup_older_than", None)
|
||||
delete_unverified = tuning.pop("delete_unverified", False)
|
||||
retrain = tuning.pop("retrain", False)
|
||||
action = tuning.pop("action", None)
|
||||
if action not in (None, "rewrite_data"):
|
||||
raise ValueError("action must be 'rewrite_data' or None")
|
||||
if durable and (cleanup_older_than is not None or delete_unverified or retrain):
|
||||
if durable and (cleanup_older_than is not None or delete_unverified):
|
||||
raise ValueError(
|
||||
"cleanup and index-maintenance options are unsupported by Optimize jobs"
|
||||
)
|
||||
@@ -521,7 +519,7 @@ def _split_optimize_options(
|
||||
raise ValueError(
|
||||
"action='rewrite_data' cannot be combined with cleanup options"
|
||||
)
|
||||
return tuning or None, cleanup_older_than, delete_unverified, retrain, action
|
||||
return tuning or None, cleanup_older_than, delete_unverified, action
|
||||
|
||||
|
||||
# Known distance metrics for legacy API detection
|
||||
@@ -3231,14 +3229,14 @@ class Table(ABC):
|
||||
return self.optimize_async(**(compaction_options or {}))
|
||||
|
||||
def optimize_async(self, **options: Unpack[OptimizeOptions]) -> Job[OptimizeResult]:
|
||||
"""Submit remote Optimize and return a durable job after acceptance.
|
||||
"""Submit Enterprise Optimize and return a durable job after acceptance.
|
||||
|
||||
Uses SQL OPTIMIZE with the table handle's branch and namespace. Supports
|
||||
the four per-job settings in
|
||||
[OptimizeOptions][lancedb.table.OptimizeOptions].
|
||||
Requires a compatible remote server, table Ownership and parent Usage.
|
||||
Local and historical-version handles are unsupported. Existing
|
||||
``optimize()`` retains its return-on-submission behavior remotely.
|
||||
Requires a compatible Enterprise server, table Ownership and parent Usage.
|
||||
Embedded and historical-version handles are unsupported. Existing
|
||||
``optimize()`` retains its return-on-submission behavior in Enterprise.
|
||||
|
||||
``job.wait()`` waits for the actual rewrite and returns
|
||||
[OptimizeResult][lancedb.optimize.OptimizeResult]. Partial/bounded
|
||||
@@ -3253,21 +3251,25 @@ class Table(ABC):
|
||||
>>> result = job.wait() # doctest: +SKIP
|
||||
>>> print(result.rows_succeeded) # doctest: +SKIP
|
||||
"""
|
||||
raise NotImplementedError("Optimize jobs are only supported on remote tables")
|
||||
raise NotImplementedError(
|
||||
"Optimize jobs are only supported in LanceDB Enterprise"
|
||||
)
|
||||
|
||||
@abstractmethod
|
||||
def optimize(self, **options: Unpack[OptimizeOptions]) -> OptimizeStats:
|
||||
def optimize(
|
||||
self, *, retrain: bool = False, **options: Unpack[OptimizeOptions]
|
||||
) -> OptimizeStats:
|
||||
"""
|
||||
Optimize the on-disk data and indices for better performance.
|
||||
|
||||
.. note::
|
||||
|
||||
On a LanceDB Enterprise (remote) table, only compaction is
|
||||
On a LanceDB Enterprise (Enterprise) table, only compaction is
|
||||
currently supported. Pruning old versions and index optimization
|
||||
are silently skipped there instead of being attempted, so this
|
||||
call returns placeholder statistics (not completed work) once
|
||||
the compaction job has been submitted; it does not wait for that
|
||||
job to finish. Remote compaction supports per-job
|
||||
job to finish. Enterprise compaction supports per-job
|
||||
``target_rows_per_fragment``, ``max_source_rows``, ``io_buffer_size``,
|
||||
and ``batch_size``. Omitted fields inherit table tuning, then
|
||||
deployment/built-in defaults. Other non-default compaction settings raise
|
||||
@@ -5989,7 +5991,9 @@ class LanceTable(Table):
|
||||
def optimize_async(self, **options: Unpack[OptimizeOptions]) -> Job[OptimizeResult]:
|
||||
return Job(LOOP.run(self._table.optimize_async(**options)))
|
||||
|
||||
def optimize(self, **options: Unpack[OptimizeOptions]) -> OptimizeStats:
|
||||
def optimize(
|
||||
self, *, retrain: bool = False, **options: Unpack[OptimizeOptions]
|
||||
) -> OptimizeStats:
|
||||
"""
|
||||
Optimize the on-disk data and indices for better performance.
|
||||
|
||||
@@ -6048,9 +6052,7 @@ class LanceTable(Table):
|
||||
you have added or modified 100,000 or more records or run more than 20 data
|
||||
modification operations.
|
||||
"""
|
||||
tuning, cleanup, delete_unverified, retrain, action = _split_optimize_options(
|
||||
options
|
||||
)
|
||||
tuning, cleanup, delete_unverified, action = _split_optimize_options(options)
|
||||
return LOOP.run(
|
||||
self._table._do_optimize(
|
||||
_optimize_cleanup_since_ms(cleanup, retrain),
|
||||
@@ -9689,29 +9691,31 @@ class AsyncTable:
|
||||
async def optimize_async(
|
||||
self, **options: Unpack[OptimizeOptions]
|
||||
) -> AsyncJob[OptimizeResult]:
|
||||
"""Submit remote Optimize; await the returned job for actual results.
|
||||
"""Submit Enterprise Optimize; await the returned job for actual results.
|
||||
|
||||
See [Table.optimize_async][lancedb.table.Table.optimize_async] for options,
|
||||
permissions, completion semantics and compatibility requirements.
|
||||
"""
|
||||
data_options, _, _, _, _ = _split_optimize_options(options, durable=True)
|
||||
data_options, _, _, _ = _split_optimize_options(options, durable=True)
|
||||
return _typed_job(
|
||||
await self._inner.optimize_async(data_options),
|
||||
OptimizeResult.from_json,
|
||||
)
|
||||
|
||||
async def optimize(self, **options: Unpack[OptimizeOptions]) -> OptimizeStats:
|
||||
async def optimize(
|
||||
self, *, retrain: bool = False, **options: Unpack[OptimizeOptions]
|
||||
) -> OptimizeStats:
|
||||
"""
|
||||
Optimize the on-disk data and indices for better performance.
|
||||
|
||||
.. note::
|
||||
|
||||
On a LanceDB Enterprise (remote) table, only compaction is
|
||||
On a LanceDB Enterprise (Enterprise) table, only compaction is
|
||||
currently supported. Pruning old versions and index optimization
|
||||
are silently skipped there instead of being attempted, so this
|
||||
call returns placeholder statistics (not completed work) once
|
||||
the compaction job has been submitted; it does not wait for that
|
||||
job to finish. Remote compaction supports per-job
|
||||
job to finish. Enterprise compaction supports per-job
|
||||
``target_rows_per_fragment``, ``max_source_rows``, ``io_buffer_size``,
|
||||
and ``batch_size``. Omitted fields inherit table tuning, then
|
||||
deployment/built-in defaults. Other non-default compaction settings raise
|
||||
@@ -9774,7 +9778,7 @@ class AsyncTable:
|
||||
you have added or modified 100,000 or more records or run more than 20 data
|
||||
modification operations.
|
||||
"""
|
||||
data_options, cleanup_older_than, delete_unverified, retrain, action = (
|
||||
data_options, cleanup_older_than, delete_unverified, action = (
|
||||
_split_optimize_options(options)
|
||||
)
|
||||
return await self._do_optimize(
|
||||
|
||||
@@ -8750,7 +8750,10 @@ def test_remote_optimize_job_rejects_maintenance_options_before_submission(optio
|
||||
|
||||
server = UnusedServer()
|
||||
with _mock_remote_table_with_sql(server) as table:
|
||||
with pytest.raises(ValueError, match="unsupported by Optimize jobs"):
|
||||
with pytest.raises(
|
||||
(ValueError, TypeError),
|
||||
match="unsupported by Optimize jobs|Unsupported Optimize option",
|
||||
):
|
||||
table.optimize_async(**options)
|
||||
assert server.calls == 0
|
||||
|
||||
|
||||
@@ -6481,10 +6481,10 @@ async def test_optimize_action_validation(mem_db_async, kwargs):
|
||||
@pytest.mark.asyncio
|
||||
async def test_optimize_async_requires_remote(mem_db, mem_db_async):
|
||||
table = mem_db.create_table("local_job", [{"id": 1}])
|
||||
with pytest.raises(NotImplementedError, match="only supported on remote tables"):
|
||||
with pytest.raises(NotImplementedError, match="LanceDB Enterprise"):
|
||||
table.optimize_async()
|
||||
async_table = await mem_db_async.create_table("local_job", [{"id": 1}])
|
||||
with pytest.raises(NotImplementedError, match="only supported on remote tables"):
|
||||
with pytest.raises(NotImplementedError, match="LanceDB Enterprise"):
|
||||
await async_table.optimize_async()
|
||||
assert hasattr(async_table, "compact_async")
|
||||
|
||||
@@ -6507,3 +6507,36 @@ def test_legacy_optimize_nested_settings_embedded(tmp_path):
|
||||
stats = table.optimize(compaction_options={"target_rows_per_fragment": 100})
|
||||
assert stats.compaction.fragments_removed == 2
|
||||
assert table.count_rows() == 2
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("asynchronous", [False, True])
|
||||
async def test_optimize_inherits_embedded_table_config(tmp_path, asynchronous):
|
||||
seed = lancedb.connect(tmp_path).create_table("policy", [{"id": 1}])
|
||||
seed.add([{"id": 2}])
|
||||
seed.to_lance().update_config(
|
||||
{
|
||||
"lance.compaction.target_rows_per_fragment": "1",
|
||||
"lance.compaction.io_buffer_size": "4096",
|
||||
"lance.compaction.max_source_rows": "1",
|
||||
}
|
||||
)
|
||||
if asynchronous:
|
||||
db = await lancedb.connect_async(tmp_path)
|
||||
table = await db.open_table("policy")
|
||||
stats = await table.optimize()
|
||||
assert stats.compaction.fragments_removed == 0
|
||||
stats = await table.optimize(
|
||||
target_rows_per_fragment=100, io_buffer_size=0, max_source_rows=None
|
||||
)
|
||||
assert stats.compaction.fragments_removed == 2
|
||||
assert await table.count_rows() == 2
|
||||
else:
|
||||
table = lancedb.connect(tmp_path).open_table("policy")
|
||||
stats = table.optimize()
|
||||
assert stats.compaction.fragments_removed == 0
|
||||
stats = table.optimize(
|
||||
target_rows_per_fragment=100, io_buffer_size=0, max_source_rows=None
|
||||
)
|
||||
assert stats.compaction.fragments_removed == 2
|
||||
assert table.count_rows() == 2
|
||||
|
||||
@@ -283,6 +283,7 @@ def test_optimize_public_types():
|
||||
from lancedb.table import OptimizeOptions
|
||||
|
||||
assert lancedb.OptimizeOptions is OptimizeOptions
|
||||
assert "retrain" not in OptimizeOptions.__annotations__
|
||||
assert lancedb.CompactionOptions is OptimizeOptions
|
||||
assert not hasattr(lancedb, "OptimizeDataOptions")
|
||||
assert importlib.util.find_spec("lancedb.compaction") is not None
|
||||
|
||||
@@ -14,6 +14,8 @@ from lancedb.optimize import OptimizeResult
|
||||
def synchronous(table: Table) -> None:
|
||||
options: OptimizeOptions = {"target_rows_per_fragment": 100, "io_buffer_size": 0}
|
||||
assert_type(table.optimize(**options), OptimizeStats)
|
||||
assert_type(table.optimize(retrain=False), OptimizeStats)
|
||||
table.optimize_async(retrain=True) # pyright: ignore[reportCallIssue]
|
||||
assert_type(table.optimize_async(**options), Job[OptimizeResult])
|
||||
assert_type(table.optimize(cleanup_older_than=timedelta(days=1)), OptimizeStats)
|
||||
table.optimize(data_options={"max_source_rows": 1}) # pyright: ignore[reportCallIssue]
|
||||
|
||||
+44
-60
@@ -32,8 +32,8 @@ use lancedb::table::optimize::OptimizeOptions;
|
||||
use lancedb::table::{
|
||||
AddDataMode, ColumnAlteration, Duration, FieldMetadataUpdate, FtsToken as LanceDbFtsToken,
|
||||
FunctionRefreshPlanningConfig, FunctionRefreshPodResources, FunctionWorkerResourceBudget,
|
||||
IndexRemapMode, NewColumnTransform, OptimizeDataMode, OptimizeOverrides, Ref,
|
||||
RefreshColumnOptions, Table as LanceDbTable,
|
||||
IndexRemapMode, NewColumnTransform, OptimizeDataMode, Ref, RefreshColumnOptions,
|
||||
Table as LanceDbTable,
|
||||
};
|
||||
use lancedb::tokenize as lancedb_tokenize;
|
||||
use pyo3::{
|
||||
@@ -488,27 +488,10 @@ fn optional_i64_bounded_u64(value: &Bound<'_, PyAny>, name: &str) -> PyResult<Op
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
/// Preserve Python field presence while sharing Embedded and Enterprise parsing.
|
||||
#[derive(Default)]
|
||||
struct ParsedOptimizeOptions {
|
||||
options: OptimizeOptions,
|
||||
target_specified: bool,
|
||||
}
|
||||
|
||||
impl ParsedOptimizeOptions {
|
||||
fn into_remote_overrides(self) -> PyResult<OptimizeOverrides> {
|
||||
let mut overrides = OptimizeOverrides::try_from(self.options).infer_error()?;
|
||||
if !self.target_specified {
|
||||
overrides.target_rows_per_fragment = None;
|
||||
}
|
||||
Ok(overrides)
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_optimize_options(options: Option<&Bound<'_, PyDict>>) -> PyResult<ParsedOptimizeOptions> {
|
||||
fn parse_optimize_options(options: Option<&Bound<'_, PyDict>>) -> PyResult<OptimizeOptions> {
|
||||
let mut parsed = OptimizeOptions::default();
|
||||
let Some(options) = options else {
|
||||
return Ok(ParsedOptimizeOptions::default());
|
||||
return Ok(OptimizeOptions::default());
|
||||
};
|
||||
|
||||
for (key, value) in options.iter() {
|
||||
@@ -523,24 +506,44 @@ fn parse_optimize_options(options: Option<&Bound<'_, PyDict>>) -> PyResult<Parse
|
||||
"{key} must be an integer, not a bool"
|
||||
)));
|
||||
}
|
||||
if value.is_none()
|
||||
&& matches!(
|
||||
key.as_str(),
|
||||
"max_bytes_per_file"
|
||||
| "num_threads"
|
||||
| "batch_size"
|
||||
| "io_buffer_size"
|
||||
| "compaction_mode"
|
||||
| "binary_copy_read_batch_bytes"
|
||||
| "max_source_fragments"
|
||||
| "max_source_rows"
|
||||
| "max_source_bytes"
|
||||
| "max_overlays_per_fragment"
|
||||
| "data_storage_version"
|
||||
)
|
||||
{
|
||||
parsed.cleared_fields.insert(key.clone());
|
||||
}
|
||||
match key.as_str() {
|
||||
"target_rows_per_fragment" => {
|
||||
parsed.target_rows_per_fragment = positive_u32(&value, &key)?
|
||||
parsed.target_rows_per_fragment = Some(positive_u32(&value, &key)?)
|
||||
}
|
||||
"max_rows_per_group" => parsed.max_rows_per_group = positive_u32(&value, &key)?,
|
||||
"max_rows_per_group" => parsed.max_rows_per_group = Some(positive_u32(&value, &key)?),
|
||||
"max_bytes_per_file" => parsed.max_bytes_per_file = value.extract()?,
|
||||
"materialize_deletions" => parsed.materialize_deletions = value.extract()?,
|
||||
"materialize_deletions" => parsed.materialize_deletions = Some(value.extract()?),
|
||||
"materialize_deletions_threshold" => {
|
||||
parsed.materialize_deletions_threshold = value.extract()?
|
||||
parsed.materialize_deletions_threshold = Some(value.extract()?)
|
||||
}
|
||||
"num_threads" => parsed.num_threads = optional_positive_usize(&value, &key)?,
|
||||
"batch_size" => parsed.batch_size = optional_positive_u32(&value, &key)?,
|
||||
"io_buffer_size" => parsed.io_buffer_size = optional_i64_bounded_u64(&value, &key)?,
|
||||
"defer_index_remap" => parsed.defer_index_remap = value.extract()?,
|
||||
"defer_index_remap" => parsed.defer_index_remap = Some(value.extract()?),
|
||||
"index_remap_mode" => {
|
||||
let mode: String = value.extract()?;
|
||||
parsed.index_remap_mode = IndexRemapMode::try_from(mode.as_str())
|
||||
.map_err(|err| PyValueError::new_err(err.to_string()))?;
|
||||
parsed.index_remap_mode = Some(
|
||||
IndexRemapMode::try_from(mode.as_str())
|
||||
.map_err(|err| PyValueError::new_err(err.to_string()))?,
|
||||
);
|
||||
}
|
||||
"compaction_mode" => {
|
||||
let mode: Option<String> = value.extract()?;
|
||||
@@ -557,7 +560,7 @@ fn parse_optimize_options(options: Option<&Bound<'_, PyDict>>) -> PyResult<Parse
|
||||
"max_source_fragments" => parsed.max_source_fragments = value.extract()?,
|
||||
"max_source_rows" => parsed.max_source_rows = optional_positive_usize(&value, &key)?,
|
||||
"max_source_bytes" => parsed.max_source_bytes = optional_positive_u64(&value, &key)?,
|
||||
"excluded_fragment_ids" => parsed.excluded_fragment_ids = u32_list(&value, &key)?,
|
||||
"excluded_fragment_ids" => parsed.excluded_fragment_ids = Some(u32_list(&value, &key)?),
|
||||
"max_overlays_per_fragment" => parsed.max_overlays_per_fragment = value.extract()?,
|
||||
"data_storage_version" => {
|
||||
let version: String = value.extract()?;
|
||||
@@ -575,10 +578,7 @@ fn parse_optimize_options(options: Option<&Bound<'_, PyDict>>) -> PyResult<Parse
|
||||
}
|
||||
}
|
||||
|
||||
Ok(ParsedOptimizeOptions {
|
||||
options: parsed,
|
||||
target_specified: options.contains("target_rows_per_fragment")?,
|
||||
})
|
||||
Ok(parsed)
|
||||
}
|
||||
|
||||
/// Statistics about a compaction operation.
|
||||
@@ -2323,7 +2323,7 @@ impl Table {
|
||||
data_options: Option<&Bound<'py, PyDict>>,
|
||||
) -> PyResult<Bound<'py, PyAny>> {
|
||||
let inner = self_.inner_ref()?.clone();
|
||||
let overrides = parse_optimize_options(data_options)?.into_remote_overrides()?;
|
||||
let overrides = parse_optimize_options(data_options)?;
|
||||
future_into_py(self_.py(), async move {
|
||||
let job = inner.optimize_async(overrides).await.infer_error()?;
|
||||
Ok(crate::job::Job::new_typed(job))
|
||||
@@ -2368,33 +2368,17 @@ impl Table {
|
||||
None
|
||||
};
|
||||
future_into_py(self_.py(), async move {
|
||||
let stats = if inner.as_native().is_some() {
|
||||
if rewrite_only {
|
||||
inner
|
||||
.optimize(lancedb::table::OptimizeAction::RewriteDataWithOptions {
|
||||
options: data_options.options,
|
||||
remap_options: None,
|
||||
})
|
||||
.await
|
||||
} else {
|
||||
inner
|
||||
.optimize_full(data_options.options, older_than, None, delete_unverified)
|
||||
.await
|
||||
}
|
||||
let stats = if rewrite_only {
|
||||
inner
|
||||
.optimize(lancedb::table::OptimizeAction::RewriteData {
|
||||
options: data_options,
|
||||
remap_options: None,
|
||||
})
|
||||
.await
|
||||
} else {
|
||||
let overrides = data_options.into_remote_overrides()?;
|
||||
if rewrite_only {
|
||||
inner.optimize(overrides).await
|
||||
} else {
|
||||
inner
|
||||
.optimize_full_with_overrides(
|
||||
overrides,
|
||||
older_than,
|
||||
None,
|
||||
delete_unverified,
|
||||
)
|
||||
.await
|
||||
}
|
||||
inner
|
||||
.optimize_full_with_options(data_options, older_than, None, delete_unverified)
|
||||
.await
|
||||
}
|
||||
.infer_error()?;
|
||||
let compaction_stats = stats.compaction.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user