mergestream

package
v0.50.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mergestream holds the pieces a streaming merge needs in both the metric and the record engine: the k-way key union, the two-unit memory budget, and the forward-cursor contract. Each engine keeps its own merge driver; only what they would otherwise each invent lives here.

Index

Constants

View Source
const DefaultPartCeiling int64 = 16 << 30

DefaultPartCeiling is the maximum merged part size when no ceiling is configured.

View Source
const MinPartCap int64 = 8 << 20

MinPartCap keeps low free space from excluding every existing part from compaction.

Variables

View Source
var ErrNotForward = errors.New("row range cannot be read forward-only")

ErrNotForward reports a row range a forward-only cursor cannot serve.

Functions

func CheckForward

func CheckForward(pos, start, end int) error

CheckForward verifies that the row range [start, end) can be read by a forward-only cursor that has already consumed every row below pos. Skipping forward is fine — the cursor discards the gap — but a range that begins behind pos, or ends before it begins, needs a reader that can seek backwards and so fails with an error wrapping ErrNotForward.

func PartCap added in v0.49.2

func PartCap(ctx context.Context, be backend.Backend, ceiling int64, fanout int) (int64, error)

PartCap derives a disk seal threshold from free space and the concurrent writer count. A negative ceiling disables disk sealing. An error still returns the configured ceiling.

Types

type Budget

type Budget struct {
	DiskBytes     int64
	ResidentBytes int64
}

Budget is the pair of limits a merge seals an output part on. The units are not interchangeable and neither bounds the other: DiskBytes is the size the part reaches encoded on the backend, ResidentBytes what the merge holds in RAM while building it — per-key state that grows with distinct keys rather than with encoded bytes. A limit of zero or less does not bound the merge.

func (Budget) Bounded

func (b Budget) Bounded() bool

Bounded reports whether the budget seals at all.

func (Budget) Reached

func (b Budget) Reached(disk, resident int64) bool

Reached reports whether an output part of the given encoded and resident size has met a limit.

type Keys

type Keys struct {
	// contains filtered or unexported fields
}

Keys yields the ascending union of several Source key sequences through a k-way heap, so a merge visits each key once without ever holding a set of them: the state is O(sources), not O(distinct keys), and no key is hashed or sorted.

The zero value is ready to Keys.Reset; a reset reuses the heap, so a reused Keys allocates nothing per traversal.

func (*Keys) Append

func (k *Keys) Append(dst []signal.SeriesID) []signal.SeriesID

Append drains the remaining union onto dst.

func (*Keys) Key

func (k *Keys) Key() signal.SeriesID

Key returns the key Keys.Next last advanced to.

func (*Keys) Next

func (k *Keys) Next() bool

Next advances to the next distinct key, reporting false once every source is exhausted.

func (*Keys) Reset

func (k *Keys) Reset(src []Source)

Reset arms k over src, discarding any traversal in progress. Each source must be ascending.

type SeriesIDs

type SeriesIDs []signal.SeriesID

SeriesIDs adapts an ascending id slice to Source.

func (SeriesIDs) At

func (s SeriesIDs) At(i int) signal.SeriesID

At implements Source.

func (SeriesIDs) Len

func (s SeriesIDs) Len() int

Len implements Source.

type Source

type Source interface {
	// Len returns how many keys the source holds.
	Len() int
	// At returns the i-th key.
	At(i int) signal.SeriesID
}

Source is one merge input's key sequence, ascending and addressed by index. Repeated keys are allowed; Keys collapses them.

Directories

Path Synopsis
Package mergestreamtest is the conformance suite for a streaming merge: the invariants both engines must hold, expressed once so neither tests them its own way.
Package mergestreamtest is the conformance suite for a streaming merge: the invariants both engines must hold, expressed once so neither tests them its own way.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL