mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
improve show collection (#20124)
Signed-off-by: wgcn <1026688210@qq.com>
This commit is contained in:
parent
3625b02d50
commit
bf5fb3cd99
@ -355,6 +355,10 @@ func (mt *MetaTable) ListCollections(ctx context.Context, ts Timestamp) ([]*mode
|
||||
mt.ddLock.RLock()
|
||||
defer mt.ddLock.RUnlock()
|
||||
|
||||
if isMaxTs(ts) {
|
||||
return mt.listCollectionFromCache()
|
||||
}
|
||||
|
||||
// list collections should always be loaded from catalog.
|
||||
ctx1 := contextutil.WithTenantID(ctx, Params.CommonCfg.ClusterName)
|
||||
colls, err := mt.catalog.ListCollections(ctx1, ts)
|
||||
@ -370,6 +374,16 @@ func (mt *MetaTable) ListCollections(ctx context.Context, ts Timestamp) ([]*mode
|
||||
return onlineCollections, nil
|
||||
}
|
||||
|
||||
func (mt *MetaTable) listCollectionFromCache() ([]*model.Collection, error) {
|
||||
collectionFromCache := make([]*model.Collection, 0)
|
||||
for _, meta := range mt.collID2Meta {
|
||||
if meta.Available() {
|
||||
collectionFromCache = append(collectionFromCache, meta)
|
||||
}
|
||||
}
|
||||
return collectionFromCache, nil
|
||||
}
|
||||
|
||||
func (mt *MetaTable) ListAbnormalCollections(ctx context.Context, ts Timestamp) ([]*model.Collection, error) {
|
||||
mt.ddLock.RLock()
|
||||
defer mt.ddLock.RUnlock()
|
||||
|
Loading…
Reference in New Issue
Block a user