libcudf  23.12.00
Files | Enumerations | Functions
Searching

Files

file  lists/contains.hpp
 

Enumerations

enum class  cudf::lists::duplicate_find_option : int32_t { cudf::lists::FIND_FIRST = 0 , cudf::lists::FIND_LAST }
 Option to choose whether index_of() returns the first or last match of a search key in a list row. More...
 

Functions

std::unique_ptr< columncudf::lists::contains (cudf::lists_column_view const &lists, cudf::scalar const &search_key, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Create a column of bool values indicating whether the specified scalar is an element of each row of a list column. More...
 
std::unique_ptr< columncudf::lists::contains (cudf::lists_column_view const &lists, cudf::column_view const &search_keys, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Create a column of bool values indicating whether the list rows of the first column contain the corresponding values in the second column. More...
 
std::unique_ptr< columncudf::lists::contains_nulls (cudf::lists_column_view const &lists, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Create a column of bool values indicating whether each row in the lists column contains at least one null element. More...
 
std::unique_ptr< columncudf::lists::index_of (cudf::lists_column_view const &lists, cudf::scalar const &search_key, duplicate_find_option find_option=duplicate_find_option::FIND_FIRST, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Create a column of values indicating the position of a search key within each list row in the lists column. More...
 
std::unique_ptr< columncudf::lists::index_of (cudf::lists_column_view const &lists, cudf::column_view const &search_keys, duplicate_find_option find_option=duplicate_find_option::FIND_FIRST, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Create a column of values indicating the position of a search key row within the corresponding list row in the lists column. More...
 

Detailed Description

Enumeration Type Documentation

◆ duplicate_find_option

enum cudf::lists::duplicate_find_option : int32_t
strong

Option to choose whether index_of() returns the first or last match of a search key in a list row.

Enumerator
FIND_FIRST 

Finds first instance of a search key in a list row.

FIND_LAST 

Finds last instance of a search key in a list row.

Definition at line 105 of file lists/contains.hpp.

Function Documentation

◆ contains() [1/2]

std::unique_ptr<column> cudf::lists::contains ( cudf::lists_column_view const &  lists,
cudf::column_view const &  search_keys,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Create a column of bool values indicating whether the list rows of the first column contain the corresponding values in the second column.

The output column has as many elements as the input lists column. Output column[i] is set to true if the lists row lists[i] contains the value in search_keys[i]. Otherwise, it is set to false.

Output column[i] is set to null if one or more of the following are true:

  1. The row search_keys[i] is null
  2. The list row lists[i] is null
Parameters
listsLists column whose n rows are to be searched
search_keysColumn of elements to be looked up in each list row.
streamCUDA stream used for device memory operations and kernel launches.
mrDevice memory resource used to allocate the returned column's device memory
Returns
BOOL8 column of n rows with the result of the lookup

◆ contains() [2/2]

std::unique_ptr<column> cudf::lists::contains ( cudf::lists_column_view const &  lists,
cudf::scalar const &  search_key,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Create a column of bool values indicating whether the specified scalar is an element of each row of a list column.

The output column has as many elements as the input lists column. Output column[i] is set to true if the lists row lists[i] contains the value specified in search_key. Otherwise, it is set to false.

Output column[i] is set to null if one or more of the following are true:

  1. The search key search_key is null
  2. The list row lists[i] is null
Parameters
listsLists column whose n rows are to be searched
search_keyThe scalar key to be looked up in each list row
streamCUDA stream used for device memory operations and kernel launches.
mrDevice memory resource used to allocate the returned column's device memory
Returns
BOOL8 column of n rows with the result of the lookup

◆ contains_nulls()

std::unique_ptr<column> cudf::lists::contains_nulls ( cudf::lists_column_view const &  lists,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Create a column of bool values indicating whether each row in the lists column contains at least one null element.

The output column has as many elements as the input lists column. Output column[i] is set to null if the row lists[i] is null. Otherwise, column[i] is set to a non-null boolean value, depending on whether that list contains a null element.

A row with an empty list will always return false. Nulls inside non-null nested elements (such as lists or structs) are not considered.

Parameters
listsLists column whose n rows are to be searched.
streamCUDA stream used for device memory operations and kernel launches.
mrDevice memory resource used to allocate the returned column's device memory
Returns
BOOL8 column of n rows with the result of the lookup

◆ index_of() [1/2]

Create a column of values indicating the position of a search key row within the corresponding list row in the lists column.

The output column has as many elements as there are rows in the input lists column. Output column[i] contains a 0-based index indicating the position of each search key row in its corresponding list row, counting from the beginning of the list. Note:

  1. If search_keys[i] is null, output[i] is also null.
  2. If the row lists[i] is null, output[i] is also null.
  3. If the row lists[i] does not contain search_key[i], output[i] is set to -1.
  4. In all other cases, output[i] is set to a non-negative size_type index.

If the find_option is set to FIND_FIRST, the position of the first match for search_key is returned. If find_option == FIND_LAST, the position of the last match in the list row is returned.

Exceptions
cudf::logic_errorIf search_keys does not match lists in its number of rows
cudf::data_type_errorIf search_keys type does not match the element type in lists
Parameters
listsLists column whose n rows are to be searched
search_keysA column of search keys to be looked up in each corresponding row of lists
find_optionWhether to return the position of the first match (FIND_FIRST) or last (FIND_LAST)
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
column of n rows with the location of the search_key

◆ index_of() [2/2]

Create a column of values indicating the position of a search key within each list row in the lists column.

The output column has as many elements as there are rows in the input lists column. Output column[i] contains a 0-based index indicating the position of the search key in each list, counting from the beginning of the list. Note:

  1. If the search_key is null, all output rows are set to null.
  2. If the row lists[i] is null, output[i] is also null.
  3. If the row lists[i] does not contain the search_key, output[i] is set to -1.
  4. In all other cases, output[i] is set to a non-negative size_type index.

If the find_option is set to FIND_FIRST, the position of the first match for search_key is returned. If find_option == FIND_LAST, the position of the last match in the list row is returned.

Exceptions
cudf::data_type_errorIf search_keys type does not match the element type in lists
Parameters
listsLists column whose n rows are to be searched
search_keyThe scalar key to be looked up in each list row
find_optionWhether to return the position of the first match (FIND_FIRST) or last (FIND_LAST)
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
column of n rows with the location of the search_key