sstable

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidMagic = errors.New("error invalid magic")

Functions

This section is empty.

Types

type Block

type Block struct {
	Offset uint64
	Length uint64
}

type Data

type Data struct {
	Entries []*internalpb.Entry
}

Data Block

func (*Data) Decode

func (d *Data) Decode(data []byte) error

func (*Data) Encode

func (d *Data) Encode() ([]byte, error)

func (*Data) Scan

func (d *Data) Scan(start, end types.Key) []*internalpb.Entry

func (*Data) Search

func (d *Data) Search(key types.Key) (*internalpb.Entry, bool)
type Footer struct {
	MetaBlock  Block
	IndexBlock Block
	Magic      uint64
}

Footer 16 + 16 + 8 = 40 bytes

func (*Footer) Decode

func (f *Footer) Decode(footer []byte) error

func (*Footer) Encode

func (f *Footer) Encode() ([]byte, error)

type Index

type Index struct {
	// Block of all data blocks of this sstable
	DataBlock Block
	Entries   []IndexEntry
}

Index block stores the first and last key of each Data Block,

func Build

func Build(entries []*internalpb.Entry, dataBlockSize, level int) (Index, []byte, error)

func (*Index) Decode

func (i *Index) Decode(index []byte) error

func (*Index) Encode

func (i *Index) Encode() ([]byte, error)

func (*Index) Scan

func (i *Index) Scan(start, end types.Key) []Block

func (*Index) Search

func (i *Index) Search(key types.Key) (Block, bool)

Search data block included the key

type IndexEntry

type IndexEntry struct {
	// StartKey of each Data block
	StartKey string
	// EndKey of each Data block
	EndKey string
	// offset and length of each data block
	DataHandle Block
}

IndexEntry include index of a sstable data block

type Meta

type Meta struct {
	CreatedUnix int64
	Level       uint64
}

Meta Block

func (*Meta) Decode

func (m *Meta) Decode(data []byte) error

func (*Meta) Encode

func (m *Meta) Encode() ([]byte, error)

type SSTable

type SSTable struct {
	DataBlocks []Data
	MetaBlock  Meta
	IndexBlock Index
	Footer     Footer
}

Jump to

Keyboard shortcuts

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