sparrow 0.3.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, including `bool`.
46 template <class T>
47 requires std::integral<T> or std::floating_point<T>
52
53 template <>
54 struct arrow_traits<std::string>
55 {
57 using value_type = std::string;
58 using const_reference = std::string_view;
59 };
60
61 template <>
62 struct arrow_traits<std::vector<byte_t>>
63 {
64 static constexpr data_type type_id = data_type::BINARY;
65 using value_type = std::vector<byte_t>;
66 using const_reference = vector_view<const byte_t>;
67 };
68
69 template <>
76
77 template <>
84
85 template <>
92
93 template <>
100
101 template <>
108
109 template <>
116
117 template <>
119 {
121 };
122
123 template <>
128
129 template <>
130 struct arrow_traits<std::chrono::seconds> : common_native_types_traits<std::chrono::seconds>
131 {
133 };
134
135 template <>
136 struct arrow_traits<std::chrono::milliseconds> : common_native_types_traits<std::chrono::milliseconds>
137 {
139 };
140
141 template <>
142 struct arrow_traits<std::chrono::microseconds> : common_native_types_traits<std::chrono::microseconds>
143 {
145 };
146
147 template <>
148 struct arrow_traits<std::chrono::nanoseconds> : common_native_types_traits<std::chrono::nanoseconds>
149 {
151 };
152
153 template <>
160
161 template <>
168
169 template <>
176
177 template <>
184
185 template <>
186 struct arrow_traits<chrono::time_seconds> : common_native_types_traits<chrono::time_seconds>
187 {
189 };
190
191 template <>
192 struct arrow_traits<chrono::time_milliseconds> : common_native_types_traits<chrono::time_milliseconds>
193 {
195 };
196
197 template <>
198 struct arrow_traits<chrono::time_microseconds> : common_native_types_traits<chrono::time_microseconds>
199 {
201 };
202
203 template <>
204 struct arrow_traits<chrono::time_nanoseconds> : common_native_types_traits<chrono::time_nanoseconds>
205 {
207 };
208
209 template <>
210 struct arrow_traits<chrono::months> : common_native_types_traits<chrono::months>
211 {
213 };
214
215 template <>
220
221 template <>
227
228 namespace detail
229 {
230 template <class T>
232
233 template <class T>
235
236 template <class T>
238
239 template <class T>
241 }
242
244 {
245 using inner_value_type = /* std::variant<null_type, bool, uint8_t, ...> */
247 // std::variant can not hold references, we need to write something based on variant and
248 // reference_wrapper
249 // using inner_const_reference = /* std::variant<null_type, const bool&, const suint8_t&, ....> */
250 /* mpl::rename<
251 mpl::transform<
252 detail::array_inner_const_reference_t,
253 all_base_types_t>,
254 std::variant>;*/
255 using value_type = // nullable_variant<nullable<null_type>, nullable<bool>, nullable<uint8_t>, ...>
257 using const_reference = // nullable_variant<nullable<null_type>, nullable<const bool&>,
258 // nullable<const uint8_t&>, ...>
260 };
261
262 namespace predicate
263 {
264
265 struct
266 {
267 template <class T>
268 consteval bool operator()(mpl::typelist<T>)
269 {
271 }
273
274 struct
275 {
276 template <class T>
277 consteval bool operator()(mpl::typelist<T>)
278 {
280 }
281 } constexpr has_arrow_traits;
282 }
283}
variant of nullable, exposing has_value for convenience
Definition nullable.hpp:513
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
Provides compile-time information about Arrow data types.
A sequence of types, used for meta-programming operations.
Definition mp_utils.hpp:55