1616 */
1717package org .apache .arrow .vector ;
1818
19+ import static org .apache .arrow .memory .util .MemoryUtil .LITTLE_ENDIAN ;
1920import static org .apache .arrow .vector .extension .UuidType .UUID_BYTE_WIDTH ;
2021
2122import java .nio .ByteBuffer ;
@@ -156,13 +157,17 @@ public int isSet(int index) {
156157 */
157158 public void get (int index , UuidHolder holder ) {
158159 Preconditions .checkArgument (index >= 0 , "Cannot get negative index in UUID vector." );
159- if (NullCheckingForGet .NULL_CHECKING_ENABLED && this .isSet (index ) == 0 ) {
160- holder .isSet = 0 ;
160+ final ArrowBuf dataBuffer = getUnderlyingVector ().getDataBuffer ();
161+ final long start = (long ) index * UUID_BYTE_WIDTH ;
162+ final long next = start + Long .BYTES ;
163+ // UUIDs are stored in big-endian byte order in Arrow buffers.
164+ // ArrowBuf.getLong() reads in native byte order, so we need to reverse bytes on LE systems.
165+ if (LITTLE_ENDIAN ) {
166+ holder .mostSigBits = Long .reverseBytes (dataBuffer .getLong (start ));
167+ holder .leastSigBits = Long .reverseBytes (dataBuffer .getLong (next ));
161168 } else {
162- holder .isSet = 1 ;
163- final ByteBuffer bb = ByteBuffer .wrap (getUnderlyingVector ().getObject (index ));
164- holder .mostSigBits = bb .getLong ();
165- holder .leastSigBits = bb .getLong ();
169+ holder .mostSigBits = dataBuffer .getLong (start );
170+ holder .leastSigBits = dataBuffer .getLong (next );
166171 }
167172 }
168173
@@ -178,9 +183,17 @@ public void get(int index, NullableUuidHolder holder) {
178183 holder .isSet = 0 ;
179184 } else {
180185 holder .isSet = 1 ;
181- final ByteBuffer bb = ByteBuffer .wrap (getUnderlyingVector ().getObject (index ));
182- holder .mostSigBits = bb .getLong ();
183- holder .leastSigBits = bb .getLong ();
186+ final ArrowBuf dataBuffer = getUnderlyingVector ().getDataBuffer ();
187+ final long offset = (long ) index * UUID_BYTE_WIDTH ;
188+ // UUIDs are stored in big-endian byte order in Arrow buffers.
189+ // ArrowBuf.getLong() reads in native byte order, so we need to reverse bytes on LE systems.
190+ if (LITTLE_ENDIAN ) {
191+ holder .mostSigBits = Long .reverseBytes (dataBuffer .getLong (offset ));
192+ holder .leastSigBits = Long .reverseBytes (dataBuffer .getLong (offset + Long .BYTES ));
193+ } else {
194+ holder .mostSigBits = dataBuffer .getLong (offset );
195+ holder .leastSigBits = dataBuffer .getLong (offset + Long .BYTES );
196+ }
184197 }
185198 }
186199
@@ -244,8 +257,8 @@ public void set(int index, ArrowBuf source, int sourceOffset) {
244257
245258 BitVectorHelper .setBit (getUnderlyingVector ().getValidityBuffer (), index );
246259 getUnderlyingVector ()
247- .getDataBuffer ()
248- .setBytes ((long ) index * UUID_BYTE_WIDTH , source , sourceOffset , UUID_BYTE_WIDTH );
260+ .getDataBuffer ()
261+ .setBytes ((long ) index * UUID_BYTE_WIDTH , source , sourceOffset , UUID_BYTE_WIDTH );
249262 }
250263
251264 /**
0 commit comments