Documentation
¶
Overview ¶
Package watermark encodes a part's per-series durability watermark sidecar: the newest timestamp each series has in that part.
Both engines write it beside the part at flush and merge, and a replica refresh reads it instead of decoding the part's whole timestamp column. It is the same shape in both — the record engine's streams are signal.SeriesID too — so the codec lives here rather than twice.
Index ¶
- Constants
- Variables
- func Encode(dst []byte, entries []Entry) []byte
- func EncodeEntries(dst []byte, count int, entry func(int) Entry) []byte
- func Key(prefix string) string
- func MemoryBound() (resident, open int64)
- func WriteCheckedEntries(ctx context.Context, b backend.Backend, key string, count int, ...) error
- func WriteEntries(ctx context.Context, b backend.Backend, key string, count int, ...) error
- type Cursor
- type Entry
- type Reader
Constants ¶
const OrdinalMagic = 0x534d414f // SMAO.
OrdinalMagic identifies a watermark sidecar whose IDs come from the associated SIDX.
Variables ¶
var ErrCorrupt = errors.New("watermark: corrupt sidecar")
ErrCorrupt marks an unreadable sidecar. A reader treats it like an absent one and falls back to decoding the timestamp column.
var ErrUnbounded = errors.New("watermark: bounded reads unavailable")
ErrUnbounded means a backend cannot validate the sidecar through bounded reads.
Functions ¶
func Encode ¶
Encode serializes the entries in the caller's order: [magic][uvarint n] then per entry [u64 id.Hi][u64 id.Lo][i64 max], all big-endian, with a trailing CRC32C. Encode appends, and the checksum covers only the bytes it appended — whatever dst already held is not part of the record.
func EncodeEntries ¶ added in v0.55.0
EncodeEntries appends a sidecar without materializing a parallel entry slice.
func Key ¶
Key is the backend key of a part's watermark sidecar (deleted with the part, since a part is removed by listing its prefix).
func MemoryBound ¶ added in v0.55.0
func MemoryBound() (resident, open int64)
MemoryBound prices a reader/cursor pair and sequential validation, including ranged-read copies.
Types ¶
type Cursor ¶ added in v0.55.0
type Cursor struct {
// contains filtered or unexported fields
}
Cursor reuses one bounded window of a validated immutable watermark sidecar.
func (*Cursor) At ¶ added in v0.55.0
At reads an ordinal, retaining its page for subsequent ordinals.
type Reader ¶ added in v0.55.0
type Reader struct {
// contains filtered or unexported fields
}
Reader retains validated framing, without retaining per-series entries.
func OpenBoundReader ¶ added in v0.55.0
func OpenBoundReader(ctx context.Context, b backend.Backend, key string, count int, binding [32]byte) (*Reader, error)
OpenBoundReader accepts both legacy watermarks and manifest-bound SIDX ordinals.
func OpenReader ¶ added in v0.55.0
OpenReader validates the checksum and sorted IDs with at most 32 KiB of scratch.
func (*Reader) Cursor ¶ added in v0.55.0
Cursor creates an operation-local reader with at most 32 KiB of scratch.
func (*Reader) Lookup ¶ added in v0.55.0
Lookup reads one series' covered timestamp without decoding other entries.