mutcask

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 19 Imported by: 2

README

mutcask

Datastore for filedag-storage

Documentation

Index

Constants

View Source
const (
	HintDeletedFlag = byte(1)
)
View Source
const HintEncodeSize = HintKeySize + 8 + 4

HintKeySize + 8 bytes value offset + 4 bytes value size

View Source
const HintKeySize = MaxKeySize + 1 + 1

max key size 128 byte + 1 byte which record the key size + 1 byte delete flag

View Source
const MaxKeySize = 128
View Source
const SLICE_SCALE = 4 << 10
View Source
const VBUF_1M = 1 << 20
View Source
const VBUF_4M = 4 << 20

Variables

View Source
var (
	ErrNone                = xerrors.New("mutcask: error none")
	ErrValueFormat         = xerrors.New("mutcask: invalid value format")
	ErrDataRotted          = xerrors.New("mutcask: data may be rotted")
	ErrKeySizeTooLong      = xerrors.New("mutcask: key size is too long")
	ErrHintFormat          = xerrors.New("mutcask: invalid hint format")
	ErrPathUndefined       = xerrors.New("mutcask: should define path within config")
	ErrPath                = xerrors.New("mutcask: path should be directory not file")
	ErrHintLogBroken       = xerrors.New("mutcask: hint log broken")
	ErrReadHintBeyondRange = xerrors.New("mutcask: read hint out of file range")
	ErrRepoLocked          = xerrors.New("mutcask: repo has been locked")
)
View Source
var ErrNotFound = xerrors.New("kv: key not found")

Functions

func DecodeValue

func DecodeValue(buf []byte, verify bool) (v []byte, err error)

func EncodeValue

func EncodeValue(v []byte) []byte

*

crc32	:	value
4 		: 	xxxx

*

func NewLevedbKV added in v0.0.4

func NewLevedbKV(dir string) (*levedbKV, error)

func NewMutcask

func NewMutcask(opts ...Option) (*mutcask, error)

Types

type Cask

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

func NewCask

func NewCask(id uint32) *Cask

func (*Cask) Close

func (c *Cask) Close()

func (*Cask) Delete

func (c *Cask) Delete(key string) (err error)

func (*Cask) Put

func (c *Cask) Put(key string, value []byte) (err error)

func (*Cask) Read

func (c *Cask) Read(key string) (v []byte, err error)

func (*Cask) Size

func (c *Cask) Size(key string) (int, error)

type CaskMap

type CaskMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*CaskMap) Add

func (cm *CaskMap) Add(id uint32, cask *Cask)

func (*CaskMap) CloseAll

func (cm *CaskMap) CloseAll()

func (*CaskMap) Get

func (cm *CaskMap) Get(id uint32) (c *Cask, b bool)

type Config

type Config struct {
	Path            string
	CaskNum         uint32
	HintBootReadNum int
	InitBuf         int
}

type Hint

type Hint struct {
	Key     string
	KOffset uint64
	VOffset uint64
	VSize   uint32
	Deleted bool
}

func (*Hint) Encode

func (h *Hint) Encode() (ret []byte, err error)

*

key		:	value offset	:	value size
128+1   :   8   			:   4

*

func (*Hint) From

func (h *Hint) From(buf []byte) (err error)

func (*Hint) Less added in v0.0.4

func (h *Hint) Less(than btree.Item) bool

type KVDB

type KVDB interface {
	Put(string, []byte) error
	Delete(string) error
	Get(string) ([]byte, error)
	Size(string) (int, error)
	CheckSum(string) (string, error)

	AllKeysChan(context.Context) (chan string, error)
	Close() error
}

func NewMemkv added in v0.0.2

func NewMemkv() KVDB

type KeyMap

type KeyMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*KeyMap) Add

func (km *KeyMap) Add(key string, hint *Hint)

func (*KeyMap) Get

func (km *KeyMap) Get(key string) (h *Hint, b bool)

type Option

type Option func(cfg *Config)

func CaskNumConf

func CaskNumConf(caskNum int) Option

func HintBootReadNumConf

func HintBootReadNumConf(hn int) Option

func InitBufConf added in v0.0.4

func InitBufConf(size int) Option

func PathConf

func PathConf(dir string) Option

Jump to

Keyboard shortcuts

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