(bucketId core.BucketId, entry *core.Entry)
| 398 | } |
| 399 | |
| 400 | func (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 | |
| 426 | func (tx *Tx) keyExistsInSortedSet(bucketId core.BucketId, key, value string) bool { |
| 427 | if _, exist := tx.db.Index.SortedSet.exist(bucketId); !exist { |
no test coverage detected