24#if defined(SPARROW_USE_DATE_POLYFILL)
28# if defined(__cpp_lib_format)
32struct std::formatter<date::zoned_time<T>>
34 constexpr auto parse(std::format_parse_context& ctx)
39 auto format(
const date::zoned_time<T>& date, std::format_context& ctx)
const
41 std::ostringstream oss;
43 std::string date_str = oss.str();
44 return std::format_to(ctx.out(),
"{}", date_str);
50namespace date = std::chrono;
67#if __cplusplus > 202002L and defined(__STDCPP_FLOAT16_T__) and defined(__STDCPP_FLOAT32_T__) \
68 and defined(__STDCPP_FLOAT64_T__)
69# define SPARROW_STD_FIXED_FLOAT_SUPPORT
74#if defined(SPARROW_STD_FIXED_FLOAT_SUPPORT)
78# if defined(__clang__)
79# pragma clang diagnostic push
80# pragma clang diagnostic ignored "-Wconversion"
81# pragma clang diagnostic ignored "-Wsign-conversion"
82# pragma clang diagnostic ignored "-Wold-style-cast"
83# pragma clang diagnostic ignored "-Wdeprecated-declarations"
84# elif defined(__GNUC__)
85# pragma GCC diagnostic push
86# pragma GCC diagnostic ignored "-Wconversion"
87# pragma GCC diagnostic ignored "-Wsign-conversion"
88# pragma GCC diagnostic ignored "-Wold-style-cast"
89# elif defined(_MSC_VER)
91# pragma warning(disable : 4365)
93# pragma warning(disable : 4514)
94# pragma warning(disable : 4668)
97# include "sparrow/details/3rdparty/float16_t.hpp"
99# pragma GCC diagnostic pop
100# elif defined(__clang__)
101# pragma clang diagnostic pop
102# elif defined(_MSC_VER)
113#if defined(SPARROW_STD_FIXED_FLOAT_SUPPORT)
128 template <
typename Duration,
typename TimeZonePtr = const date::time_zone*>
129 using timestamp = date::zoned_time<Duration, TimeZonePtr>;
135 static_assert(std::is_floating_point_v<float16_t>);
136 static_assert(std::is_floating_point_v<float32_t>);
137 static_assert(std::is_floating_point_v<float64_t>);
138 static_assert(CHAR_BIT == 8);
221 return !std::isdigit(c);
236 if (format.size() == 1)
278 else if (format ==
"vu")
282 else if (format ==
"vz")
287 else if (format.starts_with(
"t"))
293 else if (format ==
"tdm")
297 else if (format.starts_with(
"tss:"))
301 else if (format.starts_with(
"tsm:"))
305 else if (format.starts_with(
"tsu:"))
309 else if (format.starts_with(
"tsn:"))
313 else if (format ==
"tDs")
317 else if (format ==
"tDm")
321 else if (format ==
"tDu")
325 else if (format ==
"tDn")
329 else if (format ==
"tiM")
333 else if (format ==
"tiD")
337 else if (format ==
"tin")
341 else if (format ==
"tts")
345 else if (format ==
"ttm")
349 else if (format ==
"ttu")
353 else if (format ==
"ttn")
358 else if (format ==
"+l")
362 else if (format ==
"+L")
366 else if (format ==
"+vl")
370 else if (format ==
"+vL")
374 else if (format.starts_with(
"+w:"))
378 else if (format ==
"+s")
382 else if (format ==
"+m")
386 else if (format.starts_with(
"+ud:"))
390 else if (format.starts_with(
"+us:"))
394 else if (format.starts_with(
"+r"))
398 else if (format.starts_with(
"d:"))
412 throw std::runtime_error(
"Invalid format for decimal");
415 else if (format.starts_with(
"w:"))
426 template <std::
floating_po
int T>
427 requires(
sizeof(T) >= 2 &&
sizeof(T) <= 8)
447 template <std::
integral T>
448 requires(
sizeof(T) >= 1 &&
sizeof(T) <= 8)
451 if constexpr (std::same_as<bool, T>)
455 else if constexpr (std::signed_integral<T>)
472 static_assert(std::unsigned_integral<T>);
575 throw std::runtime_error(
"Unsupported data type");
648 std::chrono::seconds,
649 std::chrono::milliseconds,
650 std::chrono::microseconds,
651 std::chrono::nanoseconds,
724 template <
template <
class>
class>
740 typename T::value_type;
763 template <has_arrow_type_traits T>
771 template <has_arrow_type_traits T>
779 template <has_arrow_type_traits T>
786 template <has_arrow_type_traits T>
822 template <
class C,
bool is_const>
824 : std::conditional<is_const, typename C::inner_const_reference, typename C::inner_reference>
828 template <
class C,
bool is_const>
833 concept layout_offset = std::same_as<T, std::int32_t> || std::same_as<T, std::int64_t>;
836#if defined(__cpp_lib_format)
843 constexpr auto parse(std::format_parse_context& ctx)
884 return "Large string";
888 return "Large binary";
892 return "Date milliseconds";
894 return "Timestamp seconds";
896 return "Timestamp milliseconds";
898 return "Timestamp microseconds";
900 return "Timestamp nanoseconds";
902 return "Duration seconds";
904 return "Duration milliseconds";
906 return "Duration microseconds";
908 return "Duration nanoseconds";
910 return "Interval months";
912 return "Interval days time";
914 return "Interval months days nanoseconds";
916 return "Time seconds";
918 return "Time milliseconds";
920 return "Time microseconds";
922 return "Time nanoseconds";
930 return "Large list view";
932 return "Fixed sized list";
938 return "Dense union";
940 return "Sparse union";
942 return "Run encoded";
952 return "Fixed width binary";
954 return "String view";
956 return "Binary view";
961 return std::format_to(ctx.out(),
"{}", get_enum_name(
data_type));
966 struct formatter<
sparrow::null_type>
968 constexpr auto parse(std::format_parse_context& ctx)
973 auto format(
const sparrow::null_type&, std::format_context& ctx)
const
975 return std::format_to(ctx.out(),
"null_type");
980 struct formatter<std::byte>
982 constexpr auto parse(std::format_parse_context& ctx)
987 auto format(
const std::byte& b, std::format_context& ctx)
const
989 return std::format_to(ctx.out(),
"{}",
static_cast<int>(b));
constexpr data_descriptor(data_type id)
data_descriptor(std::string_view format)
constexpr data_descriptor()
constexpr data_type id() const
Matches any type which is one of the base C++ types supported or at least that provides an arrow_trai...
Matches types providing valid and complete arrow_traits specialization.
Checks if a type is an extended base type for Arrow.
Matches C++ representation types which are supported by default.
Matches valid and complete arrow_traits specializations for type T.
std::chrono::duration< int32_t, std::ratio< 2629746 > > months
typename get_inner_reference< C, is_const >::type get_inner_reference_t
consteval bool contains(L list)
decltype(append(TypeList{}, Us{}...)) append_t
Appends one or more types or typelist to a given TypeList.
constexpr bool is_type_instance_of_v
true if T is a concrete type template instanciation of U which is a type template.
void unreachable()
Invokes undefined behavior.
static constexpr all_base_types_extended_t all_base_types_extended
Type list of every C++ representation types supported by default, in order matching data_type related...
constexpr std::string_view data_type_format_of()
constexpr std::string_view data_type_to_format(data_type type)
constexpr bool data_type_is_primitive(data_type dt)
bool all_digits(const std::string_view s)
SPARROW_API bool operator==(const array &lhs, const array &rhs)
Compares the content of two arrays.
SPARROW_API std::size_t num_bytes_for_decimal(const char *format)
static constexpr all_base_types_t all_base_types
Type list of every C++ representation types supported by default, in order matching data_type related...
mpl::typelist< null_type, bool, std::uint8_t, std::int8_t, std::uint16_t, std::int16_t, std::uint32_t, std::int32_t, std::uint64_t, std::int64_t, float16_t, float32_t, float64_t, std::string, std::vector< byte_t >, date_days, date_milliseconds, timestamp< std::chrono::seconds >, timestamp< std::chrono::milliseconds >, timestamp< std::chrono::microseconds >, timestamp< std::chrono::nanoseconds >, std::chrono::seconds, std::chrono::milliseconds, std::chrono::microseconds, std::chrono::nanoseconds, chrono::months, days_time_interval, month_day_nanoseconds_interval, chrono::time_seconds, chrono::time_milliseconds, chrono::time_microseconds, chrono::time_nanoseconds, list_value, struct_value, decimal< std::int32_t >, decimal< std::int64_t >, decimal< int128_t >, decimal< int256_t > > all_base_types_t
C++ types value representation types matching Arrow types.
constexpr data_type data_type_from_size(T={})
data_type format_to_data_type(std::string_view format)
mpl::append_t< all_base_types_t, char, std::string_view > all_base_types_extended_t
is arrow base type or arrow compound type (list<T>, struct<T> etc.)
date::zoned_time< Duration, TimeZonePtr > timestamp
constexpr bool data_type_is_integer(data_type dt)
std::conditional_t< std::same_as< T, std::string_view >, std::string, T > get_corresponding_arrow_type_t
Template alias to get the corresponding Arrow type for a given type.
typename arrow_traits< T >::default_layout default_layout_t
Binary layout type to use by default for the given C++ representation T of an arrow value.
numeric::float16_t float16_t
std::chrono::time_point< std::chrono::system_clock, std::chrono::milliseconds > date_milliseconds
constexpr auto arrow_type_id() -> data_type
data_type
Runtime identifier of arrow data types, usually associated with raw bytes with the associated value.
@ INTERVAL_MONTHS_DAYS_NANOSECONDS
std::chrono::time_point< std::chrono::system_clock, chrono::days > date_days
Provides compile-time information about Arrow data types.
A duration representing time elapsed since midnight, in microseconds.
A duration representing time elapsed since midnight, in milliseconds.
A duration representing time elapsed since midnight, in nanoseconds.
A duration representing time elapsed since midnight.
A sequence of types, used for meta-programming operations.