sst

package
v0.0.0-...-b5db292 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compact

func Compact(filenames []string, path string, recordsPerSst int, keysPerSegment int, removeDeleted bool) (string, error)

Compact performs a k-way merge of data from the given SST files under the given path.

The recordsPerSst parameter determines the maximum number of records written to each new SST file.

The removeDeleted parameter indicates whether tombstones will be permanently removed (true) or carried through to the new SST files (false).

Data must be sorted within each input SST file. That data is streamed from each file one entry at a time and added to a min heap. We then read from the heap to get the next sorted element and write it out to a new SST file.

This process is performed for all input data, generating a new set of SST files containing sorted and non-overlapping data.

Thus we can handle large files as only a small portion of data is kept in memory at once.

If there are any duplicate keys, only the most recent entry (IE largest sequence number) is written. Note this is only applicable to SST level 0 which contains SST files that may contain overlapping data.

func Create

func Create(filename string, keys []string, m map[string]SstEntry, seqNum uint64)

TODO: input is name of .bin file. write that and corresponding .index file Create creates a new SST file from given data

func DumpBin

func DumpBin(filename string)

func DumpIndex

func DumpIndex(filename string)

func Filenames

func Filenames(path string) []string

Filenames returns names of the SST binary files under path

func Find

func Find(key string, lvl []SstLevel, path string) ([]byte, bool)

func Levels

func Levels(path string) []string

Levels returns the names of any directories containing consolidated SST files at levels greater than level 0. This implies the data is organized in non-overlapping regions across files at that level.

func Load

func Load(filename string) ([]SstEntry, SstFileHeader)

TODO: input is name of .bin file. read that and corresponding .index file and load into memory

func NextFilename

func NextFilename(path string) string

NextFilename returns the name of the next SST binary file in given directory

func PathForLevel

func PathForLevel(base string, level int) string

func Remove

func Remove(filename string)

Delete SST file from disk

func RemoveAll

func RemoveAll(path string)

Delete all SST files from disk

Types

type SstEntry

type SstEntry struct {
	Key     string
	Value   []byte
	Deleted bool
}

func LoadBlock

func LoadBlock(filename string, start int, end int) []SstEntry

type SstFile

type SstFile struct {
	Filename string
	Filter   *bloom.Filter
	Index    []SstIndex
	Cache    []SstIndexData
}

func NewSstFile

func NewSstFile(path string, filename string, filter *bloom.Filter) SstFile

type SstFileHeader

type SstFileHeader struct {
	Seq uint64
}

type SstHeap

type SstHeap []*SstHeapNode

An min-heap of SST entries Provides an easy way to sort large numbers of entries

func (SstHeap) Len

func (h SstHeap) Len() int

func (SstHeap) Less

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

func (*SstHeap) Pop

func (h *SstHeap) Pop() interface{}

func (*SstHeap) Push

func (h *SstHeap) Push(x interface{})

func (SstHeap) Swap

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

type SstHeapNode

type SstHeapNode struct {
	Seq   uint64
	Entry *SstEntry
	File  *os.File
}

type SstIndex

type SstIndex struct {
	Key string
	// contains filtered or unexported fields
}

type SstIndexData

type SstIndexData struct {
	Data     []SstEntry // cached file contents
	CachedAt time.Time  // timestamp when cache was last accessed

}

type SstLevel

type SstLevel struct {
	Files []SstFile
}

Jump to

Keyboard shortcuts

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