实用类型#

group utility_types

定义

CUDF_ENABLE_IF(...)#

作为未命名模板参数的SFINAE便利宏。

示例:

// 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();

类型定义

using size_type = int32_t#

行索引类型用于列和表。

using bitmask_type = uint32_t#

位掩码类型存储为32位无符号整数。

using valid_type = uint8_t#

主机内存中的有效类型。

using thread_index_type = int64_t#

内核中的线程索引类型。

typedef uint32_t char_utf8#

UTF-8 字符占用 1-4 个字节。

template<typename...>
using void_t = void#

实用元函数,将任何类型的序列映射到void类型。

template<typename L, typename R>
using less_comparable = decltype(std::declval<L>() < std::declval<R>())#

检查两种类型是否可以使用小于运算符进行比较(即 <)。

template<typename L, typename R>
using greater_comparable = decltype(std::declval<L>() > std::declval<R>())#

检查两种类型是否可以使用大于运算符进行比较(即 >)。

template<typename L, typename R>
using equality_comparable = decltype(std::declval<L>() == std::declval<R>())#

检查两种类型是否可以使用相等运算符(即 ==)进行比较。

template<typename ...Ts>
using has_common_type = typename detail::has_common_type_impl<void, Ts...>::type#

检查类型是否具有共同类型。

template<typename T>
using is_timestamp_t = cuda::std::disjunction<std::is_same<cudf::timestamp_D, T>, std::is_same<cudf::timestamp_s, T>, std::is_same<cudf::timestamp_ms, T>, std::is_same<cudf::timestamp_us, T>, std::is_same<cudf::timestamp_ns, T>>#

检查类型是否为时间戳类型。

template<typename T>
using is_duration_t = cuda::std::disjunction<std::is_same<cudf::duration_D, T>, std::is_same<cudf::duration_s, T>, std::is_same<cudf::duration_ms, T>, std::is_same<cudf::duration_us, T>, std::is_same<cudf::duration_ns, T>>#

检查类型是否为持续时间类型。

枚举

enum class order : bool#

指示元素应按何种顺序排序。

值:

enumerator ASCENDING#

元素按从小到大排序。

enumerator DESCENDING#

元素按从大到小排序。

enum class null_policy : bool#

枚举用于指定是包含空值还是排除空值。

值:

enumerator EXCLUDE#

排除空元素

enumerator INCLUDE#

包含空元素

enum class nan_policy : bool#

枚举将NaN浮点值视为空或非空元素。

值:

enumerator NAN_IS_NULL#

将nans视为空元素

enumerator NAN_IS_VALID#

将nans视为有效元素(非空)

enum class nan_equality#

枚举以考虑将持有NaN值的不同元素(浮点类型)视为相等或不相等。

值:

enumerator ALL_EQUAL#

所有的NaN值在比较时被视为相等,无论符号如何。

enumerator UNEQUAL#

所有NaN比较不相等(IEEE754行为)

enum class null_equality : bool#

枚举以考虑两个空值是否相等或不相等。

值:

enumerator EQUAL#

空值比较相等

enumerator UNEQUAL#

空值比较不相等

enum class null_order : bool#

指示空值如何与所有其他值进行比较。

值:

enumerator AFTER#

NULL值在所有其他值之后排序。

enumerator BEFORE#

NULL值在所有其他值之前排序。

enum class sorted : bool#

指示一组值是否已知已排序。

值:

enumerator NO#
enumerator YES#
enum class mask_state : int32_t#

控制空掩码的分配/初始化。

值:

enumerator UNALLOCATED#

未分配空掩码,(所有元素均有效)

enumerator UNINITIALIZED#

空掩码已分配,但未初始化。

enumerator ALL_VALID#

空掩码已分配,初始化为所有元素有效。

enumerator ALL_NULL#

空掩码已分配,初始化为所有元素为空。

enum class interpolation : int32_t#

当所需的分位数位于两个数据点i和j之间时使用的插值方法。

值:

enumerator LINEAR#

在i和j之间进行线性插值。

enumerator LOWER#

较低的数据点 (i)

enumerator HIGHER#

更高的数据点 (j)

enumerator MIDPOINT#

(i + j)/2

enumerator NEAREST#

i 或 j,取最接近的那个

enum class type_id : int32_t#

标识列的逻辑元素类型。

值:

enumerator EMPTY#

始终为空,没有基础数据。

enumerator INT8#

1 字节有符号整数

enumerator INT16#

2字节有符号整数

enumerator INT32#

4字节有符号整数

enumerator INT64#

8字节有符号整数

enumerator UINT8#

1 字节无符号整数

enumerator UINT16#

2字节无符号整数

enumerator UINT32#

4字节无符号整数

enumerator UINT64#

8字节无符号整数

enumerator FLOAT32#

4字节浮点数

enumerator FLOAT64#

8字节浮点数

enumerator BOOL8#

布尔值每个值使用一个字节,0 == 假,其他为真。

enumerator TIMESTAMP_DAYS#

自Unix纪元以来的天数,以int32表示

enumerator TIMESTAMP_SECONDS#

自Unix纪元以来的时间点,以秒为单位,类型为int64

enumerator TIMESTAMP_MILLISECONDS#

自Unix纪元以来的时间点,以毫秒为单位,类型为int64

enumerator TIMESTAMP_MICROSECONDS#

自Unix纪元以来的微秒时间点,以int64表示

enumerator TIMESTAMP_NANOSECONDS#

自Unix纪元以来的纳秒时间点,以int64表示

enumerator DURATION_DAYS#

时间间隔,以天为单位,数据类型为int32

enumerator DURATION_SECONDS#

时间间隔,以秒为单位,类型为int64

enumerator DURATION_MILLISECONDS#

以int64表示的毫秒时间间隔

enumerator DURATION_MICROSECONDS#

以int64表示的微秒时间间隔

enumerator DURATION_NANOSECONDS#

以int64表示的纳秒时间间隔

enumerator DICTIONARY32#

使用int32索引的字典类型。

enumerator STRING#

字符串元素。

enumerator LIST#

列出元素。

enumerator DECIMAL32#

使用int32_t的定点类型。

enumerator DECIMAL64#

使用 int64_t 的定点类型。

enumerator DECIMAL128#

使用 __int128_t 的定点类型。

enumerator STRUCT#

结构元素。

enumerator NUM_TYPE_IDS#

类型ID的总数。

函数

template<typename T>
size_type distance(T f, T l)#

类似于 std::distance 但返回 cudf::size_type 并执行 static_cast

Template Parameters:

T – 迭代器类型

Parameters:
  • f – “第一个”迭代器

  • l – “最后”迭代器

Returns:

第一个和最后一个之间的距离

constexpr bool operator==(data_type const &lhs, data_type const &rhs)#

比较两个data_type对象是否相等。

// TODO 准确定义两个data_type相等意味着什么。例如,具有不同分辨率的时间戳是否相等?具有不同比例/精度的十进制数又如何?

Parameters:
Returns:

true lhs 等于 rhs

Returns:

false lhs 不等于 rhs

inline bool operator!=(data_type const &lhs, data_type const &rhs)#

比较两个data_type对象是否不相等。

// TODO 准确定义两个data_type相等意味着什么。例如,具有不同分辨率的时间戳是否相等?具有不同比例/精度的十进制数又如何?

Parameters:
Returns:

true lhs 不等于 rhs

Returns:

false lhs 等于 rhs

std::size_t size_of(data_type t)#

返回指定data_type元素的大小(以字节为单位)

注意

仅支持固定宽度类型

Throws:

cudf::logic_error – 如果 is_fixed_width(element_type) == false

Parameters:

t – 要获取大小的 data_type

Returns:

指定data_type元素的大小(以字节为单位)

template<typename T>
inline constexpr bool has_atomic_support()#

指示类型 T 是否支持原子操作。

Template Parameters:

T – 要验证的类型

Returns:

true T 支持原子操作

Returns:

false T 不支持原子操作

inline constexpr bool has_atomic_support(data_type type)#

指示type是否支持原子操作。

Parameters:

type – 要验证的 data_type

Returns:

true type 支持原子操作

Returns:

false type 不支持原子操作

template<typename L, typename R>
inline constexpr bool is_relationally_comparable()#

指示类型为 LR 的对象是否可以进行关系比较。

给定两个对象 L lR r,如果 l < rl > r 是合法的表达式,则返回 true。

Template Parameters:
  • L – 第一个对象的类型

  • R – 第二个对象的类型

Returns:

true 类型为 LR 的对象可以进行关系比较

Returns:

false 类型为 LR 的对象无法进行比较

bool is_relationally_comparable(data_type type)#

检查data_type type是否支持关系比较。

Parameters:

type – 用于比较的数据类型。

Returns:

如果 type 支持关系比较,则为 true。

Returns:

如果 type 不支持关系比较,则为 false。

template<typename L, typename R>
inline constexpr bool is_equality_comparable()#

指示类型为 LR 的对象是否可以进行比较以判断是否相等。

给定两个对象 L lR r,如果 l == r 是一个格式良好的表达式,则返回 true。

Template Parameters:
  • L – 第一个对象的类型

  • R – 第二个对象的类型

Returns:

true 类型为 LR 的对象可以进行比较以判断是否相等

Returns:

false 类型为 LR 的对象无法进行比较

bool is_equality_comparable(data_type type)#

检查data_type type是否支持相等比较。

Parameters:

type – 用于比较的数据类型。

Returns:

如果 type 支持相等比较,则为 true。

Returns:

false 如果 type 不支持相等比较。

template<typename T>
inline constexpr bool is_numeric()#

表示类型 T 是否为数值类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是数值类型

Returns:

false T 不是数字

bool is_numeric(data_type type)#

指示type是否为数值型data_type

“数值”类型是基本的整数/浮点类型,例如 INT*FLOAT*。包装数值类型的类型不被视为数值类型,例如 TIMESTAMP

Parameters:

type – 要验证的 data_type

Returns:

true type 是数值型

Returns:

false type 不是数字类型

template<typename T>
inline constexpr bool is_index_type()#

指示类型 T 是否为索引类型。

如果可以使用类型 T 的元素来索引列,则类型 T 被视为索引类型。即,索引类型是除 'bool' 之外的整型类型,如 'INT*'。

Template Parameters:

T – 要验证的类型

Returns:

true T 是索引类型

Returns:

false T 不是索引类型

bool is_index_type(data_type type)#

指示类型 type 是否为索引类型。

如果可以使用类型 T 的元素来索引列,则类型 T 被视为索引类型。即,索引类型是除了 'bool' 之外的整型类型,例如 'INT*'。

Parameters:

type – 要验证的 data_type

Returns:

true type 是索引类型

Returns:

false type 不是索引类型

template<typename T>
inline constexpr bool is_unsigned()#

指示类型 T 是否为无符号数字类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是无符号数字

Returns:

false T 是有符号数字

bool is_unsigned(data_type type)#

指示type是否为无符号数字data_type

“无符号数字”类型是基本的整数类型,例如 UINT*

Parameters:

type – 要验证的 data_type

Returns:

true type 是无符号数字类型

Returns:

false type 是有符号数字类型

template<typename Iterator>
inline constexpr bool is_signed_iterator()#

指示Iterator值类型是否为无符号。

Template Parameters:

Iterator – 要验证的类型

Returns:

如果迭代器的值类型是无符号的,则为true

template<typename T>
inline constexpr bool is_integral()#

指示类型 T 是否为整数类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是整数

Returns:

false T 不是整数

bool is_integral(data_type type)#

指示type是否为整数data_type

“整数”类型是基本的整数类型,例如 INT*UINT*

Parameters:

type – 要验证的 data_type

Returns:

true type 是整数类型

Returns:

false type 是整数类型

template<typename T>
inline constexpr bool is_integral_not_bool()#

指示类型 T 是否为整数类型但不是布尔类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是整数类型但不是布尔类型

Returns:

false T 不是整数类型或是布尔类型

bool is_integral_not_bool(data_type type)#

指示type是否为整数data_type且不是BOOL8。

“整数”类型是基本的整数类型,例如 INT*UINT*

Parameters:

type – 要验证的 data_type

Returns:

true type 是整数类型但不是布尔类型

Returns:

false type 是整数类型或是布尔类型

template<typename T>
inline constexpr bool is_numeric_not_bool()#

指示类型 T 是否为数值类型但不是布尔类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是数字类型但不是布尔类型

Returns:

false T 不是数字或为布尔值

bool is_numeric_not_bool(data_type type)#

指示type是否为数值型data_type,但不包括BOOL8。

“数值”类型是整数/浮点类型,例如 INT*FLOAT*

Parameters:

type – 要验证的 data_type

Returns:

true type 是数字类型但不是布尔类型

Returns:

false type 不是数字类型或是布尔类型

template<typename T>
inline constexpr bool is_floating_point()#

表示类型 T 是否为浮点类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是浮点数

Returns:

false T 不是浮点数

bool is_floating_point(data_type type)#

指示type是否为浮点data_type

“浮点”类型是基本的浮点类型,例如 FLOAT*

Parameters:

type – 要验证的 data_type

Returns:

true type 是浮点类型

Returns:

false type 不是浮点类型

template<typename T>
inline constexpr bool is_byte()#

指示T是否为std::byte类型。

Template Parameters:

T – 要验证的类型

Returns:

true type 是 std::byte

Returns:

false type 不是 std::byte

template<typename T>
inline constexpr bool is_boolean()#

指示T是否为布尔类型。

Parameters:

type – 要验证的 data_type

Returns:

true type 是布尔类型

Returns:

false type 不是布尔类型

bool is_boolean(data_type type)#

指示type是否为布尔data_type

Parameters:

type – 要验证的 data_type

Returns:

true type 是一个布尔值

Returns:

false type 不是一个布尔值

template<typename T>
inline constexpr bool is_timestamp()#

表示类型 T 是否为时间戳类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是一个时间戳

Returns:

false T 不是一个时间戳

bool is_timestamp(data_type type)#

指示type是否为时间戳data_type

“Timestamp” 类型是自 Unix 纪元以来的 int32_t 或 int64_t 持续时间。

Parameters:

type – 要验证的 data_type

Returns:

true type 是一个时间戳

Returns:

false type 不是一个时间戳

template<typename T>
inline constexpr bool is_fixed_point()#

指示类型 T 是否为定点类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是一个定点类型

Returns:

false T 不是一个定点类型

bool is_fixed_point(data_type type)#

指示type是否为固定点data_type

Parameters:

type – 要验证的 data_type

Returns:

true type 是一个定点类型

Returns:

false type 不是定点类型

template<typename T>
inline constexpr bool is_duration()#

指示类型 T 是否为持续时间类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是一个持续时间

Returns:

false T 不是一个持续时间

bool is_duration(data_type type)#

指示type是否为持续时间data_type

“Duration” 类型是 int32_t 或 int64_t 的 tick 计数,表示一个时间间隔。

Parameters:

type – 要验证的 data_type

Returns:

true type 是一个持续时间

Returns:

false type 不是一个持续时间

template<typename T>
inline constexpr bool is_chrono()#

指示类型 T 是否为时间类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是一个持续时间或时间戳类型

Returns:

false T 既不是持续时间类型也不是时间戳类型

bool is_chrono(data_type type)#

指示type是否为时间序列data_type

Chrono类型包括cudf时间戳类型,它表示一个时间点,以及cudf持续时间类型,它表示一个时间间隔。

Parameters:

type – 要验证的 data_type

Returns:

true type 是一个时间类型

Returns:

false type 不是时间类型

template<typename T>
constexpr bool is_rep_layout_compatible()#

指示T是否与其“表示”类型布局兼容。

例如,在一列中,decimal32 具体由一个 int32_t 表示,但 decimal32 类型本身包含整数表示和比例。因此,decimal32 int32_t 布局兼容。

作为进一步的例子,duration_ns 与其具体的 int64_t 表示类型不同,但它们在布局上是兼容的。

Returns:

如果 T 与其“表示”类型布局兼容,则为 true

template<typename T>
inline constexpr bool is_dictionary()#

指示类型 T 是否为字典类型。

Template Parameters:

T – 要验证的类型

Returns:

true T 是一个字典类型

Returns:

false T 不是字典类型

bool is_dictionary(data_type type)#

指示type是否为字典data_type

Parameters:

type – 要验证的 data_type

Returns:

true type 是一个字典类型

Returns:

false type 不是字典类型

template<typename T>
inline constexpr bool is_fixed_width()#

指示类型为 T 的元素是否为固定宽度。

固定宽度类型的元素在字节大小上都是相同的。

Template Parameters:

