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

Method getSortedSetEntryNewAddRecordCount

tx.go:400–424  ·  view source on GitHub ↗
(bucketId core.BucketId, entry *core.Entry)

Source from the content-addressed store, hash-verified

398}
399
400func (tx *Tx) getSortedSetEntryNewAddRecordCount(bucketId core.BucketId, entry *core.Entry) (int64, error) {
401 var res int64
402 key := string(entry.Key)
403 value := string(entry.Value)
404
405 switch entry.Meta.Flag {
406 case DataZAddFlag:
407 if !tx.keyExistsInSortedSet(bucketId, key, value) {
408 res++
409 }
410 case DataZRemFlag:
411 res--
412 case DataZRemRangeByRankFlag:
413 start, end := splitIntIntStr(value, SeparatorForZSetKey)
414 delNodes, err := tx.db.Index.SortedSet.GetWithDefault(bucketId).getZRemRangeByRankNodes(key, start, end)
415 if err != nil {
416 return res, err
417 }
418 res -= int64(len(delNodes))
419 case DataZPopMaxFlag, DataZPopMinFlag:
420 res--
421 }
422
423 return res, nil
424}
425
426func (tx *Tx) keyExistsInSortedSet(bucketId core.BucketId, key, value string) bool {
427 if _, exist := tx.db.Index.SortedSet.exist(bucketId); !exist {

Callers 1

Calls 4

keyExistsInSortedSetMethod · 0.95
splitIntIntStrFunction · 0.85
GetWithDefaultMethod · 0.45

Tested by

no test coverage detected