sparrow 1.2.0
Loading...
Searching...
No Matches
sparrow::struct_array Class Referencefinal

#include <struct_array.hpp>

Inheritance diagram for sparrow::struct_array:
[legend]
Collaboration diagram for sparrow::struct_array:
[legend]

Public Types

using self_type = struct_array
 
using base_type = array_bitmap_base<self_type>
 
using inner_types = array_inner_types<self_type>
 
using value_iterator = typename inner_types::value_iterator
 
using const_value_iterator = typename inner_types::const_value_iterator
 
using size_type = typename base_type::size_type
 
using bitmap_type = typename base_type::bitmap_type
 
using bitmap_const_reference = typename base_type::bitmap_const_reference
 
using const_bitmap_range = base_type::const_bitmap_range
 
using inner_value_type = struct_value
 
using inner_reference = struct_value
 
using inner_const_reference = struct_value
 
using value_type = nullable<inner_value_type>
 
using const_reference = nullable<inner_const_reference, bitmap_const_reference>
 
using iterator_tag = base_type::iterator_tag
 
- Public Types inherited from sparrow::array_bitmap_base_impl< D, false >
using base_type
 
using size_type
 
using bitmap_type
 
using bitmap_iterator
 
using const_bitmap_iterator
 
using bitmap_const_reference
 
using difference_type
 
using const_bitmap_range
 
using iterator_tag
 

Public Member Functions

SPARROW_API struct_array (arrow_proxy proxy)
 Constructs struct array from Arrow proxy.
 
template<class... Args>
requires (mpl::excludes_copy_and_move_ctor_v<struct_array, Args...>)
 struct_array (Args &&... args)
 Generic constructor for creating struct array from various inputs.
 
SPARROW_API struct_array (const struct_array &rhs)
 Copy constructor.
 
SPARROW_API struct_arrayoperator= (const struct_array &rhs)
 Copy assignment operator.
 
 struct_array (struct_array &&)=default
 
struct_arrayoperator= (struct_array &&)=default
 
SPARROW_API size_type children_count () const
 Gets the number of child arrays (fields).
 
SPARROW_API const array_wrapperraw_child (std::size_t i) const
 Gets const pointer to child array at specified index.
 
SPARROW_API array_wrapperraw_child (std::size_t i)
 Gets mutable pointer to child array at specified index.
 
auto names () const
 Gets the names of all child arrays.
 
template<layout_or_array A>
void add_child (A &&child)
 Adds a child array to the struct.
 
template<std::ranges::input_range R>
requires layout_or_array<std::ranges::range_value_t<R>>
void add_children (R &&children)
 Adds multiple children to the struct array.
 
template<layout_or_array A>
void set_child (A &&child, size_t index)
 Sets a child array at the specified index.
 
SPARROW_API void pop_children (size_t n)
 Removes the last n children from the struct.
 
- Public Member Functions inherited from sparrow::array_bitmap_base_impl< D, false >
constexpr auto insert_bitmap (const_bitmap_iterator pos, InputIt first, InputIt last) -> bitmap_iterator is_mutable
 
constexpr auto insert_bitmap (const_bitmap_iterator pos, InputIt first, InputIt last) -> bitmap_iterator is_mutable
 

Protected Types

using children_type = std::vector<cloning_ptr<array_wrapper>>
 

Protected Member Functions

SPARROW_API value_iterator value_begin ()
 Gets iterator to beginning of value range.
 
SPARROW_API value_iterator value_end ()
 Gets iterator to end of value range.
 
SPARROW_API const_value_iterator value_cbegin () const
 Gets const iterator to beginning of value range.
 
SPARROW_API const_value_iterator value_cend () const
 Gets const iterator to end of value range.
 
SPARROW_API inner_reference value (size_type i)
 Gets mutable reference to struct at specified index.
 
SPARROW_API inner_const_reference value (size_type i) const
 Gets const reference to struct at specified index.
 
SPARROW_API children_type make_children ()
 Creates the children array wrappers.
 
- Protected Member Functions inherited from sparrow::array_bitmap_base_impl< D, false >
 array_bitmap_base_impl (arrow_proxy proxy)
 Constructs array bitmap base from Arrow proxy.
 
constexpr array_bitmap_base_impl (const array_bitmap_base_impl &)
 Copy constructor.
 
constexpr array_bitmap_base_imploperator= (const array_bitmap_base_impl &)
 Copy assignment operator.
 
constexpr array_bitmap_base_impl (array_bitmap_base_impl &&) noexcept=default
 
constexpr array_bitmap_base_imploperator= (array_bitmap_base_impl &&) noexcept=default
 
constexpr bitmap_typeget_bitmap ()
 Gets mutable reference to the validity bitmap.
 
constexpr const bitmap_typeget_bitmap () const
 Gets const reference to the validity bitmap.
 
constexpr void resize_bitmap (size_type new_length, bool value)
 Resizes the validity bitmap to accommodate new array length.
 
constexpr bitmap_iterator insert_bitmap (const_bitmap_iterator pos, bool value, size_type count)
 Inserts validity bits at specified position.
 
constexpr bitmap_iterator insert_bitmap (const_bitmap_iterator pos, InputIt first, InputIt last) is_mutable
 Inserts range of validity bits at specified position.
 
constexpr bitmap_iterator erase_bitmap (const_bitmap_iterator pos, size_type count)
 Erases validity bits starting at specified position.
 
constexpr void update ()
 Updates internal bitmap after external modifications to Arrow data.
 
constexpr non_owning_dynamic_bitset< uint8_t > get_non_owning_dynamic_bitset ()
 Gets non-owning view of the bitmap as dynamic bitset.
 
constexpr bitmap_type make_bitmap ()
 Creates bitmap wrapper from current Arrow validity buffer.
 
 array_bitmap_base_impl (arrow_proxy proxy)
 Constructs array bitmap base from Arrow proxy.
 
constexpr array_bitmap_base_impl (const array_bitmap_base_impl &)
 Copy constructor.
 
constexpr array_bitmap_base_impl (array_bitmap_base_impl &&) noexcept=default
 
constexpr array_bitmap_base_imploperator= (const array_bitmap_base_impl &)
 Copy assignment operator.
 
constexpr array_bitmap_base_imploperator= (array_bitmap_base_impl &&) noexcept=default
 
constexpr bitmap_typeget_bitmap ()
 Gets mutable reference to the validity bitmap.
 
constexpr const bitmap_typeget_bitmap () const
 Gets const reference to the validity bitmap.
 
constexpr void resize_bitmap (size_type new_length, bool value)
 Resizes the validity bitmap to accommodate new array length.
 
constexpr bitmap_iterator insert_bitmap (const_bitmap_iterator pos, bool value, size_type count)
 Inserts validity bits at specified position.
 
constexpr bitmap_iterator insert_bitmap (const_bitmap_iterator pos, InputIt first, InputIt last) is_mutable
 Inserts range of validity bits at specified position.
 
constexpr bitmap_iterator erase_bitmap (const_bitmap_iterator pos, size_type count)
 Erases validity bits starting at specified position.
 
constexpr void update ()
 Updates internal bitmap after external modifications to Arrow data.
 
constexpr non_owning_dynamic_bitset< uint8_t > get_non_owning_dynamic_bitset ()
 Gets non-owning view of the bitmap as dynamic bitset.
 
constexpr bitmap_type make_bitmap ()
 Creates bitmap wrapper from current Arrow validity buffer.
 

Static Protected Member Functions

template<std::ranges::input_range CHILDREN_RANGE, validity_bitmap_input VB = validity_bitmap, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>, array>
static auto create_proxy (CHILDREN_RANGE &&children, VB &&bitmaps, std::optional< std::string_view > name=std::nullopt, std::optional< METADATA_RANGE > metadata=std::nullopt) -> arrow_proxy
 Creates Arrow proxy from children arrays with explicit validity bitmap.
 
template<std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>, array>
static auto create_proxy (CHILDREN_RANGE &&children, bool nullable=true, std::optional< std::string_view > name=std::nullopt, std::optional< METADATA_RANGE > metadata=std::nullopt) -> arrow_proxy
 Creates Arrow proxy from children arrays with nullable flag.
 
template<std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>, array>
static auto create_proxy_impl (CHILDREN_RANGE &&children, std::optional< validity_bitmap > &&bitmap, std::optional< std::string_view > name=std::nullopt, std::optional< METADATA_RANGE > metadata=std::nullopt) -> arrow_proxy
 Implementation helper for creating Arrow proxy from components.
 

