engine

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// for data
	KVType   byte = 21
	HashType byte = 22
)

make sure keep the same with rockredis

View Source
const (
	NotOp wop = iota
	DeleteOp
	PutOp
	MergeOp
	DeleteRangeOp
)

Variables

This section is empty.

Functions

func FillDefaultOptions

func FillDefaultOptions(opts *RockOptions)

func GetDataDirFromBase added in v0.9.2

func GetDataDirFromBase(engType string, base string) (string, error)

func GetRocksdbUint64 added in v0.9.0

func GetRocksdbUint64(v []byte, err error) (uint64, error)

func NewMemEng added in v0.9.0

func NewMemEng(cfg *RockEngConfig) (*memEng, error)

func NewRadix added in v0.9.3

func NewRadix() (*radixMemIndex, error)

func NewSkipList added in v0.9.0

func NewSkipList() *skipList

func SetLogLevel

func SetLogLevel(level int32)

func SetLogger

func SetLogger(level int32, logger common.Logger)

Types

type CRange added in v0.9.0

type CRange struct {
	Start []byte
	Limit []byte
}

type ICompactFilter added in v0.9.2

type ICompactFilter interface {
	Name() string
	Filter(level int, key, value []byte) (bool, []byte)
}

type Iterator

type Iterator interface {
	Next()
	Prev()
	Valid() bool
	Seek([]byte)
	SeekForPrev([]byte)
	SeekToFirst()
	SeekToLast()
	Close()
	RefKey() []byte
	Key() []byte
	RefValue() []byte
	Value() []byte
	NoTimestamp(vt byte)
}

type IteratorGetter added in v0.9.0

type IteratorGetter interface {
	GetIterator(IteratorOpts) (Iterator, error)
}

type IteratorOpts

type IteratorOpts struct {
	Range
	Limit
	Reverse   bool
	IgnoreDel bool
	WithSnap  bool
}

type KVCheckpoint added in v0.9.0

type KVCheckpoint interface {
	Save(path string, notify chan struct{}) error
}

type KVEngine added in v0.9.0

type KVEngine interface {
	NewWriteBatch() WriteBatch
	DefaultWriteBatch() WriteBatch
	GetDataDir() string
	SetMaxBackgroundOptions(maxCompact int, maxBackJobs int) error
	CheckDBEngForRead(fullPath string) error
	OpenEng() error
	Write(wb WriteBatch) error
	DeletedBeforeCompact() int64
	AddDeletedCnt(c int64)
	LastCompactTime() int64
	CompactRange(rg CRange)
	CompactAllRange()
	DisableManualCompact(bool)
	GetApproximateTotalKeyNum() int
	GetApproximateKeyNum(ranges []CRange) uint64
	GetApproximateSizes(ranges []CRange, includeMem bool) []uint64
	IsClosed() bool
	CloseEng() bool
	CloseAll()
	GetStatistics() string
	GetInternalStatus() map[string]interface{}
	GetInternalPropertyStatus(p string) string
	GetBytesNoLock(key []byte) ([]byte, error)
	GetBytes(key []byte) ([]byte, error)
	MultiGetBytes(keyList [][]byte, values [][]byte, errs []error)
	Exist(key []byte) (bool, error)
	ExistNoLock(key []byte) (bool, error)
	GetRef(key []byte) (RefSlice, error)
	GetRefNoLock(key []byte) (RefSlice, error)
	GetValueWithOp(key []byte, op func([]byte) error) error
	GetValueWithOpNoLock(key []byte, op func([]byte) error) error
	DeleteFilesInRange(rg CRange)
	GetIterator(opts IteratorOpts) (Iterator, error)
	NewCheckpoint(printToStdoutAlso bool) (KVCheckpoint, error)
	SetOptsForLogStorage()
	SetCompactionFilter(ICompactFilter)
}

func NewKVEng added in v0.9.0

func NewKVEng(cfg *RockEngConfig) (KVEngine, error)

type Limit

type Limit struct {
	Offset int
	Count  int
}

type PebbleEng added in v0.9.0

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

func NewPebbleEng added in v0.9.0

func NewPebbleEng(cfg *RockEngConfig) (*PebbleEng, error)

func (*PebbleEng) AddDeletedCnt added in v0.9.0

func (pe *PebbleEng) AddDeletedCnt(c int64)

func (*PebbleEng) CheckDBEngForRead added in v0.9.0

func (pe *PebbleEng) CheckDBEngForRead(fullPath string) error

func (*PebbleEng) CloseAll added in v0.9.0

func (pe *PebbleEng) CloseAll()

func (*PebbleEng) CloseEng added in v0.9.0

func (pe *PebbleEng) CloseEng() bool

func (*PebbleEng) CompactAllRange added in v0.9.0

func (pe *PebbleEng) CompactAllRange()

func (*PebbleEng) CompactRange added in v0.9.0

func (pe *PebbleEng) CompactRange(rg CRange)

func (*PebbleEng) DefaultWriteBatch added in v0.9.0

func (pe *PebbleEng) DefaultWriteBatch() WriteBatch

func (*PebbleEng) DeleteFilesInRange added in v0.9.0

func (pe *PebbleEng) DeleteFilesInRange(rg CRange)

func (*PebbleEng) DeletedBeforeCompact added in v0.9.0

func (pe *PebbleEng) DeletedBeforeCompact() int64

func (*PebbleEng) DisableManualCompact added in v0.9.2

func (pe *PebbleEng) DisableManualCompact(disable bool)

func (*PebbleEng) Exist added in v0.9.0

func (pe *PebbleEng) Exist(key []byte) (bool, error)

func (*PebbleEng) ExistNoLock added in v0.9.0

func (pe *PebbleEng) ExistNoLock(key []byte) (bool, error)

func (*PebbleEng) GetApproximateKeyNum added in v0.9.0

func (pe *PebbleEng) GetApproximateKeyNum(ranges []CRange) uint64

func (*PebbleEng) GetApproximateSizes added in v0.9.0

func (pe *PebbleEng) GetApproximateSizes(ranges []CRange, includeMem bool) []uint64

func (*PebbleEng) GetApproximateTotalKeyNum added in v0.9.0

func (pe *PebbleEng) GetApproximateTotalKeyNum() int

func (*PebbleEng) GetBytes added in v0.9.0

func (pe *PebbleEng) GetBytes(key []byte) ([]byte, error)

func (*PebbleEng) GetBytesNoLock added in v0.9.0

func (pe *PebbleEng) GetBytesNoLock(key []byte) ([]byte, error)

func (*PebbleEng) GetDataDir added in v0.9.0

func (pe *PebbleEng) GetDataDir() string

func (*PebbleEng) GetInternalPropertyStatus added in v0.9.0

func (pe *PebbleEng) GetInternalPropertyStatus(p string) string

func (*PebbleEng) GetInternalStatus added in v0.9.0

func (pe *PebbleEng) GetInternalStatus() map[string]interface{}

func (*PebbleEng) GetIterator added in v0.9.0

func (pe *PebbleEng) GetIterator(opts IteratorOpts) (Iterator, error)

func (*PebbleEng) GetRef added in v0.9.0

func (pe *PebbleEng) GetRef(key []byte) (RefSlice, error)

func (*PebbleEng) GetRefNoLock added in v0.9.0

func (pe *PebbleEng) GetRefNoLock(key []byte) (RefSlice, error)

func (*PebbleEng) GetStatistics added in v0.9.0

func (pe *PebbleEng) GetStatistics() string

func (*PebbleEng) GetValueWithOp added in v0.9.0

func (pe *PebbleEng) GetValueWithOp(key []byte,
	op func([]byte) error) error

func (*PebbleEng) GetValueWithOpNoLock added in v0.9.0

func (pe *PebbleEng) GetValueWithOpNoLock(key []byte,
	op func([]byte) error) error

func (*PebbleEng) IsClosed added in v0.9.0

func (pe *PebbleEng) IsClosed() bool

func (*PebbleEng) LastCompactTime added in v0.9.0

func (pe *PebbleEng) LastCompactTime() int64

func (*PebbleEng) MultiGetBytes added in v0.9.0

func (pe *PebbleEng) MultiGetBytes(keyList [][]byte, values [][]byte, errs []error)

func (*PebbleEng) NewCheckpoint added in v0.9.0

func (pe *PebbleEng) NewCheckpoint(printToStdoutAlso bool) (KVCheckpoint, error)

func (*PebbleEng) NewWriteBatch added in v0.9.0

func (pe *PebbleEng) NewWriteBatch() WriteBatch

func (*PebbleEng) OpenEng added in v0.9.0

func (pe *PebbleEng) OpenEng() error

func (*PebbleEng) SetCompactionFilter added in v0.9.2

func (pe *PebbleEng) SetCompactionFilter(ICompactFilter)

func (*PebbleEng) SetMaxBackgroundOptions added in v0.9.0

func (pe *PebbleEng) SetMaxBackgroundOptions(maxCompact int, maxBackJobs int) error

func (*PebbleEng) SetOptsForLogStorage added in v0.9.0

func (pe *PebbleEng) SetOptsForLogStorage()

func (*PebbleEng) Write added in v0.9.0

func (pe *PebbleEng) Write(wb WriteBatch) error

type Range

type Range struct {
	Min  []byte
	Max  []byte
	Type uint8
}

type RangeLimitedIterator

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

func NewDBRangeIteratorWithOpts

func NewDBRangeIteratorWithOpts(ig IteratorGetter, opts IteratorOpts) (rit *RangeLimitedIterator, err error)

note: all the iterator use the prefix iterator flag. Which means it may skip the keys for different table prefix.

func NewDBRangeLimitIteratorWithOpts

func NewDBRangeLimitIteratorWithOpts(ig IteratorGetter, opts IteratorOpts) (rit *RangeLimitedIterator, err error)

note: all the iterator use the prefix iterator flag. Which means it may skip the keys for different table prefix.

func NewRangeIterator

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

func NewRangeLimitIterator

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

func NewRevRangeIterator

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

func NewRevRangeLimitIterator

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

func (*RangeLimitedIterator) Next

func (it *RangeLimitedIterator) Next()

func (*RangeLimitedIterator) Valid

func (it *RangeLimitedIterator) Valid() bool

type RefSlice added in v0.9.0

type RefSlice interface {
	// ref data
	Data() []byte
	Free()
	// copied data if need
	Bytes() []byte
}

type RockEng

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

func NewRockEng

func NewRockEng(cfg *RockEngConfig) (*RockEng, error)

func (*RockEng) AddDeletedCnt

func (r *RockEng) AddDeletedCnt(c int64)

func (*RockEng) CheckDBEngForRead added in v0.9.0

func (r *RockEng) CheckDBEngForRead(fullPath string) error

func (*RockEng) CloseAll

func (r *RockEng) CloseAll()

func (*RockEng) CloseEng

func (r *RockEng) CloseEng() bool

func (*RockEng) CompactAllRange added in v0.9.0

func (r *RockEng) CompactAllRange()

func (*RockEng) CompactRange

func (r *RockEng) CompactRange(rg CRange)

func (*RockEng) DefaultWriteBatch added in v0.9.0

func (r *RockEng) DefaultWriteBatch() WriteBatch

DefaultWriteBatch return the internal default write batch for write, should only call this after the engine opened and can not be used concurrently

func (*RockEng) DeleteFilesInRange added in v0.9.0

func (r *RockEng) DeleteFilesInRange(rg CRange)

func (*RockEng) DeletedBeforeCompact

func (r *RockEng) DeletedBeforeCompact() int64

func (*RockEng) DisableManualCompact added in v0.9.2

func (r *RockEng) DisableManualCompact(disable bool)

func (*RockEng) Exist added in v0.9.0

func (r *RockEng) Exist(key []byte) (bool, error)

func (*RockEng) ExistNoLock added in v0.9.0

func (r *RockEng) ExistNoLock(key []byte) (bool, error)

func (*RockEng) GetApproximateKeyNum added in v0.9.0

func (r *RockEng) GetApproximateKeyNum(ranges []CRange) uint64

func (*RockEng) GetApproximateSizes added in v0.9.0

func (r *RockEng) GetApproximateSizes(ranges []CRange, includeMem bool) []uint64

func (*RockEng) GetApproximateTotalKeyNum added in v0.9.0

