From f775fd83247c512a7d11dab0b5c14471bd757174 Mon Sep 17 00:00:00 2001 From: Alfonso Subiotto Marques Date: Wed, 15 Nov 2023 13:03:29 +0100 Subject: [PATCH] ipc: put lz4 decompression buffers back into sync.Pool 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. --- go/arrow/ipc/compression.go | 4 +++- go/arrow/ipc/file_reader.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/go/arrow/ipc/compression.go b/go/arrow/ipc/compression.go index 8856b732f9c5d..06a9cf67cfb6b 100644 --- a/go/arrow/ipc/compression.go +++ b/go/arrow/ipc/compression.go @@ -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 { diff --git a/go/arrow/ipc/file_reader.go b/go/arrow/ipc/file_reader.go index 1c7eb31799cfa..729225e794406 100644 --- a/go/arrow/ipc/file_reader.go +++ b/go/arrow/ipc/file_reader.go @@ -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()