mstar.engine.resources.kv.bounded.layout

mstar.engine.resources.kv.bounded.layout#

Host-side layout of one row of a bounded KV step.

A row’s retained keys are at most five contiguous ranges, in stream order: the sink’s source part, the sink’s written part, the window’s source part and the window’s ring (two ranges when it wraps). Its writes are at most three: the sink’s unfilled part and the ring (again two when it wraps). Each is a (start, length) pair in the source or the slot, so a step’s layout is a small integer table, and the kernels need nothing else.

Functions

flatten_row(slot, layout[, source])

row_layout(source_len, written, span, ...[, ...])

The reads and writes of a row whose stream holds source_len + written entries and gains span this step.

Classes

RowLayout(reads, writes, span)

class mstar.engine.resources.kv.bounded.layout.RowLayout(reads, writes, span)[source]#

Bases: NamedTuple

Parameters:
reads: tuple[tuple[int, int], ...]#

Alias for field number 0

span: int#

Alias for field number 2

writes: tuple[tuple[int, int, int], ...]#

Alias for field number 1

mstar.engine.resources.kv.bounded.layout.flatten_row(slot, layout, source=0)[source]#
Parameters:
Return type:

list[int]

mstar.engine.resources.kv.bounded.layout.row_layout(source_len, written, span, policy, sink_capacity, reverse=False)[source]#

The reads and writes of a row whose stream holds source_len + written entries and gains span this step. Slot offsets put the sink’s written part at [0, sink_capacity) and the ring after it. With reverse a step’s tokens join the stream last-first (see BoundedKVConfig).

Parameters:
Return type:

RowLayout