Skip to content

Commit

Permalink
only set zero if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
ViggoC committed Nov 5, 2024
1 parent 76f3fc1 commit 30e5954
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1367,11 +1367,13 @@ protected ArrowBuf allocateOrGetLastDataBuffer(int length) {
protected final void setBytes(int index, byte[] value, int start, int length) {
int writePosition = index * ELEMENT_SIZE;

// to clear the memory segment of view being written to
// this is helpful in case of overwriting the value
viewBuffer.setZero(writePosition, ELEMENT_SIZE);

if (length <= INLINE_SIZE) {
// to clear the memory segment of view being written to
// if it has been set
if (viewBuffer.getLong(writePosition) != 0 || viewBuffer.getLong(writePosition + 8) != 0) {
viewBuffer.setZero(writePosition, ELEMENT_SIZE);
}

// allocate inline buffer
// set length
viewBuffer.setInt(writePosition, length);
Expand Down Expand Up @@ -1411,11 +1413,13 @@ protected final void setBytes(int index, byte[] value, int start, int length) {
protected final void setBytes(int index, ArrowBuf valueBuf, int start, int length) {
int writePosition = index * ELEMENT_SIZE;

// to clear the memory segment of view being written to
// this is helpful in case of overwriting the value
viewBuffer.setZero(writePosition, ELEMENT_SIZE);

if (length <= INLINE_SIZE) {
// to clear the memory segment of view being written to
// if it has been set
if (viewBuffer.getLong(writePosition) != 0 || viewBuffer.getLong(writePosition + 8) != 0) {
viewBuffer.setZero(writePosition, ELEMENT_SIZE);
}

// allocate inline buffer
// set length
viewBuffer.setInt(writePosition, length);
Expand Down

0 comments on commit 30e5954

Please sign in to comment.