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

Method SCard

tx_set.go:235–249  ·  view source on GitHub ↗

SCard returns the set cardinality (number of elements) of the set stored in the bucket at given bucket and key.

(bucket string, key []byte)

Source from the content-addressed store, hash-verified

233
234// SCard returns the set cardinality (number of elements) of the set stored in the bucket at given bucket and key.
235func (tx *Tx) SCard(bucket string, key []byte) (int, error) {
236 if err := tx.checkTxIsClosed(); err != nil {
237 return 0, err
238 }
239 b, err := tx.db.bucketMgr.GetBucket(DataStructureSet, bucket)
240 if err != nil {
241 return 0, err
242 }
243 bucketId := b.Id
244 if set, ok := tx.db.Index.Set.exist(bucketId); ok {
245 return set.SCard(string(key)), nil
246 }
247
248 return 0, ErrBucketNotFound
249}
250
251// SDiffByOneBucket returns the members of the set resulting from the difference
252// between the first set and all the successive sets in one bucket.

Callers 4

getRecordCountMethod · 0.45
txSCardFunction · 0.45
testSCardFunction · 0.45

Calls 3

checkTxIsClosedMethod · 0.95
GetBucketMethod · 0.80
existMethod · 0.80

Tested by 1

txSCardFunction · 0.36