memtable

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendOnlyEntryPoolDropTotal added in v0.6.0

func AppendOnlyEntryPoolDropTotal() uint64

func AppendOnlyValueArenaPoolDropTotal added in v0.6.0

func AppendOnlyValueArenaPoolDropTotal() uint64

func DropAppendOnlyEntryPools added in v0.6.0

func DropAppendOnlyEntryPools()

DropAppendOnlyEntryPools abandons package-level append-only entry slice pools. It is intended for cold transitions away from append-only mutable memtables, where retaining restore-sized warm buffers hurts steady-state RSS more than it helps near-term reuse.

func DropAppendOnlyValueArenaPools added in v0.6.0

func DropAppendOnlyValueArenaPools()

DropAppendOnlyValueArenaPools abandons package-level append-only value-arena chunk pools. Per-memtable active/retained arenas are unaffected.

Types

type AppendOnly added in v0.4.0

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

func NewAppendOnlyWithCapacity added in v0.4.0

func NewAppendOnlyWithCapacity(capacity int) *AppendOnly

func NewAppendOnlyWithCapacityEstimatedEntryBytes added in v0.4.0

func NewAppendOnlyWithCapacityEstimatedEntryBytes(capacity, estimatedBytesPerEntry int) *AppendOnly

func NewAppendOnlyWithEntryCapacity added in v0.6.0

func NewAppendOnlyWithEntryCapacity(entries int) *AppendOnly

NewAppendOnlyWithEntryCapacity creates an append-only table sized for an expected entry count instead of a byte-capacity estimate.

func (*AppendOnly) ApplyCopySortedBatchTrusted added in v0.6.0

func (m *AppendOnly) ApplyCopySortedBatchTrusted(entries []batchpkg.Entry, borrowValues bool, storeInlinePtrValues bool, onKey func(key []byte)) bool

func (*AppendOnly) ApplyCopySortedBatchWithValueCopierTrusted added in v0.6.0

func (m *AppendOnly) ApplyCopySortedBatchWithValueCopierTrusted(entries []batchpkg.Entry, copyValue func(value []byte) []byte, storeInlinePtrValues bool, onKey func(key []byte)) bool

func (*AppendOnly) ApplyStealEntryFunc added in v0.6.0

func (m *AppendOnly) ApplyStealEntryFunc(count int, emit func(i int) (key, value []byte, ptr page.ValuePtr, flags byte, err error)) error

func (*AppendOnly) ApplyStealEntryFuncWithRevision added in v0.6.1

func (m *AppendOnly) ApplyStealEntryFuncWithRevision(count int, emit func(i int) (key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision, err error)) error

func (*AppendOnly) ApplyStealSortedBatch added in v0.4.0

func (m *AppendOnly) ApplyStealSortedBatch(entries []batchpkg.Entry, onKey func(key []byte))

func (*AppendOnly) ApplyStealSortedBatchTrusted added in v0.4.0

func (m *AppendOnly) ApplyStealSortedBatchTrusted(entries []batchpkg.Entry, onKey func(key []byte))

func (*AppendOnly) Delete added in v0.4.0

func (m *AppendOnly) Delete(key []byte)

func (*AppendOnly) DeleteKeyParts added in v0.6.0

func (m *AppendOnly) DeleteKeyParts(first, second []byte)

DeleteKeyParts stores a tombstone whose key is built from first+second and copied into table-owned storage.

func (*AppendOnly) DeleteSteal added in v0.4.0

func (m *AppendOnly) DeleteSteal(key []byte)

func (*AppendOnly) DeleteWithCallback added in v0.4.0

func (m *AppendOnly) DeleteWithCallback(key []byte, cb func(k, v []byte) error) error

func (*AppendOnly) EntryBackingBytes added in v0.6.0

func (m *AppendOnly) EntryBackingBytes() int64

EntryBackingBytes reports the retained backing bytes for entry slots.

func (*AppendOnly) EntryCapacity added in v0.6.0

func (m *AppendOnly) EntryCapacity() int

EntryCapacity reports the retained append-only entry-slot capacity.

func (*AppendOnly) Freeze added in v0.4.0

func (m *AppendOnly) Freeze()

func (*AppendOnly) Get added in v0.4.0

func (m *AppendOnly) Get(key []byte) ([]byte, bool, bool)

func (*AppendOnly) GetEntry added in v0.4.0

func (m *AppendOnly) GetEntry(key []byte) ([]byte, page.ValuePtr, byte, bool)

func (*AppendOnly) GetEntryWithRevision added in v0.6.1

func (m *AppendOnly) GetEntryWithRevision(key []byte) ([]byte, page.ValuePtr, byte, page.EntryRevision, bool)

func (*AppendOnly) Len added in v0.4.0

func (m *AppendOnly) Len() int

func (*AppendOnly) NewIterator added in v0.4.0

func (m *AppendOnly) NewIterator(start, end []byte) iterator.UnsafeIterator

func (*AppendOnly) NewReverseIterator added in v0.4.0

func (m *AppendOnly) NewReverseIterator(start, end []byte) iterator.UnsafeIterator

func (*AppendOnly) PreferSortedPointProbes added in v0.6.0

func (m *AppendOnly) PreferSortedPointProbes(first, last []byte, refCount int) bool

PreferSortedPointProbes reports whether a sorted batch of point probes should use individual GetEntry lookups instead of one iterator scan. Frozen append-only tables can answer point probes without locks; for sparse random batches this avoids scanning the gaps between sorted keys.

func (*AppendOnly) PutWithCallback added in v0.4.0

func (m *AppendOnly) PutWithCallback(key, value []byte, cb func(k, v []byte) error) error

func (*AppendOnly) Release added in v0.6.0

func (m *AppendOnly) Release()

Release returns large internal buffers to package pools when the table is no longer needed. Unlike Reset, it does not retain warm capacity on the table itself, so callers should only use it for short-lived tables they will drop.

func (*AppendOnly) ReleaseDropEntries added in v0.6.0

func (m *AppendOnly) ReleaseDropEntries()

ReleaseDropEntries releases the table without returning its entry backing slice to the package pool. Use this for cold paths where the caller does not expect near-term append-only reuse and wants to shed post-spike heap.

func (*AppendOnly) ReserveAdditionalEntries added in v0.6.0

func (m *AppendOnly) ReserveAdditionalEntries(additional int)

func (*AppendOnly) Reset added in v0.4.0

func (m *AppendOnly) Reset()

func (*AppendOnly) ResetDropEntries added in v0.6.0

func (m *AppendOnly) ResetDropEntries()

ResetDropEntries resets the table for reuse without retaining entry backing. The next write will allocate from the normal minimum append-only capacity.

func (*AppendOnly) ResetWithCapacity added in v0.4.0

func (m *AppendOnly) ResetWithCapacity(capacity, estimatedBytesPerEntry int)

ResetWithCapacity resets the memtable and, when needed, shrinks retained internal buffers toward the capacity-derived baseline. Unlike Reset, callers provide a capacity estimate so post-spike entry retention can decay.

func (*AppendOnly) ResetWithCapacityHard added in v0.4.0

func (m *AppendOnly) ResetWithCapacityHard(capacity, estimatedBytesPerEntry int)

ResetWithCapacityHard resets and clamps retained internal buffers to the capacity-derived baseline (without carrying over recent spike cardinality).

func (*AppendOnly) Set added in v0.4.0

func (m *AppendOnly) Set(key, value []byte)

func (*AppendOnly) SetEntry added in v0.4.0

func (m *AppendOnly) SetEntry(key, value []byte, ptr page.ValuePtr, flags byte)

func (*AppendOnly) SetEntryBorrowValue added in v0.4.0

func (m *AppendOnly) SetEntryBorrowValue(key, value []byte, ptr page.ValuePtr, flags byte)

func (*AppendOnly) SetEntryBorrowValueWithRevision added in v0.6.1

func (m *AppendOnly) SetEntryBorrowValueWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)

func (*AppendOnly) SetEntrySteal added in v0.4.0

func (m *AppendOnly) SetEntrySteal(key, value []byte, ptr page.ValuePtr, flags byte)

func (*AppendOnly) SetEntryStealWithRevision added in v0.6.1

func (m *AppendOnly) SetEntryStealWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)

func (*AppendOnly) SetEntryWithRevision added in v0.6.1

func (m *AppendOnly) SetEntryWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)

func (*AppendOnly) SetInlineNilKeyParts added in v0.6.0

func (m *AppendOnly) SetInlineNilKeyParts(first, second []byte)

SetInlineNilKeyParts stores an inline entry with a nil value and a key built from first+second. The key is copied into table-owned storage so callers can reuse or mutate both input slices after the call.

func (*AppendOnly) SetSteal added in v0.4.0

func (m *AppendOnly) SetSteal(key, value []byte)

func (*AppendOnly) Size added in v0.4.0

func (m *AppendOnly) Size() int64

func (*AppendOnly) StableUnsafeIteratorSlices added in v0.4.0

func (*AppendOnly) StableUnsafeIteratorSlices() bool

func (*AppendOnly) TrimEntryCapacity added in v0.6.0

func (m *AppendOnly) TrimEntryCapacity(maxEntries int) (before, after int64)

TrimEntryCapacity shrinks retained entry-slot backing while preserving active entries. It is intended for maintenance boundaries after a transient ingest spike has left a live append-only memtable with large unused capacity.

func (*AppendOnly) ValueArenaBackingStats added in v0.6.0

func (m *AppendOnly) ValueArenaBackingStats() AppendOnlyValueArenaStats

type AppendOnlyEntryPoolStats added in v0.6.0

type AppendOnlyEntryPoolStats struct {
	RetainedBytesEstimate    uint64
	RetainedBytesMaxEstimate uint64
	GetsTotal                uint64
	PutsTotal                uint64
	DropsTotal               uint64
	DropBytesTotal           uint64
	AdmissionDropsTotal      uint64
	AdmissionDropBytesTotal  uint64
}

func AppendOnlyEntryPoolStatsSnapshot added in v0.6.0

func AppendOnlyEntryPoolStatsSnapshot() AppendOnlyEntryPoolStats

type AppendOnlyEntryReserveStats added in v0.6.0

type AppendOnlyEntryReserveStats struct {
	CallsTotal               uint64
	EntriesTotal             uint64
	GrowCallsTotal           uint64
	GrowBytesTotal           uint64
	SkippedGrowthAllocsTotal uint64
	SkippedGrowthBytesTotal  uint64
}

func AppendOnlyEntryReserveStatsSnapshot added in v0.6.0

func AppendOnlyEntryReserveStatsSnapshot() AppendOnlyEntryReserveStats

type AppendOnlyValueArenaPoolStats added in v0.6.0

type AppendOnlyValueArenaPoolStats struct {
	RetainedBytesEstimate    uint64
	RetainedBytesMaxEstimate uint64
	GetsTotal                uint64
	PutsTotal                uint64
	DropsTotal               uint64
	DropBytesTotal           uint64
	AdmissionDropsTotal      uint64
	AdmissionDropBytesTotal  uint64
}

func AppendOnlyValueArenaPoolStatsSnapshot added in v0.6.0

func AppendOnlyValueArenaPoolStatsSnapshot() AppendOnlyValueArenaPoolStats

type AppendOnlyValueArenaStats added in v0.6.0

type AppendOnlyValueArenaStats struct {
	ActiveChunks   int64
	ActiveBytes    int64
	RetainedChunks int64
	RetainedBytes  int64
}

type BTree

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

func NewBTree

func NewBTree() *BTree

func NewBTreeWithDegree

func NewBTreeWithDegree(degree int) *BTree

func (*BTree) ApplyStealSortedBatch

func (m *BTree) ApplyStealSortedBatch(entries []batchpkg.Entry, onKey func(key []byte))

func (*BTree) Delete

func (m *BTree) Delete(key []byte)

func (*BTree) DeleteSteal

func (m *BTree) DeleteSteal(key []byte)

func (*BTree) DeleteWithCallback

func (m *BTree) DeleteWithCallback(key []byte, cb func(k, v []byte) error) error

func (*BTree) Freeze

func (m *BTree) Freeze()

func (*BTree) Get

func (m *BTree) Get(key []byte) ([]byte, bool, bool)

func (*BTree) GetEntry added in v0.2.0

func (m *BTree) GetEntry(key []byte) ([]byte, page.ValuePtr, byte, bool)

func (*BTree) GetEntryWithRevision added in v0.6.1

func (m *BTree) GetEntryWithRevision(key []byte) ([]byte, page.ValuePtr, byte, page.EntryRevision, bool)

func (*BTree) Len

func (m *BTree) Len() int

func (*BTree) NewIterator

func (m *BTree) NewIterator(start, end []byte) iterator.UnsafeIterator

func (*BTree) NewReverseIterator added in v0.4.0

func (m *BTree) NewReverseIterator(start, end []byte) iterator.UnsafeIterator

func (*BTree) PutWithCallback

func (m *BTree) PutWithCallback(key, value []byte, cb func(k, v []byte) error) error

func (*BTree) Reset

func (m *BTree) Reset()

Reset clears all entries while retaining internal allocations.

func (*BTree) Set

func (m *BTree) Set(key, value []byte)

func (*BTree) SetEntry added in v0.2.0

func (m *BTree) SetEntry(key, value []byte, ptr page.ValuePtr, flags byte)

func (*BTree) SetEntrySteal added in v0.2.0

func (m *BTree) SetEntrySteal(key, value []byte, ptr page.ValuePtr, flags byte)

func (*BTree) SetEntryStealWithRevision added in v0.6.1

func (m *BTree) SetEntryStealWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)

func (*BTree) SetEntryWithRevision added in v0.6.1

func (m *BTree) SetEntryWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)

func (*BTree) SetSteal

func (m *BTree) SetSteal(key, value []byte)

func (*BTree) Size

func (m *BTree) Size() int64

func (*BTree) StableUnsafeIteratorSlices added in v0.4.0

func (*BTree) StableUnsafeIteratorSlices() bool

type CopySortedBatchApplier added in v0.6.0

type CopySortedBatchApplier interface {
	ApplyCopySortedBatchTrusted(entries []batchpkg.Entry, borrowValues bool, storeInlinePtrValues bool, onKey func(key []byte)) (borrowedValues bool)
}

CopySortedBatchApplier is an optional fast path for callers that already guarantee strictly increasing keys but cannot transfer key ownership to the memtable. Implementations must copy keys into table-owned storage. When borrowValues is true, implementations may retain non-key value slices until the memtable is retired and must return true if they did so. Pointer entries receive inline value bytes only when storeInlinePtrValues is true.

type CopySortedBatchValueCopier added in v0.6.0

type CopySortedBatchValueCopier interface {
	ApplyCopySortedBatchWithValueCopierTrusted(entries []batchpkg.Entry, copyValue func(value []byte) []byte, storeInlinePtrValues bool, onKey func(key []byte)) (copiedValues bool)
}

CopySortedBatchValueCopier is an optional fast path for sorted batch callers that cannot retain caller-owned values but can provide an owner/lifetime-aware value copier. Implementations must still copy keys into table-owned storage. The copied value slices may be retained by the memtable until it is retired.

type EntryCapacityReserver added in v0.6.0

type EntryCapacityReserver interface {
	ReserveAdditionalEntries(additional int)
}

EntryCapacityReserver marks memtables that can pre-size entry metadata before a caller applies a known batch. It is a performance hint; implementations must preserve normal Set/Delete semantics if the hint is absent or conservative.

type HashSorted

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

func NewHashSorted

func NewHashSorted() *HashSorted

func NewHashSortedWithCapacityAndIndexer added in v0.3.0

