mirror of https://github.com/milvus-io/milvus.git
Pass type params when building index
Signed-off-by: sunby <bingyi.sun@zilliz.com>pull/4973/head^2
parent
e9dc96f931
commit
d0c787628b
|
@ -58,16 +58,24 @@ func (scheduler *IndexBuildScheduler) schedule(info interface{}) error {
|
|||
}
|
||||
|
||||
// parse index params
|
||||
typeParams, err := scheduler.metaTable.GetFieldTypeParams(segMeta.CollectionID, indexBuildInfo.fieldID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
indexParams, err := scheduler.metaTable.GetFieldIndexParams(segMeta.CollectionID, indexBuildInfo.fieldID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
typeParamsMap := make(map[string]string)
|
||||
indexParamsMap := make(map[string]string)
|
||||
for _, kv := range typeParams {
|
||||
typeParamsMap[kv.Key] = kv.Value
|
||||
}
|
||||
for _, kv := range indexParams {
|
||||
indexParamsMap[kv.Key] = kv.Value
|
||||
}
|
||||
|
||||
indexID, err := scheduler.client.BuildIndexWithoutID(indexBuildInfo.binlogFilePath, nil, indexParamsMap)
|
||||
indexID, err := scheduler.client.BuildIndexWithoutID(indexBuildInfo.binlogFilePath, typeParamsMap, indexParamsMap)
|
||||
log.Printf("build index for segment %d field %d", indexBuildInfo.segmentID, indexBuildInfo.fieldID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -638,6 +638,22 @@ func (mt *metaTable) removeSegmentIndexMeta(segID UniqueID) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (mt *metaTable) GetFieldTypeParams(collID UniqueID, fieldID UniqueID) ([]*commonpb.KeyValuePair, error) {
|
||||
mt.ddLock.RLock()
|
||||
defer mt.ddLock.RUnlock()
|
||||
|
||||
if _, ok := mt.collID2Meta[collID]; !ok {
|
||||
return nil, fmt.Errorf("can not find collection with id %d", collID)
|
||||
}
|
||||
|
||||
for _, fieldSchema := range mt.collID2Meta[collID].Schema.Fields {
|
||||
if fieldSchema.FieldID == fieldID {
|
||||
return fieldSchema.TypeParams, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("can not find field %d in collection %d", fieldID, collID)
|
||||
}
|
||||
|
||||
func (mt *metaTable) GetFieldIndexParams(collID UniqueID, fieldID UniqueID) ([]*commonpb.KeyValuePair, error) {
|
||||
mt.ddLock.RLock()
|
||||
defer mt.ddLock.RUnlock()
|
||||
|
|
Loading…
Reference in New Issue