Skip to content

Add BoisBufferWriter for buffered BOIS output paths#37

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/add-bois-buffer-writer
Draft

Add BoisBufferWriter for buffered BOIS output paths#37
Copilot wants to merge 2 commits intomasterfrom
copilot/add-bois-buffer-writer

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 29, 2026

This adds a dedicated BOIS writer with an 8KB staged cache for output targets that previously used direct array/stream writers. The new writer keeps buffered state across write calls, exposes explicit flush semantics, and routes large payloads without extra staging when the cache would not help.

  • New buffered writer

    • Adds Salar.Bois.Types.BoisBufferWriter : BufferWriterBase
    • Supports the existing constructor shapes used by BOIS serialization:
      • byte[]
      • byte[], int position, int length
      • Stream
    • Buffers writes into an internal 8 * 1024 cache
    • Exposes Flush() to publish buffered bytes to the final destination
  • Hot-path write behavior

    • Keeps primitive writes on fixed-size span-based paths to minimize overhead
    • Flushes only when the cache is full or when explicitly requested
    • Writes large ReadOnlySpan<byte> payloads directly to the underlying array/stream instead of copying them through the cache first
  • Serializer integration

    • Updates serializer overloads that construct writers internally to use BoisBufferWriter
    • Flushes before returning from serializer-managed array and stream outputs so callers see fully committed data
  • Coverage

    • Adds focused tests for:
      • explicit Flush() behavior
      • stream-backed serialization beyond the 8KB cache
      • byte-array-backed serialization beyond the 8KB cache
using var stream = new MemoryStream();
var writer = new BoisBufferWriter(stream);

writer.Write(new byte[] { 1, 2, 3, 4 });
// bytes are still buffered here

writer.Flush();
// bytes are now committed to the stream

Copilot AI and others added 2 commits March 29, 2026 12:53
Agent-Logs-Url: https://github.com/salarcode/Bois/sessions/76085ed5-08d1-4807-981c-8fcfe318a771

Co-authored-by: salarcode <1272095+salarcode@users.noreply.github.com>
Agent-Logs-Url: https://github.com/salarcode/Bois/sessions/76085ed5-08d1-4807-981c-8fcfe318a771

Co-authored-by: salarcode <1272095+salarcode@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants