libcudf  24.02.00
contiguous_split.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cudf/table/table.hpp>
20 #include <cudf/types.hpp>
21 
22 #include <memory>
23 #include <vector>
24 
25 namespace cudf {
26 
42  : metadata(std::make_unique<std::vector<uint8_t>>()),
43  gpu_data(std::make_unique<rmm::device_buffer>())
44  {
45  }
46 
53  packed_columns(std::unique_ptr<std::vector<uint8_t>>&& md,
54  std::unique_ptr<rmm::device_buffer>&& gd)
55  : metadata(std::move(md)), gpu_data(std::move(gd))
56  {
57  }
58 
59  std::unique_ptr<std::vector<uint8_t>> metadata;
60  std::unique_ptr<rmm::device_buffer> gpu_data;
61 };
62 
75 struct packed_table {
78 };
79 
119 std::vector<packed_table> contiguous_split(
120  cudf::table_view const& input,
121  std::vector<size_type> const& splits,
123 
124 namespace detail {
125 struct contiguous_split_state;
126 };
127 
186  public:
196  explicit chunked_pack(
197  cudf::table_view const& input,
198  std::size_t user_buffer_size,
200 
206 
212  [[nodiscard]] std::size_t get_total_contiguous_size() const;
213 
219  [[nodiscard]] bool has_next() const;
220 
234  [[nodiscard]] std::size_t next(cudf::device_span<uint8_t> const& user_buffer);
235 
241  [[nodiscard]] std::unique_ptr<std::vector<uint8_t>> build_metadata() const;
242 
261  [[nodiscard]] static std::unique_ptr<chunked_pack> create(
262  cudf::table_view const& input,
263  std::size_t user_buffer_size,
265 
266  private:
267  // internal state of contiguous split
268  std::unique_ptr<detail::contiguous_split_state> state;
269 };
270 
285 
299 std::vector<uint8_t> pack_metadata(table_view const& table,
300  uint8_t const* contiguous_buffer,
301  size_t buffer_size);
302 
318 
336 table_view unpack(uint8_t const* metadata, uint8_t const* gpu_data);
337 
339 } // namespace cudf
Perform a chunked "pack" operation of the input table_view using a user provided buffer of size user_...
std::size_t get_total_contiguous_size() const
Obtain the total size of the contiguously packed table_view.
chunked_pack(cudf::table_view const &input, std::size_t user_buffer_size, rmm::mr::device_memory_resource *temp_mr=rmm::mr::get_current_device_resource())
Construct a chunked_pack class.
std::size_t next(cudf::device_span< uint8_t > const &user_buffer)
Packs the next chunk into user_buffer. This should be called as long as has_next returns true....
~chunked_pack()
Destructor that will be implemented as default. Declared with definition here because contiguous_spli...
std::unique_ptr< std::vector< uint8_t > > build_metadata() const
Build the opaque metadata for all added columns.
static std::unique_ptr< chunked_pack > create(cudf::table_view const &input, std::size_t user_buffer_size, rmm::mr::device_memory_resource *temp_mr=rmm::mr::get_current_device_resource())
Creates a chunked_pack instance to perform a "pack" of the table_view "input", where a buffer of user...
bool has_next() const
Function to check if there are chunks left to be copied.
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:187
A set of cudf::column's of the same size.
Definition: table.hpp:40
table_view unpack(packed_columns const &input)
Deserialize the result of cudf::pack.
std::vector< uint8_t > pack_metadata(table_view const &table, uint8_t const *contiguous_buffer, size_t buffer_size)
Produce the metadata used for packing a table stored in a contiguous buffer.
std::vector< packed_table > contiguous_split(cudf::table_view const &input, std::vector< size_type > const &splits, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Performs a deep-copy split of a table_view into a vector of packed_table where each packed_table is u...
packed_columns pack(cudf::table_view const &input, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Deep-copy a table_view into a serialized contiguous memory format.
device_memory_resource * get_current_device_resource()
cuDF interfaces
Definition: aggregation.hpp:34
Device version of C++20 std::span with reduced feature set.
Definition: span.hpp:291
Column data in a serialized format.
packed_columns(std::unique_ptr< std::vector< uint8_t >> &&md, std::unique_ptr< rmm::device_buffer > &&gd)
Construct a new packed columns object.
std::unique_ptr< std::vector< uint8_t > > metadata
Host-side metadata buffer.
std::unique_ptr< rmm::device_buffer > gpu_data
Device-side data buffer.
The result(s) of a cudf::contiguous_split.
packed_columns data
Column data owned.
cudf::table_view table
Result table_view of a cudf::contiguous_split.
Class definition for cudf::table.
Type declarations for libcudf.