vlog

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: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpSet    = byte(0)
	OpDelete = byte(1)

	// HeaderSize: CRC(4) + KeyLen(2) + ValueLen(4) + Op(1)
	HeaderSize = 11
)

Variables

View Source
var (
	ErrCorrupt        = errors.New("vlog: corrupt record")
	ErrRecordTooLarge = errors.New("vlog: record too large")
	ErrKeyTooLarge    = errors.New("vlog: key too large")
	ErrValueTooLarge  = errors.New("vlog: value too large")
)
View Source
var MaxDeadMappings = 64

MaxDeadMappings caps the number of old mmaps retained to avoid exhausting vm.max_map_count. Set <= 0 to disable the cap.

Functions

func ReadAt

func ReadAt(f *os.File, ptr page.ValuePtr, verifyCRC bool) ([]byte, error)

Types

type File

type File struct {
	ID       uint32
	Path     string
	File     *os.File
	RefCount atomic.Int64
	IsZombie atomic.Bool
	// contains filtered or unexported fields
}

File represents a value-log segment on disk.

func (*File) Close

func (f *File) Close() error

func (*File) Read

func (f *File) Read(ptr page.ValuePtr, verifyCRC bool) ([]byte, error)

func (*File) ReadUnsafe

func (f *File) ReadUnsafe(ptr page.ValuePtr, verifyCRC bool) ([]byte, error)

type Manager

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

func NewManager

func NewManager(dir string) (*Manager, error)

func (*Manager) Acquire

func (m *Manager) Acquire(set *Set)

Acquire increments the Set refcount (O(1)).

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) CurrentSet

func (m *Manager) CurrentSet() *Set

CurrentSet returns a snapshot of the current value-log files.

func (*Manager) MarkZombie

func (m *Manager) MarkZombie(id uint32) error

func (*Manager) Read

func (m *Manager) Read(ptr page.ValuePtr) ([]byte, error)

func (*Manager) ReadUnsafe

func (m *Manager) ReadUnsafe(ptr page.ValuePtr) ([]byte, error)

func (*Manager) Refresh

func (m *Manager) Refresh() error

Refresh scans the directory and registers any new segments.

func (*Manager) Release

func (m *Manager) Release(set *Set) error

Release decrements the Set refcount and removes zombie files once unpinned.

func (*Manager) RemapStats

func (m *Manager) RemapStats() (remaps uint64, deadMappings uint64)

RemapStats returns cumulative mmap remap counts across value-log files.

func (*Manager) RemoveSegment

func (m *Manager) RemoveSegment(id uint32) error

func (*Manager) SegmentPath

func (m *Manager) SegmentPath(id uint32) string

func (*Manager) SetDisableReadChecksum

func (m *Manager) SetDisableReadChecksum(disable bool)

type Reader

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

func NewReader

func NewReader(path string, fileID uint32) (*Reader, error)

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) DisableChecksum

func (r *Reader) DisableChecksum()

func (*Reader) ReadNext

func (r *Reader) ReadNext() (byte, []byte, []byte, page.ValuePtr, error)

type Record

type Record struct {
	Op    byte
	Key   []byte
	Value []byte
}

type Set

type Set struct {
	Files    map[uint32]*File
	RefCount atomic.Int64
	// contains filtered or unexported fields
}

Set is an immutable snapshot of value-log files for snapshot isolation.

func (*Set) Read

func (s *Set) Read(ptr page.ValuePtr) ([]byte, error)

func (*Set) ReadUnsafe

func (s *Set) ReadUnsafe(ptr page.ValuePtr) ([]byte, error)

type Writer

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

func NewWriter

func NewWriter(path string, fileID uint32) (*Writer, error)

func (*Writer) Append

func (w *Writer) Append(op byte, key, value []byte) (page.ValuePtr, error)

func (*Writer) AppendBatch

func (w *Writer) AppendBatch(records []Record) ([]page.ValuePtr, error)

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) FileID

func (w *Writer) FileID() uint32

func (*Writer) Flush

func (w *Writer) Flush() error

func (*Writer) RotateTo

func (w *Writer) RotateTo(path string, fileID uint32) error

func (*Writer) Size

func (w *Writer) Size() int64

func (*Writer) Sync

func (w *Writer) Sync() error

Jump to

Keyboard shortcuts

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