sparrow 0.6.0
Loading...
Searching...
No Matches
data_traits.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 <chrono>
18#include <concepts>
19
26
27namespace sparrow
28{
29
30 template <class T>
32 {
33 using value_type = T;
34 using const_reference = const T&;
35 };
36
37 template <>
44
45 // Define automatically all standard floating-point and integral types support, excluding `bool`.
46 template <class T>
47 requires std::integral<T> or std::floating_point<T>
52
53 template <>
54 struct arrow_traits<bool>
55 {
56 static constexpr data_type type_id = data_type::BOOL;
57 using value_type = bool;
58 using const_reference = bool;
59 };
60
61 template <>
62 struct arrow_traits<std::string>
63 {
65 using value_type = std::string;
66 using const_reference = std::string_view;
67 };
68
69 template <>
70 struct arrow_traits<std::vector<byte_t>>
71 {
72 static constexpr data_type type_id = data_type::BINARY;
73 using value_type = std::vector<byte_t>;
74 using const_reference = vector_view<const byte_t>;
75 };
76
77 template <>
84
85 template <>
92
93 template <>
100
101 template <>
108
109 template <>
116
117 template <>
124
125 template <>
127 {
129 };
130
131 template <>
136
137 template <>
138 struct arrow_traits<std::chrono::seconds> : common_native_types_traits<std::chrono::seconds>
139 {
141 };
142
143 template <>
144 struct arrow_traits<std::chrono::milliseconds> : common_native_types_traits<std::chrono::milliseconds>
145 {
147 };
148
149 template <>
150 struct arrow_traits<std::chrono::microseconds> : common_native_types_traits<std::chrono::microseconds>
151 {
153 };
154
155 template <>
156 struct arrow_traits<std::chrono::nanoseconds> : common_native_types_traits<std::chrono::nanoseconds>
157 {
159 };
160
161 template <>
168
169 template <>
176
177 template <>
184
185 template <>
192
193 template <>
194 struct arrow_traits<chrono::time_seconds> : common_native_types_traits<chrono::time_seconds>
195 {
197 };
198
199 template <>
200 struct arrow_traits<chrono::time_milliseconds> : common_native_types_traits<chrono::time_milliseconds>
201 {
203 };
204
205 template <>
206 struct arrow_traits<chrono::time_microseconds> : common_native_types_traits<chrono::time_microseconds>
207 {
209 };
210
211 template <>
212 struct arrow_traits<chrono::time_nanoseconds> : common_native_types_traits<chrono::time_nanoseconds>
213 {
215 };
216
217 template <>
218 struct arrow_traits<chrono::months> : common_native_types_traits<chrono::months>
219 {
221 };
222
223 template <>
228
229 template <>
235
236 namespace detail
237 {
238 template <class T>
240
241 template <class T>
243
244 template <class T>
246
247 template <class T>
249 }
250
252 {
253 using inner_value_type = /* std::variant<null_type, bool, uint8_t, ...> */
255 // std::variant can not hold references, we need to write something based on variant and
256 // reference_wrapper
257 // using inner_const_reference = /* std::variant<null_type, const bool&, const suint8_t&, ....> */
258 /* mpl::rename<
259 mpl::transform<
260 detail::array_inner_const_reference_t,
261 all_base_types_t>,
262 std::variant>;*/
263 using value_type = // nullable_variant<nullable<null_type>, nullable<bool>, nullable<uint8_t>, ...>
265 using const_reference = // nullable_variant<nullable<null_type>, nullable<const bool&>,
266 // nullable<const uint8_t&>, ...>
268 };
269
270 namespace predicate
271 {
272
273 struct
274 {
275 template <class T>
276 consteval bool operator()(mpl::typelist<T>)
277 {
279 }
281
282 struct
283 {
284 template <class T>
285 consteval bool operator()(mpl::typelist<T>)
286 {
288 }
289 } constexpr has_arrow_traits;
290 }
291}
variant of nullable, exposing has_value for convenience
Definition nullable.hpp:521
The nullable class models a value or a reference that can be "null", or missing, like values traditio...
Definition nullable.hpp:280
The class vector_view describes an object that can refer to a constant contiguous sequence of T with ...
Matches C++ representation types which are supported by default.
Matches valid and complete arrow_traits specializations for type T.
nullable< array_inner_value_type_t< T > > array_value_type_t
typename arrow_traits< T >::value_type array_inner_value_type_t
typename arrow_traits< T >::const_reference array_inner_const_reference_t
nullable< array_inner_const_reference_t< T > > array_const_reference_t
typename impl::rename_impl< From, To >::type rename
Changes the type of the list to the given type/ Example: static_assert(std::same_as<rename<typelist<i...
Definition mp_utils.hpp:135
struct sparrow::predicate::@016264041366021063162134122164342372036137222311 has_arrow_traits
primesum::int128_t int128_t
Definition large_int.hpp:88
constexpr data_type data_type_from_size(T={})
date::zoned_time< Duration, TimeZonePtr > timestamp
primesum::int256_t int256_t
Definition large_int.hpp:89
std::chrono::time_point< std::chrono::system_clock, std::chrono::milliseconds > date_milliseconds
data_type
Runtime identifier of arrow data types, usually associated with raw bytes with the associated value.
std::chrono::time_point< std::chrono::system_clock, chrono::days > date_days
mpl::rename< 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
static constexpr data_type type_id
static constexpr data_type type_id
static constexpr data_type type_id
static constexpr data_type type_id
static constexpr data_type type_id
static constexpr data_type type_id
static constexpr data_type type_id
static constexpr data_type type_id
Provides compile-time information about Arrow data types.
A sequence of types, used for meta-programming operations.
Definition mp_utils.hpp:55