Documentation
¶
Index ¶
- Variables
- func BuildApplyPlanFromEntries(entries []Entry, hasDeleteRanges bool) ([]Entry, []DeleteRange)
- func DeleteRangeContainsKey(r DeleteRange, key []byte) bool
- func DeleteRangeOverlapsSpan(r DeleteRange, low, high []byte) bool
- func DeleteRangesContainKey(ranges []DeleteRange, key []byte) bool
- func IsDeleteRangeNoop(start, end []byte) bool
- func Release(b *Batch)
- type Batch
- func (b *Batch) AppendDeleteViewTrustedSortedUnique(key []byte) error
- func (b *Batch) AppendDeleteViewTrustedSortedUniqueWithRevision(key []byte, revision page.EntryRevision) error
- func (b *Batch) AppendPointerViewNoTouchTrustedSorted(key []byte, ptr page.ValuePtr)
- func (b *Batch) AppendPointerViewNoTouchTrustedSortedWithRevision(key []byte, ptr page.ValuePtr, revision page.EntryRevision)
- func (b *Batch) AppendPointerViewTrustedSortedUnique(key []byte, ptr page.ValuePtr) error
- func (b *Batch) AppendPointerViewTrustedSortedUniqueWithRevision(key []byte, ptr page.ValuePtr, revision page.EntryRevision) error
- func (b *Batch) AppendViewTrustedSortedUnique(key, value []byte) error
- func (b *Batch) AppendViewTrustedSortedUniqueWithRevision(key, value []byte, revision page.EntryRevision) error
- func (b *Batch) ApplyPlan() ([]Entry, []DeleteRange)
- func (b *Batch) AssignLegacyPointRevisions(revision page.EntryRevision) page.EntryRevision
- func (b *Batch) ByteSize() int
- func (b *Batch) Close() error
- func (b *Batch) Delete(key []byte) error
- func (b *Batch) DeleteRange(start, end []byte) error
- func (b *Batch) DeleteRangeView(start, end []byte) error
- func (b *Batch) DeleteView(key []byte) error
- func (b *Batch) DeleteViewWithRevision(key []byte, revision page.EntryRevision) error
- func (b *Batch) DeleteWithRevision(key []byte, revision page.EntryRevision) error
- func (b *Batch) EntriesCap() int
- func (b *Batch) HasDeleteRanges() bool
- func (b *Batch) HasValueLogPointers() bool
- func (b *Batch) IsEmpty() bool
- func (b *Batch) Len() int
- func (b *Batch) MaxPointRevision() page.EntryRevision
- func (b *Batch) NoteTouchedValueLogFileID(fileID uint32)
- func (b *Batch) Ops() map[string]Entry
- func (b *Batch) OrderedEntries() []Entry
- func (b *Batch) PointRevisionStats() (page.EntryRevision, bool)
- func (b *Batch) Replay(fn func(Entry) error) error
- func (b *Batch) Reserve(n int)
- func (b *Batch) Reset()
- func (b *Batch) Set(key, value []byte) error
- func (b *Batch) SetInlineThresholdResolver(resolver func([]byte) int)
- func (b *Batch) SetOps(ops []Entry) error
- func (b *Batch) SetPointer(key []byte, ptr page.ValuePtr) error
- func (b *Batch) SetPointerView(key []byte, ptr page.ValuePtr) error
- func (b *Batch) SetPointerViewNoTouch(key []byte, ptr page.ValuePtr) error
- func (b *Batch) SetPointerViewNoTouchWithRevision(key []byte, ptr page.ValuePtr, revision page.EntryRevision) error
- func (b *Batch) SetPointerViewWithRevision(key []byte, ptr page.ValuePtr, revision page.EntryRevision) error
- func (b *Batch) SetPointerWithRevision(key []byte, ptr page.ValuePtr, revision page.EntryRevision) error
- func (b *Batch) SetView(key, value []byte) error
- func (b *Batch) SetViewWithRevision(key, value []byte, revision page.EntryRevision) error
- func (b *Batch) SetWithRevision(key, value []byte, revision page.EntryRevision) error
- func (b *Batch) SortedEntries() []Entry
- func (b *Batch) TouchedValueLogSegments() []uint32
- type DeleteRange
- type Entry
- type Interface
- type OpType
- type ValueReader
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BuildApplyPlanFromEntries ¶ added in v0.6.0
func BuildApplyPlanFromEntries(entries []Entry, hasDeleteRanges bool) ([]Entry, []DeleteRange)
BuildApplyPlanFromEntries canonicalizes an ordered mixed operation stream into sorted final point ops and merged range tombstones over the base tree.
func DeleteRangeContainsKey ¶ added in v0.6.0
func DeleteRangeContainsKey(r DeleteRange, key []byte) bool
DeleteRangeContainsKey reports whether key is inside r's half-open range.
func DeleteRangeOverlapsSpan ¶ added in v0.6.0
func DeleteRangeOverlapsSpan(r DeleteRange, low, high []byte) bool
DeleteRangeOverlapsSpan reports whether r intersects the half-open child span [low, high). Nil high means unbounded upper; nil r bounds are unbounded.
func DeleteRangesContainKey ¶ added in v0.6.0
func DeleteRangesContainKey(ranges []DeleteRange, key []byte) bool
DeleteRangesContainKey reports whether key is covered by any merged or unmerged range in ranges.
func IsDeleteRangeNoop ¶ added in v0.6.0
IsDeleteRangeNoop reports whether [start,end) cannot delete any valid TreeDB key. Nil means unbounded; a non-nil end <= non-nil start is empty/reversed.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch accumulates writes and deletes before committing them.
func Acquire ¶
func Acquire(reader ValueReader, threshold int) *Batch
Acquire returns a reusable Batch from the pool.
func AcquireRetainingLargeEntries ¶ added in v0.6.0
func AcquireRetainingLargeEntries(reader ValueReader, threshold int) *Batch
AcquireRetainingLargeEntries returns a reusable Batch from the large-entry pool. See NewRetainingLargeEntries.
func NewRetainingLargeEntries ¶ added in v0.6.0
func NewRetainingLargeEntries(reader ValueReader, threshold int) *Batch
NewRetainingLargeEntries returns a batch from a separate pool that can retain larger entry slices. Use this only for repeated internal materializations with known large entry counts; ordinary batches should use New/Acquire.
func (*Batch) AppendDeleteViewTrustedSortedUnique ¶ added in v0.6.0
AppendDeleteViewTrustedSortedUnique records a Delete without copying key bytes or invalidating sorted/compacted state. Nil keys are canonicalized to the empty key. Caller must guarantee key remains immutable until commit/close, and appended keys are strictly increasing with no duplicates.
func (*Batch) AppendDeleteViewTrustedSortedUniqueWithRevision ¶ added in v0.6.1
func (b *Batch) AppendDeleteViewTrustedSortedUniqueWithRevision(key []byte, revision page.EntryRevision) error
func (*Batch) AppendPointerViewNoTouchTrustedSorted ¶ added in v0.4.0
AppendPointerViewNoTouchTrustedSorted appends a pointer Put without input validation, touched-segment tracking, or key-order checks. Caller must guarantee: batch is open, key is canonicalized if nil, ptr is a value-log pointer, and appended keys are already non-decreasing.
func (*Batch) AppendPointerViewNoTouchTrustedSortedWithRevision ¶ added in v0.6.1
func (*Batch) AppendPointerViewTrustedSortedUnique ¶ added in v0.6.0
AppendPointerViewTrustedSortedUnique records a pointer Put without copying key bytes or invalidating sorted/compacted state. Nil keys are canonicalized to the empty key. Caller must guarantee key remains immutable until commit/close, ptr is a value-log pointer, and appended keys are strictly increasing with no duplicates.
func (*Batch) AppendPointerViewTrustedSortedUniqueWithRevision ¶ added in v0.6.1
func (*Batch) AppendViewTrustedSortedUnique ¶ added in v0.6.0
AppendViewTrustedSortedUnique records a Put without copying key/value bytes or invalidating the sorted/compacted state. Nil keys/values are canonicalized to zero-length byte strings. Caller must guarantee key/value remain immutable until commit/close, and appended keys are strictly increasing with no duplicates.
func (*Batch) AppendViewTrustedSortedUniqueWithRevision ¶ added in v0.6.1
func (b *Batch) AppendViewTrustedSortedUniqueWithRevision(key, value []byte, revision page.EntryRevision) error
func (*Batch) ApplyPlan ¶ added in v0.6.0
func (b *Batch) ApplyPlan() ([]Entry, []DeleteRange)
ApplyPlan canonicalizes an ordered mixed batch into sorted final point ops and merged range tombstones over the base tree. The point-only SortedEntries path remains allocation-free and is preferred when HasDeleteRanges is false.
func (*Batch) AssignLegacyPointRevisions ¶ added in v0.6.1
func (b *Batch) AssignLegacyPointRevisions(revision page.EntryRevision) page.EntryRevision
AssignLegacyPointRevisions assigns revision to point entries that do not already carry explicit revision metadata. It returns the maximum point revision observed after assignment.
func (*Batch) DeleteRange ¶ added in v0.6.0
DeleteRange records a half-open range delete [start, end). Nil bounds are unbounded. Empty or reversed bounded ranges are no-ops.
func (*Batch) DeleteRangeView ¶ added in v0.6.0
DeleteRangeView records a range delete without copying bound bytes. Callers must treat start/end as immutable until the batch is committed or closed.
func (*Batch) DeleteView ¶
DeleteView is an internal-performance helper that records a Delete without copying the key bytes. Callers must treat key as immutable until the batch is committed (Write/WriteSync) or closed.
func (*Batch) DeleteViewWithRevision ¶ added in v0.6.1
func (b *Batch) DeleteViewWithRevision(key []byte, revision page.EntryRevision) error
func (*Batch) DeleteWithRevision ¶ added in v0.6.1
func (b *Batch) DeleteWithRevision(key []byte, revision page.EntryRevision) error
func (*Batch) EntriesCap ¶ added in v0.4.0
EntriesCap returns the current capacity of the internal entry buffer.
func (*Batch) HasDeleteRanges ¶ added in v0.6.0
HasDeleteRanges reports whether this batch contains any non-empty range deletes. Point-only callers can keep using SortedEntries' compacted fast path.
func (*Batch) HasValueLogPointers ¶ added in v0.4.0
HasValueLogPointers reports whether this batch contains any value-log pointer operations.
func (*Batch) IsEmpty ¶ added in v0.6.0
IsEmpty reports whether the batch currently has no queued operations.
func (*Batch) MaxPointRevision ¶ added in v0.6.1
func (b *Batch) MaxPointRevision() page.EntryRevision
MaxPointRevision returns the highest explicit point-entry revision without mutating the batch.
func (*Batch) NoteTouchedValueLogFileID ¶ added in v0.4.0
NoteTouchedValueLogFileID is an internal helper that records a touched value-log segment without appending a batch entry.
func (*Batch) Ops ¶
Ops returns the map of operations. WARNING: This constructs the map on demand. Duplicate keys in the batch are resolved so the last one wins.
func (*Batch) OrderedEntries ¶ added in v0.6.0
OrderedEntries returns the submission-order operation stream. The returned slice aliases batch-owned storage and must be treated as read-only.
func (*Batch) PointRevisionStats ¶ added in v0.6.1
func (b *Batch) PointRevisionStats() (page.EntryRevision, bool)
PointRevisionStats returns the highest point-entry revision and whether any point entry is still legacy-versioned.
func (*Batch) Reserve ¶ added in v0.2.0
Reserve grows internal buffers to accommodate roughly n entries without reallocation. It is intended as a best-effort performance hint for high-throughput internal callers (e.g. flush).
func (*Batch) Reset ¶
func (b *Batch) Reset()
Reset clears the batch for reuse without releasing its internal buffers.
func (*Batch) SetInlineThresholdResolver ¶ added in v0.4.0
SetInlineThresholdResolver installs an optional per-key threshold resolver used by Set/SetView/SetOps inline-size checks.
func (*Batch) SetPointer ¶
SetPointer adds a pointer directly to the batch (used by Compaction).
func (*Batch) SetPointerView ¶ added in v0.2.0
SetPointerView is an internal-performance helper that records a pointer Put without copying the key bytes. Callers must treat key as immutable until the batch is committed (Write/WriteSync) or closed.
This is intentionally not part of the public batch.Interface; it is a best-effort optimization used by higher-level layers (e.g. cached flush streaming).
func (*Batch) SetPointerViewNoTouch ¶ added in v0.4.0
SetPointerViewNoTouch is an internal-performance helper that records a pointer Put without copying key bytes and without tracking touched value-log segments. Callers must separately provide touched segment hints when commit publication needs them.
func (*Batch) SetPointerViewNoTouchWithRevision ¶ added in v0.6.1
func (*Batch) SetPointerViewWithRevision ¶ added in v0.6.1
func (*Batch) SetPointerWithRevision ¶ added in v0.6.1
func (*Batch) SetView ¶
SetView is an internal-performance helper that records a Put without copying key/value bytes. Callers must treat key/value as immutable until the batch is committed (Write/WriteSync) or closed.
func (*Batch) SetViewWithRevision ¶ added in v0.6.1
func (b *Batch) SetViewWithRevision(key, value []byte, revision page.EntryRevision) error
func (*Batch) SetWithRevision ¶ added in v0.6.1
func (b *Batch) SetWithRevision(key, value []byte, revision page.EntryRevision) error
func (*Batch) SortedEntries ¶
SortedEntries returns the operations sorted by key. Duplicate keys are resolved (last write wins). This modifies the internal entries slice (sorts and compacts). The returned slice aliases batch-owned storage and must be treated as read-only. It remains valid only until the batch is mutated, reset, released, or closed.
func (*Batch) TouchedValueLogSegments ¶ added in v0.4.0
TouchedValueLogSegments reports the value-log segments that were touched by pointer puts in this batch. The returned slice is sorted for deterministic commit/publish behavior.
In the small-set fast path, the returned slice aliases internal batch storage and remains valid only until the batch is mutated, reset, or released. Callers must treat the result as read-only.
type DeleteRange ¶ added in v0.6.0
DeleteRange describes a half-open range delete [Start, End). Nil Start or End are unbounded on that side.
func MergeDeleteRanges ¶ added in v0.6.0
func MergeDeleteRanges(ranges []DeleteRange) []DeleteRange
MergeDeleteRanges returns sorted, non-overlapping ranges equivalent to the union of ranges. It does not copy bound bytes; callers must keep them alive.
type Entry ¶
type Entry struct {
Type OpType
Key []byte // Put/Delete key, or DeleteRange start bound (nil means unbounded)
Value []byte // Inline value, or DeleteRange exclusive end bound (nil means unbounded)
ValuePtr page.ValuePtr // For large values
IsPtr bool // True if ValuePtr is valid
Revision page.EntryRevision
}
Entry represents a single operation in the batch.
type Interface ¶
type Interface interface {
Set(key, value []byte) error
Delete(key []byte) error
DeleteRange(start, end []byte) error
SetOps(ops []Entry) error
Write() error
WriteSync() error
Close() error
Replay(func(Entry) error) error
GetByteSize() (int, error)
}
Interface defines the contract for a batch operation.