复制切片#

group 切片

函数

std::vector<column_view> slice(column_view const &input, host_span<size_type const> indices, rmm::cuda_stream_view stream = cudf::get_default_stream())#

根据一组索引将一个 column_view 切分成多个 column_view

返回的 input 视图由偶数个索引构成,其中第 i 个返回的 column_view 视图指示的是 input 中由范围 [indices[2*i], indices[(2*i)+1]) 指定的元素。

对于所有的 i,期望 indices[i] <= input.size()。对于所有 i%2==0 的情况,期望 indices[i] <= indices[i+1]

input:   {10, 12, 14, 16, 18, 20, 22, 24, 26, 28}
indices: {1, 3, 5, 9, 2, 4, 8, 8}
output:  {{12, 14}, {20, 22, 24, 26}, {14, 16}, {}}

注意

调用者有责任确保返回的视图不会超出所视图设备内存的生命周期。

抛出:
  • std::invalid_argument – 如果 indices 的大小不是偶数。

  • std::invalid_argument – 当对中的值严格递减时。

  • std::out_of_range – 当对中的任何值不属于范围 [0, input.size()) 时。

参数:
  • input – 要切分的列的视图

  • indices – 用于对 input 进行切片的索引

  • stream – 用于设备内存操作和内核启动的 CUDA 流

返回:

indices 中范围指示的 input 视图向量

std::vector<column_view> slice(column_view const &input, std::initializer_list<size_type> indices, rmm::cuda_stream_view stream = cudf::get_default_stream())#

根据一组索引将一个 column_view 切分成多个 column_view

返回的 input 视图由偶数个索引构成,其中第 i 个返回的 column_view 视图指示的是 input 中由范围 [indices[2*i], indices[(2*i)+1]) 指定的元素。

对于所有的 i,期望 indices[i] <= input.size()。对于所有 i%2==0 的情况,期望 indices[i] <= indices[i+1]

input:   {10, 12, 14, 16, 18, 20, 22, 24, 26, 28}
indices: {1, 3, 5, 9, 2, 4, 8, 8}
output:  {{12, 14}, {20, 22, 24, 26}, {14, 16}, {}}

注意

调用者有责任确保返回的视图不会超出所视图设备内存的生命周期。

抛出:
  • std::invalid_argument – 如果 indices 的大小不是偶数。

  • std::invalid_argument – 当对中的值严格递减时。

  • std::out_of_range – 当对中的任何值不属于范围 [0, input.size()) 时。

参数:
  • input – 要切分的列的视图

  • indices – 用于对 input 进行切片的索引

  • stream – 用于设备内存操作和内核启动的 CUDA 流

返回:

indices 中范围指示的 input 视图向量

std::vector<table_view> slice(table_view const &input, host_span<size_type const> indices, rmm::cuda_stream_view stream = cudf::get_default_stream())#

根据一组索引将一个 table_view 切分成多个 table_view

返回的 input 视图由偶数个索引构成,其中第 i 个返回的 table_view 视图指示的是 input 中由范围 [indices[2*i], indices[(2*i)+1]) 指定的元素。

对于所有的 i,期望 indices[i] <= input.size()。对于所有 i%2==0 的情况,期望 indices[i] <= indices[i+1]

input:   [{10, 12, 14, 16, 18, 20, 22, 24, 26, 28},
          {50, 52, 54, 56, 58, 60, 62, 64, 66, 68}]
indices: {1, 3, 5, 9, 2, 4, 8, 8}
output:  [{{12, 14}, {20, 22, 24, 26}, {14, 16}, {}},
          {{52, 54}, {60, 22, 24, 26}, {14, 16}, {}}]

注意

调用者有责任确保返回的视图不会超出所视图设备内存的生命周期。

抛出:
  • std::invalid_argument – 如果 indices 的大小不是偶数。

  • std::invalid_argument – 当对中的值严格递减时。

  • std::out_of_range – 当对中的任何值不属于范围 [0, input.size()) 时。

参数:
  • input – 要切分的表的视图

  • indices – 用于对 input 进行切片的索引

  • stream – 用于设备内存操作和内核启动的 CUDA 流

返回:

indices 中范围指示的 input 视图向量

std::vector<table_view> slice(table_view const &input, std::initializer_list<size_type> indices, rmm::cuda_stream_view stream = cudf::get_default_stream())#

根据一组索引将一个 table_view 切分成多个 table_view

返回的 input 视图由偶数个索引构成,其中第 i 个返回的 table_view 视图指示的是 input 中由范围 [indices[2*i], indices[(2*i)+1]) 指定的元素。

对于所有的 i,期望 indices[i] <= input.size()。对于所有 i%2==0 的情况,期望 indices[i] <= indices[i+1]

input:   [{10, 12, 14, 16, 18, 20, 22, 24, 26, 28},
          {50, 52, 54, 56, 58, 60, 62, 64, 66, 68}]
indices: {1, 3, 5, 9, 2, 4, 8, 8}
output:  [{{12, 14}, {20, 22, 24, 26}, {14, 16}, {}},
          {{52, 54}, {60, 22, 24, 26}, {14, 16}, {}}]

注意

调用者有责任确保返回的视图不会超出所视图设备内存的生命周期。

抛出:
  • std::invalid_argument – 如果 indices 的大小不是偶数。

  • std::invalid_argument – 当对中的值严格递减时。

  • std::out_of_range – 当对中的任何值不属于范围 [0, input.size()) 时。

参数:
  • input – 要切分的表的视图

  • indices – 用于对 input 进行切片的索引

  • stream – 用于设备内存操作和内核启动的 CUDA 流

返回:

indices 中范围指示的 input 视图向量