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

Method Decompress

cpp/src/arrow/util/compression_zlib.cc:144–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142 }
143
144 Result<DecompressResult> Decompress(int64_t input_len, const uint8_t* input,
145 int64_t output_len, uint8_t* output) override {
146 static constexpr auto input_limit =
147 static_cast<int64_t>(std::numeric_limits<uInt>::max());
148 stream_.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(input));
149 stream_.avail_in = static_cast<uInt>(std::min(input_len, input_limit));
150 stream_.next_out = reinterpret_cast<Bytef*>(output);
151 stream_.avail_out = static_cast<uInt>(std::min(output_len, input_limit));
152 int ret;
153
154 ret = inflate(&stream_, Z_SYNC_FLUSH);
155 if (ret == Z_DATA_ERROR || ret == Z_STREAM_ERROR || ret == Z_MEM_ERROR) {
156 return ZlibError("zlib inflate failed: ");
157 }
158 if (ret == Z_NEED_DICT) {
159 return ZlibError("zlib inflate failed (need preset dictionary): ");
160 }
161 finished_ = (ret == Z_STREAM_END);
162 if (ret == Z_BUF_ERROR) {
163 // No progress was possible
164 return DecompressResult{0, 0, true};
165 } else {
166 ARROW_CHECK(ret == Z_OK || ret == Z_STREAM_END);
167 // Some progress has been made
168 return DecompressResult{input_len - stream_.avail_in,
169 output_len - stream_.avail_out, false};
170 }
171 return Status::OK();
172 }
173
174 bool IsFinished() override { return finished_; }
175

Callers

nothing calls this directly

Calls 1

OKFunction · 0.50

Tested by

no test coverage detected