| 2018 | } |
| 2019 | |
| 2020 | Status WriteRecordBatch(const RecordBatch& batch, RjWriter* writer) { |
| 2021 | writer->StartObject(); |
| 2022 | writer->Key("count"); |
| 2023 | writer->Int(static_cast<int32_t>(batch.num_rows())); |
| 2024 | |
| 2025 | writer->Key("columns"); |
| 2026 | writer->StartArray(); |
| 2027 | |
| 2028 | for (auto [column, i] : Zip(batch.columns(), Enumerate<int>)) { |
| 2029 | DCHECK_EQ(batch.num_rows(), column->length()) |
| 2030 | << "Array length did not match record batch length: " << batch.num_rows() |
| 2031 | << " != " << column->length() << " " << batch.column_name(i); |
| 2032 | |
| 2033 | RETURN_NOT_OK(WriteArray(batch.column_name(i), *column, writer)); |
| 2034 | } |
| 2035 | |
| 2036 | writer->EndArray(); |
| 2037 | writer->EndObject(); |
| 2038 | return Status::OK(); |
| 2039 | } |
| 2040 | |
| 2041 | Status WriteArray(const std::string& name, const Array& array, RjWriter* json_writer) { |
| 2042 | ArrayWriter converter(name, array, json_writer); |
no test coverage detected