sparrow 0.9.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#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 <>
55 struct arrow_traits<bool>
56 {
57 using value_type = bool;
58 using const_reference = bool;
59 };
60
61 template <>
62 struct arrow_traits<std::string>
63 {
64 using value_type = std::string;
65 using const_reference = std::string_view;
66 };
67
68 template <>
69 struct arrow_traits<std::vector<byte_t>>
70 {
71 using value_type = std::vector<byte_t>;
72 using const_reference = sequence_view<const byte_t>;
73 };
74
75 template <>
81
82 template <>
88
89 template <>
95
96 template <>
102
103 template <>
109
110 template <>
116
117 template <>
123
124 template <>
126 {
127 };
128
129 template <>
131 {
132 };
133
134 template <>
135 struct arrow_traits<std::chrono::seconds> : common_native_types_traits<std::chrono::seconds>
136 {
137 };
138
139 template <>
140 struct arrow_traits<std::chrono::milliseconds> : common_native_types_traits<std::chrono::milliseconds>
141 {
142 };
143
144 template <>
145 struct arrow_traits<std::chrono::microseconds> : common_native_types_traits<std::chrono::microseconds>
146 {
147 };
148
149 template <>
150 struct arrow_traits<std::chrono::nanoseconds> : common_native_types_traits<std::chrono::nanoseconds>
151 {
152 };
153
154 template <>
160
161 template <>
167
168 template <>
174
175 template <>
181
182 template <>
184 : common_native_types_traits<zoned_time_without_timezone_seconds>
185 {
186 };
187
188 template <>
190 : common_native_types_traits<zoned_time_without_timezone_milliseconds>
191 {
192 };
193
194 template <>
196 : common_native_types_traits<zoned_time_without_timezone_microseconds>
197 {
198 };
199
200 template <>
202 : common_native_types_traits<zoned_time_without_timezone_nanoseconds>
203 {
204 };
205
206 template <>
207 struct arrow_traits<chrono::time_seconds> : common_native_types_traits<chrono::time_seconds>
208 {
209 };
210
211 template <>
212 struct arrow_traits<chrono::time_milliseconds> : common_native_types_traits<chrono::time_milliseconds>
213 {
214 };
215
216 template <>
217 struct arrow_traits<chrono::time_microseconds> : common_native_types_traits<chrono::time_microseconds>
218 {
219 };
220
221 template <>
222 struct arrow_traits<chrono::time_nanoseconds> : common_native_types_traits<chrono::time_nanoseconds>
223 {
224 };
225
226 template <>
227 struct arrow_traits<chrono::months> : common_native_types_traits<chrono::months>
228 {
229 };
230
231 template <>
233 {
234 };
235
236 template <>
238 : common_native_types_traits<month_day_nanoseconds_interval>
239 {
240 };
241
242 namespace detail
243 {
244 template <class T>
246
247 template <class T>
249
250 template <class T>
252
253 template <class T>
255 }
256
258 {
259 using inner_value_type = /* std::variant<null_type, bool, uint8_t, ...> */
261 // std::variant can not hold references, we need to write something based on variant and
262 // reference_wrapper
263 // using inner_const_reference = /* std::variant<null_type, const bool&, const suint8_t&, ....> */
264 /* mpl::rename<
265 mpl::transform<
266 detail::array_inner_const_reference_t,
267 all_base_types_t>,
268 std::variant>;*/
269 using value_type = // nullable_variant<nullable<null_type>, nullable<bool>, nullable<uint8_t>, ...>
271 using const_reference = // nullable_variant<nullable<null_type>, nullable<const bool&>,
272 // nullable<const uint8_t&>, ...>
274 };
275
276 namespace predicate
277 {
278
279 struct
280 {
281 template <class T>
282 consteval bool operator()(mpl::typelist<T>)
283 {
285 }
287
288 struct
289 {
290 template <class T>
291 consteval bool operator()(mpl::typelist<T>)
292 {
294 }
295 } constexpr has_arrow_traits;
296 }
297}
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::@016264041366021063162134122164342372036137222311 has_arrow_traits
primesum::int128_t int128_t
Definition large_int.hpp:84
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
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.