godb

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

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 23 Imported by: 0

README

godb

Implementation inspired by:

Running the source code

Tested on GoLang version:

go version go1.22.5

To run the source code firt clone this repository. After that run go mod tidy to install all required dependecies.

To run all unit tests with their coverage run command ./test.sh

There is also an example of working with database in the directory called example. To run the example, cd into example directory and run GODB_LOG_PATH=/tmp/logs go run main.go. GODB_LOG_PATH specifies the directory where logs generated by the database should be stored.

Instalation

To install the package simply run

go get -u github.com/jakub-galecki/godb
Iterators
Compaction

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(name string, opts ...DbOpt) (*db, error)

Types

type Batch

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

func DecodeBatch

func DecodeBatch(raw []byte) *Batch

func NewBatch

func NewBatch() *Batch

func (*Batch) Delete

func (b *Batch) Delete(key []byte) *Batch

func (*Batch) Iter

func (b *Batch) Iter() *batchIter

func (*Batch) Set

func (b *Batch) Set(key, value []byte) *Batch

func (*Batch) Size

func (b *Batch) Size() int

type DbOpt

type DbOpt func(*dbOpts)

func WithDbPath

func WithDbPath(path string) DbOpt

func WithLogger

func WithLogger(l log.LoggerType) DbOpt

type Manifest

type Manifest struct {
	Id        string
	L0        []string   // id's of the sst files
	Levels    [][]string // id's of the sst files
	Table     string
	CreatedAt int64
	Path      string
	BlockSize uint64
	MaxLevels int
	// seqNum is a global counter for memtable writes to distinguish between new and old entries.
	SeqNum uint64
	// nextFileNumber indicates next file number that will be assigned to wal and memtable.
	NextFileNumber        uint64
	LastFlushedFileNumber uint64
	// contains filtered or unexported fields
}

func (*Manifest) DecodeMsg

func (z *Manifest) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Manifest) EncodeMsg

func (z *Manifest) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Manifest) MarshalMsg

func (z *Manifest) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Manifest) Msgsize

func (z *Manifest) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Manifest) UnmarshalMsg

func (z *Manifest) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type StorageEngine

type StorageEngine interface {
	Delete(key []byte) error
	Set(key, value []byte) error
	Get(key []byte) ([]byte, bool)
	GetSize() int
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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