zeroshade commented on a change in pull request #9862:
URL: https://github.com/apache/arrow/pull/9862#discussion_r606823174



##########
File path: go/arrow/ipc/file_reader.go
##########
@@ -348,10 +356,26 @@ func (src *ipcSource) buffer(i int) *memory.Buffer {
                return memory.NewBufferBytes(nil)
        }
 
-       raw := make([]byte, buf.Length())
-       _, err := src.r.ReadAt(raw, buf.Offset())
-       if err != nil {
-               panic(err)
+       var raw []byte
+       if src.codec == nil {
+               raw = make([]byte, buf.Length())
+               _, err := src.r.ReadAt(raw, buf.Offset())
+               if err != nil {
+                       panic(err)
+               }
+       } else {
+               sr := io.NewSectionReader(src.r, buf.Offset(), buf.Length())
+               var uncompressedSize uint64
+               if err := binary.Read(sr, binary.LittleEndian, 
&uncompressedSize); err != nil {

Review comment:
       zero length buffers are handled above this in this function, if the 
buffer is length 0, this function returns a buffer with a nil slice. In 
addition the writer doesn't attempt to compress or write for a 0 length buffer 
either.




-- 
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:
us...@infra.apache.org


Reply via email to