MCPcopy Create free account
hub / github.com/apache/arrow / Decompress

Method Decompress

cpp/src/arrow/util/compression_zstd.cc:170–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168 decompression_context_params_(std::move(decompression_context_params)) {}
169
170 Result<int64_t> Decompress(int64_t input_len, const uint8_t* input,
171 int64_t output_buffer_len, uint8_t* output_buffer) override {
172 if (output_buffer == nullptr) {
173 // We may pass a NULL 0-byte output buffer but some zstd versions demand
174 // a valid pointer: https://github.com/facebook/zstd/issues/1385
175 static uint8_t empty_buffer;
176 DCHECK_EQ(output_buffer_len, 0);
177 output_buffer = &empty_buffer;
178 }
179
180 ARROW_ASSIGN_OR_RAISE(auto dctx, CreateDCtx());
181 size_t ret = ZSTD_decompressDCtx(dctx.get(), output_buffer,
182 static_cast<size_t>(output_buffer_len), input,
183 static_cast<size_t>(input_len));
184 if (ZSTD_isError(ret)) {
185 return ZSTDError(ret, "ZSTD decompression failed: ");
186 }
187 if (static_cast<int64_t>(ret) != output_buffer_len) {
188 return Status::IOError("Corrupt ZSTD compressed data.");
189 }
190 return static_cast<int64_t>(ret);
191 }
192
193 int64_t MaxCompressedLen(int64_t input_len,
194 const uint8_t* ARROW_ARG_UNUSED(input)) override {

Callers

nothing calls this directly

Calls 3

ZSTDErrorFunction · 0.85
IOErrorFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected