Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
b39a18e
feature: implement Glushkov's NFA
lingyany-nv Mar 21, 2026
d90a5e6
implement shared memory version of Glushkov's NFA
lingyany-nv Mar 23, 2026
7644ff4
refactor and simplify the code
lingyany-nv Mar 23, 2026
b3d7ab9
add python regex tests from spark-rapids regex tests
lingyany-nv Mar 25, 2026
cca1cba
add more complex regexes to the benchmarks
lingyany-nv Apr 1, 2026
8cacf16
fix the correctness (leftmost-longest vs leftmost-first) issue; chang…
lingyany-nv Apr 8, 2026
76fb67f
add compile-time-check to disalbe Glushkov when it cannot produce lef…
lingyany-nv Apr 9, 2026
cca35f9
add nullable regexes unit tests
lingyany-nv Apr 9, 2026
9edbab7
for affected benchmarks, keep unsupported patterns in the benchmark, …
lingyany-nv Apr 10, 2026
f2240da
fix minor issues
lingyany-nv Apr 10, 2026
98646b4
delete some dead code, update stale comments
lingyany-nv Apr 10, 2026
2eaec3c
remove stalbe comments
lingyany-nv Apr 10, 2026
30fa2eb
applied the formatter
lingyany-nv Apr 13, 2026
b114480
fix python format
lingyany-nv Apr 13, 2026
8acb318
fix clang-format again
lingyany-nv Apr 13, 2026
c4e1cb8
add replace_re tests, fixed minior issues
lingyany-nv Apr 15, 2026
7c4fc14
clang-format
lingyany-nv Apr 15, 2026
c18abd8
deleted unuseful comments
lingyany-nv Apr 28, 2026
604b216
remove multi-pattern replace
davidwendt May 26, 2026
2e3a089
remove multi_re.cu from cmake file
davidwendt May 26, 2026
6328c9e
remove nullable, lazy-quantifier; add tests
davidwendt May 26, 2026
68bd0f4
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt May 26, 2026
324b304
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt May 29, 2026
e642ea1
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt May 29, 2026
d635a72
use non-capture on findall tests
davidwendt May 29, 2026
93fcf31
fix merge conflicts
davidwendt Jun 2, 2026
5f7bab7
use reinst for positions
davidwendt Jun 2, 2026
2c119e5
remove glushkov.inl
davidwendt Jun 2, 2026
b1ebcd7
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 3, 2026
cf49828
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 4, 2026
e3ae0a0
remove unused glushkov_global_source
davidwendt Jun 4, 2026
24163c5
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 5, 2026
c2b29aa
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 8, 2026
2ca6b3b
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 10, 2026
1a6341b
fix merge conflicts
davidwendt Jun 12, 2026
08736b4
factor out useful tests appropriately
davidwendt Jun 12, 2026
3a17319
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 12, 2026
d415848
merge changes for findall_tests.cpp
davidwendt Jun 12, 2026
5a2228b
templatize prog_device in utilities.cuh functions
davidwendt Jun 12, 2026
e06ca9d
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 22, 2026
22e7b81
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 23, 2026
1ab8b6e
removed more code; change g_state to glushkov_state
davidwendt Jun 23, 2026
f59edb4
separated gkprog_device from reprog_device
davidwendt Jun 23, 2026
c29f286
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 24, 2026
6a11a35
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 25, 2026
d9ba38d
some cleanup of comments and member variable names
davidwendt Jun 25, 2026
03ad2da
rework gkprog_device::create
davidwendt Jun 25, 2026
7a3b5c2
fix merge conflict
davidwendt Jun 30, 2026
4a0df6a
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 30, 2026
53bb5cc
remove the GLUSHKOV regex-flag
davidwendt Jun 30, 2026
4dd07ed
add glushkov fast-path to appropriate regex functions
davidwendt Jun 30, 2026
b7f1b50
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 30, 2026
7d8e573
remove glushkov_tests.cpp
davidwendt Jun 30, 2026
6f7d705
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 30, 2026
73a179e
replace __builtins with STL calls
davidwendt Jun 30, 2026
e177089
reset regecomp.cpp
davidwendt Jun 30, 2026
3d3e50e
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jun 30, 2026
0999669
linter fix: auto cast
davidwendt Jul 1, 2026
b6aebfb
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 1, 2026
84af963
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 1, 2026
5810765
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 2, 2026
5ab9b4f
cleanup and rename reclass.hpp to common.cuh
davidwendt Jul 2, 2026
ef1376f
add env variable
davidwendt Jul 2, 2026
5535e37
undo unneeded benchmark changes
davidwendt Jul 2, 2026
bcbf166
add sync calls
davidwendt Jul 2, 2026
28d11f5
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 2, 2026
bdf6185
remove unneeded variable
davidwendt Jul 2, 2026
11f77ad
prevent double creating the reprog-device objects
davidwendt Jul 2, 2026
5189fe1
fix builtins space check
davidwendt Jul 2, 2026
d9ff906
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 2, 2026
38f856b
fix new linter error
davidwendt Jul 3, 2026
92cd568
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 3, 2026
e1d7ec5
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 6, 2026
5d18241
remove nullable words
davidwendt Jul 6, 2026
7efb37f
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 7, 2026
7ae1f3c
use stack intead of recursion for eps_closure and ordered_eps_frontier
lingyany-nv Jul 7, 2026
9d6a4ca
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 7, 2026
2891dcc
remove new; rework reclass
davidwendt Jul 7, 2026
9046fdf
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 7, 2026
92e93d5
undo comment change
davidwendt Jul 7, 2026
35290f6
undo more unneeded changes to regexec.cpp
davidwendt Jul 7, 2026
7047521
remove unneeded include
davidwendt Jul 7, 2026
01e844e
added some consts
davidwendt Jul 7, 2026
c848b9d
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 7, 2026
9d2570e
use tuple as return type, use array instead of map
lingyany-nv Jul 8, 2026
293d238
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 8, 2026
251211d
Merge branch 'lingyany/glushkov-nfa' of github.com:lingyany-nv/cudf i…
davidwendt Jul 8, 2026
8a46843
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 8, 2026
ae3bdbc
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 8, 2026
7179ad7
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 9, 2026
41caa42
replace some literals with named constant
davidwendt Jul 9, 2026
cc0e60a
remove include cuda_runtime.h
davidwendt Jul 9, 2026
54af99b
add/update some comments
davidwendt Jul 9, 2026
8eaf307
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 9, 2026
ed12956
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 13, 2026
0e54aa9
Merge branch 'main' into lingyany/glushkov-nfa
davidwendt Jul 14, 2026
faf578d
fix merge conflicts
davidwendt Jul 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,8 @@ add_library(
src/strings/merge/merge.cu
src/strings/padding.cu
src/strings/positions.cu
src/strings/regex/gkexec.cpp
src/strings/regex/glushkov_regcomp.cpp
src/strings/regex/regcomp.cpp
src/strings/regex/regexec.cpp
src/strings/regex/regex_program.cpp
Expand Down
6 changes: 4 additions & 2 deletions cpp/src/strings/char_types/char_flags.h

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we take this chance migrating all .h headers touched in this PR to .hpp to align with the libcudf convention?

@davidwendt davidwendt Jul 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this is not a new file. I don't think this kind of change should be included in this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with that. As a small suggestion, would it make sense for new headers like glushkov_regcomp.h to use the .hpp extension?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm favorable towards changing this. If not in this PR, in an immediate follow-up.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
* SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
Expand All @@ -23,7 +23,8 @@
// 0 - decimal
//

uint8_t const g_character_codepoint_flags[] = {
// clang-format off
uint8_t const g_character_codepoint_flags[] = { // NOLINT
Comment thread
PointKernel marked this conversation as resolved.
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7,
Expand Down Expand Up @@ -3475,3 +3476,4 @@ uint8_t const g_character_codepoint_flags[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
};
// clang-format on
27 changes: 14 additions & 13 deletions cpp/src/strings/contains.cu
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ struct contains_fn {
column_device_view const d_strings;
bool const beginning_only;

__device__ bool operator()(size_type const idx,
reprog_device const prog,
int32_t const thread_idx)
template <typename ProgDevice>
__device__ bool operator()(size_type const idx, ProgDevice const prog, int32_t const thread_idx)
{
if (d_strings.is_null(idx)) return false;
auto const d_str = d_strings.element<string_view>(idx);

size_type end = beginning_only ? 1 // match only the beginning of the string;
: -1; // match anywhere in the string
return prog.find<positional::END_ONLY>(thread_idx, d_str, d_str.begin(), end).has_value();
return prog.template find<positional::END_ONLY>(thread_idx, d_str, d_str.begin(), end)
.has_value();
}
};

Expand All @@ -62,15 +62,18 @@ std::unique_ptr<column> contains_impl(strings_column_view const& input,
mr);
if (input.is_empty()) { return results; }

auto d_prog = regex_device_builder::create_prog_device(prog, stream);

auto d_results = results->mutable_view().data<bool>();
auto const d_strings = column_device_view::create(input.parent(), stream);

launch_transform_kernel(
contains_fn{*d_strings, beginning_only}, *d_prog, d_results, input.size(), stream);

results->set_null_count(input.null_count());
if (regex_device_builder::glushkov_fast_path_supported(prog)) {
auto d_prog = regex_device_builder::create_gkprog_device(prog, stream);
launch_transform_kernel(
contains_fn{*d_strings, beginning_only}, *d_prog, d_results, input.size(), stream);
} else {
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
launch_transform_kernel(
contains_fn{*d_strings, beginning_only}, *d_prog, d_results, input.size(), stream);
}

return results;
}
Expand Down Expand Up @@ -133,11 +136,9 @@ std::unique_ptr<column> count_re(strings_column_view const& input,
return count(input, target, stream, mr);
}

auto d_prog = regex_device_builder::create_prog_device(prog, stream);

auto const d_strings = column_device_view::create(input.parent(), stream);

auto result = count_matches(*d_strings, *d_prog, stream, mr);
auto result = count_matches(*d_strings, prog, stream, mr);
if (input.has_nulls()) {
result->set_null_mask(cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count());
Expand Down
60 changes: 50 additions & 10 deletions cpp/src/strings/count_matches.cu
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

#include "strings/count_matches.hpp"
#include "strings/regex/regex_program_impl.h"
#include "strings/regex/utilities.cuh"

#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/strings/regex/regex_program.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/utilities/memory_resource.hpp>

#include <type_traits>

namespace cudf {
namespace strings {
namespace detail {
Expand All @@ -23,8 +27,9 @@ template <positional P>
struct count_fn {
column_device_view const d_strings;

template <typename ProgDevice>
__device__ int32_t operator()(size_type const idx,
reprog_device const prog,
ProgDevice const prog,
int32_t const thread_idx)
{
if (d_strings.is_null(idx)) return 0;
Expand All @@ -34,7 +39,7 @@ struct count_fn {

auto itr = d_str.begin();
while (itr.position() <= nchars) {
auto result = prog.find<P>(thread_idx, d_str, itr);
auto result = prog.template find<P>(thread_idx, d_str, itr);
if (!result) { break; }
++count;
// increment the iterator is faster than creating a new one
Expand All @@ -47,29 +52,64 @@ struct count_fn {

} // namespace

template <typename ProgDevice>
std::unique_ptr<column> count_matches(column_device_view const& d_strings,
reprog_device& d_prog,
ProgDevice& d_prog,
size_type strings_count,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr)
{
auto results = make_numeric_column(
data_type{type_to_id<size_type>()}, d_strings.size(), mask_state::UNALLOCATED, stream, mr);
data_type{type_to_id<size_type>()}, strings_count, mask_state::UNALLOCATED, stream, mr);

if (d_strings.size() == 0) { return results; }
if (strings_count == 0) { return results; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this branch?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, otherwise we could launch a kernel with no threads.


auto d_results = results->mutable_view().data<cudf::size_type>();

if (d_prog.is_empty_match_possible()) {
// Glushkov's engine always requires the begin/end positional check; the Thompson
// engine can skip it (cheaper) when an empty match is not possible for this pattern.
if constexpr (std::is_same_v<ProgDevice, gkprog_device>) {
launch_transform_kernel(
count_fn<positional::BEGIN_END>{d_strings}, d_prog, d_results, d_strings.size(), stream);
count_fn<positional::BEGIN_END>{d_strings}, d_prog, d_results, strings_count, stream);
} else {
launch_transform_kernel(
count_fn<positional::END_ONLY>{d_strings}, d_prog, d_results, d_strings.size(), stream);
if (d_prog.is_empty_match_possible()) {
launch_transform_kernel(
count_fn<positional::BEGIN_END>{d_strings}, d_prog, d_results, strings_count, stream);
} else {
launch_transform_kernel(
count_fn<positional::END_ONLY>{d_strings}, d_prog, d_results, strings_count, stream);
}
}

return results;
}

template std::unique_ptr<column> count_matches<reprog_device>(column_device_view const&,
reprog_device&,
size_type,
rmm::cuda_stream_view,
rmm::device_async_resource_ref);

template std::unique_ptr<column> count_matches<gkprog_device>(column_device_view const&,
gkprog_device&,
size_type,
rmm::cuda_stream_view,
rmm::device_async_resource_ref);

std::unique_ptr<column> count_matches(column_device_view const& d_strings,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr)
{
auto const strings_count = d_strings.size();
if (regex_device_builder::glushkov_fast_path_supported(prog)) {
auto d_prog = regex_device_builder::create_gkprog_device(prog, stream);
return count_matches(d_strings, *d_prog, strings_count, stream, mr);
}
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
return count_matches(d_strings, *d_prog, strings_count, stream, mr);
}

} // namespace detail
} // namespace strings
} // namespace cudf
36 changes: 32 additions & 4 deletions cpp/src/strings/count_matches.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand All @@ -15,23 +15,51 @@ namespace cudf {
class column_device_view;

namespace strings {

class regex_program;

namespace detail {

class reprog_device;
/**
* @brief Returns a column of regex match counts for each string in the given column.
*
* A null entry will result in a zero count for that output row.
*
* This overload evaluates against an already-built device regex program. Callers that
* also need the device program for other work (e.g. extraction) should build it once
* and pass it here to avoid a redundant device program build.
*
Comment thread
davidwendt marked this conversation as resolved.
* @tparam The regex prog device instance used for this API
* @param d_strings Device view of the input strings column
* @param d_prog Device regex program to evaluate on each string
* @param strings_count Number of strings (and rows in the output column)
* @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 Integer column of match counts
*/
template <typename ProgDevice>
std::unique_ptr<column> count_matches(column_device_view const& d_strings,
ProgDevice& d_prog,
size_type strings_count,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr);

/**
* @brief Returns a column of regex match counts for each string in the given column.
*
* A null entry will result in a zero count for that output row.
*
* This overload builds its own device regex program. Prefer the overload above when
* the device program is also needed for other work on the same call site.
*
* @param d_strings Device view of the input strings column.
* @param d_prog Regex instance to evaluate on each string.
* @param prog Regex program to evaluate on each 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 Integer column of match counts
*/
std::unique_ptr<column> count_matches(column_device_view const& d_strings,
reprog_device& d_prog,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr);

Expand Down
7 changes: 4 additions & 3 deletions cpp/src/strings/extract/extract_all.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -106,9 +106,10 @@ std::unique_ptr<column> extract_all_record(strings_column_view const& input,
auto const groups = d_prog->group_counts();
CUDF_EXPECTS(groups > 0, "extract_all requires group indicators in the regex pattern.");

// Get the match counts for each string.
// Get the match counts for each string, reusing the device program built above
// instead of building a second one.
// This column will become the output lists child offsets column.
auto counts = count_matches(*d_strings, *d_prog, stream, mr);
auto counts = count_matches(*d_strings, *d_prog, strings_count, stream, mr);
auto d_counts = counts->mutable_view().data<size_type>();

// Compute null output rows
Expand Down
90 changes: 90 additions & 0 deletions cpp/src/strings/regex/common.cuh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once

#include "regcomp.h"

#include <cudf/strings/detail/char_tables.hpp>
#include <cudf/strings/detail/utf8.hpp>
#include <cudf/types.hpp>

#include <cuda/std/optional>
#include <cuda/std/utility>
#include <thrust/execution_policy.h>
#include <thrust/logical.h>

namespace cudf::strings::detail {

/// Bitmask type: bit i is set when Glushkov position i is active.
using glushkov_state_t = uint64_t;

/// Maximum number of character-consuming positions (states) in the Glushkov NFA.
/// Patterns with more positions fall back to Thompson NFA automatically.
constexpr int32_t GLUSHKOV_MAX_STATES = sizeof(glushkov_state_t) * 8;

/// Maximum shift amounts for the Hyperscan-style shift-and optimization.
constexpr int32_t GLUSHKOV_MAX_SHIFTS = 8;

/// Size of the precomputed ASCII reach table (characters 0–127).
constexpr int32_t GLUSHKOV_ASCII_TABLE_SIZE = 128;
Comment thread
PointKernel marked this conversation as resolved.

/**
* @brief Regex class stored on the device and executed by reprog_device.
*
* This class holds the unique data for any regex CCLASS instruction.
*/
struct alignas(16) reclass_device {
int32_t builtins{};
int32_t count{};
reclass_range const* literals{};

__device__ inline bool is_match(char32_t const ch, uint8_t const* codepoint_flags) const
{
if (thrust::any_of(thrust::seq, literals, literals + count, [ch](auto literal) {
return ((ch >= literal.first) && (ch <= literal.last));
})) {
return true;
}

if (!builtins) { return false; }
auto const codept = utf8_to_codepoint(ch);
constexpr uint32_t MAX_CODEPOINT = 0x00'FFFF;
if (codept > MAX_CODEPOINT) { return false; }
auto const fl = codepoint_flags[codept];
if ((builtins & CCLASS_W) && ((ch == '_') || IS_ALPHANUM(fl))) { return true; } // \w
if ((builtins & CCLASS_S) && IS_SPACE(fl)) { return true; } // \s
if ((builtins & CCLASS_D) && IS_DIGIT(fl)) { return true; } // \d
if ((builtins & NCCLASS_W) && ((ch != '\n') && (ch != '_') && !IS_ALPHANUM(fl))) { // \W
return true;
}
if ((builtins & NCCLASS_S) && !IS_SPACE(fl)) { return true; } // \S
if ((builtins & NCCLASS_D) && ((ch != '\n') && !IS_DIGIT(fl))) { return true; } // \D

return false;
}
};

/**
* @brief Check for supported new-line characters
*
* '\n, \r, \u0085, \u2028, or \u2029'
*/
CUDF_HOST_DEVICE __forceinline__ constexpr bool is_newline(char32_t const ch)
{
return (ch == '\n' || ch == '\r' || ch == 0x00c285 || ch == 0x00e280a8 || ch == 0x00e280a9);
}

/**
* @brief Template type used on `find` to specify desired position values in returned match_result
*/
enum class positional : int8_t {
BEGIN_END = 0, /// both begin and end positions are returned
END_ONLY = 1, /// only the end position is returned
};

using match_pair = cuda::std::pair<cudf::size_type, cudf::size_type>;
using match_result = cuda::std::optional<match_pair>;
Comment thread
PointKernel marked this conversation as resolved.

} // namespace cudf::strings::detail
Loading
Loading