2022-08-10 10:22:38 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
import pb "github.com/milvus-io/milvus/internal/proto/etcdpb"
|
|
|
|
|
|
|
|
type Alias struct {
|
|
|
|
Name string
|
|
|
|
CollectionID int64
|
|
|
|
CreatedTime uint64
|
2022-09-05 13:29:11 +08:00
|
|
|
State pb.AliasState
|
2023-06-25 17:20:43 +08:00
|
|
|
DbID int64
|
2022-09-05 13:29:11 +08:00
|
|
|
}
|
|
|
|
|
2023-08-30 10:24:29 +08:00
|
|
|
func (a *Alias) Available() bool {
|
2022-09-05 13:29:11 +08:00
|
|
|
return a.State == pb.AliasState_AliasCreated
|
|
|
|
}
|
|
|
|
|
2023-08-30 10:24:29 +08:00
|
|
|
func (a *Alias) Clone() *Alias {
|
2022-09-05 13:29:11 +08:00
|
|
|
return &Alias{
|
|
|
|
Name: a.Name,
|
|
|
|
CollectionID: a.CollectionID,
|
|
|
|
CreatedTime: a.CreatedTime,
|
|
|
|
State: a.State,
|
2023-06-25 17:20:43 +08:00
|
|
|
DbID: a.DbID,
|
2022-09-05 13:29:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-30 10:24:29 +08:00
|
|
|
func (a *Alias) Equal(other Alias) bool {
|
2022-09-05 13:29:11 +08:00
|
|
|
return a.Name == other.Name &&
|
2023-06-25 17:20:43 +08:00
|
|
|
a.CollectionID == other.CollectionID &&
|
|
|
|
a.DbID == other.DbID
|
2022-08-10 10:22:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func MarshalAliasModel(alias *Alias) *pb.AliasInfo {
|
|
|
|
return &pb.AliasInfo{
|
|
|
|
AliasName: alias.Name,
|
|
|
|
CollectionId: alias.CollectionID,
|
|
|
|
CreatedTime: alias.CreatedTime,
|
2022-09-05 13:29:11 +08:00
|
|
|
State: alias.State,
|
2023-06-25 17:20:43 +08:00
|
|
|
DbId: alias.DbID,
|
2022-08-10 10:22:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func UnmarshalAliasModel(info *pb.AliasInfo) *Alias {
|
|
|
|
return &Alias{
|
|
|
|
Name: info.GetAliasName(),
|
|
|
|
CollectionID: info.GetCollectionId(),
|
|
|
|
CreatedTime: info.GetCreatedTime(),
|
2022-09-05 13:29:11 +08:00
|
|
|
State: info.GetState(),
|
2023-06-25 17:20:43 +08:00
|
|
|
DbID: info.GetDbId(),
|
2022-08-10 10:22:38 +08:00
|
|
|
}
|
|
|
|
}
|