func (r *RockEng) GetApproximateTotalKeyNum() int

func (*RockEng) GetBytes added in v0.9.0

func (r *RockEng) GetBytes(key []byte) ([]byte, error)

func (*RockEng) GetBytesNoLock added in v0.9.0

func (r *RockEng) GetBytesNoLock(key []byte) ([]byte, error)

func (*RockEng) GetDataDir

func (r *RockEng) GetDataDir() string

func (*RockEng) GetInternalPropertyStatus

func (r *RockEng) GetInternalPropertyStatus(p string) string

func (*RockEng) GetInternalStatus

func (r *RockEng) GetInternalStatus() map[string]interface{}

func (*RockEng) GetIterator added in v0.9.0

func (r *RockEng) GetIterator(opts IteratorOpts) (Iterator, error)

func (*RockEng) GetOpts

func (r *RockEng) GetOpts() *gorocksdb.Options

func (*RockEng) GetRef added in v0.9.0

func (r *RockEng) GetRef(key []byte) (RefSlice, error)

func (*RockEng) GetRefNoLock added in v0.9.0

func (r *RockEng) GetRefNoLock(key []byte) (RefSlice, error)

func (*RockEng) GetStatistics

func (r *RockEng) GetStatistics() string

func (*RockEng) GetValueWithOp added in v0.7.1

func (r *RockEng) GetValueWithOp(key []byte,
	op func([]byte) error) error

func (*RockEng) GetValueWithOpNoLock added in v0.7.1

func (r *RockEng) GetValueWithOpNoLock(key []byte,
	op func([]byte) error) error

func (*RockEng) IsClosed added in v0.9.0

func (r *RockEng) IsClosed() bool

func (*RockEng) LastCompactTime

func (r *RockEng) LastCompactTime() int64

func (*RockEng) MultiGetBytes added in v0.9.0

func (r *RockEng) MultiGetBytes(keyList [][]byte, values [][]byte, errs []error)

func (*RockEng) NewCheckpoint added in v0.9.0

func (r *RockEng) NewCheckpoint(printToStdoutAlso bool) (KVCheckpoint, error)

func (*RockEng) NewWriteBatch added in v0.9.0

func (r *RockEng) NewWriteBatch() WriteBatch

NewWriteBatch init a new write batch for write, should only call this after the engine opened

func (*RockEng) OpenEng

func (r *RockEng) OpenEng() error

func (*RockEng) SetCompactionFilter added in v0.9.2

func (r *RockEng) SetCompactionFilter(filter ICompactFilter)

func (*RockEng) SetMaxBackgroundOptions added in v0.7.1

func (r *RockEng) SetMaxBackgroundOptions(maxCompact int, maxBackJobs int) error

func (*RockEng) SetOptsForLogStorage added in v0.9.0

func (r *RockEng) SetOptsForLogStorage()

func (*RockEng) Write added in v0.9.0

func (r *RockEng) Write(wb WriteBatch) error

type RockEngConfig

type RockEngConfig struct {
	DataDir            string
	ReadOnly           bool
	DataTool           bool
	SharedConfig       SharedRockConfig
	EnableTableCounter bool
	AutoCompacted      bool
	RockOptions
}

func NewRockConfig

func NewRockConfig() *RockEngConfig

type RockOptions

