20 #include <cudf/detail/utilities/assert.cuh>
21 #include <cudf/hashing/detail/hash_functions.cuh>
22 #include <cudf/hashing/detail/hashing.hpp>
23 #include <cudf/table/experimental/row_operators.cuh>
24 #include <cudf/table/row_operators.cuh>
29 #include <cuda/std/limits>
30 #include <cuda/std/type_traits>
32 namespace CUDF_EXPORT
cudf {
45 namespace row::primitive {
51 using primitive_type_t = cuda::std::conditional_t<cudf::is_numeric<T>(), T,
void>;
56 template <cudf::type_
id Id>
58 using type = primitive_type_t<id_to_type<Id>>;
75 template <typename Element, CUDF_ENABLE_IF(cudf::is_equality_comparable<Element, Element>())>
82 rhs.element<Element>(rhs_element_index));
86 template <typename Element, CUDF_ENABLE_IF(not cudf::is_equality_comparable<Element, Element>())>
92 CUDF_UNREACHABLE(
"Attempted to compare elements of uncomparable types.");
112 std::shared_ptr<cudf::experimental::row::equality::preprocessed_table> lhs,
113 std::shared_ptr<cudf::experimental::row::equality::preprocessed_table> rhs,
115 : _has_nulls{
has_nulls}, _lhs{*lhs}, _rhs{*rhs}, _nulls_are_equal{nulls_are_equal}
117 CUDF_EXPECTS(_lhs.num_columns() == _rhs.num_columns(),
"Mismatched number of columns.");
130 bool const lhs_is_null{_lhs.column(0).is_null(lhs_row_index)};
131 bool const rhs_is_null{_rhs.column(0).is_null(rhs_row_index)};
132 if (lhs_is_null and rhs_is_null) {
133 return _nulls_are_equal == null_equality::EQUAL;
134 }
else if (lhs_is_null != rhs_is_null) {
138 return cudf::type_dispatcher<dispatch_primitive_type>(_lhs.begin()->type(),
158 template <
template <
typename>
class Hash>
170 template <typename T, CUDF_ENABLE_IF(column_device_view::has_element_accessor<T>())>
175 return Hash<T>{seed}(col.element<T>(row_index));
179 template <typename T, CUDF_ENABLE_IF(not column_device_view::has_element_accessor<T>())>
182 CUDF_UNREACHABLE(
"Unsupported type in hash.");
192 template <
template <
typename>
class Hash = cudf::hashing::detail::default_hash>
207 : _has_nulls{
has_nulls}, _table{t}, _seed{seed}
219 std::shared_ptr<cudf::experimental::row::equality::preprocessed_table> t,
221 : _has_nulls{
has_nulls}, _table{*t}, _seed{seed}
233 if (_has_nulls && _table.column(0).is_null(row_index)) {
234 return cuda::std::numeric_limits<hash_value_type>::max();
236 return cudf::type_dispatcher<dispatch_primitive_type>(
An immutable, non-owning view of device data as a column of elements that is trivially copyable and u...
T element(size_type element_index) const noexcept
Returns a copy of the element at the specified index.
Performs an equality comparison between two elements in two columns.
Function object for computing the hash value of a row in a column.
Performs a relational comparison between two elements in two tables.
row_equality_comparator(cudf::nullate::DYNAMIC const &has_nulls, std::shared_ptr< cudf::experimental::row::equality::preprocessed_table > lhs, std::shared_ptr< cudf::experimental::row::equality::preprocessed_table > rhs, null_equality nulls_are_equal)
Construct a new row equality comparator object.
bool operator()(size_type lhs_row_index, size_type rhs_row_index) const
Compares the specified rows for equality.
Computes the hash value of a row in the given table.
auto operator()(size_type row_index) const
Computes the hash value of the row at row_index in the table
row_hasher(cudf::nullate::DYNAMIC const &has_nulls, table_device_view t, hash_value_type seed=DEFAULT_HASH_SEED)
Constructs a row_hasher object with a seed value.
row_hasher(cudf::nullate::DYNAMIC const &has_nulls, std::shared_ptr< cudf::experimental::row::equality::preprocessed_table > t, hash_value_type seed=DEFAULT_HASH_SEED)
Constructs a row_hasher object with a seed value.
Table device view that is usable in device memory.
A set of cudf::column_view's of the same size.
A set of cudf::column's of the same size.
Column device view class definitions.
uint32_t hash_value_type
Type of hash value.
#define CUDF_EXPECTS(...)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
null_equality
Enum to consider two nulls as equal or unequal.
int32_t size_type
Row index type for columns and tables.
bool is_primitive_row_op_compatible(cudf::table_view const &table)
Checks if a table is compatible with primitive row operations.
bool has_nulls(table_view const &view)
Returns True if the table has nulls in any of its columns.
bool equality_compare(Element lhs, Element rhs) requires(std
A specialization for floating-point Element type to check if lhs is equivalent to rhs....
nullate::DYNAMIC defers the determination of nullability to run time rather than compile time....
Custom dispatcher for primitive types.
primitive_type_t< id_to_type< Id > > type
The underlying type.
Table device view class definitions.
Defines the mapping between cudf::type_id runtime type information and concrete C++ types.