Files | Functions

Files

file  search.hpp
 Column APIs for lower_bound, upper_bound, and contains.
 

Functions

std::unique_ptr< columncudf::lower_bound (table_view const &t, table_view const &values, std::vector< order > const &column_order, std::vector< null_order > const &null_precedence, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Find smallest indices in a sorted table where values should be inserted to maintain order. More...
 
std::unique_ptr< columncudf::upper_bound (table_view const &t, table_view const &values, std::vector< order > const &column_order, std::vector< null_order > const &null_precedence, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Find largest indices in a sorted table where values should be inserted to maintain order. More...
 
bool cudf::contains (column_view const &col, scalar const &value)
 Find if the value is present in the col More...
 
std::unique_ptr< columncudf::contains (column_view const &haystack, column_view const &needles, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Returns a new column of type bool identifying for each element of haystack column, if that element is contained in needles column. More...
 

Detailed Description

Function Documentation

◆ contains() [1/2]

bool cudf::contains ( column_view const &  col,
scalar const &  value 
)

Find if the value is present in the col

Exceptions
cudf::logic_errorIf col.type() != values.type()
Single Column:
idx 0 1 2 3 4
col = { 10, 20, 20, 30, 50 }
Scalar:
value = { 20 }
result = true
Parameters
colA column object
valueA scalar value to search for in col
Returns
bool If value is found in column true, else false.

◆ contains() [2/2]

std::unique_ptr<column> cudf::contains ( column_view const &  haystack,
column_view const &  needles,
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Returns a new column of type bool identifying for each element of haystack column, if that element is contained in needles column.

The new column will have the same dimension and null status as the haystack column. That is, any element that is invalid in the haystack column will be invalid in the returned column.

Exceptions
cudf::logic_errorIf haystack.type() != needles.type()
haystack = { 10, 20, 30, 40, 50 }
needles = { 20, 40, 60, 80 }
result = { false, true, false, true, false }
Parameters
haystackA column object
needlesA column of values to search for in col
mrDevice memory resource used to allocate the returned column's device memory
Returns
A column of bool elements containing true if the corresponding entry in haystack appears in needles and false if it does not.

◆ lower_bound()

std::unique_ptr<column> cudf::lower_bound ( table_view const &  t,
table_view const &  values,
std::vector< order > const &  column_order,
std::vector< null_order > const &  null_precedence,
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Find smallest indices in a sorted table where values should be inserted to maintain order.

For each row v in values, find the first index in t where inserting the row will maintain the sort order of t

Example:
Single column:
idx 0 1 2 3 4
column = { 10, 20, 20, 30, 50 }
values = { 20 }
result = { 1 }
Multi Column:
idx 0 1 2 3 4
t = {{ 10, 20, 20, 20, 20 },
{ 5.0, .5, .5, .7, .7 },
{ 90, 77, 78, 61, 61 }}
values = {{ 20 },
{ .7 },
{ 61 }}
result = { 3 }
Parameters
tTable to search
valuesFind insert locations for these values
column_orderVector of column sort order
null_precedenceVector of null_precedence enums values
mrDevice memory resource used to allocate the returned column's device memory
Returns
A non-nullable column of cudf::size_type elements containing the insertion points.

◆ upper_bound()

std::unique_ptr<column> cudf::upper_bound ( table_view const &  t,
table_view const &  values,
std::vector< order > const &  column_order,
std::vector< null_order > const &  null_precedence,
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Find largest indices in a sorted table where values should be inserted to maintain order.

For each row v in values, find the last index in t where inserting the row will maintain the sort order of t

Example:
Single Column:
idx 0 1 2 3 4
column = { 10, 20, 20, 30, 50 }
values = { 20 }
result = { 3 }
Multi Column:
idx 0 1 2 3 4
t = {{ 10, 20, 20, 20, 20 },
{ 5.0, .5, .5, .7, .7 },
{ 90, 77, 78, 61, 61 }}
values = {{ 20 },
{ .7 },
{ 61 }}
result = { 5 }
Parameters
columnTable to search
valuesFind insert locations for these values
column_orderVector of column sort order
null_precedenceVector of null_precedence enums values
mrDevice memory resource used to allocate the returned column's device memory
Returns
A non-nullable column of cudf::size_type elements containing the insertion points.