Skip to content

Commit

Permalink
Move non-templated inline function definitions from table_view.hpp to…
Browse files Browse the repository at this point in the history
… 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: #14535
  • Loading branch information
davidwendt authored Dec 5, 2023
1 parent 434df44 commit 8f7cbe6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 36 deletions.
40 changes: 5 additions & 35 deletions cpp/include/cudf/table/table_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,7 @@ class mutable_table_view : public detail::table_view_base<mutable_column_view> {
* @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.
Expand All @@ -315,26 +312,15 @@ 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
*
* @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
Expand All @@ -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.
Expand All @@ -368,15 +346,7 @@ std::vector<column_view> 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
Expand Down
44 changes: 43 additions & 1 deletion cpp/src/table/table_view.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -18,6 +18,7 @@
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/type_checks.hpp>

#include <thrust/iterator/counting_iterator.h>

Expand Down Expand Up @@ -114,6 +115,47 @@ std::vector<column_view> 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 <typename TableView>
Expand Down

0 comments on commit 8f7cbe6

Please sign in to comment.