feat: support lazy load on querycoord (#30372)

https://github.com/milvus-io/milvus/issues/30361

Signed-off-by: sunby <sunbingyi1992@gmail.com>
pull/30989/head
Bingyi Sun 2024-03-01 18:15:29 +08:00 committed by GitHub
parent f3c56c83ab
commit 7783098ddd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 2 deletions

View File

@ -868,11 +868,20 @@ func hasMmapProp(props ...*commonpb.KeyValuePair) bool {
return false
}
func hasLazyLoadProp(props ...*commonpb.KeyValuePair) bool {
for _, p := range props {
if p.GetKey() == common.LazyLoadEnableKey {
return true
}
}
return false
}
func (t *alterCollectionTask) PreExecute(ctx context.Context) error {
t.Base.MsgType = commonpb.MsgType_AlterCollection
t.Base.SourceID = paramtable.GetNodeID()
if hasMmapProp(t.Properties...) {
if hasMmapProp(t.Properties...) || hasLazyLoadProp(t.Properties...) {
loaded, err := isCollectionLoaded(ctx, t.queryCoord, t.CollectionID)
if err != nil {
return err

View File

@ -96,6 +96,25 @@ func GetTaskType(task Task) Type {
return 0
}
func mergeCollectonProps(schemaProps []*commonpb.KeyValuePair, collectionProps []*commonpb.KeyValuePair) []*commonpb.KeyValuePair {
// Merge the collectionProps and schemaProps maps, giving priority to the values in schemaProps if there are duplicate keys.
props := make(map[string]string)
for _, p := range collectionProps {
props[p.GetKey()] = p.GetValue()
}
for _, p := range schemaProps {
props[p.GetKey()] = p.GetValue()
}
var ret []*commonpb.KeyValuePair
for k, v := range props {
ret = append(ret, &commonpb.KeyValuePair{
Key: k,
Value: v,
})
}
return ret
}
func packLoadSegmentRequest(
task *SegmentTask,
action Action,
@ -124,6 +143,8 @@ func packLoadSegmentRequest(
}
}
schema.Properties = mergeCollectonProps(schema.Properties, collectionProperties)
return &querypb.LoadSegmentsRequest{
Base: commonpbutil.NewMsgBase(
commonpbutil.WithMsgType(commonpb.MsgType_LoadSegments),

View File

@ -127,7 +127,8 @@ const (
// common properties
const (
MmapEnabledKey = "mmap.enabled"
MmapEnabledKey = "mmap.enabled"
LazyLoadEnableKey = "lazyload.enabled"
)
const (
@ -157,6 +158,15 @@ func IsFieldMmapEnabled(schema *schemapb.CollectionSchema, fieldID int64) bool {
return false
}
func IsCollectionLazyLoadEnabled(kvs ...*commonpb.KeyValuePair) bool {
for _, kv := range kvs {
if kv.Key == LazyLoadEnableKey && kv.Value == "true" {
return true
}
}
return false
}
const (
// LatestVerision is the magic number for watch latest revision
LatestRevision = int64(-1)