|
sparrow 2.4.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
|
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 |
| using | const_iterator = array_const_iterator |
| using | iterator = const_iterator |
| 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< array > | dictionary () const |
| Retrieves the dictionary array associated with this array, if it exists. | |
| auto | children () 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 size_type | offset () const |
| SPARROW_API std::int64_t | null_count () 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. | |
| SPARROW_API iterator | begin () const |
| Returns an iterator to the beginning of the array. | |
| SPARROW_API iterator | end () const |
| Returns an iterator to the end of the array. | |
| SPARROW_API const_iterator | cbegin () const |
| Returns a constant iterator to the beginning of the array. | |
| SPARROW_API const_iterator | cend () const |
| Returns a constant iterator to the end of the array. | |
| 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 bool | is_dictionary () const |
| SPARROW_API array | slice (size_type start, size_type end) const |
Returns a deep-copy of the array restricted to the elements in the half-open range [start, end). | |
| SPARROW_API array | slice_view (size_type start, size_type end) const |
Returns a zero-copy view of the array restricted to the elements in the half-open range [start, end). | |
| SPARROW_API void | slice_inplace (size_type start, size_type end) |
Restricts *this to the elements in the half-open range [start, end) in place. | |
| SPARROW_API iterator | insert (const_iterator pos, const_iterator first, const_iterator last) |
| Inserts elements from the range [first, last) before the element at the specified position. | |
| SPARROW_API iterator | insert (const_iterator pos, const_iterator first, const_iterator last, size_type count) |
| Inserts elements from the range [first, last) before the element at the specified position, repeating the insertion count times. | |
| SPARROW_API iterator | erase (const_iterator pos) |
Inserts a copy of value before pos in the array, repeating the insertion count times. | |
| SPARROW_API iterator | erase (const_iterator first, const_iterator last) |
Removes the elements in the range [ first , last ) from the array. | |
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 49 of file array_api.hpp.
Definition at line 57 of file array_api.hpp.
Definition at line 55 of file array_api.hpp.
Definition at line 58 of file array_api.hpp.
| using sparrow::array::size_type = std::size_t |
Definition at line 53 of file array_api.hpp.
Definition at line 54 of file array_api.hpp.
| using sparrow::array::visit_result_t = std::invoke_result_t<F, null_array> |
Definition at line 299 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. |
|
nodiscard |
Returns a constant reference to the last element in the container.
Calling back on an empty array causes undefined behavior.
|
nodiscard |
Returns an iterator to the beginning of the array.
|
nodiscard |
Returns a constant iterator to the beginning of the array.
|
nodiscard |
Returns a constant iterator to the end of the array.
|
inlinenodiscard |
Definition at line 180 of file array_api.hpp.
|
nodiscard |
|
nodiscard |
Retrieves the dictionary array associated with this array, if it exists.
This method is used for dictionary-encoded arrays to access the dictionary that contains the actual values referenced by the indices in this array.
|
nodiscard |
Checks if the array has no element, i.e.
whether size() == 0.
|
nodiscard |
Returns an iterator to the end of the array.
| SPARROW_API iterator sparrow::array::erase | ( | const_iterator | first, |
| const_iterator | last ) |
Removes the elements in the range [ first , last ) from the array.
| first | The iterator to the first element to remove. |
| last | The iterator to the element following the last element to remove. |
| SPARROW_API iterator sparrow::array::erase | ( | const_iterator | pos | ) |
Inserts a copy of value before pos in the array, repeating the insertion count times.
| pos | The iterator before which the element will be inserted (pos may be the end() iterator). |
| value | The element to insert. |
| count | The number of times to repeat the insertion. |
|
nodiscard |
Returns a constant reference to the first element in the container.
Calling front on an empty array causes undefined behavior.
| SPARROW_API iterator sparrow::array::insert | ( | const_iterator | pos, |
| const_iterator | first, | ||
| const_iterator | last ) |
Inserts elements from the range [first, last) before the element at the specified position.
| pos | The position before which the new elements will be inserted. |
| first | The beginning of the range of elements to insert. |
| last | The end of the range of elements to insert. |
| SPARROW_API iterator sparrow::array::insert | ( | const_iterator | pos, |
| const_iterator | first, | ||
| const_iterator | last, | ||
| size_type | count ) |
Inserts elements from the range [first, last) before the element at the specified position, repeating the insertion count times.
| pos | The position before which the new elements will be inserted. |
| first | The beginning of the range of elements to insert. |
| last | The end of the range of elements to insert. |
| count | The number of times to repeat the insertion. |
|
nodiscard |
|
nodiscard |
Checks if the array is a view.
|
nodiscard |
|
nodiscard |
|
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 608 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 |
Returns a deep-copy of the array restricted to the elements in the half-open range [start, end).
A full copy of the underlying Arrow buffers is made. The new ArrowArray.offset and ArrowArray.length are updated to represent the requested range. The returned array owns its data independently of *this.
| start | Index of the first element to keep. Must satisfy start <= end. |
| end | Index one past the last element to keep. Must be <= size of the buffers. |
| SPARROW_API void sparrow::array::slice_inplace | ( | size_type | start, |
| size_type | end ) |
Restricts *this to the elements in the half-open range [start, end) in place.
Only the ArrowArray.offset and ArrowArray.length of the current array are updated; no buffer data is copied or reallocated. This is the most efficient slicing variant when the caller does not need to retain the original range.
| start | Index of the first element to keep. Must satisfy start <= end. |
| end | Index one past the last element to keep. Must be <= size of the buffers. |
|
nodiscard |
Returns a zero-copy view of the array restricted to the elements in the half-open range [start, end).
No buffer data is copied. The returned Array shares ownership of the underlying Arrow buffers with *this, and only its ArrowArray.offset and ArrowArray.length differ. The returned object is in a view state (i.e. is_view returns true), reflecting that it does not own the data.
| start | Index of the first element to keep. Must satisfy start <= end. |
| end | Index one past the last element to keep. Must be <= 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 456 of file array_api.hpp.