reuse memory already allocated for copies of docids
when the term field reader is copying ID values out of the kv store's iterator, it is already attempting to reuse the term frequency row data structure. this change allows us to also attempt to reuse the []byte allocated for previous copies of the docid. we reset the slice length to zero then copy the data into the existing slice, avoiding new allocation and garbage collection in the cases where there is already enough space
This commit is contained in:
parent
4b1b866e0f
commit
89d83cb5a1
|
@ -83,7 +83,8 @@ func (r *UpsideDownCouchTermFieldReader) Next(preAlloced *index.TermFieldDoc) (*
|
|||
if rv == nil {
|
||||
rv = &index.TermFieldDoc{}
|
||||
}
|
||||
rv.ID = append([]byte(nil), tfr.doc...)
|
||||
rv.ID = rv.ID[:0]
|
||||
rv.ID = append(rv.ID, tfr.doc...)
|
||||
rv.Freq = tfr.freq
|
||||
rv.Norm = float64(tfr.norm)
|
||||
if tfr.vectors != nil {
|
||||
|
@ -110,7 +111,8 @@ func (r *UpsideDownCouchTermFieldReader) Advance(docID index.IndexInternalID, pr
|
|||
if rv == nil {
|
||||
rv = &index.TermFieldDoc{}
|
||||
}
|
||||
rv.ID = append([]byte(nil), tfr.doc...)
|
||||
rv.ID = rv.ID[:0]
|
||||
rv.ID = append(rv.ID, tfr.doc...)
|
||||
rv.Freq = tfr.freq
|
||||
rv.Norm = float64(tfr.norm)
|
||||
if tfr.vectors != nil {
|
||||
|
|
Loading…
Reference in New Issue