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

Class RecordBatchReaderIterator

cpp/src/arrow/record_batch.h:379–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

beginFunction · 0.85
endFunction · 0.85

Calls 1

NextFunction · 0.70

Tested by

no test coverage detected