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

Function TableFromTupleRange

cpp/src/arrow/stl.h:433–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431
432template <typename Range>
433Status 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
460template <typename Range>
461Status TupleRangeFromTable(const Table& table, const compute::CastOptions& cast_options,

Callers 2

TESTFunction · 0.85
AssertScanEqualsMethod · 0.85

Calls 7

MakeSchemaFunction · 0.85
emplace_backMethod · 0.80
beginFunction · 0.70
MakeFunction · 0.70
AppendFunction · 0.70
OKFunction · 0.70
FinishMethod · 0.45

Tested by 2

TESTFunction · 0.68
AssertScanEqualsMethod · 0.68