-
Notifications
You must be signed in to change notification settings - Fork 915
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
Change make_strings_children to return uvector #15171
Changes from all commits
c8426c0
73eedf8
7fdb691
9fa12c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -34,7 +34,7 @@ namespace strings { | |||||
namespace detail { | ||||||
|
||||||
/** | ||||||
* @brief Creates child offsets and chars columns by applying the template function that | ||||||
* @brief Creates child offsets and chars data by applying the template function that | ||||||
* can be used for computing the output size of each string as well as create the output | ||||||
* | ||||||
* @throws std::overflow_error if the output strings column exceeds the column size limit | ||||||
|
@@ -49,7 +49,7 @@ namespace detail { | |||||
* @param strings_count Number of strings. | ||||||
* @param stream CUDA stream used for device memory operations and kernel launches. | ||||||
* @param mr Device memory resource used to allocate the returned columns' device memory. | ||||||
* @return offsets child column and chars child column for a strings column | ||||||
* @return Offsets child column and chars data for a strings column | ||||||
*/ | ||||||
template <typename SizeAndExecuteFunction> | ||||||
auto make_strings_children(SizeAndExecuteFunction size_and_exec_fn, | ||||||
|
@@ -84,18 +84,17 @@ auto make_strings_children(SizeAndExecuteFunction size_and_exec_fn, | |||||
std::overflow_error); | ||||||
|
||||||
// Now build the chars column | ||||||
std::unique_ptr<column> chars_column = | ||||||
create_chars_child_column(static_cast<size_type>(bytes), stream, mr); | ||||||
rmm::device_uvector<char> chars(bytes, stream, mr); | ||||||
|
||||||
// Execute the function fn again to fill the chars column. | ||||||
// Note that if the output chars column has zero size, the function fn should not be called to | ||||||
// avoid accidentally overwriting the offsets. | ||||||
if (bytes > 0) { | ||||||
size_and_exec_fn.d_chars = chars_column->mutable_view().template data<char>(); | ||||||
size_and_exec_fn.d_chars = chars.data(); | ||||||
for_each_fn(size_and_exec_fn); | ||||||
} | ||||||
|
||||||
return std::pair(std::move(offsets_column), std::move(chars_column)); | ||||||
return std::pair(std::move(offsets_column), std::move(chars)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit: no need to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought copy elision could happen automatically with C++17 based on multiple discussions at our cpp channel and also StackOverflow and then by taking a closer look at your sample code, I realized that returning a pair makes a difference (see here). |
||||||
} | ||||||
|
||||||
/** | ||||||
|
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.
Preferably returning a unique pointer of uvector according to the developer guide,
cudf/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md
Lines 185 to 190 in 63e9040
I also noticed #14202 changed the input argument from unique ptr to rvalue reference for
make_strings_column
, which makes the ownership information obscure IMO.