Array Classes
Array classes in Apache Arrow C++ provide container classes for columnar data of various types.
Base Array Classes
Array
Base class for all array types. Immutable data array with some logical type and length.
Methods
Returns the number of elements in the array
Returns the relative position into another array’s data for zero-copy slicing
Returns the number of null entries in the array. Computed and cached on first call if not known at construction time
type
std::shared_ptr<DataType>
Returns the data type of the array
Returns true if the value at index is null. Does not perform bounds checking
Returns true if the value at index is valid (not null). Does not perform bounds checking
GetScalar
Result<std::shared_ptr<Scalar>>
Index of element to retrieve
Returns a Scalar containing the value of this array at index i
Position of the first element in the slice
Length of the slice. Adjusted if not enough elements available
Constructs a zero-copy slice of the array with the indicated offset and length
SliceSafe
Result<std::shared_ptr<Array>>
Position of the first element
Input-checking variant of Slice that validates parameters
Equality comparison options
Performs equality comparison with another array. Does not include ArrayStatistics in comparison
View
Result<std::shared_ptr<Array>>
type
std::shared_ptr<DataType>
required
Target data type
Constructs a zero-copy view of this array with the given type. Checks if types are layout-compatible
Performs cheap validation checks to determine obvious inconsistencies within the array’s internal data. O(k) where k is the number of descendants
Performs extensive validation checks. Potentially O(k*n) where k is the number of descendants and n is the array length
Numeric Arrays
NumericArray
Template class for numeric data arrays with a corresponding C type.
template <typename TYPE>
class NumericArray : public PrimitiveArray
Type Aliases
Int8Array - Array of signed 8-bit integers
Int16Array - Array of signed 16-bit integers
Int32Array - Array of signed 32-bit integers
Int64Array - Array of signed 64-bit integers
UInt8Array - Array of unsigned 8-bit integers
UInt16Array - Array of unsigned 16-bit integers
UInt32Array - Array of unsigned 32-bit integers
UInt64Array - Array of unsigned 64-bit integers
FloatArray - Array of 32-bit floating-point values
DoubleArray - Array of 64-bit floating-point values
Methods
Returns the value at index i
Returns pointer to the raw value data
operator[]
std::optional<value_type>
Returns the value at index i, or nullopt if null
BooleanArray
Array class for boolean data.
class BooleanArray : public PrimitiveArray
Returns the boolean value at index i
Returns the number of false (0) values among the valid values. Not cached
Returns the number of true (1) values among the valid values. Not cached
Binary Arrays
BinaryArray
Array class for variable-size binary data.
class BinaryArray : public BaseBinaryArray<BinaryType>
Returns binary value as a string_view
Returns binary value copied into a std::string
Returns the data buffer absolute offset of the data for the value at the passed index
Returns the length of the data for the value at the passed index
StringArray
Array class for variable-size UTF-8 string data.
class StringArray : public BinaryArray
Inherits all methods from BinaryArray.
Validates that this array contains only valid UTF-8 entries. Also implied by ValidateFull()
FixedSizeBinaryArray
Array class for fixed-size binary data.
class FixedSizeBinaryArray : public PrimitiveArray
Returns pointer to the binary value at index i
Returns binary value as a string_view
Returns the fixed byte width of each value
Nested Arrays
ListArray
Array class for variable-length list data.
class ListArray : public BaseListArray<ListType>
Returns array object containing the list’s values
Returns the offset into values array for list at index i
Returns the length of the list at index i. Requires IsValid(i)
Returns a slice of the values array for list at index i. Requires IsValid(i)
Flatten
Result<std::shared_ptr<Array>>
Returns an Array that is a concatenation of the lists in this array, taking into account offsets and skipping null elements
FromArrays
Result<std::shared_ptr<ListArray>>
Array containing n+1 offsets (int32 type)
Array containing list values
Memory pool for allocations
Constructs a ListArray from arrays of offsets and child values
StructArray
Array class for struct data.
class StructArray : public Array
Returns the field at the given position with offset, length and null count adjusted
name
const std::string&
required
Field name
Returns the field with the given name, or nullptr if not found
Memory pool for allocations
Flattens this array as a vector of arrays, one for each field
GetFlattenedField
Result<std::shared_ptr<Array>>
Memory pool for allocations
Gets one of the child arrays, combining its null bitmap with the parent struct array’s bitmap
Make
Result<std::shared_ptr<StructArray>>
children
const ArrayVector&
required
Child arrays
field_names
const std::vector<std::string>&
required
Field names
Returns a StructArray from child arrays and field names. Length and type are inferred
MapArray
Array class for map data (key-value pairs).
class MapArray : public ListArray
Returns array object containing all map keys
Returns array object containing all mapped items
FromArrays
Result<std::shared_ptr<Array>>
offsets
const std::shared_ptr<Array>&
required
Array containing n+1 offsets (int32 type)
keys
const std::shared_ptr<Array>&
required
Array containing key values
items
const std::shared_ptr<Array>&
required
Array containing item values
Memory pool for allocations
Constructs a MapArray from arrays of offsets, keys, and items