MCPcopy Create free account
hub / github.com/apache/arrow / operator()

Method operator()

cpp/src/arrow/json/reader.cc:185–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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_;

Callers

nothing calls this directly

Calls 6

TransformFinishClass · 0.85
TransformSkipClass · 0.85
TransformYieldFunction · 0.85
ProcessFinalMethod · 0.80
ProcessWithPartialMethod · 0.80
ProcessMethod · 0.45

Tested by

no test coverage detected