23#if defined(__cpp_lib_format)
177 template <
class... Args>
253 return get_arrow_proxy().children()
254 | std::views::transform(
255 [](
const auto& child)
269 template <layout_or_array A>
286 template <std::ranges::input_range R>
300 template <layout_or_array A>
338 std::ranges::input_range CHILDREN_RANGE,
341 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
343 CHILDREN_RANGE&& children,
345 std::optional<std::string_view> name = std::nullopt,
346 std::optional<METADATA_RANGE> metadata = std::nullopt
366 template <std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
367 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
369 CHILDREN_RANGE&& children,
371 std::optional<std::string_view> name = std::nullopt,
372 std::optional<METADATA_RANGE> metadata = std::nullopt
394 template <std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
395 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
397 CHILDREN_RANGE&& children,
398 std::optional<validity_bitmap>&& bitmap,
399 std::optional<std::string_view> name = std::nullopt,
400 std::optional<METADATA_RANGE> metadata = std::nullopt
485 template <std::ranges::input_range CHILDREN_RANGE, val
idity_bitmap_input VB, input_metadata_container METADATA_RANGE>
486 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
488 CHILDREN_RANGE&& children,
490 std::optional<std::string_view> name,
491 std::optional<METADATA_RANGE> metadata
494 const auto size = children.empty() ? 0 : children[0].size();
497 std::forward<CHILDREN_RANGE>(children),
504 template <std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE>
505 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
507 CHILDREN_RANGE&& children,
509 std::optional<std::string_view> name,
510 std::optional<METADATA_RANGE> metadata
513 const size_t size = children.empty() ? 0 : children[0].size();
515 std::forward<CHILDREN_RANGE>(children),
516 nullable ? std::make_optional<validity_bitmap>(
nullptr, size) : std::nullopt,
522 template <std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE>
523 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
525 CHILDREN_RANGE&& children,
526 std::optional<validity_bitmap>&& bitmap,
527 std::optional<std::string_view> name,
528 std::optional<METADATA_RANGE> metadata
531 const auto n_children = children.size();
535 const auto size = children.empty() ? 0 : children[0].size();
537 for (std::size_t i = 0; i < n_children; ++i)
539 auto& child = children[i];
542 child_arrays[i] =
new ArrowArray(std::move(flat_arr));
543 child_schemas[i] =
new ArrowSchema(std::move(flat_schema));
546 const bool bitmap_has_value = bitmap.has_value();
547 const auto null_count = bitmap_has_value ? bitmap->null_count() : 0;
548 const auto flags = bitmap_has_value
563 buffer<uint8_t> bitmap_buffer = bitmap_has_value ? std::move(*bitmap).extract_storage()
566 std::vector<buffer<std::uint8_t>> arr_buffs(1);
567 arr_buffs[0] = std::move(bitmap_buffer);
570 static_cast<std::int64_t
>(size),
571 static_cast<std::int64_t
>(null_count),
573 std::move(arr_buffs),
579 return arrow_proxy{std::move(arr), std::move(schema)};
582 template <layout_or_array A>
587 get_arrow_proxy().add_child(std::move(
array), std::move(schema));
591 template <std::ranges::input_range R>
595 for (
const auto& child : children)
600 for (
auto&& child : children)
602 add_child(std::forward<
decltype(child)>(child));
606 template <layout_or_array A>
611 get_arrow_proxy().set_child(index, std::move(
array), std::move(schema));
616#if defined(__cpp_lib_format)
622 constexpr auto parse(std::format_parse_context& ctx)
628 ->
decltype(ctx.out());
typename base_type::const_bitmap_range const_bitmap_range
typename base_type::iterator_tag iterator_tag
typename base_type::bitmap_const_reference bitmap_const_reference
typename base_type::bitmap_type bitmap_type
Base class for array type erasure.
Dynamically typed array encapsulating an Arrow layout.
Object that owns a piece of contiguous memory.
A view that repeats a value a given number of times.
SPARROW_API inner_reference value(size_type i)
Gets mutable reference to struct at specified index.
array_inner_types< self_type > inner_types
SPARROW_API children_type make_children()
Creates the children array wrappers.
void add_child(A &&child)
Adds a child array to the struct.
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.
SPARROW_API const_value_iterator value_cbegin() const
Gets const iterator to beginning of value range.
SPARROW_API struct_array(const struct_array &rhs)
Copy constructor.
SPARROW_API struct_array(arrow_proxy proxy)
Constructs struct array from Arrow proxy.
SPARROW_API value_iterator value_end()
Gets iterator to end of value range.
SPARROW_API void pop_children(size_t n)
Removes the last n children from the struct.
auto names() const
Gets the names of all child arrays.
void set_child(A &&child, size_t index)
Sets a child array at the specified index.
SPARROW_API inner_const_reference value(size_type i) const
Gets const reference to struct at specified index.
children_type m_children
Collection of child arrays (fields)
SPARROW_API array_wrapper * raw_child(std::size_t i)
Gets mutable pointer to child array at specified index.
void add_children(R &&children)
Adds multiple children to the struct array.
SPARROW_API const array_wrapper * raw_child(std::size_t i) const
Gets const pointer to child array at specified index.
nullable< inner_value_type > value_type
nullable< inner_const_reference, bitmap_const_reference > const_reference
SPARROW_API value_iterator value_begin()
Gets iterator to beginning of value range.
struct_value inner_reference
struct_array(Args &&... args)
Generic constructor for creating struct array from various inputs.
typename base_type::size_type size_type
typename inner_types::value_iterator value_iterator
base_type::iterator_tag iterator_tag
struct_value inner_value_type
std::vector< cloning_ptr< array_wrapper > > children_type
typename base_type::bitmap_type bitmap_type
struct_array(struct_array &&)=default
struct_array & operator=(struct_array &&)=default
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.
struct_value inner_const_reference
SPARROW_API size_type children_count() const
Gets the number of child arrays (fields).
base_type::const_bitmap_range const_bitmap_range
SPARROW_API const_value_iterator value_cend() const
Gets const iterator to end of value range.
SPARROW_API struct_array & operator=(const struct_array &rhs)
Copy assignment operator.
typename base_type::bitmap_const_reference bitmap_const_reference
typename inner_types::const_value_iterator const_value_iterator
array_bitmap_base< self_type > base_type
#define SPARROW_ASSERT_TRUE(expr__)
constexpr bool excludes_copy_and_move_ctor_v
Convenience variable template for excludes_copy_and_move_ctor.
ArrowSchema make_arrow_schema(F format, N name, std::optional< M > metadata, std::optional< std::unordered_set< ArrowFlag > > flags, ArrowSchema **children, const CHILDREN_OWNERSHIP &children_ownership, ArrowSchema *dictionary, bool dictionary_ownership)
Creates an ArrowSchema owned by a unique_ptr and holding the provided data.
array_bitmap_base_impl< D, false > array_bitmap_base
Convenient alias for arrays with immutable validity bitmaps.
constexpr bool is_struc_array_v
Type trait to check if a type is a struct_array.
std::pair< ArrowArray, ArrowSchema > extract_arrow_structures(A &&a)
Extracts the internal ArrowArray and ArrowSchema structures from the given array or typed layout.
ArrowArray make_arrow_array(int64_t length, int64_t null_count, int64_t offset, B buffers, ArrowArray **children, const CHILDREN_OWNERSHIP &children_ownership, ArrowArray *dictionary, bool dictionary_ownership)
Creates an ArrowArray.
dynamic_bitset< std::uint8_t > validity_bitmap
Type alias for a validity bitmap using 8-bit storage blocks.
std::ostream & operator<<(std::ostream &os, const nullval_t &)
SPARROW_API cloning_ptr< array_wrapper > array_factory(arrow_proxy proxy)
validity_bitmap ensure_validity_bitmap(std::size_t size, R &&validity_input)
Ensures a validity bitmap of the specified size from various input types.
data_type
Runtime identifier of arrow data types, usually associated with raw bytes with the associated value.
functor_index_iterator< detail::layout_value_functor< const array_type, inner_value_type > > const_value_iterator
functor_index_iterator< detail::layout_value_functor< array_type, inner_value_type > > value_iterator
struct_value inner_value_type
struct_value inner_reference
std::random_access_iterator_tag iterator_tag
struct_value inner_const_reference
Base class for array_inner_types specializations.
Traits class that must be specialized by array implementations.
static constexpr sparrow::data_type get()
Metafunction for retrieving the data_type of a typed array.