| 658 | |
| 659 | template <typename T> |
| 660 | void WriteIntegerField(const char* name, const T* values, int64_t length) { |
| 661 | writer_->Key(name); |
| 662 | writer_->StartArray(); |
| 663 | if (sizeof(T) < sizeof(int64_t)) { |
| 664 | for (int i = 0; i < length; ++i) { |
| 665 | writer_->Int64(values[i]); |
| 666 | } |
| 667 | } else { |
| 668 | // Represent 64-bit integers as strings, as JSON numbers cannot represent |
| 669 | // them exactly. |
| 670 | ::arrow::internal::StringFormatter<typename CTypeTraits<T>::ArrowType> formatter; |
| 671 | auto append = [this](std::string_view v) { |
| 672 | writer_->String(v.data(), static_cast<rj::SizeType>(v.size())); |
| 673 | return Status::OK(); |
| 674 | }; |
| 675 | for (int i = 0; i < length; ++i) { |
| 676 | DCHECK_OK(formatter(values[i], append)); |
| 677 | } |
| 678 | } |
| 679 | writer_->EndArray(); |
| 680 | } |
| 681 | |
| 682 | template <typename ArrayType> |
| 683 | void WriteBinaryViewField(const ArrayType& array) { |