pitrou commented on code in PR #37792:
URL: https://github.com/apache/arrow/pull/37792#discussion_r1338138332
##########
cpp/src/arrow/integration/json_internal.cc:
##########
@@ -642,6 +648,50 @@ class ArrayWriter {
writer_->EndArray();
}
+ template <typename ArrayType>
+ void WriteBinaryViewField(const ArrayType& array) {
+ writer_->Key("VIEWS");
+ writer_->StartArray();
+ for (int64_t i = 0; i < array.length(); ++i) {
+ auto s = array.raw_values()[i];
+ writer_->StartObject();
+ writer_->Key("SIZE");
+ writer_->Int64(s.size());
+ if (s.is_inline()) {
+ writer_->Key("INLINED");
+ if constexpr (ArrayType::TypeClass::is_utf8) {
+ writer_->String(reinterpret_cast<const char*>(s.inline_data()),
s.size());
+ } else {
+ writer_->String(HexEncode(s.inline_data(), s.size()));
+ }
+ } else {
+ // Prefix is always 4 bytes so it may not be utf-8 even if the whole
+ // string view is
+ writer_->Key("PREFIX_HEX");
+ writer_->String(HexEncode(s.inline_data(),
BinaryViewType::kPrefixSize));
+ writer_->Key("BUFFER_INDEX");
+ writer_->Int64(s.io.buffer_index);
+ writer_->Key("OFFSET");
+ writer_->Int64(s.io.offset);
+ }
+ writer_->EndObject();
+ }
Review Comment:
That works with me.
--
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]