1
0
Fork 0
forked from forgejo/forgejo
This commit is contained in:
techknowlogick 2021-02-28 18:08:33 -05:00 committed by GitHub
parent 030646eea4
commit 47f6a4ec3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
947 changed files with 26119 additions and 7062 deletions

View file

@ -600,12 +600,14 @@ func MemoryNeededForSearchResult(req *SearchRequest) uint64 {
estimate += len(req.Facets) * fr.Size()
}
// highlighting, store
// overhead from fields, highlighting
var d document.Document
if len(req.Fields) > 0 || req.Highlight != nil {
for i := 0; i < (req.Size + req.From); i++ {
estimate += (req.Size + req.From) * d.Size()
numDocsApplicable := req.Size
if numDocsApplicable > collector.PreAllocSizeSkipCap {
numDocsApplicable = collector.PreAllocSizeSkipCap
}
estimate += numDocsApplicable * d.Size()
}
return uint64(estimate)