45 struct get_data_type_from_array;
126 "The storage type must be an integral type of size 4, 8, 16 or 32 bytes"
146 template <
class... Args>
156 template <val
idity_bitmap_input R>
157 [[nodiscard]]
static auto create_proxy(
160 std::size_t precision,
162 std::optional<std::string_view> name = std::nullopt,
163 std::optional<std::string_view> metadata = std::nullopt
166 [[nodiscard]]
static auto create_proxy(
168 std::size_t precision,
170 std::optional<std::string_view> name = std::nullopt,
171 std::optional<std::string_view> metadata = std::nullopt
178 [[nodiscard]] value_iterator value_begin();
179 [[nodiscard]] value_iterator value_end();
186 static constexpr size_type DATA_BUFFER_INDEX = 1;
192 std::size_t m_precision;
207 const auto format = this->get_arrow_proxy().format();
210 if (format.size() < 2 || format[0] !=
'd' || format[1] !=
':')
212 throw std::runtime_error(
"Invalid format string for decimal array");
216 const auto format_str = format.substr(2);
218 std::stringstream ss;
221 ss >> m_precision >> c >> m_scale;
226 throw std::runtime_error(
"Invalid format string for decimal array");
231 auto decimal_array<T>::create_proxy(
233 std::size_t precision,
235 std::optional<std::string_view> name,
236 std::optional<std::string_view> metadata
239 return decimal_array<T>::create_proxy(
240 std::move(data_buffer),
250 template <val
idity_bitmap_input R>
251 auto decimal_array<T>::create_proxy(
254 std::size_t precision,
256 std::optional<std::string_view> name,
257 std::optional<std::string_view> metadata
260 const auto size = data_buffer.size();
262 const auto null_count = bitmap.null_count();
264 constexpr std::size_t sizeof_decimal =
sizeof(storage_type);
265 std::stringstream format_str;
266 format_str <<
"d:" << precision <<
"," << scale <<
"," << sizeof_decimal * 8;
279 std::vector<buffer<uint8_t>> buffers{
280 std::move(bitmap).extract_storage(),
281 std::move(data_buffer).extract_storage()
286 static_cast<std::int64_t
>(size),
287 static_cast<int64_t
>(null_count),
294 return arrow_proxy(std::move(arr), std::move(schema));
298 auto decimal_array<T>::value(size_type i) -> inner_reference
301 const auto ptr = this->get_arrow_proxy().buffers()[DATA_BUFFER_INDEX].template data<const storage_type>();
302 return inner_reference(ptr[i], m_scale);
306 auto decimal_array<T>::value(size_type i)
const -> inner_const_reference
309 const auto ptr = this->get_arrow_proxy().buffers()[DATA_BUFFER_INDEX].template data<const storage_type>();
310 return inner_const_reference(ptr[i], m_scale);
314 auto decimal_array<T>::value_begin() -> value_iterator
320 auto decimal_array<T>::value_end() -> value_iterator
326 auto decimal_array<T>::value_cbegin() const -> const_value_iterator
332 auto decimal_array<T>::value_cend() const -> const_value_iterator
334 return const_value_iterator(
typename base_type::const_bitmap_range const_bitmap_range
typename base_type::iterator_tag iterator_tag
typename base_type::const_bitmap_iterator const_bitmap_iterator
std::conditional_t< is_mutable, mutable_array_base< D >, array_crtp_base< D > > base_type
typename base_type::bitmap_const_reference bitmap_const_reference
typename base_type::bitmap_type bitmap_type
typename base_type::difference_type difference_type
Proxy class over ArrowArray and ArrowSchema.
nullable< inner_const_reference, bitmap_const_reference > const_reference
typename base_type::difference_type difference_type
typename base_type::bitmap_const_reference bitmap_const_reference
array_inner_types< self_type > inner_types
decimal_array(arrow_proxy)
typename inner_types::const_value_iterator const_value_iterator
nullable< inner_value_type > value_type
typename base_type::const_bitmap_iterator const_bitmap_iterator
typename base_type::bitmap_type bitmap_type
typename base_type::const_bitmap_range const_bitmap_range
typename decimal< int32_t >::integer_type storage_type
decimal_array< decimal< int32_t > > self_type
typename inner_types::inner_reference inner_reference
typename inner_types::inner_const_reference inner_const_reference
typename inner_types::inner_value_type inner_value_type
typename base_type::size_type size_type
typename base_type::iterator_tag iterator_tag
array_bitmap_base< self_type > base_type
decimal_array(Args &&... args)
typename inner_types::value_iterator value_iterator
The nullable class models a value or a reference that can be "null", or missing, like values traditio...
#define SPARROW_ASSERT_TRUE(expr__)
constexpr std::size_t size(typelist< T... >={})
constexpr bool excludes_copy_and_move_ctor_v
constexpr bool is_type_instance_of_v
true if T is a concrete type template instanciation of U which is a type template.
constexpr bool is_decimal_array_v
decimal_array< decimal< int128_t > > decimal_128_array
ArrowSchema make_arrow_schema(F format, N name, M metadata, std::optional< ArrowFlag > flags, int64_t n_children, ArrowSchema **children, ArrowSchema *dictionary)
Creates an ArrowSchema owned by a unique_ptr and holding the provided data.
decimal_array< decimal< int32_t > > decimal_32_array
decimal_array< decimal< int64_t > > decimal_64_array
decimal_array< decimal< int256_t > > decimal_256_array
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.
dynamic_bitset< std::uint8_t > validity_bitmap
validity_bitmap ensure_validity_bitmap(std::size_t size, R &&validity_input)
data_type
Runtime identifier of arrow data types, usually associated with raw bytes with the associated value.
ArrowArray make_arrow_array(int64_t length, int64_t null_count, int64_t offset, B buffers, size_t n_children, ArrowArray **children, ArrowArray *dictionary)
Creates an ArrowArray.
std::random_access_iterator_tag iterator_tag
functor_index_iterator< detail::layout_value_functor< const array_type, inner_value_type > > const_value_iterator
decimal_array< T > array_type
bitmap_type::const_reference bitmap_const_reference
nullable< inner_const_reference, bitmap_const_reference > const_reference
functor_index_iterator< detail::layout_value_functor< array_type, inner_value_type > > value_iterator
Base class for array_inner_types specialization.
Traits class that must be specialized by array classes inheriting from array_crtp_base.
static constexpr sparrow::data_type get()
static constexpr sparrow::data_type get()
static constexpr sparrow::data_type get()
static constexpr sparrow::data_type get()