diff --git a/cpp/include/cudf/table/experimental/row_operators.cuh b/cpp/include/cudf/table/experimental/row_operators.cuh index e9b81a525fc..c181ac7d402 100644 --- a/cpp/include/cudf/table/experimental/row_operators.cuh +++ b/cpp/include/cudf/table/experimental/row_operators.cuh @@ -252,7 +252,7 @@ using optional_dremel_view = thrust::optional; * * @tparam has_nested_columns compile-time optimization for primitive types. * This template parameter is to be used by the developer by querying - * `cudf::detail::has_nested_columns(input)`. `true` compiles operator + * `cudf::has_nested_columns(input)`. `true` compiles operator * overloads for nested types, while `false` only compiles operator * overloads for primitive types. * @tparam Nullate A cudf::nullate type describing whether to check for nulls. @@ -1014,7 +1014,7 @@ class self_comparator { * * @tparam has_nested_columns compile-time optimization for primitive types. * This template parameter is to be used by the developer by querying - * `cudf::detail::has_nested_columns(input)`. `true` compiles operator + * `cudf::has_nested_columns(input)`. `true` compiles operator * overloads for nested types, while `false` only compiles operator * overloads for primitive types. * @tparam Nullate A cudf::nullate type describing whether to check for nulls. @@ -1186,7 +1186,7 @@ class two_table_comparator { * * @tparam has_nested_columns compile-time optimization for primitive types. * This template parameter is to be used by the developer by querying - * `cudf::detail::has_nested_columns(input)`. `true` compiles operator + * `cudf::has_nested_columns(input)`. `true` compiles operator * overloads for nested types, while `false` only compiles operator * overloads for primitive types. * @tparam Nullate A cudf::nullate type describing whether to check for nulls. @@ -1326,7 +1326,7 @@ struct nan_equal_physical_equality_comparator { * * @tparam has_nested_columns compile-time optimization for primitive types. * This template parameter is to be used by the developer by querying - * `cudf::detail::has_nested_columns(input)`. `true` compiles operator + * `cudf::has_nested_columns(input)`. `true` compiles operator * overloads for nested types, while `false` only compiles operator * overloads for primitive types. * @tparam Nullate A cudf::nullate type describing whether to check for nulls. @@ -1643,7 +1643,7 @@ class self_comparator { * * @tparam has_nested_columns compile-time optimization for primitive types. * This template parameter is to be used by the developer by querying - * `cudf::detail::has_nested_columns(input)`. `true` compiles operator + * `cudf::has_nested_columns(input)`. `true` compiles operator * overloads for nested types, while `false` only compiles operator * overloads for primitive types. * @tparam Nullate A cudf::nullate type describing whether to check for nulls. @@ -1757,7 +1757,7 @@ class two_table_comparator { * * @tparam has_nested_columns compile-time optimization for primitive types. * This template parameter is to be used by the developer by querying - * `cudf::detail::has_nested_columns(input)`. `true` compiles operator + * `cudf::has_nested_columns(input)`. `true` compiles operator * overloads for nested types, while `false` only compiles operator * overloads for primitive types. * @tparam Nullate A cudf::nullate type describing whether to check for nulls. diff --git a/cpp/include/cudf/table/table_view.hpp b/cpp/include/cudf/table/table_view.hpp index a71e0558dec..4a990f67ce4 100644 --- a/cpp/include/cudf/table/table_view.hpp +++ b/cpp/include/cudf/table/table_view.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -32,7 +33,7 @@ * passed by value. */ -namespace cudf { +namespace CUDF_EXPORT cudf { namespace detail { /** * @brief Base class for a table of `ColumnView`s @@ -123,7 +124,10 @@ class table_view_base { * @param column_index The index of the desired column * @return A reference to the desired column */ - [[nodiscard]] ColumnView const& column(size_type column_index) const; + [[nodiscard]] ColumnView const& column(size_type column_index) const + { + return _columns.at(column_index); + } /** * @brief Returns the number of columns @@ -174,8 +178,17 @@ class table_view_base { * @return Whether nested columns exist in the input table */ bool has_nested_columns(table_view const& table); + } // namespace detail +/** + * @brief Determine if any nested columns exist in a given table. + * + * @param table The input table + * @return Whether nested columns exist in the input table + */ +bool has_nested_columns(table_view const& table); + /** * @brief A set of cudf::column_view's of the same size. * @@ -374,4 +387,4 @@ extern template bool is_relationally_comparable(mutable_tabl mutable_table_view const& rhs); // @endcond } // namespace detail -} // namespace cudf +} // namespace CUDF_EXPORT cudf diff --git a/cpp/src/table/table_view.cpp b/cpp/src/table/table_view.cpp index 13832b0d9dc..8a5340dc20d 100644 --- a/cpp/src/table/table_view.cpp +++ b/cpp/src/table/table_view.cpp @@ -52,12 +52,6 @@ auto concatenate_column_views(std::vector const& views) return concat_cols; } -template -ColumnView const& table_view_base::column(size_type column_index) const -{ - return _columns.at(column_index); -} - // Explicit instantiation for a table of `column_view`s template class table_view_base; @@ -172,6 +166,7 @@ bool has_nested_columns(table_view const& table) return std::any_of( table.begin(), table.end(), [](column_view const& col) { return is_nested(col.type()); }); } - } // namespace detail + +bool has_nested_columns(table_view const& table) { return detail::has_nested_columns(table); } } // namespace cudf diff --git a/cpp/tests/table/experimental_row_operator_tests.cu b/cpp/tests/table/experimental_row_operator_tests.cu index 896cc7a82d4..0d9e4e27f2c 100644 --- a/cpp/tests/table/experimental_row_operator_tests.cu +++ b/cpp/tests/table/experimental_row_operator_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023, NVIDIA CORPORATION. + * Copyright (c) 2022-2024, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,15 +109,14 @@ TYPED_TEST(TypedTableViewTest, TestSortSameTableFromTwoTables) auto const lhs = cudf::table_view{{col1}}; auto const empty_rhs = cudf::table_view{{col2}}; - auto const stream = cudf::get_default_stream(); - auto const test_sort = [stream](auto const& preprocessed, - auto const& input, - auto const& comparator, - auto const& expected) { - auto const order = sorted_order( - preprocessed, input.num_rows(), cudf::detail::has_nested_columns(input), comparator, stream); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, order->view()); - }; + auto const stream = cudf::get_default_stream(); + auto const test_sort = + [stream]( + auto const& preprocessed, auto const& input, auto const& comparator, auto const& expected) { + auto const order = sorted_order( + preprocessed, input.num_rows(), cudf::has_nested_columns(input), comparator, stream); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, order->view()); + }; auto const test_sort_two_tables = [&](auto const& preprocessed_lhs, auto const& preprocessed_empty_rhs) { @@ -188,15 +187,14 @@ TYPED_TEST(TypedTableViewTest, TestSortSameTableFromTwoTablesWithListsOfStructs) auto const lhs = cudf::table_view{{*col1}}; auto const empty_rhs = cudf::table_view{{*col2}}; - auto const stream = cudf::get_default_stream(); - auto const test_sort = [stream](auto const& preprocessed, - auto const& input, - auto const& comparator, - auto const& expected) { - auto const order = sorted_order( - preprocessed, input.num_rows(), cudf::detail::has_nested_columns(input), comparator, stream); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, order->view()); - }; + auto const stream = cudf::get_default_stream(); + auto const test_sort = + [stream]( + auto const& preprocessed, auto const& input, auto const& comparator, auto const& expected) { + auto const order = sorted_order( + preprocessed, input.num_rows(), cudf::has_nested_columns(input), comparator, stream); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, order->view()); + }; auto const test_sort_two_tables = [&](auto const& preprocessed_lhs, auto const& preprocessed_empty_rhs) { diff --git a/cpp/tests/table/row_operator_tests_utilities.cu b/cpp/tests/table/row_operator_tests_utilities.cu index cfffa1cdd54..6127864987d 100644 --- a/cpp/tests/table/row_operator_tests_utilities.cu +++ b/cpp/tests/table/row_operator_tests_utilities.cu @@ -42,7 +42,7 @@ std::unique_ptr two_table_comparison(cudf::table_view lhs, auto output = cudf::make_numeric_column( cudf::data_type(cudf::type_id::BOOL8), lhs.num_rows(), cudf::mask_state::UNALLOCATED); - if (cudf::detail::has_nested_columns(lhs) || cudf::detail::has_nested_columns(rhs)) { + if (cudf::has_nested_columns(lhs) || cudf::has_nested_columns(rhs)) { thrust::transform(rmm::exec_policy(stream), lhs_it, lhs_it + lhs.num_rows(), @@ -129,7 +129,7 @@ std::unique_ptr two_table_equality(cudf::table_view lhs, auto output = cudf::make_numeric_column( cudf::data_type(cudf::type_id::BOOL8), lhs.num_rows(), cudf::mask_state::UNALLOCATED); - if (cudf::detail::has_nested_columns(lhs) or cudf::detail::has_nested_columns(rhs)) { + if (cudf::has_nested_columns(lhs) or cudf::has_nested_columns(rhs)) { auto const equal_comparator = table_comparator.equal_to(cudf::nullate::NO{}, cudf::null_equality::EQUAL, comparator); diff --git a/cpp/tests/table/row_operator_tests_utilities2.cu b/cpp/tests/table/row_operator_tests_utilities2.cu index 057d9ee1004..17d274eba13 100644 --- a/cpp/tests/table/row_operator_tests_utilities2.cu +++ b/cpp/tests/table/row_operator_tests_utilities2.cu @@ -41,7 +41,7 @@ std::unique_ptr self_comparison(cudf::table_view input, auto output = cudf::make_numeric_column( cudf::data_type(cudf::type_id::BOOL8), input.num_rows(), cudf::mask_state::UNALLOCATED); - if (cudf::detail::has_nested_columns(input)) { + if (cudf::has_nested_columns(input)) { thrust::transform(rmm::exec_policy(stream), thrust::make_counting_iterator(0), thrust::make_counting_iterator(input.num_rows()),