Skip to content

Commit

Permalink
Remove obsolete cudf::strings::replace_nulls (#7965)
Browse files Browse the repository at this point in the history
The `cudf::strings::replace_nulls()` is a public API that was replaced by `cudf::replace_nulls()`. 
The strings one should not be used since the base one handles any column type.

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Conor Hoekstra (https://github.com/codereport)
  - Nghia Truong (https://github.com/ttnghia)
  - Christopher Harris (https://github.com/cwharris)
  - Mike Wilson (https://github.com/hyperbolic2346)

URL: #7965
  • Loading branch information
davidwendt authored Apr 21, 2021
1 parent d501d2c commit f11bcd7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 57 deletions.
18 changes: 15 additions & 3 deletions cpp/include/cudf/strings/detail/replace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,22 @@ std::unique_ptr<column> replace(
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/**
* @copydoc cudf::strings::replace(strings_column_view const&, string_scalar const&,
* rmm::mr::device_memory_resource*)
* @brief Replaces any null string entries with the given string.
*
* @param[in] stream CUDA stream used for device memory operations and kernel launches.
* This returns a strings column with no null entries.
*
* @code{.pseudo}
* Example:
* s = ["hello", nullptr, "goodbye"]
* r = replace_nulls(s,"**")
* r is now ["hello", "**", "goodbye"]
* @endcode
*
* @param strings Strings column for this operation.
* @param repl Replacement string for null entries. Default is empty string.
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return New strings column.
*/
std::unique_ptr<column> replace_nulls(
strings_column_view const& strings,
Expand Down
22 changes: 0 additions & 22 deletions cpp/include/cudf/strings/replace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,28 +151,6 @@ std::unique_ptr<column> replace(
strings_column_view const& repls,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/**
* @brief Replaces any null string entries with the given string.
*
* This returns a strings column with no null entries.
*
* @code{.pseudo}
* Example:
* s = ["hello", nullptr, "goodbye"]
* r = replace_nulls(s,"**")
* r is now ["hello", "**", "goodbye"]
* @endcode
*
* @param strings Strings column for this operation.
* @param repl Replacement string for null entries. Default is empty string.
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return New strings column.
*/
std::unique_ptr<column> replace_nulls(
strings_column_view const& strings,
string_scalar const& repl = string_scalar(""),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/** @} */ // end of doxygen group
} // namespace strings
} // namespace cudf
8 changes: 0 additions & 8 deletions cpp/src/strings/replace/replace.cu
Original file line number Diff line number Diff line change
Expand Up @@ -871,13 +871,5 @@ std::unique_ptr<column> replace(strings_column_view const& strings,
return detail::replace(strings, targets, repls, rmm::cuda_stream_default, mr);
}

std::unique_ptr<column> replace_nulls(strings_column_view const& strings,
string_scalar const& repl,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_nulls(strings, repl, rmm::cuda_stream_default, mr);
}

} // namespace strings
} // namespace cudf
24 changes: 0 additions & 24 deletions cpp/tests/strings/replace_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,30 +337,6 @@ TEST_F(StringsReplaceTest, ReplaceMulti)
}
}

TEST_F(StringsReplaceTest, ReplaceNulls)
{
std::vector<const char*> h_strings{"Héllo", "thesé", nullptr, "ARE THE", "tést strings", ""};

cudf::test::strings_column_wrapper strings(
h_strings.begin(),
h_strings.end(),
thrust::make_transform_iterator(h_strings.begin(), [](auto str) { return str != nullptr; }));
auto strings_view = cudf::strings_column_view(strings);

{
auto results = cudf::strings::replace_nulls(strings_view, cudf::string_scalar("___"));
std::vector<const char*> h_expected{"Héllo", "thesé", "___", "ARE THE", "tést strings", ""};
cudf::test::strings_column_wrapper expected(h_expected.begin(), h_expected.end());
CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected);
}
{
auto results = cudf::strings::replace_nulls(strings_view);
std::vector<const char*> h_expected{"Héllo", "thesé", "", "ARE THE", "tést strings", ""};
cudf::test::strings_column_wrapper expected(h_expected.begin(), h_expected.end());
CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected);
}
}

TEST_F(StringsReplaceTest, EmptyStringsColumn)
{
cudf::column_view zero_size_strings_column(
Expand Down

0 comments on commit f11bcd7

Please sign in to comment.