scorch optimize mem processDocument() norm calculation
This change moves the norm calculation outside of the inner loop.
This commit is contained in:
parent
6ae799052a
commit
884da6f93a
|
@ -253,12 +253,13 @@ func (s *Segment) processDocument(result *index.AnalysisResult) {
|
||||||
// now that its been rolled up into docMap, walk that
|
// now that its been rolled up into docMap, walk that
|
||||||
for fieldID, tokenFrequencies := range docMap {
|
for fieldID, tokenFrequencies := range docMap {
|
||||||
dict := s.Dicts[fieldID]
|
dict := s.Dicts[fieldID]
|
||||||
|
norm := float32(1.0/math.Sqrt(float64(fieldLens[fieldID])))
|
||||||
for term, tokenFreq := range tokenFrequencies {
|
for term, tokenFreq := range tokenFrequencies {
|
||||||
pid := dict[term] - 1
|
pid := dict[term] - 1
|
||||||
bs := s.Postings[pid]
|
bs := s.Postings[pid]
|
||||||
bs.AddInt(int(docNum))
|
bs.AddInt(int(docNum))
|
||||||
s.Freqs[pid] = append(s.Freqs[pid], uint64(tokenFreq.Frequency()))
|
s.Freqs[pid] = append(s.Freqs[pid], uint64(tokenFreq.Frequency()))
|
||||||
s.Norms[pid] = append(s.Norms[pid], float32(1.0/math.Sqrt(float64(fieldLens[fieldID]))))
|
s.Norms[pid] = append(s.Norms[pid], norm)
|
||||||
locationBS := s.PostingsLocs[pid]
|
locationBS := s.PostingsLocs[pid]
|
||||||
if len(tokenFreq.Locations) > 0 {
|
if len(tokenFreq.Locations) > 0 {
|
||||||
locationBS.AddInt(int(docNum))
|
locationBS.AddInt(int(docNum))
|
||||||
|
|
Loading…
Reference in New Issue