53 std::
size_t m_index = 0;
54 mutable
std::
size_t m_run_index = 0;
58#include "sparrow/layout/run_end_encoded_iterator.hpp"
139 template <
class... Args>
320 template <std::input_iterator InputIt>
321 requires std::constructible_from<value_type, typename std::iterator_traits<InputIt>::value_type>
326 while (first != last)
330 insert_logical_value(index + inserted_count, current_value, first == last);
336 template <std::ranges::input_range R>
337 requires std::constructible_from<value_type, std::ranges::range_value_t<R>>
342 std::ranges::begin(std::forward<R>(range)),
343 std::ranges::end(std::forward<R>(range))
392 [[nodiscard]] std::optional<std::string_view>
name()
const;
399 [[nodiscard]] std::optional<key_value_view>
metadata()
const;
413 template <input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
414 [[nodiscard]]
static auto create_proxy(
416 array&& encoded_values,
417 std::optional<std::string_view>
name = std::nullopt,
418 std::optional<METADATA_RANGE>
metadata = std::nullopt
421 using acc_length_ptr_variant_type = std::variant<const std::int16_t*, const std::int32_t*, const std::int64_t*>;
431 [[nodiscard]]
SPARROW_API static std::pair<std::int64_t, std::int64_t>
432 extract_length_and_null_count(
const array& acc_lengths_arr,
const array& encoded_values_arr);
440 [[nodiscard]]
SPARROW_API static acc_length_ptr_variant_type get_acc_lengths_ptr(
const array& ar);
448 [[nodiscard]]
SPARROW_API std::uint64_t get_acc_length(std::uint64_t run_index)
const;
493 SPARROW_API void refresh_and_merge_adjacent_runs(std::optional<size_type> merge_candidate);
511 SPARROW_API void finalize_mutation(
bool refresh_state);
513 SPARROW_API void throw_if_sliced_for_mutation(
const char* operation)
const;
520 std::uint64_t m_encoded_length;
523 array p_acc_lengths_array;
525 array p_encoded_values_array;
527 acc_length_ptr_variant_type m_acc_lengths;
539 template <input_metadata_container METADATA_RANGE>
540 auto run_end_encoded_array::create_proxy(
542 array&& encoded_values,
543 std::optional<std::string_view> name,
544 std::optional<METADATA_RANGE> metadata
548 auto [null_count, length] = extract_length_and_null_count(acc_lengths, encoded_values);
553 constexpr auto n_children = 2;
557 child_schemas[0] =
new ArrowSchema(std::move(acc_length_schema));
558 child_schemas[1] =
new ArrowSchema(std::move(encoded_values_schema));
560 child_arrays[0] =
new ArrowArray(std::move(acc_length_array));
561 child_arrays[1] =
new ArrowArray(std::move(encoded_values_array));
576 std::vector<buffer<std::uint8_t>> arr_buffs = {};
579 static_cast<std::int64_t
>(length),
580 static_cast<int64_t
>(null_count),
582 std::move(arr_buffs),
589 return arrow_proxy{std::move(arr), std::move(schema)};
595#if defined(__cpp_lib_format)
598struct std::formatter<sparrow::run_end_encoded_array>
600 constexpr auto parse(std::format_parse_context& ctx)
605 SPARROW_API auto format(
const sparrow::run_end_encoded_array& ar, std::format_context& ctx)
const
606 ->
decltype(ctx.out());
Dynamically typed array encapsulating an Arrow layout.
SPARROW_API std::unordered_set< ArrowFlag > flags() const
Gets the Arrow flags set for this array.
static const sparrow::arrow_proxy & get_arrow_proxy(const ARRAY &array)
A view that repeats a value a given number of times.
run_end_encoded_reference reference
SPARROW_API const_iterator end() const
Gets a constant iterator to the end of the array.
SPARROW_API const_reverse_iterator rend() const
Gets a constant reverse iterator to the end of the reversed array.
SPARROW_API void push_back(const value_type &value)
SPARROW_API iterator insert(const_iterator pos, const value_type &value)
Inserts a single logical value before pos.
array_traits::value_type value_type
std::optional< key_value_view > metadata() const
Gets the metadata of the array.
array_traits::const_reference const_reference
std::reverse_iterator< iterator > reverse_iterator
run_encoded_array_iterator< true > const_iterator
array_traits::inner_value_type inner_value_type
SPARROW_API size_type size() const
Gets the number of elements in the array.
~run_end_encoded_array()=default
SPARROW_API reference front()
Gets a mutable reference to the first element.
SPARROW_API array_traits::const_reference back() const
Gets a reference to the last element.
SPARROW_API bool empty() const
Checks if the array is empty.
SPARROW_API const_reverse_iterator rbegin() const
Gets a constant reverse iterator to the beginning of reversed the array.
SPARROW_API iterator end()
Gets an iterator to the end of the array.
SPARROW_API iterator begin()
Gets an iterator to the beginning of the array.
friend class run_end_encoded_reference
SPARROW_API const_iterator begin() const
Gets a constant iterator to the beginning of the array.
self_type & operator=(self_type &&)=default
SPARROW_API array_traits::const_reference operator[](std::uint64_t i) const
Constant access operator for getting element at index.
SPARROW_API run_end_encoded_array(const self_type &)
Copy constructor.
run_end_encoded_array(self_type &&)=default
SPARROW_API run_end_encoded_array(arrow_proxy proxy)
Constructs run-end encoded array from Arrow proxy.
SPARROW_API iterator erase(const_iterator first, const_iterator last)
Erases the logical range [first, last).
std::optional< std::string_view > name() const
Gets the name of the array.
std::reverse_iterator< const_iterator > const_reverse_iterator
SPARROW_API iterator insert(const_iterator pos, const value_type &value, size_type count)
Inserts count copies of value before pos.
SPARROW_API const_reverse_iterator crbegin() const
Gets a constant reverse iterator to the beginning of reversed the array.
SPARROW_API void pop_back()
SPARROW_API reference operator[](std::uint64_t i)
Mutable access operator for updating the logical value at index.
SPARROW_API reference back()
Gets a mutable reference to the last element.
SPARROW_API reverse_iterator rend()
Gets a reverse iterator to the end of the reversed array.
SPARROW_API void resize(size_type new_length, const value_type &value)
iterator insert(const_iterator pos, InputIt first, InputIt last)
SPARROW_API array_traits::const_reference front() const
Gets a constant reference to the first element.
SPARROW_API const_iterator cend() const
Gets a constant iterator to the end of the array.
SPARROW_API self_type & operator=(const self_type &)
Copy assignment operator.
run_end_encoded_array self_type
iterator insert(const_iterator pos, R &&range)
run_end_encoded_array(Args &&... args)
Generic constructor for creating run-end encoded array.
SPARROW_API reverse_iterator rbegin()
Gets a reverse iterator to the beginning of the reversed array.
SPARROW_API const_reverse_iterator crend() const
Gets a constant reverse iterator to the end of the reversed array.
SPARROW_API const_iterator cbegin() const
Gets a constant iterator to the beginning of the array.
SPARROW_API iterator erase(const_iterator pos)
Erases the logical value at pos.
run_encoded_array_iterator< false > iterator
run_end_encoded_reference(run_end_encoded_reference &&) noexcept=default
run_end_encoded_reference(const run_end_encoded_reference &)=default
SPARROW_API run_end_encoded_reference(run_end_encoded_array &array, std::size_t index)
SPARROW_API run_end_encoded_reference(run_end_encoded_array &array, std::size_t index, std::size_t run_index)
SPARROW_API bool has_value() const
array_traits::value_type value_type
array_traits::const_reference const_reference
std::ostream & operator<<(std::ostream &stream, primesum::uint128_t n)
The __int128_t type (GCC/Clang) is not well supported by the C++ standard library (in 2016) so we hav...
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.
SPARROW_API bool operator==(const array &lhs, const array &rhs)
Compares the content of two arrays.
constexpr InputIt next(InputIt it, Distance n)
constexpr bool is_run_end_encoded_array_v
Checks whether T is a run_end_encoded_array type.
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.
data_type
Runtime identifier of arrow data types, usually associated with raw bytes with the associated value.
Extensions to the C++ standard library.
mpl::rename< mpl::unique< mpl::transform< detail::array_const_reference_t, all_base_types_t > >, nullable_variant > const_reference
mpl::rename< all_base_types_t, std::variant > inner_value_type
mpl::rename< mpl::transform< detail::array_value_type_t, all_base_types_t >, nullable_variant > value_type
static constexpr sparrow::data_type get()
Metafunction for retrieving the data_type of a typed array.