sparrow
2.5.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Toggle main menu visibility
Loading...
Searching...
No Matches
map_value.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 implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#pragma once
16
17
#include <utility>
18
19
#include "
sparrow/layout/array_wrapper.hpp
"
20
#include "
sparrow/layout/layout_utils.hpp
"
21
#include "
sparrow/types/data_traits.hpp
"
22
#include "
sparrow/utils/functor_index_iterator.hpp
"
23
24
namespace
sparrow
25
{
26
class
map_array
;
27
28
class
SPARROW_API
map_value
29
{
30
public
:
31
32
using
key_type
=
array_traits::value_type
;
33
using
const_key_reference
=
array_traits::const_reference
;
34
using
mapped_type
=
array_traits::value_type
;
35
using
const_mapped_reference
=
array_traits::const_reference
;
36
37
using
value_type
= std::pair<key_type, mapped_type>;
38
using
const_reference
= std::pair<const_key_reference, const_mapped_reference>;
39
using
size_type
= std::size_t;
40
41
using
functor_type
=
detail::layout_value_functor<const map_value, const_reference>
;
42
using
const_iterator
=
functor_index_iterator<functor_type>
;
43
using
const_reverser_iterator
= std::reverse_iterator<const_iterator>;
44
45
map_value
() =
default
;
46
map_value
(
47
const
array_wrapper
* flat_keys,
48
const
array_wrapper
* flat_items,
49
size_type
index_begin,
50
size_type
index_end,
51
bool
keys_sorted
52
);
53
54
[[nodiscard]]
bool
empty
() const noexcept;
55
[[nodiscard]]
size_type
size
() const noexcept;
56
57
[[nodiscard]]
const_mapped_reference
at
(const
key_type
& key) const;
58
[[nodiscard]]
const_mapped_reference
operator[](const
key_type
& key) const;
59
60
[[nodiscard]]
bool
contains
(const
key_type
& key) const;
61
[[nodiscard]]
const_iterator
find
(const
key_type
& key) const;
62
63
[[nodiscard]]
const_iterator
begin
() const;
64
[[nodiscard]]
const_iterator
cbegin
() const;
65
66
[[nodiscard]]
const_iterator
end
() const;
67
[[nodiscard]]
const_iterator
cend
() const;
68
69
[[nodiscard]]
const_reverser_iterator
rbegin
() const;
70
[[nodiscard]]
const_reverser_iterator
crbegin
() const;
71
72
[[nodiscard]]
const_reverser_iterator
rend
() const;
73
[[nodiscard]]
const_reverser_iterator
crend
() const;
74
75
private:
76
77
size_type
find_index(const
key_type
& key) const noexcept;
78
const_reference
value(
size_type
i) const;
79
80
const
array_wrapper
* p_flat_keys =
nullptr
;
81
const
array_wrapper
* p_flat_items =
nullptr
;
82
size_type
m_index_begin = 0u;
83
size_type
m_index_end = 0u;
84
bool
m_keys_sorted = false;
85
86
friend class
detail
::layout_value_functor<const
map_value
,
const_reference
>;
87
friend class
map_array
;
88
};
89
90
SPARROW_API
91
bool
operator==(const
map_value
& lhs, const
map_value
& rhs);
92
}
93
94
#if defined(__cpp_lib_format)
95
96
template
<>
97
struct
std::formatter<
sparrow
::
map_value
>
98
{
99
constexpr
auto
parse(std::format_parse_context& ctx) ->
decltype
(ctx.begin())
100
{
101
return
ctx.begin();
// Simple implementation
102
}
103
104
SPARROW_API
auto
format(
const
sparrow::map_value
& value, std::format_context& ctx)
const
105
->
decltype
(ctx.out());
106
};
107
108
namespace
sparrow
109
{
110
SPARROW_API
std::ostream&
operator<<
(std::ostream& os,
const
map_value& value);
111
}
112
113
#endif
array_wrapper.hpp
sparrow::array_wrapper
Base class for array type erasure.
Definition
array_wrapper.hpp:50
sparrow::detail::layout_value_functor
Definition
layout_utils.hpp:29
sparrow::functor_index_iterator
Definition
functor_index_iterator.hpp:29
sparrow::map_array
Definition
map_array.hpp:90
sparrow::map_value
Definition
map_value.hpp:29
sparrow::map_value::map_array
friend class map_array
Definition
map_value.hpp:87
sparrow::map_value::const_key_reference
array_traits::const_reference const_key_reference
Definition
map_value.hpp:33
sparrow::map_value::cbegin
const_iterator cbegin() const
sparrow::map_value::end
const_iterator end() const
sparrow::map_value::value_type
std::pair< key_type, mapped_type > value_type
Definition
map_value.hpp:37
sparrow::map_value::cend
const_iterator cend() const
sparrow::map_value::crbegin
const_reverser_iterator crbegin() const
sparrow::map_value::contains
bool contains(const key_type &key) const
sparrow::map_value::rbegin
const_reverser_iterator rbegin() const
sparrow::map_value::size_type
std::size_t size_type
Definition
map_value.hpp:39
sparrow::map_value::const_mapped_reference
array_traits::const_reference const_mapped_reference
Definition
map_value.hpp:35
sparrow::map_value::empty
bool empty() const noexcept
sparrow::map_value::begin
const_iterator begin() const
sparrow::map_value::map_value
map_value(const array_wrapper *flat_keys, const array_wrapper *flat_items, size_type index_begin, size_type index_end, bool keys_sorted)
sparrow::map_value::size
size_type size() const noexcept
sparrow::map_value::at
const_mapped_reference at(const key_type &key) const
sparrow::map_value::map_value
map_value()=default
sparrow::map_value::const_reverser_iterator
std::reverse_iterator< const_iterator > const_reverser_iterator
Definition
map_value.hpp:43
sparrow::map_value::const_reference
std::pair< const_key_reference, const_mapped_reference > const_reference
Definition
map_value.hpp:38
sparrow::map_value::const_iterator
functor_index_iterator< functor_type > const_iterator
Definition
map_value.hpp:42
sparrow::map_value::rend
const_reverser_iterator rend() const
sparrow::map_value::functor_type
detail::layout_value_functor< const map_value, const_reference > functor_type
Definition
map_value.hpp:41
sparrow::map_value::crend
const_reverser_iterator crend() const
sparrow::map_value::find
const_iterator find(const key_type &key) const
sparrow::map_value::key_type
array_traits::value_type key_type
Definition
map_value.hpp:32
sparrow::map_value::mapped_type
array_traits::value_type mapped_type
Definition
map_value.hpp:34
SPARROW_API
#define SPARROW_API
Definition
config.hpp:38
data_traits.hpp
functor_index_iterator.hpp
operator<<
std::ostream & operator<<(std::ostream &stream, primesum::uint128_t n)
The __int128_t type (GCC/Clang) is not well supported by the C++ standard library (in 2016) so we hav...
Definition
int128_t.hpp:48
layout_utils.hpp
sparrow::detail
Definition
dynamic_bitset.hpp:391
sparrow
Definition
array.hpp:21
sparrow::array_traits::const_reference
mpl::rename< mpl::unique< mpl::transform< detail::array_const_reference_t, all_base_types_t > >, nullable_variant > const_reference
Definition
data_traits.hpp:276
sparrow::array_traits::value_type
mpl::rename< mpl::transform< detail::array_value_type_t, all_base_types_t >, nullable_variant > value_type
Definition
data_traits.hpp:274
sparrow
layout
map_value.hpp
Generated by
1.18.0