diff --git a/src/IO/ZstdDeflatingAppendableWriteBuffer.cpp b/src/IO/ZstdDeflatingAppendableWriteBuffer.cpp index 43c64be219f..dda2d13caa5 100644 --- a/src/IO/ZstdDeflatingAppendableWriteBuffer.cpp +++ b/src/IO/ZstdDeflatingAppendableWriteBuffer.cpp @@ -84,6 +84,8 @@ void ZstdDeflatingAppendableWriteBuffer::finalizeImpl() { if (first_write) { + /// To free cctx + finalizeZstd(); /// Nothing was written return; } @@ -117,6 +119,11 @@ void ZstdDeflatingAppendableWriteBuffer::finalizeBefore() } void ZstdDeflatingAppendableWriteBuffer::finalizeAfter() +{ + finalizeZstd(); +} + +void ZstdDeflatingAppendableWriteBuffer::finalizeZstd() { try { diff --git a/src/IO/ZstdDeflatingAppendableWriteBuffer.h b/src/IO/ZstdDeflatingAppendableWriteBuffer.h index 34ac1911312..2bddaafae69 100644 --- a/src/IO/ZstdDeflatingAppendableWriteBuffer.h +++ b/src/IO/ZstdDeflatingAppendableWriteBuffer.h @@ -52,6 +52,7 @@ private: void finalizeImpl() override; void finalizeBefore() override; void finalizeAfter() override; + void finalizeZstd(); /// Adding zstd empty block to out.working_buffer void addEmptyBlock();