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

Method Init

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

Source from the content-addressed store, hash-verified

826 explicit UnionConverter(const std::shared_ptr<DataType>& type) { type_ = type; }
827
828 Status Init() override {
829 auto union_type = checked_cast<const UnionType*>(type_.get());
830 mode_ = union_type->mode();
831 type_id_to_child_num_.clear();
832 type_id_to_child_num_.resize(union_type->max_type_code() + 1, -1);
833 int child_i = 0;
834 for (auto type_id : union_type->type_codes()) {
835 type_id_to_child_num_[type_id] = child_i++;
836 }
837 std::vector<std::shared_ptr<ArrayBuilder>> child_builders;
838 for (const auto& field : type_->fields()) {
839 std::shared_ptr<JSONConverter> child_converter;
840 RETURN_NOT_OK(GetConverter(field->type(), &child_converter));
841 child_converters_.push_back(child_converter);
842 child_builders.push_back(child_converter->builder());
843 }
844 if (mode_ == UnionMode::DENSE) {
845 builder_ = std::make_shared<DenseUnionBuilder>(default_memory_pool(),
846 std::move(child_builders), type_);
847 } else {
848 builder_ = std::make_shared<SparseUnionBuilder>(default_memory_pool(),
849 std::move(child_builders), type_);
850 }
851 return Status::OK();
852 }
853
854 // Append a JSON value that must be a 2-long array, containing the type_id
855 // 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