sparrow ..
|
Dynamically typed array encapsulating an Arrow layout. More...
#include <array_api.hpp>
Public Types | |
using | size_type = std::size_t |
using | value_type = array_traits::value_type |
using | const_reference = array_traits::const_reference |
template<class F> | |
using | visit_result_t = std::invoke_result_t<F, null_array> |
Public Member Functions | |
array ()=default | |
Constructs an empty array. | |
template<layout A> requires (not std::is_lvalue_reference_v<A>) | |
constexpr | array (A &&a) |
Constructs an Array from the given typed layout. | |
template<layout A> | |
constexpr | array (A *a) |
Constructs an Array from the given typed layout. | |
template<layout A> | |
constexpr | array (std::shared_ptr< A > a) |
Constructs an Array from the given typed layout. | |
SPARROW_API | array (ArrowArray &&array, ArrowSchema &&schema) |
Constructs an Array from the given Arrow C structures, whose ownership is transferred to the Array. | |
SPARROW_API | array (ArrowArray &&array, ArrowSchema *schema) |
Constructs an Array from the given Arrow C structures. | |
SPARROW_API | array (ArrowArray *array, ArrowSchema *schema) |
Constructs an array from the given Arrow C structures. | |
constexpr | array (const array &rhs)=default |
Performs a deep copy of the given array, even if it does not have the ownership of its internal data. | |
array & | operator= (const array &rhs)=default |
Overwrites the content of the array with a deep copy of the given array, even if it does not have the ownership of its internal data. | |
array (array &&rhs)=default | |
The move constructor. | |
array & | operator= (array &&rhs)=default |
The move assignment operator. | |
SPARROW_API enum data_type | data_type () const |
SPARROW_API std::optional< std::string_view > | name () const |
SPARROW_API void | set_name (std::optional< std::string_view > name) |
Sets the name of the array to name. | |
SPARROW_API std::optional< key_value_view > | metadata () const |
template<input_metadata_container R = std::vector<metadata_pair>> | |
constexpr void | set_metadata (std::optional< R > metadata) |
Sets the metadata of the array to metadata. | |
SPARROW_API bool | empty () const |
Checks if the array has no element, i.e. | |
SPARROW_API size_type | size () const |
SPARROW_API const_reference | at (size_type index) const |
SPARROW_API const_reference | operator[] (size_type index) const |
SPARROW_API const_reference | front () const |
Returns a constant reference to the first element in the container. | |
SPARROW_API const_reference | back () const |
Returns a constant reference to the last element in the container. | |
template<class F> | |
constexpr visit_result_t< F > | visit (F &&func) const |
Returns the result of calling the given functor func on the layout internally held by the array. | |
SPARROW_API array | view () const |
Returns a view of the array. | |
SPARROW_API bool | is_view () const |
Checks if the array is a view. | |
SPARROW_API array | slice (size_type start, size_type end) const |
Slices the array to keep only the elements between the given start and end . | |
SPARROW_API array | slice_view (size_type start, size_type end) const |
Slices the array to keep only the elements between the given start and end . | |
Friends | |
class | detail::array_access |
Dynamically typed array encapsulating an Arrow layout.
The array
class is a dynamically typed container that encapsulates a typed Arrow layout. It provides accessors returning a variant of the suported data types, and supports the visitor pattern.
This class is designed to easily manipulate data from Arrow C structures and to easily extract Arrow C structures from layouts allocated with sparrow. It supports different models of ownership.
Definition at line 40 of file array_api.hpp.
Definition at line 46 of file array_api.hpp.
using sparrow::array::size_type = std::size_t |
Definition at line 44 of file array_api.hpp.
Definition at line 45 of file array_api.hpp.
using sparrow::array::visit_result_t = std::invoke_result_t<F, null_array> |
Definition at line 224 of file array_api.hpp.
|
default |
Constructs an empty array.
|
explicitconstexpr |
|
explicitconstexpr |
|
explicitconstexpr |
SPARROW_API sparrow::array::array | ( | ArrowArray && | array, |
ArrowSchema && | schema ) |
Constructs an Array from the given Arrow C structures, whose ownership is transferred to the Array.
The user should not use array
nor schema
after calling this constructor.
array | The ArrowArray structure to transfer into the Array. |
schema | The ArrowSchema structure to transfer into the Array. |
SPARROW_API sparrow::array::array | ( | ArrowArray && | array, |
ArrowSchema * | schema ) |
Constructs an Array from the given Arrow C structures.
The Array takes the ownership of the ArrowArray only. The user should not use array
after calling this constructor. schema
can still be used normally.
array | The ArrowArray structure to transfer into the Array. |
schema | The ArrowSchema to reference in the Array. |
SPARROW_API sparrow::array::array | ( | ArrowArray * | array, |
ArrowSchema * | schema ) |
Constructs an array from the given Arrow C structures.
Both structures are referenced from the Array and can still be used normally after calling this constructor.
array | The ArrowArray structure to reference in the Array. |
schema | The ArrowSchema to reference in the Array. |
|
constexprdefault |
Performs a deep copy of the given array, even if it does not have the ownership of its internal data.
rhs | The array to copy. |
|
default |
The move constructor.
rhs | The array to move. |
|
nodiscard |
index
, with bounds checking.index | The position of the element in the array. |
std::out_of_range | if index is not within the range of the container. |
|
nodiscard |
Returns a constant reference to the last element in the container.
Calling back
on an empty array causes undefined behavior.
|
nodiscard |
|
nodiscard |
Checks if the array has no element, i.e.
whether size() == 0.
|
nodiscard |
Returns a constant reference to the first element in the container.
Calling front
on an empty array causes undefined behavior.
|
nodiscard |
Checks if the array is a view.
|
nodiscard |
|
nodiscard |
The move assignment operator.
rhs | The array to move. |
Overwrites the content of the array with a deep copy of the given array, even if it does not have the ownership of its internal data.
rhs | The array to assign. |
SPARROW_API const_reference sparrow::array::operator[] | ( | size_type | index | ) | const |
|
constexpr |
Sets the metadata of the array to metadata.
R | The metadata container type. |
metadata | The new metadata of the array. |
Definition at line 432 of file array_api.hpp.
SPARROW_API void sparrow::array::set_name | ( | std::optional< std::string_view > | name | ) |
Sets the name of the array to name.
name | The new name of the array. |
|
nodiscard |
|
nodiscard |
Slices the array to keep only the elements between the given start
and end
.
A copy of the Array is returned. The data is not modified, only the ArrowArray.offset and ArrowArray.length are updated. If end
is greater than the size of the buffers, the following elements will be invalid.
start | The index of the first element to keep. Must be less than end . |
end | The index of the first element to discard. Must be less than the size of the buffers. |
|
nodiscard |
Slices the array to keep only the elements between the given start
and end
.
A view of the Array is returned. The data is not modified, only the ArrowArray.offset and ArrowArray.length are updated. If end
is greater than the size of the buffers, the following elements will be invalid.
start | The index of the first element to keep. Must be less than end . |
end | The index of the first element to discard. Must be less than the size of the buffers. |
|
nodiscard |
Returns a view of the array.
The data is not copied.
|
constexpr |
Returns the result of calling the given functor func
on the layout internally held by the array.
The actual type of the layout is retrieved via a visitor dispatch. func
must accept any kind of layout.
F | The functor type. |
func | The functor to apply. |
Definition at line 42 of file array.hpp.
|
friend |
Definition at line 302 of file array_api.hpp.