...
- As the name indicates, CollectionAlias is an alias to an existing collection.
- The collection alias can be updated to a new collection.
- Within
RootCoordinator
,Proxy
, and all the key components,CollectionName
andCollectionAlias
are equal.
e.g.MetaTable.GetCollectionByName(collectionName string, ts typeutil.Timestamp)
can receiveCollectionAlias
and return correspondingCollectionInfo.
CollectionAlias
∧CollectionName
= ∅ .CollectionAlias
cannot collide with existingCollectionName
s.
...
Design Details
Changes to the MetaTable
Code Block |
---|
type metaTable struct {
client kv.SnapShotKV // client of a reliable kv service, i.e. etcd client
tenantID2Meta map[typeutil.UniqueID]pb.TenantMeta // tenant id to tenant meta
proxyID2Meta map[typeutil.UniqueID]pb.ProxyMeta // proxy id to proxy meta
collID2Meta map[typeutil.UniqueID]pb.CollectionInfo // collection_id -> meta
collName2ID map[string]typeutil.UniqueID // collection name to collection id
// NEW
**collAlias2ID map[string]typeutil.UniqueID**
...
} |
...
As CollectionAlias
& CollectionName
are equal, GetCollectionByName
also checks metaTable.collAlias2ID
when getting the collection by name.
Code Block |
---|
func (mt *metaTable) GetCollectionByName(collectionName string, ts typeutil.Timestamp) (*pb.CollectionInfo, error) {
mt.ddLock.RLock()
defer mt.ddLock.RUnlock()
if ts == 0 {
vid, ok := mt.collName2ID[collectionName]
if !ok {
// NEW
**if vid, ok = mt.collAlias2ID[collectionName]; !ok {**
return nil, fmt.Errorf("can't find collection: " + collectionName)
}
}
...
} |
...
CollectionAlias
also have to be persisted in the etcd
.
Code Block |
---|
const (
ComponentPrefix = "root-coord"
TenantMetaPrefix = ComponentPrefix + "/tenant"
ProxyMetaPrefix = ComponentPrefix + "/proxy"
CollectionMetaPrefix = ComponentPrefix + "/collection"
SegmentIndexMetaPrefix = ComponentPrefix + "/segment-index"
IndexMetaPrefix = ComponentPrefix + "/index"
// NEW Additions
|
...
CollectionAliasMetaPrefix = ComponentPrefix + "/collection-alias" |
...
) |
...
For persistence in etcd
, the key will be fmt.Sprintf("%s/%s", CollectionAliasMetaPrefix, CollectionAlias)
and the value be CollectionID
.
...