Skip to content

Commit 7cd0f03

Browse files
committed
avoid comparing data when fixing
1 parent 75ba941 commit 7cd0f03

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

versiondb/tsrocksdb/store.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,25 @@ func (s Store) fixDataStore(storeName string, dryRun bool) error {
262262
prefix := storePrefix(storeName)
263263
readOpts := grocksdb.NewDefaultReadOptions()
264264
defer readOpts.Destroy()
265+
266+
cacheKeyValues := make(map[string][]byte)
265267
for _, pair := range pairs {
266268
realKey := cloneAppend(prefix, pair.Key)
267269

268-
readOpts.SetTimestamp(pair.Timestamp)
269-
oldValue, err := s.db.GetCF(readOpts, s.cfHandle, realKey)
270-
if err != nil {
271-
return err
272-
}
270+
oldData, ok := cacheKeyValues[string(realKey)]
271+
if !ok {
272+
readOpts.SetTimestamp(pair.Timestamp)
273+
oldValue, err := s.db.GetCF(readOpts, s.cfHandle, realKey)
274+
if err != nil {
275+
return err
276+
}
273277

274-
clean := bytes.Equal(oldValue.Data(), pair.Value)
275-
oldValue.Free()
278+
oldData = oldValue.Data()
279+
oldValue.Free()
280+
cacheKeyValues[string(realKey)] = oldData
281+
}
276282

283+
clean := bytes.Equal(oldData, pair.Value)
277284
if clean {
278285
continue
279286
}

0 commit comments

Comments
 (0)