pitrou commented on code in PR #43832:
URL: https://github.com/apache/arrow/pull/43832#discussion_r1743700472


##########
cpp/src/arrow/acero/hash_join_benchmark.cc:
##########
@@ -640,5 +660,112 @@ BENCHMARK(BM_HashJoinBasic_ProbeParallelism)
 
 #endif  // ARROW_BUILD_DETAILED_BENCHMARKS
 
+void RowArrayDecodeBenchmark(benchmark::State& st, const 
std::shared_ptr<Schema>& schema,
+                             int column_to_decode) {
+  auto batches = MakeRandomBatches(schema, 1, 
std::numeric_limits<uint16_t>::max());
+  const auto& batch = batches.batches[0];
+  RowArray rows;
+  std::vector<uint16_t> row_ids_encode(batch.length);
+  std::iota(row_ids_encode.begin(), row_ids_encode.end(), 0);
+  std::vector<KeyColumnArray> temp_column_arrays;
+  DCHECK_OK(rows.AppendBatchSelection(
+      default_memory_pool(), 
internal::CpuInfo::GetInstance()->hardware_flags(), batch, 0,
+      static_cast<int>(batch.length), static_cast<int>(batch.length),
+      row_ids_encode.data(), temp_column_arrays));
+  std::vector<uint32_t> row_ids_decode(batch.length);
+  // Create a random access pattern to simulate hash join.
+  std::default_random_engine gen(42);
+  std::uniform_int_distribution<uint32_t> dist(0,
+                                               
static_cast<uint32_t>(batch.length - 1));
+  std::transform(row_ids_decode.begin(), row_ids_decode.end(), 
row_ids_decode.begin(),
+                 [&](uint32_t) { return dist(gen); });
+
+  uint64_t total_rows = 0;
+  for (auto _ : st) {
+    st.PauseTiming();
+    ResizableArrayData column;
+    // Allocate at least 8 rows for the convenience of SIMD decoding.
+    int log_num_rows_min = std::max(3, bit_util::Log2(batch.length));
+    DCHECK_OK(column.Init(batch[column_to_decode].type(), 
default_memory_pool(),
+                          log_num_rows_min));
+    st.ResumeTiming();
+    DCHECK_OK(rows.DecodeSelected(&column, column_to_decode,
+                                  static_cast<int>(batch.length), 
row_ids_decode.data(),
+                                  default_memory_pool()));
+    total_rows += batch.length;
+  }
+  st.counters["rows/sec"] = benchmark::Counter(total_rows, 
benchmark::Counter::kIsRate);
+}
+
+template <typename... Args>

Review Comment:
   What are the `Args` for?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to