列表收集#
- group lists_gather
函数
-
std::unique_ptr<column> 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}, {}] result : [{"a", "b", "d", "c"}, {"2", "4", "3"}, {}]如果
gather_map_list中的索引超出了范围[-n, n),其中n是源列对应行中的元素数量,行为如下:如果
bounds_policy设置为DONT_CHECK,则行为未定义。如果
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}, {}]- Throws:
cudf::logic_error – 如果
gather_map_list的大小与source_column的大小不相同。std::invalid_argument – 如果 gather_map 包含空值。
cudf::logic_error – 如果gather_map不是索引类型的列表列。
- Parameters:
source_column – 查看列表列以从中收集数据
gather_map_list – 查看一个非空列表列,该列包含整型索引,用于将源列中每行的列表元素映射到目标列的列表行。
bounds_policy – 可以是
DONT_CHECK或NULLIFY。选择当收集索引超出范围[-n, n)时,是否将输出列表行的元素置为空,其中n是与收集映射行对应的列表行中的元素数量。stream – 用于设备内存操作和内核启动的CUDA流。
mr – 用于分配任何返回对象的设备内存资源
- Returns:
基于
gather_map_list收集的行列表中的元素列
-
std::unique_ptr<column> 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())#