Skip to content

Commit 86887d5

Browse files
committed
created top level allocateValidityBuffer function
1 parent 4123e3b commit 86887d5

File tree

10 files changed

+19
-41
lines changed

10 files changed

+19
-41
lines changed

vector/src/main/java/org/apache/arrow/vector/BaseFixedWidthVector.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ private void allocateBytes(int valueCount) {
342342
*/
343343
@Override
344344
protected void allocateValidityBuffer(final long validityBufferSize) {
345-
validityBuffer = allocator.buffer(validityBufferSize);
346-
validityBuffer.readerIndex(0);
345+
super.allocateValidityBuffer(validityBufferSize);
347346
refreshValueCapacity();
348347
}
349348

vector/src/main/java/org/apache/arrow/vector/BaseLargeVariableWidthVector.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,7 @@ private ArrowBuf allocateOffsetBuffer(final long size) {
501501
/* allocate validity buffer */
502502
@Override
503503
protected void allocateValidityBuffer(final long size) {
504-
validityBuffer = allocator.buffer(size);
505-
validityBuffer.readerIndex(0);
506-
initValidityBuffer();
504+
super.allocateValidityBuffer(size);
507505
}
508506

509507
/**

vector/src/main/java/org/apache/arrow/vector/BaseValueVector.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,13 @@ protected void copyValidityBuffer(int startIndex, int length, BaseValueVector ta
355355
}
356356

357357
/**
358-
* Allocate new validity buffer for when the bytes need to be copied over
358+
* Allocate new validity buffer for when the bytes need to be copied over.
359359
*
360360
* @param byteSizeTarget desired size of the buffer
361361
*/
362-
protected void allocateValidityBuffer(final long byteSizeTarget) {
363-
throw new UnsupportedOperationException();
362+
protected void allocateValidityBuffer(long byteSizeTarget) {
363+
validityBuffer = allocator.buffer(byteSizeTarget);
364+
validityBuffer.readerIndex(0);
365+
validityBuffer.setZero(0, validityBuffer.capacity());
364366
}
365367
}

vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,7 @@ private ArrowBuf allocateOffsetBuffer(final long size) {
519519
/* allocate validity buffer */
520520
@Override
521521
protected void allocateValidityBuffer(final long size) {
522-
final int curSize = (int) size;
523-
validityBuffer = allocator.buffer(curSize);
524-
validityBuffer.readerIndex(0);
525-
initValidityBuffer();
522+
super.allocateValidityBuffer(size);
526523
}
527524

528525
/**

vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthViewVector.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,10 +848,7 @@ public void splitAndTransferTo(int startIndex, int length, BaseVariableWidthView
848848
/* allocate validity buffer */
849849
@Override
850850
protected void allocateValidityBuffer(final long size) {
851-
final int curSize = (int) size;
852-
validityBuffer = allocator.buffer(curSize);
853-
validityBuffer.readerIndex(0);
854-
initValidityBuffer();
851+
super.allocateValidityBuffer(size);
855852
}
856853

857854
@Override

vector/src/main/java/org/apache/arrow/vector/complex/FixedSizeListVector.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,8 @@ public boolean allocateNewSafe() {
247247

248248
@Override
249249
protected void allocateValidityBuffer(final long size) {
250-
final int curSize = (int) size;
251-
validityBuffer = allocator.buffer(curSize);
252-
validityBuffer.readerIndex(0);
253-
validityAllocationSizeInBytes = curSize;
254-
validityBuffer.setZero(0, validityBuffer.capacity());
250+
super.allocateValidityBuffer(size);
251+
validityAllocationSizeInBytes = (int) size;
255252
}
256253

257254
@Override

vector/src/main/java/org/apache/arrow/vector/complex/LargeListVector.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,8 @@ public boolean allocateNewSafe() {
374374

375375
@Override
376376
protected void allocateValidityBuffer(final long size) {
377-
final int curSize = (int) size;
378-
validityBuffer = allocator.buffer(curSize);
379-
validityBuffer.readerIndex(0);
380-
validityAllocationSizeInBytes = curSize;
381-
validityBuffer.setZero(0, validityBuffer.capacity());
377+
super.allocateValidityBuffer(size);
378+
validityAllocationSizeInBytes = (int) size;
382379
}
383380

384381
protected ArrowBuf allocateOffsetBuffer(final long size) {

vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,8 @@ public boolean allocateNewSafe() {
285285

286286
@Override
287287
protected void allocateValidityBuffer(final long size) {
288-
final int curSize = (int) size;
289-
validityBuffer = allocator.buffer(curSize);
290-
validityBuffer.readerIndex(0);
291-
validityAllocationSizeInBytes = curSize;
292-
validityBuffer.setZero(0, validityBuffer.capacity());
288+
super.allocateValidityBuffer(size);
289+
validityAllocationSizeInBytes = (int) size;
293290
}
294291

295292
@Override

vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,8 @@ public boolean allocateNewSafe() {
324324

325325
@Override
326326
protected void allocateValidityBuffer(final long size) {
327-
final int curSize = (int) size;
328-
validityBuffer = allocator.buffer(curSize);
329-
validityBuffer.readerIndex(0);
330-
validityAllocationSizeInBytes = curSize;
331-
validityBuffer.setZero(0, validityBuffer.capacity());
327+
super.allocateValidityBuffer(size);
328+
validityAllocationSizeInBytes = (int) size;
332329
}
333330

334331
/**

vector/src/main/java/org/apache/arrow/vector/complex/ListViewVector.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,8 @@ public boolean allocateNewSafe() {
284284

285285
@Override
286286
protected void allocateValidityBuffer(final long size) {
287-
final int curSize = (int) size;
288-
validityBuffer = allocator.buffer(curSize);
289-
validityBuffer.readerIndex(0);
290-
validityAllocationSizeInBytes = curSize;
291-
validityBuffer.setZero(0, validityBuffer.capacity());
287+
super.allocateValidityBuffer(size);
288+
validityAllocationSizeInBytes = (int) size;
292289
}
293290

294291
@Override

0 commit comments

Comments
 (0)