bitcask

package
v0.0.0-...-bda965e Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//default file size 1G
	DefaultMaxFileSize  = (1 << 32) - 1
	DefaultMaxValueSize = (1 << 8) - 1
	DefaultFileDir      = "data"
)
View Source
const (

	// 4*4
	ItemSizeWithoutKV = 1 << 4

	// 4*3 + 8 =20
	HintSizeWithoutK = 20
)

Variables

View Source
var (
	ErrNotFound = errors.New("Not Found ")

	ErrCRC32 = errors.New("Checksum IEEE error ")

	ErrReadFailed = errors.New("Read BitCask Failed ")
)

Functions

func DecodeItem

func DecodeItem(buf []byte) ([]byte, error)

Types

type BitCask

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

func Open

func Open(cfg *Config) (*BitCask, error)

func (*BitCask) Close

func (bc *BitCask) Close()

func (*BitCask) Del

func (bc *BitCask) Del(key []byte) error

func (*BitCask) Get

func (bc *BitCask) Get(key []byte) ([]byte, error)

func (*BitCask) Put

func (bc *BitCask) Put(key []byte, value []byte) error

func (*BitCask) Sync

func (bc *BitCask) Sync()

type Config

type Config struct {
	MaxFileSize  uint64
	MaxValueSize uint64
	FileDir      string
}

type File

type File struct {
	Offset uint64
	// contains filtered or unexported fields
}

func NewFile

func NewFile() *File

func OpenFile

func OpenFile(fileDir string, fileId int) (*File, error)

func (*File) CloseAll

func (af *File) CloseAll()

func (*File) Delete

func (af *File) Delete(key []byte) error

func (*File) GetFileId

func (af *File) GetFileId() uint32

func (*File) GetFileOffset

func (af *File) GetFileOffset() uint64

func (*File) Read

func (af *File) Read(off uint64, dataLen uint32) ([]byte, error)

根据offset在文件中获取,并返回数据

func (*File) Sync

func (af *File) Sync()

func (*File) Write

func (af *File) Write(key []byte, value []byte) (fileItem, error)

type Files

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

只读文件

func (*Files) CloseAllFile

func (fs *Files) CloseAllFile()

func (*Files) GetFilePtr

func (fs *Files) GetFilePtr(fileId uint32) *File

func (*Files) PutFilePtr

func (fs *Files) PutFilePtr(f *File, fileId uint32)

type HashTable

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

type MultiFileReader

type MultiFileReader interface {
	GetFilePtr(uint32) *File
	PutFilePtr(*File, uint32)
	CloseAllFile()
}

Jump to

Keyboard shortcuts

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