| 173 | } |
| 174 | |
| 175 | arrow::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 | |
| 206 | int main(int argc, char** argv) { |
| 207 | auto status = RunRowConversion(); |
no test coverage detected