23#if defined(__cpp_lib_format)
87 template <
class... Args>
90 :
struct_array(create_proxy(std::forward<Args>(args)...))
109 std::ranges::input_range CHILDREN_RANGE,
112 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
113 [[nodiscard]]
static auto create_proxy(
114 CHILDREN_RANGE&& children,
116 std::optional<std::string_view> name = std::nullopt,
117 std::optional<METADATA_RANGE> metadata = std::nullopt
120 template <std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
121 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
122 [[nodiscard]]
static auto create_proxy(
123 CHILDREN_RANGE&& children,
125 std::optional<std::string_view> name = std::nullopt,
126 std::optional<METADATA_RANGE> metadata = std::nullopt
129 template <std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
130 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
131 [[nodiscard]]
static auto create_proxy_impl(
132 CHILDREN_RANGE&& children,
133 std::optional<validity_bitmap>&& bitmap,
134 std::optional<std::string_view> name = std::nullopt,
135 std::optional<METADATA_RANGE> metadata = std::nullopt
138 using children_type = std::vector<cloning_ptr<array_wrapper>>;
147 [[nodiscard]]
SPARROW_API children_type make_children();
150 children_type m_children;
160 template <std::ranges::input_range CHILDREN_RANGE, val
idity_bitmap_input VB, input_metadata_container METADATA_RANGE>
161 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
162 auto struct_array::create_proxy(
163 CHILDREN_RANGE&& children,
165 std::optional<std::string_view> name,
166 std::optional<METADATA_RANGE> metadata
169 const auto size = children.empty() ? 0 : children[0].size();
171 return create_proxy_impl(
172 std::forward<std::vector<array>>(children),
179 template <std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE>
180 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>, array>
181 auto struct_array::create_proxy(
182 CHILDREN_RANGE&& children,
184 std::optional<std::string_view> name,
185 std::optional<METADATA_RANGE> metadata
188 const size_t size = children.empty() ? 0 : children[0].size();
189 return create_proxy_impl(
190 std::forward<std::vector<array>>(children),
191 nullable ? std::make_optional<validity_bitmap>(
nullptr, size) : std::nullopt,
197 template <std::ranges::input_range CHILDREN_RANGE, input_metadata_container METADATA_RANGE>
198 requires std::same_as<std::ranges::range_value_t<CHILDREN_RANGE>,
array>
199 auto struct_array::create_proxy_impl(
200 CHILDREN_RANGE&& children,
201 std::optional<validity_bitmap>&& bitmap,
202 std::optional<std::string_view> name,
203 std::optional<METADATA_RANGE> metadata
206 const auto n_children = children.size();
207 ArrowSchema** child_schemas =
new ArrowSchema*[n_children];
208 ArrowArray** child_arrays =
new ArrowArray*[n_children];
210 const auto size = children.empty() ? 0 : children[0].size();
212 for (std::size_t i = 0; i < n_children; ++i)
214 auto& child = children[i];
217 child_arrays[i] =
new ArrowArray(std::move(flat_arr));
218 child_schemas[i] =
new ArrowSchema(std::move(flat_schema));
221 const bool bitmap_has_value = bitmap.has_value();
222 const auto null_count = bitmap_has_value ? bitmap->null_count() : 0;
223 const auto flags = bitmap_has_value
238 buffer<uint8_t> bitmap_buffer = bitmap_has_value ? std::move(*bitmap).extract_storage()
241 std::vector<buffer<std::uint8_t>> arr_buffs(1);
242 arr_buffs[0] = std::move(bitmap_buffer);
245 static_cast<std::int64_t
>(size),
246 static_cast<std::int64_t
>(null_count),
248 std::move(arr_buffs),
254 return arrow_proxy{std::move(arr), std::move(schema)};
258#if defined(__cpp_lib_format)
263 constexpr auto parse(std::format_parse_context& ctx)
269 ->
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 defining common immutable interface for arrays with a bitmap.
Base class for array type erasure.
Dynamically typed array encapsulating an Arrow layout.
Proxy class over ArrowArray and ArrowSchema.
Object that owns a piece of contiguous memory.
The nullable class models a value or a reference that can be "null", or missing, like values traditio...
A view that repeats a value a given number of times.
array_inner_types< self_type > inner_types
SPARROW_API struct_array(arrow_proxy proxy)
SPARROW_API struct_array(const struct_array &)
SPARROW_API array_wrapper * raw_child(std::size_t i)
SPARROW_API const array_wrapper * raw_child(std::size_t i) const
nullable< inner_value_type > value_type
nullable< inner_const_reference, bitmap_const_reference > const_reference
struct_value inner_reference
struct_array(Args &&... args)
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
typename base_type::bitmap_type bitmap_type
struct_array(struct_array &&)=default
struct_array & operator=(struct_array &&)=default
struct_value inner_const_reference
SPARROW_API struct_array & operator=(const struct_array &)
SPARROW_API size_type children_count() const
base_type::const_bitmap_range const_bitmap_range
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 std::size_t size(typelist< T... >={})
constexpr bool excludes_copy_and_move_ctor_v
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 typedef to be used as a crtp base class for arrays using an immutable validity buffer.
constexpr bool is_struc_array_v
Checks whether T is a struct_array type.
std::pair< ArrowArray, ArrowSchema > extract_arrow_structures(A &&a)
Extracts the internal ArrowArrays 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
validity_bitmap ensure_validity_bitmap(std::size_t size, R &&validity_input)
std::ostream & operator<<(std::ostream &os, const sparrow::nullval_t &)
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 specialization.
Traits class that must be specialized by array classes inheriting from array_crtp_base.