Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
Signed-off-by: Haoyang Li <[email protected]>
  • Loading branch information
thirtiseven committed Jul 2, 2024
1 parent 1f58e98 commit aa6c36b
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 69 deletions.
76 changes: 38 additions & 38 deletions cpp/include/cudf/aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,44 +83,44 @@ class aggregation {
* @brief Possible aggregation operations
*/
enum Kind {
SUM, ///< sum reduction
PRODUCT, ///< product reduction
MIN, ///< min reduction
MAX, ///< max reduction
COUNT_VALID, ///< count number of valid elements
COUNT_ALL, ///< count number of elements
ANY, ///< any reduction
ALL, ///< all reduction
SUM_OF_SQUARES, ///< sum of squares reduction
MEAN, ///< arithmetic mean reduction
M2, ///< sum of squares of differences from the mean
VARIANCE, ///< variance
STD, ///< standard deviation
MEDIAN, ///< median reduction
QUANTILE, ///< compute specified quantile(s)
ARGMAX, ///< Index of max element
ARGMIN, ///< Index of min element
NUNIQUE, ///< count number of unique elements
NTH_ELEMENT, ///< get the nth element
ROW_NUMBER, ///< get row-number of current index (relative to rolling window)
EWMA, ///< get exponential weighted moving average at current index
RANK, ///< get rank of current index
COLLECT_LIST, ///< collect values into a list
COLLECT_SET, ///< collect values into a list without duplicate entries
LEAD, ///< window function, accesses row at specified offset following current row
LAG, ///< window function, accesses row at specified offset preceding current row
PTX, ///< PTX UDF based reduction
CUDA, ///< CUDA UDF based reduction
MERGE_LISTS, ///< merge multiple lists values into one list
MERGE_SETS, ///< merge multiple lists values into one list then drop duplicate entries
MERGE_M2, ///< merge partial values of M2 aggregation,
COVARIANCE, ///< covariance between two sets of elements
CORRELATION, ///< correlation between two sets of elements
TDIGEST, ///< create a tdigest from a set of input values
MERGE_TDIGEST, ///< create a tdigest by merging multiple tdigests together
HISTOGRAM, ///< compute frequency of each element
MERGE_HISTOGRAM, ///< merge partial values of HISTOGRAM aggregation,
MIN_BY ///< min reduction by another column
SUM, ///< sum reduction
PRODUCT, ///< product reduction
MIN, ///< min reduction
MAX, ///< max reduction
COUNT_VALID, ///< count number of valid elements
COUNT_ALL, ///< count number of elements
ANY, ///< any reduction
ALL, ///< all reduction
SUM_OF_SQUARES, ///< sum of squares reduction
MEAN, ///< arithmetic mean reduction
M2, ///< sum of squares of differences from the mean
VARIANCE, ///< variance
STD, ///< standard deviation
MEDIAN, ///< median reduction
QUANTILE, ///< compute specified quantile(s)
ARGMAX, ///< Index of max element
ARGMIN, ///< Index of min element
NUNIQUE, ///< count number of unique elements
NTH_ELEMENT, ///< get the nth element
ROW_NUMBER, ///< get row-number of current index (relative to rolling window)
EWMA, ///< get exponential weighted moving average at current index
RANK, ///< get rank of current index
COLLECT_LIST, ///< collect values into a list
COLLECT_SET, ///< collect values into a list without duplicate entries
LEAD, ///< window function, accesses row at specified offset following current row
LAG, ///< window function, accesses row at specified offset preceding current row
PTX, ///< PTX UDF based reduction
CUDA, ///< CUDA UDF based reduction
MERGE_LISTS, ///< merge multiple lists values into one list
MERGE_SETS, ///< merge multiple lists values into one list then drop duplicate entries
MERGE_M2, ///< merge partial values of M2 aggregation,
COVARIANCE, ///< covariance between two sets of elements
CORRELATION, ///< correlation between two sets of elements
TDIGEST, ///< create a tdigest from a set of input values
MERGE_TDIGEST, ///< create a tdigest by merging multiple tdigests together
HISTOGRAM, ///< compute frequency of each element
MERGE_HISTOGRAM, ///< merge partial values of HISTOGRAM aggregation,
MIN_BY ///< min reduction by another column
};

aggregation() = delete;
Expand Down
3 changes: 1 addition & 2 deletions cpp/include/cudf/detail/aggregation/aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class simple_aggregations_collector { // Declares the interface for the simple
class product_aggregation const& agg);
virtual std::vector<std::unique_ptr<aggregation>> visit(data_type col_type,
class min_aggregation const& agg);
virtual std::vector<std::unique_ptr<aggregation>> visit(data_type col_type,
virtual std::vector<std::unique_ptr<aggregation>> visit(data_type col_type,
class min_by_aggregation const& agg);
virtual std::vector<std::unique_ptr<aggregation>> visit(data_type col_type,
class max_aggregation const& agg);
Expand Down Expand Up @@ -238,7 +238,6 @@ class min_by_aggregation final : public groupby_aggregation, public reduce_aggre
void finalize(aggregation_finalizer& finalizer) const override { finalizer.visit(*this); }
};


/**
* @brief Derived class for specifying a max aggregation
*/
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/aggregation/aggregation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ template std::unique_ptr<rolling_aggregation> make_argmin_aggregation<rolling_ag
template std::unique_ptr<groupby_aggregation> make_argmin_aggregation<groupby_aggregation>();

/// Factory to create a MIN_BY aggregation
template <typename Base>
template <typename Base>
std::unique_ptr<Base> make_min_by_aggregation()
{
return std::make_unique<detail::min_by_aggregation>();
Expand Down
12 changes: 5 additions & 7 deletions cpp/src/groupby/sort/aggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,11 @@ void aggregate_result_functor::operator()<aggregation::MIN_BY>(aggregation const
{
if (cache.has_result(values, agg)) return;

cache.add_result(values,
agg,
detail::group_min_by(get_grouped_values(),
helper.group_labels(stream),
helper.num_groups(stream),
stream,
mr));
cache.add_result(
values,
agg,
detail::group_min_by(
get_grouped_values(), helper.group_labels(stream), helper.num_groups(stream), stream, mr));
}

template <>
Expand Down
12 changes: 6 additions & 6 deletions cpp/src/groupby/sort/group_min_by.cu
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ std::unique_ptr<column> group_min_by(column_view const& structs_column,
rmm::device_async_resource_ref mr)
{
auto structs_view = cudf::structs_column_view{structs_column};
auto const orders = structs_view.get_sliced_child(1);
auto const orders = structs_view.get_sliced_child(1);

auto indices = type_dispatcher(orders.type(),
group_reduction_dispatcher<aggregation::ARGMIN>{},
Expand All @@ -47,11 +47,11 @@ std::unique_ptr<column> group_min_by(column_view const& structs_column,
auto indices_view = indices->mutable_view();

auto res = cudf::detail::gather(table_view{{structs_column}},
indices_view,
out_of_bounds_policy::NULLIFY,
cudf::detail::negative_index_policy::NOT_ALLOWED,
stream,
mr);
indices_view,
out_of_bounds_policy::NULLIFY,
cudf::detail::negative_index_policy::NOT_ALLOWED,
stream,
mr);

return std::move(res->release()[0]);
}
Expand Down
28 changes: 14 additions & 14 deletions cpp/tests/groupby/min_by_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ TYPED_TEST(groupby_min_by_test, basic)
if (std::is_same_v<V, bool>) return;

cudf::test::fixed_width_column_wrapper<K> keys{1, 2, 3, 1, 2, 2, 1, 3, 3, 2};
cudf::test::fixed_width_column_wrapper<K> values {4, 1, 2, 3, 4, 5, 6, 7, 8, 9};
cudf::test::fixed_width_column_wrapper<V> orders {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
cudf::test::structs_column_wrapper vals {values, orders};
cudf::test::fixed_width_column_wrapper<K> values{4, 1, 2, 3, 4, 5, 6, 7, 8, 9};
cudf::test::fixed_width_column_wrapper<V> orders{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
cudf::test::structs_column_wrapper vals{values, orders};

cudf::test::fixed_width_column_wrapper<K> expect_keys {1, 2, 3};
cudf::test::fixed_width_column_wrapper<K> expect_values {4, 1, 2};
cudf::test::fixed_width_column_wrapper<V> expect_orders {1, 2, 3};
cudf::test::structs_column_wrapper expect_vals {expect_values, expect_orders};
cudf::test::fixed_width_column_wrapper<K> expect_keys{1, 2, 3};
cudf::test::fixed_width_column_wrapper<K> expect_values{4, 1, 2};
cudf::test::fixed_width_column_wrapper<V> expect_orders{1, 2, 3};
cudf::test::structs_column_wrapper expect_vals{expect_values, expect_orders};

auto agg = cudf::make_min_by_aggregation<cudf::groupby_aggregation>();
test_single_agg(keys, vals, expect_keys, expect_vals, std::move(agg));
Expand All @@ -58,20 +58,20 @@ struct groupby_min_by_string_test : public cudf::test::BaseFixture {};

TEST_F(groupby_min_by_string_test, basic)
{
cudf::test::fixed_width_column_wrapper<K> keys {1, 2, 3, 1, 2, 2, 1, 3, 3, 2};
cudf::test::fixed_width_column_wrapper<K> values {4, 1, 2, 3, 4, 5, 6, 7, 8, 9};
cudf::test::fixed_width_column_wrapper<K> keys{1, 2, 3, 1, 2, 2, 1, 3, 3, 2};
cudf::test::fixed_width_column_wrapper<K> values{4, 1, 2, 3, 4, 5, 6, 7, 8, 9};
cudf::test::strings_column_wrapper orders{
"año", "bit", "₹1", "aaa", "zit", "bat", "aab", "$1", "€1", "wut"};
cudf::test::structs_column_wrapper vals {values, orders};
cudf::test::structs_column_wrapper vals{values, orders};

cudf::test::fixed_width_column_wrapper<K> expect_keys {1, 2, 3};
cudf::test::fixed_width_column_wrapper<K> expect_values {3, 5, 7};
cudf::test::fixed_width_column_wrapper<K> expect_keys{1, 2, 3};
cudf::test::fixed_width_column_wrapper<K> expect_values{3, 5, 7};
cudf::test::strings_column_wrapper expect_orders{"aaa", "bat", "$1"};
cudf::test::structs_column_wrapper expect_vals {expect_values, expect_orders};
cudf::test::structs_column_wrapper expect_vals{expect_values, expect_orders};

auto agg = cudf::make_min_by_aggregation<cudf::groupby_aggregation>();
test_single_agg(keys, vals, expect_keys, expect_vals, std::move(agg));

auto agg2 = cudf::make_min_by_aggregation<cudf::groupby_aggregation>();
test_single_agg(keys, vals, expect_keys, expect_vals, std::move(agg2), force_use_sort_impl::YES);
}
}
2 changes: 1 addition & 1 deletion java/src/main/java/ai/rapids/cudf/GroupByAggregation.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static GroupByAggregation min() {
public static GroupByAggregation minBy() {
return new GroupByAggregation(Aggregation.minBy());
}

/**
* Max Aggregation
*/
Expand Down

0 comments on commit aa6c36b

Please sign in to comment.