| 358 | } |
| 359 | |
| 360 | Result<int64_t> Compress(int64_t input_len, const uint8_t* input, |
| 361 | int64_t output_buffer_len, uint8_t* output_buffer) override { |
| 362 | int64_t output_len; |
| 363 | #ifdef LZ4HC_CLEVEL_MIN |
| 364 | constexpr int min_hc_clevel = LZ4HC_CLEVEL_MIN; |
| 365 | #else // For older versions of the lz4 library |
| 366 | constexpr int min_hc_clevel = 3; |
| 367 | #endif |
| 368 | if (compression_level_ < min_hc_clevel) { |
| 369 | output_len = LZ4_compress_default( |
| 370 | reinterpret_cast<const char*>(input), reinterpret_cast<char*>(output_buffer), |
| 371 | static_cast<int>(input_len), static_cast<int>(output_buffer_len)); |
| 372 | } else { |
| 373 | output_len = LZ4_compress_HC( |
| 374 | reinterpret_cast<const char*>(input), reinterpret_cast<char*>(output_buffer), |
| 375 | static_cast<int>(input_len), static_cast<int>(output_buffer_len), |
| 376 | compression_level_); |
| 377 | } |
| 378 | if (output_len == 0) { |
| 379 | return Status::IOError("Lz4 compression failure."); |
| 380 | } |
| 381 | return output_len; |
| 382 | } |
| 383 | |
| 384 | Result<std::shared_ptr<Compressor>> MakeCompressor() override { |
| 385 | return Status::NotImplemented( |