10 #include <unordered_map>
13 #include <rapidsmpf/error.hpp>
14 #include <rapidsmpf/shuffler/chunk.hpp>
24 template <
typename KeyType>
39 template <
typename Fn>
40 PostBox(Fn&& key_map_fn,
size_t num_keys_hint = 0)
41 : key_map_fn_(std::move(key_map_fn)) {
42 if (num_keys_hint > 0) {
43 pigeonhole_.reserve(num_keys_hint);
117 [[nodiscard]] std::vector<std::tuple<key_type, ChunkID, std::size_t>>
search(
125 [[nodiscard]] std::string
str()
const;
129 mutable std::mutex mutex_;
132 std::unordered_map<key_type, std::unordered_map<ChunkID, Chunk>>
145 template <
typename KeyType>
Chunk with multiple messages. This class contains two buffers for concatenated metadata and data.
A thread-safe container for managing and retrieving data chunks by partition and chunk ID.
bool is_empty(PartID pid) const
Check whether the specified partition contains any chunks.
std::vector< std::tuple< key_type, ChunkID, std::size_t > > search(MemoryType mem_type) const
Searches for chunks of the specified memory type.
KeyType key_type
The type of the key used to map chunks.
std::unordered_map< ChunkID, Chunk > extract_by_key(KeyType key)
Extracts all chunks associated with a specific key.
std::string str() const
Returns a description of this instance.
bool empty() const
Checks if the PostBox is empty.
void insert(Chunk &&chunk)
Inserts a chunk into the PostBox.
PostBox(Fn &&key_map_fn, size_t num_keys_hint=0)
Construct a new PostBox.
std::unordered_map< ChunkID, Chunk > extract(PartID pid)
Extracts all chunks associated with a specific partition.
Chunk extract(PartID pid, ChunkID cid)
Extracts a specific chunk from the PostBox.
std::vector< Chunk > extract_all_ready()
Extracts all ready chunks from the PostBox.
Shuffler private interfaces.
std::ostream & operator<<(std::ostream &os, Chunk const &obj)
Overloads the stream insertion operator for the Chunk class.
std::uint64_t ChunkID
The globally unique ID of a chunk.
std::uint32_t PartID
Partition ID, which goes from 0 to the total number of partitions.