mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: remove invalid restrictions on dim for int8 vector (#43469)
issue: #43466 Signed-off-by: xianliang.li <xianliang.li@zilliz.com>
This commit is contained in:
parent
74c08069ef
commit
ed57650b52
@ -341,6 +341,7 @@ func validateDimension(field *schemapb.FieldSchema) error {
|
||||
break
|
||||
}
|
||||
}
|
||||
// for sparse vector field, dim should not be specified
|
||||
if typeutil.IsSparseFloatVectorType(field.DataType) {
|
||||
if exist {
|
||||
return fmt.Errorf("dim should not be specified for sparse vector field %s(%d)", field.GetName(), field.FieldID)
|
||||
@ -355,17 +356,18 @@ func validateDimension(field *schemapb.FieldSchema) error {
|
||||
return fmt.Errorf("invalid dimension: %d. should be in range 2 ~ %d", dim, Params.ProxyCfg.MaxDimension.GetAsInt())
|
||||
}
|
||||
|
||||
if typeutil.IsFloatVectorType(field.DataType) {
|
||||
if dim > Params.ProxyCfg.MaxDimension.GetAsInt64() {
|
||||
return fmt.Errorf("invalid dimension: %d of field %s. float vector dimension should be in range 2 ~ %d", dim, field.GetName(), Params.ProxyCfg.MaxDimension.GetAsInt())
|
||||
}
|
||||
} else {
|
||||
// for dense vector field, dim will be limited by max_dimension
|
||||
if typeutil.IsBinaryVectorType(field.DataType) {
|
||||
if dim%8 != 0 {
|
||||
return fmt.Errorf("invalid dimension: %d of field %s. binary vector dimension should be multiple of 8. ", dim, field.GetName())
|
||||
}
|
||||
if dim > Params.ProxyCfg.MaxDimension.GetAsInt64()*8 {
|
||||
return fmt.Errorf("invalid dimension: %d of field %s. binary vector dimension should be in range 2 ~ %d", dim, field.GetName(), Params.ProxyCfg.MaxDimension.GetAsInt()*8)
|
||||
}
|
||||
} else {
|
||||
if dim > Params.ProxyCfg.MaxDimension.GetAsInt64() {
|
||||
return fmt.Errorf("invalid dimension: %d of field %s. float vector dimension should be in range 2 ~ %d", dim, field.GetName(), Params.ProxyCfg.MaxDimension.GetAsInt())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -262,6 +262,31 @@ func TestValidateDimension(t *testing.T) {
|
||||
},
|
||||
}
|
||||
assert.NotNil(t, validateDimension(fieldSchema))
|
||||
|
||||
fieldSchema.DataType = schemapb.DataType_Int8Vector
|
||||
fieldSchema.TypeParams = []*commonpb.KeyValuePair{
|
||||
{
|
||||
Key: common.DimKey,
|
||||
Value: "200",
|
||||
},
|
||||
}
|
||||
assert.Nil(t, validateDimension(fieldSchema))
|
||||
|
||||
fieldSchema.TypeParams = []*commonpb.KeyValuePair{
|
||||
{
|
||||
Key: common.DimKey,
|
||||
Value: "201",
|
||||
},
|
||||
}
|
||||
assert.Nil(t, validateDimension(fieldSchema))
|
||||
|
||||
fieldSchema.TypeParams = []*commonpb.KeyValuePair{
|
||||
{
|
||||
Key: common.DimKey,
|
||||
Value: strconv.Itoa(int(Params.ProxyCfg.MaxDimension.GetAsInt32() + 1)),
|
||||
},
|
||||
}
|
||||
assert.NotNil(t, validateDimension(fieldSchema))
|
||||
}
|
||||
|
||||
func TestValidateVectorFieldMetricType(t *testing.T) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user