storage

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PageSize = 16 * 1024
)

Variables

View Source
var (
	ErrCorrupt          = errors.New("meldbase storage: corrupt database")
	ErrLocked           = errors.New("meldbase storage: database is locked")
	ErrRecoveryRequired = errors.New("meldbase storage: recovery required")
)
View Source
var (
	ErrNoSpace        = errors.New("meldbase storage: record page has no space")
	ErrStaleRecordID  = errors.New("meldbase storage: stale record id")
	ErrRecordTooLarge = errors.New("meldbase storage: record exceeds page capacity")
)

Functions

func Open

func Open(path string) (*File, []byte, Meta, error)

func OpenBlobs

func OpenBlobs(path string) (*File, []Blob, Meta, error)

func OpenBlobsWithOptions

func OpenBlobsWithOptions(path string, options OpenOptions) (*File, []Blob, Meta, OpenReport, error)

func OpenBlobsWithReport

func OpenBlobsWithReport(path string) (*File, []Blob, Meta, OpenReport, error)

Types

type Blob

type Blob struct {
	Kind  uint8
	Class BlobClass
	Data  []byte
}

type BlobClass

type BlobClass uint8
const (
	BlobClassRecord BlobClass = iota
	BlobClassIndex
)

type File

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

func (*File) Checkpoint

func (f *File) Checkpoint(token uint64, snapshot []byte) error

func (*File) CheckpointBlobs

func (f *File) CheckpointBlobs(token uint64, blobs []Blob) error

func (*File) Close

func (f *File) Close() error

type Meta

type Meta struct {
	DatabaseID      [16]byte
	Generation      uint64
	RootPage        uint64
	PageCount       uint32
	CheckpointToken uint64
}

type OpenOptions

type OpenOptions struct{ RequireClean bool }

type OpenReport

type OpenReport struct {
	Created                bool
	SelectedMetaSlot       uint8
	ValidMetaSlots         uint8
	MetaRedundancyDegraded bool
	TrailingBytesRemoved   uint64
	FreePageReuseDegraded  bool
}

OpenReport records bounded recovery actions performed by OpenBlobsWithReport. It deliberately excludes paths and snapshot contents.

type RecordID

type RecordID struct {
	Page       uint64
	Slot       uint16
	Generation uint32
}

RecordID never aliases a reused slot: deleting a record advances the slot's generation before that slot can be allocated again.

type RecordPage

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

RecordPage is a slotted 16 KiB document page. Its binary form packs record bodies from the header upward and the fixed-size slot directory downward.

func DecodeIndexPage

func DecodeIndexPage(page []byte, expectedPageID uint64) (*RecordPage, error)

func DecodeRecordPage

func DecodeRecordPage(page []byte, expectedPageID uint64) (*RecordPage, error)

func NewIndexPageAt

func NewIndexPageAt(pageID, generation, lsn uint64) *RecordPage

func NewRecordPage

func NewRecordPage(pageID uint64) *RecordPage

func NewRecordPageAt

func NewRecordPageAt(pageID, generation, lsn uint64) *RecordPage

func (*RecordPage) Delete

func (p *RecordPage) Delete(id RecordID) error

func (*RecordPage) FreeBytes

func (p *RecordPage) FreeBytes() int

func (*RecordPage) Generation

func (p *RecordPage) Generation() uint64

func (*RecordPage) Get

func (p *RecordPage) Get(id RecordID) ([]byte, error)

func (*RecordPage) Insert

func (p *RecordPage) Insert(record []byte) (RecordID, error)

func (*RecordPage) LSN

func (p *RecordPage) LSN() uint64

func (*RecordPage) MarshalBinary

func (p *RecordPage) MarshalBinary() ([]byte, error)

func (*RecordPage) PageID

func (p *RecordPage) PageID() uint64

func (*RecordPage) Update

func (p *RecordPage) Update(id RecordID, record []byte) error

Directories

Path Synopsis
Package v2 contains the experimental Meldbase Storage V2 page format.
Package v2 contains the experimental Meldbase Storage V2 page format.

Jump to

Keyboard shortcuts

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