Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move non-templated inline function definitions from table_view.hpp to table_view.cpp #14535

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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