mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 10:31:57 +00:00
separate explicit finalization for buffers
This commit is contained in:
parent
73f1ed3b69
commit
92d42567fa
@ -43,13 +43,6 @@ public:
|
||||
return offset();
|
||||
}
|
||||
|
||||
protected:
|
||||
void finalizeImpl() override
|
||||
{
|
||||
BufferWithOwnMemory<WriteBuffer>::finalizeImpl();
|
||||
out.finalize();
|
||||
}
|
||||
|
||||
private:
|
||||
void nextImpl() override;
|
||||
|
||||
|
@ -23,17 +23,7 @@ BrotliWriteBuffer::BrotliStateWrapper::~BrotliStateWrapper()
|
||||
BrotliEncoderDestroyInstance(state);
|
||||
}
|
||||
|
||||
BrotliWriteBuffer::~BrotliWriteBuffer()
|
||||
{
|
||||
try
|
||||
{
|
||||
finalize();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
BrotliWriteBuffer::~BrotliWriteBuffer() = default;
|
||||
|
||||
void BrotliWriteBuffer::nextImpl()
|
||||
{
|
||||
|
@ -33,17 +33,7 @@ Bzip2WriteBuffer::Bzip2StateWrapper::~Bzip2StateWrapper()
|
||||
BZ2_bzCompressEnd(&stream);
|
||||
}
|
||||
|
||||
Bzip2WriteBuffer::~Bzip2WriteBuffer()
|
||||
{
|
||||
try
|
||||
{
|
||||
finalize();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
Bzip2WriteBuffer::~Bzip2WriteBuffer() = default;
|
||||
|
||||
void Bzip2WriteBuffer::nextImpl()
|
||||
{
|
||||
|
@ -44,14 +44,8 @@ void LZMADeflatingWriteBuffer::initialize(int compression_level)
|
||||
|
||||
LZMADeflatingWriteBuffer::~LZMADeflatingWriteBuffer()
|
||||
{
|
||||
try
|
||||
{
|
||||
finalize();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
/// It is OK to call deflateEnd() twice (one from the finalizeAfter())
|
||||
lzma_end(&lstr);
|
||||
}
|
||||
|
||||
void LZMADeflatingWriteBuffer::nextImpl()
|
||||
|
@ -91,14 +91,8 @@ void Lz4DeflatingWriteBuffer::initialize(int compression_level)
|
||||
|
||||
Lz4DeflatingWriteBuffer::~Lz4DeflatingWriteBuffer()
|
||||
{
|
||||
try
|
||||
{
|
||||
finalize();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
if (ctx)
|
||||
LZ4F_freeCompressionContext(ctx);
|
||||
}
|
||||
|
||||
void Lz4DeflatingWriteBuffer::nextImpl()
|
||||
|
@ -44,14 +44,8 @@ void ZlibDeflatingWriteBuffer::nextImpl()
|
||||
|
||||
ZlibDeflatingWriteBuffer::~ZlibDeflatingWriteBuffer()
|
||||
{
|
||||
try
|
||||
{
|
||||
finalize();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
/// It is OK to call deflateEnd() twice (one from the finalizeAfter() that does the proper error checking)
|
||||
deflateEnd(&zstr);
|
||||
}
|
||||
|
||||
void ZlibDeflatingWriteBuffer::finalizeBefore()
|
||||
|
@ -51,14 +51,8 @@ void ZstdDeflatingWriteBuffer::initialize(int compression_level, int window_log)
|
||||
|
||||
ZstdDeflatingWriteBuffer::~ZstdDeflatingWriteBuffer()
|
||||
{
|
||||
try
|
||||
{
|
||||
finalize();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
if (cctx)
|
||||
ZSTD_freeCCtx(cctx);
|
||||
}
|
||||
|
||||
void ZstdDeflatingWriteBuffer::flush(ZSTD_EndDirective mode)
|
||||
|
@ -87,9 +87,9 @@ private:
|
||||
return;
|
||||
finalized = true;
|
||||
|
||||
if (out_maybe_compressed)
|
||||
out_maybe_compressed->finalize();
|
||||
else if (out)
|
||||
if (out_compressed_holder)
|
||||
out_compressed_holder->finalize();
|
||||
if (out)
|
||||
out->finalize();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user