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

Method ZRevRange

structure/zset.go:834–848  ·  view source on GitHub ↗

ZRevRange retrieves a range of elements from a sorted set (ZSet) in descending order. Inputs: - key: Name of the ZSet - startRank: Initial rank of the desired range - endRank: Final rank of the desired range Output: - An array of ZSetValue, representing elements from the range [startRank, endRank]

(key string, startRank int, endRank int)

Source from the content-addressed store, hash-verified

832// - Error if an issue occurs, such as when the key is empty or ZSet retrieval fails
833// error
834func (zs *ZSetStructure) ZRevRange(key string, startRank int, endRank int) ([]ZSetValue, error) {
835 if err := checkKey(key); err != nil {
836 return nil, err
837 }
838 keyBytes := stringToBytesWithKey(key)
839
840 zSet, err := zs.getZSetFromDB(keyBytes)
841 if err != nil {
842 return nil, err
843 }
844 r := zSet.skipList.getRange(startRank, endRank, true)
845
846 // rank zero means no rank found
847 return r, nil
848}
849
850// The ZCard function returns the size of the dictionary of the sorted set stored at key in the database.
851// It takes a string key as an argument.

Callers

nothing calls this directly

Calls 4

getZSetFromDBMethod · 0.95
checkKeyFunction · 0.85
stringToBytesWithKeyFunction · 0.85
getRangeMethod · 0.80

Tested by

no test coverage detected