dhruv9vats commented on a change in pull request #11946:
URL: https://github.com/apache/arrow/pull/11946#discussion_r768639599
##########
File path: cpp/src/arrow/record_batch.h
##########
@@ -234,6 +234,53 @@ class ARROW_EXPORT RecordBatchReader {
return batch;
}
+ class RecordBatchReaderIterator {
+ public:
+ RecordBatchReaderIterator() : batch_(RecordBatchEnd()) {}
+
+ explicit RecordBatchReaderIterator(RecordBatchReader* reader)
+ : batch_(RecordBatchEnd()), reader_(reader) {
+ Next();
+ }
+
+ bool operator!=(const RecordBatchReaderIterator& other) const {
+ return batch_ != other.batch_;
+ }
+
+ Result<std::shared_ptr<RecordBatch>> operator*() {
+ ARROW_RETURN_NOT_OK(batch_.status());
+
+ auto batch = std::move(batch_);
+ batch_ = RecordBatchEnd();
+ return batch;
+ }
+
+ RecordBatchReaderIterator& operator++() {
+ Next();
+ return *this;
+ }
+
+ private:
+ std::shared_ptr<RecordBatch> RecordBatchEnd() {
+ return std::shared_ptr<RecordBatch>(NULLPTR);
Review comment:
This is what `IterationTraits<std::shared_ptr<RecordBatch>>::End()`
would have returned, but using it showed the error:
```
incomplete type 'arrow::IterationTraits<std::shared_ptr<arrow::RecordBatch>
>' used in nested name specifier
```
which seems due to the abstract nature of the class.
--
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]