You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2023/03/22 05:14:03 UTC

[GitHub] [arrow] mapleFU commented on a diff in pull request #34676: GH-34673: [C++][Parquet] Add Boolean Encoding benchmark for parquet

mapleFU commented on code in PR #34676:
URL: https://github.com/apache/arrow/pull/34676#discussion_r1144236462


##########
cpp/src/parquet/encoding_benchmark.cc:
##########
@@ -279,22 +316,21 @@ static void BM_PlainDecodingSpaced(benchmark::State& state) {
   const auto null_percent = static_cast<double>(state.range(1)) / 10000.0;
 
   auto rand = ::arrow::random::RandomArrayGenerator(1923);
-  const auto array = rand.Numeric<ArrowType>(num_values, -100, 100, null_percent);
+  std::shared_ptr<::arrow::Array> array;
+  if constexpr (std::is_same_v<ParquetType, BooleanType>) {
+    array = rand.Boolean(num_values, /*true_probability*/0.5, null_percent);
+  } else {
+    array = rand.Numeric<ArrowType>(num_values, -100, 100, null_percent);
+  }
   const auto valid_bits = array->null_bitmap_data();
   const int null_count = static_cast<int>(array->null_count());
   const auto array_actual = ::arrow::internal::checked_pointer_cast<ArrayType>(array);
-  const auto raw_values = array_actual->raw_values();
-  // Guarantee the type cast between raw_values and input of PutSpaced.
-  static_assert(sizeof(CType) == sizeof(*raw_values), "Type mismatch");
-  // Cast only happens for BooleanType as it use UInt8 for the array data to match a bool*
-  // input to PutSpaced.
-  const auto src = reinterpret_cast<const CType*>(raw_values);
 
-  auto encoder = MakeTypedEncoder<ParquetType>(Encoding::PLAIN);
-  encoder->PutSpaced(src, num_values, valid_bits, 0);
+  auto encoder = MakeTypedEncoder<ParquetType>(encoding);
+  encoder->Put(*array);

Review Comment:
   Currently, this benchmark tests `GetSpaced`, so, when `Put` I just call `Put(array)`, and encoder itself will handle null and values



-- 
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-unsubscribe@arrow.apache.org

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