Skip to content

Commit

Permalink
Fix vector field type check logic (#447)
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia authored Apr 26, 2023
1 parent ab87966 commit 52df79f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions entity/columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,11 @@ func FieldDataVector(fd *schema.FieldData) (Column, error) {
switch fd.GetType() {
case schema.DataType_FloatVector:
vectors := fd.GetVectors()
data := vectors.GetFloatVector().GetData()
if data == nil {
x, ok := vectors.GetData().(*schema.VectorField_FloatVector)
if !ok {
return nil, errFieldDataTypeNotMatch
}
data := x.FloatVector.GetData()
dim := int(vectors.GetDim())
vector := make([][]float32, 0, len(data)/dim) // shall not have remanunt
for i := 0; i < len(data)/dim; i++ {
Expand All @@ -247,7 +248,11 @@ func FieldDataVector(fd *schema.FieldData) (Column, error) {
return NewColumnFloatVector(fd.GetFieldName(), dim, vector), nil
case schema.DataType_BinaryVector:
vectors := fd.GetVectors()
data := vectors.GetBinaryVector()
x, ok := vectors.GetData().(*schema.VectorField_BinaryVector)
if !ok {
return nil, errFieldDataTypeNotMatch
}
data := x.BinaryVector
if data == nil {
return nil, errFieldDataTypeNotMatch
}
Expand Down

0 comments on commit 52df79f

Please sign in to comment.