enhance: altercollectionfield support mmap_enable convert to mmap.enable (#38448)

altercollectionfield support mmap_enable convert to mmap.enable 
issue: https://github.com/milvus-io/milvus/issues/37436

---------

Signed-off-by: Xianhui.Lin <xianhui.lin@zilliz.com>
pull/38449/head
Xianhui Lin 2024-12-13 20:02:43 +08:00 committed by GitHub
parent fe79babdb3
commit b416ff8c6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 29 additions and 1 deletions

View File

@ -1146,6 +1146,10 @@ func (t *alterCollectionFieldTask) OnEnqueue() error {
return nil
}
const (
MmapEnabledKey = "mmap_enabled"
)
var allowedProps = []string{
common.MaxLengthKey,
common.MmapEnabledKey,
@ -1160,12 +1164,35 @@ func IsKeyAllowed(key string) bool {
return false
}
func updatePropertiesKeys(oldProps []*commonpb.KeyValuePair) []*commonpb.KeyValuePair {
props := make(map[string]string)
for _, prop := range oldProps {
var updatedKey string
if prop.Key == MmapEnabledKey {
updatedKey = common.MmapEnabledKey
} else {
updatedKey = prop.Key
}
props[updatedKey] = prop.Value
}
propKV := make([]*commonpb.KeyValuePair, 0)
for key, value := range props {
propKV = append(propKV, &commonpb.KeyValuePair{
Key: key,
Value: value,
})
}
return propKV
}
func (t *alterCollectionFieldTask) PreExecute(ctx context.Context) error {
collSchema, err := globalMetaCache.GetCollectionSchema(ctx, t.GetDbName(), t.CollectionName)
if err != nil {
return err
}
t.Properties = updatePropertiesKeys(t.Properties)
for _, prop := range t.Properties {
if !IsKeyAllowed(prop.Key) {
return merr.WrapErrParameterInvalidMsg("%s does not allow update in collection field param", prop.Key)
@ -1184,6 +1211,7 @@ func (t *alterCollectionFieldTask) PreExecute(ctx context.Context) error {
if loaded {
return merr.WrapErrCollectionLoaded(t.CollectionName, "can not alter collection field properties if collection loaded")
}
case common.MaxLengthKey:
IsStringType := false
fieldName := ""