scampi commented on a change in pull request #6402:

File path: 
@@ -740,10 +740,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();

Review comment:
       > If the testSplitAndTransfer tests were run with two child buffer 
allocators I think they would fail.
   @rymurr there was indeed a problem in that case where the sliced data was 
not transferred to the target allocator. See 
681327e22f6dbda71b78e408b9fee6a8af0040b0 for a test about that.
   > A clearer/more complete optimization would probably to simply read the 
initial starting offset at the index that we're slicing from and if that is 
zero, don't do the allocate/copy
   @jacques-n I have extended the condition to include also that case of 
empties/nulls. See 2e13c5239137e54b0cd128240e6a3d0895c0c36f

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

Reply via email to