文件 | 函数
聚集

文件

文件  gather.hpp
 

函数

std::unique_ptr< columncudf::lists::segmented_gather (lists_column_view const &source_column, lists_column_view const &gather_map_list, out_of_bounds_policy bounds_policy=out_of_bounds_policy::DONT_CHECK, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
 对列表列中每行的列表元素内的元素进行分段聚集。 更多...
 

详细描述

函数文档

◆ segmented_gather()

std::unique_ptr<column> cudf::lists::segmented_gather ( lists_column_view const &  source_column,
lists_column_view const &  gather_map_list,
out_of_bounds_policy  bounds_policy = out_of_bounds_policy::DONT_CHECK,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::device_async_resource_ref  mr = cudf::get_current_device_resource_ref() 
)

对列表列中每行的列表元素内的元素进行分段聚集。

仅支持任意深度的 source_column 和深度为 1 的 gather_map_list

source_column : [{"a", "b", "c", "d"}, {"1", "2", "3", "4"}, {"x", "y", "z"}]
gather_map_list : [{0, 1, 3, 2}, {1, 3, 2}, {}]
结果 : [{"a", "b", "d", "c"}, {"2", "4", "3"}, {}]
异常
cudf::logic_error如果 gather_map_list 的大小与 source_column 的大小不同。
std::invalid_argument如果 gather_map 包含 null 值。
cudf::logic_error如果 gather_map 不是索引类型的列表列。

如果 gather_map_list 中的索引超出了范围 [-n, n)(其中 n 是 source 列对应行中的元素数量),则行为如下:

  1. 如果 bounds_policy 设置为 DONT_CHECK,则行为是未定义的。
  2. 如果 bounds_policy 设置为 NULLIFY,则输出列中列表行中的相应元素将设置为 null。
source_column : [{"a", "b", "c", "d"}, {"1", "2", "3", "4"}, {"x", "y", "z"}]
gather_map_list : [{0, -1, 4, -5}, {1, 3, 5}, {}]
result_with_nullify : [{"a", "d", null, null}, {"2", "4", null}, {}]
参数
source_column要从中聚集的列表列的视图。
gather_map_list一个非 null 的整数索引列表列的视图,用于将 source 列中每行的列表元素映射到目标列中的列表行。
bounds_policy可以是 DONT_CHECKNULLIFY。当聚集索引超出范围 [-n, n) 时,选择是否将输出列表行的元素设置为 null,其中 n 是 gather-map 行对应的列表行中的元素数量。
stream用于设备内存操作和内核启动的 CUDA stream。
mr用于分配任何返回对象的设备内存资源。
返回值
一个列,其行列表中的元素根据 gather_map_list 进行聚集。