mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-05 19:32:56 +00:00
fix: Allow converting from NativeTable to Table (#1069)
This commit is contained in:
@@ -323,7 +323,7 @@ impl JsTable {
|
||||
.and_then(|val| val.downcast::<JsNumber, _>(&mut cx).ok())
|
||||
.map(|val| val.value(&mut cx) as i64)
|
||||
.unwrap_or_else(|| 2 * 7 * 24 * 60); // 2 weeks
|
||||
let older_than = chrono::Duration::minutes(older_than);
|
||||
let older_than = chrono::Duration::try_minutes(older_than).unwrap();
|
||||
let delete_unverified: Option<bool> = Some(
|
||||
cx.argument_opt(1)
|
||||
.and_then(|val| val.downcast::<JsBoolean, _>(&mut cx).ok())
|
||||
|
||||
@@ -796,10 +796,10 @@ mod tests {
|
||||
let tmp_dir = tempdir().unwrap();
|
||||
let mut names = Vec::with_capacity(100);
|
||||
for _ in 0..100 {
|
||||
let name = uuid::Uuid::new_v4().to_string();
|
||||
let mut name = uuid::Uuid::new_v4().to_string();
|
||||
names.push(name.clone());
|
||||
let table_name = name + ".lance";
|
||||
create_dir_all(tmp_dir.path().join(&table_name)).unwrap();
|
||||
name.push_str(".lance");
|
||||
create_dir_all(tmp_dir.path().join(&name)).unwrap();
|
||||
}
|
||||
names.sort();
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
use arrow_array::{Float32Array, Int64Array, RecordBatch};
|
||||
use arrow_ipc::writer::StreamWriter;
|
||||
use arrow_schema::{DataType, Field, Schema};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
@@ -504,6 +504,13 @@ impl Table {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NativeTable> for Table {
|
||||
fn from(table: NativeTable) -> Self {
|
||||
Self {
|
||||
inner: Arc::new(table),
|
||||
}
|
||||
}
|
||||
}
|
||||
/// A table in a LanceDB database.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct NativeTable {
|
||||
@@ -1141,7 +1148,7 @@ impl TableInternal for NativeTable {
|
||||
.compaction;
|
||||
stats.prune = self
|
||||
.optimize(OptimizeAction::Prune {
|
||||
older_than: Duration::days(7),
|
||||
older_than: Duration::try_days(7).unwrap(),
|
||||
delete_unverified: None,
|
||||
})
|
||||
.await?
|
||||
|
||||
Reference in New Issue
Block a user