0
0
Fork 0

Merge pull request #661 from steveyen/scorchReusePosting

scorch reuses Posting instance in PostingsIterator.Next()
This commit is contained in:
Steve Yen 2017-12-18 16:37:07 -08:00 committed by GitHub
commit 20972493d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -64,6 +64,10 @@ type PostingsList interface {
}
type PostingsIterator interface {
// The caller is responsible for copying whatever it needs from
// the returned Posting instance before calling Next(), as some
// implementations may return a shared instance to reduce memory
// allocations.
Next() (Posting, error)
}

View File

@ -115,6 +115,8 @@ type PostingsIterator struct {
locChunkStart uint64
locBitmap *roaring.Bitmap
next Posting
}
func (i *PostingsIterator) loadChunk(chunk int) error {
@ -266,10 +268,10 @@ func (i *PostingsIterator) Next() (segment.Posting, error) {
}
}
rv := &Posting{
iterator: i,
docNum: uint64(n),
}
i.next = Posting{} // clear the struct.
rv := &i.next
rv.iterator = i
rv.docNum = uint64(n)
var err error
var normBits uint64