| 77 | namespace { |
| 78 | |
| 79 | class InputStreamBlockIterator { |
| 80 | public: |
| 81 | InputStreamBlockIterator(std::shared_ptr<InputStream> stream, int64_t block_size) |
| 82 | : stream_(std::move(stream)), block_size_(block_size) {} |
| 83 | |
| 84 | Result<std::shared_ptr<Buffer>> Next() { |
| 85 | if (done_) { |
| 86 | return nullptr; |
| 87 | } |
| 88 | |
| 89 | ARROW_ASSIGN_OR_RAISE(auto out, stream_->Read(block_size_)); |
| 90 | |
| 91 | if (out->size() == 0) { |
| 92 | done_ = true; |
| 93 | stream_.reset(); |
| 94 | out.reset(); |
| 95 | } |
| 96 | |
| 97 | return out; |
| 98 | } |
| 99 | |
| 100 | protected: |
| 101 | std::shared_ptr<InputStream> stream_; |
| 102 | int64_t block_size_; |
| 103 | bool done_ = false; |
| 104 | }; |
| 105 | |
| 106 | } // namespace |
| 107 |
no outgoing calls
no test coverage detected