| 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); |
nothing calls this directly
no test coverage detected