| 431 | |
| 432 | template <typename Range> |
| 433 | Status TableFromTupleRange(MemoryPool* pool, Range&& rows, |
| 434 | const std::vector<std::string>& names, |
| 435 | std::shared_ptr<Table>* table) { |
| 436 | using row_type = typename std::iterator_traits<decltype(std::begin(rows))>::value_type; |
| 437 | constexpr std::size_t n_columns = std::tuple_size<row_type>::value; |
| 438 | |
| 439 | std::shared_ptr<Schema> schema = SchemaFromTuple<row_type>::MakeSchema(names); |
| 440 | |
| 441 | std::vector<std::unique_ptr<ArrayBuilder>> builders(n_columns); |
| 442 | ARROW_RETURN_NOT_OK(internal::CreateBuildersRecursive<row_type>::Make(pool, &builders)); |
| 443 | |
| 444 | for (const auto& row : rows) { |
| 445 | ARROW_RETURN_NOT_OK(internal::RowIterator<row_type>::Append(builders, row)); |
| 446 | } |
| 447 | |
| 448 | std::vector<std::shared_ptr<Array>> arrays; |
| 449 | for (const auto& builder : builders) { |
| 450 | std::shared_ptr<Array> array; |
| 451 | ARROW_RETURN_NOT_OK(builder->Finish(&array)); |
| 452 | arrays.emplace_back(array); |
| 453 | } |
| 454 | |
| 455 | *table = Table::Make(std::move(schema), std::move(arrays)); |
| 456 | |
| 457 | return Status::OK(); |
| 458 | } |
| 459 | |
| 460 | template <typename Range> |
| 461 | Status TupleRangeFromTable(const Table& table, const compute::CastOptions& cast_options, |