0
0
Fork 0

scorch zap optimize postings itr with tf/loc reader/decoder reuse

This commit is contained in:
Steve Yen 2018-03-06 08:06:12 -08:00
parent 530a3d24cf
commit 5b86da85f3
1 changed files with 18 additions and 0 deletions

View File

@ -45,7 +45,25 @@ func (p *PostingsList) iterator(rv *PostingsIterator) *PostingsIterator {
if rv == nil {
rv = &PostingsIterator{}
} else {
freqNormReader := rv.freqNormReader
if freqNormReader != nil {
freqNormReader.Reset([]byte(nil))
}
freqNormDecoder := rv.freqNormDecoder
locReader := rv.locReader
if locReader != nil {
locReader.Reset([]byte(nil))
}
locDecoder := rv.locDecoder
*rv = PostingsIterator{} // clear the struct
rv.freqNormReader = freqNormReader
rv.freqNormDecoder = freqNormDecoder
rv.locReader = locReader
rv.locDecoder = locDecoder
}
rv.postings = p