Protected Attributes

children_type m_children
 Collection of child arrays (fields)
 

Friends

class array_crtp_base< self_type >
 
class detail::layout_value_functor< self_type, inner_value_type >
 
class detail::layout_value_functor< const self_type, inner_value_type >
 

Detailed Description

Member Typedef Documentation

◆ base_type

◆ bitmap_const_reference

◆ bitmap_type

Definition at line 135 of file struct_array.hpp.

◆ children_type

◆ const_bitmap_range

◆ const_reference

◆ const_value_iterator

using sparrow::struct_array::const_value_iterator = typename inner_types::const_value_iterator

◆ inner_const_reference

◆ inner_reference

◆ inner_types

◆ inner_value_type

◆ iterator_tag

◆ self_type

◆ size_type

Definition at line 133 of file struct_array.hpp.

◆ value_iterator

using sparrow::struct_array::value_iterator = typename inner_types::value_iterator

Definition at line 131 of file struct_array.hpp.

◆ value_type

Constructor & Destructor Documentation

◆ struct_array() [1/4]

SPARROW_API sparrow::struct_array::struct_array ( arrow_proxy proxy)
explicit

Constructs struct array from Arrow proxy.

Parameters
proxyArrow proxy containing struct array data and schema
Precondition
proxy must contain valid Arrow struct array and schema
proxy format must be "+s"
proxy must have child arrays with consistent lengths
Postcondition
Array is initialized with data from proxy
Child arrays are accessible via field access methods
Validity bitmap is properly initialized
Here is the call graph for this function:
Here is the caller graph for this function:

◆ struct_array() [2/4]

template<class... Args>
requires (mpl::excludes_copy_and_move_ctor_v<struct_array, Args...>)
sparrow::struct_array::struct_array ( Args &&... args)
inlineexplicit

Generic constructor for creating struct array from various inputs.

Creates a struct array from different input combinations. Arguments are forwarded to compatible create_proxy() functions based on their types.

Template Parameters
ArgsParameter pack for constructor arguments
Parameters
argsConstructor arguments (children, validity, metadata, etc.)
Precondition
Arguments must match one of the create_proxy() overload signatures
All child arrays must have the same length
Child array names must be unique (if specified)
Postcondition
Array is created with the specified children and configuration
Field access is available for all child arrays

Definition at line 179 of file struct_array.hpp.

◆ struct_array() [3/4]

SPARROW_API sparrow::struct_array::struct_array ( const struct_array & rhs)

Copy constructor.

Parameters
rhsSource struct array to copy from
Precondition
rhs must be in a valid state
Postcondition
This array contains a deep copy of rhs data
All child arrays are independently copied
Field structure and names are preserved
Here is the call graph for this function:

◆ struct_array() [4/4]

sparrow::struct_array::struct_array ( struct_array && )
default
Here is the call graph for this function:

Member Function Documentation

◆ add_child()

template<layout_or_array A>
void sparrow::struct_array::add_child ( A && child)

Adds a child array to the struct.

Parameters
childThe child array to add
Postcondition
Increases the number of children by one
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

Definition at line 583 of file struct_array.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_children()

template<std::ranges::input_range R>
requires layout_or_array<std::ranges::range_value_t<R>>
void sparrow::struct_array::add_children ( R && children)

Adds multiple children to the struct array.

This function template adds a range of children (layouts or arrays) to the struct array. All children must have the same size as the current struct array.

Template Parameters
RAn input range type whose value type satisfies the layout_or_array concept
Parameters
childrenA range of child elements to be added to the struct array
Exceptions
Assertionerror if any child's size doesn't match the struct array's size
Note
The function reserves memory upfront to optimize performance when adding multiple children
Children are forwarded to maintain their value category (lvalue/rvalue)
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

Definition at line 593 of file struct_array.hpp.

Here is the call graph for this function:

◆ children_count()

SPARROW_API size_type sparrow::struct_array::children_count ( ) const
nodiscard

Gets the number of child arrays (fields).

Returns
Number of fields in the struct
Postcondition
Returns non-negative count
Equals the number of distinct fields in the struct
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

