| 113 | }; |
| 114 | |
| 115 | class OrcScanTaskIterator { |
| 116 | public: |
| 117 | static Result<Iterator<std::shared_ptr<OrcScanTask>>> Make( |
| 118 | std::shared_ptr<ScanOptions> options, std::shared_ptr<FileFragment> fragment) { |
| 119 | return Iterator<std::shared_ptr<OrcScanTask>>( |
| 120 | OrcScanTaskIterator(std::move(options), std::move(fragment))); |
| 121 | } |
| 122 | |
| 123 | Result<std::shared_ptr<OrcScanTask>> Next() { |
| 124 | if (once_) { |
| 125 | // Iteration is done. |
| 126 | return nullptr; |
| 127 | } |
| 128 | |
| 129 | once_ = true; |
| 130 | return std::make_shared<OrcScanTask>(fragment_, options_); |
| 131 | } |
| 132 | |
| 133 | private: |
| 134 | OrcScanTaskIterator(std::shared_ptr<ScanOptions> options, |
| 135 | std::shared_ptr<FileFragment> fragment) |
| 136 | : options_(std::move(options)), fragment_(std::move(fragment)) {} |
| 137 | |
| 138 | bool once_ = false; |
| 139 | std::shared_ptr<ScanOptions> options_; |
| 140 | std::shared_ptr<FileFragment> fragment_; |
| 141 | }; |
| 142 | |
| 143 | } // namespace |
| 144 | |