T – 要验证的C++类型

Returns:

true T 对应于一个固定宽度的元素类型

Returns:

false T 对应一个可变宽度的元素类型

bool is_fixed_width(data_type type)#

指示type的元素是否为固定宽度。

固定宽度类型的元素在字节大小上都是相同的。

Parameters:

type – 要验证的 data_type

Returns:

true type 是固定宽度的

Returns:

false type 是可变宽度的

template<typename T>
inline constexpr bool is_compound()#

指示类型 T 是否为复合类型。

columns 带有“复合”元素的列在逻辑上是单个元素列,但可能具体实现为两个或更多 columns。例如,一个 STRING 列可能包含一个偏移量的 column 和一个字符的子 column

Template Parameters:

T – 要验证的类型

Returns:

true T 对应一个“复合”类型

Returns:

false T 对应一个“简单”类型

bool is_compound(data_type type)#

指示type的元素是否为复合类型。

columns 带有“复合”元素的列在逻辑上是单个元素列,但可能具体实现为两个或更多 columns。例如,一个 STRING 列可能包含一个偏移量的 column 和一个字符的子 column

Parameters:

type – 要验证的 data_type

Returns:

true type 是一个复合类型

Returns:

false type 是一个简单的类型

template<typename T>
inline constexpr bool is_nested()#

指示T是否为嵌套类型。

“嵌套”类型与复合类型不同,因为它们可以具有相同类型的任意深度的后代列表。字符串不是嵌套类型,但列表是。

Parameters:

T – 要验证的类型

Returns:

true T 是一个嵌套类型

Returns:

false T 不是一个嵌套类型

bool is_nested(data_type type)#

指示type是否为嵌套类型。

“嵌套”类型与复合类型不同,因为它们可以具有相同类型的任意深度的后代列表。字符串不是嵌套类型,但列表是。

Parameters:

type – 要验证的 data_type

Returns:

true type 是一个嵌套类型

Returns:

false type 不是一个嵌套类型

bool is_bit_castable(data_type from, data_type to)#

指示from是否可以位转换为to

这种类型转换基于 std::bit_cast。具有相同大小且可简单复制的数据类型适用于此类型转换。

请参阅 cudf::bit_cast(),它在可位转换类型之间进行转换时返回一个零拷贝的 column_view

Parameters:
Returns:

true 如果类型可以转换

变量

template<typename ...Ts>
constexpr bool has_common_type_v = detail::has_common_type_impl<void, Ts...>::value#

用于 has_common_type<>::value 的辅助变量模板。

struct order_info#
#include <types.hpp>

指示一组值的排序方式。

公共成员

sorted is_sorted#

指示集合是否已排序。

order ordering#

指示值的排序顺序。

null_order null_ordering#

指示空值如何与所有其他值进行比较。

class data_type#
#include <types.hpp>

指示列中元素的逻辑数据类型。

简单类型可以完全通过它们的id()来描述,但某些类型需要额外的元数据来完全描述该类型的元素。

公共函数

data_type(data_type const&) = default#

复制构造函数。

data_type(data_type&&) = default#

移动构造函数。

data_type &operator=(data_type const&) = default#

data_type 的复制赋值运算符。

Returns:

引用此对象

data_type &operator=(data_type&&) = default#

data_type 的移动赋值运算符。

Returns:

引用此对象

inline explicit constexpr data_type(type_id id)#

构造一个新的 data_type 对象。

Parameters:

id – 类型的标识符

inline explicit data_type(type_id id, int32_t scale)#

numeric::fixed_point 构造一个新的 data_type 对象

Parameters:
  • idfixed_point 的标识符

  • scalefixed_point 的比例(参见 fixed_point::_scale

inline constexpr type_id id() const noexcept#

返回类型标识符。

Returns:

类型标识符

inline constexpr int32_t scale() const noexcept#

返回比例(用于fixed_point类型)

Returns:

比例尺

template<typename From, typename To>
struct is_convertible : public std::is_convertible<From, To>#
template<typename Duration1, typename Duration2>
struct is_convertible<cudf::detail::timestamp<Duration1>, cudf::detail::timestamp<Duration2>> : public std::is_convertible<cudf::detail::time_point<Duration1>::duration, cudf::detail::time_point<Duration2>::duration>#