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

Method getChangeCountInBucketChanges

tx.go:771–809  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

769}
770
771func (tx *Tx) getChangeCountInBucketChanges() int64 {
772 var res int64
773 f := func(bucket *core.Bucket) error {
774 bucketId := bucket.Id
775 if bucket.Meta.Op == core.BucketDeleteOperation {
776 switch bucket.Ds {
777 case DataStructureBTree:
778 if bTree, ok := tx.db.Index.BTree.Idx[bucketId]; ok {
779 res -= int64(bTree.Count())
780 }
781 case DataStructureSet:
782 if set, ok := tx.db.Index.Set.Idx[bucketId]; ok {
783 for key := range set.M {
784 res -= int64(set.SCard(key))
785 }
786 }
787 case DataStructureSortedSet:
788 if sortedSet, ok := tx.db.Index.SortedSet.Idx[bucketId]; ok {
789 for key := range sortedSet.M {
790 curLen, _ := sortedSet.ZCard(key)
791 res -= int64(curLen)
792 }
793 }
794 case DataStructureList:
795 if list, ok := tx.db.Index.List.Idx[bucketId]; ok {
796 for key := range list.Items {
797 curLen, _ := list.Size(key)
798 res -= int64(curLen)
799 }
800 }
801 default:
802 panic(fmt.Sprintf("there is an unexpected data structure that is unimplemented in our database.:%d", bucket.Ds))
803 }
804 }
805 return nil
806 }
807 _ = tx.pendingBucketList.rangeBucket(f)
808 return res
809}
810
811// getBucketAndItsStatus, get bucket and it is status in pendingBucketList,
812// if bucket is already in bucket manager but not in pendingList, will return BucketStatusExistAlready.

Callers 1

getNewAddRecordCountMethod · 0.95

Calls 5

rangeBucketMethod · 0.80
CountMethod · 0.65
SizeMethod · 0.65
SCardMethod · 0.45
ZCardMethod · 0.45

Tested by

no test coverage detected