type RockOptions struct {
	VerifyReadChecksum             bool   `json:"verify_read_checksum"`
	BlockSize                      int    `json:"block_size"`
	BlockCache                     int64  `json:"block_cache"`
	CacheIndexAndFilterBlocks      bool   `json:"cache_index_and_filter_blocks"`
	EnablePartitionedIndexFilter   bool   `json:"enable_partitioned_index_filter"`
	WriteBufferSize                int    `json:"write_buffer_size"`
	MaxWriteBufferNumber           int    `json:"max_write_buffer_number"`
	MinWriteBufferNumberToMerge    int    `json:"min_write_buffer_number_to_merge"`
	Level0FileNumCompactionTrigger int    `json:"level0_file_num_compaction_trigger"`
	MaxBytesForLevelBase           uint64 `json:"max_bytes_for_level_base"`
	TargetFileSizeBase             uint64 `json:"target_file_size_base"`
	MaxBackgroundFlushes           int    `json:"max_background_flushes"`
	MaxBackgroundCompactions       int    `json:"max_background_compactions"`
	MinLevelToCompress             int    `json:"min_level_to_compress"`
	MaxMainifestFileSize           uint64 `json:"max_mainifest_file_size"`
	RateBytesPerSec                int64  `json:"rate_bytes_per_sec"`
	BackgroundHighThread           int    `json:"background_high_thread,omitempty"`
	BackgroundLowThread            int    `json:"background_low_thread,omitempty"`
	AdjustThreadPool               bool   `json:"adjust_thread_pool,omitempty"`
	UseSharedCache                 bool   `json:"use_shared_cache,omitempty"`
	UseSharedRateLimiter           bool   `json:"use_shared_rate_limiter,omitempty"`
	DisableWAL                     bool   `json:"disable_wal,omitempty"`
	DisableMergeCounter            bool   `json:"disable_merge_counter,omitempty"`
	OptimizeFiltersForHits         bool   `json:"optimize_filters_for_hits,omitempty"`
	// note do not change this dynamic for existing db
	LevelCompactionDynamicLevelBytes bool   `json:"level_compaction_dynamic_level_bytes,omitempty"`
	InsertHintFixedLen               int    `json:"insert_hint_fixed_len"`
	EngineType                       string `json:"engine_type,omitempty"`
}

type SharedRockConfig

type SharedRockConfig interface {
	Destroy()
	ChangeLimiter(bytesPerSec int64)
}

func NewSharedEngConfig added in v0.9.0

func NewSharedEngConfig(cfg RockOptions) (SharedRockConfig, error)

type SkipListIterator added in v0.9.0

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

func (*SkipListIterator) Close added in v0.9.0

func (iter *SkipListIterator) Close()

Close closes the iterator.

func (*SkipListIterator) First added in v0.9.0

func (iter *SkipListIterator) First()

SeekToFirst moves the iterator to the first key in the database.

func (*SkipListIterator) Key added in v0.9.0

func (iter *SkipListIterator) Key() []byte

Key returns the key the iterator currently holds.

func (*SkipListIterator) Last added in v0.9.0

func (iter *SkipListIterator) Last()

SeekToLast moves the iterator to the last key in the database.

func (*SkipListIterator) Next added in v0.9.0

func (iter *SkipListIterator) Next()

Next moves the iterator to the next sequential key in the database.

func (*SkipListIterator) Prev added in v0.9.0

func (iter *SkipListIterator) Prev()

Prev moves the iterator to the previous sequential key in the database.

func (*SkipListIterator) Seek added in v0.9.0

func (iter *SkipListIterator) Seek(key []byte)

Seek moves the iterator to the position greater than or equal to the key.

func (*SkipListIterator) SeekForPrev added in v0.9.0

func (iter *SkipListIterator) SeekForPrev(key []byte)

seek to the last key that less than or equal to the target key while enable prefix_extractor, use seek() and prev() doesn't work if seek to the end of the prefix range. use this seekforprev instead

func (*SkipListIterator) Valid added in v0.9.0

func (iter *SkipListIterator) Valid() bool

Valid returns false only when an Iterator has iterated past either the first or the last key in the database.

func (*SkipListIterator) Value added in v0.9.0

func (iter *SkipListIterator) Value() []byte

Value returns the value in the database the iterator currently holds.

type Uint64AddMerger added in v0.9.0

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

func (*Uint64AddMerger) Finish added in v0.9.0

func (m *Uint64AddMerger) Finish() ([]byte, io.Closer, error)

func (*Uint64AddMerger) MergeNewer added in v0.9.0

func (m *Uint64AddMerger) MergeNewer(value []byte) error

func (*Uint64AddMerger) MergeOlder added in v0.9.0

func (m *Uint64AddMerger) MergeOlder(value []byte) error

type WriteBatch added in v0.9.0

type WriteBatch interface {
	Destroy()
	Clear()
	DeleteRange(start, end []byte)
	Delete(key []byte)
	Put(key []byte, value []byte)
	Merge(key []byte, value []byte)
	Commit() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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