Merge pull request #852 from steveyen/scorch-zap-postingsIterator-allNChunk-bug
PostingsIterator.nextDocNum() maintains allNChunk correctly
This commit is contained in:
commit
a7c4237d00
|
@ -316,11 +316,9 @@ func (rv *PostingsList) init1Hit(fstVal uint64) error {
|
||||||
|
|
||||||
// PostingsIterator provides a way to iterate through the postings list
|
// PostingsIterator provides a way to iterate through the postings list
|
||||||
type PostingsIterator struct {
|
type PostingsIterator struct {
|
||||||
postings *PostingsList
|
postings *PostingsList
|
||||||
all roaring.IntIterable
|
all roaring.IntIterable
|
||||||
offset int
|
actual roaring.IntIterable
|
||||||
locoffset int
|
|
||||||
actual roaring.IntIterable
|
|
||||||
|
|
||||||
currChunk uint32
|
currChunk uint32
|
||||||
currChunkFreqNorm []byte
|
currChunkFreqNorm []byte
|
||||||
|
@ -584,16 +582,12 @@ func (i *PostingsIterator) nextDocNum() (uint64, bool, error) {
|
||||||
nChunk := n / i.postings.sb.chunkFactor
|
nChunk := n / i.postings.sb.chunkFactor
|
||||||
allNChunk := allN / i.postings.sb.chunkFactor
|
allNChunk := allN / i.postings.sb.chunkFactor
|
||||||
|
|
||||||
// n is the next actual hit (excluding some postings)
|
// n is the next actual hit (excluding some postings), and
|
||||||
// allN is the next hit in the full postings
|
// allN is the next hit in the full postings, and
|
||||||
// if they don't match, adjust offsets to factor in item we're skipping over
|
// if they don't match, move 'all' forwards until they do
|
||||||
// incr the all iterator, and check again
|
|
||||||
for allN != n {
|
for allN != n {
|
||||||
// in different chunks, reset offsets
|
// in the same chunk, so move the freq/norm/loc decoders forward
|
||||||
if allNChunk != nChunk {
|
if allNChunk == nChunk {
|
||||||
i.locoffset = 0
|
|
||||||
i.offset = 0
|
|
||||||
} else {
|
|
||||||
if i.currChunk != nChunk || i.currChunkFreqNorm == nil {
|
if i.currChunk != nChunk || i.currChunkFreqNorm == nil {
|
||||||
err := i.loadChunk(int(nChunk))
|
err := i.loadChunk(int(nChunk))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -614,12 +608,10 @@ func (i *PostingsIterator) nextDocNum() (uint64, bool, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// in same chunk, need to account for offsets
|
|
||||||
i.offset++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allN = i.all.Next()
|
allN = i.all.Next()
|
||||||
|
allNChunk = allN / i.postings.sb.chunkFactor
|
||||||
}
|
}
|
||||||
|
|
||||||
if i.currChunk != nChunk || i.currChunkFreqNorm == nil {
|
if i.currChunk != nChunk || i.currChunkFreqNorm == nil {
|
||||||
|
|
Loading…
Reference in New Issue