| 334 | |
| 335 | template <typename ParquetType> |
| 336 | static void BM_DecodingSpaced(benchmark::State& state, Encoding::type encoding) { |
| 337 | using ArrowType = typename BM_SpacedEncodingTraits<ParquetType>::ArrowType; |
| 338 | using ArrayType = typename BM_SpacedEncodingTraits<ParquetType>::ArrayType; |
| 339 | using CType = typename BM_SpacedEncodingTraits<ParquetType>::CType; |
| 340 | |
| 341 | const int num_values = static_cast<int>(state.range(0)); |
| 342 | const auto null_percent = static_cast<double>(state.range(1)) / 10000.0; |
| 343 | |
| 344 | auto rand = ::arrow::random::RandomArrayGenerator(1923); |
| 345 | std::shared_ptr<::arrow::Array> array; |
| 346 | if constexpr (std::is_same_v<ParquetType, BooleanType>) { |
| 347 | array = rand.Boolean(num_values, /*true_probability*/ 0.5, null_percent); |
| 348 | } else { |
| 349 | array = rand.Numeric<ArrowType>(num_values, -100, 100, null_percent); |
| 350 | } |
| 351 | const auto valid_bits = array->null_bitmap_data(); |
| 352 | const int null_count = static_cast<int>(array->null_count()); |
| 353 | const auto array_actual = ::arrow::internal::checked_pointer_cast<ArrayType>(array); |
| 354 | |
| 355 | auto encoder = MakeTypedEncoder<ParquetType>(encoding); |
| 356 | encoder->Put(*array); |
| 357 | std::shared_ptr<Buffer> buf = encoder->FlushValues(); |
| 358 | |
| 359 | auto decoder = MakeTypedDecoder<ParquetType>(encoding); |
| 360 | std::vector<uint8_t> decode_values(num_values * sizeof(CType)); |
| 361 | auto decode_buf = reinterpret_cast<CType*>(decode_values.data()); |
| 362 | for (auto _ : state) { |
| 363 | decoder->SetData(num_values - null_count, buf->data(), static_cast<int>(buf->size())); |
| 364 | decoder->DecodeSpaced(decode_buf, num_values, null_count, valid_bits, 0); |
| 365 | } |
| 366 | state.counters["null_percent"] = null_percent * 100; |
| 367 | state.SetBytesProcessed(state.iterations() * num_values * sizeof(CType)); |
| 368 | } |
| 369 | |
| 370 | template <typename ParquetType> |
| 371 | static void BM_PlainDecodingSpaced(benchmark::State& state) { |
nothing calls this directly
no test coverage detected