NVIDIA / NVIDIA/cudf

[FEA] Add `cudf::gather_every` for selecting every nth row

Open
#23,161 2 comments 0 reactions 0 assignees View on GitHub
feature request libcudf
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Is your feature request related to a problem? Please describe.**
xref https://github.com/rapidsai/cudf/pull/23015#discussion_r3538492967

Polars has a [gather_every](https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.gather_every.html) operation that allows selecting every nth row from a Column.

**Describe the solution you'd like**
An API probably like

```cpp
std::unique_ptr gather_every(
table_view const& source_table,
size_t n,
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());
```

which from https://github.com/rapidsai/cudf/pull/23015#discussion_r3538492967

> I'm thinking the API can use a counting transform iterator to generate the indices on the fly.

**Describe alternatives you've considered**
Use `cudf::gather` with a gather map produced from `cudf::sequence`

Contributor guide

Open the contributing guide

Research direction

Start by reading the proposed gather_every API and the linked discussion in cudf#23015, then compare the existing cudf::gather and cudf::sequence operations. Done means selecting every nth row from a table with the specified bounds policy, stream, and memory-resource parameters, with tests covering the resulting rows and relevant edge cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.