51 virtual uint64_t
size()
const = 0;
68 virtual uint64_t
read(
std::byte** output, uint64_t offset, uint64_t size) = 0;
79 uint64_t size()
const override;
80 uint64_t read(
std::byte** output, uint64_t offset, uint64_t size)
override;
96 uint64_t size()
const override;
97 uint64_t read(
std::byte** output, uint64_t offset, uint64_t size)
override;
122 virtual void reset(
const std::byte* data, uint64_t size, uint64_t uncompressedSize) = 0;
137 void reset(
const std::byte* data, uint64_t size, uint64_t uncompressedSize)
override;
138 uint64_t read(
std::byte** output, uint64_t offset, uint64_t size)
override;
139 uint64_t size()
const override;
140 Status status()
const override;
153#ifndef MCAP_COMPRESSION_NO_ZSTD
160 void reset(
const std::byte* data, uint64_t size, uint64_t uncompressedSize)
override;
161 uint64_t read(
std::byte** output, uint64_t offset, uint64_t size)
override;
162 uint64_t size()
const override;
163 Status status()
const override;
175 static Status DecompressAll(
const std::byte* data, uint64_t compressedSize,
176 uint64_t uncompressedSize,
ByteArray* output);
189#ifndef MCAP_COMPRESSION_NO_LZ4
196 void reset(
const std::byte* data, uint64_t size, uint64_t uncompressedSize)
override;
197 uint64_t read(
std::byte** output, uint64_t offset, uint64_t size)
override;
198 uint64_t size()
const override;
199 Status status()
const override;
211 Status decompressAll(
const std::byte* data, uint64_t size, uint64_t uncompressedSize,
221 void* decompressionContext_ =
nullptr;
251 enum struct ReadOrder { FileOrder, LogTimeOrder, ReverseLogTimeOrder };
496 bool parsedSummary_ =
false;
517 const Status& status()
const;
545 const Status& status()
const;
551#ifndef MCAP_COMPRESSION_NO_LZ4
554#ifndef MCAP_COMPRESSION_NO_ZSTD
594 const Status& status()
const;
636 int unreadMessages = 0;
638 size_t findFreeChunkSlot();
643#ifndef MCAP_COMPRESSION_NO_LZ4
667 void operator++(
int);
688 bool has_value()
const;
729#ifdef MCAP_IMPLEMENTATION
A "null" compressed reader that directly passes through uncompressed data. No internal buffers are al...
BufferReader(const BufferReader &)=delete
BufferReader(BufferReader &&)=delete
BufferReader & operator=(BufferReader &&)=delete
BufferReader & operator=(const BufferReader &)=delete
IReadable implementation wrapping a FILE* pointer created by fopen() and a read buffer.
std::vector< std::byte > buffer_
IReadable implementation wrapping a std::ifstream input file stream.
std::vector< std::byte > buffer_
An abstract interface for compressed readers.
virtual Status status() const =0
Report the current status of decompression. A StatusCode other than StatusCode::Success after reset()...
virtual void reset(const std::byte *data, uint64_t size, uint64_t uncompressedSize)=0
Reset the reader state, clearing any internal buffers and state, and initialize with new compressed d...
virtual ~ICompressedReader() override=default
ICompressedReader implementation that decompresses LZ4 (https://lz4.github.io/lz4/) data.
LZ4Reader & operator=(LZ4Reader &&)=delete
LZ4Reader(LZ4Reader &&)=delete
LZ4Reader & operator=(const LZ4Reader &)=delete
ByteArray uncompressedData_
LZ4Reader(const LZ4Reader &)=delete
const std::byte * compressedData_
uint64_t uncompressedSize_
std::optional< MessageView > curMessageView_
Impl & operator=(const Impl &)=delete
Impl & operator=(Impl &&)=delete
Impl(const Impl &)=delete
std::optional< TypedRecordReader > recordReader_
LinearMessageView & view_
std::optional< IndexedMessageReader > indexedMessageReader_
Provides a read interface to an MCAP file.
std::unique_ptr< FileReader > fileInput_
std::vector< ChunkIndex > chunkIndexes_
std::unordered_map< SchemaId, SchemaPtr > schemas_
std::optional< Footer > footer_
std::optional< Header > header_
std::unique_ptr< FileStreamReader > fileStreamInput_
internal::IntervalTree< ByteOffset, ChunkIndex > chunkRanges_
std::multimap< std::string, MetadataIndex > metadataIndexes_
std::optional< Statistics > statistics_
std::unordered_map< ChannelId, ChannelPtr > channels_
std::multimap< std::string, AttachmentIndex > attachmentIndexes_
ICompressedReader implementation that decompresses Zstandard (https://facebook.github....
ZStdReader(const ZStdReader &)=delete
ByteArray uncompressedData_
ZStdReader & operator=(const ZStdReader &)=delete
ZStdReader(ZStdReader &&)=delete
ZStdReader & operator=(ZStdReader &&)=delete
constexpr Timestamp MaxTime
Compression
Supported MCAP compression algorithms.
constexpr ByteOffset EndOffset
@ AllowFallbackScan
If the Summary section is missing or incomplete, allow falling back to reading the file sequentially ...
@ ForceScan
Read the file sequentially from Header to DataEnd to produce seeking indexes and summary statistics.
@ NoFallbackScan
Parse the Summary section to produce seeking indexes and summary statistics. If the Summary section i...
bool operator==(const LinearMessageView::Iterator &a, const LinearMessageView::Iterator &b)
Attachment Index records are found in the Summary section, providing summary information for a single...
An Attachment is an arbitrary file embedded in an MCAP file, including a name, media type,...
Describes a Channel that messages are written to. A Channel represents a single connection from a pub...
Chunk Index records are found in the Summary section, providing summary information for a single Chun...
An collection of Schemas, Channels, and Messages that supports compression and indexing.
The final record in the Data section, signaling the end of Data and beginning of Summary....
An abstract interface for reading MCAP data.
virtual ~IReadable()=default
virtual uint64_t read(std::byte **output, uint64_t offset, uint64_t size)=0
This method is called by MCAP reader classes when they need to read a portion of the file.
virtual uint64_t size() const =0
Returns the size of the file in bytes.
ByteArray decompressedChunk
ByteOffset chunkStartOffset
Uses message indices to read messages out of an MCAP in log time order. The underlying MCAP must be c...
RecordReader recordReader_
std::vector< ChunkSlot > chunkSlots_
std::function< void(const Message &, RecordOffset)> onMessage_
internal::ReadJobQueue queue_
ReadMessageOptions options_
std::unordered_set< ChannelId > selectedChannels_
std::unique_ptr< Impl > impl_
An iterable view of Messages in an MCAP file.
ReadMessageOptions readMessageOptions_
LinearMessageView & operator=(const LinearMessageView &)=delete
LinearMessageView(const LinearMessageView &)=delete
LinearMessageView(LinearMessageView &&)=default
LinearMessageView & operator=(LinearMessageView &&)=delete
const ProblemCallback onProblem_
A list of timestamps to byte offsets for a single Channel. This record appears after each Chunk,...
Returned when iterating over Messages in a file, MessageView contains a reference to one Message,...
A single Message published to a Channel.
Options for reading messages out of an MCAP file.
ReadMessageOptions()=default
std::function< bool(std::string_view)> topicFilter
If provided, topicFilter is called on all topics found in the MCAP file. If topicFilter returns true ...
ReadMessageOptions(Timestamp start, Timestamp end)
A low-level interface for parsing MCAP-style TLV records from a data source.
A generic Type-Length-Value record using a uint8 type and uint64 length. This is the generic form of ...
Describes a schema used for message encoding and decoding and/or describing the shape of messages....
The Statistics record is found in the Summary section, providing counts and timestamp ranges for the ...
Wraps a status code and string message carrying additional context.
Summary Offset records are found in the Summary Offset section. Records in the Summary section are gr...
std::function< void(const Message &, ByteOffset)> onMessage
TypedChunkReader & operator=(const TypedChunkReader &)=delete
std::function< void(const SchemaPtr, ByteOffset)> onSchema
std::function< void(const Record &, ByteOffset)> onUnknownRecord
std::function< void(const ChannelPtr, ByteOffset)> onChannel
TypedChunkReader(TypedChunkReader &&)=delete
BufferReader uncompressedReader_
TypedChunkReader(const TypedChunkReader &)=delete
TypedChunkReader & operator=(TypedChunkReader &&)=delete
A mid-level interface for parsing and validating MCAP records from a data source.
std::function< void(const Message &, ByteOffset, std::optional< ByteOffset >)> onMessage
std::function< void(const Metadata &, ByteOffset)> onMetadata
std::function< void(ByteOffset)> onChunkEnd
std::function< void(const Record &, ByteOffset, std::optional< ByteOffset >)> onUnknownRecord
std::function< void(const SummaryOffset &, ByteOffset)> onSummaryOffset
std::function< void(const Footer &, ByteOffset)> onFooter
std::function< void(const DataEnd &, ByteOffset)> onDataEnd
std::function< void(const ChannelPtr, ByteOffset, std::optional< ByteOffset >)> onChannel
TypedRecordReader & operator=(TypedRecordReader &&)=delete
std::function< void(const Attachment &, ByteOffset)> onAttachment
std::function< void(const ChunkIndex &, ByteOffset)> onChunkIndex
std::function< void(const MetadataIndex &, ByteOffset)> onMetadataIndex
TypedRecordReader(const TypedRecordReader &)=delete
TypedRecordReader & operator=(const TypedRecordReader &)=delete
std::function< void(const Chunk &, ByteOffset)> onChunk
TypedChunkReader chunkReader_
std::function< void(const Statistics &, ByteOffset)> onStatistics
std::function< void(const AttachmentIndex &, ByteOffset)> onAttachmentIndex
std::function< void(const SchemaPtr, ByteOffset, std::optional< ByteOffset >)> onSchema
std::function< void(const Header &, ByteOffset)> onHeader
TypedRecordReader(TypedRecordReader &&)=delete
std::function< void(const MessageIndex &, ByteOffset)> onMessageIndex
A priority queue of jobs for an indexed MCAP reader to execute.