22 namespace CUDF_EXPORT
cudf {
47 return type_id::EMPTY;
54 struct type_to_name_impl {
61 inline std::string operator()()
67 template <cudf::type_
id t>
68 struct id_to_type_impl {
80 template <cudf::type_
id Id>
100 std::conditional_t<std::is_same_v<numeric::decimal32, T>, int32_t,
101 std::conditional_t<std::is_same_v<numeric::decimal64, T>, int64_t,
102 std::conditional_t<std::is_same_v<numeric::decimal128, T>, __int128_t, T>>>;
120 template <
typename T>
123 return base_type_to_id<std::remove_cv_t<T>>();
133 #ifndef CUDF_TYPE_MAPPING
134 #define CUDF_TYPE_MAPPING(Type, Id) \
136 constexpr inline type_id base_type_to_id<Type>() \
141 inline std::string type_to_name_impl::operator()<Type>() \
143 return CUDF_STRINGIFY(Type); \
146 struct id_to_type_impl<Id> { \
192 return type_id::INT8;
204 template <
typename T>
207 return (
id == type_id::DECIMAL32 && std::is_same_v<T, int32_t>) ||
208 (
id == type_id::DECIMAL64 && std::is_same_v<T, int64_t>) ||
209 (
id == type_id::DECIMAL128 && std::is_same_v<T, __int128_t>) ||
id == type_to_id<T>();
220 template <cudf::type_
id Id>
225 template <
typename T>
226 struct type_to_scalar_type_impl {
236 #ifndef MAP_NUMERIC_SCALAR
237 #define MAP_NUMERIC_SCALAR(Type) \
239 struct type_to_scalar_type_impl<Type> { \
240 using ScalarType = cudf::numeric_scalar<Type>; \
241 using ScalarDeviceType = cudf::numeric_scalar_device_view<Type>; \
259 struct type_to_scalar_type_impl<std::string> {
265 struct type_to_scalar_type_impl<
cudf::string_view> {
296 struct type_to_scalar_type_impl<
cudf::list_view> {
302 struct type_to_scalar_type_impl<
cudf::struct_view> {
313 #ifndef MAP_TIMESTAMP_SCALAR
314 #define MAP_TIMESTAMP_SCALAR(Type) \
316 struct type_to_scalar_type_impl<Type> { \
317 using ScalarType = cudf::timestamp_scalar<Type>; \
318 using ScalarDeviceType = cudf::timestamp_scalar_device_view<Type>; \
334 #ifndef MAP_DURATION_SCALAR
335 #define MAP_DURATION_SCALAR(Type) \
337 struct type_to_scalar_type_impl<Type> { \
338 using ScalarType = cudf::duration_scalar<Type>; \
339 using ScalarDeviceType = cudf::duration_scalar_device_view<Type>; \
354 template <
typename T>
362 template <
typename T>
460 #pragma nv_exec_check_disable
462 template <
template <cudf::type_
id>
typename IdTypeMap = id_to_type_impl,
469 switch (dtype.id()) {
471 return f.template operator()<
typename IdTypeMap<type_id::INT8>::type>(
472 std::forward<Ts>(args)...);
474 return f.template operator()<
typename IdTypeMap<type_id::INT16>::type>(
475 std::forward<Ts>(args)...);
477 return f.template operator()<
typename IdTypeMap<type_id::INT32>::type>(
478 std::forward<Ts>(args)...);
480 return f.template operator()<
typename IdTypeMap<type_id::INT64>::type>(
481 std::forward<Ts>(args)...);
483 return f.template operator()<
typename IdTypeMap<type_id::UINT8>::type>(
484 std::forward<Ts>(args)...);
485 case type_id::UINT16:
486 return f.template operator()<
typename IdTypeMap<type_id::UINT16>::type>(
487 std::forward<Ts>(args)...);
488 case type_id::UINT32:
489 return f.template operator()<
typename IdTypeMap<type_id::UINT32>::type>(
490 std::forward<Ts>(args)...);
491 case type_id::UINT64:
492 return f.template operator()<
typename IdTypeMap<type_id::UINT64>::type>(
493 std::forward<Ts>(args)...);
494 case type_id::FLOAT32:
495 return f.template operator()<
typename IdTypeMap<type_id::FLOAT32>::type>(
496 std::forward<Ts>(args)...);
497 case type_id::FLOAT64:
498 return f.template operator()<
typename IdTypeMap<type_id::FLOAT64>::type>(
499 std::forward<Ts>(args)...);
501 return f.template operator()<
typename IdTypeMap<type_id::BOOL8>::type>(
502 std::forward<Ts>(args)...);
503 case type_id::TIMESTAMP_DAYS:
504 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_DAYS>::type>(
505 std::forward<Ts>(args)...);
506 case type_id::TIMESTAMP_SECONDS:
507 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_SECONDS>::type>(
508 std::forward<Ts>(args)...);
509 case type_id::TIMESTAMP_MILLISECONDS:
510 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_MILLISECONDS>::type>(
511 std::forward<Ts>(args)...);
512 case type_id::TIMESTAMP_MICROSECONDS:
513 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_MICROSECONDS>::type>(
514 std::forward<Ts>(args)...);
515 case type_id::TIMESTAMP_NANOSECONDS:
516 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_NANOSECONDS>::type>(
517 std::forward<Ts>(args)...);
518 case type_id::DURATION_DAYS:
519 return f.template operator()<
typename IdTypeMap<type_id::DURATION_DAYS>::type>(
520 std::forward<Ts>(args)...);
521 case type_id::DURATION_SECONDS:
522 return f.template operator()<
typename IdTypeMap<type_id::DURATION_SECONDS>::type>(
523 std::forward<Ts>(args)...);
524 case type_id::DURATION_MILLISECONDS:
525 return f.template operator()<
typename IdTypeMap<type_id::DURATION_MILLISECONDS>::type>(
526 std::forward<Ts>(args)...);
527 case type_id::DURATION_MICROSECONDS:
528 return f.template operator()<
typename IdTypeMap<type_id::DURATION_MICROSECONDS>::type>(
529 std::forward<Ts>(args)...);
530 case type_id::DURATION_NANOSECONDS:
531 return f.template operator()<
typename IdTypeMap<type_id::DURATION_NANOSECONDS>::type>(
532 std::forward<Ts>(args)...);
533 case type_id::DICTIONARY32:
534 return f.template operator()<
typename IdTypeMap<type_id::DICTIONARY32>::type>(
535 std::forward<Ts>(args)...);
536 case type_id::STRING:
537 return f.template operator()<
typename IdTypeMap<type_id::STRING>::type>(
538 std::forward<Ts>(args)...);
540 return f.template operator()<
typename IdTypeMap<type_id::LIST>::type>(
541 std::forward<Ts>(args)...);
542 case type_id::DECIMAL32:
543 return f.template operator()<
typename IdTypeMap<type_id::DECIMAL32>::type>(
544 std::forward<Ts>(args)...);
545 case type_id::DECIMAL64:
546 return f.template operator()<
typename IdTypeMap<type_id::DECIMAL64>::type>(
547 std::forward<Ts>(args)...);
548 case type_id::DECIMAL128:
549 return f.template operator()<
typename IdTypeMap<type_id::DECIMAL128>::type>(
550 std::forward<Ts>(args)...);
551 case type_id::STRUCT:
552 return f.template operator()<
typename IdTypeMap<type_id::STRUCT>::type>(
553 std::forward<Ts>(args)...);
555 #ifndef __CUDA_ARCH__
558 CUDF_UNREACHABLE(
"Invalid type_id.");
566 template <
typename T1>
567 struct double_type_dispatcher_second_type {
569 #pragma nv_exec_check_disable
571 template <
typename T2,
typename F,
typename... Ts>
572 CUDF_HOST_DEVICE __forceinline__ decltype(
auto) operator()(F&& f, Ts&&... args)
const
574 return f.template operator()<T1, T2>(std::forward<Ts>(args)...);
578 template <
template <cudf::type_
id>
typename IdTypeMap>
579 struct double_type_dispatcher_first_type {
581 #pragma nv_exec_check_disable
583 template <
typename T1,
typename F,
typename... Ts>
588 return type_dispatcher<IdTypeMap>(type2,
589 detail::double_type_dispatcher_second_type<T1>{},
591 std::forward<Ts>(args)...);
613 #pragma nv_exec_check_disable
615 template <
template <cudf::type_
id>
typename IdTypeMap = id_to_type_impl,
typename F,
typename... Ts>
619 return type_dispatcher<IdTypeMap>(type1,
620 detail::double_type_dispatcher_first_type<IdTypeMap>{},
623 std::forward<Ts>(args)...);
Indicator for the logical data type of an element in a column.
A type of scalar_device_view that stores a pointer to a fixed_point value.
An owning class to represent a fixed_point number in device memory.
An owning class to represent a list value in device memory.
A non-owning, immutable view of device data that represents a list of elements of arbitrary type (inc...
A type of scalar_device_view that stores a pointer to a numerical value.
An owning class to represent a numerical value in device memory.
An owning class to represent a singular value.
A type of scalar_device_view that stores a pointer to a string value.
An owning class to represent a string in device memory.
A non-owning, immutable view of device data that is a variable length char array representing a UTF-8...
An owning class to represent a struct value in device memory.
A non-owning, immutable view of device data that represents a struct with fields of arbitrary types (...
A type for representing a number with a fixed amount of precision.
Concrete type definition for dictionary columns.
Concrete type definitions for int32_t and int64_t durations in varying resolutions.
Class definition for fixed point data type.
dictionary_wrapper< int32_t > dictionary32
32-bit integer indexed dictionary wrapper
fixed_point< int32_t, Radix::BASE_10 > decimal32
32-bit decimal fixed point
fixed_point< int64_t, Radix::BASE_10 > decimal64
64-bit decimal fixed point
fixed_point< __int128_t, Radix::BASE_10 > decimal128
128-bit decimal fixed point
detail::timestamp< cudf::duration_ms > timestamp_ms
Type alias representing a cudf::duration_ms (int64_t) since the unix epoch.
detail::timestamp< cudf::duration_s > timestamp_s
Type alias representing a cudf::duration_s (int64_t) since the unix epoch.
detail::timestamp< cudf::duration_D > timestamp_D
Type alias representing a cudf::duration_D (int32_t) since the unix epoch.
cuda::std::chrono::duration< int64_t, cuda::std::chrono::nanoseconds::period > duration_ns
Type alias representing an int64_t duration of nanoseconds.
cuda::std::chrono::duration< int32_t, cuda::std::chrono::days::period > duration_D
Type alias representing an int32_t duration of days.
cuda::std::chrono::duration< int64_t, cuda::std::chrono::milliseconds::period > duration_ms
Type alias representing an int64_t duration of milliseconds.
cuda::std::chrono::duration< int64_t, cuda::std::chrono::microseconds::period > duration_us
Type alias representing an int64_t duration of microseconds.
detail::timestamp< cudf::duration_us > timestamp_us
Type alias representing a cudf::duration_us (int64_t) since the unix epoch.
detail::timestamp< cudf::duration_ns > timestamp_ns
Type alias representing a cudf::duration_ns (int64_t) since the unix epoch.
cuda::std::chrono::duration< int64_t, cuda::std::chrono::seconds::period > duration_s
Type alias representing an int64_t duration of seconds.
#define MAP_TIMESTAMP_SCALAR(Type)
Macro used to define scalar type and scalar device type for cudf::timestamp_scalar template class for...
constexpr CUDF_HOST_DEVICE type_id base_type_to_id()
Maps a C++ type to its corresponding cudf::type_id
std::string type_to_name(data_type type)
Return a name for a given type.
#define MAP_DURATION_SCALAR(Type)
Macro used to define scalar type and scalar device type for cudf::duration_scalar template class for ...
CUDF_HOST_DEVICE constexpr decltype(auto) __forceinline__ type_dispatcher(cudf::data_type dtype, Functor f, Ts &&... args)
Invokes an operator() template with the type instantiation based on the specified cudf::data_type's i...
std::conditional_t< std::is_same_v< numeric::decimal32, T >, int32_t, std::conditional_t< std::is_same_v< numeric::decimal64, T >, int64_t, std::conditional_t< std::is_same_v< numeric::decimal128, T >, __int128_t, T > >> device_storage_type_t
"Returns" the corresponding type that is stored on the device when using cudf::column
typename type_to_scalar_type_impl< T >::ScalarDeviceType scalar_device_type_t
Maps a C++ type to the scalar device type required to hold its value.
constexpr type_id base_type_to_id< char >()
Specialization to map 'char' type to type_id::INT8.
#define CUDF_TYPE_MAPPING(Type, Id)
Macro used to define a mapping between a concrete C++ type and a cudf::type_id enum.
typename type_to_scalar_type_impl< T >::ScalarType scalar_type_t
Maps a C++ type to the scalar type required to hold its value.
constexpr type_id type_to_id()
Maps a C++ type to its corresponding cudf::type_id
CUDF_HOST_DEVICE constexpr decltype(auto) __forceinline__ double_type_dispatcher(cudf::data_type type1, cudf::data_type type2, F &&f, Ts &&... args)
Dispatches two type template parameters to a callable.
typename id_to_type_impl< Id >::type id_to_type
Maps a cudf::type_id to its corresponding concrete C++ type.
constexpr bool type_id_matches_device_storage_type(type_id id)
Checks if fixed_point-like types have template type T matching the column's stored type id.
#define MAP_NUMERIC_SCALAR(Type)
Macro used to define scalar type and scalar device type for cudf::numeric_scalar template class for n...
#define CUDF_FAIL(...)
Indicates that an erroneous code path has been taken.
type_id
Identifies a column's logical element type.
fixed_point and supporting types
A strongly typed wrapper for indices in a DICTIONARY type column.
Use this specialization on type_dispatcher whenever you only need to operate on the underlying stored...
device_storage_type_t< id_to_type< Id > > type
The underlying type.
Concrete type definitions for int32_t and int64_t timestamps in varying resolutions as durations sinc...
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.