bitcask_go

package module
v0.0.0-...-8c4c416 Latest Latest
Warning

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

Go to latest
Published: May 14, 2014 License: Apache-2.0 Imports: 14 Imported by: 0

README

bitcask_go is an implementation of bitcask in Go. It supports

  • get, set, delete
  • automatic merge

Install

go get github.com/JWZH/bitcask_go

Usage

The usage of bitcask-go is shown in bitcask_test.go

Documentation

Index

Constants

View Source
const (
	LOGFILE string = "test.log"

	DATA_FILE string = "%09d.data"
)
View Source
const (
	RECORD_HEADER_SIZE int32 = 20
)

Variables

View Source
var ErrKeyNotFound = errors.New("Key not found")

Functions

This section is empty.

Types

type Bitcask

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

func NewBitcask

func NewBitcask(o Options) (*Bitcask, error)

NewBitcask creates directory(path), and scans directory to build keydir

func (*Bitcask) Close

func (b *Bitcask) Close() error

Sync active file Release keydir Close active file

func (*Bitcask) Del

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

Set [0]

func (*Bitcask) Get

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

func (*Bitcask) Has

func (b *Bitcask) Has(key string) bool

func (*Bitcask) Keys

func (b *Bitcask) Keys() chan string

func (*Bitcask) Len

func (b *Bitcask) Len() int64

func (*Bitcask) Set

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

func (*Bitcask) Sync

func (b *Bitcask) Sync() error

type Bucket

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

File wraps *os.File with read and write records, compression, buf

func NewBucket

func NewBucket(f *os.File, id int32) *Bucket

func (*Bucket) Close

func (f *Bucket) Close() error

func (*Bucket) Name

func (f *Bucket) Name() string

func (*Bucket) Read

func (b *Bucket) Read() (*Record, error)

func (*Bucket) Sync

func (b *Bucket) Sync() error

func (*Bucket) Write

func (b *Bucket) Write(key string, value []byte, tstamp int64) (int32, error)

type Item

type Item struct {
	Fid    int32
	Vsz    int32
	Vpos   int32
	Tstamp int64
}

type Keydir

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

Keydir is a index data structure for bitcask It wrap for hashmap(builtin go) It is safe to call add, remove, get concurrently.

func NewKeydir

func NewKeydir() *Keydir

func (*Keydir) Add

func (k *Keydir) Add(key string, Fid, Vsz, Vpos int32, Tstamp int64) error

func (*Keydir) Destroy

func (k *Keydir) Destroy()

func (*Keydir) Get

func (k *Keydir) Get(key string) (*Item, bool)

func (*Keydir) Keys

func (k *Keydir) Keys() chan string

func (*Keydir) Remove

func (k *Keydir) Remove(key string)

type Options

type Options struct {
	MaxFileSize  int32
	MergeWindow  [2]int // startTime-EndTime
	MergeTrigger float32
	Path         string
}

type Record

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

type Stats

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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