列类#

group
class column#
#include <column.hpp>

一个包含可空设备数据作为元素列的容器。

公共函数

column(column const &other, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

通过深度复制 other 的内容来构造一个新的列对象。

对所有分配和复制使用指定的 stream 和 device_memory_resource。

参数:
  • other – 要复制的 column

  • stream – 用于设备内存操作的 CUDA 流。

  • mr – 用于所有设备内存分配的设备内存资源

column(column &&other) noexcept#

移动 other 的内容来创建一个新的列。

移动后,other.size() == 0other.type() = {EMPTY}

参数:

other – 其内容将被移动到新列中的列

template<typename T>
inline column(rmm::device_uvector<T> &&other, rmm::device_buffer &&null_mask, size_type null_count)#

通过取得 device_uvector 内容的所有权来构造一个新的列。

参数:
  • other – 其内容将被移动到新列中的 device_uvector。

  • null_mask – 列的空值指示符位掩码。如果 null_count 为 0,则可能为空。

  • null_count – 空元素的计数。

template<typename B1, typename B2 = rmm::device_buffer>
inline column(data_type dtype, size_type size, B1 &&data, B2 &&null_mask, size_type null_count, std::vector<std::unique_ptr<column>> &&children = {})#

从现有设备内存构造一个新的列。

注意

此构造函数主要用于列工厂函数。

抛出:

cudf::logic_error – 如果 size < 0

参数:
  • dtype – 元素类型

  • size – 列中的元素数量

  • data – 列的数据

  • null_mask – 列的空值指示符位掩码。如果 null_count 为 0,则可能为空。

  • null_count – 可选,空元素的计数。

  • children – 可选,子列向量

explicit column(column_view view, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

通过深度复制 column_view 的内容来构造一个新的列。

这会考虑 column_view 的偏移量。

参数:
  • view – 要复制的视图

  • stream – 用于设备内存操作的 CUDA 流。

  • mr – 用于所有设备内存分配的设备内存资源

inline data_type type() const noexcept#

返回列的逻辑元素类型。

返回:

列的逻辑元素类型

inline size_type size() const noexcept#

返回元素数量。

返回:

元素数量

inline size_type null_count() const#

返回空元素的计数。

返回:

空元素的数量

void set_null_mask(rmm::device_buffer &&new_null_mask, size_type new_null_count)#

将列的空值指示符位掩码设置为 new_null_mask

抛出:

cudf::logic_error – 如果 new_null_count 大于 0 且 new_null_mask 的大小与此列的大小不匹配。

参数:
  • new_null_mask – 新的空值指示符位掩码(右值重载 & 移动)用于设置列的空值指示符掩码。如果 new_null_count 为 0,则可能为空。

  • new_null_count – 空元素的计数。

void set_null_mask(rmm::device_buffer const &new_null_mask, size_type new_null_count, rmm::cuda_stream_view stream = cudf::get_default_stream())#

将列的空值指示符位掩码设置为 new_null_mask

抛出:

cudf::logic_error – 如果 new_null_count 大于 0 且 new_null_mask 的大小与此列的大小不匹配。

参数:
  • new_null_mask – 新的空值指示符位掩码(左值重载 & 复制)用于设置列的空值指示符掩码。如果 new_null_count 为 0,则可能为空。

  • new_null_count – 空元素的计数

  • stream – 用于执行分配和复制的流。如果未指定,则使用默认的 CUDF 流。

void set_null_count(size_type new_null_count)#

更新空元素的计数。

抛出:

cudf::logic_error – 如果 new_null_count > 0 and nullable() == false

参数:

new_null_count – 新的空计数。

inline bool nullable() const noexcept#

指示列是否可能包含空值,即是否分配了空值掩码。

当且仅当 null_count() == 0 时,这可能返回 false

即使 null_count() == 0,也可能返回 true。此函数仅指示列是否分配了空值掩码。

返回:

true 列可以包含空值

返回:

false 列不能包含空值

inline bool has_nulls() const noexcept#

指示列是否包含空元素。

返回:

true 一个或多个元素为空

返回:

false 零个元素为空

inline size_type num_children() const noexcept#

返回子列的数量。

返回:

子列的数量

inline column &child(size_type child_index) noexcept#

返回对指定子项的引用。

参数:

child_index – 所需子项的索引

返回:

对所需子项的引用

inline column const &child(size_type child_index) const noexcept#

返回对指定子项的 const 引用。

参数:

child_index – 所需子项的索引

返回:

对所需子项的 const 引用

contents release() noexcept#

释放列内容的所有权。

调用 release() 之前,调用者有责任查询 size(), null_count(), type()

调用列的 release() 后,它将为空,即:

返回:

一个 contents 结构体,包含列的数据、空值掩码和子项。

column_view view() const#

创建一个列数据和子项的不可变、非拥有视图。

返回:

不可变、非拥有视图

inline operator column_view() const#

隐式转换为 column_view 的运算符。

这允许将 column 对象直接传递给需要 column_view 的函数。转换是自动的。

返回:

不可变、非拥有 column_view

mutable_column_view mutable_view()#

创建一个列数据、空值掩码和子项的可变、非拥有视图。

返回:

可变、非拥有视图

inline operator mutable_column_view()#

隐式转换为 mutable_column_view 的运算符。

这允许将 column 对象传递给接受 mutable_column_view 的函数。转换是自动的。

如果空值掩码被修改,调用者应相应地更新空计数。

返回:

可变、非拥有 mutable_column_view

struct contents#
#include <column.hpp>

列内容的包装器。

column::release() 返回。

公共成员

std::unique_ptr<rmm::device_buffer> data#

数据设备内存缓冲区

std::unique_ptr<rmm::device_buffer> null_mask#

空值掩码设备内存缓冲区

std::vector<std::unique_ptr<column>> children#

子列

struct nullate#

在编译时或运行时指示空值的存在。

如果在编译时使用,此指示符可以告诉优化器包含或排除任何空值检查子句。

struct DYNAMIC#

nullate::DYNAMIC 将可空性的确定推迟到运行时而不是编译时。调用代码负责在运行时使用构造函数参数指定是否存在空值。

公共函数

inline explicit constexpr DYNAMIC(bool b) noexcept#

创建一个运行时 nullate 对象。

另请参阅

有关用法示例,请参阅cudf::column_device_view::optional_begin

参数:

b – 如果在此对象应用的运算中预期存在空值,则为 True。

inline constexpr operator bool() const noexcept#

如果在此对象应用的运算中预期存在空值,则返回 true。

返回:

如果在此对象应用的运算中预期存在空值,则为 true,否则为 false

公共成员

bool value#

如果预期存在空值,则为 True。

struct NO : public cuda::std::false_type#
struct YES : public cuda::std::true_type#
class column_device_view : public cudf::detail::column_device_view_base#

一个不可变、非拥有设备数据视图,作为元素列,它是可平凡复制且可在 CUDA 设备代码中使用的。

由 cudf::detail::lists_column_device_view, cudf::detail::structs_column_device_view 子类化

公共类型

using count_it = thrust::counting_iterator<size_type>#

计数迭代器。

template<typename T>
using const_iterator = thrust::transform_iterator<detail::value_accessor<T>, count_it>#

用于导航此列的迭代器。

template<typename T, typename Nullate>
using const_optional_iterator = thrust::transform_iterator<detail::optional_accessor<T, Nullate>, count_it>#

用于导航此列的可选迭代器。

template<typename T, bool has_nulls>
using const_pair_iterator = thrust::transform_iterator<detail::pair_accessor<T, has_nulls>, count_it>#

用于导航此列的 Pair 迭代器。

template<typename T, bool has_nulls>
using const_pair_rep_iterator = thrust::transform_iterator<detail::pair_rep_accessor<T, has_nulls>, count_it>#

用于导航此列的 Pair rep 迭代器。

每个行值都以其代表性形式访问。

公共函数

column_device_view(column_device_view const&) = default#

拷贝构造函数。

column_device_view(column_device_view&&) = default#

移动构造函数。

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

拷贝赋值运算符。

返回:

对此对象的引用

column_device_view &operator=(column_device_view&&) = default#

移动赋值运算符。

返回:

对此对象的引用(转移所有权后)

column_device_view(column_view column, void *h_ptr, void *d_ptr)#

使用指定的主机内存指针 (h_ptr) 存储子对象,并使用设备内存指针 (d_ptr) 作为任何子对象指针的基础来创建此类的实例。

参数:
  • column – 用于创建此实例的列视图。

  • h_ptr – 用于放置任何子数据的主机内存指针。

  • d_ptr – 用于基于任何子指针的设备内存指针。

inline column_device_view slice(size_type offset, size_type size) const noexcept#

获取一个作为此列切片的新 column_device_view

示例

// column = column_device_view([1, 2, 3, 4, 5, 6, 7])
auto c = column.slice(1, 3);
// c = column_device_view([2, 3, 4])
auto c1 = column.slice(2, 3);
// c1 = column_device_view([3, 4, 5])

参数:
  • offset – 切片中第一个元素的索引

  • size – 切片中元素的数量

返回:

此列的一个切片

template<typename T>
inline T element(size_type element_index) const noexcept#

返回对指定索引处元素的引用。

如果指定索引处的元素为 NULL,即 is_null(element_index) == true,则任何使用结果的尝试都将导致未定义行为。

此函数会考虑偏移量。

如果 is_rep_layout_compatible<T> 为 false,则此函数不参与重载解析。对于 is_rep_layout_compatible<T> 为 false 的类型 T,此函数可能存在特化。

模板参数:

T – 元素类型

参数:

element_index – 所需元素的位置

返回:

指定索引处元素的引用

template<typename T>
inline const_iterator<T> begin() const#

返回指向列第一个元素的迭代器。

此迭代器仅支持 has_nulls() == false 的列。在访问空元素时,将此迭代器与 has_nulls() == true 的列一起使用会导致未定义行为。

如果 column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

对于包含空元素的列,请使用 make_null_replacement_iterator

模板参数:

T – 列中元素的类型

返回:

指向列第一个元素的迭代器

template<typename T>
inline const_iterator<T> end() const#

返回指向列最后一个元素之后元素的迭代器。

此迭代器仅支持 has_nulls() == false 的列。在访问空元素时,将此迭代器与 has_nulls() == true 的列一起使用会导致未定义行为。

如果 column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

对于包含空元素的列,请使用 make_null_replacement_iterator

返回:

指向列最后一个元素之后元素的迭代器

template<typename T, typename Nullate>
inline auto optional_begin(Nullate has_nulls) const#

返回指向列第一个元素的 optional 迭代器。

解引用返回的迭代器会返回一个 cuda::std::optional<T>

此迭代器的元素在上下文上转换为 bool 类型。如果对象包含值,则转换返回 true;如果不包含值,则返回 false。

使用 nullate::DYNAMIC 调用此方法会将可空性假设推迟到运行时,由调用者指示列是否包含空值。当算法将对多个迭代器执行,并且在编译时不需要所有迭代器类型组合时,nullate::DYNAMIC 会很有用。

template<typename T>
void some_function(cudf::column_view<T> const& col_view){
   auto d_col = cudf::column_device_view::create(col_view);
   // Create a `DYNAMIC` optional iterator
   auto optional_iterator =
      d_col->optional_begin<T>(cudf::nullate::DYNAMIC{col_view.has_nulls()});
}

使用 nullate::YES 调用此方法意味着列支持空值,并且返回的 optional 可能不包含值。

使用 nullate::NO 调用此方法意味着列没有空值,并且返回的 optional 将始终包含值。

template<typename T, bool has_nulls>
void some_function(cudf::column_view<T> const& col_view){
   auto d_col = cudf::column_device_view::create(col_view);
   if constexpr(has_nulls) {
     auto optional_iterator = d_col->optional_begin<T>(cudf::nullate::YES{});
     //use optional_iterator
   } else {
     auto optional_iterator = d_col->optional_begin<T>(cudf::nullate::NO{});
     //use optional_iterator
   }
}

如果 column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

抛出:
模板参数:
  • T – 列中元素的类型

  • Nullate – 描述如何检查空值的 cudf::nullate 类型

参数:

has_nulls – 描述如何检查空值的 cudf::nullate 类型

返回:

指向列第一个元素的 optional 迭代器

template<typename T, bool has_nulls>
inline const_pair_iterator<T, has_nulls> pair_begin() const#

返回指向列第一个元素的 pair 迭代器。

解引用返回的迭代器会返回一个 thrust::pair<T, bool>

如果位置 i 处的元素有效(或 has_nulls == false),则对于 p = *(iter + i)p.first 包含位置 i 处元素的值,并且 p.second == true

否则,如果位置 i 处的元素为空,则 p.first 的值是未定义的,并且 p.second == false

如果 column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

抛出:
  • cudf::logic_error – 如果 tparam has_nulls == truenullable() == false

  • cudf::logic_error – 如果列数据类型与元素类型不匹配。

返回:

指向列第一个元素的 pair 迭代器

template<typename T, bool has_nulls>
inline const_pair_rep_iterator<T, has_nulls> pair_rep_begin() const#

返回指向列第一个元素的 pair 迭代器。

解引用返回的迭代器会返回一个 thrust::pair<rep_type, bool>,其中 rep_typedevice_storage_type<T>,即用于在设备上存储值的类型。

如果位置 i 处的元素有效(或 has_nulls == false),则对于 p = *(iter + i)p.first 包含位置 i 处元素的值,并且 p.second == true

否则,如果位置 i 处的元素为空,则 p.first 的值是未定义的,并且 p.second == false

如果 column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

抛出:
  • cudf::logic_error – 如果 tparam has_nulls == truenullable() == false

  • cudf::logic_error – 如果列数据类型与元素类型不匹配。

返回:

指向列第一个元素的 pair 迭代器

template<typename T, typename Nullate>
inline auto optional_end(Nullate has_nulls) const#

返回指向列最后一个元素之后元素的 optional 迭代器。

返回的迭代器表示一个 cuda::std::optional<T> 元素。

如果 column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

抛出:
模板参数:
  • T – 列中元素的类型

  • Nullate – 描述如何检查空值的 cudf::nullate 类型

参数:

has_nulls – 描述如何检查空值的 cudf::nullate 类型

返回:

指向列最后一个元素之后元素的 optional 迭代器

template<typename T, bool has_nulls>
inline const_pair_iterator<T, has_nulls> pair_end() const#

返回指向列最后一个元素之后元素的 pair 迭代器。

如果 column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

抛出:
  • cudf::logic_error – 如果 tparam has_nulls == truenullable() == false

  • cudf::logic_error – 如果列数据类型与元素类型不匹配。

返回:

指向列最后一个元素之后元素的 pair 迭代器

template<typename T, bool has_nulls>
inline const_pair_rep_iterator<T, has_nulls> pair_rep_end() const#

返回指向列最后一个元素之后元素的 pair 迭代器。

如果 column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

抛出:
  • cudf::logic_error – 如果 tparam has_nulls == truenullable() == false

  • cudf::logic_error – 如果列数据类型与元素类型不匹配。

返回:

指向列最后一个元素之后元素的 pair 迭代器

void destroy()#

销毁 column_device_view 对象。

注意

不释放列数据,只释放为存储子视图而分配的设备内存。

inline column_device_view child(size_type child_index) const noexcept#

返回指定的子列。

参数:

child_index – 所需子列的索引

返回:

column_view 请求的子 column_view

inline device_span<column_device_view const> children() const noexcept#

返回包含此列所有子列的 span。

返回:

包含此列所有子列的 span

inline size_type num_child_columns() const noexcept#

返回子列的数量。

返回:

子列的数量

公共静态函数

template<typename T>
static inline constexpr bool has_element_accessor()#

对于给定的 T,指示 column_device_view::element<T>() 是否存在有效的重载。

模板参数:

T – 元素类型

返回:

如果 column_device_view::element<T>() 存在有效的重载,则为 true;否则为 false

static std::unique_ptr<column_device_view, std::function<void(column_device_view*)>> create(column_view source_view, rmm::cuda_stream_view stream = cudf::get_default_stream())#

用于构造可在设备内存中使用的列视图的工厂函数。

分配 `source_view` 子视图的设备内存并进行复制,使其可在设备代码中访问。

如果 source_view.num_children() == 0,则不分配设备内存。

返回一个 std::unique_ptr<column_device_view>,带有一个自定义的析构器用于释放为子列分配的设备内存。

column_device_view 应该通过值传递到 GPU 内核中。

参数:
  • source_view – 用于在设备代码中使用的 column_view

  • stream – 用于子列设备内存操作的 CUDA 流。

返回:

指向 column_device_viewunique_ptr,它使得 source_view 中的数据在设备内存中可用。

static std::size_t extent(column_view const &source_view)#

返回保存指定列及其子列设备视图所需的内存大小(字节)。

参数:

source_view – 用于此计算的 column_view

返回:

在 GPU 内存中存储设备视图所需的字节数

class mutable_column_device_view : public cudf::detail::column_device_view_base#

设备数据的可变非拥有视图,表示为元素列,可轻松复制并在 CUDA 设备代码中使用。

公共类型

using count_it = thrust::counting_iterator<size_type>#

计数迭代器。

template<typename T>
using iterator = thrust::transform_iterator<detail::mutable_value_accessor<T>, count_it>#

用于导航此列的迭代器。

公共函数

mutable_column_device_view(mutable_column_device_view const&) = default#

拷贝构造函数。

mutable_column_device_view(mutable_column_device_view&&) = default#

移动构造函数。

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

拷贝赋值运算符。

返回:

对此对象的引用

mutable_column_device_view &operator=(mutable_column_device_view&&) = default#

移动赋值运算符。

返回:

对此对象的引用(转移所有权后)

mutable_column_device_view(mutable_column_view column, void *h_ptr, void *d_ptr)#

使用指定的主机内存指针 (h_ptr) 存储子对象,并使用设备内存指针 (d_ptr) 作为任何子对象指针的基础来创建此类的实例。

参数:
  • column – 用于创建此实例的列视图。

  • h_ptr – 用于放置任何子数据的主机内存指针。

  • d_ptr – 用于基于任何子指针的设备内存指针。

template<typename T = void>
inline T *head() const noexcept#

返回指向基设备内存分配的指针,并转换为指定的类型。

只有当 is_rep_layout_compatible<T>()std::is_same_v<T,void> 为 true 时,此函数才参与重载解析。

注意

如果 offset() == 0,则 head<T>() == data<T>()

注意

通常很少需要访问列的 head<T>() 分配,而是应该通过 data<T>() 访问元素。

模板参数:

The – 要转换的类型

返回:

指向底层数据的类型化指针

template<typename T>
inline T *data() const noexcept#

返回转换为指定类型并加上偏移量的底层数据。

如果 is_rep_layout_compatible<T> 为 false,则此函数不参与重载解析。

注意

如果 offset() == 0,则 head<T>() == data<T>()

模板参数:

T – 要转换的类型

返回:

指向底层数据的类型化指针,包含偏移量

template<typename T>
inline T &element(size_type element_index) const noexcept#

返回对指定索引处元素的引用。

此函数会考虑偏移量。

如果 is_rep_layout_compatible<T> 为 false,则此函数不参与重载解析。对于 is_rep_layout_compatible<T> 为 false 的类型 T,此函数可能存在特化。

模板参数:

T – 元素类型

参数:

element_index – 所需元素的位置

返回:

指定索引处元素的引用

inline bitmask_type *null_mask() const noexcept#

返回指向底层位掩码分配的原始指针。

注意

此函数*不*考虑 offset()

注意

如果 null_count() == 0,这可能返回 nullptr

返回:

指向底层位掩码分配的原始指针

template<typename T>
inline iterator<T> begin()#

返回底层数据转换为指定类型后的第一个元素(考虑偏移量)。

如果 mutable_column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

模板参数:

T – 所需的类型

返回:

转换后的第一个元素的指针

template<typename T>
inline iterator<T> end()#

返回底层数据转换为指定类型后的最后一个元素之后一个位置的指针。

如果 mutable_column_device_view::has_element_accessor<T>() 为 false,则此函数不参与重载解析。

模板参数:

T – 所需的类型

返回:

转换后的最后一个元素之后一个位置的指针

inline mutable_column_device_view child(size_type child_index) const noexcept#

返回指定的子列。

参数:

child_index – 所需子列的索引

返回:

请求的子 column_view

inline void set_mask_word(size_type word_index, bitmask_type new_word) const noexcept#

使用新字更新 null_mask() 中指定的位掩码字。

注意

如果 nullable() == false,调用此函数会导致未定义行为。

参数:
  • word_index – 要更新的字的索引

  • new_word – 新的位掩码字

void destroy()#

销毁 mutable_column_device_view 对象。

注意

不释放列数据,只释放为存储子视图而分配的设备内存。

公共静态函数

static std::unique_ptr<mutable_column_device_view, std::function<void(mutable_column_device_view*)>> create(mutable_column_view source_view, rmm::cuda_stream_view stream = cudf::get_default_stream())#

用于构造可在设备内存中使用的列视图的工厂函数。

分配 `source_view` 子视图的设备内存并进行复制,使其可在设备代码中访问。

如果 source_view.num_children() == 0,则不分配设备内存。

返回一个 std::unique_ptr<mutable_column_device_view>,带有一个自定义的析构器用于释放为子列分配的设备内存。

mutable_column_device_view 应该通过值传递到 GPU 内核中。

参数:
  • source_view – 用于在设备代码中使用的 column_view

  • stream – 用于子列设备内存操作的 CUDA 流。

返回:

指向 mutable_column_device_viewunique_ptr,它使得 source_view 中的数据在设备内存中可用。

template<typename T>
static inline constexpr bool has_element_accessor()#

对于给定的 T,指示 mutable_column_device_view::element<T>() 是否存在有效的重载。

返回:

如果 mutable_column_device_view::element<T>() 存在有效的重载,则为 true;否则为 false

static std::size_t extent(mutable_column_view source_view)#

返回保存指定列及其子列设备视图所需的内存大小(字节)。

参数:

source_view – 用于此计算的 column_view

返回:

保存指定列及其子列设备视图所需的内存大小(字节)

class column_view : public cudf::detail::column_view_base#
#include <column_view.hpp>

设备数据的非拥有、不可变视图,表示为元素列,其中一些元素可能如位掩码所示为空。

column_view 可以从 cudf::column 隐式构造,也可以从指向预先存在的设备内存的指针显式构造。

除非另有说明,否则 column_view 的数据和位掩码的内存布局应遵循 Arrow 物理内存布局规范:https://arrow.apache.ac.cn/docs/memory_layout.html

由于 column_view 是非拥有的,因此在创建或销毁 column_view 对象时,不会分配或释放设备内存。

为了启用零拷贝切片,column_view 有一个 `offset`,表示列中相对于基设备内存分配的第一个元素的索引。默认情况下,`offset()` 为零。

cudf::dictionary_column_view, cudf::lists_column_view, cudf::strings_column_view, cudf::structs_column_view, cudf::tdigest::tdigest_column_view 继承

公共函数

column_view(column_view const&) = default#

拷贝构造函数。

column_view(column_view&&) = default#

移动构造函数。

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

拷贝赋值运算符。

返回:

对此对象的引用

column_view &operator=(column_view&&) = default#

移动赋值运算符。

返回:

对此对象的引用

column_view(data_type type, size_type size, void const *data, bitmask_type const *null_mask, size_type null_count, size_type offset = 0, std::vector<column_view> const &children = {})#

从指向列元素和位掩码设备内存的指针构造 column_view

如果 null_count() 为零,则 null_mask 是可选的。

如果 typeEMPTY,则指定的 null_count 将被忽略,并且 null_count() 将始终返回与 size() 相同的值。

抛出:
参数:
  • type – 元素类型

  • size – 元素数量

  • data – 指向包含列元素的设备内存的指针

  • null_mask – 指向包含空值指示位掩码的设备内存的指针

  • null_count – 空元素的数量。

  • offset – 可选,第一个元素的索引

  • children – 可选,根据元素类型的不同,子列可能包含额外数据

inline column_view child(size_type child_index) const noexcept#

返回指定的子列。

参数:

child_index – 所需子列的索引

返回:

请求的子 column_view

inline size_type num_children() const noexcept#

返回子列的数量。

返回:

子列的数量

inline auto child_begin() const noexcept#

返回指向有序子视图列序列开头的迭代器。

返回:

指向引用第一个子列的 column_view 的迭代器

inline auto child_end() const noexcept#

返回指向有序子视图列序列末尾的迭代器。

返回:

指向位于子列末尾后一个位置的 column_view 的迭代器

template<typename T>
inline column_view(device_span<T const> data)#

从 device_span<T> 构造一个视图列。

仅支持数值和时间序列类型。

模板参数:

T – device span 类型。必须是 const 并与视图列的类型匹配。

参数:

data – 包含视图列数据的类型化 device span。

template<typename T>
inline operator device_span<T const>() const#

将视图列转换为 device span。

仅支持数值和时间序列数据类型。视图列不能为空值。

模板参数:

T – device span 类型。必须是 const 并与视图列的类型匹配。

抛出:
返回:

视图列数据的类型化 device span。

class mutable_column_view : public cudf::detail::column_view_base#
#include <column_view.hpp>

设备数据的非拥有、可变视图,作为元素列,其中一些元素可能为空,由位掩码指示。

mutable_column_view 可以隐式地从 cudf::column 构造,或者可以从指向预先存在的设备内存的指针显式构造。

除非另有说明,否则 mutable_column_view 的数据和位掩码的内存布局应遵循 Arrow 物理内存布局规范:https://arrow.apache.ac.cn/docs/memory_layout.html

由于 mutable_column_view 是非拥有的,因此在创建或销毁 mutable_column_view 对象时,不会分配或释放设备内存。

为了实现零拷贝切片,mutable_column_view 具有一个 offset,指示列中相对于基本设备内存分配的第一个元素的索引。默认情况下,offset() 为零。

公共函数

mutable_column_view(mutable_column_view const&) = default#

拷贝构造函数。

mutable_column_view(mutable_column_view&&) = default#

移动构造函数。

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

拷贝赋值运算符。

返回:

对此对象的引用

mutable_column_view &operator=(mutable_column_view&&) = default#

移动赋值运算符。

返回:

对此对象的引用(转移所有权后)

mutable_column_view(data_type type, size_type size, void *data, bitmask_type *null_mask, size_type null_count, size_type offset = 0, std::vector<mutable_column_view> const &children = {})#

从指向列的元素和位掩码的设备内存指针构造 mutable_column_view

如果 typeEMPTY,则指定的 null_count 将被忽略,并且 null_count() 将始终返回与 size() 相同的值。

抛出:
参数:
  • type – 元素类型

  • size – 元素数量

  • data – 指向包含列元素的设备内存的指针

  • null_mask – 指向包含空值指示位掩码的设备内存的指针

  • null_count – 空元素的数量。

  • offset – 可选,第一个元素的索引

  • children – 可选,根据元素类型的不同,子列可能包含额外数据

template<typename T = void>
inline T *head() const noexcept#

返回指向基设备内存分配的指针,并转换为指定的类型。

只有当 is_rep_layout_compatible<T>()std::is_same_v<T,void> 为 true 时,此函数才参与重载解析。

注意

如果 offset() == 0,则 head<T>() == data<T>()

注意

通常很少需要访问列的 head<T>() 分配,而是应该通过 data<T>() 访问元素。

模板参数:

The – 要转换的类型

返回:

指向底层数据的类型化指针

template<typename T>
inline T *data() const noexcept#

返回转换为指定类型并加上偏移量的底层数据。

如果 is_rep_layout_compatible<T> 为 false,则此函数不参与重载解析。

注意

如果 offset() == 0,则 head<T>() == data<T>()

模板参数:

T – 要转换的类型

返回:

指向底层数据的类型化指针,包含偏移量

template<typename T>
inline T *begin() const noexcept#

返回底层数据转换为指定类型后的第一个元素(考虑偏移量)。

如果 is_rep_layout_compatible<T> 为 false,则此函数不参与重载解析。

模板参数:

T – 所需的类型

返回:

转换后的第一个元素的指针

template<typename T>
inline T *end() const noexcept#

返回底层数据转换为指定类型后的最后一个元素之后一个位置的指针。

如果 is_rep_layout_compatible<T> 为 false,则此函数不参与重载解析。

模板参数:

T – 所需的类型

返回:

转换后的最后一个元素之后一个位置的指针

inline bitmask_type *null_mask() const noexcept#

返回指向底层位掩码分配的原始指针。

注意

此函数*不*考虑 offset()

注意

如果 null_count() == 0,则可能返回 nullptr

返回:

指向底层位掩码分配的原始指针

void set_null_count(size_type new_null_count)#

设置空值计数。

抛出:

cudf::logic_error – 如果 new_null_count > 0nullable() == false

参数:

new_null_count – 新的空值计数

inline mutable_column_view child(size_type child_index) const noexcept#

返回对指定子项的引用。

参数:

child_index – 所需子列的索引

返回:

请求的子 mutable_column_view

inline size_type num_children() const noexcept#

返回子列的数量。

返回:

子列的数量

inline auto child_begin() const noexcept#

返回指向有序子视图列序列开头的迭代器。

返回:

指向引用第一个子列的 mutable_column_view 的迭代器

inline auto child_end() const noexcept#

返回指向有序子视图列序列末尾的迭代器。

返回:

指向子列末尾后一个元素的 mutable_column_view 的迭代器

operator column_view() const#

将可变视图转换为不可变视图。

返回:

可变视图元素的不可变视图