MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / getZSetFromDB

Method getZSetFromDB

structure/zset.go:1068–1085  ·  view source on GitHub ↗

getZSetFromDB fetches and deserializes FZSet from the database. Returns a pointer to the FZSet and error, if any. If the key doesn't exist, both the pointer and the error will be nil. In case of deserialization errors, returns nil and the error.

(key []byte)

Source from the content-addressed store, hash-verified

1066// If the key doesn't exist, both the pointer and the error will be nil.
1067// In case of deserialization errors, returns nil and the error.
1068func (zs *ZSetStructure) getZSetFromDB(key []byte) (*FZSet, error) {
1069 dbData, err := zs.db.Get(key)
1070
1071 // If key is not found, return nil for both; otherwise return the error.
1072 if err != nil {
1073
1074 return nil, err
1075 }
1076 dec := encoding.NewMessagePackDecoder(dbData)
1077 // Deserialize the data.
1078 var zSetValue FZSet
1079 if err = dec.Decode(&zSetValue); err != nil {
1080 return nil, err
1081 }
1082
1083 // return a pointer to the deserialized FZSet, nil for the error
1084 return &zSetValue, nil
1085}
1086
1087// checkKey function that accepts a string parameter key
1088// and returns error if key is empty.

Callers 13

existsMethod · 0.95
ZRemMethod · 0.95
ZRemsMethod · 0.95
ZScoreMethod · 0.95
ZRankMethod · 0.95
ZRevRankMethod · 0.95
ZRangeMethod · 0.95
ZCountMethod · 0.95
ZRevRangeMethod · 0.95
ZCardMethod · 0.95
ZIncrByMethod · 0.95
getOrCreateZSetMethod · 0.95

Calls 3

NewMessagePackDecoderFunction · 0.92
GetMethod · 0.65
DecodeMethod · 0.45

Tested by 1

TestZIncrByFunction · 0.64