rockredis

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2018 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Usage

First create a rockredis instance before use:

db := rockredis.Open(cfg)

cfg is a Config instance which contains configuration for rockredis use

After you create a rockredis instance, you can store you data:

KV

KV is the most basic type like any other key-value database.

err := db.KVSet(key, value)
value, err := db.KVGet(key)

List

List is simply lists of values, sorted by insertion order. You can push or pop value on the list head (left) or tail (right).

err := db.LPush(key, value1)
err := db.RPush(key, value2)
value1, err := db.LPop(key)
value2, err := db.RPop(key)

Hash

Hash is a map between fields and values.

n, err := db.HSet(key, field1, value1)
n, err := db.HSet(key, field2, value2)
value1, err := db.HGet(key, field1)
value2, err := db.HGet(key, field2)

ZSet

ZSet is a sorted collections of values. Every member of zset is associated with score, a int64 value which used to sort, from smallest to greatest score. Members are unique, but score may be same.

 n, err := db.ZAdd(key, ScorePair{score1, member1}, ScorePair{score2, member2})
 ay, err := db.ZRangeByScore(key, minScore, maxScore, 0, -1)

	Package rockredis is a generated protocol buffer package.

	It is generated from these files:
		index_types.proto

	It has these top-level messages:
		HsetIndexInfo
		HsetIndexList

Index

Constants

View Source
const (
	NoneType byte = 0

	// table count, stats, index, schema, and etc.
	TableMetaType      byte = 10
	TableIndexMetaType byte = 11

	// for data
	KVType    byte = 21
	HashType  byte = 22
	HSizeType byte = 23
	// current using array list
	ListType   byte = 24
	LMetaType  byte = 25
	ZSetType   byte = 26
	ZSizeType  byte = 27
	ZScoreType byte = 28
	SetType    byte = 29
	SSizeType  byte = 30

	JSONType byte = 31

	ColumnType byte = 38 // used for column store for OLAP

	// for secondary index data
	IndexDataType byte = 40

	FullTextIndexDataType byte = 50
	// this type has a custom partition key length
	// to allow all the data store in the same partition
	// this type allow the transaction in the same tx group,
	// which will be stored in the same partition
	FixPartType byte = 80
	// in case there are more than 100 kinds of data types,
	// we use the extanded data for more types
	ExtandType byte = 90

	// use the exp table to store all the expire time for the key
	// and scan periodically to delete the expired keys
	ExpTimeType byte = 101
	ExpMetaType byte = 102
)

for backend store

View Source
const (
	MAX_BATCH_NUM  = 5000
	RangeDeleteNum = 500
)
View Source
const (
	MaxDatabases int = 10240

	MaxTableNameLen int = 255
	MaxColumnLen    int = 255
	//max key size
	MaxKeySize int = 10240

	//max hash field size
	MaxHashFieldSize int = 10240

	//max zset member size
	MaxZSetMemberSize int = 10240

	//max set member size
	MaxSetMemberSize int = 10240

	//max value size
	MaxValueSize int = 1024 * 1024 * 8
)
View Source
const (
	MaxCheckpointNum       = 10
	MaxRemoteCheckpointNum = 3
	HLLCacheSize           = 512
)
View Source
const (
	MinScore     int64 = -1<<63 + 1
	MaxScore     int64 = 1<<63 - 1
	InvalidScore int64 = -1 << 63

	AggregateSum byte = 0
	AggregateMin byte = 1
	AggregateMax byte = 2
)
View Source
const (
	EngType = "rockredis"
)
View Source
const (
	NilFlag byte = 0
)

Variables

View Source
var (
	ErrZScoreMiss   = errors.New("zset score miss")
	ErrWriteInROnly = errors.New("write not support in readonly mode")
)
View Source
var (
	ErrIndexStateInvalidChange = errors.New("index state change state is not invalid")
	ErrIndexDeleteNotInDeleted = errors.New("delete index in wrong state")
	ErrIndexClosed             = errors.New("index is closed")
)
View Source
var (
	ErrInvalidLengthIndexTypes = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowIndexTypes   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	ErrIndexExist          = errors.New("index already exist")
	ErrIndexTableNotExist  = errors.New("index table not exist")
	ErrIndexNotExist       = errors.New("index not exist")
	ErrIndexDeleted        = errors.New("index is deleted")
	ErrIndexValueNotNumber = errors.New("invalid value for number")
	ErrIndexValueType      = errors.New("invalid index value type")
)
View Source
var (
	ErrLocalBatchFullToCommit = errors.New("batched is fully filled and should commit right now")
	ErrLocalBatchedBuffFull   = errors.New("the local batched buffer is fully filled")
)
View Source
var IndexPropertyDType_name = map[int32]string{
	0: "Int64V",
	1: "Int32V",
	2: "StringV",
}
View Source
var IndexPropertyDType_value = map[string]int32{
	"Int64V":  0,
	"Int32V":  1,
	"StringV": 2,
}
View Source
var IndexState_name = map[int32]string{
	0: "InitIndex",
	1: "BuildingIndex",
	2: "BuildDoneIndex",
	3: "ReadyIndex",
	4: "DeletedIndex",
}
View Source
var IndexState_value = map[string]int32{
	"InitIndex":      0,
	"BuildingIndex":  1,
	"BuildDoneIndex": 2,
	"ReadyIndex":     3,
	"DeletedIndex":   4,
}
View Source
var (
	TypeName = map[byte]string{
		KVType:     "kv",
		HashType:   "hash",
		HSizeType:  "hsize",
		ListType:   "list",
		LMetaType:  "lmeta",
		ZSetType:   "zset",
		ZSizeType:  "zsize",
		ZScoreType: "zscore",
		SetType:    "set",
		SSizeType:  "ssize",
		JSONType:   "json",
	}
)

