MCPcopy Create free account
hub / github.com/apache/arrow / RecordBatchReaderIterator

Class RecordBatchReaderIterator

cpp/src/arrow/record_batch.h:384–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382 virtual DeviceAllocationType device_type() const { return DeviceAllocationType::kCPU; }
383
384 class RecordBatchReaderIterator {
385 public:
386 using iterator_category = std::input_iterator_tag;
387 using difference_type = std::ptrdiff_t;
388 using value_type = std::shared_ptr<RecordBatch>;
389 using pointer = const value_type*;
390 using reference = const value_type&;
391
392 RecordBatchReaderIterator() : batch_(RecordBatchEnd()), reader_(NULLPTR) {}
393
394 explicit RecordBatchReaderIterator(RecordBatchReader* reader)
395 : batch_(RecordBatchEnd()), reader_(reader) {
396 Next();
397 }
398
399 bool operator==(const RecordBatchReaderIterator& other) const {
400 return batch_ == other.batch_;
401 }
402
403 bool operator!=(const RecordBatchReaderIterator& other) const {
404 return !(*this == other);
405 }
406
407 Result<std::shared_ptr<RecordBatch>> operator*() {
408 ARROW_RETURN_NOT_OK(batch_);
409
410 return batch_;
411 }
412
413 RecordBatchReaderIterator& operator++() {
414 Next();
415 return *this;
416 }
417
418 RecordBatchReaderIterator operator++(int) {
419 RecordBatchReaderIterator tmp(*this);
420 Next();
421 return tmp;
422 }
423
424 private:
425 std::shared_ptr<RecordBatch> RecordBatchEnd() {
426 return std::shared_ptr<RecordBatch>(NULLPTR);
427 }
428
429 void Next() {
430 if (reader_ == NULLPTR) {
431 batch_ = RecordBatchEnd();
432 return;
433 }
434 batch_ = reader_->Next();
435 }
436
437 Result<std::shared_ptr<RecordBatch>> batch_;
438 RecordBatchReader* reader_;
439 };
440 /// \brief Return an iterator to the first record batch in the stream
441 RecordBatchReaderIterator begin() { return RecordBatchReaderIterator(this); }

Callers 2

beginFunction · 0.85
endFunction · 0.85

Calls 1

NextFunction · 0.70

Tested by

no test coverage detected