sparrow 2.3.1
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Loading...
Searching...
No Matches
dictionary_encoded_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 <optional>
18
19#include "sparrow/array_api.hpp"
36
37namespace sparrow
38{
45 template <class Layout, bool is_const>
47 {
48 public:
49
50 using layout_type = Layout;
51 using storage_type = std::conditional_t<is_const, const layout_type*, layout_type>;
52 using return_type = std::
53 conditional_t<is_const, typename layout_type::const_reference, typename layout_type::reference>;
54
58 constexpr layout_element_functor() = default;
59
65 constexpr explicit layout_element_functor(storage_type layout_)
66 : p_layout(layout_)
67 {
68 }
69
76 [[nodiscard]] constexpr return_type operator()(std::size_t i) const
77 {
78 return p_layout->operator[](i);
79 }
80
81 private:
82
84 storage_type p_layout;
85 };
86
92 template <std::integral IT>
93 class dictionary_encoded_array;
94
95 namespace copy_tracker
96 {
97 template <typename T>
99 std::string key()
100 {
101 return "dictionary_encoded_array";
102 }
103 }
104
105 namespace detail
106 {
107 template <std::integral IT>
109 {
115 [[nodiscard]] static constexpr sparrow::data_type get() noexcept
116 {
118 }
119 };
120
126 template <std::integral IT>
128 {
134 [[nodiscard]] static constexpr bool get() noexcept
135 {
136 return true;
137 }
138 };
139 }
140
146 template <class T>
148
159 template <std::integral IT>
161 {
162 public:
163
165 using size_type = std::size_t;
166 using difference_type = std::ptrdiff_t;
167
169
173
176
178 using reverse_iterator = std::reverse_iterator<iterator>;
180 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
181
183
190
196 constexpr dictionary_encoded_array(const self_type& other);
197
204 constexpr self_type& operator=(const self_type& other);
205
212
219 constexpr self_type& operator=(self_type&& other);
220
226 [[nodiscard]] constexpr std::optional<std::string_view> name() const;
227
233 [[nodiscard]] std::optional<key_value_view> metadata() const;
234
240 [[nodiscard]] constexpr size_type size() const;
241
247 [[nodiscard]] constexpr bool empty() const;
248
256
262 [[nodiscard]] constexpr iterator begin();
263
269 [[nodiscard]] constexpr iterator end();
270
276 [[nodiscard]] constexpr const_iterator begin() const;
277
283 [[nodiscard]] constexpr const_iterator end() const;
284
290 [[nodiscard]] constexpr const_iterator cbegin() const;
291
297 [[nodiscard]] constexpr const_iterator cend() const;
298
304 [[nodiscard]] constexpr reverse_iterator rbegin();
305
311 [[nodiscard]] constexpr reverse_iterator rend();
312
318 [[nodiscard]] constexpr const_reverse_iterator rbegin() const;
319
325 [[nodiscard]] constexpr const_reverse_iterator rend() const;
326
332 [[nodiscard]] constexpr const_reverse_iterator crbegin() const;
333
339 [[nodiscard]] constexpr const_reverse_iterator crend() const;
340
347
354
361 template <class... Args>
363 explicit dictionary_encoded_array(Args&&... args)
364 : dictionary_encoded_array(create_proxy(std::forward<Args>(args)...))
365 {
366 }
367
377 [[nodiscard]] constexpr self_type slice(size_type start, size_type end) const;
378
388 [[nodiscard]] constexpr self_type slice_view(size_type start, size_type end) const;
389
397 constexpr void slice_inplace(size_type start, size_type end);
398
402 [[nodiscard]] constexpr size_type offset() const;
403
404 private:
405
418 template <
420 input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
421 [[nodiscard]] static auto create_proxy(
422 keys_buffer_type&& keys,
423 array&& values,
424 R&& bitmaps,
425 std::optional<std::string_view> name = std::nullopt,
426 std::optional<METADATA_RANGE> metadata = std::nullopt
427 ) -> arrow_proxy;
428
441 template <
443 input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
444 [[nodiscard]] static auto create_proxy(
445 keys_buffer_type&& keys,
446 array&& values,
447 bool nullable = true,
448 std::optional<std::string_view> name = std::nullopt,
449 std::optional<METADATA_RANGE> metadata = std::nullopt
450 ) -> arrow_proxy;
451
463 template <input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
464 [[nodiscard]] static auto create_proxy_impl(
465 keys_buffer_type&& keys,
466 array&& values,
467 std::optional<validity_bitmap> validity = std::nullopt,
468 std::optional<std::string_view> name = std::nullopt,
469 std::optional<METADATA_RANGE> metadata = std::nullopt
470 ) -> arrow_proxy;
471
485 template <
486 std::ranges::input_range KEY_RANGE,
488 input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
489 requires(
490 !std::same_as<KEY_RANGE, keys_buffer_type>
491 and std::same_as<IT, std::ranges::range_value_t<KEY_RANGE>>
492 )
493 [[nodiscard]] static arrow_proxy create_proxy(
494 KEY_RANGE&& keys,
495 array&& values,
497 std::optional<std::string_view> name = std::nullopt,
498 std::optional<METADATA_RANGE> metadata = std::nullopt
499 )
500 {
501 keys_buffer_type keys_buffer(std::forward<KEY_RANGE>(keys));
502 return create_proxy(
503 std::move(keys_buffer),
504 std::forward<array>(values),
505 std::forward<R>(bitmaps),
506 std::move(name),
507 std::move(metadata)
508 );
509 }
510
522 template <
523 std::ranges::input_range NULLABLE_KEY_RANGE,
524 input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
525 requires std::is_same_v<std::ranges::range_value_t<NULLABLE_KEY_RANGE>, nullable<IT>>
526 static arrow_proxy create_proxy(
527 NULLABLE_KEY_RANGE&& nullable_keys,
528 array&& values,
529 std::optional<std::string_view> name = std::nullopt,
530 std::optional<METADATA_RANGE> metadata = std::nullopt
531 );
532
533 using keys_layout = primitive_array<IT>;
534 using values_layout = cloning_ptr<array_wrapper>;
540 [[nodiscard]] const inner_value_type& dummy_inner_value() const;
541
547 [[nodiscard]] const_reference dummy_const_reference() const;
548
555 [[nodiscard]] static constexpr keys_layout create_keys_layout(arrow_proxy& proxy);
556
563 [[nodiscard]] static values_layout create_values_layout(arrow_proxy& proxy);
564
570 [[nodiscard]] constexpr arrow_proxy& get_arrow_proxy();
571
577 [[nodiscard]] constexpr const arrow_proxy& get_arrow_proxy() const;
578
580 arrow_proxy m_proxy;
582 keys_layout m_keys_layout;
584 values_layout p_values_layout;
585
587 };
588
597 template <class IT>
598 constexpr bool operator==(const dictionary_encoded_array<IT>& lhs, const dictionary_encoded_array<IT>& rhs);
599
600 /*******************************************
601 * dictionary_encoded_array implementation *
602 *******************************************/
603
604 template <std::integral IT>
606 : m_proxy(std::move(proxy))
607 , m_keys_layout(create_keys_layout(m_proxy))
608 , p_values_layout(create_values_layout(m_proxy))
609 {
610 SPARROW_ASSERT_TRUE(data_type_is_integer(m_proxy.data_type()));
611 }
612
613 template <std::integral IT>
615 : m_proxy(rhs.m_proxy)
616 , m_keys_layout(create_keys_layout(m_proxy))
617 , p_values_layout(create_values_layout(m_proxy))
618 {
620 }
621
622 template <std::integral IT>
624 {
626 if (this != &rhs)
627 {
628 m_proxy = rhs.m_proxy;
629 m_keys_layout = create_keys_layout(m_proxy);
630 p_values_layout = create_values_layout(m_proxy);
631 }
632 return *this;
633 }
634
635 template <std::integral IT>
637 : m_proxy(std::move(rhs.m_proxy))
638 , m_keys_layout(create_keys_layout(m_proxy))
639 , p_values_layout(create_values_layout(m_proxy))
640 {
641 }
642
643 template <std::integral IT>
645 {
646 if (this != &rhs)
647 {
648 using std::swap;
649 swap(m_proxy, rhs.m_proxy);
650 m_keys_layout = create_keys_layout(m_proxy);
651 p_values_layout = create_values_layout(m_proxy);
652 }
653 return *this;
654 }
655
656 template <std::integral IT>
657 template <validity_bitmap_input VBI, input_metadata_container METADATA_RANGE>
658 auto dictionary_encoded_array<IT>::create_proxy(
659 keys_buffer_type&& keys,
660 array&& values,
661 VBI&& validity_input,
662 std::optional<std::string_view> name,
663 std::optional<METADATA_RANGE> metadata
664 ) -> arrow_proxy
665 {
666 const auto size = keys.size();
667 validity_bitmap vbitmap = ensure_validity_bitmap(size, std::forward<VBI>(validity_input));
668 return create_proxy_impl(
669 std::forward<keys_buffer_type>(keys),
670 std::forward<array>(values),
671 std::make_optional<validity_bitmap>(std::move(vbitmap)),
672 std::move(name),
673 std::move(metadata)
674 );
675 }
676
677 template <std::integral IT>
678 template <validity_bitmap_input VBI, input_metadata_container METADATA_RANGE>
679 auto dictionary_encoded_array<IT>::create_proxy(
680 keys_buffer_type&& keys,
681 array&& values,
682 bool nullable,
683 std::optional<std::string_view> name,
684 std::optional<METADATA_RANGE> metadata
685 ) -> arrow_proxy
686 {
687 const auto size = keys.size();
688 return create_proxy_impl(
689 std::forward<keys_buffer_type>(keys),
690 std::forward<array>(values),
691 nullable ? std::make_optional<validity_bitmap>(nullptr, size, validity_bitmap::default_allocator())
692 : std::nullopt,
693 std::move(name),
694 std::move(metadata)
695 );
696 }
697
698 template <std::integral IT>
699 template <input_metadata_container METADATA_RANGE>
700 [[nodiscard]] arrow_proxy dictionary_encoded_array<IT>::create_proxy_impl(
701 keys_buffer_type&& keys,
702 array&& values,
703 std::optional<validity_bitmap> validity,
704 std::optional<std::string_view> name,
705 std::optional<METADATA_RANGE> metadata
706 )
707 {
708 const auto size = keys.size();
709 auto [value_array, value_schema] = extract_arrow_structures(std::move(values));
710 static const repeat_view<bool> children_ownership{true, 0};
711
712 const std::optional<std::unordered_set<sparrow::ArrowFlag>>
713 flags = validity.has_value()
714 ? std::make_optional<std::unordered_set<sparrow::ArrowFlag>>({ArrowFlag::NULLABLE})
715 : std::nullopt;
716
717 // create arrow schema and array
720 std::move(name), // name
721 std::move(metadata), // metadata
722 flags, // flags
723 nullptr, // children
724 children_ownership, // children_ownership
725 new ArrowSchema(std::move(value_schema)), // dictionary
726 true // dictionary ownership
727 );
728
729 const size_t null_count = validity.has_value() ? validity->null_count() : 0;
730
731 std::vector<buffer<uint8_t>> buffers;
732 buffers.reserve(2);
733 buffers.emplace_back(
734 validity.has_value() ? std::move(*validity).extract_storage()
735 : buffer<uint8_t>{nullptr, 0, buffer<uint8_t>::default_allocator()}
736 );
737 buffers.emplace_back(std::move(keys).extract_storage());
738 // create arrow array
740 static_cast<std::int64_t>(size), // length
741 static_cast<std::int64_t>(null_count), // Null count
742 0, // offset
743 std::move(buffers),
744 nullptr, // children
745 children_ownership, // children_ownership
746 new ArrowArray(std::move(value_array)), // dictionary
747 true // dictionary ownership
748 );
749 return arrow_proxy(std::move(arr), std::move(schema));
750 }
751
752 template <std::integral IT>
753 template <std::ranges::input_range NULLABLE_KEY_RANGE, input_metadata_container METADATA_RANGE>
754 requires std::is_same_v<std::ranges::range_value_t<NULLABLE_KEY_RANGE>, nullable<IT>>
755 arrow_proxy dictionary_encoded_array<IT>::create_proxy(
756 NULLABLE_KEY_RANGE&& nullable_keys,
757 array&& values,
758 std::optional<std::string_view> name,
759 std::optional<METADATA_RANGE> metadata
760 )
761 {
762 auto keys = nullable_keys | std::views::transform(nullable_get);
763 auto is_non_null = nullable_keys
764 | std::views::transform(
765 [](const auto& v)
766 {
767 return v.has_value();
768 }
769 );
770 return create_proxy(
771 std::move(keys),
772 std::forward<array>(values),
773 std::move(is_non_null),
774 std::move(name),
775 std::move(metadata)
776 );
777 }
778
779 template <std::integral IT>
780 constexpr std::optional<std::string_view> dictionary_encoded_array<IT>::name() const
781 {
782 return m_proxy.name();
783 }
784
785 template <std::integral IT>
786 std::optional<key_value_view> dictionary_encoded_array<IT>::metadata() const
787 {
788 return m_proxy.metadata();
789 }
790
791 template <std::integral IT>
793 {
794 return m_proxy.length();
795 }
796
797 template <std::integral IT>
798 constexpr auto dictionary_encoded_array<IT>::empty() const -> bool
799 {
800 return size() == 0;
801 }
802
803 template <std::integral IT>
805 {
807 const auto index = m_keys_layout[i];
808
809 if (index.has_value())
810 {
811 SPARROW_ASSERT_TRUE(index.value() >= 0);
812 return array_element(*p_values_layout, static_cast<std::size_t>(index.value()));
813 }
814 else
815 {
816 return dummy_const_reference();
817 }
818 }
819
820 template <std::integral IT>
822 {
823 return iterator(functor_type(this), 0u);
824 }
825
826 template <std::integral IT>
828 {
829 return iterator(functor_type(this), size());
830 }
831
832 template <std::integral IT>
834 {
835 return cbegin();
836 }
837
838 template <std::integral IT>
840 {
841 return cend();
842 }
843
844 template <std::integral IT>
846 {
847 return const_iterator(const_functor_type(this), 0u);
848 }
849
850 template <std::integral IT>
852 {
853 return const_iterator(const_functor_type(this), size());
854 }
855
856 template <std::integral IT>
858 {
859 return reverse_iterator(end());
860 }
861
862 template <std::integral IT>
863 [[nodiscard]] constexpr auto dictionary_encoded_array<IT>::rend() -> reverse_iterator
864 {
865 return reverse_iterator(begin());
866 }
867
868 template <std::integral IT>
869 [[nodiscard]] constexpr auto dictionary_encoded_array<IT>::rbegin() const -> const_reverse_iterator
870 {
872 }
873
874 template <std::integral IT>
875 [[nodiscard]] constexpr auto dictionary_encoded_array<IT>::rend() const -> const_reverse_iterator
876 {
878 }
879
880 template <std::integral IT>
881 [[nodiscard]] constexpr auto dictionary_encoded_array<IT>::crbegin() const -> const_reverse_iterator
882 {
883 return rbegin();
884 }
885
886 template <std::integral IT>
887 [[nodiscard]] constexpr auto dictionary_encoded_array<IT>::crend() const -> const_reverse_iterator
888 {
889 return rend();
890 }
891
892 template <std::integral IT>
898
899 template <std::integral IT>
905
906 template <std::integral IT>
907 auto dictionary_encoded_array<IT>::dummy_inner_value() const -> const inner_value_type&
908 {
909 static const inner_value_type instance = array_default_element_value(*p_values_layout);
910 return instance;
911 }
912
913 template <std::integral IT>
915 {
916 SPARROW_ASSERT_TRUE(start <= end);
917 return self_type{get_arrow_proxy().slice(start, end)};
918 }
919
920 template <std::integral IT>
922 {
923 SPARROW_ASSERT_TRUE(start <= end);
924 return self_type{get_arrow_proxy().slice_view(start, end)};
925 }
926
927 template <std::integral IT>
929 {
930 SPARROW_ASSERT_TRUE(start <= end);
931 get_arrow_proxy().slice_inplace(start, end);
932 }
933
934 template <std::integral IT>
936 {
937 return static_cast<size_type>(get_arrow_proxy().offset());
938 }
939
940 /*template <std::integral IT>
941 auto dictionary_encoded_array<IT>::dummy_inner_const_reference() const -> inner_const_reference
942 {
943 static const inner_const_reference instance =
944 std::visit([](const auto& val) -> inner_const_reference { return val; }, dummy_inner_value());
945 return instance;
946 }*/
947
948 template <std::integral IT>
949 auto dictionary_encoded_array<IT>::dummy_const_reference() const -> const_reference
950 {
951 static const const_reference instance = std::visit(
952 [](const auto& val) -> const_reference
953 {
954 using inner_ref = typename arrow_traits<std::decay_t<decltype(val)>>::const_reference;
955 return const_reference{nullable<inner_ref>(inner_ref(val), false)};
956 },
957 dummy_inner_value()
958 );
959 return instance;
960 }
961
962 template <std::integral IT>
963 typename dictionary_encoded_array<IT>::values_layout
964 dictionary_encoded_array<IT>::create_values_layout(arrow_proxy& proxy)
965 {
966 const auto& dictionary = proxy.dictionary();
967 SPARROW_ASSERT_TRUE(dictionary);
968 arrow_proxy ar_dictionary{&(dictionary->array()), &(dictionary->schema())};
969 return array_factory(std::move(ar_dictionary));
970 }
971
972 template <std::integral IT>
973 constexpr auto dictionary_encoded_array<IT>::create_keys_layout(arrow_proxy& proxy) -> keys_layout
974 {
975 return keys_layout{arrow_proxy{&proxy.array(), &proxy.schema()}};
976 }
977
978 template <std::integral IT>
979 constexpr auto dictionary_encoded_array<IT>::get_arrow_proxy() -> arrow_proxy&
980 {
981 return m_proxy;
982 }
983
984 template <std::integral IT>
985 constexpr auto dictionary_encoded_array<IT>::get_arrow_proxy() const -> const arrow_proxy&
986 {
987 return m_proxy;
988 }
989
990 template <class IT>
992 {
993 return std::ranges::equal(lhs, rhs);
994 }
995}
996
997#if defined(__cpp_lib_format)
998template <std::integral IT>
999struct std::formatter<sparrow::dictionary_encoded_array<IT>>
1000{
1001 constexpr auto parse(std::format_parse_context& ctx)
1002 {
1003 return ctx.begin(); // Simple implementation
1004 }
1005
1006 auto format(const sparrow::dictionary_encoded_array<IT>& ar, std::format_context& ctx) const
1007 {
1008 std::format_to(ctx.out(), "Dictionary [size={}] <", ar.size());
1009 std::for_each(
1010 ar.cbegin(),
1011 std::prev(ar.cend()),
1012 [&ctx](const auto& value)
1013 {
1014 std::format_to(ctx.out(), "{}, ", value);
1015 }
1016 );
1017 std::format_to(ctx.out(), "{}>", ar.back());
1018 return ctx.out();
1019 }
1020};
1021
1022namespace sparrow
1023{
1024 template <std::integral IT>
1025 std::ostream& operator<<(std::ostream& os, const dictionary_encoded_array<IT>& value)
1026 {
1027 os << std::format("{}", value);
1028 return os;
1029 }
1030}
1031
1032#endif
Dynamically typed array encapsulating an Arrow layout.
Definition array_api.hpp:50
Object that owns a piece of contiguous memory.
Definition buffer.hpp:131
Forward declaration of dictionary_encoded_array.
constexpr iterator begin()
Gets an iterator to the beginning of the array.
functor_index_iterator< const_functor_type > const_iterator
SPARROW_CONSTEXPR_CLANG const_reference operator[](size_type i) const
Access operator for getting element at index.
constexpr self_type & operator=(const self_type &other)
Copy assignment operator.
constexpr const_reverse_iterator crbegin() const
Gets a constant reverse iterator to the beginning of the array.
constexpr self_type & operator=(self_type &&other)
Move assignment operator.
SPARROW_CONSTEXPR_CLANG const_reference back() const
Gets a reference to the last element.
constexpr void slice_inplace(size_type start, size_type end)
Slices the array in place to keep only the elements between the given start and end.
std::optional< key_value_view > metadata() const
Gets the metadata of the array.
constexpr self_type slice_view(size_type start, size_type end) const
Slices the array to keep only the elements between the given start and end.
layout_element_functor< self_type, true > functor_type
constexpr const_reverse_iterator rend() const
Gets a constant reverse iterator to the end of the array.
constexpr const_reverse_iterator crend() const
Gets a constant reverse iterator to the end of the array.
constexpr self_type slice(size_type start, size_type end) const
Slices the array to keep only the elements between the given start and end.
constexpr iterator end()
Gets an iterator to the end of the array.
constexpr const_iterator cend() const
Gets a constant iterator to the end of the array.
dictionary_encoded_array(arrow_proxy proxy)
Constructs a dictionary encoded array from an arrow proxy.
constexpr const_iterator cbegin() const
Gets a constant iterator to the beginning of the array.
layout_element_functor< self_type, true > const_functor_type
constexpr reverse_iterator rend()
Gets a reverse iterator to the end of the array.
dictionary_encoded_array(Args &&... args)
Constructs a dictionary encoded array with the given arguments.
constexpr const_iterator begin() const
Gets a constant iterator to the beginning of the array.
constexpr const_reverse_iterator rbegin() const
Gets a constant reverse iterator to the beginning of the array.
SPARROW_CONSTEXPR_CLANG const_reference front() const
Gets a reference to the first element.
constexpr std::optional< std::string_view > name() const
Gets the name of the array.
constexpr bool empty() const
Checks if the array is empty.
constexpr dictionary_encoded_array(self_type &&other)
Move constructor.
constexpr size_type size() const
Gets the number of elements in the array.
constexpr const_iterator end() const
Gets a constant iterator to the end of the array.
constexpr reverse_iterator rbegin()
Gets a reverse iterator to the beginning of the array.
functor_index_iterator< functor_type > iterator
constexpr dictionary_encoded_array(const self_type &other)
Copy constructor.
std::reverse_iterator< const_iterator > const_reverse_iterator
typename storage_type::default_allocator default_allocator
Functor for accessing elements in a layout.
constexpr layout_element_functor(storage_type layout_)
Constructs a functor with the given layout.
std:: conditional_t< is_const, typename layout_type::const_reference, typename layout_type::reference > return_type
constexpr layout_element_functor()=default
Default constructor.
std::conditional_t< is_const, const layout_type *, layout_type > storage_type
constexpr return_type operator()(std::size_t i) const
Access operator for getting element at index.
A view that repeats a value a given number of times.
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 defining valid input types for validity bitmap creation.
#define SPARROW_CONSTEXPR_CLANG
Definition config.hpp:64
#define SPARROW_ASSERT_TRUE(expr__)
#define SPARROW_ASSERT_FALSE(expr__)
SPARROW_API void increase(const std::string &key)
std::string key()
Definition buffer.hpp:49
constexpr bool excludes_copy_and_move_ctor_v
Convenience variable template for excludes_copy_and_move_ctor.
constexpr bool is_type_instance_of_v
Variable template for convenient access to is_type_instance_of.
Definition mp_utils.hpp:102
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.
constexpr std::string_view data_type_to_format(data_type type)
SPARROW_API bool operator==(const array &lhs, const array &rhs)
Compares the content of two arrays.
constexpr bool is_dictionary_encoded_array_v
Checks whether T is a dictionary_encoded_array type.
SPARROW_API array_traits::inner_value_type array_default_element_value(const array_wrapper &ar)
std::pair< ArrowArray, ArrowSchema > extract_arrow_structures(A &&a)
Extracts the internal ArrowArray and ArrowSchema structures from the given array or typed layout.
Definition array.hpp:110
constexpr nullable_get_fn nullable_get
Definition nullable.hpp:102
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.
std::ostream & operator<<(std::ostream &os, const nullval_t &)
primitive_array_impl< T, Ext, T2 > primitive_array
Array of values of whose type has fixed binary size.
SPARROW_API cloning_ptr< array_wrapper > array_factory(arrow_proxy proxy)
SPARROW_API array_traits::const_reference array_element(const array_wrapper &ar, std::size_t index)
SPARROW_API void swap(ArrowArray &lhs, ArrowArray &rhs) noexcept
Swaps the contents of the two ArrowArray objects.
validity_bitmap ensure_validity_bitmap(std::size_t size, R &&validity_input)
Ensures a validity bitmap of the specified size from various input types.
constexpr bool data_type_is_integer(data_type dt) noexcept
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
Provides compile-time information about Arrow data types.
static constexpr sparrow::data_type get() noexcept
Gets the data type for the dictionary keys.
Metafunction for retrieving the data_type of a typed array.
static constexpr bool get() noexcept
Returns true for dictionary_encoded_array types.
static constexpr bool get() noexcept