Functions

func CutOne

func CutOne(b []byte) (data []byte, remain []byte, err error)

func Decode

func Decode(b []byte, size int) ([]interface{}, error)

Decode decodes values from a byte slice generated with EncodeKey or EncodeValue before. size is the size of decoded slice.

func DecodeBytes

func DecodeBytes(b []byte) ([]byte, []byte, error)

DecodeBytes decodes bytes which is encoded by EncodeBytes before, returns the leftover bytes and decoded value if no error.

func DecodeBytesDesc

func DecodeBytesDesc(b []byte) ([]byte, []byte, error)

DecodeBytesDesc decodes bytes which is encoded by EncodeBytesDesc before, returns the leftover bytes and decoded value if no error.

func DecodeFloat

func DecodeFloat(b []byte) ([]byte, float64, error)

DecodeFloat decodes a float from a byte slice generated with EncodeFloat before.

func DecodeFloatDesc

func DecodeFloatDesc(b []byte) ([]byte, float64, error)

DecodeFloatDesc decodes a float from a byte slice generated with EncodeFloatDesc before.

func DecodeInt

func DecodeInt(b []byte) ([]byte, int64, error)

DecodeInt decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.

func DecodeIntDesc

func DecodeIntDesc(b []byte) ([]byte, int64, error)

DecodeIntDesc decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.

func DecodeOne

func DecodeOne(b []byte) (remain []byte, d interface{}, err error)

func DecodeUint

func DecodeUint(b []byte) ([]byte, uint64, error)

DecodeUint decodes value encoded by EncodeUint before. It returns the leftover un-decoded slice, decoded value if no error.

func DecodeUintDesc

func DecodeUintDesc(b []byte) ([]byte, uint64, error)

DecodeUintDesc decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.

func DisablePerfLevel added in v0.3.2

func DisablePerfLevel()

func EncodeBytes

func EncodeBytes(b []byte, data []byte) []byte

EncodeBytes guarantees the encoded value is in ascending order for comparison, encoding with the following rule:

[group1][marker1]...[groupN][markerN]
group is 8 bytes slice which is padding with 0.
marker is `0xFF - padding 0 count`

For example:

[] -> [0, 0, 0, 0, 0, 0, 0, 0, 247]
[1, 2, 3] -> [1, 2, 3, 0, 0, 0, 0, 0, 250]
[1, 2, 3, 0] -> [1, 2, 3, 0, 0, 0, 0, 0, 251]
[1, 2, 3, 4, 5, 6, 7, 8] -> [1, 2, 3, 4, 5, 6, 7, 8, 255, 0, 0, 0, 0, 0, 0, 0, 0, 247]

Refer: https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format#memcomparable-format

func EncodeBytesDesc

func EncodeBytesDesc(b []byte, data []byte) []byte

EncodeBytesDesc first encodes bytes using EncodeBytes, then bitwise reverses encoded value to guarantee the encoded value is in descending order for comparison.

func EncodeFloat

func EncodeFloat(b []byte, v float64) []byte

EncodeFloat encodes a float v into a byte slice which can be sorted lexicographically later. EncodeFloat guarantees that the encoded value is in ascending order for comparison.

func EncodeFloatDesc

func EncodeFloatDesc(b []byte, v float64) []byte

EncodeFloatDesc encodes a float v into a byte slice which can be sorted lexicographically later. EncodeFloatDesc guarantees that the encoded value is in descending order for comparison.

func EncodeInt

func EncodeInt(b []byte, v int64) []byte

EncodeInt appends the encoded value to slice b and returns the appended slice. EncodeInt guarantees that the encoded value is in ascending order for comparison.

func EncodeIntDesc

func EncodeIntDesc(b []byte, v int64) []byte

EncodeIntDesc appends the encoded value to slice b and returns the appended slice. EncodeIntDesc guarantees that the encoded value is in descending order for comparison.

func EncodeMaxKey

func EncodeMaxKey(b []byte) ([]byte, error)

func EncodeMemCmpKey

func EncodeMemCmpKey(b []byte, v ...interface{}) ([]byte, error)

EncodeKey appends the encoded values to byte slice b, returns the appended slice. It guarantees the encoded value is in ascending order for comparison.

func EncodeMinNotNull

func EncodeMinNotNull(b []byte) ([]byte, error)

func EncodeUint

func EncodeUint(b []byte, v uint64) []byte

EncodeUint appends the encoded value to slice b and returns the appended slice. EncodeUint guarantees that the encoded value is in ascending order for comparison.

func EncodeUintDesc

func EncodeUintDesc(b []byte, v uint64) []byte

EncodeUintDesc appends the encoded value to slice b and returns the appended slice. EncodeUintDesc guarantees that the encoded value is in descending order for comparison.

func FillDefaultOptions

func FillDefaultOptions(opts *RockOptions)

func Float64

func Float64(v []byte, err error) (float64, error)

func FormatInt64ToSlice

func FormatInt64ToSlice(v int64) []byte

func GetBackupDir

func GetBackupDir(base string) string

func GetBackupDirForRemote added in v0.4.3

func GetBackupDirForRemote(base string) string

func GetCheckpointDir

func GetCheckpointDir(term uint64, index uint64) string

func GetDataDirFromBase

func GetDataDirFromBase(base string) string

func GetRocksdbUint64

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

func Int64

func Int64(v []byte, err error) (int64, error)

func IsBatchableWrite

func IsBatchableWrite(cmd string) bool

func IsPerfEnabledLevel added in v0.3.2

func IsPerfEnabledLevel(lv int) bool

func MaxInt

func MaxInt(a int, b int) int

func MaxInt16

func MaxInt16(a int16, b int16) int16

func MaxInt32

func MaxInt32(a int32, b int32) int32

func MaxInt64

func MaxInt64(a int64, b int64) int64

func MaxInt8

func MaxInt8(a int8, b int8) int8

func MaxUint

func MaxUint(a uint, b uint) uint

func MaxUint16

func MaxUint16(a uint16, b uint16) uint16

func MaxUint32

func MaxUint32(a uint32, b uint32) uint32

func MaxUint64

func MaxUint64(a uint64, b uint64) uint64

func MaxUint8

func MaxUint8(a uint8, b uint8) uint8

func MinInt

func MinInt(a int, b int) int

func MinInt16

func MinInt16(a int16, b int16) int16

func MinInt32

func MinInt32(a int32, b int32) int32

func MinInt64

func MinInt64(a int64, b int64) int64

func MinInt8

func MinInt8(a int8, b int8) int8

func MinUint

func MinUint(a uint, b uint) uint

func MinUint16

func MinUint16(a uint16, b uint16) uint16

func MinUint32

func MinUint32(a uint32, b uint32) uint32

func MinUint64

func MinUint64(a uint64, b uint64) uint64

func MinUint8

func MinUint8(a uint8, b uint8) uint8

func PutFloat64

func PutFloat64(v float64) []byte

func PutInt64

func PutInt64(v int64) []byte

func PutRocksdbUint64

func PutRocksdbUint64(v uint64) []byte

func SetLogLevel

func SetLogLevel(level int32)

func SetLogger

func SetLogger(level int32, logger common.Logger)

func SetPerfLevel added in v0.3.2

func SetPerfLevel(level int)

func StrInt32

func StrInt32(v []byte, err error) (int32, error)

func StrInt64

func StrInt64(v []byte, err error) (int64, error)

func StrInt8

func StrInt8(v []byte, err error) (int8, error)

func StrUint64

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

func Uint64

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

Types

type BackupInfo

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

func (*BackupInfo) GetResult

func (self *BackupInfo) GetResult() ([]byte, error)

func (*BackupInfo) WaitReady

func (self *BackupInfo) WaitReady()

type CheckpointSortNames

type CheckpointSortNames []string

func (CheckpointSortNames) Len

func (self CheckpointSortNames) Len() int

func (CheckpointSortNames) Less

func (self CheckpointSortNames) Less(i, j int) bool

func (CheckpointSortNames) Swap

func (self CheckpointSortNames) Swap(i, j int)

type DBIterator

type DBIterator struct {
	*gorocksdb.Iterator
	// contains filtered or unexported fields
}

func NewDBIterator

func NewDBIterator(db *gorocksdb.DB, withSnap bool, prefixSame bool, lowbound []byte, upbound []byte, ignoreDel bool) (*DBIterator, error)

low_bound is inclusive upper bound is exclusive

func (*DBIterator) Close

func (it *DBIterator) Close()

func (*DBIterator) Key

func (it *DBIterator) Key() []byte

func (*DBIterator) NoTimestamp

func (it *DBIterator) NoTimestamp(vt byte)

func (*DBIterator) RefKey

func (it *DBIterator) RefKey() []byte

func (*DBIterator) RefValue

func (it *DBIterator) RefValue() []byte

func (*DBIterator) Value

func (it *DBIterator) Value() []byte

type ErrType

type ErrType int64
const (
	NotFound ErrType = 1
)

type HIndexResp

type HIndexResp struct {
	PKey          []byte
	IndexValue    []byte
	IndexIntValue int64
}

type HsetIndex

type HsetIndex struct {
	Table []byte
	HsetIndexInfo
}

func (*HsetIndex) RemoveRec

func (self *HsetIndex) RemoveRec(value []byte, pk []byte, wb *gorocksdb.WriteBatch)

func (*HsetIndex) SearchRec

func (self *HsetIndex) SearchRec(db *RockDB, cond *IndexCondition, countOnly bool) (int64, []HIndexResp, error)

func (*HsetIndex) UpdateRec

func (self *HsetIndex) UpdateRec(oldvalue []byte, value []byte, pk []byte, wb *gorocksdb.WriteBatch) error

type HsetIndexInfo

type HsetIndexInfo struct {
	Name       []byte             `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	IndexField []byte             `protobuf:"bytes,2,opt,name=index_field,json=indexField,proto3" json:"index_field,omitempty"`
	PrefixLen  int32              `protobuf:"varint,3,opt,name=prefix_len,json=prefixLen,proto3" json:"prefix_len,omitempty"`
	Unique     int32              `protobuf:"varint,4,opt,name=unique,proto3" json:"unique,omitempty"`
	ValueType  IndexPropertyDType `protobuf:"varint,5,opt,name=value_type,json=valueType,proto3,enum=rockredis.IndexPropertyDType" json:"value_type,omitempty"`
	State      IndexState         `protobuf:"varint,6,opt,name=state,proto3,enum=rockredis.IndexState" json:"state,omitempty"`
}

func (*HsetIndexInfo) Descriptor

func (*HsetIndexInfo) Descriptor() ([]byte, []int)

func (*HsetIndexInfo) Marshal

func (m *HsetIndexInfo) Marshal() (dAtA []byte, err error)

func (*HsetIndexInfo) MarshalTo

func (m *HsetIndexInfo) MarshalTo(dAtA []byte) (int, error)

func (*HsetIndexInfo) ProtoMessage

func (*HsetIndexInfo) ProtoMessage()

func (*HsetIndexInfo) Reset

func (m *HsetIndexInfo) Reset()

func (*HsetIndexInfo) Size

func (m *HsetIndexInfo) Size() (n int)

func (*HsetIndexInfo) String

func (m *HsetIndexInfo) String() string

func (*HsetIndexInfo) Unmarshal

func (m *HsetIndexInfo) Unmarshal(dAtA []byte) error

type HsetIndexList

type HsetIndexList struct {
	HsetIndexes []HsetIndexInfo `protobuf:"bytes,1,rep,name=hset_indexes,json=hsetIndexes" json:"hset_indexes"`
}

func (*HsetIndexList) Descriptor

func (*HsetIndexList) Descriptor() ([]byte, []int)

func (*HsetIndexList) Marshal

func (m *HsetIndexList) Marshal() (dAtA []byte, err error)

func (*HsetIndexList) MarshalTo

func (m *HsetIndexList) MarshalTo(dAtA []byte) (int, error)

func (*HsetIndexList) ProtoMessage

func (*HsetIndexList) ProtoMessage()

func (*HsetIndexList) Reset

func (m *HsetIndexList) Reset()

func (*HsetIndexList) Size

func (m *HsetIndexList) Size() (n int)

func (*HsetIndexList) String

func (m *HsetIndexList) String() string

func (*HsetIndexList) Unmarshal

func (m *HsetIndexList) Unmarshal(dAtA []byte) error

type IndexCondition

type IndexCondition struct {
	StartKey     []byte
	IncludeStart bool
	EndKey       []byte
	IncludeEnd   bool
	Offset       int
	PKOffset     []byte
	Limit        int
}

TODO: handle IN, LIKE, NOT equal condition in future handle index condition combine (AND, OR)

type IndexMgr

type IndexMgr struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewIndexMgr

func NewIndexMgr() *IndexMgr

func (*IndexMgr) AddHsetIndex

func (im *IndexMgr) AddHsetIndex(db *RockDB, hindex *HsetIndex) error

func (*IndexMgr) Close

func (im *IndexMgr) Close()

func (*IndexMgr) GetAllIndexSchemaInfo

func (im *IndexMgr) GetAllIndexSchemaInfo(db *RockDB) (map[string]*common.IndexSchema, error)

func (*IndexMgr) GetHsetIndex

func (im *IndexMgr) GetHsetIndex(table string, field string) (*HsetIndex, error)

func (*IndexMgr) GetIndexSchemaInfo

func (im *IndexMgr) GetIndexSchemaInfo(db *RockDB, table string) (*common.IndexSchema, error)

func (*IndexMgr) GetTableIndexes

func (im *IndexMgr) GetTableIndexes(table string) *TableIndexContainer

func (*IndexMgr) LoadIndexes

func (im *IndexMgr) LoadIndexes(db *RockDB) error

func (*IndexMgr) UpdateHsetIndexState

func (im *IndexMgr) UpdateHsetIndexState(db *RockDB, table string, field string, state IndexState) error

type IndexPropertyDType

type IndexPropertyDType int32
const (
	Int64V  IndexPropertyDType = 0
	Int32V  IndexPropertyDType = 1
	StringV IndexPropertyDType = 2
)

func (IndexPropertyDType) EnumDescriptor

func (IndexPropertyDType) EnumDescriptor() ([]byte, []int)

func (IndexPropertyDType) String

func (x IndexPropertyDType) String() string

type IndexState

type IndexState int32
const (
	InitIndex      IndexState = 0
	BuildingIndex  IndexState = 1
	BuildDoneIndex IndexState = 2
	ReadyIndex     IndexState = 3
	DeletedIndex   IndexState = 4
)

func (IndexState) EnumDescriptor

func (IndexState) EnumDescriptor() ([]byte, []int)

func (IndexState) String

func (x IndexState) String() string

type ItemContainer

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

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 JSONIndex

type JSONIndex struct {
	Table []byte
	HsetIndexInfo
}

type Limit

type Limit struct {
	Offset int
	Count  int
}

type Range

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

type RangeLimitedIterator

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

func NewDBRangeIterator

func NewDBRangeIterator(db *gorocksdb.DB, min []byte, max []byte, rtype uint8,
	reverse bool) (*RangeLimitedIterator, error)

func NewDBRangeLimitIterator

func NewDBRangeLimitIterator(db *gorocksdb.DB, min []byte, max []byte, rtype uint8,
	offset int, count int, reverse bool) (*RangeLimitedIterator, 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 NewSnapshotDBRangeIterator

func NewSnapshotDBRangeIterator(db *gorocksdb.DB, min []byte, max []byte, rtype uint8,
	reverse bool) (*RangeLimitedIterator, error)

func NewSnapshotDBRangeLimitIterator

func NewSnapshotDBRangeLimitIterator(db *gorocksdb.DB, min []byte, max []byte, rtype uint8,
	offset int, count int, reverse bool) (*RangeLimitedIterator, error)

func (*RangeLimitedIterator) Next

func (it *RangeLimitedIterator) Next()

func (*RangeLimitedIterator) Valid

func (it *RangeLimitedIterator) Valid() bool

type RockConfig

type RockConfig struct {
	DataDir            string
	EnableTableCounter bool
	// this will ignore all update and non-exist delete
	EstimateTableCounter bool
	ExpirationPolicy     common.ExpirationPolicy
	DefaultReadOpts      *gorocksdb.ReadOptions
	DefaultWriteOpts     *gorocksdb.WriteOptions
	SharedConfig         *SharedRockConfig
	RockOptions
}

func NewRockConfig

func NewRockConfig() *RockConfig

type RockDB

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

func OpenRockDB

func OpenRockDB(cfg *RockConfig) (*RockDB, error)

func (*RockDB) AddHsetIndex

func (r *RockDB) AddHsetIndex(table string, hindex *common.HsetIndexSchema) error

func (*RockDB) Append

func (db *RockDB) Append(ts int64, key []byte, value []byte) (int64, error)

func (*RockDB) Backup

func (r *RockDB) Backup(term uint64, index uint64) *BackupInfo

func (*RockDB) BeginBatchWrite

func (r *RockDB) BeginBatchWrite() error

func (*RockDB) CheckExpiredData

func (r *RockDB) CheckExpiredData(buffer common.ExpiredDataBuffer, stop chan struct{}) error

func (*RockDB) Close

func (r *RockDB) Close()

func (*RockDB) CommitBatchWrite

func (r *RockDB) CommitBatchWrite() error

func (*RockDB) CompactRange

func (r *RockDB) CompactRange()

func (*RockDB) CompactTableRange added in v0.3.2

func (r *RockDB) CompactTableRange(table string)

[start, end)

func (*RockDB) Decr

func (db *RockDB) Decr(ts int64, key []byte) (int64, error)

func (*RockDB) DecrBy

func (db *RockDB) DecrBy(ts int64, key []byte, decrement int64) (int64, error)

func (*RockDB) DelKeys

func (db *RockDB) DelKeys(keys ...[]byte) (int64, error)

func (*RockDB) DelTableKeyCount added in v0.3.2

func (db *RockDB) DelTableKeyCount(table []byte, wb *gorocksdb.WriteBatch) error

func (*RockDB) DeleteTableRange added in v0.3.2

func (r *RockDB) DeleteTableRange(dryrun bool, table string, start []byte, end []byte) error

[start, end)

func (*RockDB) Expire

func (db *RockDB) Expire(key []byte, duration int64) (int64, error)

func (*RockDB) FullScan

func (db *RockDB) FullScan(dataType common.DataType, cursor []byte, count int, match string) *common.FullScanResult

func (*RockDB) GetAllIndexSchema

func (r *RockDB) GetAllIndexSchema() (map[string]*common.IndexSchema, error)

func (*RockDB) GetBTablesSizes added in v0.3.2

func (r *RockDB) GetBTablesSizes(tables [][]byte) []int64

func (*RockDB) GetBackupBase

func (r *RockDB) GetBackupBase() string

func (*RockDB) GetBackupDir

func (r *RockDB) GetBackupDir() string

func (*RockDB) GetBackupDirForRemote added in v0.4.3

func (r *RockDB) GetBackupDirForRemote() string

func (*RockDB) GetDataDir

func (r *RockDB) GetDataDir() string

func (*RockDB) GetHsetIndexTables

func (db *RockDB) GetHsetIndexTables() [][]byte

func (*RockDB) GetIndexSchema

func (r *RockDB) GetIndexSchema(table string) (*common.IndexSchema, error)

func (*RockDB) GetInternalPropertyStatus

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

func (*RockDB) GetInternalStatus

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

func (*RockDB) GetRange

func (db *RockDB) GetRange(key []byte, start int, end int) ([]byte, error)

func (*RockDB) GetStatistics

func (r *RockDB) GetStatistics() string

func (*RockDB) GetTableApproximateNumInRange added in v0.3.2

func (r *RockDB) GetTableApproximateNumInRange(table string, start []byte, end []byte) int64

[start, end)

func (*RockDB) GetTableHsetIndexValue

func (db *RockDB) GetTableHsetIndexValue(table []byte) ([]byte, error)

func (*RockDB) GetTableKeyCount

func (db *RockDB) GetTableKeyCount(table []byte) (int64, error)

func (*RockDB) GetTableSizeInRange added in v0.3.2

func (r *RockDB) GetTableSizeInRange(table string, start []byte, end []byte) int64

[start, end)

func (*RockDB) GetTables

func (db *RockDB) GetTables() [][]byte

func (*RockDB) GetTablesSizes added in v0.3.2

func (r *RockDB) GetTablesSizes(tables []string) []int64

[start, end)

func (*RockDB) HClear

func (db *RockDB) HClear(hkey []byte) (int64, error)

func (*RockDB) HDel

func (db *RockDB) HDel(key []byte, args ...[]byte) (int64, error)

func (*RockDB) HExpire

func (db *RockDB) HExpire(key []byte, duration int64) (int64, error)

func (*RockDB) HGet

func (db *RockDB) HGet(key []byte, field []byte) ([]byte, error)

func (*RockDB) HGetAll

func (db *RockDB) HGetAll(key []byte) (int64, chan common.KVRecordRet, error)

func (*RockDB) HGetVer

func (db *RockDB) HGetVer(key []byte, field []byte) (int64, error)

func (*RockDB) HIncrBy

func (db *RockDB) HIncrBy(ts int64, key []byte, field []byte, delta int64) (int64, error)

func (*RockDB) HKeyExists

func (db *RockDB) HKeyExists(key []byte) (int64, error)

func (*RockDB) HKeys

func (db *RockDB) HKeys(key []byte) (int64, chan common.KVRecordRet, error)

func (*RockDB) HLen

func (db *RockDB) HLen(hkey []byte) (int64, error)

func (*RockDB) HMclear

func (db *RockDB) HMclear(keys ...[]byte)

func (*RockDB) HMget

func (db *RockDB) HMget(key []byte, args ...[]byte) ([][]byte, error)

func (*RockDB) HMset

func (db *RockDB) HMset(ts int64, key []byte, args ...common.KVRecord) error

func (*RockDB) HPersist

func (db *RockDB) HPersist(key []byte) (int64, error)

func (*RockDB) HScan

func (db *RockDB) HScan(key []byte, cursor []byte, count int, match string) ([]common.KVRecord, error)

func (*RockDB) HSet

func (db *RockDB) HSet(ts int64, checkNX bool, key []byte, field []byte, value []byte) (int64, error)

func (*RockDB) HValues

func (db *RockDB) HValues(key []byte) (int64, chan common.KVRecordRet, error)

func (*RockDB) HashTtl

func (db *RockDB) HashTtl(key []byte) (t int64, err error)

func (*RockDB) HsetIndexSearch

func (db *RockDB) HsetIndexSearch(table []byte, field []byte, cond *IndexCondition, countOnly bool) (IndexPropertyDType, int64, []HIndexResp, error)

search return the hash keys for matching field value

func (*RockDB) Incr

func (db *RockDB) Incr(ts int64, key []byte) (int64, error)

func (*RockDB) IncrBy

func (db *RockDB) IncrBy(ts int64, key []byte, increment int64) (int64, error)

func (*RockDB) IncrTableKeyCount

func (db *RockDB) IncrTableKeyCount(table []byte, delta int64, wb *gorocksdb.WriteBatch) error

func (*RockDB) IsLocalBackupOK

func (r *RockDB) IsLocalBackupOK(term uint64, index uint64) (bool, error)

func (*RockDB) JArrayAppend

func (db *RockDB) JArrayAppend(ts int64, key []byte, path []byte, jsons ...[]byte) (int64, error)

func (*RockDB) JArrayLen

func (db *RockDB) JArrayLen(key []byte, path []byte) (int64, error)

func (*RockDB) JArrayPop

func (db *RockDB) JArrayPop(ts int64, key []byte, path []byte) (string, error)

func (*RockDB) JDel

func (db *RockDB) JDel(ts int64, key []byte, path []byte) (int64, error)

func (*RockDB) JGet

func (db *RockDB) JGet(key []byte, paths ...[]byte) ([]string, error)

func (*RockDB) JKeyExists

func (db *RockDB) JKeyExists(key []byte) (int64, error)

func (*RockDB) JMGet

func (db *RockDB) JMGet(path []byte, keys ...[]byte) ([]string, error)

func (*RockDB) JMset

func (db *RockDB) JMset(ts int64, key []byte, args ...common.KVRecord) error

func (*RockDB) JObjKeys

func (db *RockDB) JObjKeys(key []byte, path []byte) ([]string, error)

func (*RockDB) JObjLen

func (db *RockDB) JObjLen(key []byte, path []byte) (int64, error)

func (*RockDB) JSet

func (db *RockDB) JSet(ts int64, key []byte, path []byte, value []byte) (int64, error)

func (*RockDB) JType

func (db *RockDB) JType(key []byte, path []byte) (string, error)

func (*RockDB) KVDel

func (db *RockDB) KVDel(key []byte) (int64, error)

ps : here just focus on deleting the key-value data,

any other likes expire is ignore.

func (*RockDB) KVDelWithBatch

func (db *RockDB) KVDelWithBatch(key []byte, wb *gorocksdb.WriteBatch) error

func (*RockDB) KVExists

func (db *RockDB) KVExists(keys ...[]byte) (int64, error)

func (*RockDB) KVGet

func (db *RockDB) KVGet(key []byte) ([]byte, error)

func (*RockDB) KVGetVer

func (db *RockDB) KVGetVer(key []byte) (int64, error)

func (*RockDB) KVSet

func (db *RockDB) KVSet(ts int64, rawKey []byte, value []byte) error

func (*RockDB) KVTtl

func (db *RockDB) KVTtl(key []byte) (t int64, err error)

func (*RockDB) LClear

func (db *RockDB) LClear(key []byte) (int64, error)

func (*RockDB) LExpire

func (db *RockDB) LExpire(key []byte, duration int64) (int64, error)

func (*RockDB) LFixKey

func (db *RockDB) LFixKey(ts int64, key []byte)

func (*RockDB) LIndex

func (db *RockDB) LIndex(key []byte, index int64) ([]byte, error)

func (*RockDB) LKeyExists

func (db *RockDB) LKeyExists(key []byte) (int64, error)

func (*RockDB) LLen

func (db *RockDB) LLen(key []byte) (int64, error)

func (*RockDB) LMclear

func (db *RockDB) LMclear(keys ...[]byte) (int64, error)

func (*RockDB) LPersist

func (db *RockDB) LPersist(key []byte) (int64, error)

func (*RockDB) LPop

func (db *RockDB) LPop(ts int64, key []byte) ([]byte, error)

func (*RockDB) LPush

func (db *RockDB) LPush(ts int64, key []byte, args ...[]byte) (int64, error)

func (*RockDB) LRange

func (db *RockDB) LRange(key []byte, start int64, stop int64) ([][]byte, error)

func (*RockDB) LSet

func (db *RockDB) LSet(ts int64, key []byte, index int64, value []byte) error

func (*RockDB) LTrim

func (db *RockDB) LTrim(ts int64, key []byte, start, stop int64) error

func (*RockDB) LTrimBack

func (db *RockDB) LTrimBack(ts int64, key []byte, trimSize int64) (int64, error)

func (*RockDB) LTrimFront

func (db *RockDB) LTrimFront(ts int64, key []byte, trimSize int64) (int64, error)

func (*RockDB) LVer

func (db *RockDB) LVer(key []byte) (int64, error)

func (*RockDB) ListTtl

func (db *RockDB) ListTtl(key []byte) (t int64, err error)

func (*RockDB) MGet

func (db *RockDB) MGet(keys ...[]byte) ([][]byte, []error)

func (*RockDB) MSet

func (db *RockDB) MSet(ts int64, args ...common.KVRecord) error

func (*RockDB) MaybeClearBatch

func (r *RockDB) MaybeClearBatch()

func (*RockDB) MaybeCommitBatch

func (r *RockDB) MaybeCommitBatch() error

func (*RockDB) PFAdd

func (db *RockDB) PFAdd(ts int64, rawKey []byte, elems ...[]byte) (int64, error)

func (*RockDB) PFCount

func (db *RockDB) PFCount(ts int64, keys ...[]byte) (int64, error)

func (*RockDB) Persist

func (db *RockDB) Persist(key []byte) (int64, error)

func (*RockDB) RPop

func (db *RockDB) RPop(ts int64, key []byte) ([]byte, error)

func (*RockDB) RPush

func (db *RockDB) RPush(ts int64, key []byte, args ...[]byte) (int64, error)

func (*RockDB) Restore

func (r *RockDB) Restore(term uint64, index uint64) error

func (*RockDB) RestoreFromRemoteBackup added in v0.4.3

func (r *RockDB) RestoreFromRemoteBackup(term uint64, index uint64) error

func (*RockDB) SAdd

func (db *RockDB) SAdd(ts int64, key []byte, args ...[]byte) (int64, error)

func (*RockDB) SCard

func (db *RockDB) SCard(key []byte) (int64, error)

func (*RockDB) SClear

func (db *RockDB) SClear(key []byte) (int64, error)

func (*RockDB) SExpire

func (db *RockDB) SExpire(key []byte, duration int64) (int64, error)

func (*RockDB) SGetVer

func (db *RockDB) SGetVer(key []byte) (int64, error)

func (*RockDB) SIsMember

func (db *RockDB) SIsMember(key []byte, member []byte) (int64, error)

func (*RockDB) SKeyExists

func (db *RockDB) SKeyExists(key []byte) (int64, error)

func (*RockDB) SMclear

func (db *RockDB) SMclear(keys ...[]byte) (int64, error)

func (*RockDB) SMembers

func (db *RockDB) SMembers(key []byte) ([][]byte, error)

func (*RockDB) SPersist

func (db *RockDB) SPersist(key []byte) (int64, error)

func (*RockDB) SPop added in v0.4.0

func (db *RockDB) SPop(ts int64, key []byte, count int) ([][]byte, error)

func (*RockDB) SRem

func (db *RockDB) SRem(ts int64, key []byte, args ...[]byte) (int64, error)

func (*RockDB) SScan

func (db *RockDB) SScan(key []byte, cursor []byte, count int, match string) ([][]byte, error)

func (*RockDB) Scan

func (db *RockDB) Scan(dataType common.DataType, cursor []byte, count int, match string) ([][]byte, error)

func (*RockDB) ScanWithBuffer

func (db *RockDB) ScanWithBuffer(dataType common.DataType, cursor []byte, count int, match string, buffer [][]byte) ([][]byte, error)

func (*RockDB) SetEx

func (db *RockDB) SetEx(ts int64, rawKey []byte, duration int64, value []byte) error

func (*RockDB) SetNX

func (db *RockDB) SetNX(ts int64, key []byte, value []byte) (int64, error)

func (*RockDB) SetRange

func (db *RockDB) SetRange(ts int64, key []byte, offset int, value []byte) (int64, error)

func (*RockDB) SetTableHsetIndexValue

func (db *RockDB) SetTableHsetIndexValue(table []byte, value []byte) error

func (*RockDB) SetTtl

func (db *RockDB) SetTtl(key []byte) (t int64, err error)

func (*RockDB) StrLen

func (db *RockDB) StrLen(key []byte) (int64, error)

func (*RockDB) UpdateHsetIndexState

func (r *RockDB) UpdateHsetIndexState(table string, hindex *common.HsetIndexSchema) error

func (*RockDB) ZAdd

func (db *RockDB) ZAdd(ts int64, key []byte, args ...common.ScorePair) (int64, error)

func (*RockDB) ZCard

func (db *RockDB) ZCard(key []byte) (int64, error)

func (*RockDB) ZClear

func (db *RockDB) ZClear(key []byte) (int64, error)

func (*RockDB) ZCount

func (db *RockDB) ZCount(key []byte, min float64, max float64) (int64, error)

func (*RockDB) ZExpire

func (db *RockDB) ZExpire(key []byte, duration int64) (int64, error)

func (*RockDB) ZFixKey

func (db *RockDB) ZFixKey(ts int64, key []byte) error

func (*RockDB) ZGetVer

func (db *RockDB) ZGetVer(key []byte) (int64, error)

func (*RockDB) ZIncrBy

func (db *RockDB) ZIncrBy(ts int64, key []byte, delta float64, member []byte) (float64, error)

func (*RockDB) ZKeyExists

func (db *RockDB) ZKeyExists(key []byte) (int64, error)

func (*RockDB) ZLexCount

func (db *RockDB) ZLexCount(key []byte, min []byte, max []byte, rangeType uint8) (int64, error)

func (*RockDB) ZMclear

func (db *RockDB) ZMclear(keys ...[]byte) (int64, error)

func (*RockDB) ZPersist

func (db *RockDB) ZPersist(key []byte) (int64, error)

func (*RockDB) ZRange

func (db *RockDB) ZRange(key []byte, start int, stop int) ([]common.ScorePair, error)

func (*RockDB) ZRangeByLex

func (db *RockDB) ZRangeByLex(key []byte, min []byte, max []byte, rangeType uint8, offset int, count int) ([][]byte, error)

func (*RockDB) ZRangeByScore

func (db *RockDB) ZRangeByScore(key []byte, min float64, max float64,
	offset int, count int) ([]common.ScorePair, error)

min and max must be inclusive if no limit, set offset = 0 and count = -1

func (*RockDB) ZRangeByScoreGeneric

func (db *RockDB) ZRangeByScoreGeneric(key []byte, min float64, max float64,
	offset int, count int, reverse bool) ([]common.ScorePair, error)

min and max must be inclusive if no limit, set offset = 0 and count = -1

func (*RockDB) ZRangeGeneric

func (db *RockDB) ZRangeGeneric(key []byte, start int, stop int, reverse bool) ([]common.ScorePair, error)

func (*RockDB) ZRank

func (db *RockDB) ZRank(key []byte, member []byte) (int64, error)

func (*RockDB) ZRem

func (db *RockDB) ZRem(ts int64, key []byte, members ...[]byte) (int64, error)

func (*RockDB) ZRemRangeByLex

func (db *RockDB) ZRemRangeByLex(ts int64, key []byte, min []byte, max []byte, rangeType uint8) (int64, error)

func (*RockDB) ZRemRangeByRank

func (db *RockDB) ZRemRangeByRank(ts int64, key []byte, start int, stop int) (int64, error)

func (*RockDB) ZRemRangeByScore

func (db *RockDB) ZRemRangeByScore(ts int64, key []byte, min float64, max float64) (int64, error)

min and max must be inclusive

func (*RockDB) ZRevRange

func (db *RockDB) ZRevRange(key []byte, start int, stop int) ([]common.ScorePair, error)

func (*RockDB) ZRevRangeByScore

func (db *RockDB) ZRevRangeByScore(key []byte, min float64, max float64, offset int, count int) ([]common.ScorePair, error)

min and max must be inclusive if no limit, set offset = 0 and count = -1

func (*RockDB) ZRevRank

func (db *RockDB) ZRevRank(key []byte, member []byte) (int64, error)

func (*RockDB) ZScan

func (db *RockDB) ZScan(key []byte, cursor []byte, count int, match string) ([]common.ScorePair, error)

func (*RockDB) ZScore

func (db *RockDB) ZScore(key []byte, member []byte) (float64, error)

func (*RockDB) ZSetTtl

func (db *RockDB) ZSetTtl(key []byte) (t int64, err error)

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"`
	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"`
}

type SharedRockConfig added in v0.3.2

type SharedRockConfig struct {
	SharedCache       *gorocksdb.Cache
	SharedEnv         *gorocksdb.Env
	SharedRateLimiter *gorocksdb.RateLimiter
}

func NewSharedRockConfig added in v0.3.2

func NewSharedRockConfig(opt RockOptions) *SharedRockConfig

func (*SharedRockConfig) Destroy added in v0.3.2

func (src *SharedRockConfig) Destroy()

type TTLChecker

type TTLChecker struct {
	sync.Mutex
	// contains filtered or unexported fields
}

type TableIndexContainer

type TableIndexContainer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewIndexContainer

func NewIndexContainer() *TableIndexContainer

func (*TableIndexContainer) GetHIndexNoLock

func (tic *TableIndexContainer) GetHIndexNoLock(field string) *HsetIndex

func (*TableIndexContainer) GetJSONIndexNoLock

func (tic *TableIndexContainer) GetJSONIndexNoLock(path string) *JSONIndex

Jump to

Keyboard shortcuts

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