Reads the last complete lines of a byte region without scanning it from the start.
The region is a file being appended to by the CLI. Lines are delimited by 0x0A; because no byte of a multi-byte UTF-8 sequence is ever 0x0A, splitting on the raw byte never severs a character, so each line's byte slice decodes as UTF-8 independently. A single trailing \r is stripped so a CRLF-terminated line reads the same as an LF-terminated one.
Torn-final-line rule: bytes after the last 0x0A in the region are a line whose terminating newline has not been written yet — a live append in progress — and are excluded from the tail. A region that ends exactly on a newline (or on a previous page's cursor, which is always a line start) has no such remainder.
Blocks are read backward from the region end, only far enough to expose the requested number of complete lines, so cost is proportional to the page, not the region.
Signals that scanning back from the region end reached scannedBytes without exposing enough line boundaries to bound the requested page. The region carries a line longer than the scan budget, so it is corrupt or oversized and cannot be paged.
Signals that scanning back from the region end reached scannedBytes without exposing enough line boundaries to bound the requested page. The region carries a line longer than the scan budget, so it is corrupt or oversized and cannot be paged.
Attributes
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Tail(lines: Vector[String], older: Option[Long])
A page of trailing lines.
A page of trailing lines.
Value parameters
lines
the complete lines nearest the region end, in file order (oldest first), each without its terminating newline or a trailing \r
older
the byte offset at which the oldest returned line starts, when older lines remain before it; None when the oldest line starts at byte 0 or no line was returned. Feed it back as the next call's regionEnd.
Extracts up to limit complete lines ending at regionEnd.
Extracts up to limit complete lines ending at regionEnd.
Value parameters
blockSize
how many bytes to pull per backward read; must be positive
limit
maximum number of lines to return; a non-positive value yields an empty tail
maxScanBytes
the most bytes the backward scan may buffer before giving up; a region whose page needs more than this yields ScanBudgetExceeded rather than reading unbounded bytes
readBlock
a pure view of the underlying append-only file returning the bytes in [offset, offset + length); the reader only ever asks for ranges within [0, regionEnd)
regionEnd
exclusive upper byte bound of the region to read (the file size for the newest page, or a previous Tail.older cursor for an older page)
Attributes
Returns
the page of trailing lines, or ScanBudgetExceeded when the scan budget was reached before the page's boundaries were found
A conservative default scan-back budget: a page read never buffers more than this many bytes looking for its line boundaries. A well-formed JSONL transcript's lines are far smaller than this, so only a corrupt or oversized-line region ever hits it.
A conservative default scan-back budget: a page read never buffers more than this many bytes looking for its line boundaries. A well-formed JSONL transcript's lines are far smaller than this, so only a corrupt or oversized-line region ever hits it.