You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/24 14:37:07 UTC

[GitHub] [arrow] lidavidm commented on a diff in pull request #14389: ARROW-18014: [Java] Implement copy functions for vectors and Table

lidavidm commented on code in PR #14389:
URL: https://github.com/apache/arrow/pull/14389#discussion_r1003385474


##########
java/vector/src/main/java/org/apache/arrow/vector/table/BaseTable.java:
##########
@@ -266,6 +270,48 @@ FieldVector getVector(int columnIndex) {
     return fieldVectors.get(columnIndex);
   }
 
+
+  /**
+   * Returns a copy of the vector with the given name, or throws IllegalArgumentException if the name is not found.
+   * Names are case-sensitive.
+   *
+   * @param columnName The name of the vector to copy
+   * @return A copy of the Vector with the given name
+   * @throws IllegalArgumentException if the name is not the name of a vector in the table.

Review Comment:
   nit: the exception class is different from what's actually thrown



##########
java/vector/src/test/java/org/apache/arrow/vector/table/BaseTableTest.java:
##########
@@ -180,6 +180,47 @@ void testGetVector() {
     }
   }
 
+  @Test
+  void getVectorCopyByIndex() {
+    List<FieldVector> vectorList = twoIntColumns(allocator);
+    List<FieldVector> vectorList2 = twoIntColumns(allocator);
+    try (Table t = new Table(vectorList)) {
+      // compare value by value
+      for (int vIdx = 0; vIdx < vectorList.size(); vIdx++) {
+        IntVector original = (IntVector) vectorList2.get(vIdx);
+        IntVector copy = (IntVector) t.getVectorCopy(vIdx);
+        assertNotNull(copy);
+        assertEquals(2, copy.getValueCount());
+        assertEquals(0, copy.getNullCount());
+        for (int i = 0; i < t.getRowCount(); i++) {
+          assertEquals(original.getObject(i), copy.getObject(i));
+        }

Review Comment:
   not necessarily an issue for this PR, but there is a VectorValueComparator and perhaps it would be good to integrate it as FieldVector#equals if it isn't already



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org