Skip to content

Commit

Permalink
feat: support alter collection field properties
Browse files Browse the repository at this point in the history
Signed-off-by: PowderLi <[email protected]>
  • Loading branch information
PowderLi committed Jul 29, 2024
1 parent a8a4779 commit cff7038
Show file tree
Hide file tree
Showing 21 changed files with 384 additions and 57 deletions.
55 changes: 55 additions & 0 deletions client/mock_milvus_server_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/datacoord/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ func (m *mockRootCoordClient) AlterCollection(ctx context.Context, request *milv
panic("not implemented") // TODO: Implement
}

func (m *mockRootCoordClient) AlterCollectionOrField(ctx context.Context, request *milvuspb.AlterCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
panic("not implemented") // TODO: Implement
}

func (m *mockRootCoordClient) CreatePartition(ctx context.Context, req *milvuspb.CreatePartitionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
panic("not implemented") // TODO: Implement
}
Expand Down
1 change: 1 addition & 0 deletions internal/datacoord/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,7 @@ func (s *Server) BroadcastAlteredCollection(ctx context.Context, req *datapb.Alt
return merr.Success(), nil
}

clonedColl.Schema = req.GetSchema()
clonedColl.Properties = properties
s.meta.AddCollection(clonedColl)
return merr.Success(), nil
Expand Down
5 changes: 5 additions & 0 deletions internal/distributed/proxy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ func (s *Server) AlterCollection(ctx context.Context, request *milvuspb.AlterCol
return s.proxy.AlterCollection(ctx, request)
}

func (s *Server) AlterCollectionField(ctx context.Context, request *milvuspb.AlterCollectionRequest) (*commonpb.Status, error) {

Check warning on line 845 in internal/distributed/proxy/service.go

View check run for this annotation

Codecov / codecov/patch

internal/distributed/proxy/service.go#L845

Added line #L845 was not covered by tests
// todo
return s.proxy.AlterCollection(ctx, request)

Check warning on line 847 in internal/distributed/proxy/service.go

View check run for this annotation

Codecov / codecov/patch

internal/distributed/proxy/service.go#L847

Added line #L847 was not covered by tests
}

// CreatePartition notifies Proxy to create a partition
func (s *Server) CreatePartition(ctx context.Context, request *milvuspb.CreatePartitionRequest) (*commonpb.Status, error) {
return s.proxy.CreatePartition(ctx, request)
Expand Down
11 changes: 11 additions & 0 deletions internal/distributed/rootcoord/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ func (c *Client) AlterCollection(ctx context.Context, request *milvuspb.AlterCol
})
}

func (c *Client) AlterCollectionOrField(ctx context.Context, request *milvuspb.AlterCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
request = typeutil.Clone(request)
commonpbutil.UpdateMsgBase(
request.GetBase(),
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
)
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
return client.AlterCollectionOrField(ctx, request)
})
}

// CreatePartition create partition
func (c *Client) CreatePartition(ctx context.Context, in *milvuspb.CreatePartitionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
in = typeutil.Clone(in)
Expand Down
4 changes: 4 additions & 0 deletions internal/distributed/rootcoord/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ func (s *Server) AlterCollection(ctx context.Context, request *milvuspb.AlterCol
return s.rootCoord.AlterCollection(ctx, request)
}

func (s *Server) AlterCollectionOrField(ctx context.Context, request *milvuspb.AlterCollectionRequest) (*commonpb.Status, error) {
return s.rootCoord.AlterCollectionOrField(ctx, request)
}

func (s *Server) RenameCollection(ctx context.Context, request *milvuspb.RenameCollectionRequest) (*commonpb.Status, error) {
return s.rootCoord.RenameCollection(ctx, request)
}
55 changes: 55 additions & 0 deletions internal/mocks/mock_proxy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions internal/mocks/mock_rootcoord.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions internal/mocks/mock_rootcoord_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/proto/root_coord.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ service RootCoord {

rpc AlterCollection(milvus.AlterCollectionRequest) returns (common.Status) {}

rpc AlterCollectionOrField(milvus.AlterCollectionRequest) returns (common.Status) {}

/**
* @brief This method is used to create partition
*
Expand Down
16 changes: 14 additions & 2 deletions internal/proxy/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,13 +1218,25 @@ func (node *Proxy) ShowCollections(ctx context.Context, request *milvuspb.ShowCo
}

func (node *Proxy) AlterCollection(ctx context.Context, request *milvuspb.AlterCollectionRequest) (*commonpb.Status, error) {
return node.alterCollectionOrField(ctx, "AlterCollection", &milvuspb.AlterCollectionRequest{
Base: request.Base,
DbName: request.DbName,
CollectionName: request.CollectionName,
Properties: request.Properties,
})
}

func (node *Proxy) AlterCollectionField(ctx context.Context, request *milvuspb.AlterCollectionRequest) (*commonpb.Status, error) {
return node.alterCollectionOrField(ctx, "AlterCollectionField", request)

Check warning on line 1230 in internal/proxy/impl.go

View check run for this annotation

Codecov / codecov/patch

internal/proxy/impl.go#L1229-L1230

Added lines #L1229 - L1230 were not covered by tests
}

func (node *Proxy) alterCollectionOrField(ctx context.Context, method string, request *milvuspb.AlterCollectionRequest) (*commonpb.Status, error) {
if err := merr.CheckHealthy(node.GetStateCode()); err != nil {
return merr.Status(err), nil
}

ctx, sp := otel.Tracer(typeutil.ProxyRole).Start(ctx, "Proxy-AlterCollection")
ctx, sp := otel.Tracer(typeutil.ProxyRole).Start(ctx, "Proxy-"+method)
defer sp.End()
method := "AlterCollection"
tr := timerecord.NewTimeRecorder(method)

metrics.ProxyFunctionCall.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), method, metrics.TotalLabel, request.GetDbName(), request.GetCollectionName()).Inc()
Expand Down
4 changes: 4 additions & 0 deletions internal/proxy/rootcoord_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,10 @@ func (coord *RootCoordMock) AlterCollection(ctx context.Context, request *milvus
return &commonpb.Status{}, nil
}

func (coord *RootCoordMock) AlterCollectionOrField(ctx context.Context, request *milvuspb.AlterCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
return &commonpb.Status{}, nil
}

func (coord *RootCoordMock) CreateDatabase(ctx context.Context, in *milvuspb.CreateDatabaseRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
return &commonpb.Status{}, nil
}
Expand Down
Loading

0 comments on commit cff7038

Please sign in to comment.