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

Method Init

cpp/src/arrow/json/from_string.cc:776–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

774 explicit UnionConverter(const std::shared_ptr<DataType>& type) { type_ = type; }
775
776 Status Init() override {
777 auto union_type = checked_cast<const UnionType*>(type_.get());
778 mode_ = union_type->mode();
779 type_id_to_child_num_.clear();
780 type_id_to_child_num_.resize(union_type->max_type_code() + 1, -1);
781 int child_i = 0;
782 for (auto type_id : union_type->type_codes()) {
783 type_id_to_child_num_[type_id] = child_i++;
784 }
785 std::vector<std::shared_ptr<ArrayBuilder>> child_builders;
786 for (const auto& field : type_->fields()) {
787 std::shared_ptr<JSONConverter> child_converter;
788 RETURN_NOT_OK(GetConverter(field->type(), &child_converter));
789 child_converters_.push_back(child_converter);
790 child_builders.push_back(child_converter->builder());
791 }
792 if (mode_ == UnionMode::DENSE) {
793 builder_ = std::make_shared<DenseUnionBuilder>(default_memory_pool(),
794 std::move(child_builders), type_);
795 } else {
796 builder_ = std::make_shared<SparseUnionBuilder>(default_memory_pool(),
797 std::move(child_builders), type_);
798 }
799 return Status::OK();
800 }
801
802 // Append a JSON value that must be a 2-long array, containing the type_id
803 // and value of the UnionArray's slot.

Callers

nothing calls this directly

Calls 12

default_memory_poolFunction · 0.85
resizeMethod · 0.80
max_type_codeMethod · 0.80
push_backMethod · 0.80
GetConverterFunction · 0.70
OKFunction · 0.70
getMethod · 0.45
modeMethod · 0.45
clearMethod · 0.45
fieldsMethod · 0.45
typeMethod · 0.45
builderMethod · 0.45

Tested by

no test coverage detected