cleaner fix for the TermFrequencyRow reuse bug
reset to nil first, let remaining logic work as before
This commit is contained in:
parent
cfce9c5fc5
commit
36de4a7097
|
@ -544,6 +544,7 @@ func (tfr *TermFrequencyRow) parseV(value []byte) error {
|
||||||
|
|
||||||
tfr.norm = math.Float32frombits(uint32(norm))
|
tfr.norm = math.Float32frombits(uint32(norm))
|
||||||
|
|
||||||
|
tfr.vectors = nil
|
||||||
var field uint64
|
var field uint64
|
||||||
field, bytesRead = binary.Uvarint(value[currOffset:])
|
field, bytesRead = binary.Uvarint(value[currOffset:])
|
||||||
for bytesRead > 0 {
|
for bytesRead > 0 {
|
||||||
|
@ -551,7 +552,9 @@ func (tfr *TermFrequencyRow) parseV(value []byte) error {
|
||||||
tv := TermVector{}
|
tv := TermVector{}
|
||||||
tv.field = uint16(field)
|
tv.field = uint16(field)
|
||||||
// at this point we expect at least one term vector
|
// at this point we expect at least one term vector
|
||||||
|
if tfr.vectors == nil {
|
||||||
tfr.vectors = make([]*TermVector, 0)
|
tfr.vectors = make([]*TermVector, 0)
|
||||||
|
}
|
||||||
|
|
||||||
tv.pos, bytesRead = binary.Uvarint(value[currOffset:])
|
tv.pos, bytesRead = binary.Uvarint(value[currOffset:])
|
||||||
if bytesRead <= 0 {
|
if bytesRead <= 0 {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user