Skip to content

Commit ee933dd

Browse files
committed
tried to enable kv.Searcher supporting concurrent searching, but there's only small speedup
1 parent 0a8f76f commit ee933dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lexicmap/cmd/lib-index-search.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,6 @@ func (idx *Index) Search(query *Query) (*[]*SearchResult, error) {
13341334
wg.Add(1)
13351335
// tokensS <- 1
13361336
go func(iS, beginM, endM int) {
1337-
idx.searcherTokens[iS] <- 1 // get the access to the searcher
13381337
var srs *[]*kv.SearchResult
13391338
var srs2 *[]*kv.SearchResult
13401339
var err error
@@ -1357,6 +1356,8 @@ func (idx *Index) Search(query *Query) (*[]*SearchResult, error) {
13571356
}
13581357
kv.RecycleSearchResults(srs2)
13591358
} else {
1359+
idx.searcherTokens[iS] <- 1 // get the access to the searcher
1360+
13601361
// prefix search
13611362
// srs, err = searchers[iS].Search((*_kmers)[beginM:endM], minPrefix, maxMismatch)
13621363
srs, err = searchers[iS].Search((*_kmers)[beginM:endM], minPrefix, true, false)
@@ -1385,7 +1386,10 @@ func (idx *Index) Search(query *Query) (*[]*SearchResult, error) {
13851386
ch <- srs // send result
13861387
}
13871388

1388-
<-idx.searcherTokens[iS] // return the access
1389+
if !inMemorySearch {
1390+
<-idx.searcherTokens[iS] // return the access
1391+
}
1392+
13891393
wg.Done()
13901394
// <-tokensS
13911395
}(iS, beginM, endM)

0 commit comments

Comments
 (0)