upside_down disjunction searcher reuses matching slice
This commit is contained in:
parent
e68f6ca9e6
commit
090c08eb46
|
@ -25,7 +25,6 @@ import (
|
||||||
var DisjunctionMaxClauseCount = 0
|
var DisjunctionMaxClauseCount = 0
|
||||||
|
|
||||||
type DisjunctionSearcher struct {
|
type DisjunctionSearcher struct {
|
||||||
initialized bool
|
|
||||||
indexReader index.IndexReader
|
indexReader index.IndexReader
|
||||||
searchers OrderedSearcherList
|
searchers OrderedSearcherList
|
||||||
queryNorm float64
|
queryNorm float64
|
||||||
|
@ -33,6 +32,8 @@ type DisjunctionSearcher struct {
|
||||||
currentID index.IndexInternalID
|
currentID index.IndexInternalID
|
||||||
scorer *scorers.DisjunctionQueryScorer
|
scorer *scorers.DisjunctionQueryScorer
|
||||||
min float64
|
min float64
|
||||||
|
matching []*search.DocumentMatch
|
||||||
|
initialized bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func tooManyClauses(count int) bool {
|
func tooManyClauses(count int) bool {
|
||||||
|
@ -64,6 +65,7 @@ func NewDisjunctionSearcher(indexReader index.IndexReader, qsearchers []search.S
|
||||||
currs: make([]*search.DocumentMatch, len(searchers)),
|
currs: make([]*search.DocumentMatch, len(searchers)),
|
||||||
scorer: scorers.NewDisjunctionQueryScorer(explain),
|
scorer: scorers.NewDisjunctionQueryScorer(explain),
|
||||||
min: min,
|
min: min,
|
||||||
|
matching: make([]*search.DocumentMatch, len(searchers)),
|
||||||
}
|
}
|
||||||
rv.computeQueryNorm()
|
rv.computeQueryNorm()
|
||||||
return &rv, nil
|
return &rv, nil
|
||||||
|
@ -134,10 +136,10 @@ func (s *DisjunctionSearcher) Next(ctx *search.SearchContext) (*search.DocumentM
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
var rv *search.DocumentMatch
|
var rv *search.DocumentMatch
|
||||||
matching := make([]*search.DocumentMatch, 0, len(s.searchers))
|
|
||||||
|
|
||||||
found := false
|
found := false
|
||||||
for !found && s.currentID != nil {
|
for !found && s.currentID != nil {
|
||||||
|
matching := s.matching[:0]
|
||||||
for _, curr := range s.currs {
|
for _, curr := range s.currs {
|
||||||
if curr != nil && curr.IndexInternalID.Equals(s.currentID) {
|
if curr != nil && curr.IndexInternalID.Equals(s.currentID) {
|
||||||
matching = append(matching, curr)
|
matching = append(matching, curr)
|
||||||
|
@ -150,8 +152,6 @@ func (s *DisjunctionSearcher) Next(ctx *search.SearchContext) (*search.DocumentM
|
||||||
rv = s.scorer.Score(ctx, matching, len(matching), len(s.searchers))
|
rv = s.scorer.Score(ctx, matching, len(matching), len(s.searchers))
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset matching
|
|
||||||
matching = make([]*search.DocumentMatch, 0)
|
|
||||||
// invoke next on all the matching searchers
|
// invoke next on all the matching searchers
|
||||||
for i, curr := range s.currs {
|
for i, curr := range s.currs {
|
||||||
if curr != nil && curr.IndexInternalID.Equals(s.currentID) {
|
if curr != nil && curr.IndexInternalID.Equals(s.currentID) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user