-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARROW-6284: [C++] Allow references in std::tuple when converting tupl…
…e to arrow array Currently `std::vector<std::tuple>` can be converted to a table by treating each tuple as a row and by building arrays corresponding to each element of the tuple. This PR allows reference types (and const reference types) in elements of `std::tuple` which is to be converted. This is useful for converting user defined types. For example a vector of `CustomType`: ```cpp struct CustomType { int8_t i8; uint64_t u64; bool b; std::string s; auto tie() const { return std::tie(i8, u64, b, s); } }; ``` can be converted to a table like this: ```cpp using boost::adaptors::transform; std::vector<CustomType> rows(); std::shared_ptr<Table> table; auto rng_rows = transform(rows(), [](const CustomType& c) { return c.tie(); }); TableFromTupleRange(default_memory_pool(), rng_rows, names, &table); ``` This makes it easier to convert user defined types to arrow tables. Closes #5112 from ozars/stl-ref and squashes the following commits: 6376d10 <Omer Ozarslan> Fix formatting 981edb3 <Omer Ozarslan> Test converting reference tuples to arrays 4dc780c <Omer Ozarslan> Allow references when inferring tuple element type Authored-by: Omer Ozarslan <[email protected]> Signed-off-by: François Saint-Jacques <[email protected]>
- Loading branch information
1 parent
e994e9c
commit 36bd667
Showing
2 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters