From 783a8be19cc3980446bd5366f4df1b80d3ce1f28 Mon Sep 17 00:00:00 2001 From: Mithun RK Date: Thu, 16 Sep 2021 20:53:31 -0700 Subject: [PATCH] Move equality_comparable checks inline. --- cpp/CMakeLists.txt | 1 - cpp/src/groupby/common/utils.cpp | 31 ----------------------------- cpp/src/groupby/groupby.cu | 6 ++++-- cpp/src/groupby/sort/sort_helper.cu | 7 +++++-- 4 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 cpp/src/groupby/common/utils.cpp diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 8992e13c483..de6530084ad 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -213,7 +213,6 @@ add_library(cudf src/filling/repeat.cu src/filling/sequence.cu src/groupby/groupby.cu - src/groupby/common/utils.cpp src/groupby/hash/groupby.cu src/groupby/sort/aggregate.cpp src/groupby/sort/group_argmax.cu diff --git a/cpp/src/groupby/common/utils.cpp b/cpp/src/groupby/common/utils.cpp deleted file mode 100644 index bfc2d66e694..00000000000 --- a/cpp/src/groupby/common/utils.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include -#include - -namespace cudf::groupby::detail { - -void assert_keys_equality_comparable(cudf::table_view const& keys) -{ - auto is_supported_key_type = [](auto col) { return cudf::is_equality_comparable(col.type()); }; - CUDF_EXPECTS(std::all_of(keys.begin(), keys.end(), is_supported_key_type), - "Unsupported groupby key type does not support equality comparison"); -} - -} // namespace cudf::groupby::detail diff --git a/cpp/src/groupby/groupby.cu b/cpp/src/groupby/groupby.cu index e620c06384e..bdaccba38dc 100644 --- a/cpp/src/groupby/groupby.cu +++ b/cpp/src/groupby/groupby.cu @@ -27,12 +27,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include @@ -78,7 +78,9 @@ std::pair, std::vector> groupby::disp // Optionally flatten nested key columns. auto [flattened_keys, _, __, ___] = flatten_nested_columns(_keys, {}, {}, column_nullability::FORCE); - cudf::groupby::detail::assert_keys_equality_comparable(flattened_keys); + auto is_supported_key_type = [](auto col) { return cudf::is_equality_comparable(col.type()); }; + CUDF_EXPECTS(std::all_of(flattened_keys.begin(), flattened_keys.end(), is_supported_key_type), + "Unsupported groupby key type does not support equality comparison"); auto [grouped_keys, results] = detail::hash::groupby(flattened_keys, requests, _include_null_keys, stream, mr); return std::make_pair(unflatten_nested_columns(std::move(grouped_keys), _keys), diff --git a/cpp/src/groupby/sort/sort_helper.cu b/cpp/src/groupby/sort/sort_helper.cu index 706fa847325..c4905b86ab9 100644 --- a/cpp/src/groupby/sort/sort_helper.cu +++ b/cpp/src/groupby/sort/sort_helper.cu @@ -23,9 +23,10 @@ #include #include #include +#include #include #include -#include +#include #include #include @@ -103,7 +104,9 @@ sort_groupby_helper::sort_groupby_helper(table_view const& keys, auto [flattened_keys, _, __, struct_null_vectors] = flatten_nested_columns(keys, {}, {}, column_nullability::FORCE); - cudf::groupby::detail::assert_keys_equality_comparable(flattened_keys); + auto is_supported_key_type = [](auto col) { return cudf::is_equality_comparable(col.type()); }; + CUDF_EXPECTS(std::all_of(flattened_keys.begin(), flattened_keys.end(), is_supported_key_type), + "Unsupported groupby key type does not support equality comparison"); _struct_null_vectors = std::move(struct_null_vectors); _keys = flattened_keys;