| 183 | |
| 184 | private: |
| 185 | Result<TransformFlow<ChunkedBlock>> operator()(std::shared_ptr<Buffer> next_buffer) { |
| 186 | if (!buffer_) { |
| 187 | if (ARROW_PREDICT_TRUE(!next_buffer)) { |
| 188 | DCHECK_EQ(partial_, nullptr) << "Logic error: non-null partial with null buffer"; |
| 189 | return TransformFinish(); |
| 190 | } |
| 191 | partial_ = std::make_shared<Buffer>(""); |
| 192 | buffer_ = std::move(next_buffer); |
| 193 | return TransformSkip(); |
| 194 | } |
| 195 | DCHECK_NE(partial_, nullptr); |
| 196 | |
| 197 | std::shared_ptr<Buffer> whole, completion, next_partial; |
| 198 | if (!next_buffer) { |
| 199 | // End of file reached => compute completion from penultimate block |
| 200 | RETURN_NOT_OK(chunker_->ProcessFinal(partial_, buffer_, &completion, &whole)); |
| 201 | } else { |
| 202 | std::shared_ptr<Buffer> starts_with_whole; |
| 203 | // Get completion of partial from previous block. |
| 204 | RETURN_NOT_OK(chunker_->ProcessWithPartial(partial_, buffer_, &completion, |
| 205 | &starts_with_whole)); |
| 206 | // Get all whole objects entirely inside the current buffer |
| 207 | RETURN_NOT_OK(chunker_->Process(starts_with_whole, &whole, &next_partial)); |
| 208 | } |
| 209 | |
| 210 | buffer_ = std::move(next_buffer); |
| 211 | return TransformYield(ChunkedBlock{std::exchange(partial_, next_partial), |
| 212 | std::move(completion), std::move(whole), |
| 213 | index_++}); |
| 214 | } |
| 215 | |
| 216 | std::unique_ptr<Chunker> chunker_; |
| 217 | std::shared_ptr<Buffer> partial_; |
nothing calls this directly
no test coverage detected