21 #include <cudf/utilities/export.hpp>
29 #include <unordered_map>
30 #include <unordered_set>
39 namespace CUDF_EXPORT
cudf {
112 SORTED_GROUPED_VALUES,
134 using value_type = std::variant<groupby_data_attribute, std::unique_ptr<aggregation>>;
145 template <
typename T, CUDF_ENABLE_IF(std::is_same_v<T, groupby_data_attribute>)>
154 template <
typename T,
156 std::is_same_v<T, groupby_aggregation>)>
159 CUDF_EXPECTS(std::get<std::unique_ptr<aggregation>>(value) !=
nullptr,
160 "Invalid aggregation request.");
161 if constexpr (std::is_same_v<T, aggregation>) {
164 "Requesting results from other aggregations is only supported in groupby "
205 std::unordered_set<data_attribute, data_attribute::hash, data_attribute::equal_to>;
223 using input_data_t = std::variant<column_view, size_type, device_span<size_type const>>;
229 unordered_map<data_attribute, input_data_t, data_attribute::hash, data_attribute::equal_to>;
237 using output_t = std::variant<std::unique_ptr<column>>;
270 [[nodiscard]]
virtual std::size_t
do_hash()
const
272 return std::hash<int>{}(
static_cast<int>(aggregation::Kind::HOST_UDF));
290 [[nodiscard]]
virtual std::unique_ptr<host_udf_base>
clone()
const = 0;
Representation for specifying desired aggregations from aggregation-based APIs, e....
Derived class intended for groupby specific aggregation usage.
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
#define CUDF_EXPECTS(...)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
#define CUDF_ENABLE_IF(...)
Convenience macro for SFINAE as an unnamed template parameter.
Equality comparison functor for data_attribute.
bool operator()(data_attribute const &lhs, data_attribute const &rhs) const
Check if two data attributes are equal.
Hash functor for data_attribute.
std::size_t operator()(data_attribute const &attr) const
Compute the hash value of a data attribute.
Describe possible data that may be needed in the derived class for its operations.
data_attribute(std::unique_ptr< T > value_)
Construct a new data attribute from another aggregation request.
data_attribute()=default
Default constructor.
data_attribute(T value_)
Construct a new data attribute from an aggregation attribute.
data_attribute(data_attribute &&)=default
Move constructor.
data_attribute(data_attribute const &other)
Copy constructor.
std::variant< groupby_data_attribute, std::unique_ptr< aggregation > > value_type
Hold all possible data types for the input of the aggregation in the derived class.
The interface for host-based UDF implementation.
virtual output_t operator()(input_map_t const &input, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const =0
Perform the main computation for the host-based UDF.
std::unordered_set< data_attribute, data_attribute::hash, data_attribute::equal_to > data_attribute_set_t
Set of attributes for the input data that is needed for computing the aggregation.
std::variant< column_view, size_type, device_span< size_type const > > input_data_t
Hold all possible types of the data that is passed to the derived class for executing the aggregation...
virtual bool is_equal(host_udf_base const &other) const =0
Compares two instances of the derived class for equality.
std::unordered_map< data_attribute, input_data_t, data_attribute::hash, data_attribute::equal_to > input_map_t
Input to the aggregation, mapping from each data attribute to its actual data.
virtual data_attribute_set_t get_required_data() const
Return a set of attributes for the data that is needed for computing the aggregation.
std::variant< std::unique_ptr< column > > output_t
Output type of the aggregation.
virtual output_t get_empty_output(std::optional< data_type > output_dtype, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const =0
Get the output when the input values column is empty.
groupby_data_attribute
Define the possible data needed for groupby aggregations.
virtual std::unique_ptr< host_udf_base > clone() const =0
Clones the instance.
virtual std::size_t do_hash() const
Computes hash value of the class's instance.
Type declarations for libcudf.