liyafan82 commented on a change in pull request #10983:
URL: https://github.com/apache/arrow/pull/10983#discussion_r702552897
##########
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:
I checked the code, and find the ternary logic is used twice. However,
the logic in the two places are the opposite:
1) In `initialize()`, a new vector schema root is created, if the resue flag
is enabled.
2) In `next()`, a new vector schema root is created, if the reuse flag is
diabled.
So there is no common logic here?
--
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]