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

Method End

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

Source from the content-addressed store, hash-verified

274 }
275
276 Result<EndResult> End(int64_t output_len, uint8_t* output) override {
277 DCHECK(initialized_) << "Called on non-initialized stream";
278
279 static constexpr auto input_limit =
280 static_cast<int64_t>(std::numeric_limits<uInt>::max());
281
282 stream_.avail_in = 0;
283 stream_.next_out = reinterpret_cast<Bytef*>(output);
284 stream_.avail_out = static_cast<uInt>(std::min(output_len, input_limit));
285
286 int64_t ret = 0;
287 ret = deflate(&stream_, Z_FINISH);
288 if (ret == Z_STREAM_ERROR) {
289 return ZlibError("zlib flush failed: ");
290 }
291 int64_t bytes_written = output_len - stream_.avail_out;
292 if (ret == Z_STREAM_END) {
293 // Flush complete, we can now end the stream
294 initialized_ = false;
295 ret = deflateEnd(&stream_);
296 if (ret == Z_OK) {
297 return EndResult{bytes_written, false};
298 } else {
299 return ZlibError("zlib end failed: ");
300 }
301 } else {
302 // Not everything could be flushed,
303 return EndResult{bytes_written, true};
304 }
305 }
306
307 protected:
308 Status ZlibError(const char* prefix_msg) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected