Skip to content

Commit 496e635

Browse files
fix: remove unnecessary object store initialization (lance-format#5145)
When `self.object_store` exists, there is no need to perform the initialization operation of object_store again.
1 parent 268393c commit 496e635

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

rust/lance/src/dataset/write/commit.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,23 +194,26 @@ impl<'a> CommitBuilder<'a> {
194194
dataset.commit_handler.clone(),
195195
),
196196
WriteDestination::Uri(uri) => {
197-
let (object_store, base_path) = ObjectStore::from_uri_and_params(
198-
session.store_registry(),
199-
uri,
200-
&self.store_params.clone().unwrap_or_default(),
201-
)
202-
.await?;
203-
let mut object_store = object_store;
204197
let commit_handler = if self.commit_handler.is_some() && self.object_store.is_some()
205198
{
206199
self.commit_handler.as_ref().unwrap().clone()
207200
} else {
208201
resolve_commit_handler(uri, self.commit_handler.clone(), &self.store_params)
209202
.await?
210203
};
211-
if let Some(passed_store) = self.object_store {
212-
object_store = passed_store;
213-
}
204+
let (object_store, base_path) = if let Some(passed_store) = self.object_store {
205+
(
206+
passed_store,
207+
ObjectStore::extract_path_from_uri(session.store_registry(), uri)?,
208+
)
209+
} else {
210+
ObjectStore::from_uri_and_params(
211+
session.store_registry(),
212+
uri,
213+
&self.store_params.clone().unwrap_or_default(),
214+
)
215+
.await?
216+
};
214217
(object_store, base_path, commit_handler)
215218
}
216219
};

0 commit comments

Comments
 (0)