mitkv

package module
v0.0.0-...-cbefa2a Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

README

mitkv

tool lsm tree kv database

Documentation

Index

Constants

View Source
const (
	// SET set cmd
	SET int = iota
	// GET get cmd
	GET
	// DEL cmd
	DEL
)

Variables

This section is empty.

Functions

func BytesToInt32

func BytesToInt32(bytes []byte) int32

BytesToInt32 byte转Float64

func BytesToInt64

func BytesToInt64(bytes []byte) int64

BytesToInt64 byte转Float64

func Int32ToBytes

func Int32ToBytes(bits int32) []byte

Int32ToBytes Float64 to byte

func Int64ToBytes

func Int64ToBytes(bits int64) []byte

Int64ToBytes Float64转byte

func Value2Str

func Value2Str(v interface{}) string

Value2Str interface val to str

Types

type Cmd

type Cmd struct {
	Key     string
	Val     string
	CmdType int
}

Cmd cmd

type KvStore

type KvStore interface {
	Set(key string, value string)
	Get(key string) (value string)
	Del(key string)
}

KvStore KvStore

type LSMKvStore

type LSMKvStore struct {
	Index          *avl.Tree // 内存表
	ImmutableIndex *avl.Tree // 不可变的内存表
	SstTables      *sll.List // sstTable列表
	DataDir        string    // 目录
	Lock           sync.RWMutex
	StoreThreshold int64
	PartSize       int64
	WalFile        *os.File
}

LSMKvStore LSMKvStore

func InitLSMKvStore

func InitLSMKvStore(dataDir string, storeThreshold int64, partSize int64) (lSMKvStore *LSMKvStore, err error)

InitLSMKvStore InitLSMKvStore

func (*LSMKvStore) Close

func (kv *LSMKvStore) Close()

Close close file data

func (*LSMKvStore) Del

func (kv *LSMKvStore) Del(key string)

Del del val

func (*LSMKvStore) Get

func (kv *LSMKvStore) Get(key string) (value string)

Get get val

func (*LSMKvStore) Set

func (kv *LSMKvStore) Set(key string, value string)

Set set data to db

type Position

type Position struct {
	Start int64
	Len   int64
}

Position position

type SSTTable

type SSTTable struct {
	MetaInfo    SSTTableMetaInfo
	SparseIndex *avl.Tree
	TableFile   *os.File
	FilePath    string
}

SSTTable ssttable

func CreateFromFile

func CreateFromFile(filePath string) (sst *SSTTable, err error)

CreateFromFile create

func CreateFromIndex

func CreateFromIndex(filePath string, partSize int, index avl.Tree) (sst *SSTTable, err error)

CreateFromIndex create

func InitSstTable

func InitSstTable(filePath string, partSize int) (sst *SSTTable, err error)

InitSstTable init

func (*SSTTable) Close

func (sst *SSTTable) Close()

Close close data

type SSTTableMetaInfo

type SSTTableMetaInfo struct {
	Version    int64 // 版本号
	DataStart  int64 // 数据区开始
	DataLen    int64 // 数据区长度
	IndexStart int64 // 索引区开始
	IndexLen   int64 // 索引区长度
	PartSize   int64 // 分段的大小
}

SSTTableMetaInfo sstTable的元数据

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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