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

Function GetJsonIntArray

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

Source from the content-addressed store, hash-verified

440}
441
442Result<std::vector<int64_t>> GetJsonIntArray(simdjson::dom::element value,
443 std::string_view name) {
444 ARROW_ASSIGN_OR_RAISE(auto array, GetJsonArray(value, name));
445
446 std::vector<int64_t> result;
447 result.reserve(array.size());
448
449 for (auto element : array) {
450 ARROW_ASSIGN_OR_RAISE(auto number, GetJsonInt(element, name, "integers"));
451 result.push_back(number);
452 }
453
454 return result;
455}
456
457Result<std::vector<std::optional<int64_t>>> GetJsonNullableIntArray(
458 simdjson::dom::element value, std::string_view name) {
459 ARROW_ASSIGN_OR_RAISE(auto array, GetJsonArray(value, name));
460
461 std::vector<std::optional<int64_t>> result;
462 result.reserve(array.size());
463
464 for (auto element : array) {
465 if (element.is_null()) {
466 result.emplace_back(std::nullopt);
467 } else {
468 ARROW_ASSIGN_OR_RAISE(auto number, GetJsonInt(element, name, "integers or nulls"));
469 result.emplace_back(number);
470 }
471 }
472
473 return result;
474}
475
476Result<std::vector<std::string>> GetJsonStringArray(simdjson::dom::element value,
477 std::string_view name) {
478 ARROW_ASSIGN_OR_RAISE(auto array, GetJsonArray(value, name));
479
480 std::vector<std::string> result;
481 result.reserve(array.size());
482
483 for (auto element : array) {
484 if (!element.is_string()) {
485 return Status::Invalid(name, " must contain strings, got ",
486 JsonTypeName(element.type()));
487 }
488
489 ARROW_ASSIGN_OR_RAISE(
490 auto string,
491 ResolveSimdjsonResult(element.get_string(), "Failed to get JSON string"));
492 result.emplace_back(string);
493 }
494
495 return result;
496}
497
498const char* JsonTypeName(simdjson::ondemand::json_type type) {
499 switch (type) {

Callers 2

GetMemberIntFunction · 0.85
TensorFromJSONFunction · 0.85

Calls 13

VisitJsonValueFunction · 0.85
ResolveSimdjsonResultFunction · 0.85
is_nullMethod · 0.80
resizeMethod · 0.80
InvalidFunction · 0.50
OKFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
reserveMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45
dataMethod · 0.45
valueMethod · 0.45

Tested by 1

TensorFromJSONFunction · 0.68