Skip to content

Commit

Permalink
Update doxygen, exceptions
Browse files Browse the repository at this point in the history
Co-authored-by: Chong Gao <res_life@163.com>
  • Loading branch information
davidwendt and Chong Gao committed Oct 15, 2024
1 parent b5e6d08 commit 62a51c6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
13 changes: 7 additions & 6 deletions cpp/include/cudf/strings/find_multiple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ namespace strings {
*/

/**
* @brief Returns a table of columns of boolean values for each string where true indicates
* the target string was found within that string in the provided column
* @brief Searches for the given target strings within each string in the provided column
*
* Each column in the result table corresponds to the result for the target string at the same
* ordinal. i.e. 0th column is the BOOL8 column result for the 0th target string, 1th for 1th,
Expand All @@ -38,7 +37,7 @@ namespace strings {
* If the target is not found for a string, false is returned for that entry in the output column.
* If the target is an empty string, true is returned for all non-null entries in the output column.
*
* Any null string entries return corresponding null entries in the output columns.
* Any null input strings return corresponding null entries in the output columns.
*
* @code{.pseudo}
* input = ["a", "b", "c"]
Expand All @@ -48,6 +47,8 @@ namespace strings {
* column 1: [false, false, true]
* @endcode
*
* @throw std::invalid_argument if `targets` is empty or contains nulls
*
* @param input Strings instance for this operation
* @param targets UTF-8 encoded strings to search for in each string in `input`
* @param stream CUDA stream used for device memory operations and kernel launches
Expand All @@ -61,8 +62,8 @@ std::unique_ptr<table> contains_multiple(
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/**
* @brief Returns a lists column with character position values where each
* of the target strings are found in each string.
* @brief Searches for the given target strings within each string in the provided column
* and returns the position the targets were found
*
* The size of the output column is `input.size()`.
* Each row of the output column is of size `targets.size()`.
Expand All @@ -78,7 +79,7 @@ std::unique_ptr<table> contains_multiple(
* [-1,-1, 1 ]} // for "def": "a" and "b" not found, "e" at pos 1
* @endcode
*
* @throw cudf::logic_error if `targets` is empty or contains nulls
* @throw , std::invalid_argument if `targets` is empty or contains nulls
*
* @param input Strings instance for this operation
* @param targets Strings to search for in each string
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/strings/search/contains_multiple.cu
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ std::unique_ptr<table> contains_multiple(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(not targets.is_empty(), "Must specify at least one target string.");
CUDF_EXPECTS(not targets.has_nulls(), "Target strings cannot be null");
CUDF_EXPECTS(
not targets.is_empty(), "Must specify at least one target string.", std::invalid_argument);
CUDF_EXPECTS(not targets.has_nulls(), "Target strings cannot be null", std::invalid_argument);

auto const d_strings = column_device_view::create(input.parent(), stream);
auto const d_targets = column_device_view::create(targets.parent(), stream);
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/strings/search/find_multiple.cu
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ std::unique_ptr<column> find_multiple(strings_column_view const& input,
{
auto const strings_count = input.size();
auto const targets_count = targets.size();
CUDF_EXPECTS(targets_count > 0, "Must include at least one search target");
CUDF_EXPECTS(!targets.has_nulls(), "Search targets cannot contain null strings");
CUDF_EXPECTS(targets_count > 0, "Must include at least one search target", std::invalid_argument);
CUDF_EXPECTS(
!targets.has_nulls(), "Search targets cannot contain null strings", std::invalid_argument);

auto strings_column = column_device_view::create(input.parent(), stream);
auto d_strings = *strings_column;
Expand Down
6 changes: 4 additions & 2 deletions cpp/tests/strings/find_multiple_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ TEST_F(StringsFindMultipleTest, ErrorTest)
auto const zero_size_strings_column = cudf::make_empty_column(cudf::type_id::STRING)->view();
auto empty_view = cudf::strings_column_view(zero_size_strings_column);
// targets must have at least one string
EXPECT_THROW(cudf::strings::find_multiple(strings_view, empty_view), cudf::logic_error);
EXPECT_THROW(cudf::strings::find_multiple(strings_view, empty_view), std::invalid_argument);
EXPECT_THROW(cudf::strings::contains_multiple(strings_view, empty_view), std::invalid_argument);

// targets cannot have nulls
EXPECT_THROW(cudf::strings::find_multiple(strings_view, strings_view), cudf::logic_error);
EXPECT_THROW(cudf::strings::find_multiple(strings_view, strings_view), std::invalid_argument);
EXPECT_THROW(cudf::strings::contains_multiple(strings_view, strings_view), std::invalid_argument);
}

TEST_F(StringsFindMultipleTest, MultiContains)
Expand Down

0 comments on commit 62a51c6

Please sign in to comment.