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)
| 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. |
| 406 | func (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. |
| 430 | func (tx *Tx) ZRevRank(bucket string, key, value []byte) (int, error) { |