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/05/21 01:41:31 UTC

[GitHub] [arrow] westonpace commented on a diff in pull request #13205: ARROW-16515: [C++] Adding a Close method to RecordBatchReader

westonpace commented on code in PR #13205:
URL: https://github.com/apache/arrow/pull/13205#discussion_r878616768


##########
cpp/src/arrow/record_batch.h:
##########
@@ -243,6 +243,9 @@ class ARROW_EXPORT RecordBatchReader {
     return batch;
   }
 
+  /// \brief finalize reader
+  virtual Status Close() = 0;

Review Comment:
   Instead of making this pure virtual (`= 0`) can you make this virtual and give it an implementation?
   ```suggestion
     virtual Status Close() {
       return Status::OK();
     };
   ```



##########
cpp/src/arrow/dataset/scanner.cc:
##########
@@ -85,6 +85,8 @@ class ScannerRecordBatchReader : public RecordBatchReader {
     return Status::OK();
   }
 
+  Status Close() override { return Status::OK(); }

Review Comment:
   We should execute exec plans until they finish.  So this should look something like...
   ```
   Status Close() override {
     std::shared_ptr<RecordBatch> batch;
     RETURN_NOT_OK(ReadNext(&batch));
     while (batch != nullptr) {
       RETURN_NOT_OK(ReadNext(&batch));
     }
     return Status::OK();
   }
   ```



##########
cpp/src/arrow/compute/exec/exec_plan.cc:
##########
@@ -476,6 +476,8 @@ std::shared_ptr<RecordBatchReader> MakeGeneratorReader(
       return Status::OK();
     }
 
+    Status Close() override { return Status::OK(); }

Review Comment:
   This should read from the generator until the end is reached.



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