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

Explicitly compute null count in concatenate APIs #13104

Merged
merged 6 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 7 additions & 1 deletion cpp/src/lists/copying/concatenate.cu
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <thrust/transform.h>

#include <memory>
#include <numeric>

namespace cudf {
namespace lists {
Expand Down Expand Up @@ -123,15 +124,20 @@ std::unique_ptr<column> concatenate(host_span<column_view const> columns,
std::any_of(columns.begin(), columns.end(), [](auto const& col) { return col.has_nulls(); });
rmm::device_buffer null_mask = create_null_mask(
total_list_count, has_nulls ? mask_state::UNINITIALIZED : mask_state::UNALLOCATED);
cudf::size_type null_count{0};
if (has_nulls) {
cudf::detail::concatenate_masks(columns, static_cast<bitmask_type*>(null_mask.data()), stream);
null_count =
std::transform_reduce(columns.begin(), columns.end(), 0, std::plus{}, [](auto const& col) {
return col.null_count();
});
}

// assemble into outgoing list column
return make_lists_column(total_list_count,
std::move(offsets),
std::move(data),
has_nulls ? UNKNOWN_NULL_COUNT : 0,
null_count,
std::move(null_mask),
stream,
mr);
Expand Down
17 changes: 10 additions & 7 deletions cpp/src/structs/copying/concatenate.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-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 Down Expand Up @@ -65,17 +65,20 @@ std::unique_ptr<column> concatenate(host_span<column_view const> columns,
std::any_of(columns.begin(), columns.end(), [](auto const& col) { return col.has_nulls(); });
rmm::device_buffer null_mask =
create_null_mask(total_length, has_nulls ? mask_state::UNINITIALIZED : mask_state::UNALLOCATED);
cudf::size_type null_count{0};
if (has_nulls) {
cudf::detail::concatenate_masks(columns, static_cast<bitmask_type*>(null_mask.data()), stream);
null_count = std::transform_reduce(
columns.begin(),
columns.end(),
0,
std::plus{},
[](auto const& col) { return col.null_count(); });
}

// assemble into outgoing list column
return make_structs_column(total_length,
std::move(children),
has_nulls ? UNKNOWN_NULL_COUNT : 0,
std::move(null_mask),
stream,
mr);
return make_structs_column(
total_length, std::move(children), null_count, std::move(null_mask), stream, mr);
}

} // namespace detail
Expand Down