未验证 提交 941891a3 编写于 作者: Z zhenshan.cao 提交者: GitHub

Ban AutoIndex on BinaryVector (#21381)

Signed-off-by: Nzhenshan.cao <zhenshan.cao@zilliz.com>
上级 ffbfce6e
......@@ -19,6 +19,9 @@ package indexcoord
import (
"context"
"errors"
"fmt"
"github.com/milvus-io/milvus-proto/go-api/schemapb"
"go.uber.org/zap"
......@@ -131,6 +134,11 @@ func (cit *CreateIndexTask) PreExecute(ctx context.Context) error {
if getIndexType(cit.req.GetIndexParams()) == diskAnnIndex && !cit.indexCoordClient.nodeManager.ClientSupportDisk() {
return errors.New("all IndexNodes do not support disk indexes, please verify")
}
if cit.req.GetFieldDataType() == schemapb.DataType_BinaryVector && Params.AutoIndexConfig.Enable {
return fmt.Errorf("can not create AutoIndex on binary vector")
}
return nil
}
......
......@@ -5,6 +5,7 @@ package milvus.proto.index;
option go_package = "github.com/milvus-io/milvus/internal/proto/indexpb";
import "common.proto";
import "schema.proto";
import "internal.proto";
import "milvus.proto";
......@@ -131,6 +132,7 @@ message CreateIndexRequest {
uint64 timestamp = 6;
bool is_auto_index = 7;
repeated common.KeyValuePair user_index_params = 8;
schema.DataType fieldDataType = 9;
}
message GetIndexInfoRequest {
......
......@@ -117,17 +117,6 @@ message AlterAliasRequest{
string alias = 4;
}
message CreateIndexRequest {
common.MsgBase base = 1;
string db_name = 2;
string collection_name = 3;
string field_name = 4;
int64 dbID = 5;
int64 collectionID = 6;
int64 fieldID = 7;
repeated common.KeyValuePair extra_params = 8;
}
enum InsertDataVersion {
// 0 must refer to row-based format, since it's the first version in Milvus.
RowBased = 0;
......
......@@ -202,6 +202,9 @@ func (cct *createCollectionTask) PreExecute(ctx context.Context) error {
if err != nil {
return err
}
if Params.AutoIndexConfig.Enable && field.DataType == schemapb.DataType_BinaryVector {
return fmt.Errorf("can not speficy binary vector when enabled with AutoIndex")
}
}
// valid max length per row parameters
// if max_length not specified, return error
......
......@@ -282,6 +282,11 @@ func (cit *createIndexTask) PreExecute(ctx context.Context) error {
if err != nil {
return err
}
if field.GetDataType() == schemapb.DataType_BinaryVector && Params.AutoIndexConfig.Enable {
return fmt.Errorf("can not create AutoIndex on binary vector")
}
cit.fieldSchema = field
// check index param, not accurate, only some static rules
err = cit.parseIndexParams()
......@@ -318,6 +323,7 @@ func (cit *createIndexTask) Execute(ctx context.Context) error {
IsAutoIndex: cit.isAutoIndex,
UserIndexParams: cit.req.GetExtraParams(),
Timestamp: cit.BeginTs(),
FieldDataType: cit.fieldSchema.GetDataType(),
}
cit.result, err = cit.indexCoord.CreateIndex(ctx, req)
if err != nil {
......
......@@ -54,7 +54,6 @@ func (t *createCollectionTask) validate() error {
if t.Req.GetShardsNum() >= maxShardNum {
return fmt.Errorf("shard num (%d) exceeds limit (%d)", t.Req.GetShardsNum(), maxShardNum)
}
return nil
}
......@@ -67,6 +66,15 @@ func hasSystemFields(schema *schemapb.CollectionSchema, systemFields []string) b
return false
}
func hasBinaryVecField(schema *schemapb.CollectionSchema) bool {
for _, field := range schema.GetFields() {
if field.GetDataType() == schemapb.DataType_BinaryVector {
return true
}
}
return false
}
func (t *createCollectionTask) validateSchema(schema *schemapb.CollectionSchema) error {
if t.Req.GetCollectionName() != schema.GetName() {
return fmt.Errorf("collection name = %s, schema.Name=%s", t.Req.GetCollectionName(), schema.Name)
......@@ -74,6 +82,10 @@ func (t *createCollectionTask) validateSchema(schema *schemapb.CollectionSchema)
if hasSystemFields(schema, []string{RowIDFieldName, TimeStampFieldName}) {
return fmt.Errorf("schema contains system field: %s, %s", RowIDFieldName, TimeStampFieldName)
}
if Params.AutoIndexConfig.Enable && hasBinaryVecField(schema) {
return fmt.Errorf("can not speficy binary vector when enabled with AutoIndex")
}
return nil
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册