This is an automated email from the ASF dual-hosted git repository.

mneumann pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs-object-store.git


The following commit(s) were added to refs/heads/main by this push:
     new 7ded938  Replace `Path::child` with `Path::join` (#666)
7ded938 is described below

commit 7ded938312299ccc1ca517e34fe34326d8426ebb
Author: Ruslan Fadeev <[email protected]>
AuthorDate: Thu Mar 19 15:04:10 2026 +0400

    Replace `Path::child` with `Path::join` (#666)
    
    * Path::join
    
    * update old uses
---
 src/integration.rs |  2 +-
 src/local.rs       |  4 ++--
 src/memory.rs      |  2 +-
 src/path/mod.rs    | 23 ++++++++++++++++++-----
 src/throttle.rs    |  2 +-
 5 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/integration.rs b/src/integration.rs
index 352bd4b..fbbbe74 100644
--- a/src/integration.rs
+++ b/src/integration.rs
@@ -283,7 +283,7 @@ pub async fn put_get_delete_list(storage: &DynObjectStore) {
 
     // "HELLO" percent encoded
     let hello_prefix = Path::parse("%48%45%4C%4C%4F").unwrap();
-    let path = hello_prefix.child("foo.parquet");
+    let path = hello_prefix.clone().join("foo.parquet");
 
     storage.put(&path, vec![0, 1].into()).await.unwrap();
     let files = flatten_list_stream(storage, Some(&hello_prefix))
diff --git a/src/local.rs b/src/local.rs
index 45f35f3..a12a775 100644
--- a/src/local.rs
+++ b/src/local.rs
@@ -526,7 +526,7 @@ impl ObjectStore for LocalFileSystem {
                     drop(parts);
 
                     if is_directory {
-                        common_prefixes.insert(prefix.child(common_prefix));
+                        
common_prefixes.insert(prefix.clone().join(common_prefix));
                     } else if let Some(metadata) = convert_entry(entry, 
entry_location)? {
                         objects.push(metadata);
                     }
@@ -1599,7 +1599,7 @@ mod tests {
         let integration = 
LocalFileSystem::new_with_prefix(root.clone()).unwrap();
 
         let directory = Path::from("directory");
-        let object = directory.child("child.txt");
+        let object = directory.clone().join("child.txt");
         let data = Bytes::from("arbitrary");
         integration.put(&object, data.clone().into()).await.unwrap();
         integration.head(&object).await.unwrap();
diff --git a/src/memory.rs b/src/memory.rs
index 7c72256..096b1ba 100644
--- a/src/memory.rs
+++ b/src/memory.rs
@@ -367,7 +367,7 @@ impl ObjectStore for InMemory {
             };
 
             if parts.next().is_some() {
-                common_prefixes.insert(prefix.child(common_prefix));
+                common_prefixes.insert(prefix.clone().join(common_prefix));
             } else {
                 let object = ObjectMeta {
                     location: k.clone(),
diff --git a/src/path/mod.rs b/src/path/mod.rs
index e8618db..dfd353a 100644
--- a/src/path/mod.rs
+++ b/src/path/mod.rs
@@ -360,10 +360,23 @@ impl Path {
     }
 
     /// Creates a new child of this [`Path`]
+    #[deprecated = "use .join() or .clone().join() instead"]
     pub fn child<'a>(&self, child: impl Into<PathPart<'a>>) -> Self {
-        let raw = match self.raw.is_empty() {
-            true => format!("{}", child.into().raw),
-            false => format!("{}{}{}", self.raw, DELIMITER, child.into().raw),
+        self.clone().join(child)
+    }
+
+    /// Appends a single path segment to this [`Path`]
+    pub fn join<'a>(self, child: impl Into<PathPart<'a>>) -> Self {
+        let child_cow_str = child.into().raw;
+
+        let raw = if self.raw.is_empty() {
+            child_cow_str.to_string()
+        } else {
+            use std::fmt::Write;
+
+            let mut raw = self.raw;
+            write!(raw, "{DELIMITER}{child_cow_str}").expect("failed to append 
to string");
+            raw
         };
 
         Self { raw }
@@ -598,7 +611,7 @@ mod tests {
         );
 
         // a longer prefix doesn't match
-        let needle = haystack.child("longer now");
+        let needle = haystack.clone().join("longer now");
         assert!(
             !haystack.prefix_matches(&needle),
             "{haystack:?} shouldn't have started with {needle:?}"
@@ -612,7 +625,7 @@ mod tests {
         );
 
         // two dir prefix matches
-        let needle = needle.child("baz%2Ftest");
+        let needle = needle.join("baz%2Ftest");
         assert!(
             haystack.prefix_matches(&needle),
             "{haystack:?} should have started with {needle:?}"
diff --git a/src/throttle.rs b/src/throttle.rs
index fb668f0..19bb991 100644
--- a/src/throttle.rs
+++ b/src/throttle.rs
@@ -558,7 +558,7 @@ mod tests {
 
         // create new entries
         for i in 0..n_entries {
-            let path = prefix.child(i.to_string().as_str());
+            let path = prefix.clone().join(i.to_string().as_str());
             store.put(&path, "bar".into()).await.unwrap();
         }
 

Reply via email to