lsmt

package
v0.0.0-...-06fcf48 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: MIT Imports: 8 Imported by: 0

README

LSM-Tree

A simplified Golang implementation for log structured merge tree. Put and Get are supported. Compaction is also supported. Data is only stored in memory. Disk files are simulated by in-memory byte arrays. See https://eileen-code4fun.medium.com/log-structured-merge-tree-lsm-tree-implementations-a-demo-and-leveldb-d5e028257330 for a more elaborate documentation and how this compares to LevelDB.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Upsert

func Upsert(tree **TreeNode, elem Element)

Types

type DiskFile

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

func NewDiskFile

func NewDiskFile(elems []Element) DiskFile

func (DiskFile) AllElements

func (d DiskFile) AllElements() []Element

func (DiskFile) Empty

func (d DiskFile) Empty() bool

func (DiskFile) Search

func (d DiskFile) Search(key string) (Element, error)

type Element

type Element struct {
	Key, Value string
}

func Find

func Find(tree *TreeNode, key string) (Element, error)

func JustLarger

func JustLarger(tree *TreeNode, key string) (Element, error)

func JustSmallerOrEqual

func JustSmallerOrEqual(tree *TreeNode, key string) (Element, error)

func Traverse

func Traverse(tree *TreeNode) []Element

Traverse returns all the elements in key order.

type LSMTree

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

func NewLSMTree

func NewLSMTree(flushThreshold int) *LSMTree

func (*LSMTree) Get

func (t *LSMTree) Get(key string) (string, error)

func (*LSMTree) Put

func (t *LSMTree) Put(key, value string)

type TreeNode

type TreeNode struct {
	Elem  Element
	Left  *TreeNode
	Right *TreeNode
	Size  int
}

func NewTree

func NewTree(elems []Element) *TreeNode

NewTree accepts a sorted element slice and returns a binary tree representation.

Jump to

Keyboard shortcuts

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