Documentation
¶
Overview ¶
Package bucketindex maintains a compact, incremental index of the immutable parts under a key prefix, so a stateless reader enumerates a tenant's parts (and prunes them by time) from a single object instead of a full, expensive bucket LIST (DESIGN.md §11, the object-store-native read path). The index is itself a backend object, rewritten as parts are added by flush/merge and removed by retention.
The on-disk form is a small, versioned binary blob (see Index.AppendBinary / Decode); it is fuzzed for decode safety and golden-tested for format stability.
Index ¶
Constants ¶
const Object = "bucket-index.bin"
Object is the conventional backend key, relative to a prefix, under which the index is stored. Callers join it with the tenant/signal prefix, e.g. "default/metrics/" + Object.
Variables ¶
var ErrCorrupt = errors.New("bucketindex: corrupt index")
ErrCorrupt is returned (wrapped) by Decode for malformed input.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
Entry describes one immutable part: its key prefix (the part's object-group root, e.g. "default/metrics/0000000001") and the inclusive unix-nanosecond time range of its samples, used to prune parts that cannot intersect a query window.
type Index ¶
type Index struct {
Entries []Entry
// FlushedEpoch is the highest WAL flush generation durably persisted in these parts (0 if
// unused). It is the watermark a record engine reads on recovery to skip WAL records a part
// already holds — advanced atomically with the part list, so exactly-once replay survives a
// crash between a flush committing and its WAL being truncated. Added in format v2.
FlushedEpoch uint64
}
Index is the set of parts under a prefix, kept sorted by Entry.Prefix. The zero value is a valid empty index.
func Decode ¶
Decode parses the binary encoding produced by Index.AppendBinary. It is defensive against truncated/malformed input (it is fuzzed).
func Load ¶
Load reads the index stored under key from b. A missing object is reported as an empty index (the read path starts before any flush has written one).
func (*Index) Add ¶
Add inserts e, replacing any existing entry with the same prefix, keeping the index sorted.
func (*Index) AppendBinary ¶
AppendBinary appends the versioned binary encoding of the index to dst (append-style for buffer reuse).
func (*Index) Overlapping ¶
Overlapping returns, in index order, the parts whose time range intersects the inclusive window [start, end]. It is the read-path prune: only these parts need to be opened.