From 0036ca9de78ff67a96618b07879f8d942c652769 Mon Sep 17 00:00:00 2001 From: Rob Meng Date: Mon, 23 Oct 2023 12:06:13 -0400 Subject: [PATCH] feat: add checkout method to table to reuse existing store and connections (#593) Prior to this PR, to get a new version of a table, we need to re-open the table. This has a few downsides w.r.t. performance: * Object store is recreated, which takes time and throws away existing warm connections * Commit handler is thrown aways as well, which also may contain warm connections --- rust/vectordb/src/table.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rust/vectordb/src/table.rs b/rust/vectordb/src/table.rs index a78aa2dc..8073ee29 100644 --- a/rust/vectordb/src/table.rs +++ b/rust/vectordb/src/table.rs @@ -153,6 +153,22 @@ impl Table { }) } + pub async fn checkout_latest(&self) -> Result { + let latest_version_id = self.dataset.latest_version_id().await?; + let dataset = if latest_version_id == self.dataset.version().version { + self.dataset.clone() + } else { + Arc::new(self.dataset.checkout_version(latest_version_id).await?) + }; + + Ok(Table { + name: self.name.clone(), + uri: self.uri.clone(), + dataset, + store_wrapper: self.store_wrapper.clone(), + }) + } + fn get_table_name(uri: &str) -> Result { let path = Path::new(uri); let name = path