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

Function BM_EncodingSpaced

cpp/src/parquet/encoding_benchmark.cc:256–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254
255template <typename ParquetType>
256static void BM_EncodingSpaced(benchmark::State& state, Encoding::type encoding) {
257 using ArrowType = typename BM_SpacedEncodingTraits<ParquetType>::ArrowType;
258 using ArrayType = typename BM_SpacedEncodingTraits<ParquetType>::ArrayType;
259 using CType = typename BM_SpacedEncodingTraits<ParquetType>::CType;
260
261 const int num_values = static_cast<int>(state.range(0));
262 const double null_percent = static_cast<double>(state.range(1)) / 10000.0;
263
264 auto rand = ::arrow::random::RandomArrayGenerator(1923);
265 const auto array = rand.Numeric<ArrowType>(num_values, -100, 100, null_percent);
266 const auto valid_bits = array->null_bitmap_data();
267 const auto array_actual = ::arrow::internal::checked_pointer_cast<ArrayType>(array);
268 const auto raw_values = array_actual->raw_values();
269 // Guarantee the type cast between raw_values and input of PutSpaced.
270 static_assert(sizeof(CType) == sizeof(*raw_values), "Type mismatch");
271 // Cast only happens for BooleanType as it use UInt8 for the array data to match a bool*
272 // input to PutSpaced.
273 const auto src = reinterpret_cast<const CType*>(raw_values);
274
275 auto encoder = MakeTypedEncoder<ParquetType>(encoding);
276 for (auto _ : state) {
277 encoder->PutSpaced(src, num_values, valid_bits, 0);
278 encoder->FlushValues();
279 }
280 state.counters["null_percent"] = null_percent * 100;
281 state.SetBytesProcessed(state.iterations() * num_values * sizeof(CType));
282}
283
284template <>
285void BM_EncodingSpaced<BooleanType>(benchmark::State& state, Encoding::type encoding) {

Callers

nothing calls this directly

Calls 3

raw_valuesMethod · 0.45
PutSpacedMethod · 0.45
FlushValuesMethod · 0.45

Tested by

no test coverage detected