Skip to content

GH-50421: [C++][Parquet] Add LevelDecoder Skip and Count#50422

Open
AntoinePrv wants to merge 13 commits into
apache:mainfrom
AntoinePrv:rle-bitmap-skip
Open

GH-50421: [C++][Parquet] Add LevelDecoder Skip and Count#50422
AntoinePrv wants to merge 13 commits into
apache:mainfrom
AntoinePrv:rle-bitmap-skip

Conversation

@AntoinePrv

@AntoinePrv AntoinePrv commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Rationale for this change

Adding new methods to the LevelDecoder to start reducing the complexity in ColumnReaderImplBase, TypedColumnReaderImpl, and TypedRecordReader.

What changes are included in this PR?

  • Simplify LevelDecoder members based on a single variant
  • Add LevelDecoder::Skip
  • Add LevelDecoder::CountUpTo
  • Simplify Skip implementation in TypedColumnReaderImpl
  • Add SkippableTypedDecoder to wrap TypedDecoder with the remaining usage of the scratch_for_skip_ buffer

Are these changes tested?

Yes.

Are there any user-facing changes?

No.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #50421 has been automatically assigned in GitHub to PR creator.

@AntoinePrv AntoinePrv marked this pull request as ready for review July 8, 2026 15:12
Copilot AI review requested due to automatic review settings July 8, 2026 15:12
@AntoinePrv AntoinePrv requested review from pitrou and wgtmac as code owners July 8, 2026 15:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Parquet C++ decoding by moving more “skip/count” functionality into LevelDecoder and underlying RLE/bit-packed utilities, with the goal of simplifying skip logic in column/record readers.

Changes:

  • Refactors LevelDecoder to a single std::variant-backed implementation and adds Skip / CountUpTo.
  • Reworks TypedColumnReaderImpl::Skip to skip within a page by advancing rep/def levels and skipping only the required physical values.
  • Adds/updates Arrow RLE/bit-packed decoder internals and tests for Advance / CountUpTo.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
cpp/src/parquet/column_reader.h Updates LevelDecoder public API/docs to add Skip and CountUpTo and hide implementation details behind a pimpl.
cpp/src/parquet/column_reader.cc Implements new LevelDecoder internals, introduces SkippableTypedDecoder, and simplifies TypedColumnReaderImpl::Skip.
cpp/src/arrow/util/rle_encoding_internal.h Adds Advance / CountUpTo plumbing, introduces BitPackedDecoder, and refactors run processing into ProcessValues.
cpp/src/arrow/util/rle_encoding_test.cc Adds targeted tests for CountUpTo and Advance behavior.

Comment on lines +603 to +605
value_bit_width_ = value_bit_width;
const auto value_count = (static_cast<int64_t>(data_size) * 8) / value_bit_width;
ARROW_DCHECK_LE(value_count, std::numeric_limits<rle_size_t>::max());
Comment on lines +205 to +208
const int num_values = std::min(num_values_remaining_, batch_size);
const int num_advanced = decoder_->Advance(num_values);
ARROW_DCHECK_EQ(num_values, num_advanced);
num_values_remaining_ -= num_advanced;
Comment on lines +213 to +216
const int num_values = std::min(num_values_remaining_, batch_size);
const auto result = decoder_->CountUpTo(value, num_values);
ARROW_DCHECK_EQ(num_values, result.advanced_count);
num_values_remaining_ -= result.advanced_count;
Comment thread cpp/src/parquet/column_reader.cc
Comment on lines +78 to +80
/// Initialize the LevelDecoder state with new data from a V2 page.
///
/// Encoding of the level in the
/// Use a scratch buffer to decode values into that buffer.
/// This was migrated here from a historical implementation.
/// Ideally all decoders would implement a `Skip` functionality that would at best
/// avoid decoding, and at worst, decode without intermediarry allocation.
Comment on lines +316 to +320
/// Advance and count the number of occurrence of a values.
///
/// The count is limited to at most the next `batch_size` items.
/// @return The matching value count and number of of element that were processed.
RleCountUpToResult CountUpTo(const RleCountUpToParams<value_type>& p) {
Comment on lines +90 to +93
/// Advance and count the number of occurrence of a values.
///
/// The count is limited to at most the next `batch_size` items.
/// @return The matching value count and number of elements that were processed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants