From 1797a9501bd1b5c31d0be121d9826d789c58a653 Mon Sep 17 00:00:00 2001 From: Jan Schutte <4732389+SchutteJan@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:40:46 +0200 Subject: [PATCH] Split hdfs code path in parse_url_opts to separate function --- kernel/src/engine/default/storage.rs | 36 ++++++++++++++++------------ 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/kernel/src/engine/default/storage.rs b/kernel/src/engine/default/storage.rs index 302bc1fa0..89fcdccf2 100644 --- a/kernel/src/engine/default/storage.rs +++ b/kernel/src/engine/default/storage.rs @@ -1,6 +1,6 @@ #[cfg(feature = "cloud")] use hdfs_native_object_store::HdfsObjectStore; -use object_store::parse_url_opts as object_store_parse_url_opts; +use object_store::parse_url_opts as parse_url_opts_object_store; use object_store::path::Path; use object_store::{Error, ObjectStore}; use url::Url; @@ -11,19 +11,25 @@ where K: AsRef, V: Into, { - #[cfg(feature = "cloud")] - { - let scheme = url.scheme(); - if scheme == "hdfs" || scheme == "viewfs" { - let options_map = options - .into_iter() - .map(|(k, v)| (k.as_ref().to_string(), v.into())) - .collect(); - let store = HdfsObjectStore::with_config(url.as_str(), options_map)?; - let path = Path::parse(url.path())?; - return Ok((Box::new(store), path)); - } + match url.scheme() { + #[cfg(feature = "cloud")] + "hdfs" | "viewfs" => parse_url_opts_hdfs_native(url, options), + _ => parse_url_opts_object_store(url, options) } - - object_store_parse_url_opts(url, options) } + +#[cfg(feature = "cloud")] +pub fn parse_url_opts_hdfs_native(url: &Url, options: I) -> Result<(Box, Path), Error> +where + I: IntoIterator, + K: AsRef, + V: Into, +{ + let options_map = options + .into_iter() + .map(|(k, v)| (k.as_ref().to_string(), v.into())) + .collect(); + let store = HdfsObjectStore::with_config(url.as_str(), options_map)?; + let path = Path::parse(url.path())?; + return Ok((Box::new(store), path)); +} \ No newline at end of file