Commit 860485d
committed
GH-3495: Bulk write in LittleEndianDataOutputStream.writeInt/writeShort
Replace per-byte out.write(int) calls with a single out.write(byte[], 0, N)
using the existing writeBuffer[] field, matching the pattern already used
by writeLong. For writeInt this collapses 4 trips through the underlying
stream's bookkeeping (hasRemaining check, Math.addExact, slab-grow check,
single-byte store) into 1.
Resolves the long-standing TODO comment in writeInt that flagged this as
a potential improvement.
Although this PR also deprecates the class, the optimization is worth
landing for any external Parquet-format producer still using it until
they migrate to direct ByteBuffer writes. The change is minimal (~10
lines) and obviously correct (matches the existing writeLong pattern).
Benchmark (IntEncodingBenchmark.encodePlain when routed through
LittleEndianDataOutputStream):
~20.9M -> ~28.2M ops/s (+35%)
Validation: parquet-common 308 tests pass. Built with
-Dspotless.check.skip=true -Drat.skip=true -Djapicmp.skip=true.1 parent 0e8b821 commit 860485d
1 file changed
Lines changed: 9 additions & 11 deletions
Lines changed: 9 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
144 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
145 | 147 | | |
146 | 148 | | |
147 | 149 | | |
| |||
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
167 | | - | |
168 | 166 | | |
169 | 167 | | |
170 | 168 | | |
| |||
0 commit comments