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

Function BM_DecodingSpaced

cpp/src/parquet/encoding_benchmark.cc:336–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334
335template <typename ParquetType>
336static 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
370template <typename ParquetType>
371static void BM_PlainDecodingSpaced(benchmark::State& state) {

Callers

nothing calls this directly

Calls 8

BooleanMethod · 0.45
null_countMethod · 0.45
PutMethod · 0.45
FlushValuesMethod · 0.45
dataMethod · 0.45
SetDataMethod · 0.45
sizeMethod · 0.45
DecodeSpacedMethod · 0.45

Tested by

no test coverage detected