stayrascal commented on code in PR #324:
URL: 
https://github.com/apache/arrow-rs-object-store/pull/324#discussion_r2041117793


##########
src/memory.rs:
##########
@@ -383,31 +401,57 @@ impl ObjectStore for InMemory {
             }
         }
 
-        Ok(ListResult {
+        let result = Ok(ListResult {
             objects,
             common_prefixes: common_prefixes.into_iter().collect(),
-        })
+        });
+        futures::stream::once(async { result }).boxed()
     }
+    fn list_without_delimiter(
+        &self,
+        prefix: Option<&Path>,
+        offset: Option<&Path>,
+        max_keys: Option<usize>,
+    ) -> BoxStream<'static, Result<ListResult>> {
+        let root = Path::default();
+        let prefix = prefix.unwrap_or(&root);
 
-    async fn copy(&self, from: &Path, to: &Path) -> Result<()> {
-        let entry = self.entry(from)?;
-        self.storage
-            .write()
-            .insert(to, entry.data, entry.attributes);
-        Ok(())
-    }
+        let storage = self.storage.read();
+        let mut values: Vec<_> = storage
+            .map
+            .range(prefix..)
+            .take_while(|(key, _)| key.as_ref().starts_with(prefix.as_ref()))
+            .filter(|(key, _)| {
+                // Don't return for exact prefix match
+                key.prefix_match(prefix)
+                    .map(|mut x| x.next().is_some())
+                    .unwrap_or(false)
+            })
+            .filter(|(key, _)| offset.map(|o| key > &o).unwrap_or(true))
+            .map(|(key, value)| ObjectMeta {
+                location: key.clone(),
+                last_modified: value.last_modified,
+                size: value.data.len() as u64,
+                e_tag: Some(value.e_tag.to_string()),
+                version: None,
+            })
+            .collect();
 
-    async fn copy_if_not_exists(&self, from: &Path, to: &Path) -> Result<()> {
-        let entry = self.entry(from)?;
-        let mut storage = self.storage.write();
-        if storage.map.contains_key(to) {
-            return Err(Error::AlreadyExists {
-                path: to.to_string(),
+        let objects = match max_keys {
+            Some(max_keys) if max_keys < values.len() => {
+                values.truncate(max_keys);
+                values
             }

Review Comment:
   will try



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to