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

Function GetKeyValueMetadata

cpp/src/arrow/integration/json_internal.cc:1238–1684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1236
1237template <typename FieldOrStruct>
1238Result<std::shared_ptr<KeyValueMetadata>> GetKeyValueMetadata(
1239 const FieldOrStruct& field_or_struct) {
1240 auto metadata = std::make_shared<KeyValueMetadata>();
1241
1242 ARROW_ASSIGN_OR_RAISE(auto metadata_value,
1243 internal::GetOptionalJsonField(field_or_struct, "metadata"));
1244
1245 if (!metadata_value || metadata_value->is_null()) {
1246 return metadata;
1247 }
1248
1249 ARROW_ASSIGN_OR_RAISE(auto metadata_array,
1250 internal::GetJsonArray(*metadata_value, "metadata"));
1251
1252 for (const auto& val : metadata_array) {
1253 ARROW_ASSIGN_OR_RAISE(
1254 auto key_value_pair,
1255 internal::ResolveSimdjsonResult(val.get_object(),
1256 "Metadata KeyValue was not a JSON object"));
1257
1258 ARROW_ASSIGN_OR_RAISE(const auto key, GetMemberString(key_value_pair, "key"));
1259 ARROW_ASSIGN_OR_RAISE(const auto value, GetMemberString(key_value_pair, "value"));
1260
1261 metadata->Append(std::move(key), std::move(value));
1262 }
1263
1264 return metadata;
1265}
1266
1267Result<std::shared_ptr<Field>> GetField(const JsonValue& obj, FieldPosition field_pos,
1268 DictionaryMemo* dictionary_memo) {
1269 ARROW_ASSIGN_OR_RAISE(
1270 auto json_field,
1271 internal::ResolveSimdjsonResult(obj.get_object(), "Field was not a JSON object"));
1272
1273 ARROW_ASSIGN_OR_RAISE(const auto name, GetMemberString(json_field, "name"));
1274 ARROW_ASSIGN_OR_RAISE(const bool nullable, GetMemberBool(json_field, "nullable"));
1275
1276 ARROW_ASSIGN_OR_RAISE(const auto json_type, GetMemberObject(json_field, "type"));
1277 ARROW_ASSIGN_OR_RAISE(const auto json_children, GetMemberArray(json_field, "children"));
1278
1279 ARROW_ASSIGN_OR_RAISE(FieldVector children,
1280 GetFieldsFromArray(json_children, field_pos, dictionary_memo));
1281 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<DataType> type, GetType(json_type, children));
1282
1283 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<KeyValueMetadata> metadata,
1284 GetKeyValueMetadata(json_field));
1285
1286 // Is it a dictionary type?
1287 int64_t dictionary_id = -1;
1288 std::shared_ptr<DataType> dict_value_type;
1289
1290 if (dictionary_memo != nullptr) {
1291 ARROW_ASSIGN_OR_RAISE(auto dictionary_value,
1292 internal::GetOptionalJsonField(json_field, "dictionary"));
1293
1294 if (dictionary_value) {
1295 ARROW_ASSIGN_OR_RAISE(

Callers

nothing calls this directly

Calls 2

ParseHexValueFunction · 0.85
AppendMethod · 0.45

Tested by

no test coverage detected