sparrow 0.3.0
|
The array
class is a dynamically typed array that can be built in many ways:
Example:
The array class provides a similar API to that of the typed arrays, but with certain limitations: iterators are not provided, for performance reasons. Instead, a method for visiting the array and apply an algorithm to the undelying typed array is provided.
Copying an array always perform a deep copy, regardless of whether the source array owns its internal data. This reduces the complexity of the memory model when mixing views and arrays within layouts that have children.
Like typed arrays, array provides the following methods regarding its capacity:
Method | Description |
---|---|
empty | Checks whether the container is empty |
size | Returns the number of elements |
Accessing an element in an array
yields a std::variant of nullable objects. The variant can hold any data type used by the typed array classes. A method is provided so that the user can retrieve the dynamic data_type of the array.
Method | Description |
---|---|
data_type | Returns the dynamic type of the data |
at | Access specified element with bounds checking |
operator[] | Access specified element |
front | Access the first element |
back | Access the last element |
Example:
The visit function allows the user to apply a functor to each element of the array. The functor must accept any kind of typed array.
Example:
sparrow provides free functions to either read data from sparrow arrays as Arrow C data, or to extract them.
Method | Description |
---|---|
owns_arrow_array | Checks for internal Arrow Array ownership |
owns_arrow_schema | Checks for internal Arrow Schema ownership |
Example:
These methods return pointers to the internal Arrow structures. One must NOT call the release
method on these structures after use. The sparrow array object will release them upon destruction.
Method | Description |
---|---|
get_arrow_array | Returns a pointer to the internal ArrowArray |
get_arrow_schema | Returns a pointer to the internal ArrowSchema |
get_arrow_structures | Returns a pair of pointer to the internal Arrow structures |
Example:
These methods moves out of the array the internal Arrow structures. The user is responsible for calling the release
method of these structures after use.
Method | Description |
---|---|
extract_arrow_array | Extracts the internal ArrowArray |
extract_arrow_schema | Extracts the internal ArrowSchema |
extract_arrow_structures | Extracts the internal Arrow structures |
Example: