36 template <decimal_type T>
47 struct get_data_type_from_array;
87 template <decimal_type T>
110 template <decimal_type T>
128 "The storage type must be an integral type of size 4, 8, 16 or 32 bytes"
148 template <
class... Args>
159 std::ranges::input_range VALUE_RANGE,
162 requires std::convertible_to<std::ranges::range_value_t<VALUE_RANGE>,
typename T::integer_type>
163 [[nodiscard]]
static auto create_proxy(
165 VALIDITY_RANGE&& bitmaps,
166 std::size_t precision,
168 std::optional<std::string_view> name = std::nullopt,
169 std::optional<METADATA_RANGE> metadata = std::nullopt
173 std::ranges::input_range NULLABLE_VALUE_RANGE,
176 [[nodiscard]]
static auto create_proxy(
177 NULLABLE_VALUE_RANGE&& range,
178 std::size_t precision,
180 std::optional<std::string_view> name = std::nullopt,
181 std::optional<METADATA_RANGE> metadata = std::nullopt
184 template <val
idity_bitmap_input R, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
185 [[nodiscard]]
static auto create_proxy(
188 std::size_t precision,
190 std::optional<std::string_view> name = std::nullopt,
191 std::optional<METADATA_RANGE> metadata = std::nullopt
194 template <input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
195 [[nodiscard]]
static auto create_proxy(
197 std::size_t precision,
199 std::optional<std::string_view> name = std::nullopt,
200 std::optional<METADATA_RANGE> metadata = std::nullopt
207 [[nodiscard]] value_iterator value_begin();
208 [[nodiscard]] value_iterator value_end();
215 static constexpr size_type DATA_BUFFER_INDEX = 1;
221 std::size_t m_precision;
229 template <decimal_type T>
236 const auto format = this->get_arrow_proxy().format();
239 if (format.size() < 2 || format[0] !=
'd' || format[1] !=
':')
241 throw std::runtime_error(
"Invalid format string for decimal array");
245 const auto format_str = format.substr(2);
247 std::stringstream ss;
250 ss >> m_precision >> c >> m_scale;
255 throw std::runtime_error(
"Invalid format string for decimal array");
259 template <decimal_type T>
260 template <std::ranges::input_range VALUE_RANGE, val
idity_bitmap_input VALIDITY_RANGE, input_metadata_container METADATA_RANGE>
261 requires std::convertible_to<std::ranges::range_value_t<VALUE_RANGE>,
typename T::integer_type>
264 VALIDITY_RANGE&& bitmaps,
265 std::size_t precision,
267 std::optional<std::string_view> name,
268 std::optional<METADATA_RANGE> metadata
273 std::move(u8_data_buffer),
274 std::forward<VALIDITY_RANGE>(bitmaps),
282 template <decimal_type T>
283 template <std::ranges::input_range NULLABLE_VALUE_RANGE, input_metadata_container METADATA_RANGE>
286 NULLABLE_VALUE_RANGE&& range,
287 std::size_t precision,
289 std::optional<std::string_view> name,
290 std::optional<METADATA_RANGE> metadata
294 | std::views::transform(
300 auto is_non_null = range
301 | std::views::transform(
304 return v.has_value();
307 return create_proxy(values, is_non_null, precision, scale, std::move(name), std::move(metadata));
310 template <decimal_type T>
311 template <input_metadata_container METADATA_RANGE>
312 auto decimal_array<T>::create_proxy(
314 std::size_t precision,
316 std::optional<std::string_view> name,
317 std::optional<METADATA_RANGE> metadata
320 return decimal_array<T>::create_proxy(
321 std::move(data_buffer),
330 template <decimal_type T>
331 template <val
idity_bitmap_input R, input_metadata_container METADATA_RANGE>
332 auto decimal_array<T>::create_proxy(
335 std::size_t precision,
337 std::optional<std::string_view> name,
338 std::optional<METADATA_RANGE> metadata
341 const auto size = data_buffer.size();
343 const auto null_count = bitmap.null_count();
345 constexpr std::size_t sizeof_decimal =
sizeof(storage_type);
346 std::stringstream format_str;
347 format_str <<
"d:" << precision <<
"," << scale <<
"," << sizeof_decimal * 8;
361 std::vector<buffer<uint8_t>> buffers{
362 std::move(bitmap).extract_storage(),
363 std::move(data_buffer).extract_storage()
368 static_cast<std::int64_t
>(size),
369 static_cast<int64_t
>(null_count),
377 return arrow_proxy(std::move(arr), std::move(schema));
380 template <decimal_type T>
381 auto decimal_array<T>::value(size_type i) -> inner_reference
384 const auto ptr = this->get_arrow_proxy().buffers()[DATA_BUFFER_INDEX].template data<const storage_type>();
385 return inner_reference(ptr[i], m_scale);
388 template <decimal_type T>
389 auto decimal_array<T>::value(size_type i)
const -> inner_const_reference
392 const auto ptr = this->get_arrow_proxy().buffers()[DATA_BUFFER_INDEX].template data<const storage_type>();
393 return inner_const_reference(ptr[i], m_scale);
396 template <decimal_type T>
397 auto decimal_array<T>::value_begin() -> value_iterator
402 template <decimal_type T>
403 auto decimal_array<T>::value_end() -> value_iterator
408 template <decimal_type T>
409 auto decimal_array<T>::value_cbegin() const -> const_value_iterator
414 template <decimal_type T>
415 auto decimal_array<T>::value_cend() const -> const_value_iterator
417 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 T::integer_type storage_type
decimal_array< 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...
A view that repeats a value a given number of times.
This buffer class is use as storage buffer for all sparrow arrays.
#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
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.
decimal_array< decimal< int128_t > > decimal_128_array
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.
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)
data_type
Runtime identifier of arrow data types, usually associated with raw bytes with the associated value.
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()