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

Method DoImport

cpp/src/arrow/c/bridge.cc:1044–1092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1042 }
1043
1044 Status DoImport() {
1045 // First import children (required for reconstituting parent type)
1046 child_importers_.resize(c_struct_->n_children);
1047 for (int64_t i = 0; i < c_struct_->n_children; ++i) {
1048 DCHECK_NE(c_struct_->children[i], nullptr);
1049 RETURN_NOT_OK(child_importers_[i].ImportChild(this, c_struct_->children[i]));
1050 }
1051
1052 // Import main type
1053 RETURN_NOT_OK(ProcessFormat());
1054 DCHECK_NE(type_, nullptr);
1055
1056 // Import dictionary type
1057 if (c_struct_->dictionary != nullptr) {
1058 // Check this index type
1059 if (!is_integer(type_->id())) {
1060 return Status::Invalid(
1061 "ArrowSchema struct has a dictionary but is not an integer type: ",
1062 type_->ToString());
1063 }
1064 SchemaImporter dict_importer;
1065 RETURN_NOT_OK(dict_importer.ImportDict(this, c_struct_->dictionary));
1066 bool ordered = (c_struct_->flags & ARROW_FLAG_DICTIONARY_ORDERED) != 0;
1067 type_ = dictionary(type_, dict_importer.type_, ordered);
1068 }
1069
1070 // Import metadata
1071 ARROW_ASSIGN_OR_RAISE(metadata_, DecodeMetadata(c_struct_->metadata));
1072
1073 // Detect extension type
1074 if (!metadata_.extension_name.empty()) {
1075 const auto registered_ext_type = GetExtensionType(metadata_.extension_name);
1076 if (registered_ext_type) {
1077 ARROW_ASSIGN_OR_RAISE(
1078 type_, registered_ext_type->Deserialize(std::move(type_),
1079 metadata_.extension_serialized));
1080 // If metadata is present, delete both metadata keys (otherwise, just remove
1081 // the extension name key)
1082 if (metadata_.extension_serialized_index >= 0) {
1083 RETURN_NOT_OK(metadata_.metadata->DeleteMany(
1084 {metadata_.extension_name_index, metadata_.extension_serialized_index}));
1085 } else {
1086 RETURN_NOT_OK(metadata_.metadata->Delete(metadata_.extension_name_index));
1087 }
1088 }
1089 }
1090
1091 return Status::OK();
1092 }
1093
1094 Status ProcessFormat() {
1095 f_parser_ = FormatStringParser(c_struct_->format);

Callers

nothing calls this directly

Calls 15

DecodeMetadataFunction · 0.85
GetExtensionTypeFunction · 0.85
resizeMethod · 0.80
DeleteManyMethod · 0.80
is_integerFunction · 0.50
InvalidFunction · 0.50
dictionaryFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
OKFunction · 0.50
ImportChildMethod · 0.45
idMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected