You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/10/13 13:42:48 UTC

[PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

tustvold opened a new pull request, #4930:
URL: https://github.com/apache/arrow-rs/pull/4930

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   # Rationale for this change
    
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   Having two layers of asynchrony and fallibility makes for a rather obnoxious interface. Removing this makes for better client ergonomics, at the expense of slightly more arcane logic to implement the ObjectStore
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#discussion_r1358286629


##########
object_store/src/local.rs:
##########
@@ -1158,21 +1156,14 @@ mod tests {
 
         let store = LocalFileSystem::new_with_prefix(root.path()).unwrap();
 
-        // `list` must fail

Review Comment:
   We no longer have this peculiar arrangement where an error can emerge in two different places



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#discussion_r1358288349


##########
object_store/src/limit.rs:
##########
@@ -147,23 +147,24 @@ impl<T: ObjectStore> ObjectStore for LimitStore<T> {
         self.inner.delete_stream(locations)
     }
 
-    async fn list(
-        &self,
-        prefix: Option<&Path>,
-    ) -> Result<BoxStream<'_, Result<ObjectMeta>>> {
-        let permit = Arc::clone(&self.semaphore).acquire_owned().await.unwrap();
-        let s = self.inner.list(prefix).await?;
-        Ok(PermitWrapper::new(s, permit).boxed())
+    fn list(&self, prefix: Option<&Path>) -> BoxStream<'_, Result<ObjectMeta>> {
+        let s = self.inner.list(prefix);
+        let fut = Arc::clone(&self.semaphore)
+            .acquire_owned()
+            .map(|permit| PermitWrapper::new(s, permit.unwrap()));
+        fut.into_stream().flatten().boxed()
     }
 
-    async fn list_with_offset(
+    fn list_with_offset(
         &self,
         prefix: Option<&Path>,
         offset: &Path,
-    ) -> Result<BoxStream<'_, Result<ObjectMeta>>> {
-        let permit = Arc::clone(&self.semaphore).acquire_owned().await.unwrap();
-        let s = self.inner.list_with_offset(prefix, offset).await?;
-        Ok(PermitWrapper::new(s, permit).boxed())
+    ) -> BoxStream<'_, Result<ObjectMeta>> {
+        let s = self.inner.list_with_offset(prefix, offset);
+        let fut = Arc::clone(&self.semaphore)

Review Comment:
   This somewhat peculiar ordering is required because the returned stream cannot borrow prefix



##########
object_store/src/limit.rs:
##########
@@ -147,23 +147,24 @@ impl<T: ObjectStore> ObjectStore for LimitStore<T> {
         self.inner.delete_stream(locations)
     }
 
-    async fn list(
-        &self,
-        prefix: Option<&Path>,
-    ) -> Result<BoxStream<'_, Result<ObjectMeta>>> {
-        let permit = Arc::clone(&self.semaphore).acquire_owned().await.unwrap();
-        let s = self.inner.list(prefix).await?;
-        Ok(PermitWrapper::new(s, permit).boxed())
+    fn list(&self, prefix: Option<&Path>) -> BoxStream<'_, Result<ObjectMeta>> {
+        let s = self.inner.list(prefix);
+        let fut = Arc::clone(&self.semaphore)
+            .acquire_owned()
+            .map(|permit| PermitWrapper::new(s, permit.unwrap()));
+        fut.into_stream().flatten().boxed()
     }
 
-    async fn list_with_offset(
+    fn list_with_offset(
         &self,
         prefix: Option<&Path>,
         offset: &Path,
-    ) -> Result<BoxStream<'_, Result<ObjectMeta>>> {
-        let permit = Arc::clone(&self.semaphore).acquire_owned().await.unwrap();
-        let s = self.inner.list_with_offset(prefix, offset).await?;
-        Ok(PermitWrapper::new(s, permit).boxed())
+    ) -> BoxStream<'_, Result<ObjectMeta>> {
+        let s = self.inner.list_with_offset(prefix, offset);
+        let fut = Arc::clone(&self.semaphore)

Review Comment:
   This somewhat peculiar ordering is required because the returned stream cannot borrow prefix, only self



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#issuecomment-1767200027

   cc @carols10cents 
   
   > Looks good. Should we have an issue for this?
   
   Looks like @tustvold  filed https://github.com/apache/arrow-rs/issues/4946
   


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#issuecomment-1823435109

   I wonder if it was intended that `list_with_delimiter` is still async and returns `Result`?
   
   It seems a strangely different API 
   
   https://docs.rs/object_store/latest/object_store/trait.ObjectStore.html#tymethod.list_with_delimiter
   
   
   


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#issuecomment-1850579970

   BTW I think this change has also made it somewhat harder to implement "fail fast" semantics for object store clients, something we saw in IOx and @andygrove  noticed while updating ballista


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#issuecomment-1767202298

   > I think this means we need to release another SemVer change for object_store on the next release
   
   Indeed, there are already also some other breaking changes already merged and some others in the pipeline


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#discussion_r1358286928


##########
object_store/src/local.rs:
##########
@@ -1246,13 +1237,7 @@ mod tests {
         prefix: Option<&Path>,
         expected: &[&str],
     ) {
-        let result: Vec<_> = integration
-            .list(prefix)
-            .await
-            .unwrap()
-            .try_collect()
-            .await
-            .unwrap();
+        let result: Vec<_> = integration.list(prefix).try_collect().await.unwrap();

Review Comment:
   This is much nicer imo



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#issuecomment-1767200875

   I think this means we need to release another SemVer change for object_store on the next release


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#issuecomment-1823443640

   > I wonder if it was intended that list_with_delimiter is still async and returns Result?
   
   Yes it was intended as list_with_delimiter does not return a stream


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#issuecomment-1850720208

   I ended up with the following to resolve this:
   
   ```rust
   stream::once(async { Err(...)  }).boxed()
   ```


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Remove Nested async and Fallibility from ObjectStore::list [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #4930:
URL: https://github.com/apache/arrow-rs/pull/4930#issuecomment-1850583380

   The following should do the trick
   ```
   futures::stream::once(async move { Err(...)}).boxed()
   ```


-- 
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-unsubscribe@arrow.apache.org

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