Skip to content

Commit

Permalink
Simplify null count checking in column equality comparator
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed May 9, 2023
1 parent 655cd93 commit e5265d8
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions cpp/tests/utilities/column_utilities.cu
Original file line number Diff line number Diff line change
Expand Up @@ -243,23 +243,6 @@ struct column_property_comparator {
return is_fixed_point(lhs) ? lhs.id() == rhs.id() : lhs == rhs;
}

size_type count_nulls(cudf::column_view const& c, cudf::column_view const& row_indices)
{
auto validity_iter = cudf::detail::make_counting_transform_iterator(
0,
[row_indices = row_indices.begin<size_type>(),
validity = c.null_mask(),
offset = c.offset()] __device__(int index) {
// both null mask and offsets data are not pre-sliced. so we need to add the column offset
// to every incoming index.
auto const true_index = row_indices[index] + offset;
return !validity || cudf::bit_is_set(validity, true_index) ? 0 : 1;
});
return thrust::reduce(rmm::exec_policy(cudf::get_default_stream()),
validity_iter,
validity_iter + row_indices.size());
}

bool compare_common(cudf::column_view const& lhs,
cudf::column_view const& rhs,
cudf::column_view const& lhs_row_indices,
Expand All @@ -280,12 +263,7 @@ struct column_property_comparator {

if (lhs_size > 0 && check_exact_equality) { PROP_EXPECT_EQ(lhs.nullable(), rhs.nullable()); }

// DISCUSSION: does this make sense, semantically?
auto const lhs_null_count =
check_exact_equality ? lhs.null_count() : count_nulls(lhs, lhs_row_indices);
auto const rhs_null_count =
check_exact_equality ? rhs.null_count() : count_nulls(rhs, rhs_row_indices);
PROP_EXPECT_EQ(lhs_null_count, rhs_null_count);
PROP_EXPECT_EQ(lhs.null_count(), rhs.null_count());

// equivalent, but not exactly equal columns can have a different number of children if their
// sizes are both 0. Specifically, empty string columns may or may not have children.
Expand Down

0 comments on commit e5265d8

Please sign in to comment.