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

Class DecodingOperator

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

Callable object for parsing/converting individual JSON blocks. The class itself can be called concurrently but reads from the `DecodeContext` aren't synchronized

Source from the content-addressed store, hash-verified

301// Callable object for parsing/converting individual JSON blocks. The class itself can be
302// called concurrently but reads from the `DecodeContext` aren't synchronized
303class DecodingOperator {
304 public:
305 explicit DecodingOperator(std::shared_ptr<const DecodeContext> context)
306 : context_(std::move(context)) {}
307
308 Result<DecodedBlock> operator()(const ChunkedBlock& block) const {
309 int64_t num_bytes;
310 ARROW_ASSIGN_OR_RAISE(auto unconverted, ParseBlock(block, context_->parse_options(),
311 context_->pool(), &num_bytes));
312
313 std::shared_ptr<ChunkedArrayBuilder> builder;
314 RETURN_NOT_OK(MakeChunkedArrayBuilder(TaskGroup::MakeSerial(), context_->pool(),
315 context_->promotion_graph(),
316 context_->conversion_type(), &builder));
317 builder->Insert(0, field("", unconverted->type()), unconverted);
318
319 std::shared_ptr<ChunkedArray> chunked;
320 RETURN_NOT_OK(builder->Finish(&chunked));
321 ARROW_ASSIGN_OR_RAISE(
322 auto batch, RecordBatch::FromStructArray(chunked->chunk(0), context_->pool()));
323
324 return DecodedBlock{std::move(batch), num_bytes};
325 }
326
327 private:
328 std::shared_ptr<const DecodeContext> context_;
329};
330
331// Reads from a source iterator, completes the subsequent decode task on the calling
332// thread. This is only really used for compatibility with the async pipeline when CPU

Callers 1

MakeAsyncMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected