Skip to content

Commit

Permalink
fix: slab data race; change: sort;
Browse files Browse the repository at this point in the history
  • Loading branch information
MapoMagpie committed Oct 26, 2024
1 parent 8389bca commit 12aaf56
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dict/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ func (m *MatchResult) String() string {

func (m *MatchResult) Order() int {
score := m.result.Score
score = score * (200 * m.Entry.Weight) * (1000 - m.Entry.text.Length())
score = score * (1000 - m.Entry.text.Length())
// * (10 * m.Entry.Weight)
return score
}

Expand All @@ -35,7 +36,7 @@ func (m *CacheMatcher) Reset() {
m.cache = nil
}

var slab = util.MakeSlab(100*1024, 2048)
// var slab = util.MakeSlab(200*1024, 4096)

func (m *CacheMatcher) Search(key []rune, list []*Entry, resultChan chan<- []*MatchResult, ctx context.Context) {
var done bool
Expand Down Expand Up @@ -69,6 +70,7 @@ func (m *CacheMatcher) Search(key []rune, list []*Entry, resultChan chan<- []*Ma
}

matched := make([]*MatchResult, 0)
var slab = util.MakeSlab(200*1024, 4096)
lastIdx := 0
listLen := len(list)
chunkSize := 50000 // chunkSize = listLen means no async search
Expand Down

0 comments on commit 12aaf56

Please sign in to comment.