store

package
v0.0.0-...-765978f Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2015 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	IteratorForward  uint8 = 0
	IteratorBackward uint8 = 1
)
View Source
const (
	RangeClose uint8 = 0x00
	RangeLOpen uint8 = 0x01
	RangeROpen uint8 = 0x10
	RangeOpen  uint8 = 0x11
)
View Source
const BatchDataHeadLen = 12

Variables

This section is empty.

Functions

func Repair

func Repair(cfg *config.Config) error

Types

type BatchData

type BatchData struct {
	leveldb.Batch
}

func NewBatchData

func NewBatchData(data []byte) (*BatchData, error)

func (*BatchData) Append

func (d *BatchData) Append(do *BatchData) error

func (*BatchData) Data

func (d *BatchData) Data() []byte

func (*BatchData) Items

func (d *BatchData) Items() ([]BatchItem, error)

func (*BatchData) Replay

func (d *BatchData) Replay(r BatchDataReplay) error

func (*BatchData) Reset

func (d *BatchData) Reset()

type BatchDataReplay

type BatchDataReplay interface {
	Put(key, value []byte)
	Delete(key []byte)
}

type BatchItem

type BatchItem struct {
	Key   []byte
	Value []byte
}

type DB

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

func Open

func Open(cfg *config.Config) (*DB, error)

func (*DB) Begin

func (db *DB) Begin() (*Tx, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Compact

func (db *DB) Compact() error

func (*DB) Delete

func (db *DB) Delete(key []byte) error

func (*DB) Get

func (db *DB) Get(key []byte) ([]byte, error)

func (*DB) GetSlice

func (db *DB) GetSlice(key []byte) (Slice, error)

func (*DB) NewIterator

func (db *DB) NewIterator() *Iterator

func (*DB) NewSnapshot

func (db *DB) NewSnapshot() (*Snapshot, error)

func (*DB) NewWriteBatch

func (db *DB) NewWriteBatch() *WriteBatch

func (*DB) Put

func (db *DB) Put(key []byte, value []byte) error

func (*DB) RangeIterator

func (db *DB) RangeIterator(min []byte, max []byte, rangeType uint8) *RangeLimitIterator

func (*DB) RangeLimitIterator

func (db *DB) RangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator

count < 0, unlimit.

offset must >= 0, if < 0, will get nothing.

func (*DB) RevRangeIterator

func (db *DB) RevRangeIterator(min []byte, max []byte, rangeType uint8) *RangeLimitIterator

func (*DB) RevRangeLimitIterator

func (db *DB) RevRangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator

count < 0, unlimit.

offset must >= 0, if < 0, will get nothing.

func (*DB) Stat

func (db *DB) Stat() *Stat

func (*DB) String

func (db *DB) String() string

type Iterator

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

func (*Iterator) BufKey

func (it *Iterator) BufKey(b []byte) []byte

Copy key to b, if b len is small or nil, returns a new one.

func (*Iterator) BufValue

func (it *Iterator) BufValue(b []byte) []byte

Copy value to b, if b len is small or nil, returns a new one.

func (*Iterator) Close

func (it *Iterator) Close()

func (*Iterator) Find

func (it *Iterator) Find(key []byte) []byte

Finds by key, if not found, nil returns.

func (*Iterator) Key

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

Returns a copy of key.

func (*Iterator) Next

func (it *Iterator) Next()

func (*Iterator) Prev

func (it *Iterator) Prev()

func (*Iterator) RawFind

func (it *Iterator) RawFind(key []byte) []byte

Finds by key, if not found, nil returns, else a reference of value returns. you must be careful that it will be changed after next iterate.

func (*Iterator) RawKey

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

Returns a reference of key. you must be careful that it will be changed after next iterate.

func (*Iterator) RawValue

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

Returns a reference of value. you must be careful that it will be changed after next iterate.

func (*Iterator) Seek

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

func (*Iterator) SeekToFirst

func (it *Iterator) SeekToFirst()

func (*Iterator) SeekToLast

func (it *Iterator) SeekToLast()

func (*Iterator) Valid

func (it *Iterator) Valid() bool

func (*Iterator) Value

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

Returns a copy of value.

type Limit

type Limit struct {
	Offset int
	Count  int
}

type Range

type Range struct {
	Min []byte
	Max []byte

	Type uint8
}

min must less or equal than max

range type:

close: [min, max]
open: (min, max)
lopen: (min, max]
ropen: [min, max)

type RangeLimitIterator

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

func NewRangeIterator

func NewRangeIterator(i *Iterator, r *Range) *RangeLimitIterator

func NewRangeLimitIterator

func NewRangeLimitIterator(i *Iterator, r *Range, l *Limit) *RangeLimitIterator

func NewRevRangeIterator

func NewRevRangeIterator(i *Iterator, r *Range) *RangeLimitIterator

func NewRevRangeLimitIterator

func NewRevRangeLimitIterator(i *Iterator, r *Range, l *Limit) *RangeLimitIterator

func (*RangeLimitIterator) BufKey

func (it *RangeLimitIterator) BufKey(b []byte) []byte

func (*RangeLimitIterator) BufValue

func (it *RangeLimitIterator) BufValue(b []byte) []byte

func (*RangeLimitIterator) Close

func (it *RangeLimitIterator) Close()

func (*RangeLimitIterator) Key

func (it *RangeLimitIterator) Key() []byte

func (*RangeLimitIterator) Next

func (it *RangeLimitIterator) Next()

func (*RangeLimitIterator) RawKey

func (it *RangeLimitIterator) RawKey() []byte

func (*RangeLimitIterator) RawValue

func (it *RangeLimitIterator) RawValue() []byte

func (*RangeLimitIterator) Valid

func (it *RangeLimitIterator) Valid() bool

func (*RangeLimitIterator) Value

func (it *RangeLimitIterator) Value() []byte

type Slice

type Slice interface {
	driver.ISlice
}

type Snapshot

type Snapshot struct {
	driver.ISnapshot
	// contains filtered or unexported fields
}

func (*Snapshot) Close

func (s *Snapshot) Close()

func (*Snapshot) Get

func (s *Snapshot) Get(key []byte) ([]byte, error)

func (*Snapshot) GetSlice

func (s *Snapshot) GetSlice(key []byte) (Slice, error)

func (*Snapshot) NewIterator

func (s *Snapshot) NewIterator() *Iterator

type Stat

type Stat struct {
	GetNum               sync2.AtomicInt64
	GetMissingNum        sync2.AtomicInt64
	GetTotalTime         sync2.AtomicDuration
	PutNum               sync2.AtomicInt64
	DeleteNum            sync2.AtomicInt64
	IterNum              sync2.AtomicInt64
	IterSeekNum          sync2.AtomicInt64
	IterCloseNum         sync2.AtomicInt64
	SnapshotNum          sync2.AtomicInt64
	SnapshotCloseNum     sync2.AtomicInt64
	BatchNum             sync2.AtomicInt64
	BatchCommitNum       sync2.AtomicInt64
	BatchCommitTotalTime sync2.AtomicDuration
	TxNum                sync2.AtomicInt64
	TxCommitNum          sync2.AtomicInt64
	TxCloseNum           sync2.AtomicInt64
	CompactNum           sync2.AtomicInt64
	CompactTotalTime     sync2.AtomicDuration
}

func (*Stat) Reset

func (st *Stat) Reset()

type Tx

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

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) Delete

