rockredis

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: 36 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)

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
	BitmapType     byte = 32
	BitmapMetaType byte = 33

	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 = 5000
)
View Source
const (
	MaxDatabases int = 10240

	MaxTableNameLen int = 255
	MaxColumnLen    int = 255
	//max key size
	MaxKeySize int = common.MaxKeySize

	// subkey length for hash/set/zset
	MaxSubKeyLen int = common.MaxSubKeyLen

	//max value size
	MaxValueSize int = common.MaxValueSize
)
View Source
const (
	MaxCheckpointNum       = 10
	MaxRemoteCheckpointNum = 3
	HLLReadCacheSize       = 1024
	HLLWriteCacheSize      = 32
)
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 (

	// 2MB
	MaxBitOffset = 2 * 8 * 1024 * 1024
)

kv new format as below: KVType | key -> |value header| value | modify time|

View Source
const (
	MaxBitOffsetV2 = math.MaxUint32 - 1
)
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 ErrBitOverflow = errors.New("bit offset overflowed")
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 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 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 GetLatestCheckpoint added in v0.6.2

func GetLatestCheckpoint(checkpointDir string, skipN int, matchFunc func(string) bool) 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 IsMemberNotExist added in v0.9.2

func IsMemberNotExist(err error) bool

func IsNeedAbortError added in v0.8.1

func IsNeedAbortError(err error) 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 PutInt64ToBuf added in v0.8.0

func PutInt64ToBuf(v int64, b []byte)

func PutRocksdbUint64

func PutRocksdbUint64(v uint64) []byte

func SetLogLevel

func SetLogLevel(level int32)

func SetLogger

func SetLogger(level int32, logger common.Logger)

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 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 engine.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 engine.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

func (*HsetIndexInfo) XXX_DiscardUnknown added in v0.7.1

func (m *HsetIndexInfo) XXX_DiscardUnknown()

func (*HsetIndexInfo) XXX_Marshal added in v0.7.1

func (m *HsetIndexInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HsetIndexInfo) XXX_Merge added in v0.7.1

func (m *HsetIndexInfo) XXX_Merge(src proto.Message)

func (*HsetIndexInfo) XXX_Size added in v0.7.1

func (m *HsetIndexInfo) XXX_Size() int

func (*HsetIndexInfo) XXX_Unmarshal added in v0.7.1

func (m *HsetIndexInfo) XXX_Unmarshal(b []byte) error

type HsetIndexList

type HsetIndexList struct {
	HsetIndexes []HsetIndexInfo `protobuf:"bytes,1,rep,name=hset_indexes,json=hsetIndexes,proto3" 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

func (*HsetIndexList) XXX_DiscardUnknown added in v0.7.1

func (m *HsetIndexList) XXX_DiscardUnknown()

func (*HsetIndexList) XXX_Marshal added in v0.7.1

func (m *HsetIndexList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HsetIndexList) XXX_Merge added in v0.7.1

func (m *HsetIndexList) XXX_Merge(src proto.Message)

func (*HsetIndexList) XXX_Size added in v0.7.1

func (m *HsetIndexList) XXX_Size() int

func (*HsetIndexList) XXX_Unmarshal added in v0.7.1

func (m *HsetIndexList) XXX_Unmarshal(b []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 JSONIndex

type JSONIndex struct {
	Table []byte
	HsetIndexInfo
}

type RockDB

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

func OpenRockDB

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

func (*RockDB) AbortBatch added in v0.8.1

func (r *RockDB) AbortBatch()

func (*RockDB) AddHsetIndex

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

func (*RockDB) Append

func (db *RockDB) Append(ts int64, rawKey []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) BitClear added in v0.8.0

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

func (*RockDB) BitCountV2 added in v0.8.0

func (db *RockDB) BitCountV2(key []byte, start, end int64) (int64, error)

func (*RockDB) BitExpire added in v0.8.0

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

func (*RockDB) BitGetV2 added in v0.8.0

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

func (*RockDB) BitGetVer added in v0.8.0

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

func (*RockDB) BitKeyExist added in v0.8.0

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

func (*RockDB) BitPersist added in v0.8.0

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

func (*RockDB) BitSetOld added in v0.8.0

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

BitSet set the bitmap data with format as below: key -> 0(first bit) 0 0 0 0 0 0 0 (last bit) | (second byte with 8 bits) | .... | (last byte with 8bits) at most MaxBitOffset/8 bytes for each bitmap

func (*RockDB) BitSetV2 added in v0.8.0

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

BitSetV2 set the bitmap data with new format as below: key:0 -> 0(first bit) 0 0 0 0 0 0 0 (last bit) | (second byte with 8 bits) | .... | (last byte with 8bits) at most bitmapSegBytes bytes for each segment key:1024 -> same as key:0 key:2048 -> same as key:0 ... key:512KB -> ... key:512MB ->

func (*RockDB) BitTtl added in v0.8.0

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

func (*RockDB) Close

func (r *RockDB) Close()

func (*RockDB) CommitBatchWrite

func (r *RockDB) CommitBatchWrite() error

func (*RockDB) CompactAllRange added in v0.9.1

func (r *RockDB) CompactAllRange()

func (*RockDB) CompactOldExpireData added in v0.9.2

func (r *RockDB) CompactOldExpireData()

func (*RockDB) CompactRange

func (r *RockDB) CompactRange(minKey []byte, maxKey []byte)

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) DelIfEQ added in v0.9.0

func (db *RockDB) DelIfEQ(ts int64, rawKey []byte, oldV []byte) (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 engine.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) DisableManualCompact added in v0.9.2

func (r *RockDB) DisableManualCompact(disable bool)

interrupt the manual compact to avoid stall too long?

func (*RockDB) Exist added in v0.9.0

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

func (*RockDB) ExistNoLock added in v0.9.0

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

func (*RockDB) Expire

func (db *RockDB) Expire(ts int64, rawKey []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) GetApproximateTotalNum added in v0.9.3

func (r *RockDB) GetApproximateTotalNum() int64

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) GetBytes added in v0.9.0

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

func (*RockDB) GetBytesNoLock added in v0.9.0

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

func (*RockDB) GetCollVersionKey added in v0.8.0

func (db *RockDB) GetCollVersionKey(ts int64, dt byte, key []byte, useLock bool) (collVerKeyInfo, error)

if run in raft write loop should avoid lock.

func (*RockDB) GetCompactFilterStats added in v0.9.2

func (r *RockDB) GetCompactFilterStats() metric.CompactFilterStats

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 int64, end int64) ([]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) GetTopLargeKeys added in v0.8.4

func (r *RockDB) GetTopLargeKeys() []metric.TopNInfo

func (*RockDB) GetValueWithOp added in v0.7.1

func (db *RockDB) GetValueWithOp(rawKey []byte,
	op func([]byte) error) error

func (*RockDB) GetValueWithOpNoLock added in v0.7.1

func (db *RockDB) GetValueWithOpNoLock(rawKey []byte,
	op func([]byte) error) error

func (*RockDB) HClear

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

func (*RockDB) HDel

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

func (*RockDB) HExist added in v0.7.1

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

func (*RockDB) HExpire

func (db *RockDB) HExpire(ts int64, 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, []common.KVRecordRet, error)

func (*RockDB) HGetAllExpired added in v0.9.2

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

func (*RockDB) HGetExpired added in v0.9.2

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

func (*RockDB) HGetVer

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

func (*RockDB) HGetWithOp added in v0.7.1

func (db *RockDB) HGetWithOp(key []byte, field []byte, op func([]byte) error) 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, []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) HMgetExpired added in v0.9.2

func (db *RockDB) HMgetExpired(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(ts int64, key []byte) (int64, error)

func (*RockDB) HScan

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

func (*RockDB) HSet

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

func (*RockDB) HValues

func (db *RockDB) HValues(key []byte) (int64, []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 engine.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) KVDelWithBatch

func (db *RockDB) KVDelWithBatch(key []byte, wb engine.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) KVGetExpired added in v0.9.2

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

KVGetExpired will get the value even it is expired

func (*RockDB) KVGetSet added in v0.5.2

func (db *RockDB) KVGetSet(ts int64, rawKey []byte, value []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) KVSetWithOpts added in v0.9.0

func (db *RockDB) KVSetWithOpts(ts int64, rawKey []byte, value []byte, duration int64, createOnly bool, updateOnly bool) (int64, error)

func (*RockDB) KVTtl

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

func (*RockDB) LClear

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

func (*RockDB) LExpire

func (db *RockDB) LExpire(ts int64, 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(ts int64, 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) MaybeCommitBatch

func (r *RockDB) MaybeCommitBatch() error

func (*RockDB) MultiGetBytes added in v0.9.0

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

func (*RockDB) NewDBRangeIterator added in v0.9.0

func (r *RockDB) NewDBRangeIterator(min []byte, max []byte, rtype uint8,
	reverse bool) (*engine.RangeLimitedIterator, error)

make sure close all the iterator before do any write on engine, since it may have lock on read/iterator

func (*RockDB) NewDBRangeIteratorWithOpts added in v0.9.0

func (r *RockDB) NewDBRangeIteratorWithOpts(opts engine.IteratorOpts) (*engine.RangeLimitedIterator, error)

func (*RockDB) NewDBRangeLimitIterator added in v0.9.0

func (r *RockDB) NewDBRangeLimitIterator(min []byte, max []byte, rtype uint8,
	offset int, count int, reverse bool) (*engine.RangeLimitedIterator, error)

func (*RockDB) NewDBRangeLimitIteratorWithOpts added in v0.9.0

func (r *RockDB) NewDBRangeLimitIteratorWithOpts(opts engine.IteratorOpts) (*engine.RangeLimitedIterator, 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(ts int64, rawKey []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) RegisterCompactCallback added in v0.9.2

func (r *RockDB) RegisterCompactCallback()

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(ts int64, key []byte) (int64, error)

func (*RockDB) SExpire

func (db *RockDB) SExpire(ts int64, 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(ts int64, 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) SRandMembers added in v0.8.0

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

we do not use rand here

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, reverse bool) ([][]byte, error)

func (*RockDB) Scan

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

func (*RockDB) ScanWithBuffer

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

func (*RockDB) SetEx

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

func (*RockDB) SetIfEQ added in v0.9.0

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

func (*RockDB) SetLatestSnapIndex added in v0.7.1

func (r *RockDB) SetLatestSnapIndex(i uint64)

func (*RockDB) SetMaxBackgroundOptions added in v0.7.1

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

func (*RockDB) SetNX

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

func (*RockDB) SetRange

func (db *RockDB) SetRange(ts int64, rawKey []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(ts int64, 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(ts int64, 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(ts int64, 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, reverse bool) ([]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 RockRedisDBConfig added in v0.6.0

type RockRedisDBConfig struct {
	engine.RockEngConfig
	KeepBackup int
	// this will ignore all update and non-exist delete
	EstimateTableCounter bool
	ExpirationPolicy     common.ExpirationPolicy
	DataVersion          common.DataVersionT
}

func NewRockRedisDBConfig added in v0.6.0

func NewRockRedisDBConfig() *RockRedisDBConfig

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