openkv

package
v0.0.0-...-c602644 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	IteratorForward  uint8 = 0
	IteratorBackward uint8 = 1
)

Variables

This section is empty.

Functions

func Repair

func Repair(opts *config.OpenkvOptions) (err error)

Types

type BatchData

type BatchData struct {
	leveldb.Batch
}

BatchData use it(levedb.Batch) just for data kvStore WriteBatch to commit from log store data , don't use put/delete key,val again for WriteBatch to commit when load from Batch Data to WriteBatch commit load raw data([]byte) to BatchData dump BatchData to raw data([]byte) replay BatchData to WriteBatch impl which use Put/Delete op

func NewBatchData

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

func (*BatchData) Data

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

Data dump BatchData format []data (kt|klen|key|vlen|value)... -> raw data([]byte)

func (*BatchData) Replay

func (d *BatchData) Replay(impl leveldb.BatchReplay) error

Replay batch data for leveldb.BatchReplay impl put/delete op like relay log to replay some w(insert/update/delete) op (CDC)

func (*BatchData) ReplayItems

func (d *BatchData) ReplayItems() ([]BatchReplayItem, error)

func (*BatchData) Reset

func (d *BatchData) Reset()

Reset reset batch data

type BatchReplayItem

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

type DB

type DB struct {

	// kv op interface
	openkvDriver.IDB
	// contains filtered or unexported fields
}

DB wrap driver.IDB interface op impl IKV

func Open

func Open(opts *config.OpenkvOptions) (db *DB, err error)

func (*DB) Close

func (m *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) (openkvDriver.ISlice, error)

GetSlice wrap to adapte diff language kv store get op

func (*DB) NewIterator

func (m *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 driver.RangeType) *RangeLimitIterator

RangeIterator

func (*DB) RangeLimitIterator

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

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

func (*DB) RevRangeIterator

func (db *DB) RevRangeIterator(min []byte, max []byte, rangeType driver.RangeType) *RangeLimitIterator

RevRangeIterator

func (*DB) RevRangeLimitIterator

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

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

func (*DB) String

func (m *DB) String() string

type Iterator

type Iterator struct {
	driver.IIterator
}

Iterator wrap driver.IIterator, base iter

func (*Iterator) BufKey

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

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

func (*Iterator) BufValue

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

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

func (*Iterator) Close

func (m *Iterator) Close()

func (*Iterator) Find

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

Find finds by key, if not found, nil returns.

func (*Iterator) Key

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

Key returns a copy of key.

func (*Iterator) Next

func (m *Iterator) Next()

func (*Iterator) Prev

func (m *Iterator) Prev()

func (*Iterator) RawFind

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

RawFind 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 (m *Iterator) RawKey() []byte

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

func (*Iterator) RawValue

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

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

func (*Iterator) Seek

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

func (*Iterator) SeekToFirst

func (m *Iterator) SeekToFirst()

func (*Iterator) SeekToLast

func (m *Iterator) SeekToLast()

func (*Iterator) Valid

func (m *Iterator) Valid() bool

func (*Iterator) Value

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

Value returns a copy of value.

type Limit

type Limit struct {
	Offset int
	Count  int
}

type Range

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

	Type driver.RangeType
}

type RangeLimitIterator

type RangeLimitIterator struct {
	*Iterator
	// 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) Next

func (it *RangeLimitIterator) Next()

func (*RangeLimitIterator) Valid

func (it *RangeLimitIterator) Valid() bool

type Snapshot

type Snapshot struct {
	driver.ISnapshot
}

Snapshot wrap driver.ISnapshot interface op

func (*Snapshot) Close

func (s *Snapshot) Close()

func (*Snapshot) Get

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

func (*Snapshot) NewIterator

func (s *Snapshot) NewIterator() *Iterator

type WriteBatch

type WriteBatch struct {
	driver.IWriteBatch
	// contains filtered or unexported fields
}

WriteBatch wrap driver.IWriteBatch interface op

func (*WriteBatch) BatchData

func (wb *WriteBatch) BatchData() *BatchData

BatchData the data will be undefined after commit or rollback get from kvstore WriteBatch Data([]byte) load(no cp slice) to BatchData, in order to save to log store

func (*WriteBatch) Close

func (m *WriteBatch) Close()

func (*WriteBatch) Commit

func (m *WriteBatch) Commit() (err error)

func (*WriteBatch) Data

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

Data load from kvstort Data() to BatchData, then dump BatchData,return raw data []byte Batch data format: (kt|klen|key|vlen|value)

func (*WriteBatch) Delete

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

func (*WriteBatch) Put

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

func (*WriteBatch) Rollback

func (m *WriteBatch) Rollback() error

Jump to

Keyboard shortcuts

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