MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / ZRank

Method ZRank

tx_zset.go:406–427  ·  view source on GitHub ↗

ZRank Returns the rank of member in the sorted set specified by key in a bucket, with the scores ordered from low to high.

(bucket string, key, value []byte)

Source from the content-addressed store, hash-verified

404
405// ZRank Returns the rank of member in the sorted set specified by key in a bucket, with the scores ordered from low to high.
406func (tx *Tx) ZRank(bucket string, key, value []byte) (int, error) {
407 if err := tx.ZCheck(bucket); err != nil {
408 return 0, err
409 }
410
411 b, err := tx.db.bucketMgr.GetBucket(DataStructureSortedSet, bucket)
412 if err != nil {
413 return 0, err
414 }
415
416 var (
417 bucketId = b.Id
418 sortedSet *SortedSet
419 exist bool
420 )
421
422 if sortedSet, exist = tx.db.Index.SortedSet.exist(bucketId); !exist {
423 return 0, ErrBucket
424 }
425
426 return sortedSet.ZRank(string(key), value)
427}
428
429// ZRevRank Returns the rank of member in the sorted set specified by key in a bucket, with the scores ordered from high to low.
430func (tx *Tx) ZRevRank(bucket string, key, value []byte) (int, error) {

Callers 3

txZRankFunction · 0.45
testZRankFunction · 0.45
testZRevRankFunction · 0.45

Calls 3

ZCheckMethod · 0.95
GetBucketMethod · 0.80
existMethod · 0.80

Tested by 1

txZRankFunction · 0.36