struct C0::Stream::Reader

Overview

Scans a buffer for ETB commit markers and exposes only the committed region. Zero-copy: all accessors return slices into the original buffer.

reader = C0::Stream::Reader.new(buf) reader.torn? # => true if an uncommitted tail trails reader.each_record { |rec| ... } # committed records only

Defined in:

c0/stream.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(buf : Bytes) #

[View source]
def self.read(path : Path | String) : Reader #

Read a log file into a Reader.


[View source]

Instance Method Detail

def block(i : Int32) : Bytes #

Committed block by index: the bytes between the previous commit and this block's ETB (marker and payload excluded).


[View source]
def block_count : Int32 #

Number of committed blocks.


[View source]
def buf : Bytes #

[View source]
def committed : Bytes #

The committed region of the buffer.


[View source]
def committed_end : Int32 #

Offset just past the last commit marker and its payload. Zero if the buffer contains no commits.


[View source]
def each_block(& : Bytes -> ) : Nil #

Iterate committed blocks.


[View source]
def each_record(& : Record -> ) : Nil #

Iterate committed records.


[View source]
def table : Table #

The committed region as a Table (handles an optional GS name and SOH header, then RS records).


[View source]
def tail : Bytes #

Uncommitted trailing bytes — residue of an interrupted append.


[View source]
def torn? : Bool #

True if uncommitted bytes trail the last commit marker.


[View source]