sparrow 0.6.0
|
Proxy class over ArrowArray
and ArrowSchema
.
More...
#include <arrow_array_schema_proxy.hpp>
Public Member Functions | |
SPARROW_API | arrow_proxy (ArrowArray &&array, ArrowSchema &&schema) |
Constructs an arrow_proxy which takes the ownership of the ArrowArray and ArrowSchema . | |
SPARROW_API | arrow_proxy (ArrowArray &&array, ArrowSchema *schema) |
Constructs an arrow_proxy which takes the ownership of the ArrowArray and uses the provided ArrowSchema . | |
SPARROW_API | arrow_proxy (ArrowArray *array, ArrowSchema *schema) |
Constructs an arrow_proxy which uses the provided ArrowArray and ArrowSchema . | |
SPARROW_API | arrow_proxy (const arrow_proxy &) |
SPARROW_API arrow_proxy & | operator= (const arrow_proxy &) |
SPARROW_API | arrow_proxy (arrow_proxy &&) |
SPARROW_API arrow_proxy & | operator= (arrow_proxy &&) |
SPARROW_API | ~arrow_proxy () |
SPARROW_API const std::string_view | format () const |
SPARROW_API void | set_format (const std::string_view format) |
Set the format according to the Arrow format specification: https://arrow.apache.org/docs/dev/format/CDataInterface.html#data-type-description-format-strings. | |
SPARROW_API enum data_type | data_type () const |
void SPARROW_API | set_data_type (enum data_type data_type) |
Set the data type. | |
SPARROW_API std::optional< std::string_view > | name () const |
SPARROW_API void | set_name (std::optional< std::string_view > name) |
Set the name of the ArrowSchema . | |
SPARROW_API std::optional< key_value_view > | metadata () const |
template<input_metadata_container R> | |
void | set_metadata (std::optional< R > metadata) |
Set the metadata of the ArrowSchema . | |
SPARROW_API std::unordered_set< ArrowFlag > | flags () const |
SPARROW_API void | set_flags (const std::unordered_set< ArrowFlag > &flags) |
Set the flags of the ArrowSchema . | |
SPARROW_API size_t | length () const |
SPARROW_API void | set_length (size_t length) |
Set the length of the ArrowArray . | |
SPARROW_API int64_t | null_count () const |
SPARROW_API void | set_null_count (int64_t null_count) |
Set the null count of the ArrowArray . | |
SPARROW_API size_t | offset () const |
SPARROW_API void | set_offset (size_t offset) |
Set the offset of the ArrowArray . | |
SPARROW_API size_t | n_buffers () const |
SPARROW_API void | set_n_buffers (size_t n_buffers) |
Set the number of buffers of the ArrowArray . | |
SPARROW_API size_t | n_children () const |
SPARROW_API const std::vector< sparrow::buffer_view< uint8_t > > & | buffers () const |
SPARROW_API std::vector< sparrow::buffer_view< uint8_t > > & | buffers () |
SPARROW_API void | set_buffer (size_t index, const buffer_view< uint8_t > &buffer) |
Set the buffer at the given index. | |
SPARROW_API void | set_buffer (size_t index, buffer< uint8_t > &&buffer) |
Set the buffer at the given index. | |
SPARROW_API void | resize_bitmap (size_t new_size, bool value=true) |
Resize the bitmap buffer of the ArrowArray . | |
SPARROW_API size_t | insert_bitmap (size_t index, bool value, size_t count=1) |
Insert elements of the same value in the bitmap buffer at the given index. | |
template<std::ranges::input_range R> | |
size_t | insert_bitmap (size_t index, const R &range) |
Insert several elements in the bitmap buffer at the given index. | |
SPARROW_API size_t | erase_bitmap (size_t index, size_t count=1) |
Erase several elements in the bitmap buffer at the given index. | |
SPARROW_API void | push_back_bitmap (bool value) |
Push a value at the end of the bitmap buffer. | |
SPARROW_API void | pop_back_bitmap () |
Pop a value at the end of the bitmap buffer. | |
template<std::ranges::input_range R> requires std::same_as<std::ranges::range_value_t<R>, arrow_array_and_schema_pointers> | |
void | add_children (const R &arrow_array_and_schema_pointers) |
Add children without taking their ownership. | |
template<std::ranges::input_range R> requires std::same_as<std::ranges::range_value_t<R>, arrow_array_and_schema> | |
void | add_children (R &&arrow_array_and_schemas) |
Add children and take their ownership. | |
SPARROW_API void | add_child (ArrowArray *array, ArrowSchema *schema) |
Add a child without taking its ownership. | |
SPARROW_API void | add_child (ArrowArray &&array, ArrowSchema &&schema) |
Add a child and takes its ownership. | |
SPARROW_API void | pop_children (size_t n) |
Pop n children. | |
SPARROW_API void | set_child (size_t index, ArrowArray *array, ArrowSchema *schema) |
Set the child at the given index. | |
SPARROW_API void | set_child (size_t index, ArrowArray &&array, ArrowSchema &&schema) |
Set the child at the given index. | |
SPARROW_API const std::vector< arrow_proxy > & | children () const |
SPARROW_API std::vector< arrow_proxy > & | children () |
SPARROW_API const std::unique_ptr< arrow_proxy > & | dictionary () const |
SPARROW_API std::unique_ptr< arrow_proxy > & | dictionary () |
SPARROW_API void | set_dictionary (ArrowArray *array, ArrowSchema *schema) |
Set the dictionary.It does not take the ownership on the ArrowArray and ArrowSchema passed by pointers. | |
SPARROW_API void | set_dictionary (ArrowArray &&array_dictionary, ArrowSchema &&schema_dictionary) |
Set the dictionary. | |
SPARROW_API bool | is_created_with_sparrow () const |
SPARROW_API void * | private_data () const |
SPARROW_API arrow_proxy | view () const |
get a non-owning view of the arrow_proxy. | |
SPARROW_API bool | owns_array () const |
SPARROW_API ArrowArray | extract_array () |
SPARROW_API ArrowArray & | array () |
SPARROW_API const ArrowArray & | array () const |
SPARROW_API bool | owns_schema () const |
SPARROW_API ArrowSchema | extract_schema () |
SPARROW_API ArrowSchema & | schema () |
SPARROW_API const ArrowSchema & | schema () const |
SPARROW_API arrow_schema_private_data * | get_schema_private_data () |
SPARROW_API arrow_array_private_data * | get_array_private_data () |
SPARROW_API arrow_proxy | slice (size_t start, size_t end) const |
Slices the array to keep only the elements between the given start and end . | |
SPARROW_API arrow_proxy | slice_view (size_t start, size_t end) const |
Slices the array to keep only the elements between the given start and end . | |
SPARROW_API void | update_buffers () |
Refresh the buffers views. | |
Proxy class over ArrowArray
and ArrowSchema
.
It ease the use of ArrowArray
and ArrowSchema
by providing a more user-friendly interface. It can take ownership of the ArrowArray
and ArrowSchema
or use them as pointers. If the arrow_proxy takes ownership of the ArrowArray
and ArrowSchema
, they are released when the arrow_proxy is destroyed. Otherwise, the arrow_proxy
does not release the ArrowArray
and ArrowSchema
.
Definition at line 72 of file arrow_array_schema_proxy.hpp.
|
explicit |
Constructs an arrow_proxy
which takes the ownership of the ArrowArray
and ArrowSchema
.
The array and schema are released when the arrow_proxy
is destroyed.
|
explicit |
Constructs an arrow_proxy
which takes the ownership of the ArrowArray
and uses the provided ArrowSchema
.
The array is released when the arrow_proxy
is destroyed. The schema is not released.
|
explicit |
Constructs an arrow_proxy
which uses the provided ArrowArray
and ArrowSchema
.
Neither the array nor the schema are released when the arrow_proxy
is destroyed.
SPARROW_API sparrow::arrow_proxy::arrow_proxy | ( | const arrow_proxy & | ) |
SPARROW_API sparrow::arrow_proxy::arrow_proxy | ( | arrow_proxy && | ) |
SPARROW_API sparrow::arrow_proxy::~arrow_proxy | ( | ) |
SPARROW_API void sparrow::arrow_proxy::add_child | ( | ArrowArray && | array, |
ArrowSchema && | schema ) |
Add a child and takes its ownership.
`arrow_proxy_exception` | If the `ArrowArray` or the `ArrowSchema` wrapped in this proxy were not created with sparrow. |
array | The ArrowArray to set as child. |
schema | The ArrowSchema to set as child. |
SPARROW_API void sparrow::arrow_proxy::add_child | ( | ArrowArray * | array, |
ArrowSchema * | schema ) |
Add a child without taking its ownership.
`arrow_proxy_exception` | If the `ArrowArray` or the `ArrowSchema` wrapped in this proxy were not created with sparrow. |
array | The ArrowArray to set as child. |
schema | The ArrowSchema to set as child. |
void sparrow::arrow_proxy::add_children | ( | const R & | arrow_array_and_schema_pointers | ) |
Add children without taking their ownership.
`arrow_proxy_exception` | If the `ArrowArray` or the `ArrowSchema` wrapped in this proxy were not created with sparrow. |
arrow_array_and_schema_pointers | The children to add. |
Definition at line 463 of file arrow_array_schema_proxy.hpp.
void sparrow::arrow_proxy::add_children | ( | R && | arrow_array_and_schemas | ) |
Add children and take their ownership.
`arrow_proxy_exception` | If the `ArrowArray` or the `ArrowSchema` wrapped in this proxy were not created with sparrow. |
arrow_array_and_schema | The children to add. |
Definition at line 487 of file arrow_array_schema_proxy.hpp.
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
SPARROW_API size_t sparrow::arrow_proxy::erase_bitmap | ( | size_t | index, |
size_t | count = 1 ) |
Erase several elements in the bitmap buffer at the given index.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
`arrow_proxy_exception` | If the array format does not support a validity bitmap. |
`std::out_of_range` | If the index is greater than the length of the bitmap. |
index | The index of the first value to erase. Must be less than the length of the bitmap. |
count | The number of elements to erase. 1 by default. |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
SPARROW_API size_t sparrow::arrow_proxy::insert_bitmap | ( | size_t | index, |
bool | value, | ||
size_t | count = 1 ) |
Insert elements of the same value in the bitmap buffer at the given index.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
`arrow_proxy_exception` | If the array format does not support a validity bitmap. |
`std::out_of_range` | If the index is greater than the length of the bitmap. |
index | The index where to insert the value. Must be less than the length of the bitmap. |
value | The value to insert. |
count | The number of times to insert the value. 1 by default |
|
inline |
Insert several elements in the bitmap buffer at the given index.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
`arrow_proxy_exception` | If the array format does not support a validity bitmap. |
`std::out_of_range` | If the index is greater than the length of the bitmap. |
index | The index where to insert the values. Must be less than the length of the bitmap. |
range | The range of values to insert. |
Definition at line 510 of file arrow_array_schema_proxy.hpp.
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
SPARROW_API arrow_proxy & sparrow::arrow_proxy::operator= | ( | arrow_proxy && | ) |
SPARROW_API arrow_proxy & sparrow::arrow_proxy::operator= | ( | const arrow_proxy & | ) |
|
nodiscard |
|
nodiscard |
SPARROW_API void sparrow::arrow_proxy::pop_back_bitmap | ( | ) |
Pop a value at the end of the bitmap buffer.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
`arrow_proxy_exception` | If the array format does not support a validity bitmap. |
SPARROW_API void sparrow::arrow_proxy::pop_children | ( | size_t | n | ) |
Pop n children.
If the children were created by sparrow or are owned by the proxy, it will delete them.
n | The number of children to pop. |
|
nodiscard |
SPARROW_API void sparrow::arrow_proxy::push_back_bitmap | ( | bool | value | ) |
Push a value at the end of the bitmap buffer.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
`arrow_proxy_exception` | If the array format does not support a validity bitmap. |
value | The value to push. |
SPARROW_API void sparrow::arrow_proxy::resize_bitmap | ( | size_t | new_size, |
bool | value = true ) |
Resize the bitmap buffer of the ArrowArray
.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
`arrow_proxy_exception` | If the array format does not support a validity bitmap. |
new_size | The new size of the bitmap buffer. |
value | The value to set in the new elements. True by default. |
|
nodiscard |
|
nodiscard |
SPARROW_API void sparrow::arrow_proxy::set_buffer | ( | size_t | index, |
buffer< uint8_t > && | buffer ) |
Set the buffer at the given index.
You have to call the set_length
method before calling this method to have the right sizes when calling buffers()
.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
index | The index of the buffer to set. |
buffer | The buffer to set. |
SPARROW_API void sparrow::arrow_proxy::set_buffer | ( | size_t | index, |
const buffer_view< uint8_t > & | buffer ) |
Set the buffer at the given index.
You have to call the set_length
method before calling this method to have the right sizes when calling buffers()
.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
index | The index of the buffer to set. |
buffer | The buffer to set. |
SPARROW_API void sparrow::arrow_proxy::set_child | ( | size_t | index, |
ArrowArray && | array, | ||
ArrowSchema && | schema ) |
Set the child at the given index.
It takes the ownership on the ArrowArray
andArrowSchema
passed by rvalue referencess.
`arrow_proxy_exception` | If the `ArrowArray` or `ArrowSchema` wrapped in this proxy were not created with sparrow. |
index | The index of the child to set. |
array | The ArrowArray to set as child. |
schema | The ArrowSchema to set as child. |
SPARROW_API void sparrow::arrow_proxy::set_child | ( | size_t | index, |
ArrowArray * | array, | ||
ArrowSchema * | schema ) |
Set the child at the given index.
It does not take the ownership on the ArrowArray
and ArrowSchema
passed by pointers.
`arrow_proxy_exception` | If the `ArrowArray` or the `ArrowSchema` wrapped in this proxy were not created with sparrow. |
index | The index of the child to set. |
array | The ArrowArray to set as child. |
schema | The ArrowSchema to set as child. |
void SPARROW_API sparrow::arrow_proxy::set_data_type | ( | enum data_type | data_type | ) |
Set the data type.
It's a convenient way to set the format of the ArrowSchema
.
`arrow_proxy_exception` | If the `ArrowSchema` was not created with sparrow. |
data_type | The data type to set. |
SPARROW_API void sparrow::arrow_proxy::set_dictionary | ( | ArrowArray && | array_dictionary, |
ArrowSchema && | schema_dictionary ) |
Set the dictionary.
It takes the ownership on the ArrowArray
andArrowSchema
passed by rvalue referencess.
`arrow_proxy_exception` | If the `ArrowArray` or `ArrowSchema` wrapped in this proxy were not created with sparrow. |
index | The index of the child to set. |
array | The ArrowArray to set as child. |
schema | The ArrowSchema to set as child. |
SPARROW_API void sparrow::arrow_proxy::set_dictionary | ( | ArrowArray * | array, |
ArrowSchema * | schema ) |
Set the dictionary.It does not take the ownership on the ArrowArray
and ArrowSchema
passed by pointers.
`arrow_proxy_exception` | If the `ArrowArray` or `ArrowSchema` were not created with sparrow. |
array | The ArrowArray to set as dictionary. |
schema | The ArrowSchema to set as dictionary. |
SPARROW_API void sparrow::arrow_proxy::set_flags | ( | const std::unordered_set< ArrowFlag > & | flags | ) |
Set the flags of the ArrowSchema
.
`arrow_proxy_exception` | If the `ArrowSchema` was not created with sparrow. |
flags | The flags to set. |
SPARROW_API void sparrow::arrow_proxy::set_format | ( | const std::string_view | format | ) |
Set the format according to the Arrow format specification: https://arrow.apache.org/docs/dev/format/CDataInterface.html#data-type-description-format-strings.
`arrow_proxy_exception` | If the `ArrowSchema` was not created with sparrow. |
format | The format to set. |
SPARROW_API void sparrow::arrow_proxy::set_length | ( | size_t | length | ) |
Set the length of the ArrowArray
.
This method does not resize the buffers of the ArrowArray
. You have to change the length before replacing/resizing the buffers to have the right sizes when calling buffers()
.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
length | The length to set. |
|
inline |
Set the metadata of the ArrowSchema
.
`arrow_proxy_exception` | If the `ArrowSchema` was not created with sparrow. |
metadata | The metadata to set. |
Definition at line 130 of file arrow_array_schema_proxy.hpp.
SPARROW_API void sparrow::arrow_proxy::set_n_buffers | ( | size_t | n_buffers | ) |
Set the number of buffers of the ArrowArray
.
Resize the buffers vector of the ArrowArray
private data.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
n_buffers | The number of buffers to set. |
SPARROW_API void sparrow::arrow_proxy::set_name | ( | std::optional< std::string_view > | name | ) |
Set the name of the ArrowSchema
.
`arrow_proxy_exception` | If the `ArrowSchema` was not created with sparrow. |
name | The name to set. |
SPARROW_API void sparrow::arrow_proxy::set_null_count | ( | int64_t | null_count | ) |
Set the null count of the ArrowArray
.
This method does not change the bitmap.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
null_count | The null count to set. |
SPARROW_API void sparrow::arrow_proxy::set_offset | ( | size_t | offset | ) |
Set the offset of the ArrowArray
.
`arrow_proxy_exception` | If the `ArrowArray` was not created with sparrow. |
offset | The offset to set. |
|
nodiscard |
Slices the array to keep only the elements between the given start
and end
.
A copy of the Array is modified. 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. |
SPARROW_API void sparrow::arrow_proxy::update_buffers | ( | ) |
Refresh the buffers views.
This method should be called after modifying the buffers of the array.
|
nodiscard |