mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
Merge remote-tracking branch 'origin/main' into xuanwo/add-node-version-parity
# Conflicts: # nodejs/src/table.rs
This commit is contained in:
@@ -572,6 +572,11 @@ impl Connection {
|
||||
job.into_typed::<lancedb::table::PrewarmDataResult>()
|
||||
.default_error()?,
|
||||
))
|
||||
} else if job.job_type().as_deref() == Some("cleanup") {
|
||||
Ok(crate::job::Job::new_typed(
|
||||
job.into_typed::<lancedb::table::CleanupResult>()
|
||||
.default_error()?,
|
||||
))
|
||||
} else if job.job_type().as_deref() == Some("compact") {
|
||||
Ok(crate::job::Job::new_typed(
|
||||
job.into_typed::<lancedb::table::CompactionResult>()
|
||||
|
||||
@@ -1001,6 +1001,33 @@ impl Table {
|
||||
Ok(self.inner_ref()?.current_branch())
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
pub async fn explain_cleanup(
|
||||
&self,
|
||||
min_age_seconds: Option<f64>,
|
||||
) -> napi::Result<serde_json::Value> {
|
||||
let plan = self
|
||||
.inner_ref()?
|
||||
.explain_cleanup(parse_cleanup_options(min_age_seconds)?)
|
||||
.await
|
||||
.default_error()?;
|
||||
serde_json::to_value(plan).map_err(|error| napi::Error::from_reason(error.to_string()))
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
pub async fn cleanup_async(
|
||||
&self,
|
||||
min_age_seconds: Option<f64>,
|
||||
) -> napi::Result<crate::job::Job> {
|
||||
let options = parse_cleanup_options(min_age_seconds)?;
|
||||
let job = self
|
||||
.inner_ref()?
|
||||
.cleanup_async(options)
|
||||
.await
|
||||
.default_error()?;
|
||||
Ok(crate::job::Job::new_typed(job))
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
pub async fn compact_async(
|
||||
&self,
|
||||
@@ -2600,6 +2627,22 @@ impl Branches {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_cleanup_options(
|
||||
min_age_seconds: Option<f64>,
|
||||
) -> napi::Result<lancedb::table::CleanupOptions> {
|
||||
let mut options = lancedb::table::CleanupOptions::new();
|
||||
if let Some(age) = min_age_seconds {
|
||||
if !age.is_finite() || age.fract() != 0.0 || !(0.0..=9_007_199_254_740_991.0).contains(&age)
|
||||
{
|
||||
return Err(napi::Error::from_reason(
|
||||
"minAgeSeconds must be a nonnegative safe integer",
|
||||
));
|
||||
}
|
||||
options.min_age_seconds = Some(age as u64);
|
||||
}
|
||||
Ok(options)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::from_tag_hint;
|
||||
|
||||
Reference in New Issue
Block a user