| 2056 | } |
| 2057 | |
| 2058 | Status WriteRecordBatch(const RecordBatch& batch, RjWriter* writer) { |
| 2059 | writer->StartObject(); |
| 2060 | writer->Key("count"); |
| 2061 | writer->Int(static_cast<int32_t>(batch.num_rows())); |
| 2062 | |
| 2063 | writer->Key("columns"); |
| 2064 | writer->StartArray(); |
| 2065 | |
| 2066 | for (auto [column, i] : Zip(batch.columns(), Enumerate<int>)) { |
| 2067 | DCHECK_EQ(batch.num_rows(), column->length()) |
| 2068 | << "Array length did not match record batch length: " << batch.num_rows() |
| 2069 | << " != " << column->length() << " " << batch.column_name(i); |
| 2070 | |
| 2071 | RETURN_NOT_OK(WriteArray(batch.column_name(i), *column, writer)); |
| 2072 | } |
| 2073 | |
| 2074 | writer->EndArray(); |
| 2075 | writer->EndObject(); |
| 2076 | return Status::OK(); |
| 2077 | } |
| 2078 | |
| 2079 | Status WriteArray(const std::string& name, const Array& array, RjWriter* json_writer) { |
| 2080 | ArrayWriter converter(name, array, json_writer); |
no test coverage detected