Skip to content

Commit f91c665

Browse files
author
Yicong Huang
committed
doc: update comment
1 parent 1ec1198 commit f91c665

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,10 @@ private void setReaderAndWriterIndex() {
379379
validityBuffer.writerIndex(BitVectorHelper.getValidityBufferSizeFromCount(valueCount));
380380
valueBuffer.writerIndex(lastDataOffset);
381381
}
382-
// Per Arrow spec, offset buffer always has (valueCount + 1) entries including offset[0]=0.
383-
// This ensures IPC serialization includes the offset buffer even when valueCount is 0.
382+
// IPC serializer will determine readable bytes based on `readerIndex` and `writerIndex`.
383+
// Both are set to 0 means 0 bytes are written to the IPC stream which will crash IPC readers
384+
// in other libraries. According to Arrow spec, we should still output the offset buffer which
385+
// is [0].
384386
offsetBuffer.writerIndex((long) (valueCount + 1) * OFFSET_WIDTH);
385387
}
386388

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,10 @@ private void setReaderAndWriterIndex() {
395395
validityBuffer.writerIndex(BitVectorHelper.getValidityBufferSizeFromCount(valueCount));
396396
valueBuffer.writerIndex(lastDataOffset);
397397
}
398-
// Per Arrow spec, offset buffer always has (valueCount + 1) entries including offset[0]=0.
399-
// This ensures IPC serialization includes the offset buffer even when valueCount is 0.
398+
// IPC serializer will determine readable bytes based on `readerIndex` and `writerIndex`.
399+
// Both are set to 0 means 0 bytes are written to the IPC stream which will crash IPC readers
400+
// in other libraries. According to Arrow spec, we should still output the offset buffer which
401+
// is [0].
400402
offsetBuffer.writerIndex((long) (valueCount + 1) * OFFSET_WIDTH);
401403
}
402404

0 commit comments

Comments
 (0)