pjmsg_mcap_wrapper
|
Provides a write interface to an MCAP file.
Definition at line 322 of file writer.hpp.
#include <writer.hpp>
Public Member Functions | |
~McapWriter () | |
Status | open (std::string_view filename, const McapWriterOptions &options) |
Open a new MCAP file for writing and write the header. | |
void | open (IWritable &writer, const McapWriterOptions &options) |
Open a new MCAP file for writing and write the header. | |
void | open (std::ostream &stream, const McapWriterOptions &options) |
Open a new MCAP file for writing and write the header. | |
void | close () |
Write the MCAP footer, flush pending writes to the output stream, and reset internal state. The writer may be re-used with another call to open afterwards. | |
void | terminate () |
Reset internal state without writing the MCAP footer or flushing pending writes. This should only be used in error cases as the output MCAP file will be truncated. The writer may be re-used with another call to open afterwards. | |
void | addSchema (Schema &schema) |
Add a new schema to the MCAP file and set schema.id to a generated schema id. The schema id is used when adding channels to the file. | |
void | addChannel (Channel &channel) |
Add a new channel to the MCAP file and set channel.id to a generated channel id. The channel id is used when adding messages to the file. | |
Status | write (const Message &message) |
Write a message to the output stream. | |
Status | write (Attachment &attachment) |
Write an attachment to the output stream. | |
Status | write (const Metadata &metadata) |
Write a metadata record to the output stream. | |
const Statistics & | statistics () const |
Current MCAP file-level statistics. This is written as a Statistics record in the Summary section of the MCAP file. | |
IWritable * | dataSink () |
Returns a pointer to the IWritable data destination backing this writer. Will return nullptr if the writer is not open. | |
void | closeLastChunk () |
finishes the current chunk in progress and writes it to the file, if a chunk is in progress. | |
Static Public Member Functions | |
static void | writeMagic (IWritable &output) |
static uint64_t | write (IWritable &output, const Header &header) |
static uint64_t | write (IWritable &output, const Footer &footer, bool crcEnabled) |
static uint64_t | write (IWritable &output, const Schema &schema) |
static uint64_t | write (IWritable &output, const Channel &channel) |
static uint64_t | getRecordSize (const Message &message) |
static uint64_t | write (IWritable &output, const Message &message) |
static uint64_t | write (IWritable &output, const Attachment &attachment) |
static uint64_t | write (IWritable &output, const Metadata &metadata) |
static uint64_t | write (IWritable &output, const Chunk &chunk) |
static uint64_t | write (IWritable &output, const MessageIndex &index) |
static uint64_t | write (IWritable &output, const ChunkIndex &index) |
static uint64_t | write (IWritable &output, const AttachmentIndex &index) |
static uint64_t | write (IWritable &output, const MetadataIndex &index) |
static uint64_t | write (IWritable &output, const Statistics &stats) |
static uint64_t | write (IWritable &output, const SummaryOffset &summaryOffset) |
static uint64_t | write (IWritable &output, const DataEnd &dataEnd) |
static uint64_t | write (IWritable &output, const Record &record) |
static void | write (IWritable &output, const std::string_view str) |
static void | write (IWritable &output, const ByteArray bytes) |
static void | write (IWritable &output, OpCode value) |
static void | write (IWritable &output, uint16_t value) |
static void | write (IWritable &output, uint32_t value) |
static void | write (IWritable &output, uint64_t value) |
static void | write (IWritable &output, const std::byte *data, uint64_t size) |
static void | write (IWritable &output, const KeyValueMap &map, uint32_t size=0) |
Private Member Functions | |
IWritable & | getOutput () |
IChunkWriter * | getChunkWriter () |
void | writeChunk (IWritable &output, IChunkWriter &chunkData) |
Private Attributes | |
McapWriterOptions | options_ {""} |
uint64_t | chunkSize_ = DefaultChunkSize |
IWritable * | output_ = nullptr |
std::unique_ptr< FileWriter > | fileOutput_ |
std::unique_ptr< StreamWriter > | streamOutput_ |
std::unique_ptr< BufferWriter > | uncompressedChunk_ |
std::unique_ptr< LZ4Writer > | lz4Chunk_ |
std::unique_ptr< ZStdWriter > | zstdChunk_ |
std::vector< Schema > | schemas_ |
std::vector< Channel > | channels_ |
std::vector< AttachmentIndex > | attachmentIndex_ |
std::vector< MetadataIndex > | metadataIndex_ |
std::vector< ChunkIndex > | chunkIndex_ |
Statistics | statistics_ {} |
std::unordered_set< SchemaId > | writtenSchemas_ |
std::unordered_map< ChannelId, MessageIndex > | currentMessageIndex_ |
Timestamp | currentChunkStart_ = MaxTime |
Timestamp | currentChunkEnd_ = 0 |
Compression | compression_ = Compression::None |
uint64_t | uncompressedSize_ = 0 |
bool | opened_ = false |
mcap::McapWriter::~McapWriter | ( | ) |
Definition at line 302 of file writer.inl.
void mcap::McapWriter::addChannel | ( | Channel & | channel | ) |
Add a new channel to the MCAP file and set channel.id
to a generated channel id. The channel id is used when adding messages to the file.
Channels are not cleared when the state is reset via close
() or terminate
(). If you're re-using a writer for multiple files in a row, the channels only need to be added once, before first use.
This method does not de-duplicate channels.
channel | Description of the channel to register. The id value is ignored and will be set to a generated channel id. |
Definition at line 520 of file writer.inl.
void mcap::McapWriter::addSchema | ( | Schema & | schema | ) |
Add a new schema to the MCAP file and set schema.id
to a generated schema id. The schema id is used when adding channels to the file.
Schemas are not cleared when the state is reset via close
() or terminate
(). If you're re-using a writer for multiple files in a row, the schemas only need to be added once, before first use.
This method does not de-duplicate schemas.
schema | Description of the schema to register. The id field is ignored and will be set to a generated schema id. |
Definition at line 515 of file writer.inl.
void mcap::McapWriter::close | ( | ) |
Write the MCAP footer, flush pending writes to the output stream, and reset internal state. The writer may be re-used with another call to open afterwards.
Definition at line 373 of file writer.inl.
void mcap::McapWriter::closeLastChunk | ( | ) |
finishes the current chunk in progress and writes it to the file, if a chunk is in progress.
Definition at line 362 of file writer.inl.
IWritable * mcap::McapWriter::dataSink | ( | ) |
Returns a pointer to the IWritable data destination backing this writer. Will return nullptr if the writer is not open.
Definition at line 697 of file writer.inl.
|
private |
Definition at line 722 of file writer.inl.
|
private |
Definition at line 703 of file writer.inl.
|
static |
Definition at line 906 of file writer.inl.
void mcap::McapWriter::open | ( | IWritable & | writer, |
const McapWriterOptions & | options | ||
) |
Open a new MCAP file for writing and write the header.
If the writer was already opened, this calls close
() first to reset the state. A writer may be re-used after being reset via close
() or terminate
().
writer | An implementation of the IWritable interface. Output bytes will be written to this object. |
options | Options for MCAP writing. profile is required. |
Definition at line 306 of file writer.inl.
void mcap::McapWriter::open | ( | std::ostream & | stream, |
const McapWriterOptions & | options | ||
) |
Open a new MCAP file for writing and write the header.
stream | Output stream to write to. |
options | Options for MCAP writing. profile is required. |
Definition at line 355 of file writer.inl.
Status mcap::McapWriter::open | ( | std::string_view | filename, |
const McapWriterOptions & | options | ||
) |
Open a new MCAP file for writing and write the header.
If the writer was already opened, this calls close
() first to reset the state. A writer may be re-used after being reset via close
() or terminate
().
filename | Filename of the MCAP file to write. |
options | Options for MCAP writing. profile is required. |
Definition at line 342 of file writer.inl.
const Statistics & mcap::McapWriter::statistics | ( | ) | const |
Current MCAP file-level statistics. This is written as a Statistics record in the Summary section of the MCAP file.
Definition at line 693 of file writer.inl.
void mcap::McapWriter::terminate | ( | ) |
Reset internal state without writing the MCAP footer or flushing pending writes. This should only be used in error cases as the output MCAP file will be truncated. The writer may be re-used with another call to open afterwards.
Definition at line 486 of file writer.inl.
Status mcap::McapWriter::write | ( | Attachment & | attachment | ) |
Write an attachment to the output stream.
attachment | Attachment to add. The attachment.crc will be calculated and set if configuration options allow CRC calculation. |
Definition at line 617 of file writer.inl.
Write a message to the output stream.
msg | Message to add. |
Definition at line 525 of file writer.inl.
Write a metadata record to the output stream.
metadata | Named group of key/value string pairs to add. |
Definition at line 665 of file writer.inl.
|
static |
Definition at line 924 of file writer.inl.
|
static |
Definition at line 1021 of file writer.inl.
Definition at line 1126 of file writer.inl.
Definition at line 887 of file writer.inl.
Definition at line 953 of file writer.inl.
|
static |
Definition at line 988 of file writer.inl.
Definition at line 1103 of file writer.inl.
|
static |
Definition at line 853 of file writer.inl.
Definition at line 842 of file writer.inl.
|
static |
Definition at line 1151 of file writer.inl.
Definition at line 910 of file writer.inl.
|
static |
Definition at line 971 of file writer.inl.
Definition at line 941 of file writer.inl.
|
static |
Definition at line 1043 of file writer.inl.
Definition at line 1113 of file writer.inl.
Definition at line 871 of file writer.inl.
|
static |
Definition at line 1057 of file writer.inl.
Definition at line 1147 of file writer.inl.
|
static |
Definition at line 1121 of file writer.inl.
|
static |
Definition at line 1089 of file writer.inl.
Definition at line 1131 of file writer.inl.
|
static |
Definition at line 1135 of file writer.inl.
|
static |
Definition at line 1139 of file writer.inl.
|
static |
Definition at line 1143 of file writer.inl.
|
private |
Definition at line 742 of file writer.inl.
|
static |
Definition at line 838 of file writer.inl.
|
private |
Definition at line 493 of file writer.hpp.
|
private |
Definition at line 492 of file writer.hpp.
|
private |
Definition at line 495 of file writer.hpp.
|
private |
Definition at line 480 of file writer.hpp.
|
private |
Definition at line 501 of file writer.hpp.
|
private |
Definition at line 500 of file writer.hpp.
Definition at line 499 of file writer.hpp.
|
private |
Definition at line 498 of file writer.hpp.
|
private |
Definition at line 482 of file writer.hpp.
|
private |
Definition at line 486 of file writer.hpp.
|
private |
Definition at line 494 of file writer.hpp.
|
private |
Definition at line 503 of file writer.hpp.
|
private |
Definition at line 479 of file writer.hpp.
|
private |
Definition at line 481 of file writer.hpp.
|
private |
Definition at line 491 of file writer.hpp.
|
private |
Definition at line 496 of file writer.hpp.
|
private |
Definition at line 483 of file writer.hpp.
|
private |
Definition at line 484 of file writer.hpp.
|
private |
Definition at line 502 of file writer.hpp.
|
private |
Definition at line 497 of file writer.hpp.
|
private |
Definition at line 489 of file writer.hpp.