bitcask

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

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

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 13 Imported by: 0

README

bitcask

A fast key/value store based on the Bitcask model

Documentation

Index

Constants

View Source
const (
	HeaderSize = 4 + 8 + 4 + 4 // Header size in bytes. See the Header struct for more detail
)
View Source
const MaxFileSize int64 = 1024 * 1024 * 1024 // 1GB

Variables

This section is empty.

Functions

func Encode

func Encode(e Entry) []byte

func GetDataFiles

func GetDataFiles(path string) ([]string, error)

func GetFileID

func GetFileID(filename string) (int64, error)

Types

type Bitcask

type Bitcask struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func Open

func Open(path string) (*Bitcask, error)

func (*Bitcask) Close

func (b *Bitcask) Close() error

func (*Bitcask) Delete

func (b *Bitcask) Delete(key string) error

func (*Bitcask) Get

func (b *Bitcask) Get(key string) ([]byte, error)

func (*Bitcask) ListKeys

func (b *Bitcask) ListKeys() ([]string, error)

func (*Bitcask) Merge

func (b *Bitcask) Merge() error

func (*Bitcask) Put

func (b *Bitcask) Put(key string, value []byte) error

type DataFile

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

func OpenDataFile

func OpenDataFile(path string, fileID int64, readonly bool) (*DataFile, error)

func (*DataFile) Close

func (df *DataFile) Close() error

func (*DataFile) Delete

func (df *DataFile) Delete() error

func (*DataFile) Read

func (df *DataFile) Read() (*Entry, error)

func (*DataFile) ReadValueAt

func (df *DataFile) ReadValueAt(offset int64, size int32) ([]byte, error)

func (*DataFile) Writable

func (df *DataFile) Writable(data []byte) bool

func (*DataFile) Write

func (df *DataFile) Write(key string, value []byte) (*EntryIndex, error)

type Entry

type Entry struct {
	Header
	// contains filtered or unexported fields
}

func Decode

func Decode(b []byte, h Header) (*Entry, error)

func (*Entry) GetSize

func (e *Entry) GetSize() int64

type EntryIndex

type EntryIndex struct {
	// contains filtered or unexported fields
}
type Header struct {
	// contains filtered or unexported fields
}

func DecodeHeader

func DecodeHeader(buf []byte) Header

type KeyDir

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

func (*KeyDir) Add

func (k *KeyDir) Add(key string, idx *EntryIndex)

func (*KeyDir) Get

func (k *KeyDir) Get(key string) *EntryIndex

func (*KeyDir) Remove

func (k *KeyDir) Remove(key string)

Jump to

Keyboard shortcuts

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