fix: reuse deserialize result to help improve memory management (#34507)

Fixed #33268
The original reuse is broken by #33359

Signed-off-by: Ted Xu <ted.xu@zilliz.com>
This commit is contained in:
Ted Xu 2024-07-09 14:12:10 +08:00 committed by GitHub
parent eeb03a0d6a
commit eae4dfca7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -538,8 +538,9 @@ func (deser *DeserializeReader[T]) Next() error {
deser.pos = 0
deser.rec = deser.rr.Record()
// allocate new slice preventing overwrite previous batch
deser.values = make([]T, deser.rec.Len())
if deser.values == nil || len(deser.values) != deser.rec.Len() {
deser.values = make([]T, deser.rec.Len())
}
if err := deser.deserializer(deser.rec, deser.values); err != nil {
return err
}