sparrow 0.6.0
|
sparrow
offers an array class for each Arrow layout. These arrays are commonly referred to as typed arrays because the exact data type is known. Despite differences in memory layout, all these arrays share a consistent API for reading data. This API is designed to resemble that of the standard container std::vector.
Typed arrays support missing values, or "nulls": any value in an array may be semantically null, regardless of its type.Therefore, when reading data from an array, one does not get scalar values, but a value of a special type that can handle missing values: nullable.
nullable has an API similar to std::optional:
Contrary to std::optional, nullable can hold a reference and act as a reference proxy. Assigning to a nullable proxy will assign to referenced value, it won't rebind the internal reference:
However, assigning null to a nullable proxy does not change the underlying value, it just reset the internal flags:
Typed arrays provide the following methods regarding their capacity:
Method | Description |
---|---|
empty | Checks whether the container is empty |
size | Returns the number of elements |
Example:
Typed arrays provide the following const methods to read elements:
Method | Description |
---|---|
at | Access specified element with bounds checking |
operator[] | Access specified element |
front | Access the first element |
back | Access the last element |
For an array holding data of type T
, these methods return values of type nullable<const T&>
.
Example:
Typed arrays also provide traditional iterating methods:
Method | Description |
---|---|
begin | Returns an iterator to the beginning |
cbegin | Returns an iterator to the beginning |
end | Returns an iterator to the end |
cend | Returns an iterator to the end |
rbegin | Returns a reverse iterator to the beginning |
crbegin | Returns a reverse iterator to the beginning |
rend | Returns a reverse iterator to the end |
crend | Returns a reverse iterator to the end |
Example:
In addition to the common API described above, typed arrays offer convenient constructors tailored to their specific types. They also implement full value-semantics and can therefore be copied and moved:
This array implements the Fixed-Size Primitive Layout.
TODO: add constructors.
This array implements the Variable-Size Binary Layout.
TODO: add constructors.
This array implements the Variable-Size List Layout.
TODO: add constructors.
This array implements the Variable-size ListView Layout.
TODO: add constructors.
This array implements the Fixed-size List Layout.
TODO: add constructors.
This array implements the Struct Layout.
TODO: add constructors.
This array implements the Union Layout.
TODO: add constructors.
This array implements the Union Layout.
TODO: add constructors.
This array implements the Dictionary-encoded Layout.
TODO: add constructors.