MCPcopy Create free account
hub / github.com/apache/arrow / WriteRecordBatch

Function WriteRecordBatch

cpp/src/arrow/integration/json_internal.cc:2020–2039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2018}
2019
2020Status 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
2041Status WriteArray(const std::string& name, const Array& array, RjWriter* json_writer) {
2042 ArrayWriter converter(name, array, json_writer);

Callers 2

WriteRecordBatchMethod · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.70

Calls 12

ZipClass · 0.85
WriteArrayFunction · 0.85
columnsMethod · 0.80
OKFunction · 0.50
StartObjectMethod · 0.45
KeyMethod · 0.45
IntMethod · 0.45
num_rowsMethod · 0.45
StartArrayMethod · 0.45
lengthMethod · 0.45
EndArrayMethod · 0.45
EndObjectMethod · 0.45

Tested by

no test coverage detected