1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-05 10:07:22 +00:00
This commit is contained in:
techknowlogick
2021-02-28 18:08:33 -05:00
committed by GitHub
parent 030646eea4
commit 47f6a4ec3f
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)