irisdb

package module
v0.0.0-...-b23e58e Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyExtension     = ".key"
	ValExtension     = ".val"
	BloomExtension   = ".bf"
	WalExtension     = ".wal"
	SSTABLEExtesnion = ".sst"
	DBExtension      = ".irisdb"
	MagicNumber      = 0xAB75DE95
)

Variables

View Source
var (
	Fsync            = true
	SyncInterval     = 100 * time.Millisecond
	PageSize         = 4096
	Compression      = true
	Wal              = true
	Flag             = os.O_CREATE | os.O_RDWR
	Permission       = 0644
	FalsePostiveProb = 0.01
	DBName           = "irisdb"
	MemTableSize     = 64 * 1024
	AvgKeySize       = 16
	SstableSize      = 128 * 1024 // size of sstable in level 0
	SizeMultiple     = 5          // SizeLevel(i) = Multiple * SizeLevel(i-1)
	TOMPOSTONE       = []byte{0xFD, 0xFE, 0xFA, 0xF9}
	MaxLevels        = 6
)

Functions

This section is empty.

Types

type Block

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

func DeserializeBlock

func DeserializeBlock(buf bytes.Buffer) *Block

func (*Block) SerializeBlock

func (b *Block) SerializeBlock(buf bytes.Buffer)

type HeapItem

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

type IndexBlock

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

func DeserializeIndex

func DeserializeIndex(buf bytes.Buffer) *IndexBlock

func (*IndexBlock) SerializeIndex

func (i *IndexBlock) SerializeIndex(buf bytes.Buffer)

type IndexEntry

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

type IrisDB

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

func OpenDB

func OpenDB(dbPath string) (*IrisDB, error)

func (*IrisDB) Read

func (db *IrisDB) Read(key []byte) ([]byte, error)

TODO: avoid suddenly flush when read

type LogEntry

type LogEntry struct {
	Op    byte // Operation type
	Key   []byte
	Value []byte
}

Single Wal Entry

type MinHeap

type MinHeap []*HeapItem

func (MinHeap) Len

func (h MinHeap) Len() int

func (MinHeap) Less

func (h MinHeap) Less(i, j int) bool

func (*MinHeap) Pop

func (h *MinHeap) Pop() any

func (*MinHeap) Push

func (h *MinHeap) Push(x any)

func (MinHeap) Swap

func (h MinHeap) Swap(i, j int)

type SSTABLE

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

func NewSSTABLE

func NewSSTABLE(level int) (*SSTABLE, error)

type SSTMergeIterator

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

Merge N sstables

func NewSSTMergeIterator

func NewSSTMergeIterator(sstables []*SSTABLE, level int) *SSTMergeIterator

func (*SSTMergeIterator) CreateSST

func (smi *SSTMergeIterator) CreateSST() ([]*SSTABLE, error)

func (*SSTMergeIterator) Next

func (smi *SSTMergeIterator) Next() ([]byte, int, error)

type WAL

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

func NewWal

func NewWal(name string, pageSize uint16, fsync bool, syncInterval time.Duration) (*WAL, error)

NewWal creates a new Write-Ahead Log

func (*WAL) Close

func (w *WAL) Close() error

Close closes the WAL

func (*WAL) Read

func (w *WAL) Read(pageNum uint16) (*LogEntry, error)

func (*WAL) Replay

func (w *WAL) Replay(fn func(*LogEntry) error) error

Replay replays all WAL entries using an iterator

func (*WAL) Write

func (w *WAL) Write(entry *LogEntry) (uint32, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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