find.hpp
转到此文件的文档。
1 /*
2  * Copyright (c) 2019-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://apache.ac.cn/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <cudf/column/column.hpp>
19 #include <cudf/scalar/scalar.hpp>
22 
23 namespace CUDF_EXPORT cudf {
24 namespace strings {
54 /**
55  * @brief Returns a column of character position values where the target string
56  * scalar is first found in the corresponding input string.
57  *
58  * Any null entries in the input or target columns will result in a null entry
59  * in the output column.
60  *
61  * @param input Strings column
62  * @param target String scalar to search for
63  * @param start The starting index of the substring to search within each string.
64  * @param stop The ending index of the substring to search within each string.
65  * @param stream CUDA stream used for device memory operations and kernel launches
66  * @param mr Device memory resource used to allocate the returned column's device memory
67  * @throw rmm::bad_alloc if device memory allocation fails
68  * @return New INT32 column of found positions, -1 if not found. Null entries in the input or target column result in corresponding null output entry.
69  */
70 std::unique_ptr<column> find(
71  strings_column_view const& input,
72  string_scalar const& target,
73  size_type start = 0,
74  size_type stop = -1,
77 
85 /**
86  * @brief Returns a column of character position values where the target string
87  * scalar is first found searching from the end of the corresponding input string.
88  *
89  * Any null entries in the input or target columns will result in a null entry
90  * in the output column.
91  *
92  * @param input Strings column
93  * @param target String scalar to search for
94  * @param start The starting index of the substring to search within each string.
95  * @param stop The ending index of the substring to search within each string.
96  * @param stream CUDA stream used for device memory operations and kernel launches
97  * @param mr Device memory resource used to allocate the returned column's device memory
98  * @throw rmm::bad_alloc if device memory allocation fails
99  * @return New INT32 column of found positions, -1 if not found. Null entries in the input or target column result in corresponding null output entry.
100  */
101 std::unique_ptr<column> rfind(
102  strings_column_view const& input,
103  string_scalar const& target,
104  size_type start = 0,
105  size_type stop = -1,
108 
113 /**
114  * @brief Returns a column of character position values where the corresponding target string
115  * is first found in the corresponding input string.
116  *
117  * Any null entries in the input or target columns will result in a null entry
118  * in the output column.
119  *
120  * @param input Strings column
121  * @param target Strings column to search for
122  * @param start The starting index of the substring to search within each string.
123  * @param stream CUDA stream used for device memory operations and kernel launches
124  * @param mr Device memory resource used to allocate the returned column's device memory
125  * @throw rmm::bad_alloc if device memory allocation fails
126  * @throw cudf::logic_error if number of elements in input and target columns do not match
127  * @return New INT32 column of found positions, -1 if not found. Null entries in the input or target column result in corresponding null output entry.
128  */
129 std::unique_ptr<column> find(
130  strings_column_view const& input,
131  strings_column_view const& target,
132  size_type start = 0,
136  * @brief Returns a column of boolean values for each string where true indicates
137  * the target string scalar is contained within the corresponding input string.
138  *
139  * Any null entries in the input or target columns will result in a null entry
140  * in the output column.
141  *
142  * @param input Strings column
143  * @param target String scalar to search for
144  * @param stream CUDA stream used for device memory operations and kernel launches
145  * @param mr Device memory resource used to allocate the returned column's device memory
146  * @throw rmm::bad_alloc if device memory allocation fails
147  * @return New BOOL8 column. Null entries in the input or target column result in corresponding null output entry.
148  */
149 std::unique_ptr<column> contains(
150  strings_column_view const& input,
154 
160 /**
150  strings_column_view const& input,
161  * @brief Returns a column of boolean values for each string where true indicates
162  * the corresponding target string is contained within the corresponding input string.
163  *
164  * Any null entries in the input or target columns will result in a null entry
165  * in the output column.
166  *
167  * @param input Strings column
168  * @param targets Strings column to search for
169  * @param stream CUDA stream used for device memory operations and kernel launches
170  * @param mr Device memory resource used to allocate the returned column's device memory
171  * @throw rmm::bad_alloc if device memory allocation fails