Classes | Public Types | Public Member Functions | List of all members
rapidsmpf::streaming::SpillableMessages Class Reference

Container for individually spillable messages. More...

#include <spillable_messages.hpp>

Public Types

using MessageId = std::uint64_t
 Unique identifier assigned to each message.
 

Public Member Functions

 SpillableMessages (SpillableMessages const &)=delete
 
SpillableMessagesoperator= (SpillableMessages const &)=delete
 
 SpillableMessages (SpillableMessages &&) noexcept=delete
 
SpillableMessagesoperator= (SpillableMessages &&) noexcept=delete
 
MessageId insert (Message &&message)
 Insert a new message and return its assigned ID. More...
 
Message extract (MessageId mid)
 Extract and remove a message by ID. More...
 
std::size_t spill (MessageId mid, BufferResource *br) const
 Spill a message's device memory to host memory. More...
 
std::map< MessageId, ContentDescriptionget_content_descriptions () const
 Get a snapshot of current messages' content descriptions. More...
 

Detailed Description

Container for individually spillable messages.

SpillableMessages manages a collection of Message instances that can be spilled or extracted independently. Each message is assigned a unique MessageId upon insertion, which can later be used to extract or spill that message.

The container is thread-safe for concurrent insertions, extractions, and spills.

Example

SpillableMessages messages;
auto id = messages.insert(to_message(TableChunk{...}));
messages.spill(id, ...);
auto msg = messages.extract(id);
Message to_message(std::uint64_t sequence_number, std::unique_ptr< PackedDataChunk > chunk)
Wrap a PackedDataChunk into a Message.
Definition: packed_data.hpp:44

Definition at line 38 of file spillable_messages.hpp.

Member Function Documentation

◆ extract()

Message rapidsmpf::streaming::SpillableMessages::extract ( MessageId  mid)

Extract and remove a message by ID.

If the message is currently being spilled, this method blocks until spilling completes.

Parameters
midMessage identifier.
Returns
Extracted Message instance.
Exceptions
std::out_of_rangeIf the message ID is invalid or was already extracted.

◆ get_content_descriptions()

std::map<MessageId, ContentDescription> rapidsmpf::streaming::SpillableMessages::get_content_descriptions ( ) const

Get a snapshot of current messages' content descriptions.

The returned map may become outdated immediately if other threads modify the container after this call.

Use this snapshot to decide which messages to spill, but keep in mind that the information may no longer be accurate when the actual spill occurs. When calling spill(), the returned size reflects what was actually spilled.

Returns
Copy of a map from MessageId to ContentDescription.

◆ insert()

MessageId rapidsmpf::streaming::SpillableMessages::insert ( Message &&  message)

Insert a new message and return its assigned ID.

Parameters
messageMessage to insert.
Returns
Assigned MessageId of the inserted message.

◆ spill()

std::size_t rapidsmpf::streaming::SpillableMessages::spill ( MessageId  mid,
BufferResource br 
) const

Spill a message's device memory to host memory.

Performs an in-place deep copy of the message's payload from device to host memory using the specified buffer resource.

If the message is currently being accessed by another thread, is already spilled, not spillable, or does not exist, the operation returns immediately without spilling.

Parameters
midMessage identifier. If the message does not exist, zero is returned.
brBuffer resource used for allocations during the spill operation.
Returns
Number of bytes released from device memory (0 if nothing was spilled).
Exceptions
std::runtime_errorIf there is insufficient host memory to reserve.

The documentation for this class was generated from the following file: