memtable

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) Len

func (m *BTree) Len() int

func (*BTree) NewIterator

func (m *BTree) NewIterator(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) SetSteal

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

func (*BTree) Size

func (m *BTree) Size() int64

type HashSorted

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

func NewHashSorted

func NewHashSorted() *HashSorted

func NewHashSortedWithIndexer

func NewHashSortedWithIndexer(indexer *HashSortedIndexer) *HashSorted

func (*HashSorted) ApplyStealSortedBatch

func (m *HashSorted) ApplyStealSortedBatch(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) Len

func (m *HashSorted) Len() int

func (*HashSorted) NewIterator

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

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) SetSteal

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

func (*HashSorted) Size

func (m *HashSorted) Size() int64

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) 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 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) Len

func (m *Memtable) Len() int

func (*Memtable) NewIterator

func (m *Memtable) NewIterator(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) 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).

type Mode

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

func ModeFromString

func ModeFromString(mode string) (Mode, error)

func (Mode) String

func (m Mode) String() string

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 Table

type Table interface {
	Set(key, value []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)
	DeleteSteal(key []byte)
	Get(key []byte) ([]byte, bool, 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
	Freeze()
}

func NewWithCapacityMode

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

func NewWithCapacityModeAndIndexer

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

Jump to

Keyboard shortcuts

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