Skip to content

feat(bag-writer): Use WriterConfig options for compression and chunk size #55

@zhexuany

Description

@zhexuany

Overview

The BagFormat::create_writer() method currently ignores the WriterConfig parameter and always creates a writer with default settings.

Current State

pub fn create_writer<P: AsRef<Path>>(
    path: P,
    _config: &crate::io::writer::WriterConfig,
) -> Result<Box<dyn crate::io::traits::FormatWriter>> {
    // For now, we create a simple writer
    // TODO: Use config options for compression, chunk size, etc.
    let writer = BagWriter::create(path)?;
    Ok(Box::new(writer))
}

Desired Behavior

Use the WriterConfig to configure:

  • Compression type: bz2, lz4, none
  • Chunk size: Size of each chunk (default: 768KB)
  • Chunk threshold: Messages per chunk before splitting

Example Implementation

pub fn create_writer<P: AsRef<Path>>(
    path: P,
    config: &crate::io::writer::WriterConfig,
) -> Result<Box<dyn crate::io::traits::FormatWriter>> {
    let compression = config.compression.as_deref().unwrap_or("bz2");
    let chunk_size = config.chunk_size.unwrap_or(768 * 1024);
    
    let writer = BagWriter::create_with_options(path, compression, chunk_size)?;
    Ok(Box::new(writer))
}

Files to Modify

  • src/io/formats/bag/parallel.rs - Update create_writer() method
  • src/io/formats/bag/writer.rs - Add create_with_options() method

Acceptance Criteria

  • Compression option is respected ("bz2", "lz4", "none")
  • Chunk size option is respected
  • Default values match historical ROS1 bag behavior
  • Tests verify each configuration option
  • Documentation is updated

Related Code

  • Location: src/io/formats/bag/parallel.rs:59
  • See also: WriterConfig definition in src/io/writer/mod.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions