Public Types | Public Member Functions | List of all members
rapidsmpf::shuffler::detail::PostBox< KeyType > Class Template Reference

A thread-safe container for managing and retrieving data chunks by partition and chunk ID. More...

#include <postbox.hpp>

Public Types

using key_type = KeyType
 The type of the key used to map chunks.
 

Public Member Functions

template<typename Fn >
 PostBox (Fn &&key_map_fn, size_t num_keys_hint=0)
 Construct a new PostBox. More...
 
void insert (Chunk &&chunk)
 Inserts a chunk into the PostBox. More...
 
bool is_empty (PartID pid) const
 Check whether the specified partition contains any chunks. More...
 
Chunk extract (PartID pid, ChunkID cid)
 Extracts a specific chunk from the PostBox. More...
 
std::unordered_map< ChunkID, Chunkextract (PartID pid)
 Extracts all chunks associated with a specific partition. More...
 
std::unordered_map< ChunkID, Chunkextract_by_key (KeyType key)
 Extracts all chunks associated with a specific key. More...
 
std::vector< Chunkextract_all_ready ()
 Extracts all ready chunks from the PostBox. More...
 
bool empty () const
 Checks if the PostBox is empty. More...
 
std::vector< std::tuple< key_type, ChunkID, std::size_t > > search (MemoryType mem_type) const
 Searches for chunks of the specified memory type. More...
 
std::string str () const
 Returns a description of this instance. More...
 

Detailed Description

template<typename KeyType>
class rapidsmpf::shuffler::detail::PostBox< KeyType >

A thread-safe container for managing and retrieving data chunks by partition and chunk ID.

Template Parameters
KeyTypeThe type of the key used to map chunks.

Definition at line 25 of file postbox.hpp.

Constructor & Destructor Documentation

◆ PostBox()

template<typename KeyType >
template<typename Fn >
rapidsmpf::shuffler::detail::PostBox< KeyType >::PostBox ( Fn &&  key_map_fn,
size_t  num_keys_hint = 0 
)
inline

Construct a new PostBox.

Template Parameters
FnThe type of the function that maps a partition ID to a key.
Parameters
key_map_fnA function that maps a partition ID to a key.
num_keys_hintThe number of keys to reserve space for.
Note
The key_map_fn must be convertible to a function that takes a PartID and returns a KeyType.

Definition at line 40 of file postbox.hpp.

Member Function Documentation

◆ empty()

template<typename KeyType >
bool rapidsmpf::shuffler::detail::PostBox< KeyType >::empty ( ) const

Checks if the PostBox is empty.

Returns
true if the PostBox is empty, false otherwise.

◆ extract() [1/2]

template<typename KeyType >
std::unordered_map<ChunkID, Chunk> rapidsmpf::shuffler::detail::PostBox< KeyType >::extract ( PartID  pid)

Extracts all chunks associated with a specific partition.

Parameters
pidThe ID of the partition.
Returns
A map of chunk IDs to chunks for the specified partition.
Exceptions
std::out_of_rangeIf the partition is not found.

◆ extract() [2/2]

template<typename KeyType >
Chunk rapidsmpf::shuffler::detail::PostBox< KeyType >::extract ( PartID  pid,
ChunkID  cid 
)

Extracts a specific chunk from the PostBox.

Parameters
pidThe ID of the partition containing the chunk.
cidThe ID of the chunk to be accessed.
Returns
The extracted chunk.
Exceptions
std::out_of_rangeIf the chunk is not found.

◆ extract_all_ready()

template<typename KeyType >
std::vector<Chunk> rapidsmpf::shuffler::detail::PostBox< KeyType >::extract_all_ready ( )

Extracts all ready chunks from the PostBox.

Returns
A vector of all ready chunks in the PostBox.

◆ extract_by_key()

template<typename KeyType >
std::unordered_map<ChunkID, Chunk> rapidsmpf::shuffler::detail::PostBox< KeyType >::extract_by_key ( KeyType  key)

Extracts all chunks associated with a specific key.

Parameters
keyThe key.
Returns
A map of chunk IDs to chunks for the specified key.
Exceptions
std::out_of_rangeIf the key is not found.

◆ insert()

template<typename KeyType >
void rapidsmpf::shuffler::detail::PostBox< KeyType >::insert ( Chunk &&  chunk)

Inserts a chunk into the PostBox.

Parameters
chunkThe chunk to insert.

◆ is_empty()

template<typename KeyType >
bool rapidsmpf::shuffler::detail::PostBox< KeyType >::is_empty ( PartID  pid) const

Check whether the specified partition contains any chunks.

Parameters
pidIdentifier of the partition to query.
Returns
True if the partition contains no chunks, false otherwise.
Note
The result reflects a snapshot at the time of the call and may change immediately afterward.

◆ search()

template<typename KeyType >
std::vector<std::tuple<key_type, ChunkID, std::size_t> > rapidsmpf::shuffler::detail::PostBox< KeyType >::search ( MemoryType  mem_type) const

Searches for chunks of the specified memory type.

Parameters
mem_typeThe type of memory to search within.
Returns
A vector of tuples, where each tuple contains: PartID, ChunkID, and the size of the chunk.

◆ str()

template<typename KeyType >
std::string rapidsmpf::shuffler::detail::PostBox< KeyType >::str ( ) const

Returns a description of this instance.

Returns
The description.

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