-
Notifications
You must be signed in to change notification settings - Fork 902
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
Support nested types for nth_element reduction #9043
Support nested types for nth_element reduction #9043
Conversation
Signed-off-by: sperlingxx <[email protected]>
if (col.size() <= col.null_count()) return result; | ||
// Returns default scalar if input column is non-valid. In terms of nested columns, we need to | ||
// handcraft the default scalar with input column. | ||
if (col.size() <= col.null_count()) { |
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.
This looks like we need something like a make_empty_scalar_like(column_view)
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 agree. And I created the method make_empty_scalar_like
based on the above code.
Signed-off-by: sperlingxx <[email protected]>
Codecov Report
@@ Coverage Diff @@
## branch-21.10 #9043 +/- ##
===============================================
Coverage ? 10.71%
===============================================
Files ? 114
Lines ? 19090
Branches ? 0
===============================================
Hits ? 2046
Misses ? 17044
Partials ? 0 Continue to review full report at Codecov.
|
Co-authored-by: Nghia Truong <[email protected]>
cpp/src/scalar/scalar_factories.cpp
Outdated
result->set_valid_async(false, stream); | ||
break; | ||
case type_id::STRUCT: | ||
// Struct scalar inputs must have exactly 1 row. |
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.
Should have "at least one row", I think...
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.
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.
If so, you don't have to have your own CUDF_EXPECT
because rows == 1
will be handled in the scalar constructor.
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.
Wait, then you should use make_struct_scalar
too :|
Co-authored-by: David Wendt <[email protected]> Co-authored-by: Nghia Truong <[email protected]>
cpp/src/scalar/scalar_factories.cpp
Outdated
case type_id::STRUCT: | ||
// Struct scalar inputs must have exactly 1 row. | ||
CUDF_EXPECTS(!column.is_empty(), "Can not create empty struct scalar"); | ||
result = detail::get_element(column, 1, stream, mr); |
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.
index=1
? (should be 0
right?)
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.
How about result = make_struct_scalar(column, stream, mr)
?
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.
make_struct_scalar
only accepts table_view
or host_span<column_view>
. In addition, it assumes the size of input data == 1 (rather than slicing them to 1).
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.
Wow, expecting full_size() == 1
(not sliced_size() == 1
) should be wrong!
OK get it. So you are just slicing the input column (get one row) from it and don't care how many rows it has.
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.
index=
1
? (should be0
right?)
Yes, I corrected it. Thanks!
Rerun tests. |
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.
LGTM.
@gpucibot merge |
Closes #8967
Current PR supported the construction of default scalar on nested types (LIST_TYPE and STRUCT_TYPE) for reduction, in order to support nested types for nth_element reduction.