Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/milvus-io/milvus into 241…
Browse files Browse the repository at this point in the history
…1-revert-db-import-master
  • Loading branch information
bigsheeper committed Nov 7, 2024
2 parents e0e92c4 + aed3b94 commit 89edbb9
Show file tree
Hide file tree
Showing 137 changed files with 2,726 additions and 792 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ Contributions to Milvus are welcome from everyone. See [Guidelines for Contribut
### All contributors

<br><!-- Do not remove start of hero-bot -->
<img src="https://img.shields.io/badge/all--contributors-412-orange"><br>
<img src="https://img.shields.io/badge/all--contributors-415-orange"><br>
<a href="https://github.com/0xflotus"><img src="https://avatars.githubusercontent.com/u/26602940?v=4" width="30px" /></a>
<a href="https://github.com/ABNER-1"><img src="https://avatars.githubusercontent.com/u/24547351?v=4" width="30px" /></a>
<a href="https://github.com/Accagain2014"><img src="https://avatars.githubusercontent.com/u/9635216?v=4" width="30px" /></a>
<a href="https://github.com/Ahmetyasin"><img src="https://avatars.githubusercontent.com/u/34247619?v=4" width="30px" /></a>
<a href="https://github.com/Ald392"><img src="https://avatars.githubusercontent.com/u/166891594?v=4" width="30px" /></a>
<a href="https://github.com/AliDotS"><img src="https://avatars.githubusercontent.com/u/33119433?v=4" width="30px" /></a>
<a href="https://github.com/AllenYu1987"><img src="https://avatars.githubusercontent.com/u/12489985?v=4" width="30px" /></a>
Expand Down Expand Up @@ -504,6 +505,7 @@ Contributions to Milvus are welcome from everyone. See [Guidelines for Contribut
<a href="https://github.com/sre-ro"><img src="https://avatars.githubusercontent.com/u/93502486?v=4" width="30px" /></a>
<a href="https://github.com/sreyan-ghosh"><img src="https://avatars.githubusercontent.com/u/60854658?v=4" width="30px" /></a>
<a href="https://github.com/ss892714028"><img src="https://avatars.githubusercontent.com/u/34635663?v=4" width="30px" /></a>
<a href="https://github.com/stefanwebb"><img src="https://avatars.githubusercontent.com/u/4926302?v=4" width="30px" /></a>
<a href="https://github.com/stephen37"><img src="https://avatars.githubusercontent.com/u/6506810?v=4" width="30px" /></a>
<a href="https://github.com/stevetracvc"><img src="https://avatars.githubusercontent.com/u/70416691?v=4" width="30px" /></a>
<a href="https://github.com/stuartjing"><img src="https://avatars.githubusercontent.com/u/3454260?v=4" width="30px" /></a>
Expand Down Expand Up @@ -571,6 +573,7 @@ Contributions to Milvus are welcome from everyone. See [Guidelines for Contribut
<a href="https://github.com/yxm1536"><img src="https://avatars.githubusercontent.com/u/62009483?v=4" width="30px" /></a>
<a href="https://github.com/yylstudy"><img src="https://avatars.githubusercontent.com/u/26402953?v=4" width="30px" /></a>
<a href="https://github.com/zamanmub"><img src="https://avatars.githubusercontent.com/u/32416908?v=4" width="30px" /></a>
<a href="https://github.com/zander-bobronnikov"><img src="https://avatars.githubusercontent.com/u/183726703?v=4" width="30px" /></a>
<a href="https://github.com/zc2638"><img src="https://avatars.githubusercontent.com/u/28284116?v=4" width="30px" /></a>
<a href="https://github.com/zc277584121"><img src="https://avatars.githubusercontent.com/u/17022025?v=4" width="30px" /></a>
<a href="https://github.com/zengxy"><img src="https://avatars.githubusercontent.com/u/11961641?v=4" width="30px" /></a>
Expand Down
5 changes: 4 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ Milvus [训练营](https://github.com/milvus-io/bootcamp)能够帮助你了解
### All contributors

<br><!-- Do not remove start of hero-bot -->
<img src="https://img.shields.io/badge/all--contributors-412-orange"><br>
<img src="https://img.shields.io/badge/all--contributors-415-orange"><br>
<a href="https://github.com/0xflotus"><img src="https://avatars.githubusercontent.com/u/26602940?v=4" width="30px" /></a>
<a href="https://github.com/ABNER-1"><img src="https://avatars.githubusercontent.com/u/24547351?v=4" width="30px" /></a>
<a href="https://github.com/Accagain2014"><img src="https://avatars.githubusercontent.com/u/9635216?v=4" width="30px" /></a>
<a href="https://github.com/Ahmetyasin"><img src="https://avatars.githubusercontent.com/u/34247619?v=4" width="30px" /></a>
<a href="https://github.com/Ald392"><img src="https://avatars.githubusercontent.com/u/166891594?v=4" width="30px" /></a>
<a href="https://github.com/AliDotS"><img src="https://avatars.githubusercontent.com/u/33119433?v=4" width="30px" /></a>
<a href="https://github.com/AllenYu1987"><img src="https://avatars.githubusercontent.com/u/12489985?v=4" width="30px" /></a>
Expand Down Expand Up @@ -486,6 +487,7 @@ Milvus [训练营](https://github.com/milvus-io/bootcamp)能够帮助你了解
<a href="https://github.com/sre-ro"><img src="https://avatars.githubusercontent.com/u/93502486?v=4" width="30px" /></a>
<a href="https://github.com/sreyan-ghosh"><img src="https://avatars.githubusercontent.com/u/60854658?v=4" width="30px" /></a>
<a href="https://github.com/ss892714028"><img src="https://avatars.githubusercontent.com/u/34635663?v=4" width="30px" /></a>
<a href="https://github.com/stefanwebb"><img src="https://avatars.githubusercontent.com/u/4926302?v=4" width="30px" /></a>
<a href="https://github.com/stephen37"><img src="https://avatars.githubusercontent.com/u/6506810?v=4" width="30px" /></a>
<a href="https://github.com/stevetracvc"><img src="https://avatars.githubusercontent.com/u/70416691?v=4" width="30px" /></a>
<a href="https://github.com/stuartjing"><img src="https://avatars.githubusercontent.com/u/3454260?v=4" width="30px" /></a>
Expand Down Expand Up @@ -553,6 +555,7 @@ Milvus [训练营](https://github.com/milvus-io/bootcamp)能够帮助你了解
<a href="https://github.com/yxm1536"><img src="https://avatars.githubusercontent.com/u/62009483?v=4" width="30px" /></a>
<a href="https://github.com/yylstudy"><img src="https://avatars.githubusercontent.com/u/26402953?v=4" width="30px" /></a>
<a href="https://github.com/zamanmub"><img src="https://avatars.githubusercontent.com/u/32416908?v=4" width="30px" /></a>
<a href="https://github.com/zander-bobronnikov"><img src="https://avatars.githubusercontent.com/u/183726703?v=4" width="30px" /></a>
<a href="https://github.com/zc2638"><img src="https://avatars.githubusercontent.com/u/28284116?v=4" width="30px" /></a>
<a href="https://github.com/zc277584121"><img src="https://avatars.githubusercontent.com/u/17022025?v=4" width="30px" /></a>
<a href="https://github.com/zengxy"><img src="https://avatars.githubusercontent.com/u/11961641?v=4" width="30px" /></a>
Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/Nightly2.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('jenkins-shared-library@v0.62.0') _
@Library('jenkins-shared-library@v0.67.0') _

def pod = libraryResource 'io/milvus/pod/tekton-4am.yaml'

Expand Down
9 changes: 8 additions & 1 deletion ci/jenkins/PR-for-go-sdk.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('jenkins-shared-library@v0.62.0') _
@Library('jenkins-shared-library@v0.67.0') _

def pod = libraryResource 'io/milvus/pod/tekton-4am.yaml'

Expand All @@ -11,6 +11,13 @@ pipeline {
buildDiscarder logRotator(artifactDaysToKeepStr: '30')
preserveStashes(buildCount: 5)
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 6, unit: 'HOURS')
throttleJobProperty(
categories: ['go-sdk'],
throttleEnabled: true,
throttleOption: 'category'

)
}
agent {
kubernetes {
Expand Down
9 changes: 8 additions & 1 deletion ci/jenkins/PR.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('jenkins-shared-library@v0.62.0') _
@Library('jenkins-shared-library@v0.67.0') _

def pod = libraryResource 'io/milvus/pod/tekton-4am.yaml'
def milvus_helm_chart_version = '4.2.8'
Expand All @@ -10,6 +10,13 @@ pipeline {
buildDiscarder logRotator(artifactDaysToKeepStr: '30')
preserveStashes(buildCount: 5)
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 6, unit: 'HOURS')
throttleJobProperty(
categories: ['cpu-e2e'],
throttleEnabled: true,
throttleOption: 'category'

)
}
agent {
kubernetes {
Expand Down
15 changes: 12 additions & 3 deletions ci/jenkins/UT-CPP.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('jenkins-shared-library@v0.63.0') _
@Library('jenkins-shared-library@v0.67.0') _

def pod = libraryResource 'io/milvus/pod/tekton-4am.yaml'
def milvus_helm_chart_version = '4.2.8'
Expand All @@ -10,6 +10,13 @@ pipeline {
buildDiscarder logRotator(artifactDaysToKeepStr: '30')
preserveStashes(buildCount: 5)
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 6, unit: 'HOURS')
throttleJobProperty(
categories: ['cpp-unit-test'],
throttleEnabled: true,
throttleOption: 'category'

)
}
agent {
kubernetes {
Expand All @@ -29,7 +36,7 @@ pipeline {
}
}
}
stage('build') {
stage('build & test') {
steps {
container('tkn') {
script {
Expand All @@ -40,7 +47,9 @@ pipeline {
pullRequestNumber: "$env.CHANGE_ID",
make_cmd: "make clean && make USE_ASAN=ON build-cpp-with-coverage",
test_entrypoint: "./scripts/run_cpp_codecov.sh",
codecov_files: "./lcov_output.info"
codecov_report_name: "cpp-unit-test",
codecov_files: "./lcov_output.info",
tekton_pipeline_timeout: '3h'
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions client/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,12 @@ func (c *Client) RenameCollection(ctx context.Context, option RenameCollectionOp
return merr.CheckRPCCall(resp, err)
})
}

func (c *Client) AlterCollection(ctx context.Context, option AlterCollectionOption, callOptions ...grpc.CallOption) error {
req := option.Request()

return c.callService(func(milvusService milvuspb.MilvusServiceClient) error {
resp, err := milvusService.AlterCollection(ctx, req, callOptions...)
return merr.CheckRPCCall(resp, err)
})
}
47 changes: 47 additions & 0 deletions client/collection_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package client

import (
"fmt"

"google.golang.org/protobuf/proto"

"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
Expand Down Expand Up @@ -56,6 +58,8 @@ type createCollectionOption struct {
// partition key
numPartitions int64

indexOptions []CreateIndexOption

// is fast create collection
isFast bool
// fast creation with index
Expand Down Expand Up @@ -83,6 +87,21 @@ func (opt *createCollectionOption) WithVarcharPK(varcharPK bool, maxLen int) *cr
return opt
}

func (opt *createCollectionOption) WithIndexOptions(indexOpts ...CreateIndexOption) *createCollectionOption {
opt.indexOptions = append(opt.indexOptions, indexOpts...)
return opt
}

func (opt *createCollectionOption) WithProperty(key string, value any) *createCollectionOption {
opt.properties[key] = fmt.Sprintf("%v", value)
return opt
}

func (opt *createCollectionOption) WithConsistencyLevel(cl entity.ConsistencyLevel) *createCollectionOption {
opt.consistencyLevel = cl
return opt
}

func (opt *createCollectionOption) Request() *milvuspb.CreateCollectionRequest {
// fast create collection
if opt.isFast {
Expand All @@ -103,6 +122,7 @@ func (opt *createCollectionOption) Request() *milvuspb.CreateCollectionRequest {

var schemaBytes []byte
if opt.schema != nil {
opt.schema.WithName(opt.name)
schemaProto := opt.schema.ProtoMessage()
schemaBytes, _ = proto.Marshal(schemaProto)
}
Expand Down Expand Up @@ -144,6 +164,7 @@ func SimpleCreateCollectionOptions(name string, dim int64) *createCollectionOpti
dim: dim,
enabledDynamicSchema: true,
consistencyLevel: entity.DefaultConsistencyLevel,
properties: make(map[string]string),

isFast: true,
metricType: entity.COSINE,
Expand All @@ -157,6 +178,7 @@ func NewCreateCollectionOption(name string, collectionSchema *entity.Schema) *cr
shardNum: 1,
schema: collectionSchema,
consistencyLevel: entity.DefaultConsistencyLevel,
properties: make(map[string]string),

metricType: entity.COSINE,
}
Expand Down Expand Up @@ -263,3 +285,28 @@ func NewRenameCollectionOption(oldName, newName string) *renameCollectionOption
newCollectionName: newName,
}
}

type AlterCollectionOption interface {
Request() *milvuspb.AlterCollectionRequest
}

type alterCollectionOption struct {
collectionName string
properties map[string]string
}

func (opt *alterCollectionOption) WithProperty(key string, value any) *alterCollectionOption {
opt.properties[key] = fmt.Sprintf("%v", value)
return opt
}

func (opt *alterCollectionOption) Request() *milvuspb.AlterCollectionRequest {
return &milvuspb.AlterCollectionRequest{
CollectionName: opt.collectionName,
Properties: entity.MapKvPairs(opt.properties),
}
}

func NewAlterCollectionOption(collection string) *alterCollectionOption {
return &alterCollectionOption{collectionName: collection, properties: make(map[string]string)}
}
43 changes: 42 additions & 1 deletion client/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus/client/v2/entity"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/util/merr"
)

Expand Down Expand Up @@ -117,11 +118,20 @@ func (s *CollectionSuite) TestCreateCollectionOptions() {
WithField(entity.NewField().WithName("int64").WithDataType(entity.FieldTypeInt64).WithIsPrimaryKey(true)).
WithField(entity.NewField().WithName("vector").WithDim(128).WithDataType(entity.FieldTypeFloatVector))

opt = NewCreateCollectionOption(collectionName, schema).WithShardNum(2)
opt = NewCreateCollectionOption(collectionName, schema).
WithShardNum(2).
WithConsistencyLevel(entity.ClEventually).
WithProperty(common.CollectionTTLConfigKey, 86400)

req = opt.Request()
s.Equal(collectionName, req.GetCollectionName())
s.EqualValues(2, req.GetShardsNum())
s.EqualValues(commonpb.ConsistencyLevel_Eventually, req.GetConsistencyLevel())
if s.Len(req.GetProperties(), 1) {
kv := req.GetProperties()[0]
s.Equal(common.CollectionTTLConfigKey, kv.GetKey())
s.Equal("86400", kv.GetValue())
}

collSchema = &schemapb.CollectionSchema{}
err = proto.Unmarshal(req.GetSchema(), collSchema)
Expand Down Expand Up @@ -274,6 +284,37 @@ func (s *CollectionSuite) TestRenameCollection() {
})
}

func (s *CollectionSuite) TestAlterCollection() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

collName := fmt.Sprintf("test_collection_%s", s.randString(6))
key := s.randString(6)
value := s.randString(6)

s.Run("success", func() {
s.mock.EXPECT().AlterCollection(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, acr *milvuspb.AlterCollectionRequest) (*commonpb.Status, error) {
s.Equal(collName, acr.GetCollectionName())
if s.Len(acr.GetProperties(), 1) {
item := acr.GetProperties()[0]
s.Equal(key, item.GetKey())
s.Equal(value, item.GetValue())
}
return merr.Success(), nil
}).Once()

err := s.client.AlterCollection(ctx, NewAlterCollectionOption(collName).WithProperty(key, value))
s.NoError(err)
})

s.Run("failure", func() {
s.mock.EXPECT().AlterCollection(mock.Anything, mock.Anything).Return(nil, merr.WrapErrServiceInternal("mocked")).Once()

err := s.client.AlterCollection(ctx, NewAlterCollectionOption(collName).WithProperty(key, value))
s.Error(err)
})
}

func TestCollection(t *testing.T) {
suite.Run(t, new(CollectionSuite))
}
5 changes: 5 additions & 0 deletions client/read_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ func (opt *searchOption) WithPartitions(partitionNames ...string) *searchOption
return opt
}

func (opt *searchOption) WithGroupByField(groupByField string) *searchOption {
opt.request.groupByField = groupByField
return opt
}

func NewSearchOption(collectionName string, limit int, vectors []entity.Vector) *searchOption {
return &searchOption{
collectionName: collectionName,
Expand Down
3 changes: 2 additions & 1 deletion client/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (s *ReadSuite) TestSearch() {
s.mock.EXPECT().Search(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, sr *milvuspb.SearchRequest) (*milvuspb.SearchResults, error) {
s.Equal(collectionName, sr.GetCollectionName())
s.ElementsMatch([]string{partitionName}, sr.GetPartitionNames())
// s.Equal(s)

return &milvuspb.SearchResults{
Status: merr.Success(),
Expand All @@ -71,7 +72,7 @@ func (s *ReadSuite) TestSearch() {
entity.FloatVector(lo.RepeatBy(128, func(_ int) float32 {
return rand.Float32()
})),
}).WithPartitions(partitionName))
}).WithPartitions(partitionName).WithGroupByField("group_by"))
s.NoError(err)
})

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,6 @@ github.com/milvus-io/cgosymbolizer v0.0.0-20240722103217-b7dee0e50119 h1:9VXijWu
github.com/milvus-io/cgosymbolizer v0.0.0-20240722103217-b7dee0e50119/go.mod h1:DvXTE/K/RtHehxU8/GtDs4vFtfw64jJ3PaCnFri8CRg=
github.com/milvus-io/gorocksdb v0.0.0-20220624081344-8c5f4212846b h1:TfeY0NxYxZzUfIfYe5qYDBzt4ZYRqzUjTR6CvUzjat8=
github.com/milvus-io/gorocksdb v0.0.0-20220624081344-8c5f4212846b/go.mod h1:iwW+9cWfIzzDseEBCCeDSN5SD16Tidvy8cwQ7ZY8Qj4=
github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20240930043709-0c23514e4c34 h1:Fwxpg98128gfWRbQ1A3PMP9o2IfYZk7RSEy8rcoCWDA=
github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20240930043709-0c23514e4c34/go.mod h1:/6UT4zZl6awVeXLeE7UGDWZvXj3IWkRsh3mqsn0DiAs=
github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20241025031121-4d5c88b00cf7 h1:HwAitQk+V59QdYUwwVVYHTujd4QZrebg2Cc2hmcjhAg=
github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20241025031121-4d5c88b00cf7/go.mod h1:/6UT4zZl6awVeXLeE7UGDWZvXj3IWkRsh3mqsn0DiAs=
github.com/milvus-io/pulsar-client-go v0.12.1 h1:O2JZp1tsYiO7C0MQ4hrUY/aJXnn2Gry6hpm7UodghmE=
Expand Down
Loading

0 comments on commit 89edbb9

Please sign in to comment.