Skip to content

Commit

Permalink
JSON writer: avoid default stream use in string_scalar constructors (
Browse files Browse the repository at this point in the history
…#14444)

Added the true/false string scalars to `column_to_strings_fn` so they are created once, instead of creating new scalars for each boolean column (using default stream).

Authors:
  - Vukasin Milovanovic (https://github.com/vuule)

Approvers:
  - Nghia Truong (https://github.com/ttnghia)
  - https://github.com/shrshi

URL: #14444
  • Loading branch information
vuule authored Nov 17, 2023
1 parent 8917870 commit 10218a9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cpp/src/io/json/write_json.cu
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ struct column_to_strings_fn {
struct_row_end_wrap("}", true, stream),
list_value_separator(",", true, stream),
list_row_begin_wrap("[", true, stream),
list_row_end_wrap("]", true, stream)
list_row_end_wrap("]", true, stream),
true_value(options_.get_true_value(), true, stream),
false_value(options_.get_false_value(), true, stream)
{
}

Expand All @@ -526,8 +528,7 @@ struct column_to_strings_fn {
std::enable_if_t<std::is_same_v<column_type, bool>, std::unique_ptr<column>> operator()(
column_view const& column) const
{
return cudf::strings::detail::from_booleans(
column, options_.get_true_value(), options_.get_false_value(), stream_, mr_);
return cudf::strings::detail::from_booleans(column, true_value, false_value, stream_, mr_);
}

// strings:
Expand Down Expand Up @@ -742,6 +743,9 @@ struct column_to_strings_fn {
string_scalar const list_value_separator; // ","
string_scalar const list_row_begin_wrap; // "["
string_scalar const list_row_end_wrap; // "]"
// bool converter constants
string_scalar const true_value;
string_scalar const false_value;
};

} // namespace
Expand Down

0 comments on commit 10218a9

Please sign in to comment.