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