2022-07-22 10:20:29 +08:00
|
|
|
package metastore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-10-16 20:49:27 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/milvuspb"
|
2022-07-22 10:20:29 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/metastore/model"
|
2022-08-20 10:24:51 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/datapb"
|
2022-09-15 18:48:32 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/querypb"
|
2022-07-22 10:20:29 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/typeutil"
|
|
|
|
)
|
|
|
|
|
2022-09-27 19:18:54 +08:00
|
|
|
//go:generate mockery --name=RootCoordCatalog
|
2022-08-20 10:24:51 +08:00
|
|
|
type RootCoordCatalog interface {
|
2022-07-22 10:20:29 +08:00
|
|
|
CreateCollection(ctx context.Context, collectionInfo *model.Collection, ts typeutil.Timestamp) error
|
|
|
|
GetCollectionByID(ctx context.Context, collectionID typeutil.UniqueID, ts typeutil.Timestamp) (*model.Collection, error)
|
|
|
|
GetCollectionByName(ctx context.Context, collectionName string, ts typeutil.Timestamp) (*model.Collection, error)
|
|
|
|
ListCollections(ctx context.Context, ts typeutil.Timestamp) (map[string]*model.Collection, error)
|
|
|
|
CollectionExists(ctx context.Context, collectionID typeutil.UniqueID, ts typeutil.Timestamp) bool
|
|
|
|
DropCollection(ctx context.Context, collectionInfo *model.Collection, ts typeutil.Timestamp) error
|
2022-09-05 13:29:11 +08:00
|
|
|
AlterCollection(ctx context.Context, oldColl *model.Collection, newColl *model.Collection, alterType AlterType, ts typeutil.Timestamp) error
|
2022-07-22 10:20:29 +08:00
|
|
|
|
2022-08-10 10:22:38 +08:00
|
|
|
CreatePartition(ctx context.Context, partition *model.Partition, ts typeutil.Timestamp) error
|
|
|
|
DropPartition(ctx context.Context, collectionID typeutil.UniqueID, partitionID typeutil.UniqueID, ts typeutil.Timestamp) error
|
2022-09-05 13:29:11 +08:00
|
|
|
AlterPartition(ctx context.Context, oldPart *model.Partition, newPart *model.Partition, alterType AlterType, ts typeutil.Timestamp) error
|
2022-07-22 10:20:29 +08:00
|
|
|
|
2022-08-10 10:22:38 +08:00
|
|
|
CreateAlias(ctx context.Context, alias *model.Alias, ts typeutil.Timestamp) error
|
|
|
|
DropAlias(ctx context.Context, alias string, ts typeutil.Timestamp) error
|
|
|
|
AlterAlias(ctx context.Context, alias *model.Alias, ts typeutil.Timestamp) error
|
|
|
|
ListAliases(ctx context.Context, ts typeutil.Timestamp) ([]*model.Alias, error)
|
2022-07-22 10:20:29 +08:00
|
|
|
|
|
|
|
GetCredential(ctx context.Context, username string) (*model.Credential, error)
|
|
|
|
CreateCredential(ctx context.Context, credential *model.Credential) error
|
2022-08-24 14:32:56 +08:00
|
|
|
AlterCredential(ctx context.Context, credential *model.Credential) error
|
2022-07-22 10:20:29 +08:00
|
|
|
DropCredential(ctx context.Context, username string) error
|
|
|
|
ListCredentials(ctx context.Context) ([]string, error)
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
CreateRole(ctx context.Context, tenant string, entity *milvuspb.RoleEntity) error
|
|
|
|
DropRole(ctx context.Context, tenant string, roleName string) error
|
2022-08-23 10:26:53 +08:00
|
|
|
AlterUserRole(ctx context.Context, tenant string, userEntity *milvuspb.UserEntity, roleEntity *milvuspb.RoleEntity, operateType milvuspb.OperateUserRoleType) error
|
|
|
|
ListRole(ctx context.Context, tenant string, entity *milvuspb.RoleEntity, includeUserInfo bool) ([]*milvuspb.RoleResult, error)
|
|
|
|
ListUser(ctx context.Context, tenant string, entity *milvuspb.UserEntity, includeRoleInfo bool) ([]*milvuspb.UserResult, error)
|
|
|
|
AlterGrant(ctx context.Context, tenant string, entity *milvuspb.GrantEntity, operateType milvuspb.OperatePrivilegeType) error
|
2022-08-26 19:22:56 +08:00
|
|
|
DeleteGrant(ctx context.Context, tenant string, role *milvuspb.RoleEntity) error
|
2022-08-23 10:26:53 +08:00
|
|
|
ListGrant(ctx context.Context, tenant string, entity *milvuspb.GrantEntity) ([]*milvuspb.GrantEntity, error)
|
2022-08-04 11:04:34 +08:00
|
|
|
ListPolicy(ctx context.Context, tenant string) ([]string, error)
|
|
|
|
ListUserRole(ctx context.Context, tenant string) ([]string, error)
|
|
|
|
|
2022-07-22 10:20:29 +08:00
|
|
|
Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
type AlterType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
ADD AlterType = iota
|
|
|
|
DELETE
|
|
|
|
MODIFY
|
|
|
|
)
|
2022-08-20 10:24:51 +08:00
|
|
|
|
2022-09-05 13:29:11 +08:00
|
|
|
func (t AlterType) String() string {
|
|
|
|
switch t {
|
|
|
|
case ADD:
|
|
|
|
return "ADD"
|
|
|
|
case DELETE:
|
|
|
|
return "DELETE"
|
|
|
|
case MODIFY:
|
|
|
|
return "MODIFY"
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2022-08-20 10:24:51 +08:00
|
|
|
type DataCoordCatalog interface {
|
|
|
|
ListSegments(ctx context.Context) ([]*datapb.SegmentInfo, error)
|
|
|
|
AddSegment(ctx context.Context, segment *datapb.SegmentInfo) error
|
|
|
|
AlterSegments(ctx context.Context, segments []*datapb.SegmentInfo) error
|
|
|
|
// AlterSegmentsAndAddNewSegment for transaction
|
|
|
|
AlterSegmentsAndAddNewSegment(ctx context.Context, segments []*datapb.SegmentInfo, newSegment *datapb.SegmentInfo) error
|
2022-08-25 16:48:53 +08:00
|
|
|
SaveDroppedSegmentsInBatch(ctx context.Context, segments []*datapb.SegmentInfo) error
|
2022-08-20 10:24:51 +08:00
|
|
|
DropSegment(ctx context.Context, segment *datapb.SegmentInfo) error
|
|
|
|
MarkChannelDeleted(ctx context.Context, channel string) error
|
|
|
|
IsChannelDropped(ctx context.Context, channel string) bool
|
|
|
|
DropChannel(ctx context.Context, channel string) error
|
2022-09-23 10:50:51 +08:00
|
|
|
|
|
|
|
RevertAlterSegmentsAndAddNewSegment(ctx context.Context, segments []*datapb.SegmentInfo, removalSegment *datapb.SegmentInfo) error
|
2022-08-20 10:24:51 +08:00
|
|
|
}
|
2022-08-25 15:48:54 +08:00
|
|
|
|
|
|
|
type IndexCoordCatalog interface {
|
|
|
|
CreateIndex(ctx context.Context, index *model.Index) error
|
|
|
|
ListIndexes(ctx context.Context) ([]*model.Index, error)
|
|
|
|
AlterIndex(ctx context.Context, newIndex *model.Index) error
|
|
|
|
AlterIndexes(ctx context.Context, newIndexes []*model.Index) error
|
|
|
|
DropIndex(ctx context.Context, collID, dropIdxID typeutil.UniqueID) error
|
|
|
|
|
|
|
|
CreateSegmentIndex(ctx context.Context, segIdx *model.SegmentIndex) error
|
|
|
|
ListSegmentIndexes(ctx context.Context) ([]*model.SegmentIndex, error)
|
|
|
|
AlterSegmentIndex(ctx context.Context, newSegIndex *model.SegmentIndex) error
|
|
|
|
AlterSegmentIndexes(ctx context.Context, newSegIdxes []*model.SegmentIndex) error
|
|
|
|
DropSegmentIndex(ctx context.Context, collID, partID, segID, buildID typeutil.UniqueID) error
|
|
|
|
}
|
2022-09-15 18:48:32 +08:00
|
|
|
|
|
|
|
type QueryCoordCatalog interface {
|
|
|
|
SaveCollection(info *querypb.CollectionLoadInfo) error
|
|
|
|
SavePartition(info ...*querypb.PartitionLoadInfo) error
|
|
|
|
SaveReplica(replica *querypb.Replica) error
|
|
|
|
GetCollections() ([]*querypb.CollectionLoadInfo, error)
|
|
|
|
GetPartitions() (map[int64][]*querypb.PartitionLoadInfo, error)
|
|
|
|
GetReplicas() ([]*querypb.Replica, error)
|
|
|
|
ReleaseCollection(id int64) error
|
|
|
|
ReleasePartition(collection int64, partitions ...int64) error
|
|
|
|
ReleaseReplicas(collectionID int64) error
|
|
|
|
ReleaseReplica(collection, replica int64) error
|
|
|
|
RemoveHandoffEvent(segmentInfo *querypb.SegmentInfo) error
|
|
|
|
}
|