Commit 86c8431
committed
apacheGH-3493: Optimize PlainValuesReader with direct ByteBuffer reads
Replace the LittleEndianDataInputStream wrapper with direct ByteBuffer
access using LITTLE_ENDIAN byte order in PlainValuesReader. Each
read{Integer,Long,Float,Double}() previously dispatched through 4
in.read() calls per value and assembled the result with manual bit
shifts; it now compiles to a single ByteBuffer get*() JVM intrinsic.
In initFromPage, the page data is obtained as a single contiguous
ByteBuffer via ByteBufferInputStream.slice(available). The
ByteBufferInputStream.slice() method handles both single-buffer
(zero-copy view) and multi-buffer (copy into contiguous buffer) cases
transparently. In practice page data is almost always a single
contiguous buffer.
Benchmark (IntEncodingBenchmark.decodePlain, 100k INT32 values per
invocation, JMH -wi 3 -i 5 -f 1):
Pattern Before (ops/s) After (ops/s) Speedup
SEQUENTIAL 427,630,411 5,397,298,681 12.6x
RANDOM 431,052,072 5,437,926,758 12.6x
LOW_CARDINALITY 423,443,685 5,477,810,011 12.9x
HIGH_CARDINALITY 426,405,891 5,485,493,740 12.9x
The improvement is consistent regardless of data distribution because
the bottleneck was entirely in the dispatch overhead. All four numeric
plain reader types (int, long, float, double) benefit equally.
All 573 parquet-column tests pass.1 parent 53d7842 commit 86c8431
2 files changed
Lines changed: 25 additions & 51 deletions
File tree
- parquet-column/src/main/java/org/apache/parquet/column/values/plain
Lines changed: 23 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | | - | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | | - | |
| 41 | + | |
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
39 | 45 | | |
40 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
41 | 52 | | |
42 | 53 | | |
43 | 54 | | |
44 | 55 | | |
45 | 56 | | |
46 | 57 | | |
47 | 58 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 68 | + | |
73 | 69 | | |
74 | 70 | | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
78 | 74 | | |
79 | 75 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 76 | + | |
85 | 77 | | |
86 | 78 | | |
87 | 79 | | |
88 | 80 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 81 | + | |
94 | 82 | | |
95 | 83 | | |
96 | 84 | | |
97 | 85 | | |
98 | 86 | | |
99 | 87 | | |
100 | 88 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 89 | + | |
106 | 90 | | |
107 | 91 | | |
108 | 92 | | |
109 | 93 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 94 | + | |
115 | 95 | | |
116 | 96 | | |
117 | 97 | | |
118 | 98 | | |
119 | 99 | | |
120 | 100 | | |
121 | 101 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 102 | + | |
127 | 103 | | |
128 | 104 | | |
129 | 105 | | |
130 | 106 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 107 | + | |
136 | 108 | | |
137 | 109 | | |
138 | 110 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
| 597 | + | |
| 598 | + | |
597 | 599 | | |
598 | 600 | | |
599 | 601 | | |
| |||
0 commit comments