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

Method Compress

cpp/src/arrow/util/compression_lz4.cc:432–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430 }
431
432 Result<int64_t> Compress(int64_t input_len, const uint8_t* input,
433 int64_t output_buffer_len, uint8_t* output_buffer) override {
434 if (output_buffer_len < kPrefixLength) {
435 return Status::Invalid("Output buffer too small for Lz4HadoopCodec compression");
436 }
437
438 ARROW_ASSIGN_OR_RAISE(
439 int64_t output_len,
440 Lz4Codec::Compress(input_len, input, output_buffer_len - kPrefixLength,
441 output_buffer + kPrefixLength));
442
443 // Prepend decompressed size in bytes and compressed size in bytes
444 // to be compatible with Hadoop Lz4Codec
445 const uint32_t decompressed_size =
446 bit_util::ToBigEndian(static_cast<uint32_t>(input_len));
447 const uint32_t compressed_size =
448 bit_util::ToBigEndian(static_cast<uint32_t>(output_len));
449 SafeStore(output_buffer, decompressed_size);
450 SafeStore(output_buffer + sizeof(uint32_t), compressed_size);
451
452 return kPrefixLength + output_len;
453 }
454
455 Result<std::shared_ptr<Compressor>> MakeCompressor() override {
456 return Status::NotImplemented(

Callers

nothing calls this directly

Calls 3

SafeStoreFunction · 0.85
ToBigEndianFunction · 0.70
InvalidFunction · 0.50

Tested by

no test coverage detected