HuaHuaY commented on code in PR #48865:
URL: https://github.com/apache/arrow/pull/48865#discussion_r2696600193
##########
cpp/src/arrow/util/compression_zstd.cc:
##########
@@ -235,13 +226,47 @@ class ZSTDCodec : public Codec {
int compression_level() const override { return compression_level_; }
private:
+ Result<CCtxPtr> CreateCCtx() const {
+ CCtxPtr cctx{ZSTD_createCCtx(), ZSTD_freeCCtx};
+ auto ret =
+ ZSTD_CCtx_setParameter(cctx.get(), ZSTD_c_compressionLevel,
compression_level_);
+ if (ZSTD_isError(ret)) {
+ return ZSTDError(ret, "ZSTD_CCtx create failed: ");
+ }
+ for (auto& [key, value] : compression_context_params_) {
+ ret = ZSTD_CCtx_setParameter(cctx.get(),
static_cast<ZSTD_cParameter>(key), value);
+ if (ZSTD_isError(ret)) {
+ return ZSTDError(ret, "ZSTD_CCtx create failed: ");
+ }
+ }
+ return cctx;
+ }
+
+ Result<DCtxPtr> CreateDCtx() const {
+ DCtxPtr dctx{ZSTD_createDCtx(), ZSTD_freeDCtx};
+ for (auto& [key, value] : decompression_context_params_) {
+ auto ret =
+ ZSTD_DCtx_setParameter(dctx.get(),
static_cast<ZSTD_dParameter>(key), value);
+ if (ZSTD_isError(ret)) {
+ return ZSTDError(ret, "ZSTD_DCtx create failed: ");
Review Comment:
By `ZSTD_getErrorName(ret)`. You can check line 44
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]