◆ create_proxy() [1/2]

template<std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE>
requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>, array>
auto sparrow::struct_array::create_proxy ( CHILDREN_RANGE && children,
bool nullable = true,
std::optional< std::string_view > name = std::nullopt,
std::optional< METADATA_RANGE > metadata = std::nullopt ) -> arrow_proxy
staticnodiscardprotected

Creates Arrow proxy from children arrays with nullable flag.

Template Parameters
CHILDREN_RANGEType of children range
METADATA_RANGEType of metadata container
Parameters
childrenRange of child arrays (one per field)
nullableWhether the struct array should support null values
nameOptional name for the struct array
metadataOptional metadata for the struct array
Returns
Arrow proxy containing the struct array data and schema
Precondition
CHILDREN_RANGE must be input range of array objects
All children must have the same length
Postcondition
If nullable is true, array supports null values (though none initially set)
If nullable is false, array does not support null values
Returns valid Arrow proxy with struct format

Definition at line 506 of file struct_array.hpp.

Here is the call graph for this function:

◆ create_proxy() [2/2]

template<std::ranges::input_range CHILDREN_RANGE, validity_bitmap_input VB, input_metadata_container METADATA_RANGE>
requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>, array>
auto sparrow::struct_array::create_proxy ( CHILDREN_RANGE && children,
VB && bitmaps,
std::optional< std::string_view > name = std::nullopt,
std::optional< METADATA_RANGE > metadata = std::nullopt ) -> arrow_proxy
staticnodiscardprotected

Creates Arrow proxy from children arrays with explicit validity bitmap.

Template Parameters
CHILDREN_RANGEType of children range
VBType of validity bitmap input
METADATA_RANGEType of metadata container
Parameters
childrenRange of child arrays (one per field)
bitmapsValidity bitmap specification
nameOptional name for the struct array
metadataOptional metadata for the struct array
Returns
Arrow proxy containing the struct array data and schema
Precondition
CHILDREN_RANGE must be input range of array objects
All children must have the same length
bitmaps size must match children length (if not empty)
Postcondition
Returns valid Arrow proxy with struct format ("+s")
Child arrays are properly embedded in the structure
Validity bitmap reflects the provided bitmap data
Note
Internal assertion: SPARROW_ASSERT_TRUE(child.size() == size) for each child
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

Definition at line 487 of file struct_array.hpp.

Here is the call graph for this function:

◆ create_proxy_impl()

template<std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE>
requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>, array>
auto sparrow::struct_array::create_proxy_impl ( CHILDREN_RANGE && children,
std::optional< validity_bitmap > && bitmap,
std::optional< std::string_view > name = std::nullopt,
std::optional< METADATA_RANGE > metadata = std::nullopt ) -> arrow_proxy
staticnodiscardprotected

Implementation helper for creating Arrow proxy from components.

Template Parameters
CHILDREN_RANGEType of children range
METADATA_RANGEType of metadata container
Parameters
childrenRange of child arrays
bitmapOptional validity bitmap
nameOptional name for the struct array
metadataOptional metadata for the struct array
Returns
Arrow proxy containing the struct array data and schema
Precondition
All children must have the same length
If bitmap is provided, its size must match children length
Postcondition
Returns valid Arrow proxy with struct format ("+s")
Child arrays are embedded with proper ownership management
Schema includes field definitions from child arrays
Note
Internal assertion: SPARROW_ASSERT_TRUE(child.size() == size) for each child
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

Definition at line 524 of file struct_array.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_children()

SPARROW_API children_type sparrow::struct_array::make_children ( )
nodiscardprotected

Creates the children array wrappers.

Returns
Vector of cloning pointers to child array wrappers
Postcondition
Returns valid children collection
Each child corresponds to a field in the struct
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

◆ names()

auto sparrow::struct_array::names ( ) const
inlinenodiscard

Gets the names of all child arrays.

Returns
Range of child array names.
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

Definition at line 251 of file struct_array.hpp.

◆ operator=() [1/2]

SPARROW_API struct_array & sparrow::struct_array::operator= ( const struct_array & rhs)

Copy assignment operator.

