Skip to content

Commit

Permalink
[2.2.x] Fix vector field type check logic (#446)
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 bef5ddb commit 0f8c85b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions entity/columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,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 @@ -237,10 +238,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()
if data == nil {
x, ok := vectors.GetData().(*schema.VectorField_BinaryVector)
if !ok {
return nil, errFieldDataTypeNotMatch
}
data := x.BinaryVector
dim := int(vectors.GetDim())
blen := dim / 8
vector := make([][]byte, 0, len(data)/blen)
Expand Down

0 comments on commit 0f8c85b

Please sign in to comment.