kvstore

package
v0.0.0-...-303e327 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCFName = errors.New("invalid column family name")
	ErrNotFound      = os.ErrNotExist
)

Functions

This section is empty.

Types

type DbOptions

type DbOptions func(*RocksDBOption)

type Iterator

type Iterator interface {
	SeekToFirst()
	SeekToLast()
	Seek([]byte)
	Valid() bool
	ValidForPrefix(prefix []byte) bool
	Key() *rdb.Slice
	Next()
	Value() *rdb.Slice
	// destroy iterator and read option
	Close()
	Err() error
}

type KV

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

type KVStorage

type KVStorage interface {
	Put(kv KV, opts ...OpOption) error
	Get(key []byte, opts ...OpOption) ([]byte, error)
	Delete(key []byte, opts ...OpOption) error
	NewWriteBatch() *WriteBatch
	DeleteBatch(keys [][]byte, safe bool) error
	WriteBatch(kvs []KV, safe bool) error
	DoBatch(batch *WriteBatch) error
	Flush() error
	NewSnapshot() *Snapshot
	ReleaseSnapshot(snapshot *Snapshot)
	NewIterator(snapshot *Snapshot, opts ...OpOption) Iterator
}

type KVStore

type KVStore interface {
	KVStorage
	GetDB() *rdb.DB
	Table(name string) KVTable
	Close() error
}

func OpenDB

func OpenDB(path string, isSync bool, dbOpts ...DbOptions) (KVStore, error)

func OpenDBWithCF

func OpenDBWithCF(path string, isSync bool, cfnames []string, dbOpts ...DbOptions) (KVStore, error)

type KVTable

type KVTable interface {
	KVStorage
	GetDB() *rdb.DB
	GetCf() *rdb.ColumnFamilyHandle
}

type Op

type Op struct {
	// for put
	PutKeys []KV
	// for delete
	DelKeys []KV
	// for iterator
	Ro   *ReadOptions
	Snap *Snapshot
}

type OpOption

type OpOption func(*Op)

type Range

type Range rdb.Range

type ReadOptions

type ReadOptions struct {
	*rdb.ReadOptions
}

func NewReadOptions

func NewReadOptions() *ReadOptions

type RocksDBOption

type RocksDBOption struct {
	ReadOnly                       bool   `json:"readonly"`
	InfoLogLevel                   *uint8 `json:"log_level"`
	BackThreadCount                int    `json:"back_thread_count"`
	MaxBackgroundCompaction        int    `json:"max_background_compactions"`
	MaxBackgroundFlushes           int    `json:"max_background_flushes"`
	WriteBufferSize                int    `json:"write_buffer_size"`
	MaxWriteBufferNumber           int    `json:"max_write_buffer_number"`
	MaxOpenFiles                   int    `json:"max_open_files"`
	BlockSize                      int    `json:"block_size"`
	CreateIfMissing                bool   `json:"create_if_missing"`
	ErrorIfExists                  bool   `json:"error_if_exists"`
	LRUCache                       int    `json:"lrucache"`
	BloomFilterSize                int    `json:"bloom_filter_size"`
	TargetFileSizeBase             uint64 `json:"target_file_size_base"`
	MaxBytesForLevelBase           uint64 `json:"max_bytes_for_level_base"`
	TargetFileSizeMultiplier       int    `json:"target_file_size_multiplie"`
	NumLevels                      int    `json:"num_levels"`
	Level0FileNumCompactionTrigger int    `json:"level0_file_num_compaction_trigger"`
	Level0SlowdownWritesTrigger    int    `json:"level0_slowdown_writes_trigger"`
	Level0StopWritesTrigger        int    `json:"level0_stop_writes_trigger"`
	EnableStatistics               bool   `json:"enable_statistics"`
	AllowMMAPRead                  bool   `json:"allow_mmap_reads"`
	AllowMMAPWrite                 bool   `json:"allow_mmap_writes"`
	InplaceUpdateSupport           bool   `json:"inplace_update_support"`
	StatsDumpPeriodSec             uint   `json:"stats_dump_period_sec"`
	CreateIfMissingColumnFamilies  bool   `json:"create_if_missing_column_families"`
	MaxLogFileSize                 int    `json:"max_log_file_size"`
	KeepLogFileNum                 int    `json:"keep_log_file_num"`
}

type Snapshot

type Snapshot rdb.Snapshot

type WriteBatch

type WriteBatch struct {
	*rdb.WriteBatch
}

type WriteOptions

type WriteOptions struct {
	*rdb.WriteOptions
}

func NewWriteOptions

func NewWriteOptions() *WriteOptions

Jump to

Keyboard shortcuts

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