diff --git a/cpp/include/cudf/detail/null_mask.hpp b/cpp/include/cudf/detail/null_mask.hpp index 6ee406de5ef..83ef78a8250 100644 --- a/cpp/include/cudf/detail/null_mask.hpp +++ b/cpp/include/cudf/detail/null_mask.hpp @@ -268,9 +268,9 @@ std::pair bitmask_or( * @param mask_size_bits The number of bits to be ANDed in each mask * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate the returned device_buffer - * @return rmm::device_buffer Output bitmask + * @return Count of set bits */ -void inplace_bitmask_and( +cudf::size_type inplace_bitmask_and( device_span dest_mask, host_span masks, host_span masks_begin_bits, diff --git a/cpp/src/bitmask/null_mask.cu b/cpp/src/bitmask/null_mask.cu index ec3776fb6d5..d1107ad3cfd 100644 --- a/cpp/src/bitmask/null_mask.cu +++ b/cpp/src/bitmask/null_mask.cu @@ -404,14 +404,14 @@ std::vector segmented_null_count(const bitmask_type* bitmask, } // Inplace Bitwise AND of the masks -void inplace_bitmask_and(device_span dest_mask, - host_span masks, - host_span begin_bits, - size_type mask_size, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +cudf::size_type inplace_bitmask_and(device_span dest_mask, + host_span masks, + host_span begin_bits, + size_type mask_size, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { - inplace_bitmask_binop( + return inplace_bitmask_binop( [] __device__(bitmask_type left, bitmask_type right) { return left & right; }, dest_mask, masks, diff --git a/cpp/src/structs/utilities.cpp b/cpp/src/structs/utilities.cpp index 43a32c8405a..afea8a55b16 100644 --- a/cpp/src/structs/utilities.cpp +++ b/cpp/src/structs/utilities.cpp @@ -322,14 +322,15 @@ void superimpose_parent_nulls(bitmask_type const* parent_null_mask, reinterpret_cast(parent_null_mask), reinterpret_cast(current_child_mask)}; std::vector begin_bits{0, 0}; - cudf::detail::inplace_bitmask_and( + auto const valid_count = cudf::detail::inplace_bitmask_and( device_span(current_child_mask, num_bitmask_words(child.size())), masks, begin_bits, child.size(), stream, mr); - child.set_null_count(UNKNOWN_NULL_COUNT); + auto const null_count = child.size() - valid_count; + child.set_null_count(null_count); } // If the child is also a struct, repeat for all grandchildren.