Skip to content

Commit

Permalink
Merge pull request #1 from sirensolutions/issue-3023
Browse files Browse the repository at this point in the history
do not allocate a new offset buffer if the slice starts at 0 since th…
  • Loading branch information
scampi authored Feb 18, 2020
2 parents 225ebea + a2f4572 commit 5b13305
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,16 @@ private void splitAndTransferOffsetBuffer(int startIndex, int length, BaseVariab
final int start = offsetBuffer.getInt(startIndex * OFFSET_WIDTH);
final int end = offsetBuffer.getInt((startIndex + length) * OFFSET_WIDTH);
final int dataLength = end - start;
target.allocateOffsetBuffer((length + 1) * OFFSET_WIDTH);
for (int i = 0; i < length + 1; i++) {
final int relativeSourceOffset = offsetBuffer.getInt((startIndex + i) * OFFSET_WIDTH) - start;
target.offsetBuffer.setInt(i * OFFSET_WIDTH, relativeSourceOffset);

if (startIndex == 0) {
target.offsetBuffer = offsetBuffer.slice(0, (1 + length) * OFFSET_WIDTH);
target.offsetBuffer.getReferenceManager().retain();
} else {
target.allocateOffsetBuffer((length + 1) * OFFSET_WIDTH);
for (int i = 0; i < length + 1; i++) {
final int relativeSourceOffset = offsetBuffer.getInt((startIndex + i) * OFFSET_WIDTH) - start;
target.offsetBuffer.setInt(i * OFFSET_WIDTH, relativeSourceOffset);
}
}
final ArrowBuf slicedBuffer = valueBuffer.slice(start, dataLength);
target.valueBuffer = transferBuffer(slicedBuffer, target.allocator);
Expand Down

0 comments on commit 5b13305

Please sign in to comment.