Skip to content

Commit

Permalink
refactor: remove useless code (#582)
Browse files Browse the repository at this point in the history
LGTM
  • Loading branch information
crwen committed Apr 2, 2024
1 parent b346859 commit 9c1e1fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
22 changes: 9 additions & 13 deletions tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ func (tx *Tx) Commit() (err error) {

func (tx *Tx) getNewAddRecordCount() (int64, error) {
var res int64
changeCountInEntries := tx.getChangeCountInEntriesChanges()
changeCountInEntries, err := tx.getChangeCountInEntriesChanges()
changeCountInBucket := tx.getChangeCountInBucketChanges()
res += changeCountInEntries
res += changeCountInBucket
return res, nil
return res, err
}

func (tx *Tx) getListHeadTailSeq(bucketId BucketId, key string) *HeadTailSeq {
Expand Down Expand Up @@ -622,9 +622,6 @@ func (tx *Tx) put(bucket string, key, value []byte, ttl uint32, flag uint16, tim
return err
}
tx.submitEntry(ds, bucket, e)
if err != nil {
return err
}
tx.size += e.Size()

return nil
Expand Down Expand Up @@ -763,35 +760,34 @@ func (tx *Tx) buildBucketInIndex() error {
return nil
}

func (tx *Tx) getChangeCountInEntriesChanges() int64 {
func (tx *Tx) getChangeCountInEntriesChanges() (int64, error) {
var res int64
var err error
for _, entriesInDS := range tx.pendingWrites.entriesInBTree {
for _, entry := range entriesInDS {
curRecordCnt, _ := tx.getEntryNewAddRecordCount(entry)
curRecordCnt, err := tx.getEntryNewAddRecordCount(entry)
if err != nil {
return res
return res, nil
}
res += curRecordCnt
}
}
for _, entriesInDS := range tx.pendingWrites.entries {
for _, entries := range entriesInDS {
for _, entry := range entries {
curRecordCnt, _ := tx.getEntryNewAddRecordCount(entry)
curRecordCnt, err := tx.getEntryNewAddRecordCount(entry)
if err != nil {
return res
return res, err
}
res += curRecordCnt
}
}
}
return res
return res, nil
}

func (tx *Tx) getChangeCountInBucketChanges() int64 {
var res int64
var f = func(bucket *Bucket) error {
f := func(bucket *Bucket) error {
bucketId := bucket.Id
if bucket.Meta.Op == BucketDeleteOperation {
switch bucket.Ds {
Expand Down
3 changes: 0 additions & 3 deletions tx_btree.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,6 @@ func (tx *Tx) RangeScan(bucket string, start, end []byte) (values [][]byte, err

if index, ok := tx.db.Index.bTree.exist(bucketId); ok {
records := index.Range(start, end)
if err != nil {
return nil, ErrRangeScan
}

_, values, err = tx.getHintIdxDataItemsWrapper(records, ScanNoLimit, bucketId, false, true)
if err != nil {
Expand Down

0 comments on commit 9c1e1fd

Please sign in to comment.