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

Method ZCount

tx_zset.go:123–144  ·  view source on GitHub ↗

ZCount Returns the number of elements in the sorted set specified by key in a bucket with a score between min and max and opts. Opt includes the following parameters: Limit int // limit the max nodes to return ExcludeStart bool // exclude start value, so it search in interval (start, end] or

(bucket string, key []byte, start, end float64, opts *GetByScoreRangeOptions)

Source from the content-addressed store, hash-verified

121// ExcludeStart bool // exclude start value, so it search in interval (start, end] or (start, end)
122// ExcludeEnd bool // exclude end value, so it search in interval [start, end) or (start, end)
123func (tx *Tx) ZCount(bucket string, key []byte, start, end float64, opts *GetByScoreRangeOptions) (int, error) {
124 if err := tx.ZCheck(bucket); err != nil {
125 return 0, err
126 }
127
128 b, err := tx.db.bucketMgr.GetBucket(DataStructureSortedSet, bucket)
129 if err != nil {
130 return 0, err
131 }
132
133 var (
134 bucketId = b.Id
135 sortedSet *SortedSet
136 exist bool
137 )
138
139 if sortedSet, exist = tx.db.Index.SortedSet.exist(bucketId); !exist {
140 return 0, ErrBucket
141 }
142
143 return sortedSet.ZCount(string(key), SCORE(start), SCORE(end), opts)
144}
145
146// ZPopMax Removes and returns the member with the highest score in the sorted set specified by key in a bucket.
147func (tx *Tx) ZPopMax(bucket string, key []byte) (*SortedSetMember, error) {

Callers 2

TestTx_ZCountFunction · 0.45
testZCountFunction · 0.45

Calls 4

ZCheckMethod · 0.95
SCORETypeAlias · 0.85
GetBucketMethod · 0.80
existMethod · 0.80

Tested by 1

TestTx_ZCountFunction · 0.36