-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose stream parameter in public strings contains APIs (#14280)
Add stream parameter to public APIs: - `cudf::strings::contains_re()` - `cudf::strings::matches_re()` - `cudf::strings::count_re()` - `cudf::strings::like()` (x2) - `cudf::strings::extract()` - `cudf::strings::extract_all_record()` Also cleaned up some of the doxygen comments. Reference #13744 Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) URL: #14280
- Loading branch information
1 parent
91aeec8
commit 865c21e
Showing
9 changed files
with
139 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <cudf_test/base_fixture.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
#include <cudf_test/default_stream.hpp> | ||
|
||
#include <cudf/strings/contains.hpp> | ||
#include <cudf/strings/regex/regex_program.hpp> | ||
|
||
#include <string> | ||
|
||
class StringsContainsTest : public cudf::test::BaseFixture {}; | ||
|
||
TEST_F(StringsContainsTest, Contains) | ||
{ | ||
auto input = cudf::test::strings_column_wrapper({"Héllo", "thesé", "tést strings", ""}); | ||
auto view = cudf::strings_column_view(input); | ||
|
||
auto const pattern = std::string("[a-z]"); | ||
auto const prog = cudf::strings::regex_program::create(pattern); | ||
cudf::strings::contains_re(view, *prog, cudf::test::get_default_stream()); | ||
cudf::strings::matches_re(view, *prog, cudf::test::get_default_stream()); | ||
cudf::strings::count_re(view, *prog, cudf::test::get_default_stream()); | ||
} | ||
|
||
TEST_F(StringsContainsTest, Like) | ||
{ | ||
auto input = cudf::test::strings_column_wrapper({"Héllo", "thesés", "tést", ""}); | ||
auto view = cudf::strings_column_view(input); | ||
|
||
auto const pattern = cudf::string_scalar("%és", true, cudf::test::get_default_stream()); | ||
auto const escape = cudf::string_scalar("%", true, cudf::test::get_default_stream()); | ||
cudf::strings::like(view, pattern, escape, cudf::test::get_default_stream()); | ||
|
||
auto const patterns = cudf::test::strings_column_wrapper({"H%", "t%s", "t", ""}); | ||
cudf::strings::like( | ||
view, cudf::strings_column_view(patterns), escape, cudf::test::get_default_stream()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <cudf_test/base_fixture.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
#include <cudf_test/default_stream.hpp> | ||
|
||
#include <cudf/strings/extract.hpp> | ||
#include <cudf/strings/regex/regex_program.hpp> | ||
|
||
#include <string> | ||
|
||
class StringsExtractTest : public cudf::test::BaseFixture {}; | ||
|
||
TEST_F(StringsExtractTest, Extract) | ||
{ | ||
auto input = cudf::test::strings_column_wrapper({"Joe Schmoe", "John Smith", "Jane Smith"}); | ||
auto view = cudf::strings_column_view(input); | ||
|
||
auto const pattern = std::string("([A-Z][a-z]+)"); | ||
auto const prog = cudf::strings::regex_program::create(pattern); | ||
cudf::strings::extract(view, *prog, cudf::test::get_default_stream()); | ||
cudf::strings::extract_all_record(view, *prog, cudf::test::get_default_stream()); | ||
} |