Skip to content

Commit

Permalink
apacheGH-39845: [C++][Parquet] Minor: avoid creating a new Reader obj…
Browse files Browse the repository at this point in the history
…ect in Decoder::SetData (apache#39847)

### Rationale for this change

avoid creating a new Reader object in Decoder::SetData

### What changes are included in this PR?

avoid creating a new Reader object in Decoder::SetData

### Are these changes tested?

Already

### Are there any user-facing changes?

no

* Closes: apache#39845

Authored-by: mwish <[email protected]>
Signed-off-by: mwish <[email protected]>
  • Loading branch information
mapleFU authored and dgreiss committed Feb 17, 2024
1 parent 08ccb3c commit 59752fc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cpp/src/parquet/encoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2411,7 +2411,11 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual public TypedDecoder<DTyp
void SetData(int num_values, const uint8_t* data, int len) override {
// num_values is equal to page's num_values, including null values in this page
this->num_values_ = num_values;
decoder_ = std::make_shared<::arrow::bit_util::BitReader>(data, len);
if (decoder_ == nullptr) {
decoder_ = std::make_shared<::arrow::bit_util::BitReader>(data, len);
} else {
decoder_->Reset(data, len);
}
InitHeader();
}

Expand Down Expand Up @@ -2769,7 +2773,11 @@ class DeltaLengthByteArrayDecoder : public DecoderImpl,

void SetData(int num_values, const uint8_t* data, int len) override {
DecoderImpl::SetData(num_values, data, len);
decoder_ = std::make_shared<::arrow::bit_util::BitReader>(data, len);
if (decoder_ == nullptr) {
decoder_ = std::make_shared<::arrow::bit_util::BitReader>(data, len);
} else {
decoder_->Reset(data, len);
}
DecodeLengths();
}

Expand Down

0 comments on commit 59752fc

Please sign in to comment.