Skip to content

Commit

Permalink
Move cudf::lists::detail::make_empty_lists_column to public API
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwendt committed Feb 12, 2025
1 parent b4ff54f commit 06865f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
17 changes: 16 additions & 1 deletion cpp/include/cudf/column/column_factories.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024, NVIDIA CORPORATION.
* Copyright (c) 2019-2025, 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 @@ -516,6 +516,21 @@ std::unique_ptr<cudf::column> make_lists_column(
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Create an empty LIST column
*
* A list column requires a child type and so cannot be created with `make_empty_column`.
*
* @param child_type The type used for the empty child column
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column's device memory
* @return New empty lists column
*/
std::unique_ptr<column> make_empty_lists_column(
data_type child_type,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Construct a STRUCT column using specified child columns as members.
*
Expand Down
11 changes: 10 additions & 1 deletion cpp/src/lists/lists_column_factories.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024, NVIDIA CORPORATION.
* Copyright (c) 2020-2025, 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 @@ -112,6 +112,13 @@ std::unique_ptr<column> make_all_nulls_lists_column(size_type size,
} // namespace detail
} // namespace lists

std::unique_ptr<column> make_empty_lists_column(data_type child_type,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr)
{
return lists::detail::make_empty_lists_column(child_type, stream, mr);
}

/**
* @copydoc cudf::make_lists_column
*/
Expand Down Expand Up @@ -144,6 +151,8 @@ std::unique_ptr<column> make_lists_column(size_type num_rows,
null_count,
std::move(children));

if (num_rows == 0) { return output; }

// We need to enforce all null lists to be empty.
// `has_nonempty_nulls` is less expensive than `purge_nonempty_nulls` and can save some
// run time if we don't have any non-empty nulls.
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/lists/sequences.cu
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ std::unique_ptr<column> sequences(column_view const& starts,
}

auto const n_lists = starts.size();
if (n_lists == 0) { return make_empty_lists_column(starts.type(), stream, mr); }
if (n_lists == 0) { return cudf::make_empty_lists_column(starts.type(), stream, mr); }

// Generate list offsets for the output.
auto list_offsets = make_numeric_column(
Expand Down

0 comments on commit 06865f1

Please sign in to comment.