| 664 | #endif // ARROW_BUILD_DETAILED_BENCHMARKS |
| 665 | |
| 666 | void RowArrayDecodeBenchmark(benchmark::State& st, const std::shared_ptr<Schema>& schema, |
| 667 | int column_to_decode) { |
| 668 | auto batches = MakeRandomBatches(schema, 1, std::numeric_limits<uint16_t>::max()); |
| 669 | const auto& batch = batches.batches[0]; |
| 670 | RowArray rows; |
| 671 | std::vector<uint16_t> row_ids_encode(batch.length); |
| 672 | std::iota(row_ids_encode.begin(), row_ids_encode.end(), 0); |
| 673 | std::vector<KeyColumnArray> temp_column_arrays; |
| 674 | DCHECK_OK(rows.AppendBatchSelection( |
| 675 | default_memory_pool(), internal::CpuInfo::GetInstance()->hardware_flags(), batch, 0, |
| 676 | static_cast<int>(batch.length), static_cast<int>(batch.length), |
| 677 | row_ids_encode.data(), temp_column_arrays)); |
| 678 | std::vector<uint32_t> row_ids_decode(batch.length); |
| 679 | // Create a random access pattern to simulate hash join. |
| 680 | std::default_random_engine gen(42); |
| 681 | std::uniform_int_distribution<uint32_t> dist(0, |
| 682 | static_cast<uint32_t>(batch.length - 1)); |
| 683 | std::transform(row_ids_decode.begin(), row_ids_decode.end(), row_ids_decode.begin(), |
| 684 | [&](uint32_t) { return dist(gen); }); |
| 685 | |
| 686 | for (auto _ : st) { |
| 687 | ResizableArrayData column; |
| 688 | // Allocate at least 8 rows for the convenience of SIMD decoding. |
| 689 | int log_num_rows_min = std::max(3, bit_util::Log2(batch.length)); |
| 690 | DCHECK_OK(column.Init(batch[column_to_decode].type(), default_memory_pool(), |
| 691 | log_num_rows_min)); |
| 692 | DCHECK_OK(rows.DecodeSelected(&column, column_to_decode, |
| 693 | static_cast<int>(batch.length), row_ids_decode.data(), |
| 694 | default_memory_pool())); |
| 695 | } |
| 696 | st.SetItemsProcessed(st.iterations() * batch.length); |
| 697 | } |
| 698 | |
| 699 | static void BM_RowArray_Decode(benchmark::State& st, |
| 700 | const std::shared_ptr<DataType>& type) { |
no test coverage detected