[FEA] Allow control of mask state in return value of `cudf::contains`
- 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.**
`cudf::contains`, specifically the column overload, searches for a bunch of needles in a haystack. If any of the needles are null, the return value has nulls in the same location. The detail API has finer-grained control over whether nulls should compare equal (so that if the haystack contains a null and one of needles is null, the output column has a `true` value in that slot).
It would be nice to be able to control whether the bitmask is copied from the needles to the result or not. In Python cudf, we use `contains` to implement `Series.isin` where the semantics are that nulls are just treated as any other value. So if the needles contain a null, the result is true or false depending on whether the haystack also has a null. Right now, we call contains, and then must perform some post-processing to obtain a result that internally has already been computed.
**Describe the solution you'd like**
A flag specifying whether `contains` masks its output.
**Describe alternatives you've considered**
Above-board, I do this in Python with:
```
if needles.null_count > 0:
result.fillna(haystack.null_count > 0)
```
This is an extra allocation + kernel launch.
The cheap way of doing it is to obtain the result, and then drop the mask on the floor. This happens to work due to the way `cudf::contains` is implemented. However, I would rather not do this because libcudf explicitly does not guarantee that the masked out entries of a column contain valid data, so I am relying on an implementation detail which could change.
Contributor guide
Assessment
This issue has not been assessed yet.