mgattozzi opened a new issue, #6200:
URL: https://github.com/apache/arrow-rs/issues/6200

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   <!--
   A clear and concise description of what the problem is. Ex. I'm always 
frustrated when [...] 
   (This section helps Arrow developers understand the context and *why* for 
this feature, in addition to  the *what*)
   -->
   
   Recently I wanted to stream data to Object Store using the 
[MultipartUpload](https://docs.rs/object_store/latest/object_store/trait.MultipartUpload.html)
 via `AsyncArrowWriter` to create files asynchronously and streamed to Object 
Store. However, I had to manually create a type to do this as there is no 
`obj_store` type or `parquet` type that implements `AsyncFileWriter`
   
   **Describe the solution you'd like**
   <!--
   A clear and concise description of what you want to happen.
   -->
   
   A type that implements `MultipartUpload` or wraps the future from 
[put_multipart_opts](https://docs.rs/object_store/latest/object_store/trait.ObjectStore.html#tymethod.put_multipart_opts)
 and also implements `AsyncFileWriter` for usage in `AsyncArrowWriter`
   
   **Describe alternatives you've considered**
   <!--
   A clear and concise description of any alternative solutions or features 
you've considered.
   -->
   
   I can easily maintain this wrapper myself, but I figured I'm not the only 
one with this issue. There aren't really any alternatives besides not 
implementing this that I can think of.
   
   **Additional context**
   <!--
   Add any other context or screenshots about the feature request here.
   -->
   
   The code I have currently looks like this. I'm sure there would be more 
specific changes for the `parquet` crate, but hopefully this is enough to show 
that it's a fairly easy add.
   
   ```rust
   struct AsyncMultiPart {
       multi_part: Box<dyn MultipartUpload>,
   }
   
   impl AsyncMultiPart {
       fn new(multi_part: Box<dyn MultipartUpload>) -> Self {
           Self { multi_part }
       }
   }
   
   struct AsyncMultiPartWrite {
       payload: Pin<Box<dyn Future<Output = Result<(), object_store::Error>> + 
Send + 'static>>,
   }
   
   impl Future for AsyncMultiPartWrite {
       type Output = parquet::errors::Result<()>;
   
       fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> 
Poll<Self::Output> {
           match self.payload.as_mut().poll(cx) {
               Poll::Pending => Poll::Pending,
               Poll::Ready(Ok(())) => Poll::Ready(Ok(())),
               Poll::Ready(Err(err)) => {
                   
Poll::Ready(Err(parquet::errors::ParquetError::General(err.to_string())))
               }
           }
       }
   }
   
   struct AsyncMultiPartComplete<'complete> {
       complete:
           Pin<Box<dyn Future<Output = Result<PutResult, object_store::Error>> 
+ Send + 'complete>>,
   }
   
   impl Future for AsyncMultiPartComplete<'_> {
       type Output = parquet::errors::Result<()>;
   
       fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> 
Poll<Self::Output> {
           match self.complete.as_mut().poll(cx) {
               Poll::Pending => Poll::Pending,
               Poll::Ready(Ok(_)) => Poll::Ready(Ok(())),
               Poll::Ready(Err(err)) => {
                   
Poll::Ready(Err(parquet::errors::ParquetError::General(err.to_string())))
               }
           }
       }
   }
   
   impl AsyncFileWriter for AsyncMultiPart {
       fn write(&mut self, bs: Bytes) -> BoxFuture<'_, 
parquet::errors::Result<()>> {
           Box::pin(AsyncMultiPartWrite {
               payload: self.multi_part.put_part(PutPayload::from_bytes(bs)),
           })
       }
   
       fn complete(&mut self) -> BoxFuture<'_, parquet::errors::Result<()>> {
           Box::pin(AsyncMultiPartComplete {
               complete: self.multi_part.complete(),
           })
       }
   }
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to