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

Use empty_like in scatter #8314

Merged
merged 3 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 1 addition & 16 deletions cpp/include/cudf/lists/detail/copying.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, 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 @@ -48,21 +48,6 @@ std::unique_ptr<cudf::column> copy_slice(lists_column_view const& lists,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @brief Create a single-level empty lists column.
*
* An empty lists column contains empty children so the column's
* basic type is recorded.
*
* @param child_type The type used for the 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<cudf::column> make_empty_lists_column(data_type child_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
Comment on lines -62 to -64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thumbs up. This function should not exist.


} // namespace detail
} // namespace lists
} // namespace cudf
5 changes: 1 addition & 4 deletions cpp/include/cudf/lists/detail/scatter.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,7 @@ struct list_child_constructor {

if (num_child_rows == 0) {
// make an empty lists column using the input child type
return make_empty_lists_column(
source_lists_column_view.child().child(lists_column_view::child_column_index).type(),
stream,
mr);
return empty_like(source_lists_column_view.child());
jlowe marked this conversation as resolved.
Show resolved Hide resolved
}

auto child_list_views = rmm::device_uvector<unbound_list_view>(num_child_rows, stream, mr);
Expand Down
13 changes: 0 additions & 13 deletions cpp/src/lists/copying/copying.cu
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,6 @@ std::unique_ptr<cudf::column> copy_slice(lists_column_view const& lists,
std::move(null_mask));
}

std::unique_ptr<cudf::column> make_empty_lists_column(data_type child_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return cudf::make_lists_column(0,
make_empty_column(data_type{type_to_id<offset_type>()}),
make_empty_column(child_type),
0, // Null count
rmm::device_buffer{0, stream, mr}, // Null mask
stream,
mr);
}

} // namespace detail
} // namespace lists
} // namespace cudf
20 changes: 20 additions & 0 deletions cpp/tests/partitioning/partition_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,23 @@ TEST_F(PartitionTestNotTyped, ListOfListOfIntEmpty)
CUDF_TEST_EXPECT_TABLES_EQUAL(table_to_partition, result.first->view());
EXPECT_EQ(3, result.second.size());
}

TEST_F(PartitionTestNotTyped, ListOfListOfListOfIntEmpty)
{
cudf::test::lists_column_wrapper<int32_t> level_3_list{};

fixed_width_column_wrapper<int32_t> level_2_offsets{};
std::unique_ptr<cudf::column> level_2_list =
cudf::make_lists_column(0, level_2_offsets.release(), level_3_list.release(), 0, {});

fixed_width_column_wrapper<int32_t> level_1_offsets{0, 0};
std::unique_ptr<cudf::column> level_1_list =
cudf::make_lists_column(1, level_1_offsets.release(), std::move(level_2_list), 0, {});

auto table_to_partition = cudf::table_view{{*level_1_list}};
fixed_width_column_wrapper<int32_t> map{0};

auto result = cudf::partition(table_to_partition, map, 2);
CUDF_TEST_EXPECT_TABLES_EQUAL(table_to_partition, result.first->view());
EXPECT_EQ(3, result.second.size());
}