Improve `RunLengthBitPackingHybridDecoder.readNext` to avoid per-call buffer allocation and `DataInputStream` wrapping
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
parquet-column/src/main/java/org/apache/parquet/column/values/rle/RunLengthBitPackingHybridDecoder.java から開始し、94–98 行付近の readNext() にある PACKED-mode パスと、既存の TODO に注目します。バッファーと入力読み取りがどのように使用されているかを追跡し、その後、関連するデコーダーテストを実行します。繰り返し行われる PACKED-mode の呼び出しで、呼び出しごとに DataInputStream ラッパーを作成せず、十分なサイズのバッファーが再利用され、デコード動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the enhancement requested
RunLengthBitPackingHybridDecoder.readNext() allocates a new int[] and byte[] on every PACKED-mode call. In workloads that decode many bit-packed runs (definition levels, repetition levels, RLE-encoded integers), these allocations dominate the read-side allocation profile. The upstream code even acknowledges this with a // TODO: reuse a buffer comment.
Problem 1: per-call buffer allocation
Lines 94–95 allocate fresh arrays on every PACKED-mode readNext():
currentBuffer = new int[currentCount]; // TODO: reuse a buffer
byte[] bytes = new byte[numGroups * bitWidth];
currentCount is always numGroups * 8, and numGroups is typically small (1–16 groups = 8–128 values per run). These allocations are individually modest but occur thousands of times per column chunk — once per bit-packed run. In a 180M-row merge with multiple integer/boolean columns, the cumulative allocation is substantial.
Since currentCount varies between runs (different numGroups values), the fix retains the field-level int[] and a new field-level byte[], growing them only when the next run requires a larger buffer.
Problem 2: per-call DataInputStream wrapping
Line 98 creates a new DataInputStream(in) on every PACKED-mode call:
new DataInputStream(in).readFully(bytes, 0, bytesToRead);
This allocates a DataInputStream wrapper object per call just to access readFully(). A private readFully() method on the decoder itself eliminates this allocation and the virtual dispatch through the wrapper.
Component(s)
Core
- 主要言語
- Java
- スター
- 3.1k
- フォーク
- 1.6k
- 平均マージ
- 4日 5時間
- マージ済み PR(30日)
- 30
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/parquet-java のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
apache/parquet-java#3829 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
apache/parquet-java#3820 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/parquet-java#3767 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/parquet-java#3695 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/parquet-java#3667 ·
メンテナーはふだん 2 日以内に返信
apache/parquet-java の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
objectionary/eo#9182 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
objectionary/hone-maven-plugin#1293 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
MaikuB/flutter_appauth#683 ·
-
wait for review
難易度 1/5 1〜3時間 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信