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
- 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 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 FillDefaultOptions(opts *RockOptions)
- func Float64(v []byte, err error) (float64, error)
- func FormatInt64ToSlice(v int64) []byte
- func GetBackupDir(base string) string
- func GetCheckpointDir(term uint64, index uint64) string
- func GetDataDirFromBase(base string) string
- func GetRocksdbUint64(v []byte, err error) (uint64, error)
- func Int64(v []byte, err error) (int64, error)
- func IsBatchableWrite(cmd string) 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 PutRocksdbUint64(v uint64) []byte
- func SetLogLevel(level int32)
- func SetLogger(level int32, logger common.Logger)
- 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 DBIterator
- 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
- 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
- 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 Iterator
- type JSONIndex
- type Limit
- type Range
- type RangeLimitedIterator
- func NewDBRangeIterator(db *gorocksdb.DB, min []byte, max []byte, rtype uint8, reverse bool) (*RangeLimitedIterator, error)
- func NewDBRangeLimitIterator(db *gorocksdb.DB, min []byte, max []byte, rtype uint8, offset int, count int, ...) (*RangeLimitedIterator, error)
- func NewRangeIterator(i Iterator, r *Range) *RangeLimitedIterator
- func NewRangeLimitIterator(i Iterator, r *Range, l *Limit) *RangeLimitedIterator
- func NewRevRangeIterator(i Iterator, r *Range) *RangeLimitedIterator
- func NewRevRangeLimitIterator(i Iterator, r *Range, l *Limit) *RangeLimitedIterator
- func NewSnapshotDBRangeIterator(db *gorocksdb.DB, min []byte, max []byte, rtype uint8, reverse bool) (*RangeLimitedIterator, error)
- func NewSnapshotDBRangeLimitIterator(db *gorocksdb.DB, min []byte, max []byte, rtype uint8, offset int, count int, ...) (*RangeLimitedIterator, error)
- type RockConfig
- type RockDB
- func (r *RockDB) AddHsetIndex(table string, hindex *common.HsetIndexSchema) error
- func (db *RockDB) Append(ts int64, key []byte, value []byte) (int64, error)
- func (r *RockDB) Backup(term uint64, index uint64) *BackupInfo
- func (r *RockDB) BeginBatchWrite() error
- func (r *RockDB) CheckExpiredData(buffer common.ExpiredDataBuffer, stop chan struct{}) error
- func (r *RockDB) ClearBackup(term uint64, index uint64) error
- func (r *RockDB) Close()
- func (r *RockDB) CommitBatchWrite() error
- func (r *RockDB) CompactRange()
- 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) Expire(key []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) GetBackupBase() string
- func (r *RockDB) GetBackupDir() string
- func (r *RockDB) GetDataDir() string
- func (db *RockDB) GetHsetIndexTables() chan []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) GetRecordsInRange()
- func (r *RockDB) GetStatistics() string
- func (db *RockDB) GetTableHsetIndexValue(table []byte) ([]byte, error)
- func (db *RockDB) GetTableKeyCount(table []byte) (int64, error)
- func (db *RockDB) GetTables() chan []byte
- func (db *RockDB) HClear(hkey []byte) (int64, error)
- func (db *RockDB) HDel(key []byte, args ...[]byte) (int64, error)
- func (db *RockDB) HExpire(key []byte, duration int64) (int64, error)
- func (db *RockDB) HGet(key []byte, field []byte) ([]byte, error)
- func (db *RockDB) HGetAll(key []byte) (int64, chan common.KVRecordRet, error)
- func (db *RockDB) HGetVer(key []byte, field []byte) (int64, 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, chan 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(key []byte) (int64, error)
- func (db *RockDB) HScan(key []byte, cursor []byte, count int, match string) ([]common.KVRecord, error)
- func (db *RockDB) HSet(ts int64, checkNX bool, key []byte, field []byte, value []byte) (int64, error)
- func (db *RockDB) HValues(key []byte) (int64, chan 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) 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(key []byte) (int64, error)
- func (db *RockDB) LExpire(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(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) MaybeClearBatch()
- 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(key []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 (db *RockDB) SAdd(ts int64, key []byte, args ...[]byte) (int64, error)
- func (db *RockDB) SCard(key []byte) (int64, error)
- func (db *RockDB) SClear(key []byte) (int64, error)
- func (db *RockDB) SExpire(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(key []byte) (int64, 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) ([][]byte, error)
- func (db *RockDB) Scan(dataType common.DataType, cursor []byte, count int, match string) ([][]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 (db *RockDB) SetNX(ts int64, key []byte, value []byte) (int64, error)
- func (r *RockDB) SetPerfLevel(level int)
- func (db *RockDB) SetRange(ts int64, key []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(key []byte) (int64, error)
- func (db *RockDB) ZCount(key []byte, min float64, max float64) (int64, error)
- func (db *RockDB) ZExpire(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(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) ([]common.ScorePair, error)
- func (db *RockDB) ZScore(key []byte, member []byte) (float64, error)
- func (db *RockDB) ZSetTtl(key []byte) (t int64, err error)
- type RockOptions
- 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 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 RANGE_DELETE_NUM = 100000 )
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 )
const ( MAX_CHECKPOINT_NUM = 10 HLLCacheSize = 512 )
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 (
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 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 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 FillDefaultOptions ¶
func FillDefaultOptions(opts *RockOptions)
func FormatInt64ToSlice ¶
func GetBackupDir ¶
func GetCheckpointDir ¶
func GetDataDirFromBase ¶
func IsBatchableWrite ¶
func PutFloat64 ¶
func PutRocksdbUint64 ¶
func SetLogLevel ¶
func SetLogLevel(level int32)
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 ¶
func NewDBIterator ¶
func NewDBIterator(db *gorocksdb.DB, withSnap bool) (*DBIterator, error)
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 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
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) 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 ¶
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 RangeLimitedIterator ¶
type RangeLimitedIterator struct { Iterator // contains filtered or unexported fields }
func NewDBRangeIterator ¶
func NewDBRangeLimitIterator ¶
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 (*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 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) BeginBatchWrite ¶
func (*RockDB) CheckExpiredData ¶
func (r *RockDB) CheckExpiredData(buffer common.ExpiredDataBuffer, stop chan struct{}) error
func (*RockDB) CommitBatchWrite ¶
func (*RockDB) CompactRange ¶
func (r *RockDB) CompactRange()
func (*RockDB) GetAllIndexSchema ¶
func (r *RockDB) GetAllIndexSchema() (map[string]*common.IndexSchema, error)
func (*RockDB) GetBackupBase ¶
func (*RockDB) GetBackupDir ¶
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) GetRecordsInRange ¶
func (r *RockDB) GetRecordsInRange()
func (*RockDB) GetStatistics ¶
func (*RockDB) GetTableHsetIndexValue ¶
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) MaybeClearBatch ¶
func (r *RockDB) MaybeClearBatch()
func (*RockDB) MaybeCommitBatch ¶
func (*RockDB) ScanWithBuffer ¶
func (*RockDB) SetPerfLevel ¶
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 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"` }
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