Parameters
rhsSource struct array to copy from
Returns
Reference to this array
Precondition
rhs must be in a valid state
Postcondition
This array contains a deep copy of rhs data
Previous data is properly released
All child arrays are independently copied
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.
Here is the call graph for this function:

◆ operator=() [2/2]

struct_array & sparrow::struct_array::operator= ( struct_array && )
default
Here is the call graph for this function:

◆ pop_children()

SPARROW_API void sparrow::struct_array::pop_children ( size_t n)

Removes the last n children from the struct.

Parameters
nThe number of children to remove
Precondition
n must be <= children_count()
Postcondition
Decreases the number of children by n.
The owned arrays are released.
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

◆ raw_child() [1/2]

SPARROW_API array_wrapper * sparrow::struct_array::raw_child ( std::size_t i)
nodiscard

Gets mutable pointer to child array at specified index.

Parameters
iIndex of the child array
Returns
Pointer to the child array wrapper
Precondition
i must be < children_count()
Postcondition
Returns non-null pointer to valid array_wrapper
Modifications through pointer affect the struct array

◆ raw_child() [2/2]

SPARROW_API const array_wrapper * sparrow::struct_array::raw_child ( std::size_t i) const
nodiscard

Gets const pointer to child array at specified index.

Parameters
iIndex of the child array
Returns
Const pointer to the child array wrapper
Precondition
i must be < children_count()
Postcondition
Returns non-null pointer to valid array_wrapper
Pointer remains valid while struct array exists
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

◆ set_child()

template<layout_or_array A>
void sparrow::struct_array::set_child ( A && child,
size_t index )

Sets a child array at the specified index.

Parameters
childThe child array to set
indexThe index at which to set the child
Precondition
index must be < children_count()
Postcondition
Replaces the child array at the specified index. Release the array if it has the ownership.
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

Definition at line 607 of file struct_array.hpp.

Here is the call graph for this function:

◆ value() [1/2]

SPARROW_API inner_reference sparrow::struct_array::value ( size_type i)
nodiscardprotected

Gets mutable reference to struct at specified index.

Parameters
iIndex of the struct to access
Returns
Mutable reference to the struct value
Precondition
i must be < size()
Postcondition
Returns valid reference providing access to all fields
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

◆ value() [2/2]

SPARROW_API inner_const_reference sparrow::struct_array::value ( size_type i) const
nodiscardprotected

Gets const reference to struct at specified index.

Parameters
iIndex of the struct to access
Returns
Const reference to the struct value
Precondition
i must be < size()
Postcondition
Returns valid const reference providing access to all fields

◆ value_begin()

SPARROW_API value_iterator sparrow::struct_array::value_begin ( )
nodiscardprotected

Gets iterator to beginning of value range.

Returns
Iterator pointing to the first struct element
Postcondition
Returns valid iterator to array beginning
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

◆ value_cbegin()

SPARROW_API const_value_iterator sparrow::struct_array::value_cbegin ( ) const
nodiscardprotected

Gets const iterator to beginning of value range.

Returns
Const iterator pointing to the first struct element
Postcondition
Returns valid const iterator to array beginning
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

◆ value_cend()

SPARROW_API const_value_iterator sparrow::struct_array::value_cend ( ) const
nodiscardprotected

Gets const iterator to end of value range.

Returns
Const iterator pointing past the last struct element
Postcondition
Returns valid const iterator to array end
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

◆ value_end()

SPARROW_API value_iterator sparrow::struct_array::value_end ( )
nodiscardprotected

Gets iterator to end of value range.

Returns
Iterator pointing past the last struct element
Postcondition
Returns valid iterator to array end
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

Friends And Related Symbol Documentation

◆ array_crtp_base< self_type >

friend class array_crtp_base< self_type >
friend

Definition at line 475 of file struct_array.hpp.

◆ detail::layout_value_functor< const self_type, inner_value_type >

Definition at line 475 of file struct_array.hpp.

◆ detail::layout_value_functor< self_type, inner_value_type >

Definition at line 475 of file struct_array.hpp.

Member Data Documentation

◆ m_children

children_type sparrow::struct_array::m_children
protected

Collection of child arrays (fields)

Examples
/home/runner/work/sparrow/sparrow/include/sparrow/struct_array.hpp.

Definition at line 475 of file struct_array.hpp.


The documentation for this class was generated from the following file: