sparrow
2.4.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
SPARROW_API
map_value
27
{
28
public
:
29
30
using
key_type
=
array_traits::value_type
;
31
using
const_key_reference
=
array_traits::const_reference
;
32
using
mapped_type
=
array_traits::value_type
;
33
using
const_mapped_reference
=
array_traits::const_reference
;
34
35
using
value_type
= std::pair<key_type, mapped_type>;
36
using
const_reference
= std::pair<const_key_reference, const_mapped_reference>;
37
using
size_type
= std::size_t;
38
39
using
functor_type
=
detail::layout_value_functor<const map_value, const_reference>
;
40
using
const_iterator
=
functor_index_iterator<functor_type>
;
41
using
const_reverser_iterator
= std::reverse_iterator<const_iterator>;
42
43
map_value
() =
default
;
44
map_value
(
45
const
array_wrapper
* flat_keys,
46
const
array_wrapper
* flat_items,
47
size_type
index_begin,
48
size_type
index_end,
49
bool
keys_sorted
50
);
51
52
[[nodiscard]]
bool
empty
() const noexcept;
53
[[nodiscard]]
size_type
size
() const noexcept;
54
55
[[nodiscard]]
const_mapped_reference
at
(const
key_type
& key) const;
56
[[nodiscard]]
const_mapped_reference
operator[](const
key_type
& key) const;
57
58
[[nodiscard]]
bool
contains
(const
key_type
& key) const;
59
[[nodiscard]]
const_iterator
find
(const
key_type
& key) const;
60
61
[[nodiscard]]
const_iterator
begin
() const;
62
[[nodiscard]]
const_iterator
cbegin
() const;
63
64
[[nodiscard]]
const_iterator
end
() const;
65
[[nodiscard]]
const_iterator
cend
() const;
66
67
[[nodiscard]]
const_reverser_iterator
rbegin
() const;
68
[[nodiscard]]
const_reverser_iterator
crbegin
() const;
69
70
[[nodiscard]]
const_reverser_iterator
rend
() const;
71
[[nodiscard]]
const_reverser_iterator
crend
() const;
72
73
private:
74
75
size_type
find_index(const
key_type
& key) const noexcept;
76
const_reference
value(
size_type
i) const;
77
78
const
array_wrapper
* p_flat_keys;
79
const
array_wrapper
* p_flat_items;
80
size_type
m_index_begin;
81
size_type
m_index_end;
82
bool
m_keys_sorted;
83
84
friend class
detail
::layout_value_functor<const
map_value
,
const_reference
>;
85
};
86
87
SPARROW_API
88
bool
operator==(const
map_value
& lhs, const
map_value
& rhs);
89
}
90
91
#if defined(__cpp_lib_format)
92
93
template
<>
94
struct
std::formatter<
sparrow
::
map_value
>
95
{
96
constexpr
auto
parse(std::format_parse_context& ctx) ->
decltype
(ctx.begin())
97
{
98
return
ctx.begin();
// Simple implementation
99
}
100
101
SPARROW_API
auto
format(
const
sparrow::map_value
& value, std::format_context& ctx)
const
102
->
decltype
(ctx.out());
103
};
104
105
namespace
sparrow
106
{
107
SPARROW_API
std::ostream&
operator<<
(std::ostream& os,
const
map_value& value);
108
}
109
110
#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_value
Definition
map_value.hpp:27
sparrow::map_value::const_key_reference
array_traits::const_reference const_key_reference
Definition
map_value.hpp:31
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:35
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:37
sparrow::map_value::const_mapped_reference
array_traits::const_reference const_mapped_reference
Definition
map_value.hpp:33
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:41
sparrow::map_value::const_reference
std::pair< const_key_reference, const_mapped_reference > const_reference
Definition
map_value.hpp:36
sparrow::map_value::const_iterator
functor_index_iterator< functor_type > const_iterator
Definition
map_value.hpp:40
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:39
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:30
sparrow::map_value::mapped_type
array_traits::value_type mapped_type
Definition
map_value.hpp:32
SPARROW_API
#define SPARROW_API
Definition
config.hpp:38
data_traits.hpp
functor_index_iterator.hpp
layout_utils.hpp
sparrow::detail
Definition
dynamic_bitset.hpp:391
sparrow
Definition
array.hpp:21
sparrow::operator<<
std::ostream & operator<<(std::ostream &os, const nullval_t &)
Definition
nullable.hpp:1597
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.17.0