Skip to content

Commit

Permalink
enhance: altercollectionfield support mmap_enable convert to mmap.ena…
Browse files Browse the repository at this point in the history
…ble (#38448)

altercollectionfield support mmap_enable convert to mmap.enable 
issue: #37436

---------

Signed-off-by: Xianhui.Lin <[email protected]>
  • Loading branch information
JsDove authored Dec 13, 2024
1 parent fe79bab commit b416ff8
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion internal/proxy/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,10 @@ func (t *alterCollectionFieldTask) OnEnqueue() error {
return nil
}

const (
MmapEnabledKey = "mmap_enabled"
)

var allowedProps = []string{
common.MaxLengthKey,
common.MmapEnabledKey,
Expand All @@ -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)
Expand All @@ -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 := ""
Expand Down

0 comments on commit b416ff8

Please sign in to comment.