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

Function GetMemberInt

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

Source from the content-addressed store, hash-verified

881
882template <typename IntType = int>
883Result<IntType> GetMemberInt(const JsonObject& obj, std::string_view key) {
884 ARROW_ASSIGN_OR_RAISE(
885 auto value, internal::ResolveSimdjsonResult(obj[key], "Failed to get JSON field"));
886 ARROW_ASSIGN_OR_RAISE(auto integer, internal::GetJsonInt(value, key, "an integer"));
887 return static_cast<IntType>(integer);
888}
889
890Result<bool> GetMemberBool(const JsonObject& obj, std::string_view key) {
891 ARROW_ASSIGN_OR_RAISE(
892 auto value, internal::ResolveSimdjsonResult(obj[key], "Failed to get JSON field"));
893 return internal::ResolveSimdjsonResult(value.get_bool(), "field was not a boolean");
894}
895
896Result<std::string> GetMemberString(const JsonObject& obj, std::string_view key) {
897 ARROW_ASSIGN_OR_RAISE(
898 auto value, internal::ResolveSimdjsonResult(obj[key], "Failed to get JSON field"));
899 ARROW_ASSIGN_OR_RAISE(
900 auto string_view,
901 internal::ResolveSimdjsonResult(value.get_string(), "field was not a string"));
902 return std::string(string_view);
903}
904
905Result<JsonObject> GetMemberObject(const JsonObject& obj, std::string_view key) {
906 ARROW_ASSIGN_OR_RAISE(
907 auto value, internal::ResolveSimdjsonResult(obj[key], "Failed to get JSON field"));
908 return internal::ResolveSimdjsonResult(value.get_object(), "field was not an object");
909}
910
911Result<JsonArray> GetMemberArray(const JsonObject& obj, std::string_view key) {
912 ARROW_ASSIGN_OR_RAISE(
913 auto value, internal::ResolveSimdjsonResult(obj[key], "Failed to get JSON field"));
914
915 return internal::GetJsonArray(value, key);
916}
917
918Result<TimeUnit::type> GetMemberTimeUnit(const JsonObject& obj, std::string_view key) {
919 ARROW_ASSIGN_OR_RAISE(const auto unit_str, GetMemberString(obj, key));
920 return GetUnitFromString(unit_str);
921}
922
923Result<std::shared_ptr<DataType>> GetInteger(const JsonObject& json_type) {
924 ARROW_ASSIGN_OR_RAISE(const bool is_signed, GetMemberBool(json_type, "isSigned"));
925 ARROW_ASSIGN_OR_RAISE(const int bit_width, GetMemberInt<int>(json_type, "bitWidth"));
926
927 switch (bit_width) {
928 case 8:
929 return is_signed ? int8() : uint8();
930 case 16:
931 return is_signed ? int16() : uint16();
932 case 32:
933 return is_signed ? int32() : uint32();
934 case 64:
935 return is_signed ? int64() : uint64();
936 }
937 return Status::Invalid("Invalid bit width: ", bit_width);
938}
939
940Result<std::shared_ptr<DataType>> GetFloatingPoint(const JsonObject& json_type) {

Callers

nothing calls this directly

Calls 15

decimal32Function · 0.85
decimal64Function · 0.85
decimal256Function · 0.85
GetTimeFunction · 0.85
GetOptionalJsonFieldFunction · 0.85
ResolveSimdjsonResultFunction · 0.85
day_time_intervalFunction · 0.85
month_intervalFunction · 0.85
month_day_nano_intervalFunction · 0.85
GetJsonIntArrayFunction · 0.85
sparse_unionFunction · 0.85
dense_unionFunction · 0.85

Tested by

no test coverage detected