liyafan82 commented on pull request #8949:
URL: https://github.com/apache/arrow/pull/8949#issuecomment-760767374


   > The [comment in the BodyCompression 
protobuf](https://github.com/apache/arrow/blob/master/format/Message.fbs#L59-L65)
 states:
   > 
   > > Each constituent buffer is first compressed with the indicated 
compressor, and then written with the uncompressed length in the first 8 bytes 
as a 64-bit little-endian signed integer followed by the compressed buffer 
bytes (and then padding as required by the protocol). **The uncompressed length 
may be set to -1 to indicate that the data that follows is not compressed, 
which can be useful for cases where compression does not yield appreciable 
savings.**
   > 
   > Should the check for a length of -1 be made outside of `CompressionCodec` 
implementation? I think it would be useful to do it in the 
`#decompress(BufferAllocator, ArrowBuf)` method.
   > 
   > Should be pretty easy if I don't miss something:
   > 
   > ```java
   >     if (decompressedLength == -1L) {
   >       // handle uncompressed buffers
   >       return compressedBuffer.slice(SIZE_OF_MESSAGE_LENGTH,
   >           compressedBuffer.writerIndex() - SIZE_OF_MESSAGE_LENGTH);
   >     }
   > ```
   
   @HedgehogCode Thanks for your good suggestion. I have revised the code to 
implement the logic that when the compressed buffer is larger, we directly send 
the raw buffer with length -1. In addition, I have updated the test cast to 
make sure the code path of the logic is covered. 


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

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


Reply via email to