Skip to content

Commit

Permalink
chore: Remove legacy cachekv commented copy method
Browse files Browse the repository at this point in the history
  • Loading branch information
dudong2 committed Oct 23, 2024
1 parent 9692120 commit 117b111
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 60 deletions.
32 changes: 0 additions & 32 deletions store/cachekv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,38 +128,6 @@ func (store *GStore[V]) CacheWrap() types.CacheWrap {
return NewGStore(store, store.isZero, store.valueLen)
}

// Copy implements deep copy of CacheKVStore
// TODO(dudong2): frequent calls to deep copy are a big bottleneck for performance, so need to benchmark
// TODO(dudong2): need to re-implement this based on OPE
// func (store *Store) Copy() types.CacheKVStore {
// store.mtx.Lock()
// defer store.mtx.Unlock()

// // deep copy of cValue
// cacheCopied := make(map[string]*cValue, len(store.cache))
// for key, val := range store.cache {
// valueCopied := make([]byte, len(val.value))
// copy(valueCopied, val.value)
// cacheCopied[key] = &cValue{
// value: valueCopied,
// dirty: val.dirty,
// }
// }

// // unsortedCache only track the key
// unsortedCacheCopied := make(map[string]struct{}, len(store.unsortedCache))
// for key := range store.unsortedCache {
// unsortedCacheCopied[key] = struct{}{}
// }

// return &Store{
// cache: cacheCopied,
// unsortedCache: unsortedCacheCopied,
// sortedCache: store.sortedCache.Copy(),
// parent: store.parent,
// }
// }

//----------------------------------------
// Iteration

Expand Down
21 changes: 0 additions & 21 deletions store/cachemulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,27 +188,6 @@ func (cms Store) GetObjKVStore(key types.StoreKey) types.ObjKVStore {
return store
}

// Copy returns an deep copy of CacheMultiStore
// TODO(dudong2): frequent calls to deep copy are a big bottleneck for performance, so need to benchmark
// TODO(dudong2): need to re-implement this based on OPE
// func (cms Store) Copy() types.CacheMultiStore {
// // deep copy of CacheKVStore underlying CacheMultiStore
// storesCopied := make(map[types.StoreKey]types.CacheWrap, len(cms.stores))
// for key, store := range cms.stores {
// if store, ok := store.(*cachekv.GStore[V]); ok {
// storesCopied[key] = store.Copy()
// }
// }

// return Store{
// db: cms.db.Copy(),
// stores: storesCopied,
// keys: cms.keys,
// traceWriter: cms.traceWriter,
// traceContext: cms.traceContext,
// }
// }

func (cms Store) Clone() Store {
stores := make(map[types.StoreKey]types.CacheWrap, len(cms.stores))
for k, v := range cms.stores {
Expand Down
8 changes: 1 addition & 7 deletions store/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,8 @@ type RootMultiStore interface {
type CacheMultiStore interface {
MultiStore
Write() // Writes operations to underlying KVStore
RunAtomic(func(CacheMultiStore) error) error

// TODO(dudong2): need to uncomment after re-implementing OPE
// Copy() CacheMultiStore // deep copy of CacheMultiStore
RunAtomic(func(CacheMultiStore) error) error
}

// CommitMultiStore is an interface for a MultiStore without cache capabilities.
Expand Down Expand Up @@ -321,10 +319,6 @@ type CacheKVStore interface {

// Writes operations to underlying KVStore
Write()

// deep copy of CacheKVStore
// TODO(dudong2): need to uncomment after re-implementing OPE
// Copy() CacheKVStore
}

// CommitKVStore is an interface for MultiStore.
Expand Down

0 comments on commit 117b111

Please sign in to comment.