sparrow 2.3.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
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#include <string>
20#include <vector>
21
29
30namespace sparrow
31{
32
33 template <class T>
35 {
36 using value_type = T;
37 using const_reference = const T&;
38 };
39
40 template <>
46
47 // Define automatically all standard floating-point and integral types support, excluding `bool`.
48 template <class T>
49 requires std::integral<T> or std::floating_point<T>
51 {
52 };
53
54 template <>
56 {
57 };
58
59 template <>
60 struct arrow_traits<bool>
61 {
62 using value_type = bool;
63 using const_reference = bool;
64 };
65
66 template <>
67 struct arrow_traits<std::string>
68 {
69 using value_type = std::string;
70 using const_reference = std::string_view;
71 };
72
73 template <>
74 struct arrow_traits<std::vector<byte_t>>
75 {
76 using value_type = std::vector<byte_t>;
77 using const_reference = sequence_view<const byte_t>;
78 };
79
80 template <>
86
87 template <>
93
94 template <>
100
101 template <>
107
108 template <>
114
115 template <>
121
122 template <>
128
129 template <>
131 {
132 };
133
134 template <>
136 {
137 };
138
139 template <>
140 struct arrow_traits<std::chrono::seconds> : common_native_types_traits<std::chrono::seconds>
141 {
142 };
143
144 template <>
145 struct arrow_traits<std::chrono::milliseconds> : common_native_types_traits<std::chrono::milliseconds>
146 {
147 };
148
149 template <>
150 struct arrow_traits<std::chrono::microseconds> : common_native_types_traits<std::chrono::microseconds>
151 {
152 };
153
154 template <>
155 struct arrow_traits<std::chrono::nanoseconds> : common_native_types_traits<std::chrono::nanoseconds>
156 {
157 };
158
159 template <>
165
166 template <>
172
173 template <>
179
180 template <>
186
187 template <>
189 : common_native_types_traits<zoned_time_without_timezone_seconds>
190 {
191 };
192
193 template <>
195 : common_native_types_traits<zoned_time_without_timezone_milliseconds>
196 {
197 };
198
199 template <>
201 : common_native_types_traits<zoned_time_without_timezone_microseconds>
202 {
203 };
204
205 template <>
207 : common_native_types_traits<zoned_time_without_timezone_nanoseconds>
208 {
209 };
210
211 template <>
212 struct arrow_traits<chrono::time_seconds> : common_native_types_traits<chrono::time_seconds>
213 {
214 };
215
216 template <>
217 struct arrow_traits<chrono::time_milliseconds> : common_native_types_traits<chrono::time_milliseconds>
218 {
219 };
220
221 template <>
222 struct arrow_traits<chrono::time_microseconds> : common_native_types_traits<chrono::time_microseconds>
223 {
224 };
225
226 template <>
227 struct arrow_traits<chrono::time_nanoseconds> : common_native_types_traits<chrono::time_nanoseconds>
228 {
229 };
230
231 template <>
232 struct arrow_traits<chrono::months> : common_native_types_traits<chrono::months>
233 {
234 };
235
236 template <>
238 {
239 };
240
241 template <>
243 : common_native_types_traits<month_day_nanoseconds_interval>
244 {
245 };
246
247 namespace detail
248 {
249 template <class T>
251
252 template <class T>
254
255 template <class T>
257
258 template <class T>
260 }
261
263 {
264 using inner_value_type = /* std::variant<null_type, bool, uint8_t, ...> */
266 // std::variant can not hold references, we need to write something based on variant and
267 // reference_wrapper
268 // using inner_const_reference = /* std::variant<null_type, const bool&, const suint8_t&, ....> */
269 /* mpl::rename<
270 mpl::transform<
271 detail::array_inner_const_reference_t,
272 all_base_types_t>,
273 std::variant>;*/
274 using value_type = // nullable_variant<nullable<null_type>, nullable<bool>, nullable<uint8_t>, ...>
276 using const_reference = // nullable_variant<nullable<null_type>, nullable<const bool&>,
277 // nullable<const uint8_t&>, ...>
279 };
280
281 namespace predicate
282 {
283
284 struct
285 {
286 template <class T>
287 consteval bool operator()(mpl::typelist<T>)
288 {
290 }
292
293 struct
294 {
295 template <class T>
296 consteval bool operator()(mpl::typelist<T>)
297 {
299 }
300 } constexpr has_arrow_traits;
301 }
302}
Variant of nullable types with has_value() convenience method.
The class sequence_view describes an object that can refer to a constant contiguous sequence of T wit...
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 template type of a type list.
Definition mp_utils.hpp:268
struct sparrow::predicate::@133355332276125161102302222157102151155345254340 has_arrow_traits
primesum::int128_t int128_t
Definition large_int.hpp:84
half_float::half float16_t
date::zoned_time< Duration, TimeZonePtr > timestamp
primesum::int256_t int256_t
Definition large_int.hpp:85
std::chrono::time_point< std::chrono::system_clock, std::chrono::milliseconds > date_milliseconds
std::chrono::time_point< std::chrono::system_clock, chrono::days > date_days
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.
A sequence of types used for metaprogramming operations.
Definition mp_utils.hpp:123
A zoned time value without timezone, in microseconds.
A zoned time value without timezone, in milliseconds.
A zoned time value without timezone, in nanoseconds.
A zoned time value without timezone, in seconds.