0
0

cleaner fix for the TermFrequencyRow reuse bug

reset to nil first, let remaining logic work as before
This commit is contained in:
Marty Schoch 2016-08-01 17:17:29 -04:00
parent cfce9c5fc5
commit 36de4a7097

View File

@ -544,6 +544,7 @@ func (tfr *TermFrequencyRow) parseV(value []byte) error {
tfr.norm = math.Float32frombits(uint32(norm))
tfr.vectors = nil
var field uint64
field, bytesRead = binary.Uvarint(value[currOffset:])
for bytesRead > 0 {
@ -551,7 +552,9 @@ func (tfr *TermFrequencyRow) parseV(value []byte) error {
tv := TermVector{}
tv.field = uint16(field)
// at this point we expect at least one term vector
tfr.vectors = make([]*TermVector, 0)
if tfr.vectors == nil {
tfr.vectors = make([]*TermVector, 0)
}
tv.pos, bytesRead = binary.Uvarint(value[currOffset:])
if bytesRead <= 0 {