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 2024/03/29 02:09:16 UTC
Re: [PR] GH-40872: [C++][Parquet] Encoding: Optimize DecodeArrow/Decode(bitmap) for PlainBooleanDecoder [arrow]
mapleFU commented on code in PR #40876:
URL: https://github.com/apache/arrow/pull/40876#discussion_r1543957842
##########
cpp/src/parquet/encoding.cc:
##########
@@ -1188,19 +1190,37 @@ 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 {
+ int64_t previous_offset = 0;
+ int64_t previous_value_offset = 0;
+ PARQUET_THROW_NOT_OK(::arrow::internal::VisitSetBitRuns(
Review Comment:
If the data is interleaving "null, non-null, null, non-null, ...". Don't know that would performance be
##########
cpp/src/parquet/encoding.cc:
##########
@@ -1188,19 +1190,37 @@ 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) {
Review Comment:
Seems `BooleanBuilder->Append{Nulls/Values}` don't have a unsafe api? So I don't call reserve
--
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