Skip to content

Commit

Permalink
ipc: put lz4 decompression buffers back into sync.Pool
Browse files Browse the repository at this point in the history
The lz4 decompressor was not calling Reset on the underlying writer in its
Close method. This could cause buffers not to be released back to the pool and
defeating the purpose of the sync.Pool in the lz4 package.

Additionally, a call to Close was missing in readDictionary.
  • Loading branch information
asubiotto committed Nov 16, 2023
1 parent 8bc1c1d commit db19523
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/arrow/ipc/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ type lz4Decompressor struct {
*lz4.Reader
}

func (z *lz4Decompressor) Close() {}
func (z *lz4Decompressor) Close() {
z.Reader.Reset(nil)
}

func getDecompressor(codec flatbuf.CompressionType) decompressor {
switch codec {
Expand Down
1 change: 1 addition & 0 deletions go/arrow/ipc/file_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ func readDictionary(memo *dictutils.Memo, meta *memory.Buffer, body ReadAtSeeker
bodyCompress := data.Compression(nil)
if bodyCompress != nil {
codec = getDecompressor(bodyCompress.Codec())
defer codec.Close()
}

id := md.Id()
Expand Down

0 comments on commit db19523

Please sign in to comment.