30 template <
bool is_const>
33 run_encoded_array_iterator<is_const>,
34 array_traits::value_type,
35 std::bidirectional_iterator_tag,
36 std::conditional_t<is_const, array_traits::const_reference, run_end_encoded_reference>>
40 using array_ptr_type = std::conditional_t<is_const, const run_end_encoded_array*, run_end_encoded_array*>;
41 using reference_type = std::conditional_t<is_const, array_traits::const_reference, run_end_encoded_reference>;
53 [[nodiscard]] reference_type dereference()
const;
55 array_ptr_type p_array =
nullptr;
56 const array* p_encoded_values_array =
nullptr;
57 std::uint64_t m_index = 0;
58 std::uint64_t m_run_end_index = 0;
59 std::uint64_t m_acc_length_up = 0;
60 std::uint64_t m_acc_length_down = 0;
65 template <
bool is_const>
67 array_ptr_type array_ptr,
69 std::uint64_t run_end_index
72 , p_encoded_values_array(&array_ptr->p_encoded_values_array)
74 , m_run_end_index(run_end_index)
76 m_index < p_array->size() ? p_array->get_acc_length(m_run_end_index) : p_array->m_encoded_length
78 , m_acc_length_down(m_run_end_index == 0 ? 0 : p_array->get_acc_length(m_run_end_index - 1))
82 template <
bool is_const>
85 return m_index == rhs.m_index;
88 template <
bool is_const>
89 void run_encoded_array_iterator<is_const>::increment()
95 m_acc_length_up = p_array->get_acc_length(m_run_end_index);
96 m_acc_length_down = 0;
98 else if (m_index >= p_array->size())
100 m_run_end_index = p_array->m_encoded_length;
102 else if (m_index == m_acc_length_up)
105 m_acc_length_up = p_array->get_acc_length(m_run_end_index);
106 m_acc_length_down = p_array->get_acc_length(m_run_end_index - 1);
110 template <
bool is_const>
111 void run_encoded_array_iterator<is_const>::decrement()
115 m_run_end_index = p_array->m_encoded_length;
117 else if (m_index == p_array->size() || m_index == m_acc_length_down)
120 m_acc_length_up = p_array->get_acc_length(m_run_end_index);
121 m_acc_length_down = m_run_end_index == 0 ? 0 : p_array->get_acc_length(m_run_end_index - 1);
126 template <
bool is_const>
127 auto run_encoded_array_iterator<is_const>::dereference() const -> reference_type
129 if constexpr (is_const)
131 return (*p_encoded_values_array)[
static_cast<std::size_t
>(m_run_end_index)];
135 return reference_type(
137 static_cast<std::size_t
>(m_index),
138 static_cast<std::size_t
>(m_run_end_index)
Dynamically typed array encapsulating an Arrow layout.
run_encoded_array_iterator(array_ptr_type array_ptr, std::uint64_t index, std::uint64_t run_end_index)
run_encoded_array_iterator()=default
friend class iterator_access