mapleFU commented on code in PR #40876:
URL: https://github.com/apache/arrow/pull/40876#discussion_r1549812311
##########
cpp/src/parquet/encoding.cc:
##########
@@ -1188,19 +1191,52 @@ int PlainBooleanDecoder::DecodeArrow(
typename EncodingTraits<BooleanType>::Accumulator* builder) {
int values_decoded = num_values - null_count;
if (ARROW_PREDICT_FALSE(num_values_ < values_decoded)) {
+ // A too large `num_values` was requested.
+ ParquetException::EofException();
+ }
+ if (ARROW_PREDICT_FALSE(!bit_reader_->Advance(values_decoded))) {
ParquetException::EofException();
}
- PARQUET_THROW_NOT_OK(builder->Reserve(num_values));
-
- VisitNullBitmapInline(
- valid_bits, valid_bits_offset, num_values, null_count,
- [&]() {
- bool value;
- ARROW_IGNORE_EXPR(bit_reader_->GetValue(1, &value));
- builder->UnsafeAppend(value);
- },
- [&]() { builder->UnsafeAppendNull(); });
+ if (null_count == 0) {
+ // FastPath: can copy the data directly
+ PARQUET_THROW_NOT_OK(builder->AppendValues(data_, values_decoded, NULLPTR,
+ total_num_values_ -
num_values_));
+ } else {
+ // Handle nulls by BitBlockCounter
+ PARQUET_THROW_NOT_OK(builder->Reserve(num_values));
+ BitBlockCounter bit_counter(valid_bits, valid_bits_offset, num_values);
+ int64_t value_position = 0;
+ int64_t valid_bits_offset_position = valid_bits_offset;
+ int64_t previous_value_offset = 0;
+ while (value_position < num_values) {
+ auto block = bit_counter.NextWord();
+ if (block.AllSet()) {
+ // Note: We don't have UnsafeAppendValues for booleans currently,
+ // so using `AppendValues` here.
Review Comment:
Created: https://github.com/apache/arrow/issues/40978
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]