toddfarmer commented on code in PR #207:
URL: https://github.com/apache/arrow-cookbook/pull/207#discussion_r872745979


##########
java/source/dataset.rst:
##########
@@ -224,11 +240,19 @@ Consider that we have these files: data1: 3 rows, data2: 
3 rows and data3: 250 r
         scanner.scan().forEach(scanTask-> {
             VectorLoader loader = new VectorLoader(vsr);
             final int[] count = {1};
-            scanTask.execute().forEachRemaining(arrowRecordBatch -> {
-                loader.load(arrowRecordBatch);
-                System.out.println("Batch: " + count[0]++ + ", RowCount: " + 
vsr.getRowCount());
-                arrowRecordBatch.close();
-            });
+            try(ArrowReader reader = scanTask.execute()){
+                while (reader.loadNextBatch()) {
+                    try(VectorSchemaRoot root = reader.getVectorSchemaRoot()) {

Review Comment:
   ```suggestion
                       try (VectorSchemaRoot root = 
reader.getVectorSchemaRoot()) {
   ```



##########
java/source/dataset.rst:
##########
@@ -275,11 +302,19 @@ In case we need to project only certain columns we could 
configure ScanOptions w
     ){
         scanner.scan().forEach(scanTask-> {
             VectorLoader loader = new VectorLoader(vsr);
-            scanTask.execute().forEachRemaining(arrowRecordBatch -> {
-                loader.load(arrowRecordBatch);
-                System.out.print(vsr.contentToTSVString());
-                arrowRecordBatch.close();
-            });
+            try(ArrowReader reader = scanTask.execute()){
+                while (reader.loadNextBatch()) {
+                    try(VectorSchemaRoot root = reader.getVectorSchemaRoot()) {

Review Comment:
   ```suggestion
                       try (VectorSchemaRoot root = 
reader.getVectorSchemaRoot()) {
   ```



##########
java/source/dataset.rst:
##########
@@ -224,11 +240,19 @@ Consider that we have these files: data1: 3 rows, data2: 
3 rows and data3: 250 r
         scanner.scan().forEach(scanTask-> {
             VectorLoader loader = new VectorLoader(vsr);
             final int[] count = {1};
-            scanTask.execute().forEachRemaining(arrowRecordBatch -> {
-                loader.load(arrowRecordBatch);
-                System.out.println("Batch: " + count[0]++ + ", RowCount: " + 
vsr.getRowCount());
-                arrowRecordBatch.close();
-            });
+            try(ArrowReader reader = scanTask.execute()){
+                while (reader.loadNextBatch()) {
+                    try(VectorSchemaRoot root = reader.getVectorSchemaRoot()) {
+                        final VectorUnloader unloader = new 
VectorUnloader(root);
+                        try(ArrowRecordBatch arrowRecordBatch = 
unloader.getRecordBatch()){

Review Comment:
   ```suggestion
                           try (ArrowRecordBatch arrowRecordBatch = 
unloader.getRecordBatch()) {
   ```



##########
java/source/dataset.rst:
##########
@@ -275,11 +302,19 @@ In case we need to project only certain columns we could 
configure ScanOptions w
     ){
         scanner.scan().forEach(scanTask-> {
             VectorLoader loader = new VectorLoader(vsr);
-            scanTask.execute().forEachRemaining(arrowRecordBatch -> {
-                loader.load(arrowRecordBatch);
-                System.out.print(vsr.contentToTSVString());
-                arrowRecordBatch.close();
-            });
+            try(ArrowReader reader = scanTask.execute()){
+                while (reader.loadNextBatch()) {
+                    try(VectorSchemaRoot root = reader.getVectorSchemaRoot()) {
+                        final VectorUnloader unloader = new 
VectorUnloader(root);
+                        try(ArrowRecordBatch arrowRecordBatch = 
unloader.getRecordBatch()){

Review Comment:
   ```suggestion
                           try (ArrowRecordBatch arrowRecordBatch = 
unloader.getRecordBatch()) {
   ```



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