Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ifplusor committed Oct 8, 2023
1 parent 564a181 commit 24c2b89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions server/store/meta/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (s *SyncStore) set(ctx context.Context, kvs Ranger, cb StoreCallback) {
// Update state.
s.mu.Lock()
_ = kvs.Range(func(key []byte, value interface{}) error {
set(s.committed, key, value)
update(s.committed, key, value)
return nil
})
s.version = r.EO
Expand Down Expand Up @@ -170,7 +170,7 @@ func RecoverSyncStore(ctx context.Context, dir string, opts ...walog.Option) (*S
walog.FromPosition(snapshot),
walog.WithRecoveryCallback(func(data []byte, r walog.Range) error {
err2 := defaultCodec.Unmarshal(data, func(key []byte, value interface{}) error {
rawSet(committed, key, value)
rawUpdate(committed, key, value)
return nil
})
if err2 != nil {
Expand Down
10 changes: 7 additions & 3 deletions server/store/meta/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ import (
"github.com/huandu/skiplist"
)

func set(m *skiplist.SkipList, key []byte, value interface{}) {
func update(m *skiplist.SkipList, key []byte, value interface{}) {
if value == DeletedMark {
m.Remove(key)
return
}

set(m, key, value)
}

func set(m *skiplist.SkipList, key []byte, value interface{}) {
switch val := value.(type) {
case []byte:
// Make a copy to avoid modifying value outside.
Expand All @@ -35,7 +39,7 @@ func set(m *skiplist.SkipList, key []byte, value interface{}) {
}
}

func rawSet(m *skiplist.SkipList, key []byte, value interface{}) {
func rawUpdate(m *skiplist.SkipList, key []byte, value interface{}) {
if value == DeletedMark {
m.Remove(key)
} else {
Expand All @@ -45,6 +49,6 @@ func rawSet(m *skiplist.SkipList, key []byte, value interface{}) {

func merge(dst, src *skiplist.SkipList) {
for el := src.Front(); el != nil; el = el.Next() {
rawSet(dst, el.Key().([]byte), el.Value)
rawUpdate(dst, el.Key().([]byte), el.Value)
}
}

0 comments on commit 24c2b89

Please sign in to comment.