Skip to content

Commit

Permalink
addressed some reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
metonymic-smokey committed Nov 12, 2024
1 parent 0f0ae26 commit 44a59ce
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions search/collector/eligible.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,24 @@ import (
index "github.com/blevesearch/bleve_index_api"
)

type eligibleStore struct {
ids []index.IndexInternalID
}

func (s *eligibleStore) AddDocumentMatch(doc *search.DocumentMatch) *search.DocumentMatch {
copyOfID := make([]byte, len(doc.IndexInternalID))
copy(copyOfID, doc.IndexInternalID)
s.ids = append(s.ids, copyOfID)
return doc
}

type EligibleCollector struct {
size int
total uint64
took time.Duration
results search.DocumentMatchCollection

store *eligibleStore
ids []index.IndexInternalID
}

func NewEligibleCollector(size int) *EligibleCollector {
return newEligibleCollector(size)
}

func getEligibleCollectorStore(size int) *eligibleStore {
return &eligibleStore{
ids: make([]index.IndexInternalID, 0, size),
}
}

func newEligibleCollector(size int) *EligibleCollector {
// No sort order & skip always 0 since this is only to filter eligible docs.
ec := &EligibleCollector{size: size}
ec.store = getEligibleCollectorStore(size)
ec := &EligibleCollector{size: size,
ids: make([]index.IndexInternalID, 0, size),
}
return ec
}

Expand All @@ -67,8 +51,10 @@ func makeEligibleDocumentMatchHandler(ctx *search.SearchContext) (search.Documen
return nil
}

doc := ec.store.AddDocumentMatch(d)
ctx.DocumentMatchPool.Put(doc)
copyOfID := make([]byte, len(d.IndexInternalID))
copy(copyOfID, d.IndexInternalID)
ec.ids = append(ec.ids, copyOfID)
ctx.DocumentMatchPool.Put(d)
return nil
}, nil
}
Expand Down

0 comments on commit 44a59ce

Please sign in to comment.