emkornfield commented on a change in pull request #10983:
URL: https://github.com/apache/arrow/pull/10983#discussion_r700732345



##########
File path: 
java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/ArrowVectorIterator.java
##########
@@ -137,48 +139,46 @@ private VectorSchemaRoot createVectorSchemaRoot() {
 
   // Loads the next schema root or null if no more rows are available.
   private void load(VectorSchemaRoot root) throws SQLException {
-
-    for (int i = 1; i <= consumers.length; i++) {
-      consumers[i - 
1].resetValueVector(root.getVector(rsmd.getColumnLabel(i)));
+    for (int i = 0; i < consumers.length; i++) {
+      consumers[i].resetValueVector(root.getVector(i));
     }
 
     consumeData(root);
-
-    if (root.getRowCount() == 0) {
-      root.close();
-      nextBatch = null;
-    } else {
-      nextBatch = root;
-    }
   }
 
   @Override
   public boolean hasNext() {
-    return nextBatch != null;
+    try {
+      return !resultSet.isAfterLast();
+    } catch (SQLException e) {
+      throw new RuntimeException(e);
+    }
   }
 
   /**
-   * Gets the next vector. The user is responsible for freeing its resources.
+   * Gets the next vector.
+   * If {@link JdbcToArrowConfig#isReuseVectorSchemaRoot()} is false,
+   * the client is responsible for freeing its resources.
    */
   @Override
   public VectorSchemaRoot next() {
     Preconditions.checkArgument(hasNext());
-    VectorSchemaRoot returned = nextBatch;
     try {
-      load(createVectorSchemaRoot());
+      VectorSchemaRoot ret = config.isReuseVectorSchemaRoot() ? nextBatch : 
createVectorSchemaRoot();

Review comment:
       does it make sense to factor this out to a method that takes config? 
instead of repeating ternary logic in a few places?




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