-
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
Added streams to JSON reader and writer api #14313
Conversation
/ok to test |
/ok to test |
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.
Nice! I have a couple of change requests, then this should be good to go.
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.
Thanks!
/ok to test |
@shrshi Looks like there's a test failure (link to logs).
This indicates that there might be an API that is using the default stream rather than a passed-in user stream. |
Can you please also remove unused |
/ok to test |
/ok to test |
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.
Great job! Was the copy constructor of column_to_strings_fn
the missing piece for the earlier errors?
Yes, the error was that the implicitly generated copy constructor of |
/ok to test |
/ok to test |
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.
Tests can be cleaned up to exclude the default-able parameters.
Looks good otherwise!
cudf::io::write_json(options_builder.build(), | ||
cudf::test::get_default_stream(), | ||
rmm::mr::get_current_device_resource()); |
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.
can these just be
cudf::io::write_json(options_builder.build(), | |
cudf::test::get_default_stream(), | |
rmm::mr::get_current_device_resource()); | |
cudf::io::write_json(options_builder.build()); |
We have the same values for the defaults. Not sure why mr
was specified in the first place.
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.
now I see the difference, cudf::get_default_stream vs cudf::test::get_default_stream
does this matter for these tests? I don't see other PRs adding the stream parameter to all 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.
Yes, the stream parameter can be left as is for now. For the moment, cudf::test::get_default_stream
is only necessary for the stream tests. That may change in the future, but probably isn't worth planning for right now.
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.
Thanks for the feedback! I've cleaned up the rmm::mr
default parameter in both the calls.
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.
Not sure I understand what "as is" is in @vyasr 's comment, but it looks like we might be adding the stream parameter to all API calls in the future so we might as do it now.
FWIW, the mr
parameter can be removed from write_json
calls in this file as well. I'm not blocking the PR on that, though.
/ok to test |
cpp/src/io/json/write_json.cu
Outdated
column_to_strings_fn(column_to_strings_fn const& other) | ||
: options_{other.options_}, | ||
stream_{other.stream_}, | ||
mr_{other.mr_}, | ||
narep(other.narep, other.stream_), | ||
struct_value_separator(other.struct_value_separator, other.stream_), | ||
struct_row_begin_wrap(other.struct_row_begin_wrap, other.stream_), | ||
struct_row_end_wrap(other.struct_row_end_wrap, other.stream_), | ||
list_value_separator(other.list_value_separator, other.stream_), | ||
list_row_begin_wrap(other.list_row_begin_wrap, other.stream_), | ||
list_row_end_wrap(other.list_row_end_wrap, other.stream_) | ||
{ | ||
} |
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.
column_to_strings_fn
is not meant to be copied.
I just added the patch to fix the copy constructor from being invoked. (please apply pre-commit hooks for clang-format, after applying this patch)
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.
diff --git a/cpp/src/io/json/write_json.cu b/cpp/src/io/json/write_json.cu
index c98e93aec4..98b35fc943 100644
--- a/cpp/src/io/json/write_json.cu
+++ b/cpp/src/io/json/write_json.cu
@@ -633,17 +633,17 @@ struct column_to_strings_fn {
auto child_string_with_null = [&]() {
if (child_view.type().id() == type_id::STRUCT) {
- return (*this).template operator()<cudf::struct_view>(
+ return this->template operator()<cudf::struct_view>(
child_view,
children_names.size() > child_index ? children_names[child_index].children
: std::vector<column_name_info>{});
} else if (child_view.type().id() == type_id::LIST) {
- return (*this).template operator()<cudf::list_view>(child_view,
+ return this->template operator()<cudf::list_view>(child_view,
children_names.size() > child_index
? children_names[child_index].children
: std::vector<column_name_info>{});
} else {
- return cudf::type_dispatcher(child_view.type(), *this, child_view);
+ return cudf::type_dispatcher<cudf::id_to_type_impl, column_to_strings_fn const&>(child_view.type(), *this, child_view);
}
};
auto new_offsets = cudf::lists::detail::get_normalized_offsets(
@@ -706,17 +706,17 @@ struct column_to_strings_fn {
auto const& current_col = thrust::get<1>(i_current_col);
// Struct needs children's column names
if (current_col.type().id() == type_id::STRUCT) {
- return (*this).template operator()<cudf::struct_view>(
+ return this->template operator()<cudf::struct_view>(
current_col,
children_names.size() > i ? children_names[i].children
: std::vector<column_name_info>{});
} else if (current_col.type().id() == type_id::LIST) {
- return (*this).template operator()<cudf::list_view>(
+ return this->template operator()<cudf::list_view>(
current_col,
children_names.size() > i ? children_names[i].children
: std::vector<column_name_info>{});
} else {
- return cudf::type_dispatcher(current_col.type(), *this, current_col);
+ return cudf::type_dispatcher<cudf::id_to_type_impl, column_to_strings_fn const&>(current_col.type(), *this, current_col);
}
});
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.
column_to_strings_fn(column_to_strings_fn const& other) | |
: options_{other.options_}, | |
stream_{other.stream_}, | |
mr_{other.mr_}, | |
narep(other.narep, other.stream_), | |
struct_value_separator(other.struct_value_separator, other.stream_), | |
struct_row_begin_wrap(other.struct_row_begin_wrap, other.stream_), | |
struct_row_end_wrap(other.struct_row_end_wrap, other.stream_), | |
list_value_separator(other.list_value_separator, other.stream_), | |
list_row_begin_wrap(other.list_row_begin_wrap, other.stream_), | |
list_row_end_wrap(other.list_row_end_wrap, other.stream_) | |
{ | |
} | |
column_to_strings_fn(column_to_strings_fn const& other) = delete; |
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.
similarly other constructors and assignment operators can be deleted too.
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.
Thank you, @karthikeyann. The patch has been applied.
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.
TIL you can get the type dispatcher to take the functor by reference.
Thanks @karthikeyann!
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.
Very nice job on this, @karthikeyann. 👏
…4549500; deleting copy and move assignment constructors
/ok to test |
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 👍
/merge |
does codecov/patch check not stop the merge ?! |
@karthikeyann Codecov is purely informational. It tends to have a lot of noise and false positives / false negatives. We are hoping that switching to a new branching strategy (like always merging to |
Description
This PR contributes to #13744.
cudf::io::read_json
cudf::io::write_json
Checklist