Chunk with multiple messages. This class contains two buffers for concatenated metadata and data. More...
#include <chunk.hpp>
Public Member Functions | |
| Chunk (Chunk &&other) noexcept=default | |
| move constructor More... | |
| Chunk & | operator= (Chunk &&other) noexcept=default |
| move assignment operator More... | |
| Chunk (Chunk const &)=delete | |
| Chunk & | operator= (Chunk const &)=delete |
| constexpr ChunkID | chunk_id () const |
| The ID of the chunk. More... | |
| constexpr size_t | n_messages () const |
| The number of messages in the chunk. More... | |
| constexpr PartID | part_id (size_t i) const |
| Partition ID of the i-th message. More... | |
| constexpr size_t | expected_num_chunks (size_t i) const |
| The expected number of chunks of the i-th message. More... | |
| constexpr bool | is_control_message (size_t i) const |
| Whether the i-th message is a control message. More... | |
| Chunk | get_data (ChunkID new_chunk_id, size_t i, BufferResource *br) |
| Get the data of the i-th message, as a new chunk. More... | |
| constexpr uint32_t | metadata_size (size_t i) const |
| Get the size of the metadata of the i-th message. More... | |
| constexpr size_t | data_size (size_t i) const |
| Get the size of the packed data of the i-th message. More... | |
| void | set_data_buffer (std::unique_ptr< Buffer > data) |
| Set the data buffer. More... | |
| bool | is_data_buffer_set () const |
| Whether the data buffer is set. More... | |
| bool | is_metadata_buffer_set () const |
| Whether the metadata buffer is set. More... | |
| MemoryType | data_memory_type () const |
| Get the memory type of the data buffer. More... | |
| constexpr size_t | concat_data_size () const |
| Get the size of the concatenated data. More... | |
| constexpr size_t | concat_metadata_size () const |
| Get the size of the concatenated metadata. More... | |
| std::unique_ptr< std::vector< uint8_t > > | release_metadata_buffer () |
| Release the ownership of the metadata buffer. More... | |
| std::unique_ptr< Buffer > | release_data_buffer () |
| Release the ownership of the data buffer. More... | |
| bool | is_ready () const |
| Whether the chunk is ready for consumption. More... | |
| std::string | str () const |
| Returns a description of this chunk. More... | |
| std::unique_ptr< std::vector< uint8_t > > | serialize () const |
| Returns a metadata message that represents this chunk. More... | |
Static Public Member Functions | |
| static constexpr size_t | metadata_message_header_size (size_t n_messages) |
| The size of the metadata message header. More... | |
| static Chunk | from_packed_data (ChunkID chunk_id, PartID part_id, PackedData &&packed_data) |
| Create a single-message chunk from a packed data. More... | |
| static Chunk | from_finished_partition (ChunkID chunk_id, PartID part_id, size_t expected_num_chunks) |
| Create a single-message chunk for a finished partition (control message). More... | |
| static Chunk | deserialize (std::vector< uint8_t > const &msg, bool validate=true) |
| Create a chunk by deserializing a metadata message. More... | |
| static bool | validate_format (std::vector< uint8_t > const &serialized_buf) |
| Validate if a deserialized buffer follows the Chunk format. More... | |
| static Chunk | concat (std::vector< Chunk > &&chunks, ChunkID chunk_id, BufferResource *br, std::optional< MemoryType > preferred_mem_type=std::nullopt) |
| Concatenate multiple chunks into a single chunk. More... | |
Friends | |
| Chunk | make_dummy_chunk (ChunkID, PartID) |
Chunk with multiple messages. This class contains two buffers for concatenated metadata and data.
When the Chunk is serialized, the format is as follows:
For a chunk with N messages with M bytes of concat metadata the size of serialized buffer is sizeof(ChunkID) + sizeof(size_t) + N * (sizeof(PartID) + sizeof(size_t) + sizeof(uint32_t) + sizeof(uint64_t)) + M = 16 + N * 24 + M bytes.
For a chunk with a single control message (ie. M = 0), the size of the serialized buffer is 40 bytes.
For a chunk with a single message with M bytes of metadata, the size of the serialized buffer is 40 + M bytes.
|
defaultnoexcept |
move constructor
| other | The chunk to move. |
|
inlineconstexpr |
|
static |
Concatenate multiple chunks into a single chunk.
Using a new stream from br->stream_pool() for the concatenation.
| chunks | Vector of chunks to concatenate. |
| chunk_id | The ID for the resulting concatenated chunk. |
| br | The buffer resource to use for memory allocation. |
| preferred_mem_type | The preferred memory type to use for the concatenated data buffer. |
| std::logic_error | if the input vector is empty or the concatenated chunk contains duplicate partition IDs. |
|
inlineconstexpr |
|
inlineconstexpr |
|
inline |
|
inlineconstexpr |
Get the size of the packed data of the i-th message.
| i | The index of the message. |
PackedData::data of the message.
|
static |
Create a chunk by deserializing a metadata message.
| msg | The metadata message received from another rank. |
| validate | Whether to validate the metadata buffer. |
| std::runtime_error | if the metadata buffer does not follow the expected format and validate is true. |
|
inlineconstexpr |
|
static |
Create a single-message chunk for a finished partition (control message).
| chunk_id | The ID of the chunk. |
| part_id | The ID of the partition. |
| expected_num_chunks | The expected number of chunks. |
|
static |
Create a single-message chunk from a packed data.
| chunk_id | The ID of the chunk. |
| part_id | The ID of the partition. |
| packed_data | The packed data. |
| Chunk rapidsmpf::shuffler::detail::Chunk::get_data | ( | ChunkID | new_chunk_id, |
| size_t | i, | ||
| BufferResource * | br | ||
| ) |
Get the data of the i-th message, as a new chunk.
| new_chunk_id | The ID of the new chunk. |
| i | The index of the message. |
| br | The buffer resource to use for copying the data. |
br->stream_pool(). If there is only one message and the message is a data message, the buffers will be moved to the new chunk. Otherwise a new chunk will be created by copying data. If the i'th message is,| std::out_of_range | if the index is out of bounds. |
|
inlineconstexpr |
|
inline |
|
inline |
|
inline |
|
inlinestaticconstexpr |
|
inlineconstexpr |
Get the size of the metadata of the i-th message.
| i | The index of the message. |
PackedData::metadata.
|
inlineconstexpr |
move assignment operator
| other | The chunk to move. |
|
inlineconstexpr |
|
inline |
|
inline |
| std::unique_ptr<std::vector<uint8_t> > rapidsmpf::shuffler::detail::Chunk::serialize | ( | ) | const |
Returns a metadata message that represents this chunk.
|
inline |
| std::string rapidsmpf::shuffler::detail::Chunk::str | ( | ) | const |
Returns a description of this chunk.
|
static |