enhance: remove extra get collection (#42042)

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
This commit is contained in:
XuanYang-cn 2025-06-10 18:34:35 +08:00 committed by GitHub
parent f1a4526bac
commit 83877b9faf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -259,7 +259,12 @@ func (loader *segmentLoader) Load(ctx context.Context,
addBucketNameStorageV2(segmentInfo)
}
coll := loader.manager.Collection.Get(collectionID)
collection := loader.manager.Collection.Get(collectionID)
if collection == nil {
err := merr.WrapErrCollectionNotFound(collectionID)
log.Warn("failed to get collection", zap.Error(err))
return nil, err
}
// Filter out loaded & loading segments
infos := loader.prepare(ctx, segmentType, segments...)
@ -276,7 +281,7 @@ func (loader *segmentLoader) Load(ctx context.Context,
var err error
var requestResourceResult requestResourceResult
if !isLazyLoad(coll, segmentType) {
if !isLazyLoad(collection, segmentType) {
// Check memory & storage limit
// no need to check resource for lazy load here
requestResourceResult, err = loader.requestResource(ctx, infos...)
@ -300,13 +305,6 @@ func (loader *segmentLoader) Load(ctx context.Context,
debug.FreeOSMemory()
}()
collection := loader.manager.Collection.Get(collectionID)
if collection == nil {
err := merr.WrapErrCollectionNotFound(collectionID)
log.Warn("failed to get collection", zap.Error(err))
return nil, err
}
for _, info := range infos {
loadInfo := info