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

Function RunRowConversion

cpp/examples/arrow/row_wise_conversion_example.cc:175–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175arrow::Status RunRowConversion() {
176 std::vector<data_row> original_rows = {
177 {1, 1, {10.0}}, {2, 3, {11.0, 12.0, 13.0}}, {3, 2, {15.0, 25.0}}};
178 std::shared_ptr<arrow::Table> table;
179 std::vector<data_row> converted_rows;
180
181 ARROW_ASSIGN_OR_RAISE(table, VectorToColumnarTable(original_rows));
182
183 ARROW_ASSIGN_OR_RAISE(converted_rows, ColumnarTableToVector(table));
184
185 assert(original_rows.size() == converted_rows.size());
186
187 // Print out contents of table, should get
188 // ID Components Component prices
189 // 1 1 10
190 // 2 3 11 12 13
191 // 3 2 15 25
192 std::cout << std::left << std::setw(3) << "ID " << std::left << std::setw(11)
193 << "Components " << std::left << std::setw(15) << "Component prices "
194 << std::endl;
195 for (const auto& row : converted_rows) {
196 std::cout << std::left << std::setw(3) << row.id << std::left << std::setw(11)
197 << row.components;
198 for (const auto& cost : row.component_cost) {
199 std::cout << std::left << std::setw(4) << cost;
200 }
201 std::cout << std::endl;
202 }
203 return arrow::Status::OK();
204}
205
206int main(int argc, char** argv) {
207 auto status = RunRowConversion();

Callers 1

mainFunction · 0.85

Calls 5

VectorToColumnarTableFunction · 0.85
ColumnarTableToVectorFunction · 0.85
ARROW_ASSIGN_OR_RAISEFunction · 0.70
OKFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected