memdb

package
v0.0.0-...-b800c40 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

README

memdb

A high performance DRAM storage engine

License

Apache 2.0

Documentation

Index

Constants

View Source
const DiskBlockSize = 512 * 1024

Variables

View Source
var (
	ErrMaxSnapshotsLimitReached = fmt.Errorf("Maximum snapshots limit reached")
	ErrShutdown                 = fmt.Errorf("MemDB instance has been shutdown")
)
View Source
var (
	ErrNotEnoughSpace = errors.New("Not enough space in the buffer")
)

Functions

func CompareMemDB

func CompareMemDB(this unsafe.Pointer, that unsafe.Pointer) int

func CompareSnapshot

func CompareSnapshot(this, that unsafe.Pointer) int

func Debug

func Debug(flag bool)

func ItemSize

func ItemSize(p unsafe.Pointer) int

func MemoryInUse

func MemoryInUse() (sz int64)

func SnapshotSize

func SnapshotSize(p unsafe.Pointer) int

Types

type CheckPointCallback

type CheckPointCallback func()

type Config

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

func DefaultConfig

func DefaultConfig() Config

func (*Config) IgnoreItemSize

func (cfg *Config) IgnoreItemSize()

func (*Config) SetFileType

func (cfg *Config) SetFileType(t FileType) error

func (*Config) SetKeyComparator

func (cfg *Config) SetKeyComparator(cmp KeyCompare)

func (*Config) UseDeltaInterleaving

func (cfg *Config) UseDeltaInterleaving()

func (*Config) UseMemoryMgmt

func (cfg *Config) UseMemoryMgmt(malloc skiplist.MallocFn, free skiplist.FreeFn)

type FileReader

type FileReader interface {
	Open(path string) error
	ReadItem() (*Item, error)
	Close() error
}

type FileType

type FileType int
const (
	ForestdbFile FileType = iota
	RawdbFile
)

type FileWriter

type FileWriter interface {
	Open(path string) error
	WriteItem(*Item) error
	Close() error
}

type Item

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

func (*Item) Bytes

func (itm *Item) Bytes() (bs []byte)

type ItemCallback

type ItemCallback func(*ItemEntry)

type ItemEntry

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

func (*ItemEntry) Item

func (e *ItemEntry) Item() *Item

func (*ItemEntry) Node

func (e *ItemEntry) Node() *skiplist.Node

type Iterator

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

func (*Iterator) Close

func (it *Iterator) Close()

func (*Iterator) Get

func (it *Iterator) Get() []byte

func (*Iterator) GetNode

func (it *Iterator) GetNode() *skiplist.Node

func (*Iterator) Next

func (it *Iterator) Next()

func (*Iterator) Refresh

func (it *Iterator) Refresh()

Refresh can help safe-memory-reclaimer to free deleted objects

func (*Iterator) Seek

func (it *Iterator) Seek(bs []byte)

func (*Iterator) SeekFirst

func (it *Iterator) SeekFirst()

func (*Iterator) SetRefreshRate

func (it *Iterator) SetRefreshRate(rate int)

func (*Iterator) Valid

func (it *Iterator) Valid() bool

type KeyCompare

type KeyCompare func([]byte, []byte) int

type MemDB

type MemDB struct {
	Config
	// contains filtered or unexported fields
}

func New

func New() *MemDB

func NewWithConfig

func NewWithConfig(cfg Config) *MemDB

func (*MemDB) Close

func (m *MemDB) Close()

func (*MemDB) DecodeItem

func (m *MemDB) DecodeItem(ver int, buf []byte, r io.Reader) (*Item, error)

func (*MemDB) DumpStats

func (m *MemDB) DumpStats() string

func (*MemDB) EncodeItem

func (m *MemDB) EncodeItem(itm *Item, buf []byte, w io.Writer) error

func (*MemDB) GC

func (m *MemDB) GC()

func (*MemDB) GetSnapshots

func (m *MemDB) GetSnapshots() []*Snapshot

func (*MemDB) ItemsCount

func (m *MemDB) ItemsCount() int64

func (*MemDB) LoadFromDisk

func (m *MemDB) LoadFromDisk(dir string, concurr int, callb ItemCallback) (*Snapshot, error)

func (*MemDB) MemoryInUse

func (m *MemDB) MemoryInUse() int64

func (*MemDB) NewIterator

func (m *MemDB) NewIterator(snap *Snapshot) *Iterator

func (*MemDB) NewSnapshot

func (m *MemDB) NewSnapshot() (*Snapshot, error)

func (*MemDB) NewWriter

func (m *MemDB) NewWriter() *Writer

func (*MemDB) StoreToDisk

func (m *MemDB) StoreToDisk(dir string, snap *Snapshot, concurr int, itmCallback ItemCallback) (err error)

func (*MemDB) Visitor

func (m *MemDB) Visitor(snap *Snapshot, callb VisitorCallback, shards int, concurrency int) error

type NodeList

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

func NewNodeList

func NewNodeList(head *skiplist.Node) *NodeList

func (*NodeList) Add

func (l *NodeList) Add(node *skiplist.Node)

func (*NodeList) Head

func (l *NodeList) Head() *skiplist.Node

func (*NodeList) Keys

func (l *NodeList) Keys() (keys [][]byte)

func (*NodeList) Remove

func (l *NodeList) Remove(key []byte) *skiplist.Node

type Snapshot

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

func (*Snapshot) Close

func (s *Snapshot) Close()

func (Snapshot) Count

func (s Snapshot) Count() int64

func (*Snapshot) Decode

func (s *Snapshot) Decode(buf []byte, r io.Reader) error

func (*Snapshot) Encode

func (s *Snapshot) Encode(buf []byte, w io.Writer) error

func (*Snapshot) NewIterator

func (s *Snapshot) NewIterator() *Iterator

func (*Snapshot) Open

func (s *Snapshot) Open() bool

type VisitorCallback

type VisitorCallback func(*Item, int) error

type Writer

type Writer struct {
	*MemDB
	// contains filtered or unexported fields
}

func (*Writer) Delete

func (w *Writer) Delete(bs []byte) (success bool)

Find first item, seek until dead=0, mark dead=sn

func (*Writer) Delete2

func (w *Writer) Delete2(bs []byte) (n *skiplist.Node, success bool)

func (*Writer) DeleteNode

func (w *Writer) DeleteNode(x *skiplist.Node) (success bool)

func (*Writer) GetNode

func (w *Writer) GetNode(bs []byte) *skiplist.Node

func (*Writer) Put

func (w *Writer) Put(bs []byte)

func (*Writer) Put2

func (w *Writer) Put2(bs []byte) (n *skiplist.Node)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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