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

Function TupleRangeFromTable

cpp/src/arrow/stl.h:461–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

459
460template <typename Range>
461Status TupleRangeFromTable(const Table& table, const compute::CastOptions& cast_options,
462 compute::ExecContext* ctx, Range* rows) {
463 using row_type = typename std::decay<decltype(*std::begin(*rows))>::type;
464 constexpr std::size_t n_columns = std::tuple_size<row_type>::value;
465
466 if (table.schema()->num_fields() != n_columns) {
467 return Status::Invalid(
468 "Number of columns in the table does not match the width of the target: ",
469 table.schema()->num_fields(), " != ", n_columns);
470 }
471
472 if (std::size(*rows) != static_cast<size_t>(table.num_rows())) {
473 return Status::Invalid(
474 "Number of rows in the table does not match the size of the target: ",
475 table.num_rows(), " != ", std::size(*rows));
476 }
477
478 // Check that all columns have the correct type, otherwise cast them.
479 std::shared_ptr<Table> table_owner;
480 std::reference_wrapper<const ::arrow::Table> current_table(table);
481
482 ARROW_RETURN_NOT_OK(internal::EnsureColumnTypes<row_type>::Cast(
483 table, &table_owner, cast_options, ctx, &current_table));
484
485 internal::TupleSetter<Range, row_type>::Fill(current_table.get(), rows);
486
487 return Status::OK();
488}
489
490} // namespace stl
491} // namespace arrow

Callers 1

TESTFunction · 0.85

Calls 9

CastFunction · 0.85
beginFunction · 0.70
InvalidFunction · 0.70
sizeFunction · 0.70
OKFunction · 0.70
num_fieldsMethod · 0.45
schemaMethod · 0.45
num_rowsMethod · 0.45
getMethod · 0.45

Tested by 1

TESTFunction · 0.68