| 165 | } |
| 166 | |
| 167 | static void StreamingDecompression( |
| 168 | Compression::type compression, const std::vector<uint8_t>& data, |
| 169 | benchmark::State& state) { // NOLINT non-const reference |
| 170 | auto codec = *Codec::Create(compression); |
| 171 | |
| 172 | std::vector<uint8_t> compressed_data; |
| 173 | ARROW_UNUSED(StreamingCompress(codec.get(), data, &compressed_data)); |
| 174 | state.counters["ratio"] = |
| 175 | static_cast<double>(data.size()) / static_cast<double>(compressed_data.size()); |
| 176 | |
| 177 | while (state.KeepRunning()) { |
| 178 | auto decompressor = *codec->MakeDecompressor(); |
| 179 | |
| 180 | const uint8_t* input = compressed_data.data(); |
| 181 | int64_t input_len = compressed_data.size(); |
| 182 | int64_t decompressed_size = 0; |
| 183 | |
| 184 | std::vector<uint8_t> output_buffer(1 << 20); // 1 MB |
| 185 | while (!decompressor->IsFinished()) { |
| 186 | auto result = *decompressor->Decompress(input_len, input, output_buffer.size(), |
| 187 | output_buffer.data()); |
| 188 | input += result.bytes_read; |
| 189 | input_len -= result.bytes_read; |
| 190 | decompressed_size += result.bytes_written; |
| 191 | if (result.need_more_output) { |
| 192 | // Enlarge output buffer |
| 193 | output_buffer.resize(output_buffer.size() * 2); |
| 194 | } |
| 195 | } |
| 196 | ARROW_CHECK(decompressed_size == static_cast<int64_t>(data.size())); |
| 197 | } |
| 198 | state.SetBytesProcessed(state.iterations() * data.size()); |
| 199 | } |
| 200 | |
| 201 | template <Compression::type COMPRESSION> |
| 202 | static void ReferenceStreamingDecompression( |
no test coverage detected