func NewHashSortedWithCapacityAndIndexer(capacity int, indexer *HashSortedIndexer) *HashSorted

func NewHashSortedWithIndexer

func NewHashSortedWithIndexer(indexer *HashSortedIndexer) *HashSorted

func (*HashSorted) ApplyCopySortedBatchTrusted added in v0.6.0

func (m *HashSorted) ApplyCopySortedBatchTrusted(entries []batchpkg.Entry, borrowValues bool, storeInlinePtrValues bool, onKey func(key []byte)) bool

func (*HashSorted) ApplyStealSortedBatch

func (m *HashSorted) ApplyStealSortedBatch(entries []batchpkg.Entry, onKey func(key []byte))

func (*HashSorted) ApplyStealSortedBatchTrusted added in v0.4.0

func (m *HashSorted) ApplyStealSortedBatchTrusted(entries []batchpkg.Entry, onKey func(key []byte))

func (*HashSorted) Delete

func (m *HashSorted) Delete(key []byte)

func (*HashSorted) DeleteSteal

func (m *HashSorted) DeleteSteal(key []byte)

func (*HashSorted) DeleteWithCallback

func (m *HashSorted) DeleteWithCallback(key []byte, cb func(k, v []byte) error) error

func (*HashSorted) Freeze

func (m *HashSorted) Freeze()

func (*HashSorted) Get

func (m *HashSorted) Get(key []byte) ([]byte, bool, bool)

func (*HashSorted) GetEntry added in v0.2.0

func (m *HashSorted) GetEntry(key []byte) ([]byte, page.ValuePtr, byte, bool)

func (*HashSorted) GetEntryWithRevision added in v0.6.1

func (m *HashSorted) GetEntryWithRevision(key []byte) ([]byte, page.ValuePtr, byte, page.EntryRevision, bool)

func (*HashSorted) Len

func (m *HashSorted) Len() int

func (*HashSorted) NewIterator

func (m *HashSorted) NewIterator(start, end []byte) iterator.UnsafeIterator

func (*HashSorted) NewReverseIterator added in v0.4.0

func (m *HashSorted) NewReverseIterator(start, end []byte) iterator.UnsafeIterator

func (*HashSorted) PreferSortedPointProbes added in v0.6.0

func (m *HashSorted) PreferSortedPointProbes(first, last []byte, refCount int) bool

PreferSortedPointProbes reports whether a sorted batch of point probes should use individual hash lookups instead of one iterator scan. Frozen hash-sorted tables have stable maps; sparse random batches avoid scanning large key gaps.

func (*HashSorted) PutWithCallback

func (m *HashSorted) PutWithCallback(key, value []byte, cb func(k, v []byte) error) error

func (*HashSorted) Reset

func (m *HashSorted) Reset()

Reset clears all entries while retaining internal allocations.

func (*HashSorted) Set

func (m *HashSorted) Set(key, value []byte)

func (*HashSorted) SetEntry added in v0.2.0

func (m *HashSorted) SetEntry(key, value []byte, ptr page.ValuePtr, flags byte)

func (*HashSorted) SetEntrySteal added in v0.2.0

func (m *HashSorted) SetEntrySteal(key, value []byte, ptr page.ValuePtr, flags byte)

func (*HashSorted) SetEntryStealWithRevision added in v0.6.1

func (m *HashSorted) SetEntryStealWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)

func (*HashSorted) SetEntryWithRevision added in v0.6.1

func (m *HashSorted) SetEntryWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)

func (*HashSorted) SetSteal

func (m *HashSorted) SetSteal(key, value []byte)

func (*HashSorted) Size

func (m *HashSorted) Size() int64

func (*HashSorted) StableUnsafeIteratorSlices added in v0.4.0

func (*HashSorted) StableUnsafeIteratorSlices() bool

type HashSortedIndexer

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

HashSortedIndexer processes sealed key chunks in the background.

func NewHashSortedIndexer

func NewHashSortedIndexer() *HashSortedIndexer

func (*HashSortedIndexer) Close

func (x *HashSortedIndexer) Close()

Close stops the indexer after draining queued work.

type Iterator

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

Iterator wrapper

func (*Iterator) Close

func (it *Iterator) Close() error

func (*Iterator) Domain

func (it *Iterator) Domain() (start, end []byte)

func (*Iterator) Error

func (it *Iterator) Error() error

func (*Iterator) IsDeleted

func (it *Iterator) IsDeleted() bool

func (*Iterator) Key

func (it *Iterator) Key() []byte

func (*Iterator) KeyCopy

func (it *Iterator) KeyCopy(dst []byte) []byte

func (*Iterator) Next

func (it *Iterator) Next()

func (*Iterator) Seek

func (it *Iterator) Seek(key []byte)

func (*Iterator) UnsafeEntry

func (it *Iterator) UnsafeEntry() ([]byte, page.ValuePtr, byte)

func (*Iterator) UnsafeEntryWithRevision added in v0.6.1

func (it *Iterator) UnsafeEntryWithRevision() ([]byte, page.ValuePtr, byte, page.EntryRevision)

func (*Iterator) UnsafeKey

func (it *Iterator) UnsafeKey() []byte

func (*Iterator) UnsafeValue

func (it *Iterator) UnsafeValue() []byte

func (*Iterator) Valid

func (it *Iterator) Valid() bool

func (*Iterator) Value

func (it *Iterator) Value() []byte

func (*Iterator) ValueCopy

func (it *Iterator) ValueCopy(dst []byte) []byte

type KeyPartsWriter added in v0.6.0

type KeyPartsWriter interface {
	SetInlineNilKeyParts(first, second []byte)
	DeleteKeyParts(first, second []byte)
}

KeyPartsWriter marks memtables that can build and own common two-part keys without forcing callers to allocate a concatenated key slice first.

type Memtable

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

func New

func New() *Memtable

New creates a new Memtable (skiplist).

func NewWithCapacity

func NewWithCapacity(capacity int) *Memtable

NewWithCapacity creates a new Memtable with the requested arena capacity. A non-positive capacity uses a small default to keep rotations cheap.

func (*Memtable) ApplyStealSortedBatch

func (m *Memtable) ApplyStealSortedBatch(entries []batchpkg.Entry, onKey func(key []byte))

func (*Memtable) Delete

func (m *Memtable) Delete(key []byte)

func (*Memtable) DeleteSteal

func (m *Memtable) DeleteSteal(key []byte)

DeleteSteal - SkipList copies data, so Steal is same as Delete.

func (*Memtable) DeleteWithCallback

func (m *Memtable) DeleteWithCallback(key []byte, cb func(k, v []byte) error) error

func (*Memtable) Freeze

func (m *Memtable) Freeze()

func (*Memtable) Get

func (m *Memtable) Get(key []byte) ([]byte, bool, bool)

func (*Memtable) GetEntry added in v0.2.0

func (m *Memtable) GetEntry(key []byte) ([]byte, page.ValuePtr, byte, bool)

func (*Memtable) GetEntryWithRevision added in v0.6.1

func (m *Memtable) GetEntryWithRevision(key []byte) ([]byte, page.ValuePtr, byte, page.EntryRevision, bool)

func (*Memtable) Len

func (m *Memtable) Len() int

func (*Memtable) NewIterator

func (m *Memtable) NewIterator(start, end []byte) iterator.UnsafeIterator

func (*Memtable) NewReverseIterator added in v0.4.0

func (m *Memtable) NewReverseIterator(start, end []byte) iterator.UnsafeIterator

func (*Memtable) PutWithCallback

func (m *Memtable) PutWithCallback(key, value []byte, cb func(k, v []byte) error) error

func (*Memtable) Reset

func (m *Memtable) Reset()

Reset clears the memtable while retaining its arena capacity.

func (*Memtable) Set

func (m *Memtable) Set(key, value []byte)

func (*Memtable) SetEntry added in v0.2.0

func (m *Memtable) SetEntry(key, value []byte, ptr page.ValuePtr, flags byte)

func (*Memtable) SetEntrySteal added in v0.2.0

func (m *Memtable) SetEntrySteal(key, value []byte, ptr page.ValuePtr, flags byte)

SetEntrySteal - SkipList copies data, so Steal is same as SetEntry.

func (*Memtable) SetEntryStealWithRevision added in v0.6.1

func (m *Memtable) SetEntryStealWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)

func (*Memtable) SetEntryWithRevision added in v0.6.1

func (m *Memtable) SetEntryWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)

func (*Memtable) SetSteal

func (m *Memtable) SetSteal(key, value []byte)

SetSteal - SkipList copies data, so Steal is same as Set.

func (*Memtable) Size

func (m *Memtable) Size() int64

Size returns the total memory usage (arena size).

func (*Memtable) StableUnsafeIteratorSlices added in v0.4.0

func (*Memtable) StableUnsafeIteratorSlices() bool

type Mode

type Mode uint8
const (
	ModeSkiplist Mode = iota
	ModeHashSorted
	ModeBTree
	ModeAppendOnly
)

func ModeFromString

func ModeFromString(mode string) (Mode, error)

func (Mode) String

func (m Mode) String() string

type ReverseIterator added in v0.4.0

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

func (*ReverseIterator) Close added in v0.4.0

func (it *ReverseIterator) Close() error

func (*ReverseIterator) Domain added in v0.4.0

func (it *ReverseIterator) Domain() (start, end []byte)

func (*ReverseIterator) Error added in v0.4.0

func (it *ReverseIterator) Error() error

func (*ReverseIterator) IsDeleted added in v0.4.0

func (it *ReverseIterator) IsDeleted() bool

func (*ReverseIterator) Key added in v0.4.0

func (it *ReverseIterator) Key() []byte

func (*ReverseIterator) KeyCopy added in v0.4.0

func (it *ReverseIterator) KeyCopy(dst []byte) []byte

func (*ReverseIterator) Next added in v0.4.0

func (it *ReverseIterator) Next()

func (*ReverseIterator) Seek added in v0.4.0

func (it *ReverseIterator) Seek(key []byte)

func (*ReverseIterator) UnsafeEntry added in v0.4.0

func (it *ReverseIterator) UnsafeEntry() ([]byte, page.ValuePtr, byte)

func (*ReverseIterator) UnsafeEntryWithRevision added in v0.6.1

func (it *ReverseIterator) UnsafeEntryWithRevision() ([]byte, page.ValuePtr, byte, page.EntryRevision)

func (*ReverseIterator) UnsafeKey added in v0.4.0

func (it *ReverseIterator) UnsafeKey() []byte

func (*ReverseIterator) UnsafeValue added in v0.4.0

func (it *ReverseIterator) UnsafeValue() []byte

func (*ReverseIterator) Valid added in v0.4.0

func (it *ReverseIterator) Valid() bool

func (*ReverseIterator) Value added in v0.4.0

func (it *ReverseIterator) Value() []byte

func (*ReverseIterator) ValueCopy added in v0.4.0

func (it *ReverseIterator) ValueCopy(dst []byte) []byte

type RevisionStealEntryFuncApplier added in v0.6.1

type RevisionStealEntryFuncApplier interface {
	ApplyStealEntryFuncWithRevision(count int, emit func(i int) (key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision, err error)) error
}

RevisionStealEntryFuncApplier is the revision-preserving variant of StealEntryFuncApplier.

type RevisionStealTable added in v0.6.1

type RevisionStealTable interface {
	SetEntryStealWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)
}

RevisionStealTable is implemented by memtables that can accept caller-owned key/value buffers while preserving native entry revisions.

type RevisionTable added in v0.6.1

type RevisionTable interface {
	SetEntryWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)
	GetEntryWithRevision(key []byte) (val []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision, found bool)
}

RevisionTable is implemented by memtables that carry native entry revisions beside value/pointer/flags metadata.

type RevisionValueBorrower added in v0.6.1

type RevisionValueBorrower interface {
	SetEntryBorrowValueWithRevision(key, value []byte, ptr page.ValuePtr, flags byte, revision page.EntryRevision)
}

RevisionValueBorrower is the revision-preserving variant of ValueBorrower.

type SortedBatchApplier

type SortedBatchApplier interface {
	ApplyStealSortedBatch(entries []batchpkg.Entry, onKey func(key []byte))
}

SortedBatchApplier is an optional fast path for applying a strictly-increasing batch under a single memtable lock.

Callers should only use this when they know the entries are already in increasing key order.

type StableUnsafeIteratorTable added in v0.4.0

type StableUnsafeIteratorTable interface {
	StableUnsafeIteratorSlices() bool
}

StableUnsafeIteratorTable marks memtable implementations whose iterator.UnsafeIterator key/value views (from UnsafeKey/UnsafeValue/UnsafeEntry) are backed by storage that outlives the iterator itself.

Implementations returning true MUST ensure these views stay valid and immutable across Next/Seek and remain valid after Close, at least until the underlying memtable is reset or garbage-collected.

Callers such as buildOpRuns rely on this stronger contract to materialize immutable flush runs without per-entry defensive copies.

type StealEntryFuncApplier added in v0.6.0

type StealEntryFuncApplier interface {
	ApplyStealEntryFunc(count int, emit func(i int) (key, value []byte, ptr page.ValuePtr, flags byte, err error)) error
}

StealEntryFuncApplier is an optional fast path for building short-lived append-only tables by emitting owned entries under one table lock.

type Table

type Table interface {
	Set(key, value []byte)
	// SetEntry stores a value with explicit flags and optional value pointer.
	// When flags include node.FlagPointer, value may be nil and ptr must be set;
	// if value is non-nil it is stored alongside the pointer bytes.
	SetEntry(key, value []byte, ptr page.ValuePtr, flags byte)
	PutWithCallback(key, value []byte, cb func(k, v []byte) error) error
	Delete(key []byte)
	DeleteWithCallback(key []byte, cb func(k, v []byte) error) error
	SetSteal(key, value []byte)
	// SetEntrySteal is like SetEntry but allows stealing the provided value slice.
	SetEntrySteal(key, value []byte, ptr page.ValuePtr, flags byte)
	DeleteSteal(key []byte)
	Get(key []byte) ([]byte, bool, bool)
	// GetEntry returns the raw entry, including pointer and flags, if present.
	GetEntry(key []byte) (val []byte, ptr page.ValuePtr, flags byte, found bool)
	Size() int64
	Len() int
	// NewIterator may hold a read lock until Close; callers should avoid
	// iterating over mutable memtables on hot write paths.
	NewIterator(start, end []byte) iterator.UnsafeIterator
	// NewReverseIterator returns a reverse iterator over [start, end).
	// Like NewIterator, it may hold a read lock until Close.
	NewReverseIterator(start, end []byte) iterator.UnsafeIterator
	Freeze()
}

func NewWithCapacityMode

func NewWithCapacityMode(capacity int, mode Mode) (Table, error)

func NewWithCapacityModeAndIndexer

func NewWithCapacityModeAndIndexer(capacity int, mode Mode, indexer *HashSortedIndexer) (Table, error)

type TrustedSortedBatchApplier added in v0.4.0

type TrustedSortedBatchApplier interface {
	ApplyStealSortedBatchTrusted(entries []batchpkg.Entry, onKey func(key []byte))
}

TrustedSortedBatchApplier is an optional fast path for callers that already guarantee strictly increasing keys (for example, stream-qualified batch writes partitioned by shard while preserving source order).

type ValueBorrower added in v0.4.0

type ValueBorrower interface {
	SetEntryBorrowValue(key, value []byte, ptr page.ValuePtr, flags byte)
}

ValueBorrower marks memtables that can safely retain caller-owned value slices while still copying keys into their own storage.

Callers must keep the underlying value storage alive until the memtable is retired or reset.

Jump to

Keyboard shortcuts

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