albertlockett commented on issue #8423:
URL: https://github.com/apache/arrow-rs/issues/8423#issuecomment-3549364891

   @wjones127 there's a 
[`try_finish`](https://docs.rs/lz4_flex/latest/lz4_flex/frame/struct.FrameEncoder.html#method.try_finish)
 method that doesn't consume the `FrameEncoder`. 
   
   We might be able to do something like this
   ```rs
   #[cfg(feature = "lz4")]
   fn compress_lz4(input: &[u8], output: &mut Vec<u8>,  context: &mut 
CompressionContext) -> Result<(), ArrowError> {
       use std::io::Write;
   
       // assuming CompressionContext having a field called `frame_encoder` of 
type `FrameEncoder<Vec<u8>>>`
       context.frame_encoder.encoder.write_all(input)?;
       encoder.try_finish().map_err(|e| 
ArrowError::ExternalError(Box::new(e)))?;
   
       // copy the bytes from the frame encoder's write buffer
       let w: &mut Vec<u8> = encoder.get_mut();
       output.extend_from_slice(w);
       
       // reset the write buffer
       w.clear();
   
       Ok(())
   }
   ```


-- 
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