25#if defined(SPARROW_USE_DATE_POLYFILL)
29# if defined(__cpp_lib_format)
33struct std::formatter<date::zoned_time<T>>
35 constexpr auto parse(std::format_parse_context& ctx)
40 auto format(
const date::zoned_time<T>& date, std::format_context& ctx)
const
42 std::ostringstream oss;
44 std::string date_str = oss.str();
45 return std::format_to(ctx.out(),
"{}", date_str);
51namespace date = std::chrono;
68#if __cplusplus > 202002L and defined(__STDCPP_FLOAT16_T__) and defined(__STDCPP_FLOAT32_T__) \
69 and defined(__STDCPP_FLOAT64_T__)
70# define SPARROW_STD_FIXED_FLOAT_SUPPORT
75#if defined(SPARROW_STD_FIXED_FLOAT_SUPPORT)
79# if defined(__clang__)
80# pragma clang diagnostic push
81# pragma clang diagnostic ignored "-Wconversion"
82# pragma clang diagnostic ignored "-Wsign-conversion"
83# pragma clang diagnostic ignored "-Wold-style-cast"
84# pragma clang diagnostic ignored "-Wdeprecated-declarations"
85# elif defined(__GNUC__)
86# pragma GCC diagnostic push
87# pragma GCC diagnostic ignored "-Wconversion"
88# pragma GCC diagnostic ignored "-Wsign-conversion"
89# pragma GCC diagnostic ignored "-Wold-style-cast"
90# elif defined(_MSC_VER)
92# pragma warning(disable : 4365)
94# pragma warning(disable : 4514)
95# pragma warning(disable : 4668)
98# include "sparrow/details/3rdparty/float16_t.hpp"
100# pragma GCC diagnostic pop
101# elif defined(__clang__)
102# pragma clang diagnostic pop
103# elif defined(_MSC_VER)
114#if defined(SPARROW_STD_FIXED_FLOAT_SUPPORT)
129 template <
typename Duration,
typename TimeZonePtr = const date::time_zone*>
130 using timestamp = date::zoned_time<Duration, TimeZonePtr>;
136 static_assert(std::is_floating_point_v<float16_t>);
137 static_assert(std::is_floating_point_v<float32_t>);
138 static_assert(std::is_floating_point_v<float64_t>);
139 static_assert(CHAR_BIT == 8);
222 return !std::isdigit(c);
237 if (format.size() == 1)
279 else if (format ==
"vu")
283 else if (format ==
"vz")
288 else if (format.starts_with(
"t"))
294 else if (format ==
"tdm")
298 else if (format.starts_with(
"tss:"))
302 else if (format.starts_with(
"tsm:"))
306 else if (format.starts_with(
"tsu:"))
310 else if (format.starts_with(
"tsn:"))
314 else if (format ==
"tDs")
318 else if (format ==
"tDm")
322 else if (format ==
"tDu")
326 else if (format ==
"tDn")
330 else if (format ==
"tiM")
334 else if (format ==
"tiD")
338 else if (format ==
"tin")
342 else if (format ==
"tts")
346 else if (format ==
"ttm")
350 else if (format ==
"ttu")
354 else if (format ==
"ttn")
359 else if (format ==
"+l")
363 else if (format ==
"+L")
367 else if (format ==
"+vl")
371 else if (format ==
"+vL")
375 else if (format.starts_with(
"+w:"))
379 else if (format ==
"+s")
383 else if (format ==
"+m")
387 else if (format.starts_with(
"+ud:"))
391 else if (format.starts_with(
"+us:"))
395 else if (format.starts_with(
"+r"))
399 else if (format.starts_with(
"d:"))
413 throw std::runtime_error(
"Invalid format for decimal");
416 else if (format.starts_with(
"w:"))
427 template <std::
floating_po
int T>
428 requires(
sizeof(T) >= 2 &&
sizeof(T) <= 8)
448 template <std::
integral T>
449 requires(
sizeof(T) >= 1 &&
sizeof(T) <= 8)
452 if constexpr (std::same_as<bool, T>)
456 else if constexpr (std::signed_integral<T>)
473 static_assert(std::unsigned_integral<T>);
576 throw std::runtime_error(
"Unsupported data type");
653 std::chrono::seconds,
654 std::chrono::milliseconds,
655 std::chrono::microseconds,
656 std::chrono::nanoseconds,
729 template <
template <
class>
class>
745 typename T::value_type;
768 template <has_arrow_type_traits T>
776 template <has_arrow_type_traits T>
784 template <has_arrow_type_traits T>
791 template <has_arrow_type_traits T>
827 template <
class C,
bool is_const>
829 : std::conditional<is_const, typename C::inner_const_reference, typename C::inner_reference>
833 template <
class C,
bool is_const>
838 concept layout_offset = std::same_as<T, std::int32_t> || std::same_as<T, std::int64_t>;
841#if defined(__cpp_lib_format)
848 constexpr auto parse(std::format_parse_context& ctx)
889 return "Large string";
893 return "Large binary";
897 return "Date milliseconds";
899 return "Timestamp seconds";
901 return "Timestamp milliseconds";
903 return "Timestamp microseconds";
905 return "Timestamp nanoseconds";
907 return "Duration seconds";
909 return "Duration milliseconds";
911 return "Duration microseconds";
913 return "Duration nanoseconds";
915 return "Interval months";
917 return "Interval days time";
919 return "Interval months days nanoseconds";
921 return "Time seconds";
923 return "Time milliseconds";
925 return "Time microseconds";
927 return "Time nanoseconds";
935 return "Large list view";
937 return "Fixed sized list";
943 return "Dense union";
945 return "Sparse union";
947 return "Run encoded";
957 return "Fixed width binary";
959 return "String view";
961 return "Binary view";
966 return std::format_to(ctx.out(),
"{}", get_enum_name(
data_type));
972struct std::formatter<
sparrow::null_type>
974 constexpr auto parse(std::format_parse_context& ctx)
979 auto format(
const sparrow::null_type&, std::format_context& ctx)
const
981 return std::format_to(ctx.out(),
"null_type");
987 os << std::format(
"{}",
"null");
992struct std::formatter<
std::byte>
994 constexpr auto parse(std::format_parse_context& ctx)
999 auto format(
const std::byte& b, std::format_context& ctx)
const
1001 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)
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 >, zoned_time_without_timezone_seconds, zoned_time_without_timezone_milliseconds, zoned_time_without_timezone_microseconds, zoned_time_without_timezone_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 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...
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
std::ostream & operator<<(std::ostream &os, const sparrow::nullval_t &)
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.
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.