sparrow 0.3.0
|
Table-like data structure. More...
#include <record_batch.hpp>
Public Types | |
using | name_type = std::string |
using | size_type = std::size_t |
using | initializer_type = std::initializer_list<std::pair<name_type, array>> |
using | name_range = std::ranges::ref_view<const std::vector<name_type>> |
using | column_range = std::ranges::ref_view<const std::vector<array>> |
Public Member Functions | |
template<std::ranges::input_range NR, std::ranges::input_range CR> requires (std::convertible_to<std::ranges::range_value_t<NR>, std::string> and std::same_as<std::ranges::range_value_t<CR>, array>) | |
record_batch (NR &&names, CR &&columns) | |
Constructs a record_batch from a range of names and a range of arrays. | |
template<std::ranges::input_range CR> requires std::same_as<std::ranges::range_value_t<CR>, array> | |
record_batch (CR &&columns) | |
SPARROW_API | record_batch (initializer_type init) |
Constructs a record_batch from a list of std::pair<name_type, array> . | |
SPARROW_API | record_batch (struct_array &&ar) |
Construct a record batch from the given struct array. | |
SPARROW_API | record_batch (const record_batch &) |
SPARROW_API record_batch & | operator= (const record_batch &) |
record_batch (record_batch &&)=default | |
record_batch & | operator= (record_batch &&)=default |
SPARROW_API size_type | nb_columns () const |
SPARROW_API size_type | nb_rows () const |
SPARROW_API bool | contains_column (const name_type &key) const |
Checks if the record_batch constains a column mapped to the specified name. | |
SPARROW_API const name_type & | get_column_name (size_type index) const |
SPARROW_API const array & | get_column (const name_type &key) const |
SPARROW_API const array & | get_column (size_type index) const |
SPARROW_API name_range | names () const |
SPARROW_API column_range | columns () const |
SPARROW_API struct_array | extract_struct_array () |
Moves the internal columns of the record batch into a struct_array object. | |
SPARROW_API void | add_column (name_type name, array column) |
Appends the array column to the record batch, and maps it with name. | |
SPARROW_API void | add_column (array column) |
Appends the array column to the record batch, and maps it to its internal name. | |
Table-like data structure.
A record batch is a collection of equal-length arrays mapped to names. Each array represents a column of the table. record_batch is provided as a convenient unit of work for various serialization and computation functions.
Example of usage:
Definition at line 46 of file record_batch.hpp.
using sparrow::record_batch::column_range = std::ranges::ref_view<const std::vector<array>> |
Definition at line 55 of file record_batch.hpp.
using sparrow::record_batch::initializer_type = std::initializer_list<std::pair<name_type, array>> |
Definition at line 52 of file record_batch.hpp.
using sparrow::record_batch::name_range = std::ranges::ref_view<const std::vector<name_type>> |
Definition at line 54 of file record_batch.hpp.
using sparrow::record_batch::name_type = std::string |
Definition at line 50 of file record_batch.hpp.
using sparrow::record_batch::size_type = std::size_t |
Definition at line 51 of file record_batch.hpp.
sparrow::record_batch::record_batch | ( | NR && | names, |
CR && | columns ) |
Constructs a record_batch from a range of names and a range of arrays.
Each array is internally mapped to the name at the same position in the names range.
names | An input range of names. The names must be unique. |
columns | An input range of arrays. |
Definition at line 209 of file record_batch.hpp.
sparrow::record_batch::record_batch | ( | CR && | columns | ) |
SPARROW_API sparrow::record_batch::record_batch | ( | initializer_type | init | ) |
Constructs a record_batch from a list of std::pair<name_type, array>
.
init | a list of pair "name - array". |
SPARROW_API sparrow::record_batch::record_batch | ( | struct_array && | ar | ) |
Construct a record batch from the given struct array.
The array must owns its internal arrow structures.
ar | An input struct array |
SPARROW_API sparrow::record_batch::record_batch | ( | const record_batch & | ) |
|
default |
SPARROW_API void sparrow::record_batch::add_column | ( | array | column | ) |
Appends the array column to the record batch, and maps it to its internal name.
column must have a name.
column | The array to append. |
SPARROW_API void sparrow::record_batch::add_column | ( | name_type | name, |
array | column ) |
Appends the array column to the record batch, and maps it with name.
name | The name of the column to append. |
column | The array to append. |
SPARROW_API column_range sparrow::record_batch::columns | ( | ) | const |
SPARROW_API bool sparrow::record_batch::contains_column | ( | const name_type & | key | ) | const |
Checks if the record_batch constains a column mapped to the specified name.
key | The name of the column. |
true
if the record_batch contains the mapping, false
otherwise. SPARROW_API struct_array sparrow::record_batch::extract_struct_array | ( | ) |
Moves the internal columns of the record batch into a struct_array object.
The record batch is empty anymore after calling this method.
SPARROW_API const array & sparrow::record_batch::get_column | ( | const name_type & | key | ) | const |
key | The name of the column to search for. |
std::out_of_range | if the column is not found. |
SPARROW_API const array & sparrow::record_batch::get_column | ( | size_type | index | ) | const |
index | The index of the column. The index must be less than the number of columns. |
SPARROW_API const name_type & sparrow::record_batch::get_column_name | ( | size_type | index | ) | const |
index | The index of the column in the record_batch. The index must be less than the number of columns. |
SPARROW_API name_range sparrow::record_batch::names | ( | ) | const |
SPARROW_API size_type sparrow::record_batch::nb_columns | ( | ) | const |
SPARROW_API size_type sparrow::record_batch::nb_rows | ( | ) | const |
SPARROW_API record_batch & sparrow::record_batch::operator= | ( | const record_batch & | ) |
|
default |