Class ChunksPile

Class Documentation

class ChunksPile

Chunks state map.

Validity info and next offset.

Public Types

using StreamChunksMap = std::unordered_map<uint32_t, std::shared_ptr<std::vector<uint64_t>>>

stream_id to offset map.

Public Functions

ChunksPile() = default

Default blank constructor.

ChunksPile(const std::vector<ChunkState> &chunks, uint64_t end_of_chunks_offset)

Construct a ChunksPile from a vector of ChunkState and the offset of the end of the last chunk (in bytes relative to the header.)

Parameters:
  • chunks[in] – a vector of chunks

  • end_of_chunks_offset[in] – the offset of the end of the last chunk in bytes relative to the header.

ChunkState *get(uint64_t offset)

Return the chunk associated with an offset.

Parameters:

offset[in] – The offset to return the chunk for.

Returns:

The chunk if found, or nullptr.

void add_info(uint64_t offset, uint32_t stream_id, uint32_t message_count)

Add a new streaming info to the ChunkPile.

Parameters:
  • offset[in] – The offset for the chunk.

  • stream_id[in] – The stream_id associated.

  • message_count[in] – The number of messages.

ChunkInfoNode *get_info(uint64_t offset)

Return the streaming info associated with an offset.

Parameters:

offset[in] – The offset to return the streaming info for.

Returns:

The streaming info if found, or nullptr.

ChunkInfoNode *get_info_by_message_idx(uint32_t stream_id, uint32_t message_idx)

Return the streaming info associated with a message_idx.

Parameters:
  • stream_id[in] – The stream to look for infos in.

  • message_idx[in] – The specific message index to look for.

Returns:

The streaming info if found, or nullptr.

ChunkState *get_by_lower_bound_ts(uint32_t stream_id, const ts_t ts)

Return the chunk associated with a lower bound timestamp.

Parameters:
  • stream_id[in] – The stream to look for chunks in.

  • ts[in] – The lower bound for the chunk.

Returns:

The chunk if found, or nullptr.

ChunkState *next(uint64_t offset)

Return the next chunk identified by the offset.

Parameters:

offset[in] – The offset to return the next chunk for.

Returns:

The chunk if found, or nullptr.

ChunkState *next_by_stream(uint64_t offset)

Return the next chunk identified by the offset per stream.

Parameters:

offset[in] – The offset to return the next chunk for.

Returns:

The chunk if found, or nullptr.

ChunkState *first()

Return the first chunk.

Returns:

The chunk if found, or nullptr.

size_t size() const

Return the size of the chunk pile.

Returns:

The size of the chunk pile.

bool has_message_idx() const

Return if there is a message index.

Returns:

If there is a message index.

StreamChunksMap &stream_chunks()

Return the stream_id to chunk offset map.

Returns:

The stream_id to chunk offset map.

std::vector<uint64_t> chunk_offsets() const

Return the chunks offset vector.

Returns:

The chunks offset vector.

Builds internal links between ChunkInfoNode per stream.

Throws:
  • std::logic_error – exception on non increasing timestamps.

  • std::logic_error – exception on non existent info.