func (tx *Tx) Delete(key []byte) error

func (*Tx) Get

func (tx *Tx) Get(key []byte) ([]byte, error)

func (*Tx) GetSlice

func (tx *Tx) GetSlice(key []byte) (Slice, error)

func (*Tx) NewIterator

func (tx *Tx) NewIterator() *Iterator

func (*Tx) NewWriteBatch

func (tx *Tx) NewWriteBatch() *WriteBatch

func (*Tx) Put

func (tx *Tx) Put(key []byte, value []byte) error

func (*Tx) RangeIterator

func (tx *Tx) RangeIterator(min []byte, max []byte, rangeType uint8) *RangeLimitIterator

func (*Tx) RangeLimitIterator

func (tx *Tx) RangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator

count < 0, unlimit.

offset must >= 0, if < 0, will get nothing.

func (*Tx) RevRangeIterator

func (tx *Tx) RevRangeIterator(min []byte, max []byte, rangeType uint8) *RangeLimitIterator

func (*Tx) RevRangeLimitIterator

func (tx *Tx) RevRangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator

count < 0, unlimit.

offset must >= 0, if < 0, will get nothing.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

type WriteBatch

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

func (*WriteBatch) BatchData

func (wb *WriteBatch) BatchData() *BatchData

the data will be undefined after commit or rollback

func (*WriteBatch) Close

func (wb *WriteBatch) Close()

func (*WriteBatch) Commit

func (wb *WriteBatch) Commit() error

func (*WriteBatch) Data

func (wb *WriteBatch) Data() []byte

func (*WriteBatch) Delete

func (wb *WriteBatch) Delete(key []byte)

func (*WriteBatch) Put

func (wb *WriteBatch) Put(key []byte, value []byte)

func (*WriteBatch) Rollback

func (wb *WriteBatch) Rollback() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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