kv

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMetadata = errors.New("no metadata")
)

Functions

func DecodeDataKey

func DecodeDataKey(key []byte) []byte

DecodeDataKey returns the origin data key. Note that no data copy is generated here, only a slice of the key is returned

func EncodeDataKey

func EncodeDataKey(keys []byte, buffer *buf.ByteBuf) []byte

EncodeDataKey encode data key with data key prefix

func EncodeShardEnd

func EncodeShardEnd(value []byte, buffer *buf.ByteBuf) []byte

EncodeShardEnd encode shard start key with data prefix

func EncodeShardMetadataKey

func EncodeShardMetadataKey(key []byte, buffer *buf.ByteBuf) []byte

EncodeShardMetadataKey encode shard metadata key with metadata prefix

func EncodeShardStart

func EncodeShardStart(value []byte, buffer *buf.ByteBuf) []byte

EncodeShardStart encode shard start key with data prefix

func NewBaseStorage

func NewBaseStorage(kv storage.KVStorage, fs vfs.FS) storage.KVBaseStorage

func NewKVDataStorage

func NewKVDataStorage(base storage.KVBaseStorage,
	executor storage.Executor, opts ...Option) storage.DataStorage

NewKVDataStorage returns data storage based on a kv base storage.

func NextKey added in v0.3.0

func NextKey(key []byte, buffer *buf.ByteBuf) []byte

NextKey returns the next key of current key

Types

type BaseStorage

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

func (*BaseStorage) ApplySnapshot

func (s *BaseStorage) ApplySnapshot(shardID uint64, path string) error

ApplySnapshot apply a snapshort file from giving path

func (*BaseStorage) Close

func (s *BaseStorage) Close() error

func (*BaseStorage) CreateSnapshot

func (s *BaseStorage) CreateSnapshot(shardID uint64, path string) error

CreateSnapshot create a snapshot file under the giving path

func (*BaseStorage) Delete

func (s *BaseStorage) Delete(key []byte, sync bool) error

func (*BaseStorage) Get

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

func (*BaseStorage) GetView

func (s *BaseStorage) GetView() storage.View

func (*BaseStorage) NewWriteBatch

func (s *BaseStorage) NewWriteBatch() storage.Resetable

func (*BaseStorage) PrefixScan

func (s *BaseStorage) PrefixScan(prefix []byte,
	handler func(key, value []byte) (bool, error), copy bool) error

func (*BaseStorage) RangeDelete

func (s *BaseStorage) RangeDelete(start, end []byte, sync bool) error

func (*BaseStorage) Scan

func (s *BaseStorage) Scan(start, end []byte,
	handler func(key, value []byte) (bool, error), copy bool) error

func (*BaseStorage) ScanInView

func (s *BaseStorage) ScanInView(view storage.View,
	start, end []byte, handler func(key, value []byte) (bool, error), copy bool) error

func (*BaseStorage) Seek

func (s *BaseStorage) Seek(key []byte) ([]byte, []byte, error)

func (*BaseStorage) Set

func (s *BaseStorage) Set(key []byte, value []byte, sync bool) error

func (*BaseStorage) Stats

func (s *BaseStorage) Stats() stats.Stats

func (*BaseStorage) Sync

func (s *BaseStorage) Sync() error

func (*BaseStorage) Write

func (s *BaseStorage) Write(wb util.WriteBatch, sync bool) error

type Option

type Option func(*options)

Option option func

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger set logger

func WithSampleSync

func WithSampleSync(value uint64) Option

WithSampleSync set sync sample interval. `Cube` will call the `GetPersistentLogIndex` method of `DataStorage` to obtain the last `PersistentLogIndex`, which is used for log compression. Since all the writes of `DataStorage` are not written by fsync, we need to sample some sync writes to ensure that the returned `PersistentLogIndex` will not exceed the real `PersistentLogIndex` to avoid the log being compressed by mistake.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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