vibhatha commented on code in PR #43637:
URL: https://github.com/apache/arrow/pull/43637#discussion_r1714763416


##########
java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java:
##########
@@ -452,6 +450,163 @@ public <OUT, IN> OUT accept(VectorVisitor<OUT, IN> 
visitor, IN value) {
     throw new UnsupportedOperationException();
   }
 
+  private class TransferImpl implements TransferPair {
+
+    LargeListViewVector to;
+    TransferPair dataTransferPair;
+
+    public TransferImpl(String name, BufferAllocator allocator, CallBack 
callBack) {
+      this(new LargeListViewVector(name, allocator, field.getFieldType(), 
callBack));
+    }
+
+    public TransferImpl(Field field, BufferAllocator allocator, CallBack 
callBack) {
+      this(new LargeListViewVector(field, allocator, callBack));
+    }
+
+    public TransferImpl(LargeListViewVector to) {
+      this.to = to;
+      to.addOrGetVector(vector.getField().getFieldType());
+      if (to.getDataVector() instanceof ZeroVector) {
+        to.addOrGetVector(vector.getField().getFieldType());
+      }
+      dataTransferPair = getDataVector().makeTransferPair(to.getDataVector());
+    }
+
+    @Override
+    public void transfer() {
+      to.clear();
+      dataTransferPair.transfer();
+      to.validityBuffer = transferBuffer(validityBuffer, to.allocator);
+      to.offsetBuffer = transferBuffer(offsetBuffer, to.allocator);
+      to.sizeBuffer = transferBuffer(sizeBuffer, to.allocator);
+      if (valueCount > 0) {
+        to.setValueCount(valueCount);
+      }
+      clear();
+    }
+
+    @Override
+    public void splitAndTransfer(int startIndex, int length) {
+      Preconditions.checkArgument(
+          startIndex >= 0 && length >= 0 && startIndex + length <= valueCount,
+          "Invalid parameters startIndex: %s, length: %s for valueCount: %s",
+          startIndex,
+          length,
+          valueCount);
+      to.clear();
+      if (length > 0) {
+        // we have to scan by index since there are out-of-order offsets
+        to.offsetBuffer = to.allocateBuffers((long) length * OFFSET_WIDTH);
+        to.sizeBuffer = to.allocateBuffers((long) length * SIZE_WIDTH);
+
+        /* splitAndTransfer the size buffer */
+        int maxOffsetAndSizeSum = -1;
+        int minOffsetValue = -1;
+        for (int i = 0; i < length; i++) {
+          final int offsetValue = offsetBuffer.getInt((long) (startIndex + i) 
* OFFSET_WIDTH);
+          final int sizeValue = sizeBuffer.getInt((long) (startIndex + i) * 
SIZE_WIDTH);
+          to.sizeBuffer.setInt((long) i * SIZE_WIDTH, sizeValue);
+          if (maxOffsetAndSizeSum < offsetValue + sizeValue) {
+            maxOffsetAndSizeSum = offsetValue + sizeValue;
+          }
+          if (minOffsetValue == -1 || minOffsetValue > offsetValue) {

Review Comment:
   Right, I understand. I will update accordingly. Also we need to fix this 
logic across all the vectors. I am planning to make a follow up PR to make this 
component a util. We discussed this @lidavidm in a prior PR.  



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to