Skip to content

Commit

Permalink
apacheGH-42140: [C++] Avoid invalid accesses in parquet-encoding-benc…
Browse files Browse the repository at this point in the history
…hmark
  • Loading branch information
pitrou committed Jun 13, 2024
1 parent 40f9c26 commit a8d1141
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions cpp/src/parquet/encoding_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1233,12 +1233,10 @@ class BenchmarkDecodeArrowByteArray : public BenchmarkDecodeArrowBase<ByteArrayT
valid_bits_ = input_array_->null_bitmap_data();
total_size_ = input_array_->data()->buffers[2]->size();

values_.reserve(num_values_);
values_.resize(num_values_);
const auto& binary_array = static_cast<const ::arrow::BinaryArray&>(*input_array_);
for (int64_t i = 0; i < binary_array.length(); i++) {
auto view = binary_array.GetView(i);
values_.emplace_back(static_cast<uint32_t>(view.length()),
reinterpret_cast<const uint8_t*>(view.data()));
values_[i] = binary_array.GetView(i);
}
}

Expand Down Expand Up @@ -1431,10 +1429,10 @@ class BenchmarkDecodeArrowBoolean : public BenchmarkDecodeArrowBase<BooleanType>
// so, we uses this as "total_size" for the benchmark.
total_size_ = ::arrow::bit_util::BytesForBits(num_values_);

values_.reserve(num_values_);
values_.resize(num_values_);
const auto& boolean_array = static_cast<const ::arrow::BooleanArray&>(*input_array_);
for (int64_t i = 0; i < boolean_array.length(); i++) {
values_.push_back(boolean_array.Value(i));
values_[i] = boolean_array.Value(i);
}
}

Expand Down

0 comments on commit a8d1141

Please sign in to comment.