14 #include <rapidsmpf/buffer/buffer.hpp>
15 #include <rapidsmpf/buffer/resource.hpp>
16 #include <rapidsmpf/error.hpp>
27 std::unique_ptr<std::vector<std::uint8_t>>
metadata;
28 std::unique_ptr<Buffer>
data;
37 std::unique_ptr<std::vector<std::uint8_t>>
metadata, std::unique_ptr<Buffer>
data
41 this->metadata !=
nullptr,
"the metadata pointer cannot be null"
43 RAPIDSMPF_EXPECTS(this->data !=
nullptr,
"the GPU data pointer cannot be null");
45 (this->metadata->size() > 0 || this->data->size == 0),
46 "Empty Metadata and non-empty GPU data is not allowed"
69 [[nodiscard]]
bool empty()
const {
79 return data->stream();
92 buffer_copy(*dst, *
data,
data->size);
94 std::make_unique<std::vector<std::uint8_t>>(*metadata), std::move(dst)
std::unique_ptr< Buffer > allocate(std::size_t size, rmm::cuda_stream_view stream, MemoryReservation &reservation)
Allocate a buffer of the specified memory type by the reservation.
Represents a reservation for future memory allocation.
constexpr BufferResource * br() const noexcept
Get the buffer resource associated with this reservation.
Bag of bytes with metadata suitable for sending over the wire.
rmm::cuda_stream_view stream() const
Get the stream associated with the data buffer.
std::unique_ptr< Buffer > data
The GPU data.
PackedData(std::unique_ptr< std::vector< std::uint8_t >> metadata, std::unique_ptr< Buffer > data)
Construct from metadata and GPU data, taking ownership.
std::unique_ptr< std::vector< std::uint8_t > > metadata
The metadata.
bool empty() const
Check if the packed data is empty.
PackedData copy(MemoryReservation &reservation) const
Create a deep copy of the packed data.
PackedData & operator=(PackedData &&)=default
Move assignment.
PackedData(PackedData &&)=default
PackedData is moveable.