@@ -22,24 +22,14 @@ namespace detail {
2222template <typename ColumnDeviceView, typename HostTableView>
2323void table_device_view_base<ColumnDeviceView, HostTableView>::destroy()
2424{
25- delete _descendant_storage;
2625 delete this ;
2726}
2827
2928template <typename ColumnDeviceView, typename HostTableView>
3029table_device_view_base<ColumnDeviceView, HostTableView>::table_device_view_base(
31- HostTableView source_view, rmm::cuda_stream_view stream )
32- : _num_rows{source_view.num_rows ()}, _num_columns{source_view.num_columns ()}
30+ HostTableView source_view, ColumnDeviceView* columns )
31+ : _columns{columns}, _num_rows{source_view.num_rows ()}, _num_columns{source_view.num_columns ()}
3332{
34- // The table's columns must be converted to ColumnDeviceView
35- // objects and copied into device memory for the table_device_view's
36- // _columns member.
37- if (source_view.num_columns () > 0 ) {
38- std::unique_ptr<rmm::device_buffer> descendant_storage_owner;
39- std::tie (descendant_storage_owner, _columns) =
40- contiguous_copy_column_device_views<ColumnDeviceView, HostTableView>(source_view, stream);
41- _descendant_storage = descendant_storage_owner.release ();
42- }
4333}
4434
4535// Explicit instantiation for a device table of immutable views
@@ -51,8 +41,8 @@ template class table_device_view_base<mutable_column_device_view, mutable_table_
5141} // namespace detail
5242
5343template <typename ColumnDeviceView, typename HostTableView>
54- std::pair<std::unique_ptr<rmm::device_buffer>, ColumnDeviceView*>
55- contiguous_copy_column_device_views ( HostTableView source_view, rmm::cuda_stream_view stream)
44+ std::pair<std::unique_ptr<rmm::device_buffer>, ColumnDeviceView*> create_column_device_views (
45+ HostTableView source_view, rmm::cuda_stream_view stream)
5646{
5747 // First calculate the size of memory needed to hold the
5848 // table's ColumnDeviceViews. This is done by calling extent()
@@ -89,7 +79,47 @@ contiguous_copy_column_device_views(HostTableView source_view, rmm::cuda_stream_
8979}
9080
9181template std::pair<std::unique_ptr<rmm::device_buffer>, column_device_view*>
92- contiguous_copy_column_device_views <column_device_view, host_span<column_view const >>(
82+ create_column_device_views <column_device_view, host_span<column_view const >>(
9383 host_span<column_view const > source_view, rmm::cuda_stream_view stream);
9484
85+ table_device_view::table_device_view (table_view source_view, column_device_view* columns)
86+ : detail::table_device_view_base<column_device_view, table_view>(source_view, columns)
87+ {
88+ }
89+
90+ std::unique_ptr<table_device_view, std::function<void (table_device_view*)>>
91+ table_device_view::create (table_view source_view, rmm::cuda_stream_view stream)
92+ {
93+ auto [descendant_storage, columns] =
94+ create_column_device_views<column_device_view, table_view>(source_view, stream);
95+ auto deleter = [ds = descendant_storage.release ()](table_device_view* tv) {
96+ tv->destroy ();
97+ delete ds;
98+ };
99+ std::unique_ptr<table_device_view, decltype (deleter)> result{
100+ new table_device_view (source_view, columns), deleter};
101+ return result;
102+ }
103+
104+ mutable_table_device_view::mutable_table_device_view (mutable_table_view source_view,
105+ mutable_column_device_view* columns)
106+ : detail::table_device_view_base<mutable_column_device_view, mutable_table_view>(source_view,
107+ columns)
108+ {
109+ }
110+
111+ std::unique_ptr<mutable_table_device_view, std::function<void (mutable_table_device_view*)>>
112+ mutable_table_device_view::create (mutable_table_view source_view, rmm::cuda_stream_view stream)
113+ {
114+ auto [descendant_storage, columns] =
115+ create_column_device_views<mutable_column_device_view, mutable_table_view>(source_view, stream);
116+ auto deleter = [ds = descendant_storage.release ()](mutable_table_device_view* tv) {
117+ tv->destroy ();
118+ delete ds;
119+ };
120+ std::unique_ptr<mutable_table_device_view, decltype (deleter)> result{
121+ new mutable_table_device_view (source_view, columns), deleter};
122+ return result;
123+ }
124+
95125} // namespace cudf
0 commit comments