4848 * UUID value = vector.getObject(0);
4949 * }</pre>
5050 *
51- * @see {@link UuidType}
52- * @see {@link UuidHolder}
53- * @see {@link NullableUuidHolder}
51+ * @see UuidType
52+ * @see UuidHolder
53+ * @see NullableUuidHolder
5454 */
5555public class UuidVector extends ExtensionTypeVector <FixedSizeBinaryVector >
5656 implements ValueIterableVector <UUID >, FixedWidthVector , FixedSizeExtensionType {
5757 private final Field field ;
58+
59+ /** The fixed byte width of UUID values (16 bytes). */
5860 public static final int TYPE_WIDTH = UUID_BYTE_WIDTH ;
5961
62+ /**
63+ * Constructs a UUID vector with the given name, allocator, and underlying vector.
64+ *
65+ * @param name the name of the vector
66+ * @param allocator the buffer allocator
67+ * @param underlyingVector the underlying FixedSizeBinaryVector for storage
68+ */
6069 public UuidVector (
6170 String name , BufferAllocator allocator , FixedSizeBinaryVector underlyingVector ) {
6271 super (name , allocator , underlyingVector );
6372 this .field = new Field (name , FieldType .nullable (new UuidType ()), null );
6473 }
6574
75+ /**
76+ * Constructs a UUID vector with the given name, field type, allocator, and underlying vector.
77+ *
78+ * @param name the name of the vector
79+ * @param fieldType the field type (should contain UuidType)
80+ * @param allocator the buffer allocator
81+ * @param underlyingVector the underlying FixedSizeBinaryVector for storage
82+ */
6683 public UuidVector (
6784 String name ,
6885 FieldType fieldType ,
@@ -72,11 +89,25 @@ public UuidVector(
7289 this .field = new Field (name , fieldType , null );
7390 }
7491
92+ /**
93+ * Constructs a UUID vector with the given name and allocator.
94+ *
95+ * <p>Creates a new underlying FixedSizeBinaryVector with 16-byte width.
96+ *
97+ * @param name the name of the vector
98+ * @param allocator the buffer allocator
99+ */
75100 public UuidVector (String name , BufferAllocator allocator ) {
76101 super (name , allocator , new FixedSizeBinaryVector (name , allocator , UUID_BYTE_WIDTH ));
77102 this .field = new Field (name , FieldType .nullable (new UuidType ()), null );
78103 }
79104
105+ /**
106+ * Constructs a UUID vector from a field and allocator.
107+ *
108+ * @param field the field definition (should contain UuidType)
109+ * @param allocator the buffer allocator
110+ */
80111 public UuidVector (Field field , BufferAllocator allocator ) {
81112 super (
82113 field .getName (),
@@ -104,10 +135,23 @@ public int hashCode(int index, ArrowBufHasher hasher) {
104135 return getUnderlyingVector ().hashCode (index , hasher );
105136 }
106137
138+ /**
139+ * Checks if the value at the given index is set (non-null).
140+ *
141+ * @param index the index to check
142+ * @return 1 if the value is set, 0 if null
143+ */
107144 public int isSet (int index ) {
108145 return getUnderlyingVector ().isSet (index );
109146 }
110147
148+ /**
149+ * Gets the UUID value at the given index as an ArrowBuf.
150+ *
151+ * @param index the index to retrieve
152+ * @return a buffer slice containing the 16-byte UUID
153+ * @throws IllegalStateException if the value at the index is null and null checking is enabled
154+ */
111155 public ArrowBuf get (int index ) throws IllegalStateException {
112156 if (NullCheckingForGet .NULL_CHECKING_ENABLED && this .isSet (index ) == 0 ) {
113157 throw new IllegalStateException ("Value at index is null" );
@@ -116,6 +160,12 @@ public ArrowBuf get(int index) throws IllegalStateException {
116160 }
117161 }
118162
163+ /**
164+ * Reads the UUID value at the given index into a NullableUuidHolder.
165+ *
166+ * @param index the index to read from
167+ * @param holder the holder to populate with the UUID data
168+ */
119169 public void get (int index , NullableUuidHolder holder ) {
120170 if (NullCheckingForGet .NULL_CHECKING_ENABLED && this .isSet (index ) == 0 ) {
121171 holder .isSet = 0 ;
@@ -125,15 +175,23 @@ public void get(int index, NullableUuidHolder holder) {
125175 }
126176 }
127177
178+ /**
179+ * Reads the UUID value at the given index into a UuidHolder.
180+ *
181+ * @param index the index to read from
182+ * @param holder the holder to populate with the UUID data
183+ */
128184 public void get (int index , UuidHolder holder ) {
129- if (NullCheckingForGet .NULL_CHECKING_ENABLED && this .isSet (index ) == 0 ) {
130- holder .isSet = 0 ;
131- } else {
132- holder .isSet = 1 ;
133- holder .buffer = getBufferSlicePostNullCheck (index );
134- }
185+ holder .isSet = 1 ;
186+ holder .buffer = getBufferSlicePostNullCheck (index );
135187 }
136188
189+ /**
190+ * Sets the UUID value at the given index.
191+ *
192+ * @param index the index to set
193+ * @param value the UUID value to set, or null to set a null value
194+ */
137195 public void set (int index , UUID value ) {
138196 if (value != null ) {
139197 set (index , UuidUtility .getBytesFromUUID (value ));
@@ -142,33 +200,77 @@ public void set(int index, UUID value) {
142200 }
143201 }
144202
203+ /**
204+ * Sets the UUID value at the given index from a UuidHolder.
205+ *
206+ * @param index the index to set
207+ * @param holder the holder containing the UUID data
208+ */
145209 public void set (int index , UuidHolder holder ) {
146210 this .set (index , holder .isSet , holder .buffer );
147211 }
148212
213+ /**
214+ * Sets the UUID value at the given index from a NullableUuidHolder.
215+ *
216+ * @param index the index to set
217+ * @param holder the holder containing the UUID data
218+ */
149219 public void set (int index , NullableUuidHolder holder ) {
150220 this .set (index , holder .isSet , holder .buffer );
151221 }
152222
223+ /**
224+ * Sets the UUID value at the given index with explicit null flag.
225+ *
226+ * @param index the index to set
227+ * @param isSet 1 if the value is set, 0 if null
228+ * @param buffer the buffer containing the 16-byte UUID data
229+ */
153230 public void set (int index , int isSet , ArrowBuf buffer ) {
154231 getUnderlyingVector ().set (index , isSet , buffer );
155232 }
156233
234+ /**
235+ * Sets the UUID value at the given index from an ArrowBuf.
236+ *
237+ * @param index the index to set
238+ * @param value the buffer containing the 16-byte UUID data
239+ */
157240 public void set (int index , ArrowBuf value ) {
158241 getUnderlyingVector ().set (index , value );
159242 }
160243
244+ /**
245+ * Sets the UUID value at the given index by copying from a source buffer.
246+ *
247+ * @param index the index to set
248+ * @param source the source buffer to copy from
249+ * @param sourceOffset the offset in the source buffer where the UUID data starts
250+ */
161251 public void set (int index , ArrowBuf source , int sourceOffset ) {
162252 // Copy bytes from source buffer to target vector data buffer
163253 ArrowBuf dataBuffer = getUnderlyingVector ().getDataBuffer ();
164254 dataBuffer .setBytes ((long ) index * UUID_BYTE_WIDTH , source , sourceOffset , UUID_BYTE_WIDTH );
165255 getUnderlyingVector ().setIndexDefined (index );
166256 }
167257
258+ /**
259+ * Sets the UUID value at the given index from a byte array.
260+ *
261+ * @param index the index to set
262+ * @param value the 16-byte array containing the UUID data
263+ */
168264 public void set (int index , byte [] value ) {
169265 getUnderlyingVector ().set (index , value );
170266 }
171267
268+ /**
269+ * Sets the UUID value at the given index, expanding capacity if needed.
270+ *
271+ * @param index the index to set
272+ * @param value the UUID value to set, or null to set a null value
273+ */
172274 public void setSafe (int index , UUID value ) {
173275 if (value != null ) {
174276 setSafe (index , UuidUtility .getBytesFromUUID (value ));
@@ -177,6 +279,12 @@ public void setSafe(int index, UUID value) {
177279 }
178280 }
179281
282+ /**
283+ * Sets the UUID value at the given index from a NullableUuidHolder, expanding capacity if needed.
284+ *
285+ * @param index the index to set
286+ * @param holder the holder containing the UUID data, or null to set a null value
287+ */
180288 public void setSafe (int index , NullableUuidHolder holder ) {
181289 if (holder != null ) {
182290 getUnderlyingVector ().setSafe (index , holder .isSet , holder .buffer );
@@ -185,6 +293,12 @@ public void setSafe(int index, NullableUuidHolder holder) {
185293 }
186294 }
187295
296+ /**
297+ * Sets the UUID value at the given index from a UuidHolder, expanding capacity if needed.
298+ *
299+ * @param index the index to set
300+ * @param holder the holder containing the UUID data, or null to set a null value
301+ */
188302 public void setSafe (int index , UuidHolder holder ) {
189303 if (holder != null ) {
190304 getUnderlyingVector ().setSafe (index , holder .isSet , holder .buffer );
@@ -193,20 +307,27 @@ public void setSafe(int index, UuidHolder holder) {
193307 }
194308 }
195309
310+ /**
311+ * Sets the UUID value at the given index from a byte array, expanding capacity if needed.
312+ *
313+ * @param index the index to set
314+ * @param value the 16-byte array containing the UUID data
315+ */
196316 public void setSafe (int index , byte [] value ) {
197317 getUnderlyingVector ().setIndexDefined (index );
198318 getUnderlyingVector ().setSafe (index , value );
199319 }
200320
321+ /**
322+ * Sets the UUID value at the given index from an ArrowBuf, expanding capacity if needed.
323+ *
324+ * @param index the index to set
325+ * @param value the buffer containing the 16-byte UUID data
326+ */
201327 public void setSafe (int index , ArrowBuf value ) {
202328 getUnderlyingVector ().setSafe (index , value );
203329 }
204330
205- @ Override
206- public int getTypeWidth () {
207- return UUID_BYTE_WIDTH ;
208- }
209-
210331 @ Override
211332 public void copyFrom (int fromIndex , int thisIndex , ValueVector from ) {
212333 getUnderlyingVector ()
@@ -285,34 +406,74 @@ private ArrowBuf getBufferSlicePostNullCheck(int index) {
285406 .slice ((long ) index * UUID_BYTE_WIDTH , UUID_BYTE_WIDTH );
286407 }
287408
409+ @ Override
410+ public int getTypeWidth () {
411+ return getUnderlyingVector ().getTypeWidth ();
412+ }
413+
288414 /** {@link TransferPair} for {@link UuidVector}. */
289415 public class TransferImpl implements TransferPair {
290416 UuidVector to ;
291417
418+ /**
419+ * Constructs a transfer pair with the given target vector.
420+ *
421+ * @param to the target UUID vector
422+ */
292423 public TransferImpl (UuidVector to ) {
293424 this .to = to ;
294425 }
295426
427+ /**
428+ * Constructs a transfer pair, creating a new target vector from the field and allocator.
429+ *
430+ * @param field the field definition for the target vector
431+ * @param allocator the buffer allocator for the target vector
432+ */
296433 public TransferImpl (Field field , BufferAllocator allocator ) {
297434 this .to = new UuidVector (field , allocator );
298435 }
299436
437+ /**
438+ * Constructs a transfer pair, creating a new target vector with the given name and allocator.
439+ *
440+ * @param ref the name for the target vector
441+ * @param allocator the buffer allocator for the target vector
442+ */
300443 public TransferImpl (String ref , BufferAllocator allocator ) {
301444 this .to = new UuidVector (ref , allocator );
302445 }
303446
447+ /**
448+ * Gets the target vector of this transfer pair.
449+ *
450+ * @return the target UUID vector
451+ */
304452 public UuidVector getTo () {
305453 return this .to ;
306454 }
307455
456+ /** Transfers ownership of data from the source vector to the target vector. */
308457 public void transfer () {
309458 getUnderlyingVector ().transferTo (to .getUnderlyingVector ());
310459 }
311460
461+ /**
462+ * Splits and transfers a range of values from the source vector to the target vector.
463+ *
464+ * @param startIndex the starting index in the source vector
465+ * @param length the number of values to transfer
466+ */
312467 public void splitAndTransfer (int startIndex , int length ) {
313468 getUnderlyingVector ().splitAndTransferTo (startIndex , length , to .getUnderlyingVector ());
314469 }
315470
471+ /**
472+ * Copies a value from the source vector to the target vector, expanding capacity if needed.
473+ *
474+ * @param fromIndex the index in the source vector
475+ * @param toIndex the index in the target vector
476+ */
316477 public void copyValueSafe (int fromIndex , int toIndex ) {
317478 to .copyFromSafe (fromIndex , toIndex , (ValueVector ) UuidVector .this );
318479 }
0 commit comments