Skip to content

Commit 859bf82

Browse files
author
Andreas Ringlstetter
committed
Minimise ZSTD context changes #48187
1 parent fab5a70 commit 859bf82

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cpp/src/arrow/util/compression_zstd.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,15 @@ class ZSTDCodec : public Codec {
229229
if (!compression_context_) {
230230
compression_context_ =
231231
decltype(compression_context_)(ZSTD_createCCtx(), ZSTDContextDeleter{});
232+
size_t ret = ZSTD_CCtx_setParameter(compression_context_.get(),
233+
ZSTD_c_compressionLevel, compression_level_);
234+
if (ZSTD_isError(ret)) {
235+
return ZSTDError(ret, "Setting ZSTD compression level failed: ");
236+
}
232237
}
233-
size_t ret = ZSTD_compressCCtx(compression_context_.get(), output_buffer,
234-
static_cast<size_t>(output_buffer_len), input,
235-
static_cast<size_t>(input_len), compression_level_);
238+
size_t ret = ZSTD_compress2(compression_context_.get(), output_buffer,
239+
static_cast<size_t>(output_buffer_len), input,
240+
static_cast<size_t>(input_len));
236241
if (ZSTD_isError(ret)) {
237242
return ZSTDError(ret, "ZSTD compression failed: ");
238243
}

0 commit comments

Comments
 (0)