Skip to content

Commit caa91d0

Browse files
committed
GH-3475: Fix parquet-vector compatiblity with Java > 17
Replace the ByteBuffer-specific vector loads with local helpers that copy the required bytes and then call ByteVector.fromArray. This removes the dependency on JDK-specific ByteVector.fromByteBuffer entry points, which can fail with NoSuchMethodError on newer runtimes. Assisted-by: OpenCode:gpt-5.4
1 parent 4c8f4d4 commit caa91d0

3 files changed

Lines changed: 51 additions & 34 deletions

File tree

.github/workflows/vector-plugins.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
java: [ '17' ]
29+
java: [ '17', '21', '25' ]
3030
codes: [ 'uncompressed' ]
3131
name: Build Parquet with JDK ${{ matrix.java }} and ${{ matrix.codes }}
3232

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.class
22
.project
33
.classpath
4+
.factorypath
45
.settings
56
target
67
# Package Files #
@@ -20,4 +21,3 @@ target/
2021
mvn_install.log
2122
.vscode/*
2223
.DS_Store
23-

parquet-plugins/parquet-encoding-vector/src/main/java/org/apache/parquet/column/values/bitpacking/ByteBitPacking512VectorLE.java

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
177177

178178
public final void unpackValuesUsingVector(
179179
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
180-
ByteVector byteVector = ByteVector.fromByteBuffer(BYTE_SPECIES_64, in, inPos, in.order());
180+
ByteVector byteVector = fromByteBuffer(BYTE_SPECIES_64, in, inPos);
181181
ShortVector tempRes = byteVector
182182
.castShape(SHORT_SPECIES_512, 0)
183183
.reinterpretAsBytes()
@@ -260,7 +260,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
260260

261261
public final void unpackValuesUsingVector(
262262
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
263-
ByteVector byteVector = ByteVector.fromByteBuffer(BYTE_SPECIES, in, inPos, in.order());
263+
ByteVector byteVector = fromByteBuffer(BYTE_SPECIES, in, inPos);
264264
ShortVector tempRes = byteVector
265265
.castShape(LONG_SPECIES, 0)
266266
.reinterpretAsBytes()
@@ -377,7 +377,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
377377

378378
public final void unpackValuesUsingVector(
379379
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
380-
ByteVector byteVector = ByteVector.fromByteBuffer(B128, in, inPos, in.order())
380+
ByteVector byteVector = fromByteBuffer(B128, in, inPos, inp_mask)
381381
.castShape(S512, 0)
382382
.reinterpretAsBytes();
383383
ShortVector tempRes1 = byteVector
@@ -466,7 +466,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
466466

467467
public final void unpackValuesUsingVector(
468468
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
469-
ByteVector byteVector = ByteVector.fromByteBuffer(BSPECIES, in, inPos, in.order());
469+
ByteVector byteVector = fromByteBuffer(BSPECIES, in, inPos);
470470
ShortVector tempRes = byteVector
471471
.castShape(ISPECIES, 0)
472472
.reinterpretAsBytes()
@@ -582,7 +582,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
582582

583583
public final void unpackValuesUsingVector(
584584
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
585-
ByteVector byteVector = ByteVector.fromByteBuffer(B256, in, inPos, in.order(), inp_mask)
585+
ByteVector byteVector = fromByteBuffer(B256, in, inPos, inp_mask)
586586
.castShape(S512, 0)
587587
.reinterpretAsBytes();
588588

@@ -705,7 +705,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
705705

706706
public final void unpackValuesUsingVector(
707707
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
708-
ByteVector byteVector = ByteVector.fromByteBuffer(B256, in, inPos, in.order(), inp_mask)
708+
ByteVector byteVector = fromByteBuffer(B256, in, inPos, inp_mask)
709709
.castShape(S512, 0)
710710
.reinterpretAsBytes();
711711

@@ -827,7 +827,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
827827

828828
public final void unpackValuesUsingVector(
829829
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
830-
ByteVector byteVector = ByteVector.fromByteBuffer(B256, in, inPos, in.order(), inp_mask)
830+
ByteVector byteVector = fromByteBuffer(B256, in, inPos, inp_mask)
831831
.castShape(S512, 0)
832832
.reinterpretAsBytes();
833833
ShortVector tempRes1 = byteVector
@@ -914,7 +914,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
914914

915915
public final void unpackValuesUsingVector(
916916
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
917-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order());
917+
ByteVector byteVector = fromByteBuffer(B512, in, inPos);
918918
byteVector
919919
.castShape(ISPECIES, 0)
920920
.lanewise(VectorOperators.AND, 255)
@@ -1004,7 +1004,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
10041004

10051005
public final void unpackValuesUsingVector(
10061006
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1007-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
1007+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
10081008
ShortVector tempRes1 = byteVector
10091009
.rearrange(perm_mask0)
10101010
.reinterpretAsShorts()
@@ -1084,7 +1084,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
10841084

10851085
public final void unpackValuesUsingVector(
10861086
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1087-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order());
1087+
ByteVector byteVector = fromByteBuffer(B512, in, inPos);
10881088
ShortVector tempRes1 = byteVector
10891089
.rearrange(perm_mask0)
10901090
.reinterpretAsShorts()
@@ -1194,7 +1194,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
11941194

11951195
public final void unpackValuesUsingVector(
11961196
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1197-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
1197+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
11981198
ShortVector tempRes1 = byteVector
11991199
.rearrange(perm_mask0)
12001200
.reinterpretAsShorts()
@@ -1280,7 +1280,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
12801280

12811281
public final void unpackValuesUsingVector(
12821282
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1283-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order());
1283+
ByteVector byteVector = fromByteBuffer(B512, in, inPos);
12841284
ShortVector tempRes1 = byteVector
12851285
.rearrange(perm_mask0)
12861286
.reinterpretAsShorts()
@@ -1388,7 +1388,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
13881388

13891389
public final void unpackValuesUsingVector(
13901390
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1391-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
1391+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
13921392
ShortVector tempRes1 = byteVector
13931393
.rearrange(perm_mask0)
13941394
.reinterpretAsShorts()
@@ -1512,7 +1512,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
15121512

15131513
public final void unpackValuesUsingVector(
15141514
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1515-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
1515+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
15161516
ShortVector tempRes1 = byteVector
15171517
.rearrange(perm_mask0)
15181518
.reinterpretAsShorts()
@@ -1630,7 +1630,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
16301630

16311631
public final void unpackValuesUsingVector(
16321632
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1633-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
1633+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
16341634
ShortVector tempRes1 = byteVector
16351635
.rearrange(perm_mask0)
16361636
.reinterpretAsShorts()
@@ -1703,7 +1703,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
17031703

17041704
public final void unpackValuesUsingVector(
17051705
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1706-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
1706+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
17071707
ShortVector shortVector = byteVector.reinterpretAsShorts();
17081708
shortVector
17091709
.castShape(I512, 0)
@@ -1783,7 +1783,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
17831783

17841784
public final void unpackValuesUsingVector(
17851785
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1786-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
1786+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
17871787
IntVector tempRes1 = byteVector
17881788
.rearrange(perm_mask0)
17891789
.reinterpretAsInts()
@@ -1866,7 +1866,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
18661866

18671867
public final void unpackValuesUsingVector(
18681868
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1869-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
1869+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
18701870
IntVector tempRes1 = byteVector
18711871
.rearrange(perm_mask0)
18721872
.reinterpretAsInts()
@@ -1944,7 +1944,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
19441944

19451945
public final void unpackValuesUsingVector(
19461946
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
1947-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
1947+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
19481948
IntVector tempRes1 = byteVector
19491949
.rearrange(perm_mask0)
19501950
.reinterpretAsInts()
@@ -2022,7 +2022,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
20222022

20232023
public final void unpackValuesUsingVector(
20242024
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2025-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2025+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
20262026
IntVector tempRes1 = byteVector
20272027
.rearrange(perm_mask0)
20282028
.reinterpretAsInts()
@@ -2102,7 +2102,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
21022102

21032103
public final void unpackValuesUsingVector(
21042104
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2105-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2105+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
21062106
IntVector tempRes1 = byteVector
21072107
.rearrange(perm_mask0)
21082108
.reinterpretAsInts()
@@ -2182,7 +2182,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
21822182

21832183
public final void unpackValuesUsingVector(
21842184
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2185-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2185+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
21862186
IntVector tempRes1 = byteVector
21872187
.rearrange(perm_mask0)
21882188
.reinterpretAsInts()
@@ -2261,7 +2261,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
22612261

22622262
public final void unpackValuesUsingVector(
22632263
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2264-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2264+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
22652265
IntVector tempRes1 = byteVector
22662266
.rearrange(perm_mask0)
22672267
.reinterpretAsInts()
@@ -2332,7 +2332,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
23322332

23332333
public final void unpackValuesUsingVector(
23342334
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2335-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2335+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
23362336
IntVector tempRes1 =
23372337
byteVector.rearrange(perm_mask0).reinterpretAsInts().lanewise(VectorOperators.AND, 16777215);
23382338
tempRes1.intoArray(out, outPos, out_mask);
@@ -2407,7 +2407,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
24072407

24082408
public final void unpackValuesUsingVector(
24092409
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2410-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2410+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
24112411
IntVector tempRes1 = byteVector
24122412
.rearrange(perm_mask0)
24132413
.reinterpretAsInts()
@@ -2486,7 +2486,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
24862486

24872487
public final void unpackValuesUsingVector(
24882488
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2489-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2489+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
24902490
IntVector tempRes1 = byteVector
24912491
.rearrange(perm_mask0)
24922492
.reinterpretAsInts()
@@ -2603,7 +2603,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
26032603

26042604
public final void unpackValuesUsingVector(
26052605
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2606-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2606+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
26072607
IntVector tempRes1 = byteVector
26082608
.rearrange(perm_mask0)
26092609
.reinterpretAsInts()
@@ -2718,7 +2718,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
27182718

27192719
public final void unpackValuesUsingVector(
27202720
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2721-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2721+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
27222722
IntVector tempRes1 = byteVector
27232723
.rearrange(perm_mask0)
27242724
.reinterpretAsInts()
@@ -2832,7 +2832,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
28322832

28332833
public final void unpackValuesUsingVector(
28342834
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2835-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2835+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
28362836
IntVector tempRes1 = byteVector
28372837
.rearrange(perm_mask0)
28382838
.reinterpretAsInts()
@@ -2960,7 +2960,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
29602960

29612961
public final void unpackValuesUsingVector(
29622962
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
2963-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
2963+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
29642964
IntVector tempRes1 = byteVector
29652965
.rearrange(perm_mask0)
29662966
.reinterpretAsInts()
@@ -3089,7 +3089,7 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
30893089

30903090
public final void unpackValuesUsingVector(
30913091
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
3092-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
3092+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
30933093
IntVector tempRes1 = byteVector
30943094
.rearrange(perm_mask0)
30953095
.reinterpretAsInts()
@@ -3175,13 +3175,30 @@ public final void unpackValuesUsingVector(final byte[] in, final int inPos, fina
31753175

31763176
public final void unpackValuesUsingVector(
31773177
final ByteBuffer in, final int inPos, final int[] out, final int outPos) {
3178-
ByteVector byteVector = ByteVector.fromByteBuffer(B512, in, inPos, in.order(), inp_mask);
3178+
ByteVector byteVector = fromByteBuffer(B512, in, inPos, inp_mask);
31793179
IntVector tempRes1 = byteVector.rearrange(perm_mask0).reinterpretAsInts();
31803180

31813181
tempRes1.intoArray(out, outPos, out_mask);
31823182
}
31833183
}
31843184

3185+
private static ByteVector fromByteBuffer(VectorSpecies<Byte> species, ByteBuffer input, int inPos) {
3186+
return ByteVector.fromArray(species, readInputBytes(input, inPos, species.length()), 0);
3187+
}
3188+
3189+
private static ByteVector fromByteBuffer(
3190+
VectorSpecies<Byte> species, ByteBuffer input, int inPos, VectorMask<Byte> mask) {
3191+
return ByteVector.fromArray(species, readInputBytes(input, inPos, mask.trueCount()), 0, mask);
3192+
}
3193+
3194+
private static byte[] readInputBytes(ByteBuffer input, int inPos, int byteCount) {
3195+
byte[] bytes = new byte[byteCount];
3196+
ByteBuffer source = input.duplicate();
3197+
source.position(inPos);
3198+
source.get(bytes);
3199+
return bytes;
3200+
}
3201+
31853202
private static void notSupport() {
31863203
throw new RuntimeException(
31873204
"ByteBitPacking512VectorLE doesn't support the function, please use ByteBitPackingLE!");

0 commit comments

Comments
 (0)