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
28
29namespace sparrow
30{
31
32 template <class T>
34 {
35 using value_type = T;
36 using const_reference = const T&;
37 };
38
39 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>
54
55 template <>
56 struct arrow_traits<bool>
57 {
58 static constexpr data_type type_id = data_type::BOOL;
59 using value_type = bool;
60 using const_reference = bool;
61 };
62
63 template <>
64 struct arrow_traits<std::string>
65 {
67 using value_type = std::string;
68 using const_reference = std::string_view;
69 };
70
71 template <>
72 struct arrow_traits<std::vector<byte_t>>
73 {
74 static constexpr data_type type_id = data_type::BINARY;
75 using value_type = std::vector<byte_t>;
76 using const_reference = vector_view<const byte_t>;
77 };
78
79 template <>
86
87 template <>
94
95 template <>
102
103 template <>
110
111 template <>
118
119 template <>
126
127 template <>
129 {
131 };
132
133 template <>
138
139 template <>
140 struct arrow_traits<std::chrono::seconds> : common_native_types_traits<std::chrono::seconds>
141 {
143 };
144
145 template <>
146 struct arrow_traits<std::chrono::milliseconds> : common_native_types_traits<std::chrono::milliseconds>
147 {
149 };
150
151 template <>
152 struct arrow_traits<std::chrono::microseconds> : common_native_types_traits<std::chrono::microseconds>
153 {
155 };
156
157 template <>
158 struct arrow_traits<std::chrono::nanoseconds> : common_native_types_traits<std::chrono::nanoseconds>
159 {
161 };
162
163 template <>
170
171 template <>
178
179 template <>
186
187 template <>
194
195 template <>
197 : common_native_types_traits<zoned_time_without_timezone_seconds>
198 {
200 };
201
202 template <>
204 : common_native_types_traits<zoned_time_without_timezone_milliseconds>
205 {
207 };
208
209 template <>
211 : common_native_types_traits<zoned_time_without_timezone_microseconds>
212 {
214 };
215
216 template <>
218 : common_native_types_traits<zoned_time_without_timezone_nanoseconds>
219 {
221 };
222
223 template <>
224 struct arrow_traits<chrono::time_seconds> : common_native_types_traits<chrono::time_seconds>
225 {
227 };
228
229 template <>
230 struct arrow_traits<chrono::time_milliseconds> : common_native_types_traits<chrono::time_milliseconds>
231 {
233 };
234
235 template <>
236 struct arrow_traits<chrono::time_microseconds> : common_native_types_traits<chrono::time_microseconds>
237 {
239 };
240
241 template <>
242 struct arrow_traits<chrono::time_nanoseconds> : common_native_types_traits<chrono::time_nanoseconds>
243 {
245 };
246
247 template <>
248 struct arrow_traits<chrono::months> : common_native_types_traits<chrono::months>
249 {
251 };
252
253 template <>
258
259 template <>
265
266 namespace detail
267 {
268 template <class T>
270
271 template <class T>
273
274 template <class T>
276
277 template <class T>
279 }
280
282 {
283 using inner_value_type = /* std::variant<null_type, bool, uint8_t, ...> */
285 // std::variant can not hold references, we need to write something based on variant and
286 // reference_wrapper
287 // using inner_const_reference = /* std::variant<null_type, const bool&, const suint8_t&, ....> */
288 /* mpl::rename<
289 mpl::transform<
290 detail::array_inner_const_reference_t,
291 all_base_types_t>,
292 std::variant>;*/
293 using value_type = // nullable_variant<nullable<null_type>, nullable<bool>, nullable<uint8_t>, ...>
295 using const_reference = // nullable_variant<nullable<null_type>, nullable<const bool&>,
296 // nullable<const uint8_t&>, ...>
298 };
299
300 namespace predicate
301 {
302
303 struct
304 {
305 template <class T>
306 consteval bool operator()(mpl::typelist<T>)
307 {
309 }
311
312 struct
313 {
314 template <class T>
315 consteval bool operator()(mpl::typelist<T>)
316 {
318 }
319 } constexpr has_arrow_traits;
320 }
321}
variant of nullable, exposing has_value for convenience
Definition nullable.hpp:534
The nullable class models a value or a reference that can be "null", or missing, like values traditio...
Definition nullable.hpp:281
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:84
constexpr data_type data_type_from_size(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
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
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.