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

Method GetBool

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

Source from the content-addressed store, hash-verified

115 }
116
117 Result<bool> GetBool(const char* key) {
118 document_.rewind();
119
120 auto object = document_.get_object();
121
122 auto field = object.find_field(key);
123
124 if (field.error() == simdjson::NO_SUCH_FIELD) {
125 return Status::KeyError("Key '", key, "' does not exist");
126 }
127 if (field.error()) {
128 return Status::Invalid("Error accessing key '", key,
129 "': ", simdjson::error_message(field.error()));
130 }
131
132 auto bool_result = field.get_bool();
133 if (bool_result.error() == simdjson::INCORRECT_TYPE) {
134 return Status::TypeError("Key '", key, "' is not a boolean");
135 }
136 if (bool_result.error()) {
137 return Status::Invalid("Error getting bool for key '", key,
138 "': ", simdjson::error_message(bool_result.error()));
139 }
140
141 bool value;
142 if (auto error = std::move(bool_result).get(value)) {
143 return Status::Invalid("Error getting bool for key '", key,
144 "': ", simdjson::error_message(error));
145 }
146
147 return value;
148 }
149
150 private:
151 simdjson::ondemand::parser parser_;

Callers

nothing calls this directly

Calls 5

KeyErrorFunction · 0.85
InvalidFunction · 0.50
TypeErrorFunction · 0.50
find_fieldMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected