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

Method GetStringMap

cpp/src/arrow/util/simdjson_internal.cc:78–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76 }
77
78 Result<std::unordered_map<std::string, std::string>> GetStringMap() {
79 std::unordered_map<std::string, std::string> map;
80
81 document_.rewind();
82
83 auto object = document_.get_object();
84
85 for (auto field : object) {
86 std::string_view key;
87 if (auto error = field.unescaped_key().get(key)) {
88 return Status::Invalid("Error getting object key: ",
89 simdjson::error_message(error));
90 }
91
92 auto value = field.value();
93
94 auto str_result = value.get_string();
95
96 if (str_result.error() == simdjson::INCORRECT_TYPE) {
97 return Status::TypeError("Key '", std::string(key),
98 "' does not have a string value");
99 }
100 if (str_result.error()) {
101 return Status::Invalid("Error getting value for key '", std::string(key),
102 "': (code=", static_cast<int>(str_result.error()), ")");
103 }
104
105 std::string_view str;
106 if (auto error = std::move(str_result).get(str)) {
107 return Status::Invalid("Error getting value for key '", std::string(key),
108 "': ", simdjson::error_message(error));
109 }
110
111 map.emplace(std::string(key), std::string(str));
112 }
113
114 return map;
115 }
116
117 Result<bool> GetBool(const char* key) {
118 document_.rewind();

Callers

nothing calls this directly

Calls 4

InvalidFunction · 0.50
TypeErrorFunction · 0.50
getMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected