Utility Types#
- group Types
Defines
-
CUDF_ENABLE_IF(...)#
Convenience macro for SFINAE as an unnamed template parameter.
Example:
// This function will participate in overload resolution only if T is an integral type template <typename T, CUDF_ENABLE_IF(std::is_integral_v<T> )> void foo();
Typedefs
-
using size_type = int32_t#
Row index type for columns and tables.
-
using bitmask_type = uint32_t#
Bitmask type stored as 32-bit unsigned integer.
-
using valid_type = uint8_t#
Valid type in host memory.
-
using thread_index_type = int64_t#
Thread index type in kernels.
-
typedef uint32_t char_utf8#
UTF-8 characters are 1-4 bytes.
-
template<typename...>
using void_t = void# Utility metafunction that maps a sequence of any types to the type void.
-
template<typename L, typename R>
using less_comparable = decltype(cuda::std::declval<L>() < cuda::std::declval<R>())# Checks if two types are comparable using less operator (i.e. <).
-
template<typename L, typename R>
using greater_comparable = decltype(cuda::std::declval<L>() > cuda::std::declval<R>())# Checks if two types are comparable using greater operator (i.e. >).
-
template<typename L, typename R>
using equality_comparable = decltype(cuda::std::declval<L>() == cuda::std::declval<R>())# Checks if two types are comparable using equality operator (i.e. ==).
-
template<typename ...Ts>
using has_common_type = typename detail::has_common_type_impl<void, Ts...>::type# Checks if types have a common type.
-
template<typename T>
using is_timestamp_t = cuda::std::disjunction<cuda::std::is_same<cudf::timestamp_D, T>, cuda::std::is_same<cudf::timestamp_h, T>, cuda::std::is_same<cudf::timestamp_m, T>, cuda::std::is_same<cudf::timestamp_s, T>, cuda::std::is_same<cudf::timestamp_ms, T>, cuda::std::is_same<cudf::timestamp_us, T>, cuda::std::is_same<cudf::timestamp_ns, T>># Checks if a type is a timestamp type.
-
template<typename T>
using is_duration_t = cuda::std::disjunction<cuda::std::is_same<cudf::duration_D, T>, cuda::std::is_same<cudf::duration_h, T>, cuda::std::is_same<cudf::duration_m, T>, cuda::std::is_same<cudf::duration_s, T>, cuda::std::is_same<cudf::duration_ms, T>, cuda::std::is_same<cudf::duration_us, T>, cuda::std::is_same<cudf::duration_ns, T>># Checks if a type is a duration type.
Enums
-
enum class order : bool#
Indicates the order in which elements should be sorted.
Values:
-
enumerator ASCENDING#
Elements ordered from small to large.
-
enumerator DESCENDING#
Elements ordered from large to small.
-
enumerator ASCENDING#
-
enum class null_policy : bool#
Enum to specify whether to include nulls or exclude nulls.
Values:
-
enumerator EXCLUDE#
exclude null elements
-
enumerator INCLUDE#
include null elements
-
enumerator EXCLUDE#
-
enum class nan_policy : bool#
Enum to treat NaN floating point value as null or non-null element.
Values:
-
enumerator NAN_IS_NULL#
treat nans as null elements
-
enumerator NAN_IS_VALID#
treat nans as valid elements (non-null)
-
enumerator NAN_IS_NULL#
-
enum class nan_equality#
Enum to consider different elements (of floating point types) holding NaN value as equal or unequal.
Values:
-
enumerator ALL_EQUAL#
All NaNs compare equal, regardless of sign.
-
enumerator UNEQUAL#
All NaNs compare unequal (IEEE754 behavior)
-
enumerator ALL_EQUAL#
-
enum class null_equality : bool#
Enum to consider two nulls as equal or unequal.
Values:
-
enumerator EQUAL#
nulls compare equal
-
enumerator UNEQUAL#
nulls compare unequal
-
enumerator EQUAL#
-
enum class null_order : bool#
Indicates how null values compare against all other values.
Values:
-
enumerator AFTER#
NULL values ordered after all other values.
-
enumerator BEFORE#
NULL values ordered before all other values.
-
enumerator AFTER#
-
enum class sorted : bool#
Indicates whether a collection of values is known to be sorted.
Values:
-
enumerator NO#
-
enumerator YES#
-
enumerator NO#
-
enum class mask_state : int32_t#
Controls the allocation/initialization of a null mask.
Values:
-
enumerator UNALLOCATED#
Null mask not allocated, (all elements are valid)
-
enumerator UNINITIALIZED#
Null mask allocated, but not initialized.
-
enumerator ALL_VALID#
Null mask allocated, initialized to all elements valid.
-
enumerator ALL_NULL#
Null mask allocated, initialized to all elements NULL.
-
enumerator UNALLOCATED#
-
enum class interpolation : int32_t#
Interpolation method to use when the desired quantile lies between two data points i and j.
Values:
-
enumerator LINEAR#
Linear interpolation between i and j.
-
enumerator LOWER#
Lower data point (i)
-
enumerator HIGHER#
Higher data point (j)
-
enumerator MIDPOINT#
(i + j)/2
-
enumerator NEAREST#
i or j, whichever is nearest
-
enumerator LINEAR#
-
enum class type_id : int32_t#
Identifies a column’s logical element type.
Values:
-
enumerator EMPTY#
Always null with no underlying data.
-
enumerator INT8#
1 byte signed integer
-
enumerator INT16#
2 byte signed integer
-
enumerator INT32#
4 byte signed integer
-
enumerator INT64#
8 byte signed integer
-
enumerator UINT8#
1 byte unsigned integer
-
enumerator UINT16#
2 byte unsigned integer
-
enumerator UINT32#
4 byte unsigned integer
-
enumerator UINT64#
8 byte unsigned integer
-
enumerator FLOAT32#
4 byte floating point
-
enumerator FLOAT64#
8 byte floating point
-
enumerator BOOL8#
Boolean using one byte per value, 0 == false, else true.
-
enumerator TIMESTAMP_DAYS#
point in time in days since Unix Epoch in int32
-
enumerator TIMESTAMP_SECONDS#
point in time in seconds since Unix Epoch in int64
-
enumerator TIMESTAMP_MILLISECONDS#
point in time in milliseconds since Unix Epoch in int64
-
enumerator TIMESTAMP_MICROSECONDS#
point in time in microseconds since Unix Epoch in int64
-
enumerator TIMESTAMP_NANOSECONDS#
point in time in nanoseconds since Unix Epoch in int64
-
enumerator DURATION_DAYS#
time interval of days in int32
-
enumerator DURATION_SECONDS#
time interval of seconds in int64
-
enumerator DURATION_MILLISECONDS#
time interval of milliseconds in int64
-
enumerator DURATION_MICROSECONDS#
time interval of microseconds in int64
-
enumerator DURATION_NANOSECONDS#
time interval of nanoseconds in int64
-
enumerator DICTIONARY32#
Dictionary type using int32 indices.
-
enumerator STRING#
String elements.
-
enumerator LIST#
List elements.
-
enumerator DECIMAL32#
Fixed-point type with int32_t.
-
enumerator DECIMAL64#
Fixed-point type with int64_t.
-
enumerator DECIMAL128#
Fixed-point type with __int128_t.
-
enumerator STRUCT#
Struct elements.
-
enumerator NUM_TYPE_IDS#
Total number of type ids.
-
enumerator EMPTY#
Functions
-
template<typename T>
size_type distance(T f, T l)# Similar to
std::distancebut returnscudf::size_typeand performsstatic_cast- Template Parameters:
T – Iterator type
- Parameters:
f – “first” iterator
l – “last” iterator
- Returns:
The distance between first and last
-
constexpr bool operator==(data_type const &lhs, data_type const &rhs)#
Compares two
data_typeobjects for equality.// TODO Define exactly what it means for two
data_types to be equal. e.g., are two timestamps with different resolutions equal? How about decimals with different scale/precision?
-
inline bool operator!=(data_type const &lhs, data_type const &rhs)#
Compares two
data_typeobjects for inequality.// TODO Define exactly what it means for two
data_types to be equal. e.g., are two timestamps with different resolutions equal? How about decimals with different scale/precision?
-
std::size_t size_of(data_type t)#
Returns the size in bytes of elements of the specified
data_typeNote
Only fixed-width types are supported
- Throws:
cudf::logic_error – if
is_fixed_width(element_type) == false- Parameters:
t – The
data_typeto get the size of- Returns:
Size in bytes of an element of the specified
data_type
-
template<typename T>
inline constexpr bool has_atomic_support()# Indicates whether the type
Thas support for atomics.- Template Parameters:
T – The type to verify
- Returns:
true
Thas support for atomics- Returns:
false
Tno support for atomics
-
inline constexpr bool has_atomic_support(data_type type)#
Indicates whether
typehas support for atomics.- Parameters:
type – The
data_typeto verify- Returns:
true
typehas support for atomics- Returns:
false
typeno support for atomics
-
template<typename L, typename R>
inline constexpr bool is_relationally_comparable()# Indicates whether objects of types
LandRcan be relationally compared.Given two objects
L l, andR r, returns true ifl < randl > rare well-formed expressions.- Template Parameters:
L – Type of the first object
R – Type of the second object
- Returns:
true Objects of types
LandRcan be relationally be compared- Returns:
false Objects of types
LandRcannot be compared
-
bool is_relationally_comparable(data_type type)#
Checks whether
data_typetypesupports relational comparisons.- Parameters:
type – Data_type for comparison.
- Returns:
true If
typesupports relational comparisons.- Returns:
false If
typedoes not support relational comparisons.
-
template<typename L, typename R>
inline constexpr bool is_equality_comparable()# Indicates whether objects of types
LandRcan be compared for equality.Given two objects
L l, andR r, returns true ifl == ris a well-formed expression.- Template Parameters:
L – Type of the first object
R – Type of the second object
- Returns:
true Objects of types
LandRcan be compared for equality- Returns:
false Objects of types
LandRcannot be compared
-
bool is_equality_comparable(data_type type)#
Checks whether
data_typetypesupports equality comparisons.- Parameters:
type – Data_type for comparison.
- Returns:
true If
typesupports equality comparisons.- Returns:
false If
typedoes not support equality comparisons.
-
template<typename T>
inline constexpr bool is_numeric()# Indicates whether the type
Tis a numeric type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis numeric- Returns:
false
Tis not numeric
-
bool is_numeric(data_type type)#
Indicates whether
typeis a numericdata_type.“Numeric” types are fundamental integral/floating point types such as
INT*orFLOAT*. Types that wrap a numeric type are not considered numeric, e.g.,TIMESTAMP.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis numeric- Returns:
false
typeis not numeric
-
template<typename T>
inline constexpr bool is_index_type()# Indicates whether the type
Tis a index type.A type
Tis considered an index type if it is valid to use elements of typeTto index into a column. I.e., index types are integral types such as ‘INT*’ apart from ‘bool’.- Template Parameters:
T – The type to verify
- Returns:
true
Tis index type- Returns:
false
Tis not index type
-
bool is_index_type(data_type type)#
Indicates whether the type
typeis a index type.A type
Tis considered an index type if it is valid to use elements of typeTto index into a column. I.e., index types are integral types such as ‘INT*’ apart from ‘bool’.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis index type- Returns:
false
typeis not index type
-
template<typename T>
inline constexpr bool is_signed()# Indicates whether the type
Tis a signed numeric type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis signed numeric
-
bool is_signed(data_type type)#
Indicates whether
typeis a signed numericdata_type.“Signed Numeric” types include fundamental integral types such as
INT*but can also beFLOAT*types.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis signed numeric
-
template<typename T>
inline constexpr bool is_unsigned()# Indicates whether the type
Tis a unsigned numeric type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis unsigned numeric- Returns:
false
Tis signed numeric
-
bool is_unsigned(data_type type)#
Indicates whether
typeis a unsigned numericdata_type.“Unsigned Numeric” types are fundamental integral types such as
UINT*.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis unsigned numeric- Returns:
false
typeis signed numeric
-
template<typename Iterator>
inline constexpr bool is_signed_iterator()# Indicates whether the
Iteratorvalue type is unsigned.- Template Parameters:
Iterator – The type to verify
- Returns:
true if the iterator’s value type is unsigned
-
template<typename T>
inline constexpr bool is_integral()# Indicates whether the type
Tis an integral type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis integral- Returns:
false
Tis not integral
-
bool is_integral(data_type type)#
Indicates whether
typeis a integraldata_type.“Integral” types are fundamental integer types such as
INT*andUINT*.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis integral- Returns:
false
typeis integral
-
template<typename T>
inline constexpr bool is_integral_not_bool()# Indicates whether the type
Tis an integral type but not bool type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis integral but not bool- Returns:
false
Tis not integral or is bool
-
bool is_integral_not_bool(data_type type)#
Indicates whether
typeis a integraldata_typeand not BOOL8.“Integral” types are fundamental integer types such as
INT*andUINT*.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis integral but not bool- Returns:
false
typeis integral or is bool
-
template<typename T>
inline constexpr bool is_numeric_not_bool()# Indicates whether the type
Tis a numeric type but not bool type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis numeric but not bool- Returns:
false
Tis not numeric or is bool
-
bool is_numeric_not_bool(data_type type)#
Indicates whether
typeis a numericdata_typebut not BOOL8.“Numeric” types are integral/floating point types such as
INT*orFLOAT*.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis numeric but not bool- Returns:
false
typeis not numeric or is bool
-
template<typename T>
inline constexpr bool is_floating_point()# Indicates whether the type
Tis a floating point type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis floating point- Returns:
false
Tis not floating point
-
bool is_floating_point(data_type type)#
Indicates whether
typeis a floating pointdata_type.“Floating point” types are fundamental floating point types such as
FLOAT*.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis floating point- Returns:
false
typeis not floating point
-
template<typename T>
inline constexpr bool is_byte()# Indicates whether
Tis a std::byte type.- Template Parameters:
T – The type to verify
- Returns:
true
typeis std::byte- Returns:
false
typeis not std::byte
-
template<typename T>
inline constexpr bool is_boolean()# Indicates whether
Tis a Boolean type.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis Boolean- Returns:
false
typeis not Boolean
-
bool is_boolean(data_type type)#
Indicates whether
typeis a Booleandata_type.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis a Boolean- Returns:
false
typeis not a Boolean
-
template<typename T>
inline constexpr bool is_timestamp()# Indicates whether the type
Tis a timestamp type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis a timestamp- Returns:
false
Tis not a timestamp
-
bool is_timestamp(data_type type)#
Indicates whether
typeis a timestampdata_type.“Timestamp” types are int32_t or int64_t durations since the unix epoch.
- Parameters:
type – The
data_typeto verify- Returns:
true
typeis a timestamp- Returns:
false
typeis not a timestamp
-
template<typename T>
inline constexpr bool is_fixed_point()# Indicates whether the type
Tis a fixed-point type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis a fixed-point type- Returns:
false
Tis not a fixed-point type
-
bool is_fixed_point(data_type type)#
Indicates whether
typeis a fixed pointdata_type.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis a fixed point type- Returns:
false
typeis not a fixed point type
-
template<typename T>
inline constexpr bool is_duration()# Indicates whether the type
Tis a duration type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis a duration- Returns:
false
Tis not a duration
-
bool is_duration(data_type type)#
Indicates whether
typeis a durationdata_type.“Duration” types are int32_t or int64_t tick counts representing a time interval.
- Parameters:
type – The
data_typeto verify- Returns:
true
typeis a duration- Returns:
false
typeis not a duration
-
template<typename T>
inline constexpr bool is_chrono()# Indicates whether the type
Tis a chrono type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis a duration or a timestamp type- Returns:
false
Tis neither a duration nor a timestamp type
-
bool is_chrono(data_type type)#
Indicates whether
typeis a chronodata_type.Chrono types include cudf timestamp types, which represent a point in time, and cudf duration types that represent a time interval.
- Parameters:
type – The
data_typeto verify- Returns:
true
typeis a chrono type- Returns:
false
typeis not a chrono type
-
template<typename T>
constexpr bool is_rep_layout_compatible()# Indicates whether
Tis layout compatible with its “representation” type.For example, in a column, a
decimal32is concretely represented by a singleint32_t, but thedecimal32type itself contains both the integer representation and the scale. Therefore,decimal32is not layout compatible withint32_t.As further example,
duration_nsis distinct from its concreteint64_trepresentation type, but they are layout compatible.- Returns:
true if
Tis layout compatible with its “representation” type
-
template<typename T>
inline constexpr bool is_dictionary()# Indicates whether the type
Tis a dictionary type.- Template Parameters:
T – The type to verify
- Returns:
true
Tis a dictionary-type- Returns:
false
Tis not dictionary-type
-
bool is_dictionary(data_type type)#
Indicates whether
typeis a dictionarydata_type.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis a dictionary type- Returns:
false
typeis not a dictionary type
-
template<typename T>
inline constexpr bool is_fixed_width()# Indicates whether elements of type
Tare fixed-width.Elements of a fixed-width type all have the same size in bytes.
- Template Parameters:
T – The C++ type to verify
- Returns:
true
Tcorresponds to a fixed-width element type- Returns:
false
Tcorresponds to a variable-width element type
-
bool is_fixed_width(data_type type)#
Indicates whether elements of
typeare fixed-width.Elements of a fixed-width type all have the same size in bytes.
- Parameters:
type – The
data_typeto verify- Returns:
true
typeis fixed-width- Returns:
false
typeis variable-width
-
template<typename T>
inline constexpr bool is_compound()# Indicates whether the type
Tis a compound type.columns with “compound” elements are logically a single column of elements, but may be concretely implemented with two or morecolumns. For example, aSTRINGcolumn could contain acolumnof offsets and a childcolumnof characters.- Template Parameters:
T – The type to verify
- Returns:
true
Tcorresponds to a “compound” type- Returns:
false
Tcorresponds to a “simple” type
-
bool is_compound(data_type type)#
Indicates whether elements of
typeare compound.columns with “compound” elements are logically a single column of elements, but may be concretely implemented with two or morecolumns. For example, aSTRINGcolumn could contain acolumnof offsets and a childcolumnof characters.- Parameters:
type – The
data_typeto verify- Returns:
true
typeis a compound type- Returns:
false
typeis a simple type
-
template<typename T>
inline constexpr bool is_nested()# Indicates whether
Tis a nested type.“Nested” types are distinct from compound types in that they can have an arbitrarily deep list of descendants of the same type. Strings are not a nested type, but lists are.
- Parameters:
T – The type to verify
- Returns:
true T is a nested type
- Returns:
false T is not a nested type
-
bool is_nested(data_type type)#
Indicates whether
typeis a nested type.“Nested” types are distinct from compound types in that they can have an arbitrarily deep list of descendants of the same type. Strings are not a nested type, but lists are.
- Parameters:
type – The
data_typeto verify- Returns:
true
typeis a nested type- Returns:
false
typeis not a nested type
-
bool is_bit_castable(data_type from, data_type to)#
Indicates whether
fromis bit-castable toto.This casting is based on std::bit_cast. Data types that have the same size and are trivially copyable are eligible for this casting.
See
cudf::bit_cast()which returns a zero-copycolumn_viewwhen casting between bit-castable types.
Variables
-
struct order_info#
- #include <types.hpp>
Indicates how a collection of values has been ordered.
-
class data_type#
- #include <types.hpp>
Indicator for the logical data type of an element in a column.
Simple types can be entirely described by their
id(), but some types require additional metadata to fully describe elements of that type.Public Functions
-
data_type &operator=(data_type const&) = default#
Copy assignment operator for data_type.
- Returns:
Reference to this object
-
data_type &operator=(data_type&&) = default#
Move assignment operator for data_type.
- Returns:
Reference to this object
-
inline explicit constexpr data_type(type_id id)#
Construct a new
data_typeobject.- Parameters:
id – The type’s identifier
-
inline explicit data_type(type_id id, int32_t scale)#
Construct a new
data_typeobject fornumeric::fixed_point- Parameters:
id – The
fixed_point’s identifierscale – The
fixed_point’s scale (seefixed_point::_scale)
-
inline constexpr type_id id() const noexcept#
Returns the type identifier.
- Returns:
The type identifier
-
inline constexpr int32_t scale() const noexcept#
Returns the scale (for fixed_point types)
- Returns:
The scale
-
data_type &operator=(data_type const&) = default#
-
CUDF_ENABLE_IF(...)#