vvysotskyi commented on a change in pull request #1829: DRILL-7096: Develop 
vector for canonical Map<K,V>
URL: https://github.com/apache/drill/pull/1829#discussion_r317194371
 
 

 ##########
 File path: 
exec/vector/src/main/java/org/apache/drill/exec/vector/complex/BaseRepeatedValueVector.java
 ##########
 @@ -250,6 +251,54 @@ public void exchange(ValueVector other) {
     offsets.exchange(target.offsets);
   }
 
+  protected abstract class BaseRepeatedValueVectorTransferPair<T extends 
BaseRepeatedValueVector> implements TransferPair {
+
+    protected final T target;
+    protected final TransferPair[] children;
+
+    protected BaseRepeatedValueVectorTransferPair(T target) {
+      this.target = Preconditions.checkNotNull(target);
+      if (target.getDataVector() == DEFAULT_DATA_VECTOR) {
+        
target.addOrGetVector(VectorDescriptor.create(getDataVector().getField()));
+        target.getDataVector().allocateNew();
+      }
+      this.children = new TransferPair[] {
+          getOffsetVector().makeTransferPair(target.getOffsetVector()),
+          getDataVector().makeTransferPair(target.getDataVector())
+      };
+    }
+
+    @Override
+    public void transfer() {
+      for (TransferPair child : children) {
+        child.transfer();
+      }
+    }
+
+    @Override
+    public ValueVector getTo() {
+      return target;
+    }
+
+    @Override
+    public void splitAndTransfer(int startIndex, int length) {
+      target.allocateNew();
+      for (int i = 0; i < length; i++) {
+        copyValueSafe(startIndex + i, i);
+      }
+    }
+
+    protected void copyValueSafe(int destIndex, int start, int end) {
+      final TransferPair vectorTransfer = children[1];
+      int newIndex = target.getOffsetVector().getAccessor().get(destIndex);
+      //todo: make this a bulk copy.
 
 Review comment:
   ```suggestion
         // TODO: make this a bulk copy.
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to