-
Notifications
You must be signed in to change notification settings - Fork 917
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
extract_list_element()
with column_view
indices
#9214
extract_list_element()
with column_view
indices
#9214
Conversation
Fixes rapidsai#9124. Adds an overload of `extract_list_element()` where the indices may be specified as a column_view. This function returns a list element from a potentially different index, for each list row. The semantics of the scalar-index version of the function are retained. i.e.: 0. The index is 0-based. 1. if (list_row == null) return null; 2. if (index > list_row.size()) return null; 3. if (index == null) return null; 4. if (index < 0 || -index <= length) return list_row[length + index];
WIP. The need to do the following:
|
@mythrocks it's more helpful to have lists like that in the PR description as GH actually parses those and shows it in the PR list view. |
if constexpr (PositiveIndex) { return index < length ? index + offset : out_of_bounds; } | ||
return index >= -length ? length + index + offset : out_of_bounds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is far more complicated than it needs to be. This looks like precisely the same logic as what is done in gather
. I don't think there's any need for the PositiveIndex
template argument.
if constexpr (PositiveIndex) { return index < length ? index + offset : out_of_bounds; } | |
return index >= -length ? length + index + offset : out_of_bounds; | |
auto const wrapped = (index < 0) ? index + length + offset : index + offset; | |
return (wrapped >= 0 and wrapped < length) ? wrapped : out_of_bounds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PositiveIndex
, etc. is the original code I'm trying to retain for extract_list_element(list_column_view, size_type, mr)
. I interpreted your advice here to be to retain the algo and fit the column_view
version around it.
It would certainly simplify things to remove PositiveIndex
.
Come to think of it, this is just |
@ttnghia alerted me to this fact on the issue, based on your advice in #9124.
Would you recommend that we redo both versions of |
I think we could add the
Hm, good point. It could either be the caller's responsibility to extract the data child or we have a wrapper function to call |
Closing this PR in favour of #9367, where it's all (re)done via |
Fixes #9172. Adds an overload of `extract_list_element()` where the indices may be specified as a `column_view`. This function returns a list element from a potentially different index, for each list row. The semantics of the scalar-index version of the function are retained. i.e.: 0. The index is 0-based. 1. `if (list_row == null) return null;` 2. `if (index > list_row.size()) return null;` 3. `if (index == null) return null;` 4. `if (index < 0 && -index <= length) return list_row[length + index];` This commit also reworks `extract_list_element(list, size_type, stream)`, to use `segmented_gather()`, as per the advice in #9214. Authors: - MithunR (https://github.com/mythrocks) Approvers: - David Wendt (https://github.com/davidwendt) - Mark Harris (https://github.com/harrism) - Nghia Truong (https://github.com/ttnghia) URL: #9367
Fixes #9172.
Adds an overload of
extract_list_element()
where the indicesmay be specified as a column_view.
This function returns a list element from a potentially different index,
for each list row. The semantics of the scalar-index version of the function
are retained. i.e.:
Currently a work in progress. The following still needs addressing: