From 8f7cbe69d4c2f670b97decc63e73b08e0eef7329 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Tue, 5 Dec 2023 07:06:18 -0500 Subject: [PATCH] Move non-templated inline function definitions from table_view.hpp to table_view.cpp (#14535) Moves some `inline` functions from the `table_view.hpp` to the `table_view.cpp` to help reduce dependency bloat. Also reference #14531: I'd like to minimize changes to the highly inclusive `table_view.hpp`. Closes #14431 Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Karthikeyan (https://github.com/karthikeyann) - Mike Wilson (https://github.com/hyperbolic2346) URL: https://github.com/rapidsai/cudf/pull/14535 --- cpp/include/cudf/table/table_view.hpp | 40 +++--------------------- cpp/src/table/table_view.cpp | 44 ++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/cpp/include/cudf/table/table_view.hpp b/cpp/include/cudf/table/table_view.hpp index 5d9c930d137..4f3b23747e6 100644 --- a/cpp/include/cudf/table/table_view.hpp +++ b/cpp/include/cudf/table/table_view.hpp @@ -302,10 +302,7 @@ class mutable_table_view : public detail::table_view_base { * @param view The table to check for nullability * @return True if any of the columns in the table is nullable, false otherwise */ -inline bool nullable(table_view const& view) -{ - return std::any_of(view.begin(), view.end(), [](auto const& col) { return col.nullable(); }); -} +bool nullable(table_view const& view); /** * @brief Returns True if the table has nulls in any of its columns. @@ -315,10 +312,7 @@ inline bool nullable(table_view const& view) * @param view The table to check for nulls * @return True if the table has nulls in any of its columns, false otherwise */ -inline bool has_nulls(table_view const& view) -{ - return std::any_of(view.begin(), view.end(), [](auto const& col) { return col.has_nulls(); }); -} +bool has_nulls(table_view const& view); /** * @brief Returns True if the table has nulls in any of its columns hierarchy @@ -326,15 +320,7 @@ inline bool has_nulls(table_view const& view) * @param input The table to check for nulls * @return True if the table has nulls in any of its columns hierarchy, false otherwise */ -inline bool has_nested_nulls(table_view const& input) -{ - return std::any_of(input.begin(), input.end(), [](auto const& col) { - return col.has_nulls() || - std::any_of(col.child_begin(), col.child_end(), [](auto const& child_col) { - return has_nested_nulls(table_view{{child_col}}); - }); - }); -} +bool has_nested_nulls(table_view const& input); /** * @brief Returns True if the table has a nullable column at any level of the column hierarchy @@ -343,15 +329,7 @@ inline bool has_nested_nulls(table_view const& input) * @return True if the table has nullable columns at any level of the column hierarchy, false * otherwise */ -inline bool has_nested_nullable_columns(table_view const& input) -{ - return std::any_of(input.begin(), input.end(), [](auto const& col) { - return col.nullable() || - std::any_of(col.child_begin(), col.child_end(), [](auto const& child_col) { - return has_nested_nullable_columns(table_view{{child_col}}); - }); - }); -} +bool has_nested_nullable_columns(table_view const& input); /** * @brief The function to collect all nullable columns at all nested levels in a given table. @@ -368,15 +346,7 @@ std::vector get_nullable_columns(table_view const& table); * @param rhs right-side table_view operand * @return boolean comparison result */ -inline bool have_same_types(table_view const& lhs, table_view const& rhs) -{ - return std::equal( - lhs.begin(), - lhs.end(), - rhs.begin(), - rhs.end(), - [](column_view const& lcol, column_view const& rcol) { return (lcol.type() == rcol.type()); }); -} +bool have_same_types(table_view const& lhs, table_view const& rhs); /** * @brief Copy column_views from a table_view into another table_view according to diff --git a/cpp/src/table/table_view.cpp b/cpp/src/table/table_view.cpp index 0d1cabfd4f6..bcbf2d44139 100644 --- a/cpp/src/table/table_view.cpp +++ b/cpp/src/table/table_view.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -114,6 +115,47 @@ std::vector get_nullable_columns(table_view const& table) return result; } +bool nullable(table_view const& view) +{ + return std::any_of(view.begin(), view.end(), [](auto const& col) { return col.nullable(); }); +} + +bool has_nulls(table_view const& view) +{ + return std::any_of(view.begin(), view.end(), [](auto const& col) { return col.has_nulls(); }); +} + +bool has_nested_nulls(table_view const& input) +{ + return std::any_of(input.begin(), input.end(), [](auto const& col) { + return col.has_nulls() || + std::any_of(col.child_begin(), col.child_end(), [](auto const& child_col) { + return has_nested_nulls(table_view{{child_col}}); + }); + }); +} + +bool has_nested_nullable_columns(table_view const& input) +{ + return std::any_of(input.begin(), input.end(), [](auto const& col) { + return col.nullable() || + std::any_of(col.child_begin(), col.child_end(), [](auto const& child_col) { + return has_nested_nullable_columns(table_view{{child_col}}); + }); + }); +} + +bool have_same_types(table_view const& lhs, table_view const& rhs) +{ + return std::equal(lhs.begin(), + lhs.end(), + rhs.begin(), + rhs.end(), + [](column_view const& lcol, column_view const& rcol) { + return cudf::column_types_equal(lcol, rcol); + }); +} + namespace detail { template