Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate group labels from offsets #10945

Merged
merged 43 commits into from
Jun 1, 2022
Merged

Conversation

ttnghia
Copy link
Contributor

@ttnghia ttnghia commented May 24, 2022

This PR adds a small (detail) API that generates group labels from a given offset array offsets. The output will be an array containing consecutive groups of identical labels, the number of elements in each group i is defined by offsets[i+1] - offsets[i].

Examples:

offsets = [ 0, 4, 6, 10 ]
output  = [ 0, 0, 0, 0, 1, 1, 2, 2, 2, 2 ]

offsets = [ 5, 10, 12 ]
output  = [ 0, 0, 0, 0, 0, 1, 1 ]

Note that the label values always start from 0. We can in fact add a parameter to allow specifying any starting value but we don't need it in now.

Several places in cudf have been updated to adopt the new API immediately. These places have been tested extensively thus no unit tests for the new API is needed. In addition, I ran a benchmark for groupby aggregations and found no performance difference after adopting this.

Closes #10905 and unblocks #10409.

@ttnghia ttnghia added feature request New feature or request 3 - Ready for Review Ready for review by team libcudf blocker libcudf Affects libcudf (C++/CUDA) code. Spark Functionality that helps Spark RAPIDS non-breaking Non-breaking change labels May 24, 2022
@ttnghia ttnghia requested a review from a team as a code owner May 24, 2022 05:01
@ttnghia ttnghia self-assigned this May 24, 2022
@ttnghia ttnghia requested review from devavret and davidwendt May 24, 2022 05:01
@codecov

This comment was marked as off-topic.

cpp/src/groupby/sort/sort_helper.cu Outdated Show resolved Hide resolved
cpp/src/lists/drop_list_duplicates.cu Outdated Show resolved Hide resolved
cpp/src/lists/drop_list_duplicates.cu Outdated Show resolved Hide resolved
Signed-off-by: Nghia Truong <[email protected]>
@ttnghia ttnghia marked this pull request as draft May 29, 2022 13:20
@ttnghia
Copy link
Contributor Author

ttnghia commented May 29, 2022

Rerun tests.

@ttnghia ttnghia marked this pull request as ready for review May 30, 2022 14:13
ttnghia added 2 commits May 30, 2022 08:02
Signed-off-by: Nghia Truong <[email protected]>
Signed-off-by: Nghia Truong <[email protected]>
ttnghia added 2 commits May 31, 2022 14:22
Signed-off-by: Nghia Truong <[email protected]>
Signed-off-by: Nghia Truong <[email protected]>
@ttnghia
Copy link
Contributor Author

ttnghia commented Jun 1, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 7f359e0 into rapidsai:branch-22.08 Jun 1, 2022
@ttnghia ttnghia deleted the list_label branch June 1, 2022 17:57
rapids-bot bot pushed a commit that referenced this pull request Jun 3, 2022
Given an array of integer values which may be the labels of some list elements, we want to generate an array of offsets so we can create a lists column from these offsets.

For example:
```
input_labels = [ 0, 0, 0, 0, 1, 1, 4, 4, 4, 4 ]
output = [ 0, 4, 6, 6, 6, 10 ]
```

This is basically the reverse operation of #10945.

Closes #10955.

Authors:
  - Nghia Truong (https://github.com/ttnghia)

Approvers:
  - Devavret Makkar (https://github.com/devavret)
  - Jake Hemstad (https://github.com/jrhemstad)

URL: #11017
rapids-bot bot pushed a commit that referenced this pull request Jul 26, 2022
This PR adds the following APIs for set operations:
 * `lists::have_overlap`
 * `lists::intersect_distinct`
 * `lists::union_distinct`
 * `lists::difference_distinct`

### Name Convention
Except for the first API (`lists::have_overlap`) that returns a boolean column, the suffix `_distinct` of the rest APIs denotes that their results will be lists columns in which all list rows have been post-processed to remove duplicates. As such, their results are actually "set" columns in which each row is a "set" of distinct elements.

---

Depends on:
 * #10945
 * #11017
 * NVIDIA/cuCollections#175
 * #11052
 * #11118
 * #11100
 * #11149

Closes #10409.

Authors:
  - Nghia Truong (https://github.com/ttnghia)
  - Yunsong Wang (https://github.com/PointKernel)

Approvers:
  - Michael Wang (https://github.com/isVoid)
  - AJ Schmidt (https://github.com/ajschmidt8)
  - Bradley Dice (https://github.com/bdice)
  - Yunsong Wang (https://github.com/PointKernel)

URL: #11043
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change Spark Functionality that helps Spark RAPIDS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA] Generate element labels from offsets
3 participants