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 IsOrdinal(raw []byte) bool
- func Key(prefix string) string
- func MemoryBound() (resident, open int64)
- func VisitOrdinal(raw []byte, binding [32]byte, count int, visit func(int64) bool) error
- 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 OrdinalWriter
- type Reader
Constants ¶
const ( // PagedOrdinalMagic identifies ordinal watermarks with packed, independently seekable pages. PagedOrdinalMagic = 0x534d4150 // SMAP. // PagedWriterScratch accounts for one input page and its temporary encoded bytes. PagedWriterScratch = 2 * ordinalPageRows * 8 )
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 IsOrdinal ¶ added in v0.56.0
IsOrdinal identifies the legacy or packed coverage encodings bound to a part.
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.
func VisitOrdinal ¶ added in v0.56.0
VisitOrdinal validates a complete sidecar and visits timestamps in SIDX order.
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 OrdinalWriter ¶ added in v0.56.0
type OrdinalWriter struct {
// contains filtered or unexported fields
}
OrdinalWriter writes legacy or packed watermarks in SIDX order. The paged layout is magic, packed deltas, directory, then the bound ordinal footer. Each directory entry contains a payload-relative offset, base, and width.
func OpenOrdinalWriter ¶ added in v0.56.0
func OpenOrdinalWriter(ctx context.Context, b backend.Backend, key string, paged bool) (*OrdinalWriter, error)
OpenOrdinalWriter starts a manifest-bound sidecar in the requested encoding.
func (*OrdinalWriter) Abort ¶ added in v0.56.0
func (w *OrdinalWriter) Abort()
Abort discards an uncommitted object and returns writer scratch.
func (*OrdinalWriter) Append ¶ added in v0.56.0
func (w *OrdinalWriter) Append(ctx context.Context, timestamp int64) error
Append writes an exact covered timestamp.
func (*OrdinalWriter) Commit ¶ added in v0.56.0
Commit closes the object with its page directory, binding, count and checksum.
func (*OrdinalWriter) DirectoryBytes ¶ added in v0.56.0
func (w *OrdinalWriter) DirectoryBytes() int64
DirectoryBytes accounts for the packed page directory retained until commit.
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.