Use proto Size to calculate req size (#10294)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/10298/head
congqixia 2021-10-20 19:27:27 +08:00 committed by GitHub
parent 455172202a
commit e8a7c482c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 25 deletions

View File

@ -15,7 +15,6 @@ import (
"context"
"errors"
"fmt"
"reflect"
"sync"
"time"
@ -1861,28 +1860,5 @@ func assignInternalTask(ctx context.Context,
}
func getSizeOfLoadSegmentReq(req *querypb.LoadSegmentsRequest) int {
var totalSize = 0
totalSize += int(reflect.ValueOf(*req).Type().Size())
for _, info := range req.Infos {
totalSize += int(reflect.ValueOf(*info).Type().Size())
for _, FieldBinlog := range info.BinlogPaths {
totalSize += int(reflect.ValueOf(*FieldBinlog).Type().Size())
for _, path := range FieldBinlog.Binlogs {
totalSize += len(path)
}
}
}
totalSize += len(req.Schema.Name) + len(req.Schema.Description) + int(reflect.ValueOf(*req.Schema).Type().Size())
for _, fieldSchema := range req.Schema.Fields {
totalSize += len(fieldSchema.Name) + len(fieldSchema.Description) + int(reflect.ValueOf(*fieldSchema).Type().Size())
for _, typeParam := range fieldSchema.TypeParams {
totalSize += len(typeParam.Key) + len(typeParam.Value)
}
for _, indexParam := range fieldSchema.IndexParams {
totalSize += len(indexParam.Key) + len(indexParam.Value)
}
}
return totalSize
return proto.Size(req)
}