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
- Variables
- func CutOne(b []byte) (data []byte, remain []byte, err error)
- func Decode(b []byte, size int) ([]interface{}, error)
- func DecodeBytes(b []byte) ([]byte, []byte, error)
- func DecodeBytesDesc(b []byte) ([]byte, []byte, error)
- func DecodeFloat(b []byte) ([]byte, float64, error)
- func DecodeFloatDesc(b []byte) ([]byte, float64, error)
- func DecodeInt(b []byte) ([]byte, int64, error)
- func DecodeIntDesc(b []byte) ([]byte, int64, error)
- func DecodeOne(b []byte) (remain []byte, d interface{}, err error)
- func DecodeUint(b []byte) ([]byte, uint64, error)
- func DecodeUintDesc(b []byte) ([]byte, uint64, error)
- func DisablePerfLevel()
- func EncodeBytes(b []byte, data []byte) []byte
- func EncodeBytesDesc(b []byte, data []byte) []byte
- func EncodeFloat(b []byte, v float64) []byte
- func EncodeFloatDesc(b []byte, v float64) []byte
- func EncodeInt(b []byte, v int64) []byte
- func EncodeIntDesc(b []byte, v int64) []byte
- func EncodeMaxKey(b []byte) ([]byte, error)
- func EncodeMemCmpKey(b []byte, v ...interface{}) ([]byte, error)
- func EncodeMinNotNull(b []byte) ([]byte, error)
- func EncodeUint(b []byte, v uint64) []byte
- func EncodeUintDesc(b []byte, v uint64) []byte
- func Float64(v []byte, err error) (float64, error)
- func FormatInt64ToSlice(v int64) []byte
- func GetBackupDir(base string) string
- func GetBackupDirForRemote(base string) string
- func GetCheckpointDir(term uint64, index uint64) string
- func GetDataDirFromBase(base string) string
- func GetLatestCheckpoint(checkpointDir string, skipN int, matchFunc func(string) bool) string
- func GetRocksdbUint64(v []byte, err error) (uint64, error)
- func Int64(v []byte, err error) (int64, error)
- func IsBatchableWrite(cmd string) bool
- func IsNeedAbortError(err error) bool
- func IsPerfEnabledLevel(lv int) bool
- func MaxInt(a int, b int) int
- func MaxInt16(a int16, b int16) int16
- func MaxInt32(a int32, b int32) int32
- func MaxInt64(a int64, b int64) int64
- func MaxInt8(a int8, b int8) int8
- func MaxUint(a uint, b uint) uint
- func MaxUint16(a uint16, b uint16) uint16
- func MaxUint32(a uint32, b uint32) uint32
- func MaxUint64(a uint64, b uint64) uint64
- func MaxUint8(a uint8, b uint8) uint8
- func MinInt(a int, b int) int
- func MinInt16(a int16, b int16) int16
- func MinInt32(a int32, b int32) int32
- func MinInt64(a int64, b int64) int64
- func MinInt8(a int8, b int8) int8
- func MinUint(a uint, b uint) uint
- func MinUint16(a uint16, b uint16) uint16
- func MinUint32(a uint32, b uint32) uint32
- func MinUint64(a uint64, b uint64) uint64
- func MinUint8(a uint8, b uint8) uint8
- func PutFloat64(v float64) []byte
- func PutInt64(v int64) []byte
- func PutInt64ToBuf(v int64, b []byte)
- func PutRocksdbUint64(v uint64) []byte
- func SetLogLevel(level int32)
- func SetLogger(level int32, logger common.Logger)
- func SetPerfLevel(level int)
- func StrInt32(v []byte, err error) (int32, error)
- func StrInt64(v []byte, err error) (int64, error)
- func StrInt8(v []byte, err error) (int8, error)
- func StrUint64(v []byte, err error) (uint64, error)
- func Uint64(v []byte, err error) (uint64, error)
- type BackupInfo
- type CheckpointSortNames
- type ErrType
- type HIndexResp
- type HsetIndex
- func (self *HsetIndex) RemoveRec(value []byte, pk []byte, wb *gorocksdb.WriteBatch)
- func (self *HsetIndex) SearchRec(db *RockDB, cond *IndexCondition, countOnly bool) (int64, []HIndexResp, error)
- func (self *HsetIndex) UpdateRec(oldvalue []byte, value []byte, pk []byte, wb *gorocksdb.WriteBatch) error
- type HsetIndexInfo
- func (*HsetIndexInfo) Descriptor() ([]byte, []int)
- func (m *HsetIndexInfo) Marshal() (dAtA []byte, err error)
- func (m *HsetIndexInfo) MarshalTo(dAtA []byte) (int, error)
- func (*HsetIndexInfo) ProtoMessage()
- func (m *HsetIndexInfo) Reset()
- func (m *HsetIndexInfo) Size() (n int)
- func (m *HsetIndexInfo) String() string
- func (m *HsetIndexInfo) Unmarshal(dAtA []byte) error
- func (m *HsetIndexInfo) XXX_DiscardUnknown()
- func (m *HsetIndexInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HsetIndexInfo) XXX_Merge(src proto.Message)
- func (m *HsetIndexInfo) XXX_Size() int
- func (m *HsetIndexInfo) XXX_Unmarshal(b []byte) error
- type HsetIndexList
- func (*HsetIndexList) Descriptor() ([]byte, []int)
- func (m *HsetIndexList) Marshal() (dAtA []byte, err error)
- func (m *HsetIndexList) MarshalTo(dAtA []byte) (int, error)
- func (*HsetIndexList) ProtoMessage()
- func (m *HsetIndexList) Reset()
- func (m *HsetIndexList) Size() (n int)
- func (m *HsetIndexList) String() string
- func (m *HsetIndexList) Unmarshal(dAtA []byte) error
- func (m *HsetIndexList) XXX_DiscardUnknown()
- func (m *HsetIndexList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HsetIndexList) XXX_Merge(src proto.Message)
- func (m *HsetIndexList) XXX_Size() int
- func (m *HsetIndexList) XXX_Unmarshal(b []byte) error
- type IndexCondition
- type IndexMgr
- func (im *IndexMgr) AddHsetIndex(db *RockDB, hindex *HsetIndex) error
- func (im *IndexMgr) Close()
- func (im *IndexMgr) GetAllIndexSchemaInfo(db *RockDB) (map[string]*common.IndexSchema, error)
- func (im *IndexMgr) GetHsetIndex(table string, field string) (*HsetIndex, error)
- func (im *IndexMgr) GetIndexSchemaInfo(db *RockDB, table string) (*common.IndexSchema, error)
- func (im *IndexMgr) GetTableIndexes(table string) *TableIndexContainer
- func (im *IndexMgr) LoadIndexes(db *RockDB) error
- func (im *IndexMgr) UpdateHsetIndexState(db *RockDB, table string, field string, state IndexState) error
- type IndexPropertyDType
- type IndexState
- type ItemContainer
- type JSONIndex
- type RockDB
- func (r *RockDB) AbortBatch()
- func (r *RockDB) AddHsetIndex(table string, hindex *common.HsetIndexSchema) error
- func (db *RockDB) Append(ts int64, rawKey []byte, value []byte) (int64, error)
- func (r *RockDB) Backup(term uint64, index uint64) *BackupInfo
- func (r *RockDB) BeginBatchWrite() error
- func (db *RockDB) BitClear(ts int64, key []byte) (int64, error)
- func (db *RockDB) BitCountV2(key []byte, start, end int) (int64, error)
- func (db *RockDB) BitExpire(ts int64, key []byte, ttlSec int64) (int64, error)
- func (db *RockDB) BitGetV2(key []byte, offset int64) (int64, error)
- func (db *RockDB) BitGetVer(key []byte) (int64, error)
- func (db *RockDB) BitKeyExist(key []byte) (int64, error)
- func (db *RockDB) BitPersist(ts int64, key []byte) (int64, error)
- func (db *RockDB) BitSetOld(ts int64, key []byte, offset int64, on int) (int64, error)
- func (db *RockDB) BitSetV2(ts int64, key []byte, offset int64, on int) (int64, error)
- func (db *RockDB) BitTtl(key []byte) (t int64, err error)
- func (r *RockDB) Close()
- func (r *RockDB) CommitBatchWrite() error
- func (r *RockDB) CompactRange()
- func (r *RockDB) CompactTableRange(table string)
- func (db *RockDB) Decr(ts int64, key []byte) (int64, error)
- func (db *RockDB) DecrBy(ts int64, key []byte, decrement int64) (int64, error)
- func (db *RockDB) DelKeys(keys ...[]byte) (int64, error)
- func (db *RockDB) DelTableKeyCount(table []byte, wb *gorocksdb.WriteBatch) error
- func (r *RockDB) DeleteTableRange(dryrun bool, table string, start []byte, end []byte) error
- func (db *RockDB) Expire(ts int64, rawKey []byte, duration int64) (int64, error)
- func (db *RockDB) FullScan(dataType common.DataType, cursor []byte, count int, match string) *common.FullScanResult
- func (r *RockDB) GetAllIndexSchema() (map[string]*common.IndexSchema, error)
- func (r *RockDB) GetBTablesSizes(tables [][]byte) []int64
- func (r *RockDB) GetBackupBase() string
- func (r *RockDB) GetBackupDir() string
- func (r *RockDB) GetBackupDirForRemote() string
- func (db *RockDB) GetCollVersionKey(ts int64, dt byte, key []byte, useLock bool) (collVerKeyInfo, error)
- func (r *RockDB) GetDataDir() string
- func (db *RockDB) GetHsetIndexTables() [][]byte
- func (r *RockDB) GetIndexSchema(table string) (*common.IndexSchema, error)
- func (r *RockDB) GetInternalPropertyStatus(p string) string
- func (r *RockDB) GetInternalStatus() map[string]interface{}
- func (db *RockDB) GetRange(key []byte, start int, end int) ([]byte, error)
- func (r *RockDB) GetStatistics() string
- func (r *RockDB) GetTableApproximateNumInRange(table string, start []byte, end []byte) int64
- func (db *RockDB) GetTableHsetIndexValue(table []byte) ([]byte, error)
- func (db *RockDB) GetTableKeyCount(table []byte) (int64, error)
- func (r *RockDB) GetTableSizeInRange(table string, start []byte, end []byte) int64
- func (db *RockDB) GetTables() [][]byte
- func (r *RockDB) GetTablesSizes(tables []string) []int64
- func (r *RockDB) GetTopLargeKeys() []metric.TopNInfo
- func (db *RockDB) GetValueWithOp(rawKey []byte, op func([]byte) error) error
- func (db *RockDB) GetValueWithOpNoLock(rawKey []byte, op func([]byte) error) error
- func (db *RockDB) HClear(ts int64, hkey []byte) (int64, error)
- func (db *RockDB) HDel(ts int64, key []byte, args ...[]byte) (int64, error)
- func (db *RockDB) HExist(key []byte, field []byte) (bool, error)
- func (db *RockDB) HExpire(ts int64, key []byte, duration int64) (int64, error)
- func (db *RockDB) HGet(key []byte, field []byte) ([]byte, error)
- func (db *RockDB) HGetAll(key []byte) (int64, []common.KVRecordRet, error)
- func (db *RockDB) HGetVer(key []byte, field []byte) (int64, error)
- func (db *RockDB) HGetWithOp(key []byte, field []byte, op func([]byte) error) error
- func (db *RockDB) HIncrBy(ts int64, key []byte, field []byte, delta int64) (int64, error)
- func (db *RockDB) HKeyExists(key []byte) (int64, error)
- func (db *RockDB) HKeys(key []byte) (int64, []common.KVRecordRet, error)
- func (db *RockDB) HLen(hkey []byte) (int64, error)
- func (db *RockDB) HMclear(keys ...[]byte)
- func (db *RockDB) HMget(key []byte, args ...[]byte) ([][]byte, error)
- func (db *RockDB) HMset(ts int64, key []byte, args ...common.KVRecord) error
- func (db *RockDB) HPersist(ts int64, key []byte) (int64, error)
- func (db *RockDB) HScan(key []byte, cursor []byte, count int, match string, reverse bool) ([]common.KVRecord, error)
- func (db *RockDB) HSet(ts int64, checkNX bool, key []byte, field []byte, ovalue []byte) (int64, error)
- func (db *RockDB) HValues(key []byte) (int64, []common.KVRecordRet, error)
- func (db *RockDB) HashTtl(key []byte) (t int64, err error)
- func (db *RockDB) HsetIndexSearch(table []byte, field []byte, cond *IndexCondition, countOnly bool) (IndexPropertyDType, int64, []HIndexResp, error)
- func (db *RockDB) Incr(ts int64, key []byte) (int64, error)
- func (db *RockDB) IncrBy(ts int64, key []byte, increment int64) (int64, error)
- func (db *RockDB) IncrTableKeyCount(table []byte, delta int64, wb *gorocksdb.WriteBatch) error
- func (r *RockDB) IsLocalBackupOK(term uint64, index uint64) (bool, error)
- func (db *RockDB) JArrayAppend(ts int64, key []byte, path []byte, jsons ...[]byte) (int64, error)
- func (db *RockDB) JArrayLen(key []byte, path []byte) (int64, error)
- func (db *RockDB) JArrayPop(ts int64, key []byte, path []byte) (string, error)
- func (db *RockDB) JDel(ts int64, key []byte, path []byte) (int64, error)
- func (db *RockDB) JGet(key []byte, paths ...[]byte) ([]string, error)
- func (db *RockDB) JKeyExists(key []byte) (int64, error)
- func (db *RockDB) JMGet(path []byte, keys ...[]byte) ([]string, error)
- func (db *RockDB) JMset(ts int64, key []byte, args ...common.KVRecord) error
- func (db *RockDB) JObjKeys(key []byte, path []byte) ([]string, error)
- func (db *RockDB) JObjLen(key []byte, path []byte) (int64, error)
- func (db *RockDB) JSet(ts int64, key []byte, path []byte, value []byte) (int64, error)
- func (db *RockDB) JType(key []byte, path []byte) (string, error)
- func (db *RockDB) KVDel(key []byte) (int64, error)
- func (db *RockDB) KVDelWithBatch(key []byte, wb *gorocksdb.WriteBatch) error
- func (db *RockDB) KVExists(keys ...[]byte) (int64, error)
- func (db *RockDB) KVGet(key []byte) ([]byte, error)
- func (db *RockDB) KVGetSet(ts int64, rawKey []byte, value []byte) ([]byte, error)
- func (db *RockDB) KVGetVer(key []byte) (int64, error)
- func (db *RockDB) KVSet(ts int64, rawKey []byte, value []byte) error
- func (db *RockDB) KVTtl(key []byte) (t int64, err error)
- func (db *RockDB) LClear(ts int64, key []byte) (int64, error)
- func (db *RockDB) LExpire(ts int64, key []byte, duration int64) (int64, error)
- func (db *RockDB) LFixKey(ts int64, key []byte)
- func (db *RockDB) LIndex(key []byte, index int64) ([]byte, error)
- func (db *RockDB) LKeyExists(key []byte) (int64, error)
- func (db *RockDB) LLen(key []byte) (int64, error)
- func (db *RockDB) LMclear(keys ...[]byte) (int64, error)
- func (db *RockDB) LPersist(ts int64, key []byte) (int64, error)
- func (db *RockDB) LPop(ts int64, key []byte) ([]byte, error)
- func (db *RockDB) LPush(ts int64, key []byte, args ...[]byte) (int64, error)
- func (db *RockDB) LRange(key []byte, start int64, stop int64) ([][]byte, error)
- func (db *RockDB) LSet(ts int64, key []byte, index int64, value []byte) error
- func (db *RockDB) LTrim(ts int64, key []byte, start, stop int64) error
- func (db *RockDB) LTrimBack(ts int64, key []byte, trimSize int64) (int64, error)
- func (db *RockDB) LTrimFront(ts int64, key []byte, trimSize int64) (int64, error)
- func (db *RockDB) LVer(key []byte) (int64, error)
- func (db *RockDB) ListTtl(key []byte) (t int64, err error)
- func (db *RockDB) MGet(keys ...[]byte) ([][]byte, []error)
- func (db *RockDB) MSet(ts int64, args ...common.KVRecord) error
- func (r *RockDB) MaybeCommitBatch() error
- func (db *RockDB) PFAdd(ts int64, rawKey []byte, elems ...[]byte) (int64, error)
- func (db *RockDB) PFCount(ts int64, keys ...[]byte) (int64, error)
- func (db *RockDB) Persist(ts int64, rawKey []byte) (int64, error)
- func (db *RockDB) RPop(ts int64, key []byte) ([]byte, error)
- func (db *RockDB) RPush(ts int64, key []byte, args ...[]byte) (int64, error)
- func (r *RockDB) Restore(term uint64, index uint64) error
- func (r *RockDB) RestoreFromRemoteBackup(term uint64, index uint64) error
- func (db *RockDB) SAdd(ts int64, key []byte, args ...[]byte) (int64, error)
- func (db *RockDB) SCard(key []byte) (int64, error)
- func (db *RockDB) SClear(ts int64, key []byte) (int64, error)
- func (db *RockDB) SExpire(ts int64, key []byte, duration int64) (int64, error)
- func (db *RockDB) SGetVer(key []byte) (int64, error)
- func (db *RockDB) SIsMember(key []byte, member []byte) (int64, error)
- func (db *RockDB) SKeyExists(key []byte) (int64, error)
- func (db *RockDB) SMclear(keys ...[]byte) (int64, error)
- func (db *RockDB) SMembers(key []byte) ([][]byte, error)
- func (db *RockDB) SPersist(ts int64, key []byte) (int64, error)
- func (db *RockDB) SPop(ts int64, key []byte, count int) ([][]byte, error)
- func (db *RockDB) SRandMembers(key []byte, count int64) ([][]byte, error)
- func (db *RockDB) SRem(ts int64, key []byte, args ...[]byte) (int64, error)
- func (db *RockDB) SScan(key []byte, cursor []byte, count int, match string, reverse bool) ([][]byte, error)
- func (db *RockDB) Scan(dataType common.DataType, cursor []byte, count int, match string, reverse bool) ([][]byte, error)
- func (db *RockDB) ScanWithBuffer(dataType common.DataType, cursor []byte, count int, match string, ...) ([][]byte, error)
- func (db *RockDB) SetEx(ts int64, rawKey []byte, duration int64, value []byte) error
- func (r *RockDB) SetLatestSnapIndex(i uint64)
- func (r *RockDB) SetMaxBackgroundOptions(maxCompact int, maxBackJobs int) error
- func (db *RockDB) SetNX(ts int64, rawKey []byte, value []byte) (int64, error)
- func (db *RockDB) SetRange(ts int64, rawKey []byte, offset int, value []byte) (int64, error)
- func (db *RockDB) SetTableHsetIndexValue(table []byte, value []byte) error
- func (db *RockDB) SetTtl(key []byte) (t int64, err error)
- func (db *RockDB) StrLen(key []byte) (int64, error)
- func (r *RockDB) UpdateHsetIndexState(table string, hindex *common.HsetIndexSchema) error
- func (db *RockDB) ZAdd(ts int64, key []byte, args ...common.ScorePair) (int64, error)
- func (db *RockDB) ZCard(key []byte) (int64, error)
- func (db *RockDB) ZClear(ts int64, key []byte) (int64, error)
- func (db *RockDB) ZCount(key []byte, min float64, max float64) (int64, error)
- func (db *RockDB) ZExpire(ts int64, key []byte, duration int64) (int64, error)
- func (db *RockDB) ZFixKey(ts int64, key []byte) error
- func (db *RockDB) ZGetVer(key []byte) (int64, error)
- func (db *RockDB) ZIncrBy(ts int64, key []byte, delta float64, member []byte) (float64, error)
- func (db *RockDB) ZKeyExists(key []byte) (int64, error)
- func (db *RockDB) ZLexCount(key []byte, min []byte, max []byte, rangeType uint8) (int64, error)
- func (db *RockDB) ZMclear(keys ...[]byte) (int64, error)
- func (db *RockDB) ZPersist(ts int64, key []byte) (int64, error)
- func (db *RockDB) ZRange(key []byte, start int, stop int) ([]common.ScorePair, error)
- func (db *RockDB) ZRangeByLex(key []byte, min []byte, max []byte, rangeType uint8, offset int, count int) ([][]byte, error)
- func (db *RockDB) ZRangeByScore(key []byte, min float64, max float64, offset int, count int) ([]common.ScorePair, error)
- func (db *RockDB) ZRangeByScoreGeneric(key []byte, min float64, max float64, offset int, count int, reverse bool) ([]common.ScorePair, error)
- func (db *RockDB) ZRangeGeneric(key []byte, start int, stop int, reverse bool) ([]common.ScorePair, error)
- func (db *RockDB) ZRank(key []byte, member []byte) (int64, error)
- func (db *RockDB) ZRem(ts int64, key []byte, members ...[]byte) (int64, error)
- func (db *RockDB) ZRemRangeByLex(ts int64, key []byte, min []byte, max []byte, rangeType uint8) (int64, error)
- func (db *RockDB) ZRemRangeByRank(ts int64, key []byte, start int, stop int) (int64, error)
- func (db *RockDB) ZRemRangeByScore(ts int64, key []byte, min float64, max float64) (int64, error)
- func (db *RockDB) ZRevRange(key []byte, start int, stop int) ([]common.ScorePair, error)
- func (db *RockDB) ZRevRangeByScore(key []byte, min float64, max float64, offset int, count int) ([]common.ScorePair, error)
- func (db *RockDB) ZRevRank(key []byte, member []byte) (int64, error)
- func (db *RockDB) ZScan(key []byte, cursor []byte, count int, match string, reverse bool) ([]common.ScorePair, error)
- func (db *RockDB) ZScore(key []byte, member []byte) (float64, error)
- func (db *RockDB) ZSetTtl(key []byte) (t int64, err error)
- type RockRedisDBConfig
- type TTLChecker
- type TableIndexContainer
Constants ¶
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
const ( MAX_BATCH_NUM = 5000 RangeDeleteNum = 5000 )
const ( MaxDatabases int = 10240 MaxTableNameLen int = 255 MaxColumnLen int = 255 //max key size MaxKeySize int = 10240 // subkey length for hash/set/zset MaxSubKeyLen int = 10240 //max value size MaxValueSize int = 1024 * 1024 * 8 )
const ( MaxCheckpointNum = 10 MaxRemoteCheckpointNum = 3 HLLReadCacheSize = 1024 HLLWriteCacheSize = 32 )
const ( MinScore int64 = -1<<63 + 1 MaxScore int64 = 1<<63 - 1 InvalidScore int64 = -1 << 63 AggregateSum byte = 0 AggregateMin byte = 1 AggregateMax byte = 2 )
const (
EngType = "rockredis"
)
const (
// 2MB
MaxBitOffset = 2 * 8 * 1024 * 1024
)
kv new format as below: KVType | key -> |value header| value | modify time|
const (
MaxBitOffsetV2 = math.MaxUint32 - 1
)
const (
NilFlag byte = 0
)
Variables ¶
var ( ErrZScoreMiss = errors.New("zset score miss") ErrWriteInROnly = errors.New("write not support in readonly mode") )
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") )
var ( ErrInvalidLengthIndexTypes = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowIndexTypes = fmt.Errorf("proto: integer overflow") )
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") )
var ( ErrLocalBatchFullToCommit = errors.New("batched is fully filled and should commit right now") ErrLocalBatchedBuffFull = errors.New("the local batched buffer is fully filled") )
var ErrBitOverflow = errors.New("bit offset overflowed")
var IndexPropertyDType_name = map[int32]string{
0: "Int64V",
1: "Int32V",
2: "StringV",
}
var IndexPropertyDType_value = map[string]int32{
"Int64V": 0,
"Int32V": 1,
"StringV": 2,
}
var IndexState_name = map[int32]string{
0: "InitIndex",
1: "BuildingIndex",
2: "BuildDoneIndex",
3: "ReadyIndex",
4: "DeletedIndex",
}
var IndexState_value = map[string]int32{
"InitIndex": 0,
"BuildingIndex": 1,
"BuildDoneIndex": 2,
"ReadyIndex": 3,
"DeletedIndex": 4,
}
Functions ¶
func Decode ¶
Decode decodes values from a byte slice generated with EncodeKey or EncodeValue before. size is the size of decoded slice.
func DecodeBytes ¶
DecodeBytes decodes bytes which is encoded by EncodeBytes before, returns the leftover bytes and decoded value if no error.
func DecodeBytesDesc ¶
DecodeBytesDesc decodes bytes which is encoded by EncodeBytesDesc before, returns the leftover bytes and decoded value if no error.
func DecodeFloat ¶
DecodeFloat decodes a float from a byte slice generated with EncodeFloat before.
func DecodeFloatDesc ¶
DecodeFloatDesc decodes a float from a byte slice generated with EncodeFloatDesc before.
func DecodeInt ¶
DecodeInt decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.
func DecodeIntDesc ¶
DecodeIntDesc decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.
func DecodeUint ¶
DecodeUint decodes value encoded by EncodeUint before. It returns the leftover un-decoded slice, decoded value if no error.
func DecodeUintDesc ¶
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 ¶
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 ¶
EncodeBytesDesc first encodes bytes using EncodeBytes, then bitwise reverses encoded value to guarantee the encoded value is in descending order for comparison.
func EncodeFloat ¶
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 ¶
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 ¶
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 ¶
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 EncodeMemCmpKey ¶
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 EncodeUint ¶
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 ¶
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 FormatInt64ToSlice ¶
func GetBackupDir ¶
func GetBackupDirForRemote ¶ added in v0.4.3
func GetCheckpointDir ¶
func GetDataDirFromBase ¶
func GetLatestCheckpoint ¶ added in v0.6.2
func IsBatchableWrite ¶
func IsNeedAbortError ¶ added in v0.8.1
func IsPerfEnabledLevel ¶ added in v0.3.2
func PutFloat64 ¶
func PutInt64ToBuf ¶ added in v0.8.0
func PutRocksdbUint64 ¶
func SetLogLevel ¶
func SetLogLevel(level int32)
func SetPerfLevel ¶ added in v0.3.2
func SetPerfLevel(level int)
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 HIndexResp ¶
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)
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) 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) 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 ¶
func NewIndexMgr ¶
func NewIndexMgr() *IndexMgr
func (*IndexMgr) AddHsetIndex ¶
func (*IndexMgr) GetAllIndexSchemaInfo ¶
func (*IndexMgr) GetHsetIndex ¶
func (*IndexMgr) GetIndexSchemaInfo ¶
func (*IndexMgr) GetTableIndexes ¶
func (im *IndexMgr) GetTableIndexes(table string) *TableIndexContainer
func (*IndexMgr) LoadIndexes ¶
func (*IndexMgr) UpdateHsetIndexState ¶
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) BeginBatchWrite ¶
func (*RockDB) BitCountV2 ¶ added in v0.8.0
func (*RockDB) BitKeyExist ¶ added in v0.8.0
func (*RockDB) BitPersist ¶ added in v0.8.0
func (*RockDB) BitSetOld ¶ added in v0.8.0
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
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) CommitBatchWrite ¶
func (*RockDB) CompactRange ¶
func (r *RockDB) CompactRange()
func (*RockDB) CompactTableRange ¶ added in v0.3.2
[start, end)
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
[start, end)
func (*RockDB) GetAllIndexSchema ¶
func (r *RockDB) GetAllIndexSchema() (map[string]*common.IndexSchema, error)
func (*RockDB) GetBTablesSizes ¶ added in v0.3.2
func (*RockDB) GetBackupBase ¶
func (*RockDB) GetBackupDir ¶
func (*RockDB) GetBackupDirForRemote ¶ added in v0.4.3
func (*RockDB) GetCollVersionKey ¶ added in v0.8.0
func (*RockDB) GetDataDir ¶
func (*RockDB) GetHsetIndexTables ¶
func (*RockDB) GetIndexSchema ¶
func (r *RockDB) GetIndexSchema(table string) (*common.IndexSchema, error)
func (*RockDB) GetInternalPropertyStatus ¶
func (*RockDB) GetInternalStatus ¶
func (*RockDB) GetStatistics ¶
func (*RockDB) GetTableApproximateNumInRange ¶ added in v0.3.2
[start, end)
func (*RockDB) GetTableHsetIndexValue ¶
func (*RockDB) GetTableSizeInRange ¶ added in v0.3.2
[start, end)
func (*RockDB) GetTablesSizes ¶ added in v0.3.2
[start, end)
func (*RockDB) GetTopLargeKeys ¶ added in v0.8.4
func (*RockDB) GetValueWithOp ¶ added in v0.7.1
func (*RockDB) GetValueWithOpNoLock ¶ added in v0.7.1
func (*RockDB) HGetWithOp ¶ added in v0.7.1
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) IncrTableKeyCount ¶
func (*RockDB) IsLocalBackupOK ¶
func (*RockDB) JArrayAppend ¶
func (*RockDB) KVDel ¶
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) LTrimFront ¶
func (*RockDB) MaybeCommitBatch ¶
func (*RockDB) RestoreFromRemoteBackup ¶ added in v0.4.3
func (*RockDB) SRandMembers ¶ added in v0.8.0
we do not use rand here
func (*RockDB) ScanWithBuffer ¶
func (*RockDB) SetLatestSnapIndex ¶ added in v0.7.1
func (*RockDB) SetMaxBackgroundOptions ¶ added in v0.7.1
func (*RockDB) SetTableHsetIndexValue ¶
func (*RockDB) UpdateHsetIndexState ¶
func (r *RockDB) UpdateHsetIndexState(table string, hindex *common.HsetIndexSchema) error
func (*RockDB) ZRangeByLex ¶
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 (*RockDB) ZRemRangeByLex ¶
func (*RockDB) ZRemRangeByRank ¶
func (*RockDB) ZRemRangeByScore ¶
min and max must be inclusive
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
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 TableIndexContainer ¶
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