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

Function VisitJsonValue

cpp/src/arrow/util/simdjson_internal.h:194–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192 typename NullFn, typename Int64Fn, typename Uint64Fn, typename DoubleFn,
193 typename BigIntegerFn>
194Status VisitJsonValue(simdjson::ondemand::value value, ObjectFn&& object_fn,
195 ArrayFn&& array_fn, StringFn&& string_fn, BoolFn&& bool_fn,
196 NullFn&& null_fn, Int64Fn&& int64_fn, Uint64Fn&& uint64_fn,
197 DoubleFn&& double_fn, BigIntegerFn&& big_integer_fn) {
198 ARROW_ASSIGN_OR_RAISE(
199 auto type, ResolveSimdjsonResult(value.type(), "Failed to determine JSON type"));
200
201 switch (type) {
202 case simdjson::ondemand::json_type::object: {
203 ARROW_ASSIGN_OR_RAISE(
204 auto object,
205 ResolveSimdjsonResult(value.get_object(), "Failed to get JSON object"));
206 return object_fn(object);
207 }
208
209 case simdjson::ondemand::json_type::array: {
210 ARROW_ASSIGN_OR_RAISE(
211 auto array,
212 ResolveSimdjsonResult(value.get_array(), "Failed to get JSON array"));
213 return array_fn(array);
214 }
215
216 case simdjson::ondemand::json_type::string: {
217 ARROW_ASSIGN_OR_RAISE(
218 auto string,
219 ResolveSimdjsonResult(value.get_string(), "Failed to get JSON string"));
220 return string_fn(string);
221 }
222
223 case simdjson::ondemand::json_type::boolean: {
224 ARROW_ASSIGN_OR_RAISE(
225 auto boolean,
226 ResolveSimdjsonResult(value.get_bool(), "Failed to get JSON boolean"));
227 return bool_fn(boolean);
228 }
229
230 case simdjson::ondemand::json_type::null:
231 return null_fn();
232
233 case simdjson::ondemand::json_type::number: {
234 ARROW_ASSIGN_OR_RAISE(
235 auto number_type,
236 ResolveSimdjsonResult(value.get_number_type(),
237 "Failed to determine JSON number type"));
238
239 switch (number_type) {
240 case simdjson::ondemand::number_type::signed_integer: {
241 ARROW_ASSIGN_OR_RAISE(
242 auto number,
243 ResolveSimdjsonResult(value.get_int64(), "Failed to get signed integer"));
244 return int64_fn(number);
245 }
246
247 case simdjson::ondemand::number_type::unsigned_integer: {
248 ARROW_ASSIGN_OR_RAISE(auto number,
249 ResolveSimdjsonResult(value.get_uint64(),
250 "Failed to get unsigned integer"));
251 return uint64_fn(number);

Callers 2

WriteValueMethod · 0.85
GetJsonIntArrayFunction · 0.85

Calls 1

InvalidFunction · 0.50

Tested by

no test coverage detected