Skip to content

Append records with segment rolling by size #3

@mairinkdev

Description

@mairinkdev

Summary

Implement basic append: write full record frames (header + payload + checksum) to the current segment. When the segment reaches a configured max size (segment_max_bytes), roll to a new segment. Support sequential scan to read back appended records (no index yet).

Scope

  • Log::append(payload) (or equivalent): encode record (header + payload + checksum), append to current segment file.
  • Segment roll: when current segment size would exceed segment_max_bytes, close current segment and open next (base_offset = next offset). Configurable segment_max_bytes.
  • Sequential scan: iterate records from a given segment (or from first segment) in order; decode and yield (offset, payload) or error on corruption (checksum validation can be Day 5; here decoding is enough).
  • Tests: append N records; scan and assert order and content; append until roll, then scan across segment boundary and assert continuity of offsets and payloads.

Acceptance criteria

  • Append is append-only; offsets are monotonic across segment rolls.
  • Scan reads back exactly what was appended, in order.
  • Segment roll triggers at configured size; no record is split across segments.

Suggested commit

feat: append records with segment rolling

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions