sparrow 2.3.1
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Loading...
Searching...
No Matches
fixed_width_binary_array.hpp
Go to the documentation of this file.
1// Copyright 2024 Man Group Operations Limited
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or mplied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <cstddef>
18#include <cstdint>
19#include <iterator>
20#include <optional>
21#include <ranges>
22#include <string>
23#include <type_traits>
24#include <vector>
25
42
43namespace sparrow
44{
45 template <std::ranges::sized_range T, typename CR, typename Ext = empty_extension>
47
49
80 fixed_width_binary_traits::value_type,
81 fixed_width_binary_traits::const_reference>;
82
83 namespace copy_tracker
84 {
85 template <>
86 inline std::string key<fixed_width_binary_array>()
87 {
88 return "fixed_width_binary_array";
89 }
90 }
91
92 template <std::ranges::sized_range T, typename CR, typename Ext>
119
120 namespace detail
121 {
122 template <>
124 {
125 [[nodiscard]] static constexpr sparrow::data_type get()
126 {
128 }
129 };
130 }
131
132 template <std::ranges::sized_range T, class CR, class Ext>
134 : public mutable_array_bitmap_base<fixed_width_binary_array_impl<T, CR, Ext>>,
135 public Ext
136 {
137 private:
138
139 static_assert(
140 sizeof(std::ranges::range_value_t<T>) == sizeof(byte_t),
141 "Only sequences of types with the same size as byte_t are supported"
142 );
143
144 public:
145
148
150 using inner_value_type = typename inner_types::inner_value_type;
151 using inner_reference = typename inner_types::inner_reference;
152 using inner_const_reference = typename inner_types::inner_const_reference;
153
155 using bitmap_reference = typename base_type::bitmap_reference;
158
162
166 using data_iterator = typename inner_types::data_iterator;
167
168 using const_data_iterator = typename inner_types::const_data_iterator;
169 using data_value_type = typename inner_types::data_value_type;
170
171 using value_iterator = typename inner_types::value_iterator;
172 using const_value_iterator = typename inner_types::const_value_iterator;
173
174 using functor_type = typename inner_types::functor_type;
175 using const_functor_type = typename inner_types::const_functor_type;
176
191
193
196
197 self_type& operator=(const self_type&);
198 self_type& operator=(self_type&&) noexcept = default;
199
215 template <class... ARGS>
216 requires(mpl::excludes_copy_and_move_ctor_v<fixed_width_binary_array_impl<T, CR, Ext>, ARGS...>)
218 : base_type(create_proxy(std::forward<ARGS>(args)...))
219 , m_element_size(num_bytes_for_fixed_sized_binary(this->get_arrow_proxy().format()))
220 {
221 }
222
223 using base_type::get_arrow_proxy;
224 using base_type::size;
225
237 [[nodiscard]] constexpr inner_reference value(size_type i);
238
250 [[nodiscard]] constexpr inner_const_reference value(size_type i) const;
251
252 private:
253
275 template <
278 input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
279 [[nodiscard]] static arrow_proxy create_proxy(
280 u8_buffer<C>&& data_buffer,
281 size_t element_count,
282 size_t element_size,
284 std::optional<std::string_view> name = std::nullopt,
285 std::optional<METADATA_RANGE> metadata = std::nullopt
286 );
287
303 template <input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
304 [[nodiscard]] static arrow_proxy create_proxy(
305 size_t element_size,
306 bool nullable = true,
307 std::optional<std::string_view> name = std::nullopt,
308 std::optional<METADATA_RANGE> metadata = std::nullopt
309 );
310
331 template <
332 std::ranges::input_range VALUES,
334 input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
335 requires(
336 std::ranges::input_range<std::ranges::range_value_t<VALUES>>
338 )
339 [[nodiscard]] static arrow_proxy create_proxy(
340 VALUES&& values,
341 VB&& validity_input,
342 std::optional<std::string_view> name = std::nullopt,
343 std::optional<METADATA_RANGE> metadata = std::nullopt
344 );
345
365 template <std::ranges::input_range VALUES, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
366 requires(
367 std::ranges::input_range<std::ranges::range_value_t<VALUES>>
369 )
370 [[nodiscard]] static arrow_proxy create_proxy(
371 VALUES&& values,
372 bool nullable = true,
373 std::optional<std::string_view> name = std::nullopt,
374 std::optional<METADATA_RANGE> metadata = std::nullopt
375 );
376
394 template <std::ranges::input_range NULLABLE_VALUES, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
396 && std::ranges::input_range<typename std::ranges::range_value_t<NULLABLE_VALUES>::value_type>
397 && std::is_same_v<
398 std::ranges::range_value_t<typename std::ranges::range_value_t<NULLABLE_VALUES>::value_type>,
399 byte_t>
400 [[nodiscard]] static arrow_proxy create_proxy(
401 NULLABLE_VALUES&&,
402 std::optional<std::string_view> name = std::nullopt,
403 std::optional<METADATA_RANGE> metadata = std::nullopt
404 );
405
429 template <mpl::char_like C, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
430 [[nodiscard]] static arrow_proxy create_proxy_impl(
431 u8_buffer<C>&& data_buffer,
432 size_t element_count,
433 size_t element_size,
434 std::optional<validity_bitmap>&& validity_input,
435 std::optional<std::string_view> name = std::nullopt,
436 std::optional<METADATA_RANGE> metadata = std::nullopt
437 );
438
439 static constexpr size_t DATA_BUFFER_INDEX = 1;
440
449 [[nodiscard]] constexpr size_type byte_offset(size_type index) const
450 {
451 return (index + static_cast<size_type>(this->get_arrow_proxy().offset())) * m_element_size;
452 }
453
461 [[nodiscard]] constexpr auto& get_data_buffer()
462 {
463 return this->get_arrow_proxy().get_array_private_data()->buffers()[DATA_BUFFER_INDEX];
464 }
465
473 [[nodiscard]] constexpr const auto& get_data_buffer() const
474 {
475 return this->get_arrow_proxy().buffers()[DATA_BUFFER_INDEX];
476 }
477
489 [[nodiscard]] constexpr data_iterator data(size_type i);
490
498 [[nodiscard]] constexpr value_iterator value_begin();
499
507 [[nodiscard]] constexpr value_iterator value_end();
508
516 [[nodiscard]] constexpr const_value_iterator value_cbegin() const;
517
525 [[nodiscard]] constexpr const_value_iterator value_cend() const;
526
538 [[nodiscard]] constexpr const_data_iterator data(size_type i) const;
539
540 // Modifiers
541
558 template <std::ranges::sized_range U>
559 requires mpl::convertible_ranges<U, T>
560 constexpr void resize_values(size_type new_length, U value);
561
581 template <std::ranges::sized_range U>
582 requires mpl::convertible_ranges<U, T>
583 constexpr value_iterator insert_value(const_value_iterator pos, U value, size_type count);
584
610 template <typename InputIt>
611 requires std::input_iterator<InputIt>
612 && mpl::convertible_ranges<typename std::iterator_traits<InputIt>::value_type, T>
613 constexpr value_iterator insert_values(const_value_iterator pos, InputIt first, InputIt last);
614
633 constexpr value_iterator erase_values(const_value_iterator pos, size_type count);
634
651 template <std::ranges::sized_range U>
652 requires mpl::convertible_ranges<U, T>
653 constexpr void assign(U&& rhs, size_type index);
654
655 size_t m_element_size = 0;
656
659 friend base_type;
662 };
663
664 /************************************************
665 * fixed_width_binary_array_impl implementation *
666 ************************************************/
667
668 template <std::ranges::sized_range T, typename CR, typename Ext>
670 : base_type(std::move(proxy))
671 , m_element_size(num_bytes_for_fixed_sized_binary(this->get_arrow_proxy().format()))
672 {
673 SPARROW_ASSERT_TRUE(this->get_arrow_proxy().data_type() == data_type::FIXED_WIDTH_BINARY);
674 }
675
676 template <std::ranges::sized_range T, typename CR, typename Ext>
683
684 template <std::ranges::sized_range T, typename CR, typename Ext>
687 {
690 m_element_size = rhs.m_element_size;
691 return *this;
692 }
693
694 // Move constructor and assignment are defaulted in the class definition
695
696 template <std::ranges::sized_range T, typename CR, typename Ext>
697 template <mpl::char_like C, validity_bitmap_input VB, input_metadata_container METADATA_RANGE>
698 arrow_proxy fixed_width_binary_array_impl<T, CR, Ext>::create_proxy(
699 u8_buffer<C>&& data_buffer,
700 size_t element_count,
701 size_t element_size,
702 VB&& validity_input,
703 std::optional<std::string_view> name,
704 std::optional<METADATA_RANGE> metadata
705 )
706 {
707 validity_bitmap bitmap = ensure_validity_bitmap(element_count, std::forward<VB>(validity_input));
708 return create_proxy_impl(
709 std::move(data_buffer),
710 element_count,
711 element_size,
712 std::move(bitmap),
713 std::move(name),
714 std::move(metadata)
715 );
716 }
717
718 template <std::ranges::sized_range T, typename CR, typename Ext>
719 template <input_metadata_container METADATA_RANGE>
720 arrow_proxy fixed_width_binary_array_impl<T, CR, Ext>::create_proxy(
721 size_t element_size,
722 bool nullable,
723 std::optional<std::string_view> name,
724 std::optional<METADATA_RANGE> metadata
725 )
726 {
727 u8_buffer<char> data_buffer{};
728 std::optional<validity_bitmap> bitmap = nullable ? std::make_optional<validity_bitmap>(
729 nullptr,
730 0,
732 )
733 : std::nullopt;
734 return create_proxy_impl(
735 std::move(data_buffer),
736 0,
737 element_size,
738 std::move(bitmap),
739 std::move(name),
740 std::move(metadata)
741 );
742 }
743
744 template <std::ranges::sized_range T, typename CR, typename Ext>
745 template <std::ranges::input_range R, validity_bitmap_input VB, input_metadata_container METADATA_RANGE>
746 requires(
747 std::ranges::input_range<std::ranges::range_value_t<R>> && // a range of ranges
749 // range of char-like
750 )
751 arrow_proxy fixed_width_binary_array_impl<T, CR, Ext>::create_proxy(
752 R&& values,
753 VB&& validity_input,
754 std::optional<std::string_view> name,
755 std::optional<METADATA_RANGE> metadata
756 )
757 {
758 using values_type = std::ranges::range_value_t<R>;
759 using values_inner_value_type = std::ranges::range_value_t<values_type>;
760
762 const size_t element_size = std::ranges::empty(values) ? 0 : std::ranges::size(*values.begin());
763
764 auto data_buffer = u8_buffer<values_inner_value_type>(std::ranges::views::join(values));
765 return create_proxy(
766 std::move(data_buffer),
767 values.size(),
768 element_size,
769 std::forward<VB>(validity_input),
770 std::forward<std::optional<std::string_view>>(name),
771 std::forward<std::optional<METADATA_RANGE>>(metadata)
772 );
773 }
774
775 template <std::ranges::sized_range T, typename CR, typename Ext>
776 template <std::ranges::input_range R, input_metadata_container METADATA_RANGE>
777 requires(
778 std::ranges::input_range<std::ranges::range_value_t<R>> && // a range of ranges
780 // range of char-like
781 )
782 arrow_proxy fixed_width_binary_array_impl<T, CR, Ext>::create_proxy(
783 R&& values,
784 bool nullable,
785 std::optional<std::string_view> name,
786 std::optional<METADATA_RANGE> metadata
787 )
788 {
789 if (nullable)
790 {
791 return create_proxy(
792 std::forward<R>(values),
794 std::move(name),
795 std::move(metadata)
796 );
797 }
798 else
799 {
800 using values_type = std::ranges::range_value_t<R>;
801 using values_inner_value_type = std::ranges::range_value_t<values_type>;
802
804 const size_t element_size = std::ranges::empty(values) ? 0 : std::ranges::size(*values.begin());
805 auto data_buffer = u8_buffer<values_inner_value_type>(std::ranges::views::join(values));
806 return create_proxy_impl(
807 std::move(data_buffer),
808 values.size(), // element count
809 element_size,
810 std::nullopt, // validity bitmap
811 std::move(name),
812 std::move(metadata)
813 );
814 }
815 }
816
817 template <std::ranges::sized_range T, typename CR, typename Ext>
818 template <std::ranges::input_range NULLABLE_RANGE, input_metadata_container METADATA_RANGE>
820 && std::ranges::input_range<typename std::ranges::range_value_t<NULLABLE_RANGE>::value_type>
821 && std::is_same_v<
822 std::ranges::range_value_t<typename std::ranges::range_value_t<NULLABLE_RANGE>::value_type>,
823 byte_t>
824 arrow_proxy fixed_width_binary_array_impl<T, CR, Ext>::create_proxy(
825 NULLABLE_RANGE&& range,
826 std::optional<std::string_view> name,
827 std::optional<METADATA_RANGE> metadata
828 )
829 {
830 // split into values and is_non_null ranges
831 const auto values = range | std::views::transform(nullable_get);
832 const auto is_non_null = range
833 | std::views::transform(
834 [](const auto& v)
835 {
836 return v.has_value();
837 }
838 );
839 return self_type::create_proxy(values, is_non_null, std::move(name), std::move(metadata));
840 }
841
842 template <std::ranges::sized_range T, typename CR, typename Ext>
843 template <mpl::char_like C, input_metadata_container METADATA_RANGE>
844 arrow_proxy fixed_width_binary_array_impl<T, CR, Ext>::create_proxy_impl(
845 u8_buffer<C>&& data_buffer,
846 size_t element_count,
847 size_t element_size,
848 std::optional<validity_bitmap>&& bitmap,
849 std::optional<std::string_view> name,
850 std::optional<METADATA_RANGE> metadata
851 )
852 {
854 element_size == 0 ? (data_buffer.size() == 0) : (data_buffer.size() % element_size == 0)
855 );
856
857 const auto null_count = bitmap.has_value() ? bitmap->null_count() : 0;
858 std::string format_str = "w:" + std::to_string(element_size);
859 const std::optional<std::unordered_set<ArrowFlag>>
860 flags = bitmap.has_value()
861 ? std::make_optional<std::unordered_set<ArrowFlag>>({ArrowFlag::NULLABLE})
862 : std::nullopt;
863
865 std::move(format_str),
866 std::move(name), // name
867 std::move(metadata), // metadata
868 flags, // flags,
869 nullptr, // children
870 repeat_view<bool>(true, 0), // children_ownership
871 nullptr, // dictionary
872 true // dictionary ownership
873
874 );
875 std::vector<buffer<std::uint8_t>> arr_buffs;
876 arr_buffs.reserve(2);
877 arr_buffs.emplace_back(
878 bitmap.has_value() ? std::move(*bitmap).extract_storage()
879 : buffer<std::uint8_t>{nullptr, 0, validity_bitmap::default_allocator()}
880 );
881 arr_buffs.emplace_back(std::move(data_buffer).extract_storage());
882
884 static_cast<std::int64_t>(element_count), // length
885 static_cast<int64_t>(null_count),
886 0, // offset
887 std::move(arr_buffs),
888 nullptr, // children
889 repeat_view<bool>(true, 0), // children_ownership
890 nullptr, // dictionary
891 true // dictionary ownership
892 );
893 arrow_proxy proxy{std::move(arr), std::move(schema)};
894 Ext::init(proxy);
895 return proxy;
896 }
897
898 template <std::ranges::sized_range T, typename CR, typename Ext>
899 constexpr auto fixed_width_binary_array_impl<T, CR, Ext>::data(size_type i) -> data_iterator
900 {
901 return const_cast<data_iterator>(std::as_const(*this).data(i));
902 }
903
904 template <std::ranges::sized_range T, typename CR, typename Ext>
905 constexpr auto fixed_width_binary_array_impl<T, CR, Ext>::data(size_type i) const -> const_data_iterator
906 {
907 const auto& data_buffer = get_data_buffer();
908 const size_t data_buffer_size = data_buffer.size();
909 const size_type index_offset = (static_cast<size_type>(this->get_arrow_proxy().offset())
910 * m_element_size)
911 + i;
912 SPARROW_ASSERT_TRUE(data_buffer_size >= index_offset);
913 return data_buffer.template data<const data_value_type>() + index_offset;
914 }
915
916 template <std::ranges::sized_range T, typename CR, typename Ext>
917 template <std::ranges::sized_range U>
919 constexpr void fixed_width_binary_array_impl<T, CR, Ext>::assign(U&& rhs, size_type index)
920 {
921 SPARROW_ASSERT_TRUE(std::ranges::size(rhs) == m_element_size);
922 SPARROW_ASSERT_TRUE(index < size());
923 std::copy(std::ranges::begin(rhs), std::ranges::end(rhs), data(index * m_element_size));
924 }
925
926 template <std::ranges::sized_range T, typename CR, typename Ext>
928 {
929 SPARROW_ASSERT_TRUE(i < size());
930 return inner_reference(this, i);
931 }
932
933 template <std::ranges::sized_range T, typename CR, typename Ext>
935 {
936 SPARROW_ASSERT_TRUE(i < this->size());
937 const auto offset_begin = i * m_element_size;
938 const auto offset_end = offset_begin + m_element_size;
939 const const_data_iterator pointer_begin = data(static_cast<size_type>(offset_begin));
940 const const_data_iterator pointer_end = data(static_cast<size_type>(offset_end));
941 return inner_const_reference(pointer_begin, pointer_end);
942 }
943
944 template <std::ranges::sized_range T, typename CR, typename Ext>
945 constexpr auto fixed_width_binary_array_impl<T, CR, Ext>::value_begin() -> value_iterator
946 {
947 return value_iterator{functor_type{&(this->derived_cast())}, 0};
948 }
949
950 template <std::ranges::sized_range T, typename CR, typename Ext>
951 constexpr auto fixed_width_binary_array_impl<T, CR, Ext>::value_end() -> value_iterator
952 {
953 return sparrow::next(value_begin(), size());
954 }
955
956 template <std::ranges::sized_range T, typename CR, typename Ext>
957 constexpr auto fixed_width_binary_array_impl<T, CR, Ext>::value_cbegin() const -> const_value_iterator
958 {
959 return const_value_iterator{const_functor_type{&(this->derived_cast())}, 0};
960 }
961
962 template <std::ranges::sized_range T, typename CR, typename Ext>
963 constexpr auto fixed_width_binary_array_impl<T, CR, Ext>::value_cend() const -> const_value_iterator
964 {
965 return sparrow::next(value_cbegin(), this->size());
966 }
967
968 template <std::ranges::sized_range T, typename CR, typename Ext>
969 template <std::ranges::sized_range U>
971 constexpr void fixed_width_binary_array_impl<T, CR, Ext>::resize_values(size_type new_length, U value)
972 {
973 SPARROW_ASSERT_TRUE(m_element_size == value.size());
974 if (new_length < size())
975 {
976 const size_t new_size = new_length + static_cast<size_t>(this->get_arrow_proxy().offset());
977 const auto offset = new_size * m_element_size;
978 auto& data_buffer = get_data_buffer();
979 data_buffer.resize(offset);
980 }
981 else if (new_length > size())
982 {
983 insert_value(value_cend(), value, new_length - size());
984 }
985 }
986
987 template <std::ranges::sized_range T, typename CR, typename Ext>
988 template <std::ranges::sized_range U>
990 constexpr auto
991 fixed_width_binary_array_impl<T, CR, Ext>::insert_value(const_value_iterator pos, U value, size_type count)
993 {
994 SPARROW_ASSERT_TRUE(m_element_size == value.size());
995 const auto idx = static_cast<size_t>(std::distance(value_cbegin(), pos));
996
997 const uint8_t* uint8_ptr = reinterpret_cast<const uint8_t*>(value.data());
998 const std::vector<uint8_t> casted_value(uint8_ptr, uint8_ptr + value.size());
999 const auto my_repeat_view = repeat_view{casted_value, count};
1000 const auto joined_repeated_value_range = std::ranges::views::join(my_repeat_view);
1001 auto& data_buffer = get_data_buffer();
1002 const auto offset_begin = byte_offset(idx);
1003 const auto pos_to_insert = sparrow::next(data_buffer.cbegin(), offset_begin);
1004 data_buffer.insert(pos_to_insert, joined_repeated_value_range.begin(), joined_repeated_value_range.end());
1005 return sparrow::next(value_begin(), idx);
1006 }
1007
1008 template <std::ranges::sized_range T, typename CR, typename Ext>
1009 template <typename InputIt>
1010 requires std::input_iterator<InputIt>
1012 constexpr auto
1013 fixed_width_binary_array_impl<T, CR, Ext>::insert_values(const_value_iterator pos, InputIt first, InputIt last)
1015 {
1016 SPARROW_ASSERT_TRUE(value_cbegin() <= pos)
1017 SPARROW_ASSERT_TRUE(pos <= value_cend());
1018 SPARROW_ASSERT_TRUE(first <= last);
1019 SPARROW_ASSERT_TRUE(all_same_size(std::ranges::subrange(first, last)));
1020 SPARROW_ASSERT_TRUE(m_element_size == std::ranges::size(*first));
1021
1022 auto values = std::ranges::subrange(first, last);
1023 const size_t cumulative_sizes = values.size() * m_element_size;
1024 auto& data_buffer = get_data_buffer();
1025 data_buffer.resize(data_buffer.size() + cumulative_sizes);
1026 const auto idx = static_cast<size_t>(std::distance(value_cbegin(), pos));
1027 sequence_view<byte_t> casted_values{reinterpret_cast<byte_t*>(data_buffer.data()), data_buffer.size()};
1028 const auto offset_begin = byte_offset(idx);
1029 auto insert_pos = sparrow::next(casted_values.begin(), offset_begin);
1030
1031 // Move elements to make space for the new value
1032 std::move_backward(
1033 insert_pos,
1034 sparrow::next(casted_values.end(), -static_cast<difference_type>(cumulative_sizes)),
1035 casted_values.end()
1036 );
1037
1038 for (const auto& val : values)
1039 {
1040 std::copy(val.begin(), val.end(), insert_pos);
1041 std::advance(insert_pos, m_element_size);
1042 }
1043 return sparrow::next(value_begin(), idx);
1044 }
1045
1046 template <std::ranges::sized_range T, typename CR, typename Ext>
1047 constexpr auto
1048 fixed_width_binary_array_impl<T, CR, Ext>::erase_values(const_value_iterator pos, size_type count)
1049 -> value_iterator
1050 {
1051 SPARROW_ASSERT_TRUE(pos >= value_cbegin());
1052 SPARROW_ASSERT_TRUE(pos <= value_cend());
1053 const size_t index = static_cast<size_t>(std::distance(value_cbegin(), pos));
1054 if (count == 0)
1055 {
1056 return sparrow::next(value_begin(), index);
1057 }
1058 auto& data_buffer = get_data_buffer();
1059 const size_type byte_count = m_element_size * count;
1060 const auto offset_begin = byte_offset(index);
1061 const auto offset_end = offset_begin + byte_count;
1062 // move the values after the erased ones
1063 std::move(
1064 data_buffer.begin() + static_cast<difference_type>(offset_end),
1065 data_buffer.end(),
1066 data_buffer.begin() + static_cast<difference_type>(offset_begin)
1067 );
1068 data_buffer.resize(data_buffer.size() - byte_count);
1069 return sparrow::next(value_begin(), index);
1070 }
1071}
typename base_type::const_bitmap_range const_bitmap_range
typename base_type::iterator_tag iterator_tag
constexpr array_bitmap_base_impl & operator=(const array_bitmap_base_impl &)
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
typename storage_type::default_allocator default_allocator
fixed_width_binary_array_impl(arrow_proxy)
Constructs fixed-width binary array from Arrow proxy.
constexpr inner_reference value(size_type i)
Gets mutable reference to element at specified index.
fixed_width_binary_array_impl(self_type &&) noexcept=default
Move constructor.
constexpr inner_const_reference value(size_type i) const
Gets const reference to element at specified index.
A view that repeats a value a given number of times.
The class sequence_view describes an object that can refer to a constant contiguous sequence of T wit...
This buffer class is used as storage buffer for all sparrow arrays.
Concept for input containers that can provide metadata pairs.
Definition metadata.hpp:332
Concept for character-like types.
Concept for convertible range types.
Definition mp_utils.hpp:931
Concept defining valid input types for validity bitmap creation.
#define SPARROW_ASSERT_TRUE(expr__)
SPARROW_API void increase(const std::string &key)
std::string key()
Definition buffer.hpp:49
constexpr std::size_t size(typelist< T... >={})
Gets the count of types contained in a typelist.
Definition mp_utils.hpp:216
constexpr bool is_type_instance_of_v
Variable template for convenient access to is_type_instance_of.
Definition mp_utils.hpp:102
array_bitmap_base_impl< D, true > mutable_array_bitmap_base
Convenient alias for arrays with mutable validity bitmaps.
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.
std::byte byte_t
constexpr bool all_same_size(const Range &range)
Definition ranges.hpp:49
arrow_traits< std::vector< byte_t > > fixed_width_binary_traits
constexpr InputIt next(InputIt it, Distance n)
Definition iterator.hpp:605
constexpr nullable_get_fn nullable_get
Definition nullable.hpp:102
fixed_width_binary_array_impl< fixed_width_binary_traits::value_type, fixed_width_binary_traits::const_reference > fixed_width_binary_array
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
Type alias for a validity bitmap using 8-bit storage blocks.
SPARROW_API std::size_t num_bytes_for_fixed_sized_binary(std::string_view format)
Get the number of bytes for a fixed width binary layout from the ArrowArray format string.
validity_bitmap ensure_validity_bitmap(std::size_t size, R &&validity_input)
Ensures a validity bitmap of the specified size from various input types.
repeat_view(T &, size_t) -> repeat_view< T & >
data_type
Runtime identifier of arrow data types, usually associated with raw bytes with the associated value.
Extensions to the C++ standard library.
detail::layout_value_functor< array_type, inner_reference > functor_type
detail::layout_value_functor< const array_type, inner_const_reference > const_functor_type
Base class for array_inner_types specializations.
Traits class that must be specialized by array implementations.
Provides compile-time information about Arrow data types.
Metafunction for retrieving the data_type of a typed array.