TrainKV

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 20 Imported by: 0

README

TrainKV

TrainKV is a key-value store that uses LSM-trees to store data. It is designed to be fast, efficient, and easy to use.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RequestPool = sync.Pool{
	New: func() interface{} {
		return new(Request)
	},
}

Functions

This section is empty.

Types

type DBIterator

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

func (*DBIterator) Close

func (dbIter *DBIterator) Close() error

func (*DBIterator) Item

func (dbIter *DBIterator) Item() model.Item

func (*DBIterator) Next

func (dbIter *DBIterator) Next()

func (*DBIterator) Rewind

func (dbIter *DBIterator) Rewind()

func (*DBIterator) Seek

func (dbIter *DBIterator) Seek(key []byte)

func (*DBIterator) Valid

func (dbIter *DBIterator) Valid() bool

type Request

type Request struct {
	Entries []*model.Entry
	ValPtr  []*model.ValuePtr
	Wg      sync.WaitGroup
	Err     error
	// contains filtered or unexported fields
}

func (*Request) DecrRef

func (r *Request) DecrRef()

func (*Request) IncrRef

func (r *Request) IncrRef()

func (*Request) Reset

func (r *Request) Reset()

func (*Request) Wait

func (r *Request) Wait() error

type TrainKVDB

type TrainKVDB struct {
	Mux sync.Mutex
	Lsm *lsm.LSM

	Opt *lsm.Options

	VlogReplayHead model.ValuePtr

	Closer closer
	// contains filtered or unexported fields
}

func Open

func Open(opt *lsm.Options) (*TrainKVDB, error, func() error)

func (*TrainKVDB) BatchSet

func (db *TrainKVDB) BatchSet(entries []*model.Entry) error

BatchSet batch set entries 1. vlog GC组件调用, 目的是加速 有效key重新写;

func (*TrainKVDB) Close

func (db *TrainKVDB) Close() error

func (*TrainKVDB) Del

func (db *TrainKVDB) Del(key []byte, version int64) error

func (*TrainKVDB) Get

func (db *TrainKVDB) Get(key []byte) (model.Entry, error)

func (*TrainKVDB) NewDBIterator

func (db *TrainKVDB) NewDBIterator(opt *model.Options) *DBIterator

func (*TrainKVDB) RunValueLogGC

func (db *TrainKVDB) RunValueLogGC(discardRatio float64) error

func (*TrainKVDB) SendToWriteCh

func (db *TrainKVDB) SendToWriteCh(entries []*model.Entry) (*Request, error)

SendToWriteCh 发送数据到 db.writeCh 通道中; vlog 组件调用; 1. Re重放: openVlog() -> go vlog.flushDiscardStats(); 监听并收集vlog文件的GC信息, 必要时将序列化统计表数据, 发送到 db 的写通道中, 以便重启时可以直接获得; 2. GC重写: db.batchSet(); 批处理(加速vlog GC重写速度), 将多个 []entry 写到指定通道中;

func (*TrainKVDB) Set

func (db *TrainKVDB) Set(entry model.Entry) error

func (*TrainKVDB) ShouldWriteValueToLSM

func (db *TrainKVDB) ShouldWriteValueToLSM(entry model.Entry) bool

type VLogFileDisCardStaInfo

type VLogFileDisCardStaInfo struct {
	FileMap           map[uint32]int64
	FlushCh           chan map[uint32]int64
	UpdatesSinceFlush int // flush 次数
	// contains filtered or unexported fields
}

type ValueLog

type ValueLog struct {
	DirPath string
	Mux     sync.RWMutex

	FilesToDel []uint32

	Opt *lsm.Options

	Db                     *TrainKVDB
	GarbageCh              chan struct{}
	VLogFileDisCardStaInfo *VLogFileDisCardStaInfo
	// contains filtered or unexported fields
}

func (*ValueLog) Close

func (vlog *ValueLog) Close() error

func (*ValueLog) Entry

func (vlog *ValueLog) Entry(read io.Reader, offset uint32) (*model.Entry, error)

func (*ValueLog) NewValuePtr

func (vlog *ValueLog) NewValuePtr(entry *model.Entry) (*model.ValuePtr, error)

func (*ValueLog) Open

func (vlog *ValueLog) Open(replayFn model.LogEntry) error

func (*ValueLog) Read

func (vlog *ValueLog) Read(vp *model.ValuePtr) ([]byte, func(), error)

func (*ValueLog) ReadValueBytes

func (vlog *ValueLog) ReadValueBytes(vp *model.ValuePtr) ([]byte, *file.VLogFile, error)

func (*ValueLog) Write

func (vlog *ValueLog) Write(reqs []*Request) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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