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