[FEA] Support reverse `cudf::scan`
- 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/23164#discussion_r3552925843
Polars cumulative operations support a `reverse` argument to perform a scan in the reverse direction e.g. https://docs.pola.rs/api/python/dev/reference/expressions/api/polars.Expr.cum_max.html
**Describe the solution you'd like**
Possibly a new `order direction` keyword in `cudf::scan` for a caller to indicate whether the scan should be performed in ascending or descending row count order. From https://github.com/rapidsai/cudf/pull/23164#discussion_r3552925843
> CUB and thrust definitely support scans over iterators, so I think we should try and instead offer an option to use a reverse iterator in libcudf scans.
> Rather than having to copy everything twice.
**Describe alternatives you've considered**
Use `cudf::reverse` to flip the data order, perform the `cudf::scan`, and use `cudf::reverse` to align to the original order
**Additional context**
Add any other context, code examples, or references to existing implementations about the feature request here.
Contributor guide
Research direction
Start with the libcudf `cudf::scan` entry points and read the discussion in PR #23164, especially the notes about CUB, Thrust, and reverse iterators. Trace how scan order is currently selected and identify the relevant tests. Done means callers can request reverse scan order while results remain aligned with the original row order, without the documented reverse-copy workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100