Reranko05 commented on code in PR #50937:
URL: https://github.com/apache/arrow/pull/50937#discussion_r3842327127
##########
cpp/src/arrow/integration/json_internal.cc:
##########
@@ -1671,49 +1712,46 @@ class ArrayReader {
continue;
}
- DCHECK(val.IsString())
- << "Found non-string JSON value when parsing Decimal128 value";
- DCHECK_GT(val.GetStringLength(), 0)
- << "Empty string found when parsing Decimal128 value";
+ ARROW_ASSIGN_OR_RAISE(auto string,
+ internal::ResolveSimdjsonResult(
+ val.get_string(), "Expected decimal value as
string"));
+
+ DCHECK_GT(string.size(), 0) << "Empty string found when parsing
Decimal128 value";
using Value = typename TypeTraits<T>::ScalarType::ValueType;
- ARROW_ASSIGN_OR_RAISE(Value decimal_val,
Value::FromString(val.GetString()));
+ ARROW_ASSIGN_OR_RAISE(Value decimal_val, Value::FromString(string));
RETURN_NOT_OK(builder.Append(decimal_val));
}
return FinishBuilder(&builder);
}
template <typename T>
- Status GetIntArray(const RjArray& json_array, const int32_t length,
+ Status GetIntArray(const JsonArray& json_array, const int32_t length,
std::shared_ptr<Buffer>* out) {
- if (static_cast<rj::SizeType>(length) != json_array.Size()) {
- return Status::Invalid("Integer array had unexpected length ",
json_array.Size(),
+ if (static_cast<int32_t>(json_array.size()) != length) {
+ return Status::Invalid("Integer array had unexpected length ",
json_array.size(),
" (expected ", length, ")");
}
ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(length * sizeof(T),
pool_));
T* values = reinterpret_cast<T*>(buffer->mutable_data());
- for (auto [i, val] : Zip(Enumerate<rj::SizeType>, json_array)) {
+ for (auto [i, val] : Zip(Enumerate<size_t>, json_array)) {
if constexpr (sizeof(T) < sizeof(int64_t)) {
- DCHECK(val.IsInt() || val.IsInt64());
- if (val.IsInt()) {
- values[i] = static_cast<T>(val.GetInt());
- } else {
- values[i] = static_cast<T>(val.GetInt64());
- }
+ ARROW_ASSIGN_OR_RAISE(
+ auto integer,
+ internal::ResolveSimdjsonResult(val.get_int64(), "Expected integer
value"));
+ values[i] = static_cast<T>(integer);
} else {
- // Read 64-bit integers as strings, as JSON numbers cannot represent
- // them exactly.
Review Comment:
Addressed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]