mirror of https://github.com/milvus-io/milvus.git
Add ListCollection for meta table
Signed-off-by: neza2017 <yefu.chen@zilliz.com>pull/4973/head^2
parent
c2382adf04
commit
74f8c45a23
|
@ -1133,6 +1133,7 @@ func (meta *metaTable) AddCollection(coll *CollectionMeta) error
|
|||
func (meta *metaTable) DeleteCollection(collId UniqueId) error
|
||||
func (meta *metaTable) HasCollection(collId UniqueId) bool
|
||||
func (meta *metaTable) GetCollectionByName(collName string) (*CollectionMeta, error)
|
||||
func (meta *metaTable) ListCollections()([]string, error)
|
||||
|
||||
func (meta *metaTable) AddPartition(collId UniqueId, tag string) error
|
||||
func (meta *metaTable) HasPartition(collId UniqueId, tag string) bool
|
||||
|
|
|
@ -287,6 +287,17 @@ func (mt *metaTable) GetCollectionByName(collectionName string) (*pb.CollectionM
|
|||
return &col, nil
|
||||
}
|
||||
|
||||
func (mt *metaTable) ListCollections() ([]string, error) {
|
||||
mt.ddLock.RLock()
|
||||
defer mt.ddLock.RUnlock()
|
||||
|
||||
colls := make([]string, 0, len(mt.collName2ID))
|
||||
for name := range mt.collName2ID {
|
||||
colls = append(colls, name)
|
||||
}
|
||||
return colls, nil
|
||||
}
|
||||
|
||||
func (mt *metaTable) AddPartition(collID UniqueID, tag string) error {
|
||||
mt.ddLock.Lock()
|
||||
defer mt.ddLock.Unlock()
|
||||
|
|
|
@ -102,6 +102,11 @@ func TestMetaTable_Collection(t *testing.T) {
|
|||
assert.NotNil(t, err)
|
||||
err = meta.AddCollection(&colMeta5)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
collsName, err := meta.ListCollections()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, collsName, []string{"coll1", "coll2"})
|
||||
|
||||
hasCollection := meta.HasCollection(colMeta.ID)
|
||||
assert.True(t, hasCollection)
|
||||
err = meta.AddPartition(colMeta.ID, "p1")
|
||||
|
|
Loading…
Reference in New Issue