Documentation ¶
Index ¶
- Variables
- func DecodeDataKey(key []byte) []byte
- func EncodeDataKey(keys []byte, buffer *buf.ByteBuf) []byte
- func EncodeShardEnd(value []byte, buffer *buf.ByteBuf) []byte
- func EncodeShardMetadataKey(key []byte, buffer *buf.ByteBuf) []byte
- func EncodeShardStart(value []byte, buffer *buf.ByteBuf) []byte
- func NewBaseStorage(kv storage.KVStorage, fs vfs.FS) storage.KVBaseStorage
- func NewKVDataStorage(base storage.KVBaseStorage, executor storage.Executor, opts ...Option) storage.DataStorage
- func NextKey(key []byte, buffer *buf.ByteBuf) []byte
- type BaseStorage
- func (s *BaseStorage) ApplySnapshot(shardID uint64, path string) error
- func (s *BaseStorage) Close() error
- func (s *BaseStorage) CreateSnapshot(shardID uint64, path string) error
- func (s *BaseStorage) Delete(key []byte, sync bool) error
- func (s *BaseStorage) Get(key []byte) ([]byte, error)
- func (s *BaseStorage) GetView() storage.View
- func (s *BaseStorage) NewWriteBatch() storage.Resetable
- func (s *BaseStorage) PrefixScan(prefix []byte, handler func(key, value []byte) (bool, error), copy bool) error
- func (s *BaseStorage) RangeDelete(start, end []byte, sync bool) error
- func (s *BaseStorage) Scan(start, end []byte, handler func(key, value []byte) (bool, error), copy bool) error
- func (s *BaseStorage) ScanInView(view storage.View, start, end []byte, ...) error
- func (s *BaseStorage) Seek(key []byte) ([]byte, []byte, error)
- func (s *BaseStorage) Set(key []byte, value []byte, sync bool) error
- func (s *BaseStorage) Stats() stats.Stats
- func (s *BaseStorage) Sync() error
- func (s *BaseStorage) Write(wb util.WriteBatch, sync bool) error
- type Option
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoMetadata = errors.New("no metadata")
)
Functions ¶
func DecodeDataKey ¶
DecodeDataKey returns the origin data key. Note that no data copy is generated here, only a slice of the key is returned
func EncodeDataKey ¶
EncodeDataKey encode data key with data key prefix
func EncodeShardEnd ¶
EncodeShardEnd encode shard start key with data prefix
func EncodeShardMetadataKey ¶
EncodeShardMetadataKey encode shard metadata key with metadata prefix
func EncodeShardStart ¶
EncodeShardStart encode shard start key with data prefix
func NewBaseStorage ¶
func NewKVDataStorage ¶
func NewKVDataStorage(base storage.KVBaseStorage, executor storage.Executor, opts ...Option) storage.DataStorage
NewKVDataStorage returns data storage based on a kv base storage.
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) GetView ¶
func (s *BaseStorage) GetView() storage.View
func (*BaseStorage) NewWriteBatch ¶
func (s *BaseStorage) NewWriteBatch() storage.Resetable
func (*BaseStorage) PrefixScan ¶
func (*BaseStorage) RangeDelete ¶
func (s *BaseStorage) RangeDelete(start, end []byte, sync bool) error
func (*BaseStorage) ScanInView ¶
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 WithSampleSync ¶
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.