From 10218a972d3a4950d4639c41d9ae9116aff18c12 Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Fri, 17 Nov 2023 14:14:55 -0800 Subject: [PATCH] JSON writer: avoid default stream use in `string_scalar` constructors (#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: https://github.com/rapidsai/cudf/pull/14444 --- cpp/src/io/json/write_json.cu | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cpp/src/io/json/write_json.cu b/cpp/src/io/json/write_json.cu index c211d17f13a..938f9728fe8 100644 --- a/cpp/src/io/json/write_json.cu +++ b/cpp/src/io/json/write_json.cu @@ -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) { } @@ -526,8 +528,7 @@ struct column_to_strings_fn { std::enable_if_t, std::unique_ptr> 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: @@ -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