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

Method Insert

cpp/src/arrow/json/chunked_builder.cc:291–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289 }
290
291 void Insert(int64_t block_index, const std::shared_ptr<Field>&,
292 const std::shared_ptr<Array>& unconverted) override {
293 std::unique_lock<std::mutex> lock(mutex_);
294
295 if (null_bitmap_chunks_.size() <= static_cast<size_t>(block_index)) {
296 null_bitmap_chunks_.resize(static_cast<size_t>(block_index) + 1, nullptr);
297 chunk_lengths_.resize(null_bitmap_chunks_.size(), -1);
298 child_absent_.resize(null_bitmap_chunks_.size(), std::vector<bool>(0));
299 }
300 null_bitmap_chunks_[block_index] = unconverted->null_bitmap();
301 chunk_lengths_[block_index] = unconverted->length();
302
303 if (unconverted->type_id() == Type::NA) {
304 auto maybe_buffer = AllocateBitmap(unconverted->length(), pool_);
305 if (maybe_buffer.ok()) {
306 null_bitmap_chunks_[block_index] = *std::move(maybe_buffer);
307 std::memset(null_bitmap_chunks_[block_index]->mutable_data(), 0,
308 null_bitmap_chunks_[block_index]->size());
309 } else {
310 Status st = maybe_buffer.status();
311 task_group_->Append([st] { return st; });
312 }
313
314 // absent fields will be inserted at Finish
315 return;
316 }
317
318 const auto& struct_array = checked_cast<const StructArray&>(*unconverted);
319 if (promotion_graph_ == nullptr) {
320 // If unexpected fields are ignored or result in an error then all parsers will emit
321 // columns exclusively in the ordering specified in ParseOptions::explicit_schema,
322 // so child_builders_ is immutable and no associative lookup is necessary.
323 for (int i = 0; i < unconverted->num_fields(); ++i) {
324 child_builders_[i]->Insert(block_index, unconverted->type()->field(i),
325 struct_array.field(i));
326 }
327 } else {
328 auto st = InsertChildren(block_index, struct_array);
329 if (!st.ok()) {
330 return task_group_->Append([st] { return st; });
331 }
332 }
333 }
334
335 Status Finish(std::shared_ptr<ChunkedArray>* out) override {
336 RETURN_NOT_OK(task_group_->Finish());

Callers

nothing calls this directly

Calls 13

AllocateBitmapFunction · 0.85
resizeMethod · 0.80
sizeMethod · 0.45
lengthMethod · 0.45
type_idMethod · 0.45
okMethod · 0.45
mutable_dataMethod · 0.45
statusMethod · 0.45
AppendMethod · 0.45
num_fieldsMethod · 0.45
InsertMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected