Skip to content

Commit

Permalink
Add back deprecated methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice committed Apr 12, 2024
1 parent 8a44004 commit fce091f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
44 changes: 33 additions & 11 deletions cpp/include/cudf/utilities/type_checks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,39 @@

namespace cudf {

/**
* @brief Compares the type of two `column_view`s
*
* @deprecated Since 24.06. Use cudf::have_same_types instead.
*
* This function returns true if the type of `lhs` equals that of `rhs`.
* - For fixed point types, the scale is compared.
* - For dictionary types, the type of the keys are compared if both are
* non-empty columns.
* - For lists types, the type of child columns are compared recursively.
* - For struct types, the type of each field are compared in order.
* - For all other types, the `id` of `data_type` is compared.
*
* @param lhs The first `column_view` to compare
* @param rhs The second `column_view` to compare
* @return true if column types match
*/
[[deprecated]] bool column_types_equal(column_view const& lhs, column_view const& rhs);

/**
* @brief Compare the type IDs of two `column_view`s
*
* @deprecated Since 24.06.
*
* This function returns true if the type of `lhs` equals that of `rhs`.
* - For fixed point types, the scale is ignored.
*
* @param lhs The first `column_view` to compare
* @param rhs The second `column_view` to compare
* @return true if column types match
*/
[[deprecated]] bool column_types_equivalent(column_view const& lhs, column_view const& rhs);

/**
* @brief Compares the type of two `column_view`s
*
Expand Down Expand Up @@ -88,17 +121,6 @@ bool have_same_types(scalar const& lhs, column_view const& rhs);
*/
bool have_same_types(scalar const& lhs, scalar const& rhs);

/**
* @brief Compare the type IDs of two `column_view`s
* This function returns true if the type of `lhs` equals that of `rhs`.
* - For fixed point types, the scale is ignored.
*
* @param lhs The first `column_view` to compare
* @param rhs The second `column_view` to compare
* @return true if column types match
*/
bool types_equivalent(column_view const& lhs, column_view const& rhs);

/**
* @brief Compare the types of a range of `column_view` or `scalar` objects
*
Expand Down
7 changes: 6 additions & 1 deletion cpp/src/utilities/type_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ bool have_same_types(column_view const& lhs, column_view const& rhs)
return type_dispatcher(lhs.type(), columns_equal_fn{}, lhs, rhs);
}

bool column_types_equal(column_view const& lhs, column_view const& rhs)
{
return have_same_types(lhs, rhs);
}

bool have_same_types(column_view const& lhs, scalar const& rhs)
{
return type_dispatcher(lhs.type(), column_scalar_equal_fn{}, lhs, rhs);
Expand All @@ -158,7 +163,7 @@ bool have_same_types(scalar const& lhs, scalar const& rhs)
return type_dispatcher(lhs.type(), scalars_equal_fn{}, lhs, rhs);
}

bool types_equivalent(column_view const& lhs, column_view const& rhs)
bool column_types_equivalent(column_view const& lhs, column_view const& rhs)
{
// Check if the columns have fixed point types. This is the only case where
// type equality and equivalence differ.
Expand Down
10 changes: 6 additions & 4 deletions cpp/tests/utilities/column_utilities.cu
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <cudf/table/experimental/row_operators.cuh>
#include <cudf/table/table_device_view.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/type_checks.hpp>
#include <cudf/utilities/type_dispatcher.hpp>

#include <rmm/exec_policy.hpp>
Expand Down Expand Up @@ -238,9 +239,10 @@ std::unique_ptr<column> generate_child_row_indices(lists_column_view const& c,

template <bool check_exact_equality>
struct column_property_comparator {
bool types_equivalent(cudf::data_type const& lhs, cudf::data_type const& rhs)
bool types_equivalent(cudf::column_view const& lhs, cudf::column_view const& rhs)
{
return is_fixed_point(lhs) ? lhs.id() == rhs.id() : lhs == rhs;
return cudf::is_fixed_point(lhs.type()) ? lhs.type().id() == rhs.type().id()
: cudf::have_same_types(lhs, rhs);
}

bool compare_common(cudf::column_view const& lhs,
Expand All @@ -252,9 +254,9 @@ struct column_property_comparator {
bool result = true;

if (check_exact_equality) {
PROP_EXPECT_EQ(lhs.type(), rhs.type());
PROP_EXPECT_EQ(cudf::have_same_types(lhs, rhs), true);
} else {
PROP_EXPECT_EQ(types_equivalent(lhs.type(), rhs.type()), true);
PROP_EXPECT_EQ(types_equivalent(lhs, rhs), true);
}

auto const lhs_size = check_exact_equality ? lhs.size() : lhs_row_indices.size();
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/utilities_tests/type_check_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ TEST_F(ColumnTypeCheckTest, DifferentFixedWidth)
cudf::test::fixed_point_column_wrapper<int32_t> rhs5({10000}, numeric::scale_type{0});

EXPECT_FALSE(cudf::have_same_types(lhs5, rhs5));
EXPECT_TRUE(cudf::types_equivalent(lhs5, rhs5));
EXPECT_TRUE(cudf::column_types_equivalent(lhs5, rhs5));

// Different rep, same scale
cudf::test::fixed_point_column_wrapper<int32_t> lhs6({10000}, numeric::scale_type{-1});
Expand Down

0 comments on commit fce091f

Please sign in to comment.