From 06e40d5d82cc2197ec7bb7eda3be62e760bf66da Mon Sep 17 00:00:00 2001 From: congqixia Date: Tue, 30 Jul 2024 15:53:51 +0800 Subject: [PATCH] enhance: Enable linux code checker (#35084) See also #34483 --------- Signed-off-by: Congqi Xia --- cmd/milvus/mck.go | 36 ++++---- go.mod | 4 +- go.sum | 7 +- internal/datacoord/server.go | 2 +- internal/datacoord/services_test.go | 2 +- internal/datanode/data_sync_service_test.go | 2 +- internal/datanode/flow_graph_dd_node.go | 8 +- internal/datanode/flow_graph_dd_node_test.go | 8 +- internal/datanode/mock_test.go | 8 +- internal/datanode/stats_updater.go | 2 +- .../writebuffer/bf_write_buffer_test.go | 4 +- .../writebuffer/insert_buffer_test.go | 2 +- .../writebuffer/l0_write_buffer_test.go | 4 +- .../proxy/httpserver/handler_test.go | 8 +- .../proxy/httpserver/handler_v2_test.go | 8 +- .../proxy/httpserver/utils_test.go | 28 +++--- .../metastore/kv/rootcoord/kv_catalog_test.go | 2 +- internal/proxy/impl.go | 2 +- internal/proxy/impl_test.go | 20 ++--- internal/proxy/msg_pack.go | 5 +- internal/proxy/msg_pack_test.go | 4 +- internal/proxy/task_delete.go | 31 ++++--- internal/proxy/task_insert_test.go | 8 +- internal/proxy/task_scheduler_test.go | 2 +- internal/proxy/task_test.go | 10 +-- internal/proxy/task_upsert.go | 6 +- internal/proxy/task_upsert_test.go | 8 +- internal/proxy/util.go | 20 ++--- internal/proxy/util_test.go | 62 ++++++------- .../delegator/delegator_data_test.go | 6 +- internal/querynodev2/pipeline/mock_data.go | 4 +- internal/querynodev2/segments/mock_data.go | 16 ++-- internal/querynodev2/segments/segment.go | 6 +- internal/rootcoord/create_collection_task.go | 2 +- internal/rootcoord/garbage_collector.go | 4 +- internal/rootcoord/timeticksync.go | 16 ++-- internal/storage/data_codec_test.go | 4 +- internal/storage/data_sorter_test.go | 4 +- internal/storage/payload_test.go | 8 +- internal/storage/utils_test.go | 12 +-- internal/util/flowgraph/node_test.go | 19 ++-- internal/util/testutil/test_util.go | 7 +- pkg/go.mod | 4 +- pkg/go.sum | 7 +- pkg/mq/msgdispatcher/mock_test.go | 14 +-- pkg/mq/msgstream/factory_stream_test.go | 4 +- pkg/mq/msgstream/mq_msgstream_test.go | 16 ++-- pkg/mq/msgstream/mq_rocksmq_msgstream_test.go | 4 +- pkg/mq/msgstream/msg.go | 90 +++++++++---------- pkg/mq/msgstream/msg_for_collection.go | 30 +++---- pkg/mq/msgstream/msg_for_collection_test.go | 6 +- pkg/mq/msgstream/msg_for_database.go | 20 ++--- pkg/mq/msgstream/msg_for_database_test.go | 4 +- pkg/mq/msgstream/msg_for_index.go | 30 +++---- pkg/mq/msgstream/msg_for_index_test.go | 4 +- pkg/mq/msgstream/msg_for_partition.go | 20 ++--- pkg/mq/msgstream/msg_for_partition_test.go | 4 +- pkg/mq/msgstream/msg_test.go | 28 +++--- pkg/mq/msgstream/unmarshal_test.go | 2 +- pkg/util/funcutil/policy.go | 2 +- pkg/util/testutils/gen_data.go | 42 +++++++++ pkg/util/typeutil/schema_test.go | 2 +- 62 files changed, 401 insertions(+), 353 deletions(-) diff --git a/cmd/milvus/mck.go b/cmd/milvus/mck.go index b8534eb09c77b..6581356c252b6 100644 --- a/cmd/milvus/mck.go +++ b/cmd/milvus/mck.go @@ -528,40 +528,40 @@ func (c *mck) unmarshalTask(taskID int64, t string) (string, []int64, []int64, e switch header.Base.MsgType { case commonpb.MsgType_LoadCollection: - loadReq := querypb.LoadCollectionRequest{} - err = proto.Unmarshal([]byte(t), &loadReq) + loadReq := &querypb.LoadCollectionRequest{} + err = proto.Unmarshal([]byte(t), loadReq) if err != nil { return errReturn(taskID, "LoadCollectionRequest", err) } log.Info("LoadCollection", zap.String("detail", fmt.Sprintf("+%v", loadReq))) return "LoadCollection", emptyInt64(), emptyInt64(), nil case commonpb.MsgType_LoadPartitions: - loadReq := querypb.LoadPartitionsRequest{} - err = proto.Unmarshal([]byte(t), &loadReq) + loadReq := &querypb.LoadPartitionsRequest{} + err = proto.Unmarshal([]byte(t), loadReq) if err != nil { return errReturn(taskID, "LoadPartitionsRequest", err) } log.Info("LoadPartitions", zap.String("detail", fmt.Sprintf("+%v", loadReq))) return "LoadPartitions", loadReq.PartitionIDs, emptyInt64(), nil case commonpb.MsgType_ReleaseCollection: - loadReq := querypb.ReleaseCollectionRequest{} - err = proto.Unmarshal([]byte(t), &loadReq) + loadReq := &querypb.ReleaseCollectionRequest{} + err = proto.Unmarshal([]byte(t), loadReq) if err != nil { return errReturn(taskID, "ReleaseCollectionRequest", err) } log.Info("ReleaseCollection", zap.String("detail", fmt.Sprintf("+%v", loadReq))) return "ReleaseCollection", emptyInt64(), emptyInt64(), nil case commonpb.MsgType_ReleasePartitions: - loadReq := querypb.ReleasePartitionsRequest{} - err = proto.Unmarshal([]byte(t), &loadReq) + loadReq := &querypb.ReleasePartitionsRequest{} + err = proto.Unmarshal([]byte(t), loadReq) if err != nil { return errReturn(taskID, "ReleasePartitionsRequest", err) } log.Info("ReleasePartitions", zap.String("detail", fmt.Sprintf("+%v", loadReq))) return "ReleasePartitions", loadReq.PartitionIDs, emptyInt64(), nil case commonpb.MsgType_LoadSegments: - loadReq := querypb.LoadSegmentsRequest{} - err = proto.Unmarshal([]byte(t), &loadReq) + loadReq := &querypb.LoadSegmentsRequest{} + err = proto.Unmarshal([]byte(t), loadReq) if err != nil { return errReturn(taskID, "LoadSegmentsRequest", err) } @@ -584,16 +584,16 @@ func (c *mck) unmarshalTask(taskID int64, t string) (string, []int64, []int64, e log.Info("LoadSegments", zap.String("detail", fmt.Sprintf("+%v", loadReq))) return "LoadSegments", removeRepeatElement(partitionIDs), removeRepeatElement(segmentIDs), nil case commonpb.MsgType_ReleaseSegments: - loadReq := querypb.ReleaseSegmentsRequest{} - err = proto.Unmarshal([]byte(t), &loadReq) + loadReq := &querypb.ReleaseSegmentsRequest{} + err = proto.Unmarshal([]byte(t), loadReq) if err != nil { return errReturn(taskID, "ReleaseSegmentsRequest", err) } log.Info("ReleaseSegments", zap.String("detail", fmt.Sprintf("+%v", loadReq))) return "ReleaseSegments", loadReq.PartitionIDs, loadReq.SegmentIDs, nil case commonpb.MsgType_WatchDmChannels: - loadReq := querypb.WatchDmChannelsRequest{} - err = proto.Unmarshal([]byte(t), &loadReq) + loadReq := &querypb.WatchDmChannelsRequest{} + err = proto.Unmarshal([]byte(t), loadReq) if err != nil { return errReturn(taskID, "WatchDmChannelsRequest", err) } @@ -619,16 +619,16 @@ func (c *mck) unmarshalTask(taskID int64, t string) (string, []int64, []int64, e log.Warn("legacy WatchQueryChannels type found, ignore") return "WatchQueryChannels", emptyInt64(), emptyInt64(), nil case commonpb.MsgType_LoadBalanceSegments: - loadReq := querypb.LoadBalanceRequest{} - err = proto.Unmarshal([]byte(t), &loadReq) + loadReq := &querypb.LoadBalanceRequest{} + err = proto.Unmarshal([]byte(t), loadReq) if err != nil { return errReturn(taskID, "LoadBalanceRequest", err) } log.Info("LoadBalanceSegments", zap.String("detail", fmt.Sprintf("+%v", loadReq))) return "LoadBalanceSegments", emptyInt64(), loadReq.SealedSegmentIDs, nil case commonpb.MsgType_HandoffSegments: - handoffReq := querypb.HandoffSegmentsRequest{} - err = proto.Unmarshal([]byte(t), &handoffReq) + handoffReq := &querypb.HandoffSegmentsRequest{} + err = proto.Unmarshal([]byte(t), handoffReq) if err != nil { return errReturn(taskID, "HandoffSegmentsRequest", err) } diff --git a/go.mod b/go.mod index 5e12b9a50cdb8..95b2f7156c6e3 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/soheilhy/cmux v0.1.5 github.com/spf13/cast v1.3.1 github.com/spf13/viper v1.8.1 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.865 github.com/tikv/client-go/v2 v2.0.4 @@ -194,7 +194,7 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/stathat/consistent v1.0.0 // indirect github.com/streamnative/pulsarctl v0.5.0 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.2.0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect github.com/tidwall/match v1.1.1 // indirect diff --git a/go.sum b/go.sum index 1111b94c3f86b..23bb4ad3d9b18 100644 --- a/go.sum +++ b/go.sum @@ -834,8 +834,9 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -848,8 +849,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.865 h1:LcUqBlKC4j15LhT303yQDX/XxyHG4haEQqbHgZZA4SY= diff --git a/internal/datacoord/server.go b/internal/datacoord/server.go index 130ce1324e005..5d44736519081 100644 --- a/internal/datacoord/server.go +++ b/internal/datacoord/server.go @@ -779,7 +779,7 @@ func (s *Server) handleDataNodeTimetickMsgstream(ctx context.Context, ttMsgStrea checker.Check() } - if err := s.handleDataNodeTtMsg(ctx, &ttMsg.DataNodeTtMsg); err != nil { + if err := s.handleDataNodeTtMsg(ctx, ttMsg.DataNodeTtMsg); err != nil { log.Warn("failed to handle timetick message", zap.Error(err)) continue } diff --git a/internal/datacoord/services_test.go b/internal/datacoord/services_test.go index 60b753e48a282..5de663ca9eb69 100644 --- a/internal/datacoord/services_test.go +++ b/internal/datacoord/services_test.go @@ -77,7 +77,7 @@ func genMsg(msgType commonpb.MsgType, ch string, t Timestamp, sourceID int64) *m BaseMsg: msgstream.BaseMsg{ HashValues: []uint32{0}, }, - DataNodeTtMsg: msgpb.DataNodeTtMsg{ + DataNodeTtMsg: &msgpb.DataNodeTtMsg{ Base: &commonpb.MsgBase{ MsgType: msgType, Timestamp: t, diff --git a/internal/datanode/data_sync_service_test.go b/internal/datanode/data_sync_service_test.go index 55c9f58fac658..1225b7f73f999 100644 --- a/internal/datanode/data_sync_service_test.go +++ b/internal/datanode/data_sync_service_test.go @@ -528,7 +528,7 @@ func (s *DataSyncServiceSuite) TestStartStop() { EndTimestamp: tsoutil.GetCurrentTime(), HashValues: []uint32{0}, }, - TimeTickMsg: msgpb.TimeTickMsg{ + TimeTickMsg: &msgpb.TimeTickMsg{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_TimeTick, MsgID: UniqueID(0), diff --git a/internal/datanode/flow_graph_dd_node.go b/internal/datanode/flow_graph_dd_node.go index 6c0042dd378a9..da46d9390d747 100644 --- a/internal/datanode/flow_graph_dd_node.go +++ b/internal/datanode/flow_graph_dd_node.go @@ -180,11 +180,11 @@ func (ddn *ddNode) Operate(in []Msg) []Msg { continue } - rateCol.Add(metricsinfo.InsertConsumeThroughput, float64(proto.Size(&imsg.InsertRequest))) + rateCol.Add(metricsinfo.InsertConsumeThroughput, float64(proto.Size(imsg.InsertRequest))) metrics.DataNodeConsumeBytesCount. WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.InsertLabel). - Add(float64(proto.Size(&imsg.InsertRequest))) + Add(float64(proto.Size(imsg.InsertRequest))) metrics.DataNodeConsumeMsgCount. WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.InsertLabel, fmt.Sprint(ddn.collectionID)). @@ -214,11 +214,11 @@ func (ddn *ddNode) Operate(in []Msg) []Msg { } log.Debug("DDNode receive delete messages", zap.String("channel", ddn.vChannelName), zap.Int64("numRows", dmsg.NumRows)) - rateCol.Add(metricsinfo.DeleteConsumeThroughput, float64(proto.Size(&dmsg.DeleteRequest))) + rateCol.Add(metricsinfo.DeleteConsumeThroughput, float64(proto.Size(dmsg.DeleteRequest))) metrics.DataNodeConsumeBytesCount. WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.DeleteLabel). - Add(float64(proto.Size(&dmsg.DeleteRequest))) + Add(float64(proto.Size(dmsg.DeleteRequest))) metrics.DataNodeConsumeMsgCount. WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.DeleteLabel, fmt.Sprint(ddn.collectionID)). diff --git a/internal/datanode/flow_graph_dd_node_test.go b/internal/datanode/flow_graph_dd_node_test.go index 8cf42894d81f7..d1a8b3c00e999 100644 --- a/internal/datanode/flow_graph_dd_node_test.go +++ b/internal/datanode/flow_graph_dd_node_test.go @@ -146,7 +146,7 @@ func TestFlowGraph_DDNode_Operate(t *testing.T) { } var dropCollMsg msgstream.TsMsg = &msgstream.DropCollectionMsg{ - DropCollectionRequest: msgpb.DropCollectionRequest{ + DropCollectionRequest: &msgpb.DropCollectionRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_DropCollection}, CollectionID: test.msgCollID, }, @@ -199,7 +199,7 @@ func TestFlowGraph_DDNode_Operate(t *testing.T) { } var dropPartMsg msgstream.TsMsg = &msgstream.DropPartitionMsg{ - DropPartitionRequest: msgpb.DropPartitionRequest{ + DropPartitionRequest: &msgpb.DropPartitionRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_DropPartition}, CollectionID: test.msgCollID, PartitionID: test.msgPartID, @@ -261,7 +261,7 @@ func TestFlowGraph_DDNode_Operate(t *testing.T) { EndTimestamp: test.MsgEndTs, HashValues: []uint32{0}, }, - DeleteRequest: msgpb.DeleteRequest{ + DeleteRequest: &msgpb.DeleteRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_Delete}, ShardName: "by-dev-rootcoord-dml-mock-0", CollectionID: test.inMsgCollID, @@ -595,7 +595,7 @@ func getInsertMsg(segmentID UniqueID, ts Timestamp) *msgstream.InsertMsg { func getInsertMsgWithChannel(segmentID UniqueID, ts Timestamp, vChannelName string) *msgstream.InsertMsg { return &msgstream.InsertMsg{ BaseMsg: msgstream.BaseMsg{EndTimestamp: ts}, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_Insert}, SegmentID: segmentID, CollectionID: 1, diff --git a/internal/datanode/mock_test.go b/internal/datanode/mock_test.go index e945973971a71..b0c0821c588fa 100644 --- a/internal/datanode/mock_test.go +++ b/internal/datanode/mock_test.go @@ -751,7 +751,7 @@ func (df *DataFactory) GenMsgStreamInsertMsg(idx int, chanName string) *msgstrea BaseMsg: msgstream.BaseMsg{ HashValues: []uint32{uint32(idx)}, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -781,7 +781,7 @@ func (df *DataFactory) GenMsgStreamInsertMsgWithTs(idx int, chanName string, ts BeginTimestamp: ts, EndTimestamp: ts, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -831,7 +831,7 @@ func (df *DataFactory) GenMsgStreamDeleteMsg(pks []storage.PrimaryKey, chanName BaseMsg: msgstream.BaseMsg{ HashValues: []uint32{uint32(idx)}, }, - DeleteRequest: msgpb.DeleteRequest{ + DeleteRequest: &msgpb.DeleteRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Delete, MsgID: 0, @@ -857,7 +857,7 @@ func (df *DataFactory) GenMsgStreamDeleteMsgWithTs(idx int, pks []storage.Primar BeginTimestamp: ts, EndTimestamp: ts, }, - DeleteRequest: msgpb.DeleteRequest{ + DeleteRequest: &msgpb.DeleteRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Delete, MsgID: 1, diff --git a/internal/datanode/stats_updater.go b/internal/datanode/stats_updater.go index 2f25c88136bba..87be27044e02b 100644 --- a/internal/datanode/stats_updater.go +++ b/internal/datanode/stats_updater.go @@ -58,7 +58,7 @@ func (u *mqStatsUpdater) send(ts Timestamp, segmentIDs []int64) error { EndTimestamp: ts, HashValues: []uint32{0}, }, - DataNodeTtMsg: msgpb.DataNodeTtMsg{ + DataNodeTtMsg: &msgpb.DataNodeTtMsg{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_DataNodeTt), commonpbutil.WithTimeStamp(ts), diff --git a/internal/datanode/writebuffer/bf_write_buffer_test.go b/internal/datanode/writebuffer/bf_write_buffer_test.go index f4796930e8d48..7cfe976b2c0dd 100644 --- a/internal/datanode/writebuffer/bf_write_buffer_test.go +++ b/internal/datanode/writebuffer/bf_write_buffer_test.go @@ -132,7 +132,7 @@ func (s *BFWriteBufferSuite) composeInsertMsg(segmentID int64, rowCount int, dim } flatten := lo.Flatten(vectors) return tss, &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ SegmentID: segmentID, Version: msgpb.InsertDataVersion_ColumnBased, RowIDs: tss, @@ -183,7 +183,7 @@ func (s *BFWriteBufferSuite) composeInsertMsg(segmentID int64, rowCount int, dim func (s *BFWriteBufferSuite) composeDeleteMsg(pks []storage.PrimaryKey) *msgstream.DeleteMsg { delMsg := &msgstream.DeleteMsg{ - DeleteRequest: msgpb.DeleteRequest{ + DeleteRequest: &msgpb.DeleteRequest{ PrimaryKeys: storage.ParsePrimaryKeys2IDs(pks), Timestamps: lo.RepeatBy(len(pks), func(idx int) uint64 { return tsoutil.ComposeTSByTime(time.Now(), int64(idx+1)) }), }, diff --git a/internal/datanode/writebuffer/insert_buffer_test.go b/internal/datanode/writebuffer/insert_buffer_test.go index a55b286c88dce..bcb54aebc9f9f 100644 --- a/internal/datanode/writebuffer/insert_buffer_test.go +++ b/internal/datanode/writebuffer/insert_buffer_test.go @@ -53,7 +53,7 @@ func (s *InsertBufferSuite) composeInsertMsg(rowCount int, dim int) ([]int64, *m }) flatten := lo.Flatten(vectors) return tss, &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Version: msgpb.InsertDataVersion_ColumnBased, RowIDs: tss, Timestamps: lo.Map(tss, func(id int64, _ int) uint64 { return uint64(id) }), diff --git a/internal/datanode/writebuffer/l0_write_buffer_test.go b/internal/datanode/writebuffer/l0_write_buffer_test.go index 0cd644cf1dff8..5d79a25b40203 100644 --- a/internal/datanode/writebuffer/l0_write_buffer_test.go +++ b/internal/datanode/writebuffer/l0_write_buffer_test.go @@ -103,7 +103,7 @@ func (s *L0WriteBufferSuite) composeInsertMsg(segmentID int64, rowCount int, dim } } return tss, &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ SegmentID: segmentID, Version: msgpb.InsertDataVersion_ColumnBased, RowIDs: tss, @@ -154,7 +154,7 @@ func (s *L0WriteBufferSuite) composeInsertMsg(segmentID int64, rowCount int, dim func (s *L0WriteBufferSuite) composeDeleteMsg(pks []storage.PrimaryKey) *msgstream.DeleteMsg { delMsg := &msgstream.DeleteMsg{ - DeleteRequest: msgpb.DeleteRequest{ + DeleteRequest: &msgpb.DeleteRequest{ PrimaryKeys: storage.ParsePrimaryKeys2IDs(pks), Timestamps: lo.RepeatBy(len(pks), func(idx int) uint64 { return tsoutil.ComposeTSByTime(time.Now(), int64(idx)+1) }), }, diff --git a/internal/distributed/proxy/httpserver/handler_test.go b/internal/distributed/proxy/httpserver/handler_test.go index cdfff887ca9fc..4b69022229a7c 100644 --- a/internal/distributed/proxy/httpserver/handler_test.go +++ b/internal/distributed/proxy/httpserver/handler_test.go @@ -209,7 +209,7 @@ func (m *mockProxyComponent) Query(ctx context.Context, request *milvuspb.QueryR return &queryResult, nil } -var flushResult = milvuspb.FlushResponse{ +var flushResult = &milvuspb.FlushResponse{ DbName: "default", } @@ -217,10 +217,10 @@ func (m *mockProxyComponent) Flush(ctx context.Context, request *milvuspb.FlushR if len(request.CollectionNames) < 1 { return nil, errors.New("body parse err") } - return &flushResult, nil + return flushResult, nil } -var calcDistanceResult = milvuspb.CalcDistanceResults{ +var calcDistanceResult = &milvuspb.CalcDistanceResults{ Array: &milvuspb.CalcDistanceResults_IntDist{ IntDist: &schemapb.IntArray{ Data: []int32{1, 2, 3}, @@ -232,7 +232,7 @@ func (m *mockProxyComponent) CalcDistance(ctx context.Context, request *milvuspb if len(request.Params) < 1 { return nil, errors.New("body parse err") } - return &calcDistanceResult, nil + return calcDistanceResult, nil } func (m *mockProxyComponent) GetFlushState(ctx context.Context, request *milvuspb.GetFlushStateRequest) (*milvuspb.GetFlushStateResponse, error) { diff --git a/internal/distributed/proxy/httpserver/handler_v2_test.go b/internal/distributed/proxy/httpserver/handler_v2_test.go index 1a97ebe7ff008..deaa09b6365c5 100644 --- a/internal/distributed/proxy/httpserver/handler_v2_test.go +++ b/internal/distributed/proxy/httpserver/handler_v2_test.go @@ -1359,10 +1359,10 @@ func TestSearchV2(t *testing.T) { bfloat16VectorField.Name = "bfloat16Vector" sparseFloatVectorField := generateVectorFieldSchema(schemapb.DataType_SparseFloatVector) sparseFloatVectorField.Name = "sparseFloatVector" - collSchema.Fields = append(collSchema.Fields, &binaryVectorField) - collSchema.Fields = append(collSchema.Fields, &float16VectorField) - collSchema.Fields = append(collSchema.Fields, &bfloat16VectorField) - collSchema.Fields = append(collSchema.Fields, &sparseFloatVectorField) + collSchema.Fields = append(collSchema.Fields, binaryVectorField) + collSchema.Fields = append(collSchema.Fields, float16VectorField) + collSchema.Fields = append(collSchema.Fields, bfloat16VectorField) + collSchema.Fields = append(collSchema.Fields, sparseFloatVectorField) mp.EXPECT().DescribeCollection(mock.Anything, mock.Anything).Return(&milvuspb.DescribeCollectionResponse{ CollectionName: DefaultCollectionName, Schema: collSchema, diff --git a/internal/distributed/proxy/httpserver/utils_test.go b/internal/distributed/proxy/httpserver/utils_test.go index e01958b6574ef..897728f38de51 100644 --- a/internal/distributed/proxy/httpserver/utils_test.go +++ b/internal/distributed/proxy/httpserver/utils_test.go @@ -27,8 +27,8 @@ const ( var DefaultScores = []float32{0.01, 0.04, 0.09} -func generatePrimaryField(datatype schemapb.DataType) schemapb.FieldSchema { - return schemapb.FieldSchema{ +func generatePrimaryField(datatype schemapb.DataType) *schemapb.FieldSchema { + return &schemapb.FieldSchema{ FieldID: common.StartOfUserFieldID, Name: FieldBookID, IsPrimaryKey: true, @@ -69,12 +69,12 @@ func generateIDs(dataType schemapb.DataType, num int) *schemapb.IDs { return nil } -func generateVectorFieldSchema(dataType schemapb.DataType) schemapb.FieldSchema { +func generateVectorFieldSchema(dataType schemapb.DataType) *schemapb.FieldSchema { dim := "2" if dataType == schemapb.DataType_BinaryVector { dim = "8" } - return schemapb.FieldSchema{ + return &schemapb.FieldSchema{ FieldID: common.StartOfUserFieldID + int64(dataType), IsPrimaryKey: false, DataType: dataType, @@ -97,14 +97,14 @@ func generateCollectionSchema(primaryDataType schemapb.DataType) *schemapb.Colle Description: "", AutoID: false, Fields: []*schemapb.FieldSchema{ - &primaryField, { + primaryField, { FieldID: common.StartOfUserFieldID + 1, Name: FieldWordCount, IsPrimaryKey: false, Description: "", DataType: 5, AutoID: false, - }, &vectorField, + }, vectorField, }, EnableDynamicField: true, } @@ -465,14 +465,14 @@ func TestPrimaryField(t *testing.T) { primaryField := generatePrimaryField(schemapb.DataType_Int64) field, ok := getPrimaryField(coll) assert.Equal(t, true, ok) - assert.Equal(t, primaryField, *field) + assert.EqualExportedValues(t, primaryField, field) assert.Equal(t, "1,2,3", joinArray([]int64{1, 2, 3})) assert.Equal(t, "1,2,3", joinArray([]string{"1", "2", "3"})) jsonStr := "{\"id\": [1, 2, 3]}" idStr := gjson.Get(jsonStr, "id") - rangeStr, err := convertRange(&primaryField, idStr) + rangeStr, err := convertRange(primaryField, idStr) assert.Equal(t, nil, err) assert.Equal(t, "1,2,3", rangeStr) filter, err := checkGetPrimaryKey(coll, idStr) @@ -482,7 +482,7 @@ func TestPrimaryField(t *testing.T) { primaryField = generatePrimaryField(schemapb.DataType_VarChar) jsonStr = "{\"id\": [\"1\", \"2\", \"3\"]}" idStr = gjson.Get(jsonStr, "id") - rangeStr, err = convertRange(&primaryField, idStr) + rangeStr, err = convertRange(primaryField, idStr) assert.Equal(t, nil, err) assert.Equal(t, `"1","2","3"`, rangeStr) coll2 := generateCollectionSchema(schemapb.DataType_VarChar) @@ -524,7 +524,7 @@ func TestInsertWithoutVector(t *testing.T) { err, _ = checkAndSetData(body, &schemapb.CollectionSchema{ Name: DefaultCollectionName, Fields: []*schemapb.FieldSchema{ - &primaryField, &floatVectorField, + primaryField, floatVectorField, }, EnableDynamicField: true, }) @@ -533,7 +533,7 @@ func TestInsertWithoutVector(t *testing.T) { err, _ = checkAndSetData(body, &schemapb.CollectionSchema{ Name: DefaultCollectionName, Fields: []*schemapb.FieldSchema{ - &primaryField, &binaryVectorField, + primaryField, binaryVectorField, }, EnableDynamicField: true, }) @@ -542,7 +542,7 @@ func TestInsertWithoutVector(t *testing.T) { err, _ = checkAndSetData(body, &schemapb.CollectionSchema{ Name: DefaultCollectionName, Fields: []*schemapb.FieldSchema{ - &primaryField, &float16VectorField, + primaryField, float16VectorField, }, EnableDynamicField: true, }) @@ -551,7 +551,7 @@ func TestInsertWithoutVector(t *testing.T) { err, _ = checkAndSetData(body, &schemapb.CollectionSchema{ Name: DefaultCollectionName, Fields: []*schemapb.FieldSchema{ - &primaryField, &bfloat16VectorField, + primaryField, bfloat16VectorField, }, EnableDynamicField: true, }) @@ -1293,7 +1293,7 @@ func TestVector(t *testing.T) { Description: "", AutoID: false, Fields: []*schemapb.FieldSchema{ - &primaryField, &floatVectorField, &binaryVectorField, &float16VectorField, &bfloat16VectorField, &sparseFloatVectorField, + primaryField, floatVectorField, binaryVectorField, float16VectorField, bfloat16VectorField, sparseFloatVectorField, }, EnableDynamicField: true, } diff --git a/internal/metastore/kv/rootcoord/kv_catalog_test.go b/internal/metastore/kv/rootcoord/kv_catalog_test.go index d0678c5fc30d5..b56a5b7801d5d 100644 --- a/internal/metastore/kv/rootcoord/kv_catalog_test.go +++ b/internal/metastore/kv/rootcoord/kv_catalog_test.go @@ -1273,7 +1273,7 @@ func TestCatalog_DropCollection(t *testing.T) { } func getUserInfoMetaString(username string) string { - validInfo := internalpb.CredentialInfo{Username: username, EncryptedPassword: "pwd" + username} + validInfo := &internalpb.CredentialInfo{Username: username, EncryptedPassword: "pwd" + username} validBytes, _ := json.Marshal(validInfo) return string(validBytes) } diff --git a/internal/proxy/impl.go b/internal/proxy/impl.go index 72fe2f25fe3ec..6359d9c127bc1 100644 --- a/internal/proxy/impl.go +++ b/internal/proxy/impl.go @@ -2515,7 +2515,7 @@ func (node *Proxy) Insert(ctx context.Context, request *milvuspb.InsertRequest) BaseMsg: msgstream.BaseMsg{ HashValues: request.HashKeys, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Insert), commonpbutil.WithSourceID(paramtable.GetNodeID()), diff --git a/internal/proxy/impl_test.go b/internal/proxy/impl_test.go index 53f0ef9da172b..c9f7f2439ef3f 100644 --- a/internal/proxy/impl_test.go +++ b/internal/proxy/impl_test.go @@ -1421,14 +1421,13 @@ func TestProxy_ReplicateMessage(t *testing.T) { } { - timeTickResult := msgpb.TimeTickMsg{} timeTickMsg := &msgstream.TimeTickMsg{ BaseMsg: msgstream.BaseMsg{ BeginTimestamp: 1, EndTimestamp: 10, HashValues: []uint32{0}, }, - TimeTickMsg: timeTickResult, + TimeTickMsg: &msgpb.TimeTickMsg{}, } msgBytes, _ := timeTickMsg.Marshal(timeTickMsg) resp, err := node.ReplicateMessage(context.TODO(), &milvuspb.ReplicateMessageRequest{ @@ -1441,20 +1440,19 @@ func TestProxy_ReplicateMessage(t *testing.T) { } { - timeTickResult := msgpb.TimeTickMsg{ - Base: commonpbutil.NewMsgBase( - commonpbutil.WithMsgType(commonpb.MsgType(-1)), - commonpbutil.WithTimeStamp(10), - commonpbutil.WithSourceID(-1), - ), - } timeTickMsg := &msgstream.TimeTickMsg{ BaseMsg: msgstream.BaseMsg{ BeginTimestamp: 1, EndTimestamp: 10, HashValues: []uint32{0}, }, - TimeTickMsg: timeTickResult, + TimeTickMsg: &msgpb.TimeTickMsg{ + Base: commonpbutil.NewMsgBase( + commonpbutil.WithMsgType(commonpb.MsgType(-1)), + commonpbutil.WithTimeStamp(10), + commonpbutil.WithSourceID(-1), + ), + }, } msgBytes, _ := timeTickMsg.Marshal(timeTickMsg) resp, err := node.ReplicateMessage(context.TODO(), &milvuspb.ReplicateMessageRequest{ @@ -1512,7 +1510,7 @@ func TestProxy_ReplicateMessage(t *testing.T) { MsgID: []byte("mock message id 2"), }, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 10001, diff --git a/internal/proxy/msg_pack.go b/internal/proxy/msg_pack.go index 1177bd8adc1dd..426cc0a9d1f7b 100644 --- a/internal/proxy/msg_pack.go +++ b/internal/proxy/msg_pack.go @@ -50,7 +50,7 @@ func genInsertMsgsByPartition(ctx context.Context, // create empty insert message createInsertMsg := func(segmentID UniqueID, channelName string) *msgstream.InsertMsg { - insertReq := msgpb.InsertRequest{ + insertReq := &msgpb.InsertRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Insert), commonpbutil.WithTimeStamp(insertMsg.BeginTimestamp), // entity's timestamp was set to equal it.BeginTimestamp in preExecute() @@ -63,9 +63,8 @@ func genInsertMsgsByPartition(ctx context.Context, SegmentID: segmentID, ShardName: channelName, Version: msgpb.InsertDataVersion_ColumnBased, + FieldsData: make([]*schemapb.FieldData, len(insertMsg.GetFieldsData())), } - insertReq.FieldsData = make([]*schemapb.FieldData, len(insertMsg.GetFieldsData())) - msg := &msgstream.InsertMsg{ BaseMsg: msgstream.BaseMsg{ Ctx: ctx, diff --git a/internal/proxy/msg_pack_test.go b/internal/proxy/msg_pack_test.go index 731edbb7d7b97..29873f11b0821 100644 --- a/internal/proxy/msg_pack_test.go +++ b/internal/proxy/msg_pack_test.go @@ -91,7 +91,7 @@ func TestRepackInsertData(t *testing.T) { BaseMsg: msgstream.BaseMsg{ HashValues: hash, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -201,7 +201,7 @@ func TestRepackInsertDataWithPartitionKey(t *testing.T) { BaseMsg: msgstream.BaseMsg{ HashValues: hash, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, diff --git a/internal/proxy/task_delete.go b/internal/proxy/task_delete.go index 5a0fbdad5d6d3..4e2e202325467 100644 --- a/internal/proxy/task_delete.go +++ b/internal/proxy/task_delete.go @@ -202,26 +202,25 @@ func (dt *deleteTask) newDeleteMsg(ctx context.Context) (*msgstream.DeleteMsg, e if err != nil { return nil, errors.Wrap(err, "failed to allocate MsgID of delete") } - sliceRequest := msgpb.DeleteRequest{ - Base: commonpbutil.NewMsgBase( - commonpbutil.WithMsgType(commonpb.MsgType_Delete), - // msgid of delete msg must be set - // or it will be seen as duplicated msg in mq - commonpbutil.WithMsgID(msgid), - commonpbutil.WithTimeStamp(dt.ts), - commonpbutil.WithSourceID(paramtable.GetNodeID()), - ), - CollectionID: dt.collectionID, - PartitionID: dt.partitionID, - CollectionName: dt.req.GetCollectionName(), - PartitionName: dt.req.GetPartitionName(), - PrimaryKeys: &schemapb.IDs{}, - } return &msgstream.DeleteMsg{ BaseMsg: msgstream.BaseMsg{ Ctx: ctx, }, - DeleteRequest: sliceRequest, + DeleteRequest: &msgpb.DeleteRequest{ + Base: commonpbutil.NewMsgBase( + commonpbutil.WithMsgType(commonpb.MsgType_Delete), + // msgid of delete msg must be set + // or it will be seen as duplicated msg in mq + commonpbutil.WithMsgID(msgid), + commonpbutil.WithTimeStamp(dt.ts), + commonpbutil.WithSourceID(paramtable.GetNodeID()), + ), + CollectionID: dt.collectionID, + PartitionID: dt.partitionID, + CollectionName: dt.req.GetCollectionName(), + PartitionName: dt.req.GetPartitionName(), + PrimaryKeys: &schemapb.IDs{}, + }, }, nil } diff --git a/internal/proxy/task_insert_test.go b/internal/proxy/task_insert_test.go index 4fa7480d23ca8..a397b1ecdc330 100644 --- a/internal/proxy/task_insert_test.go +++ b/internal/proxy/task_insert_test.go @@ -22,7 +22,7 @@ func TestInsertTask_CheckAligned(t *testing.T) { // passed NumRows is less than 0 case1 := insertTask{ insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -52,7 +52,7 @@ func TestInsertTask_CheckAligned(t *testing.T) { dim := 128 case2 := insertTask{ insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -275,7 +275,7 @@ func TestInsertTask(t *testing.T) { it := insertTask{ ctx: context.Background(), insertMsg: &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ CollectionName: collectionName, }, }, @@ -297,7 +297,7 @@ func TestMaxInsertSize(t *testing.T) { it := insertTask{ ctx: context.Background(), insertMsg: &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ DbName: "hooooooo", CollectionName: "fooooo", }, diff --git a/internal/proxy/task_scheduler_test.go b/internal/proxy/task_scheduler_test.go index 771a5eb9f1d86..9b16150b4cf5e 100644 --- a/internal/proxy/task_scheduler_test.go +++ b/internal/proxy/task_scheduler_test.go @@ -582,7 +582,7 @@ func TestTaskScheduler_concurrentPushAndPop(t *testing.T) { it := &insertTask{ ctx: context.Background(), insertMsg: &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{}, CollectionName: collectionName, }, diff --git a/internal/proxy/task_test.go b/internal/proxy/task_test.go index c796d64f7c856..a85813c6330b8 100644 --- a/internal/proxy/task_test.go +++ b/internal/proxy/task_test.go @@ -1712,7 +1712,7 @@ func TestTask_Int64PrimaryKey(t *testing.T) { BaseMsg: msgstream.BaseMsg{ HashValues: hash, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -1906,7 +1906,7 @@ func TestTask_VarCharPrimaryKey(t *testing.T) { BaseMsg: msgstream.BaseMsg{ HashValues: hash, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -1962,7 +1962,7 @@ func TestTask_VarCharPrimaryKey(t *testing.T) { BaseMsg: msgstream.BaseMsg{ HashValues: hash, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -1979,7 +1979,7 @@ func TestTask_VarCharPrimaryKey(t *testing.T) { BaseMsg: msgstream.BaseMsg{ HashValues: hash, }, - DeleteRequest: msgpb.DeleteRequest{ + DeleteRequest: &msgpb.DeleteRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Delete, MsgID: 0, @@ -3322,7 +3322,7 @@ func TestPartitionKey(t *testing.T) { it := &insertTask{ insertMsg: &BaseInsertTask{ BaseMsg: msgstream.BaseMsg{}, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, diff --git a/internal/proxy/task_upsert.go b/internal/proxy/task_upsert.go index 550e95d7b5580..ed82be44bb286 100644 --- a/internal/proxy/task_upsert.go +++ b/internal/proxy/task_upsert.go @@ -324,7 +324,7 @@ func (it *upsertTask) PreExecute(ctx context.Context) error { it.upsertMsg = &msgstream.UpsertMsg{ InsertMsg: &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Insert), commonpbutil.WithSourceID(paramtable.GetNodeID()), @@ -338,7 +338,7 @@ func (it *upsertTask) PreExecute(ctx context.Context) error { }, }, DeleteMsg: &msgstream.DeleteMsg{ - DeleteRequest: msgpb.DeleteRequest{ + DeleteRequest: &msgpb.DeleteRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Delete), commonpbutil.WithSourceID(paramtable.GetNodeID()), @@ -466,7 +466,7 @@ func (it *upsertTask) deleteExecute(ctx context.Context, msgPack *msgstream.MsgP if err != nil { errors.Wrap(err, "failed to allocate MsgID for delete of upsert") } - sliceRequest := msgpb.DeleteRequest{ + sliceRequest := &msgpb.DeleteRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Delete), commonpbutil.WithTimeStamp(ts), diff --git a/internal/proxy/task_upsert_test.go b/internal/proxy/task_upsert_test.go index 032ee18b21ab0..a23162e0f8342 100644 --- a/internal/proxy/task_upsert_test.go +++ b/internal/proxy/task_upsert_test.go @@ -41,11 +41,11 @@ func TestUpsertTask_CheckAligned(t *testing.T) { }, upsertMsg: &msgstream.UpsertMsg{ InsertMsg: &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{}, + InsertRequest: &msgpb.InsertRequest{}, }, }, } - case1.upsertMsg.InsertMsg.InsertRequest = msgpb.InsertRequest{ + case1.upsertMsg.InsertMsg.InsertRequest = &msgpb.InsertRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Insert), ), @@ -102,7 +102,7 @@ func TestUpsertTask_CheckAligned(t *testing.T) { schema: schema, upsertMsg: &msgstream.UpsertMsg{ InsertMsg: &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{}, + InsertRequest: &msgpb.InsertRequest{}, }, }, } @@ -120,7 +120,7 @@ func TestUpsertTask_CheckAligned(t *testing.T) { newBinaryVectorFieldData("BinaryVector", numRows, dim), newScalarFieldData(varCharFieldSchema, "VarChar", numRows), } - case2.upsertMsg.InsertMsg.InsertRequest = msgpb.InsertRequest{ + case2.upsertMsg.InsertMsg.InsertRequest = &msgpb.InsertRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Insert), ), diff --git a/internal/proxy/util.go b/internal/proxy/util.go index 6f9c4fd403018..bb9f027bff6fb 100644 --- a/internal/proxy/util.go +++ b/internal/proxy/util.go @@ -1567,52 +1567,52 @@ func SendReplicateMessagePack(ctx context.Context, replicateMsgStream msgstream. case *milvuspb.CreateDatabaseRequest: tsMsg = &msgstream.CreateDatabaseMsg{ BaseMsg: getBaseMsg(ctx, ts), - CreateDatabaseRequest: *r, + CreateDatabaseRequest: r, } case *milvuspb.DropDatabaseRequest: tsMsg = &msgstream.DropDatabaseMsg{ BaseMsg: getBaseMsg(ctx, ts), - DropDatabaseRequest: *r, + DropDatabaseRequest: r, } case *milvuspb.FlushRequest: tsMsg = &msgstream.FlushMsg{ BaseMsg: getBaseMsg(ctx, ts), - FlushRequest: *r, + FlushRequest: r, } case *milvuspb.LoadCollectionRequest: tsMsg = &msgstream.LoadCollectionMsg{ BaseMsg: getBaseMsg(ctx, ts), - LoadCollectionRequest: *r, + LoadCollectionRequest: r, } case *milvuspb.ReleaseCollectionRequest: tsMsg = &msgstream.ReleaseCollectionMsg{ BaseMsg: getBaseMsg(ctx, ts), - ReleaseCollectionRequest: *r, + ReleaseCollectionRequest: r, } case *milvuspb.CreateIndexRequest: tsMsg = &msgstream.CreateIndexMsg{ BaseMsg: getBaseMsg(ctx, ts), - CreateIndexRequest: *r, + CreateIndexRequest: r, } case *milvuspb.DropIndexRequest: tsMsg = &msgstream.DropIndexMsg{ BaseMsg: getBaseMsg(ctx, ts), - DropIndexRequest: *r, + DropIndexRequest: r, } case *milvuspb.LoadPartitionsRequest: tsMsg = &msgstream.LoadPartitionsMsg{ BaseMsg: getBaseMsg(ctx, ts), - LoadPartitionsRequest: *r, + LoadPartitionsRequest: r, } case *milvuspb.ReleasePartitionsRequest: tsMsg = &msgstream.ReleasePartitionsMsg{ BaseMsg: getBaseMsg(ctx, ts), - ReleasePartitionsRequest: *r, + ReleasePartitionsRequest: r, } case *milvuspb.AlterIndexRequest: tsMsg = &msgstream.AlterIndexMsg{ BaseMsg: getBaseMsg(ctx, ts), - AlterIndexRequest: *r, + AlterIndexRequest: r, } default: log.Warn("unknown request", zap.Any("request", request)) diff --git a/internal/proxy/util_test.go b/internal/proxy/util_test.go index 08b6b07621435..a1d5d013962ef 100644 --- a/internal/proxy/util_test.go +++ b/internal/proxy/util_test.go @@ -1136,7 +1136,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { Fields: []*schemapb.FieldSchema{}, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1168,7 +1168,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1202,7 +1202,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1231,7 +1231,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1259,7 +1259,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1287,7 +1287,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1321,7 +1321,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1365,7 +1365,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1399,7 +1399,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1432,7 +1432,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1465,7 +1465,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1507,7 +1507,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1549,7 +1549,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1592,7 +1592,7 @@ func Test_InsertTaskcheckFieldsDataBySchema(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1628,7 +1628,7 @@ func Test_InsertTaskCheckPrimaryFieldData(t *testing.T) { Fields: []*schemapb.FieldSchema{}, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1663,7 +1663,7 @@ func Test_InsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1705,7 +1705,7 @@ func Test_InsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1747,7 +1747,7 @@ func Test_InsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1793,7 +1793,7 @@ func Test_UpsertTaskCheckPrimaryFieldData(t *testing.T) { Fields: []*schemapb.FieldSchema{}, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1830,7 +1830,7 @@ func Test_UpsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1873,7 +1873,7 @@ func Test_UpsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1918,7 +1918,7 @@ func Test_UpsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -1963,7 +1963,7 @@ func Test_UpsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -2009,7 +2009,7 @@ func Test_UpsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -2048,7 +2048,7 @@ func Test_UpsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -2089,7 +2089,7 @@ func Test_UpsertTaskCheckPrimaryFieldData(t *testing.T) { }, }, insertMsg: &BaseInsertTask{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, }, @@ -2219,7 +2219,7 @@ func Test_CheckDynamicFieldData(t *testing.T) { jsonFieldData := autoGenDynamicFieldData(jsonData) schema := newTestSchema() insertMsg := &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ CollectionName: "collectionName", FieldsData: []*schemapb.FieldData{jsonFieldData}, NumRows: 1, @@ -2248,7 +2248,7 @@ func Test_CheckDynamicFieldData(t *testing.T) { jsonFieldData := autoGenDynamicFieldData(jsonData) schema := newTestSchema() insertMsg := &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ CollectionName: "collectionName", FieldsData: []*schemapb.FieldData{jsonFieldData}, NumRows: 1, @@ -2276,7 +2276,7 @@ func Test_CheckDynamicFieldData(t *testing.T) { jsonFieldData := autoGenDynamicFieldData(jsonData) schema := newTestSchema() insertMsg := &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ CollectionName: "collectionName", FieldsData: []*schemapb.FieldData{jsonFieldData}, NumRows: 1, @@ -2292,7 +2292,7 @@ func Test_CheckDynamicFieldData(t *testing.T) { jsonFieldData := autoGenDynamicFieldData([][]byte{[]byte(data)}) schema := newTestSchema() insertMsg := &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ CollectionName: "collectionName", FieldsData: []*schemapb.FieldData{jsonFieldData}, NumRows: 1, @@ -2305,7 +2305,7 @@ func Test_CheckDynamicFieldData(t *testing.T) { t.Run("no json data", func(t *testing.T) { schema := newTestSchema() insertMsg := &msgstream.InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ CollectionName: "collectionName", FieldsData: []*schemapb.FieldData{}, NumRows: 1, diff --git a/internal/querynodev2/delegator/delegator_data_test.go b/internal/querynodev2/delegator/delegator_data_test.go index 7a96b3d919cd2..407de0effd9c0 100644 --- a/internal/querynodev2/delegator/delegator_data_test.go +++ b/internal/querynodev2/delegator/delegator_data_test.go @@ -1203,10 +1203,10 @@ func (s *DelegatorDataSuite) TestReadDeleteFromMsgstream() { datas := []*msgstream.MsgPack{ {EndTs: 10, EndPositions: []*msgpb.MsgPosition{{Timestamp: 10}}, Msgs: []msgstream.TsMsg{ - &msgstream.DeleteMsg{DeleteRequest: msgpb.DeleteRequest{Base: baseMsg, CollectionID: s.collectionID, PartitionID: 1, PrimaryKeys: storage.ParseInt64s2IDs(1), Timestamps: []uint64{1}}}, - &msgstream.DeleteMsg{DeleteRequest: msgpb.DeleteRequest{Base: baseMsg, CollectionID: s.collectionID, PartitionID: -1, PrimaryKeys: storage.ParseInt64s2IDs(2), Timestamps: []uint64{5}}}, + &msgstream.DeleteMsg{DeleteRequest: &msgpb.DeleteRequest{Base: baseMsg, CollectionID: s.collectionID, PartitionID: 1, PrimaryKeys: storage.ParseInt64s2IDs(1), Timestamps: []uint64{1}}}, + &msgstream.DeleteMsg{DeleteRequest: &msgpb.DeleteRequest{Base: baseMsg, CollectionID: s.collectionID, PartitionID: -1, PrimaryKeys: storage.ParseInt64s2IDs(2), Timestamps: []uint64{5}}}, // invalid msg because partition wrong - &msgstream.DeleteMsg{DeleteRequest: msgpb.DeleteRequest{Base: baseMsg, CollectionID: s.collectionID, PartitionID: 2, PrimaryKeys: storage.ParseInt64s2IDs(1), Timestamps: []uint64{10}}}, + &msgstream.DeleteMsg{DeleteRequest: &msgpb.DeleteRequest{Base: baseMsg, CollectionID: s.collectionID, PartitionID: 2, PrimaryKeys: storage.ParseInt64s2IDs(1), Timestamps: []uint64{10}}}, }}, } diff --git a/internal/querynodev2/pipeline/mock_data.go b/internal/querynodev2/pipeline/mock_data.go index a26b0d56603c7..f0090d9abc58c 100644 --- a/internal/querynodev2/pipeline/mock_data.go +++ b/internal/querynodev2/pipeline/mock_data.go @@ -53,7 +53,7 @@ func buildInsertMsg(collectionID int64, partitionID int64, segmentID int64, chan } func emptyDeleteMsg(collectionID int64, partitionID int64, channel string) *msgstream.DeleteMsg { - deleteReq := msgpb.DeleteRequest{ + deleteReq := &msgpb.DeleteRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Delete), commonpbutil.WithTimeStamp(0), @@ -70,7 +70,7 @@ func emptyDeleteMsg(collectionID int64, partitionID int64, channel string) *msgs } func emptyInsertMsg(collectionID int64, partitionID int64, segmentID int64, channel string) *msgstream.InsertMsg { - insertReq := msgpb.InsertRequest{ + insertReq := &msgpb.InsertRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Insert), commonpbutil.WithTimeStamp(0), diff --git a/internal/querynodev2/segments/mock_data.go b/internal/querynodev2/segments/mock_data.go index 03ac60b5b6c34..0b69cd1491762 100644 --- a/internal/querynodev2/segments/mock_data.go +++ b/internal/querynodev2/segments/mock_data.go @@ -586,9 +586,12 @@ func genInsertData(msgLength int, schema *schemapb.CollectionSchema) (*storage.I Dim: dim, } case schemapb.DataType_SparseFloatVector: - sparseData := testutils.GenerateSparseFloatVectors(msgLength) + contents, dim := testutils.GenerateSparseFloatVectorsData(msgLength) insertData.Data[f.FieldID] = &storage.SparseFloatVectorFieldData{ - SparseFloatArray: *sparseData, + SparseFloatArray: schemapb.SparseFloatArray{ + Contents: contents, + Dim: dim, + }, } default: err := errors.New("data type not supported") @@ -694,9 +697,12 @@ func GenAndSaveIndexV2(collectionID, partitionID, segmentID, buildID int64, case schemapb.DataType_BFloat16Vector: dataset = indexcgowrapper.GenBFloat16VecDataset(testutils.GenerateBFloat16Vectors(msgLength, defaultDim)) case schemapb.DataType_SparseFloatVector: - data := testutils.GenerateSparseFloatVectors(msgLength) + contents, dim := testutils.GenerateSparseFloatVectorsData(msgLength) dataset = indexcgowrapper.GenSparseFloatVecDataset(&storage.SparseFloatVectorFieldData{ - SparseFloatArray: *data, + SparseFloatArray: schemapb.SparseFloatArray{ + Contents: contents, + Dim: dim, + }, }) } @@ -1110,7 +1116,7 @@ func genInsertMsg(collection *Collection, partitionID, segment int64, numRows in return &msgstream.InsertMsg{ BaseMsg: genMsgStreamBaseMsg(), - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: genCommonMsgBase(commonpb.MsgType_Insert, 0), CollectionName: "test-collection", PartitionName: "test-partition", diff --git a/internal/querynodev2/segments/segment.go b/internal/querynodev2/segments/segment.go index 9eeea5e0ba7cb..880518592e2bb 100644 --- a/internal/querynodev2/segments/segment.go +++ b/internal/querynodev2/segments/segment.go @@ -239,7 +239,7 @@ func (s *baseSegment) SetNeedUpdatedVersion(version int64) { } type FieldInfo struct { - datapb.FieldBinlog + *datapb.FieldBinlog RowCount int64 } @@ -426,7 +426,7 @@ func (s *LocalSegment) initializeSegment() error { }) if !typeutil.IsVectorType(field.GetDataType()) && !s.HasRawData(fieldID) { s.fields.Insert(fieldID, &FieldInfo{ - FieldBinlog: *info.FieldBinlog, + FieldBinlog: info.FieldBinlog, RowCount: loadInfo.GetNumOfRows(), }) } @@ -434,7 +434,7 @@ func (s *LocalSegment) initializeSegment() error { for _, binlogs := range fieldBinlogs { s.fields.Insert(binlogs.FieldID, &FieldInfo{ - FieldBinlog: *binlogs, + FieldBinlog: binlogs, RowCount: loadInfo.GetNumOfRows(), }) } diff --git a/internal/rootcoord/create_collection_task.go b/internal/rootcoord/create_collection_task.go index 3d77c69eb366a..b597ffc33d5ae 100644 --- a/internal/rootcoord/create_collection_task.go +++ b/internal/rootcoord/create_collection_task.go @@ -412,7 +412,7 @@ func (t *createCollectionTask) genCreateCollectionMsg(ctx context.Context, ts ui EndTimestamp: ts, HashValues: []uint32{0}, }, - CreateCollectionRequest: msgpb.CreateCollectionRequest{ + CreateCollectionRequest: &msgpb.CreateCollectionRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_CreateCollection), commonpbutil.WithTimeStamp(ts), diff --git a/internal/rootcoord/garbage_collector.go b/internal/rootcoord/garbage_collector.go index 523191da2274f..6657ca959269a 100644 --- a/internal/rootcoord/garbage_collector.go +++ b/internal/rootcoord/garbage_collector.go @@ -176,7 +176,7 @@ func (c *bgGarbageCollector) notifyCollectionGc(ctx context.Context, coll *model EndTimestamp: ts, HashValues: []uint32{0}, }, - DropCollectionRequest: msgpb.DropCollectionRequest{ + DropCollectionRequest: &msgpb.DropCollectionRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_DropCollection), commonpbutil.WithTimeStamp(ts), @@ -208,7 +208,7 @@ func (c *bgGarbageCollector) notifyPartitionGc(ctx context.Context, pChannels [] EndTimestamp: ts, HashValues: []uint32{0}, }, - DropPartitionRequest: msgpb.DropPartitionRequest{ + DropPartitionRequest: &msgpb.DropPartitionRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_DropPartition), commonpbutil.WithTimeStamp(ts), diff --git a/internal/rootcoord/timeticksync.go b/internal/rootcoord/timeticksync.go index 4ad56bc05911b..fee0c59ca1f8d 100644 --- a/internal/rootcoord/timeticksync.go +++ b/internal/rootcoord/timeticksync.go @@ -327,20 +327,20 @@ func (t *timetickSync) sendTimeTickToChannel(chanNames []string, ts typeutil.Tim }() msgPack := msgstream.MsgPack{} - timeTickResult := msgpb.TimeTickMsg{ - Base: commonpbutil.NewMsgBase( - commonpbutil.WithMsgType(commonpb.MsgType_TimeTick), - commonpbutil.WithTimeStamp(ts), - commonpbutil.WithSourceID(t.sourceID), - ), - } + timeTickMsg := &msgstream.TimeTickMsg{ BaseMsg: msgstream.BaseMsg{ BeginTimestamp: ts, EndTimestamp: ts, HashValues: []uint32{0}, }, - TimeTickMsg: timeTickResult, + TimeTickMsg: &msgpb.TimeTickMsg{ + Base: commonpbutil.NewMsgBase( + commonpbutil.WithMsgType(commonpb.MsgType_TimeTick), + commonpbutil.WithTimeStamp(ts), + commonpbutil.WithSourceID(t.sourceID), + ), + }, } msgPack.Msgs = append(msgPack.Msgs, timeTickMsg) if err := t.dmlChannels.broadcast(chanNames, &msgPack); err != nil { diff --git a/internal/storage/data_codec_test.go b/internal/storage/data_codec_test.go index b074d045d337b..d1847a034b494 100644 --- a/internal/storage/data_codec_test.go +++ b/internal/storage/data_codec_test.go @@ -449,7 +449,7 @@ func TestInsertCodec(t *testing.T) { 0, 255, 0, 255, 0, 255, 0, 255, }, resultData.Data[BFloat16VectorField].(*BFloat16VectorFieldData).Data) - assert.Equal(t, schemapb.SparseFloatArray{ + assert.EqualExportedValues(t, &schemapb.SparseFloatArray{ // merged dim should be max of all dims Dim: 600, Contents: [][]byte{ @@ -460,7 +460,7 @@ func TestInsertCodec(t *testing.T) { typeutil.CreateSparseFloatRow([]uint32{10, 20, 30}, []float32{2.1, 2.2, 2.3}), typeutil.CreateSparseFloatRow([]uint32{100, 200, 599}, []float32{3.1, 3.2, 3.3}), }, - }, resultData.Data[SparseFloatVectorField].(*SparseFloatVectorFieldData).SparseFloatArray) + }, &resultData.Data[SparseFloatVectorField].(*SparseFloatVectorFieldData).SparseFloatArray) int32ArrayList := [][]int32{{1, 2, 3}, {4, 5, 6}, {3, 2, 1}, {6, 5, 4}} resultArrayList := [][]int32{} diff --git a/internal/storage/data_sorter_test.go b/internal/storage/data_sorter_test.go index e433967701ab7..1ca05285f9a50 100644 --- a/internal/storage/data_sorter_test.go +++ b/internal/storage/data_sorter_test.go @@ -270,14 +270,14 @@ func TestDataSorter(t *testing.T) { assert.Equal(t, []float32{16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, dataSorter.InsertData.Data[109].(*FloatVectorFieldData).Data) assert.Equal(t, []byte{16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, dataSorter.InsertData.Data[110].(*Float16VectorFieldData).Data) assert.Equal(t, []byte{16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, dataSorter.InsertData.Data[111].(*BFloat16VectorFieldData).Data) - assert.Equal(t, schemapb.SparseFloatArray{ + assert.EqualExportedValues(t, &schemapb.SparseFloatArray{ Dim: 600, Contents: [][]byte{ typeutil.CreateSparseFloatRow([]uint32{100, 200, 599}, []float32{3.1, 3.2, 3.3}), typeutil.CreateSparseFloatRow([]uint32{0, 1, 2}, []float32{1.1, 1.2, 1.3}), typeutil.CreateSparseFloatRow([]uint32{10, 20, 30}, []float32{2.1, 2.2, 2.3}), }, - }, dataSorter.InsertData.Data[112].(*SparseFloatVectorFieldData).SparseFloatArray) + }, &dataSorter.InsertData.Data[112].(*SparseFloatVectorFieldData).SparseFloatArray) } func TestDataSorter_Len(t *testing.T) { diff --git a/internal/storage/payload_test.go b/internal/storage/payload_test.go index b7109043dd238..5f72282da92e4 100644 --- a/internal/storage/payload_test.go +++ b/internal/storage/payload_test.go @@ -668,7 +668,7 @@ func TestPayload_ReaderAndWriter(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 600, dim) assert.Equal(t, 6, len(floatVecs.Contents)) - assert.Equal(t, schemapb.SparseFloatArray{ + assert.EqualExportedValues(t, &schemapb.SparseFloatArray{ // merged dim should be max of all dims Dim: 600, Contents: [][]byte{ @@ -679,7 +679,7 @@ func TestPayload_ReaderAndWriter(t *testing.T) { typeutil.CreateSparseFloatRow([]uint32{60, 80, 230}, []float32{2.1, 2.2, 2.3}), typeutil.CreateSparseFloatRow([]uint32{170, 300, 579}, []float32{3.1, 3.2, 3.3}), }, - }, floatVecs.SparseFloatArray) + }, &floatVecs.SparseFloatArray) ifloatVecs, dim, err := r.GetDataFromPayload() assert.NoError(t, err) @@ -721,10 +721,10 @@ func TestPayload_ReaderAndWriter(t *testing.T) { assert.NoError(t, err) assert.Equal(t, actualDim, dim) assert.Equal(t, 3, len(floatVecs.Contents)) - assert.Equal(t, schemapb.SparseFloatArray{ + assert.EqualExportedValues(t, &schemapb.SparseFloatArray{ Dim: int64(dim), Contents: rows, - }, floatVecs.SparseFloatArray) + }, &floatVecs.SparseFloatArray) ifloatVecs, dim, err := r.GetDataFromPayload() assert.NoError(t, err) diff --git a/internal/storage/utils_test.go b/internal/storage/utils_test.go index 401b3666f611f..ec9a4d6518dce 100644 --- a/internal/storage/utils_test.go +++ b/internal/storage/utils_test.go @@ -543,7 +543,7 @@ func genRowBasedInsertMsg(numRows, fVecDim, bVecDim, f16VecDim, bf16VecDim int) HashValues: nil, MsgPosition: nil, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -581,7 +581,7 @@ func genColumnBasedInsertMsg(schema *schemapb.CollectionSchema, numRows, fVecDim HashValues: nil, MsgPosition: nil, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -924,7 +924,7 @@ func TestRowBasedInsertMsgToInsertFloat16VectorDataError(t *testing.T) { HashValues: nil, MsgPosition: nil, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -967,7 +967,7 @@ func TestRowBasedInsertMsgToInsertBFloat16VectorDataError(t *testing.T) { HashValues: nil, MsgPosition: nil, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -1028,7 +1028,7 @@ func TestColumnBasedInsertMsgToInsertFloat16VectorDataError(t *testing.T) { HashValues: nil, MsgPosition: nil, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, @@ -1072,7 +1072,7 @@ func TestColumnBasedInsertMsgToInsertBFloat16VectorDataError(t *testing.T) { HashValues: nil, MsgPosition: nil, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 0, diff --git a/internal/util/flowgraph/node_test.go b/internal/util/flowgraph/node_test.go index 850fd183a267f..238e1f485f1a8 100644 --- a/internal/util/flowgraph/node_test.go +++ b/internal/util/flowgraph/node_test.go @@ -35,21 +35,20 @@ import ( func generateMsgPack() msgstream.MsgPack { msgPack := msgstream.MsgPack{} - timeTickResult := msgpb.TimeTickMsg{ - Base: &commonpb.MsgBase{ - MsgType: commonpb.MsgType_TimeTick, - MsgID: 0, - Timestamp: math.MaxUint64, - SourceID: 0, - }, - } timeTickMsg := &msgstream.TimeTickMsg{ BaseMsg: msgstream.BaseMsg{ BeginTimestamp: uint64(time.Now().Unix()), EndTimestamp: uint64(time.Now().Unix() + 1), HashValues: []uint32{0}, }, - TimeTickMsg: timeTickResult, + TimeTickMsg: &msgpb.TimeTickMsg{ + Base: &commonpb.MsgBase{ + MsgType: commonpb.MsgType_TimeTick, + MsgID: 0, + Timestamp: math.MaxUint64, + SourceID: 0, + }, + }, } msgPack.Msgs = append(msgPack.Msgs, timeTickMsg) @@ -64,7 +63,7 @@ func generateInsertMsgPack() msgstream.MsgPack { EndTimestamp: uint64(time.Now().Unix() + 1), HashValues: []uint32{0}, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_Insert}, }, } diff --git a/internal/util/testutil/test_util.go b/internal/util/testutil/test_util.go index 4548f0e77ff31..698530b361b64 100644 --- a/internal/util/testutil/test_util.go +++ b/internal/util/testutil/test_util.go @@ -177,9 +177,12 @@ func CreateInsertData(schema *schemapb.CollectionSchema, rows int) (*storage.Ins Dim: int(dim), } case schemapb.DataType_SparseFloatVector: - sparseFloatVecData := testutils.GenerateSparseFloatVectors(rows) + data, dim := testutils.GenerateSparseFloatVectorsData(rows) insertData.Data[f.FieldID] = &storage.SparseFloatVectorFieldData{ - SparseFloatArray: *sparseFloatVecData, + SparseFloatArray: schemapb.SparseFloatArray{ + Contents: data, + Dim: dim, + }, } case schemapb.DataType_String, schemapb.DataType_VarChar: insertData.Data[f.FieldID] = &storage.StringFieldData{ diff --git a/pkg/go.mod b/pkg/go.mod index 8f6ee1adf2ddd..f9837c915be1c 100644 --- a/pkg/go.mod +++ b/pkg/go.mod @@ -26,7 +26,7 @@ require ( github.com/spf13/cast v1.3.1 github.com/spf13/viper v1.8.1 github.com/streamnative/pulsarctl v0.5.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c github.com/tikv/client-go/v2 v2.0.4 github.com/uber/jaeger-client-go v2.30.0+incompatible @@ -145,7 +145,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stathat/consistent v1.0.0 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.2.0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect github.com/tikv/pd/client v0.0.0-20221031025758-80f0d8ca4d07 // indirect diff --git a/pkg/go.sum b/pkg/go.sum index fe505616a4301..2764bdeb34ec9 100644 --- a/pkg/go.sum +++ b/pkg/go.sum @@ -707,8 +707,9 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -719,8 +720,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= diff --git a/pkg/mq/msgdispatcher/mock_test.go b/pkg/mq/msgdispatcher/mock_test.go index 38b9cc21cc65a..a1be264befe77 100644 --- a/pkg/mq/msgdispatcher/mock_test.go +++ b/pkg/mq/msgdispatcher/mock_test.go @@ -110,7 +110,7 @@ func genInsertMsg(numRows int, vchannel string, msgID typeutil.UniqueID) *msgstr } return &msgstream.InsertMsg{ BaseMsg: msgstream.BaseMsg{HashValues: hashValues}, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_Insert, MsgID: msgID}, ShardName: vchannel, Timestamps: genTimestamps(numRows), @@ -132,7 +132,7 @@ func genInsertMsg(numRows int, vchannel string, msgID typeutil.UniqueID) *msgstr func genDeleteMsg(numRows int, vchannel string, msgID typeutil.UniqueID) *msgstream.DeleteMsg { return &msgstream.DeleteMsg{ BaseMsg: msgstream.BaseMsg{HashValues: make([]uint32, numRows)}, - DeleteRequest: msgpb.DeleteRequest{ + DeleteRequest: &msgpb.DeleteRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_Delete, MsgID: msgID}, ShardName: vchannel, PrimaryKeys: &schemapb.IDs{ @@ -153,28 +153,28 @@ func genDDLMsg(msgType commonpb.MsgType) msgstream.TsMsg { case commonpb.MsgType_CreateCollection: return &msgstream.CreateCollectionMsg{ BaseMsg: msgstream.BaseMsg{HashValues: []uint32{0}}, - CreateCollectionRequest: msgpb.CreateCollectionRequest{ + CreateCollectionRequest: &msgpb.CreateCollectionRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreateCollection}, }, } case commonpb.MsgType_DropCollection: return &msgstream.DropCollectionMsg{ BaseMsg: msgstream.BaseMsg{HashValues: []uint32{0}}, - DropCollectionRequest: msgpb.DropCollectionRequest{ + DropCollectionRequest: &msgpb.DropCollectionRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_DropCollection}, }, } case commonpb.MsgType_CreatePartition: return &msgstream.CreatePartitionMsg{ BaseMsg: msgstream.BaseMsg{HashValues: []uint32{0}}, - CreatePartitionRequest: msgpb.CreatePartitionRequest{ + CreatePartitionRequest: &msgpb.CreatePartitionRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreatePartition}, }, } case commonpb.MsgType_DropPartition: return &msgstream.DropPartitionMsg{ BaseMsg: msgstream.BaseMsg{HashValues: []uint32{0}}, - DropPartitionRequest: msgpb.DropPartitionRequest{ + DropPartitionRequest: &msgpb.DropPartitionRequest{ Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_DropPartition}, }, } @@ -185,7 +185,7 @@ func genDDLMsg(msgType commonpb.MsgType) msgstream.TsMsg { func genTimeTickMsg(ts typeutil.Timestamp) *msgstream.TimeTickMsg { return &msgstream.TimeTickMsg{ BaseMsg: msgstream.BaseMsg{HashValues: []uint32{0}}, - TimeTickMsg: msgpb.TimeTickMsg{ + TimeTickMsg: &msgpb.TimeTickMsg{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_TimeTick, Timestamp: ts, diff --git a/pkg/mq/msgstream/factory_stream_test.go b/pkg/mq/msgstream/factory_stream_test.go index 0cf5fcbd7acdb..38803e9723cbe 100644 --- a/pkg/mq/msgstream/factory_stream_test.go +++ b/pkg/mq/msgstream/factory_stream_test.go @@ -90,7 +90,7 @@ func testInsertWithRepack(t *testing.T, f []Factory) { } func testInsertRepackFuncWithDifferentClient(t *testing.T, f []Factory) { - insertRequest := msgpb.InsertRequest{ + insertRequest := &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 1, @@ -119,7 +119,7 @@ func testInsertRepackFuncWithDifferentClient(t *testing.T, f []Factory) { } func testDeleteRepackFuncWithDifferentClient(t *testing.T, f []Factory) { - deleteRequest := msgpb.DeleteRequest{ + deleteRequest := &msgpb.DeleteRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Delete, MsgID: 1, diff --git a/pkg/mq/msgstream/mq_msgstream_test.go b/pkg/mq/msgstream/mq_msgstream_test.go index 3bf6e6a0b3548..1fbefef9e160f 100644 --- a/pkg/mq/msgstream/mq_msgstream_test.go +++ b/pkg/mq/msgstream/mq_msgstream_test.go @@ -245,7 +245,7 @@ func TestStream_PulsarMsgStream_InsertRepackFunc(t *testing.T) { consumerChannels := []string{c1, c2} consumerSubName := funcutil.RandomString(8) - insertRequest := msgpb.InsertRequest{ + insertRequest := &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 1, @@ -299,7 +299,7 @@ func TestStream_PulsarMsgStream_DeleteRepackFunc(t *testing.T) { consumerChannels := []string{c1, c2} consumerSubName := funcutil.RandomString(8) - deleteRequest := msgpb.DeleteRequest{ + deleteRequest := &msgpb.DeleteRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Delete, MsgID: 1, @@ -1251,7 +1251,7 @@ func getTsMsg(msgType MsgType, reqID UniqueID) TsMsg { time := uint64(reqID) switch msgType { case commonpb.MsgType_Insert: - insertRequest := msgpb.InsertRequest{ + insertRequest := &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: reqID, @@ -1276,7 +1276,7 @@ func getTsMsg(msgType MsgType, reqID UniqueID) TsMsg { } return insertMsg case commonpb.MsgType_Delete: - deleteRequest := msgpb.DeleteRequest{ + deleteRequest := &msgpb.DeleteRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Delete, MsgID: reqID, @@ -1299,7 +1299,7 @@ func getTsMsg(msgType MsgType, reqID UniqueID) TsMsg { } return deleteMsg case commonpb.MsgType_CreateCollection: - createCollectionRequest := msgpb.CreateCollectionRequest{ + createCollectionRequest := &msgpb.CreateCollectionRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_CreateCollection, MsgID: reqID, @@ -1326,7 +1326,7 @@ func getTsMsg(msgType MsgType, reqID UniqueID) TsMsg { } return createCollectionMsg case commonpb.MsgType_TimeTick: - timeTickResult := msgpb.TimeTickMsg{ + timeTickResult := &msgpb.TimeTickMsg{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_TimeTick, MsgID: reqID, @@ -1350,7 +1350,7 @@ func getTsMsg(msgType MsgType, reqID UniqueID) TsMsg { func getTimeTickMsg(reqID UniqueID) TsMsg { hashValue := uint32(reqID) time := uint64(reqID) - timeTickResult := msgpb.TimeTickMsg{ + timeTickResult := &msgpb.TimeTickMsg{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_TimeTick, MsgID: reqID, @@ -1399,7 +1399,7 @@ func getInsertMsgUniqueID(ts UniqueID) TsMsg { hashValue := uint32(ts) time := uint64(ts) - insertRequest := msgpb.InsertRequest{ + insertRequest := &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: idCounter.Inc(), diff --git a/pkg/mq/msgstream/mq_rocksmq_msgstream_test.go b/pkg/mq/msgstream/mq_rocksmq_msgstream_test.go index b3de2b1895bcc..73f3f069b491a 100644 --- a/pkg/mq/msgstream/mq_rocksmq_msgstream_test.go +++ b/pkg/mq/msgstream/mq_rocksmq_msgstream_test.go @@ -84,7 +84,7 @@ func TestMqMsgStream_ComputeProduceChannelIndexes(t *testing.T) { // not called AsProducer yet insertMsg := &InsertMsg{ BaseMsg: generateBaseMsg(), - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 1, @@ -137,7 +137,7 @@ func TestMqMsgStream_Produce(t *testing.T) { // Produce before called AsProducer insertMsg := &InsertMsg{ BaseMsg: generateBaseMsg(), - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 1, diff --git a/pkg/mq/msgstream/msg.go b/pkg/mq/msgstream/msg.go index 6ae92c33da7cd..179fe44d11576 100644 --- a/pkg/mq/msgstream/msg.go +++ b/pkg/mq/msgstream/msg.go @@ -125,7 +125,7 @@ func convertToByteArray(input interface{}) ([]byte, error) { // InsertMsg is a message pack that contains insert request type InsertMsg struct { BaseMsg - msgpb.InsertRequest + *msgpb.InsertRequest } // interface implementation validation @@ -154,7 +154,7 @@ func (it *InsertMsg) SourceID() int64 { // Marshal is used to serialize a message pack to byte array func (it *InsertMsg) Marshal(input TsMsg) (MarshalType, error) { insertMsg := input.(*InsertMsg) - insertRequest := &insertMsg.InsertRequest + insertRequest := insertMsg.InsertRequest mb, err := proto.Marshal(insertRequest) if err != nil { return nil, err @@ -164,12 +164,12 @@ func (it *InsertMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserialize a message pack from byte array func (it *InsertMsg) Unmarshal(input MarshalType) (TsMsg, error) { - insertRequest := msgpb.InsertRequest{} + insertRequest := &msgpb.InsertRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &insertRequest) + err = proto.Unmarshal(in, insertRequest) if err != nil { return nil, err } @@ -234,8 +234,8 @@ func (it *InsertMsg) CheckAligned() error { return nil } -func (it *InsertMsg) rowBasedIndexRequest(index int) msgpb.InsertRequest { - return msgpb.InsertRequest{ +func (it *InsertMsg) rowBasedIndexRequest(index int) *msgpb.InsertRequest { + return &msgpb.InsertRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Insert), commonpbutil.WithMsgID(it.Base.MsgID), @@ -256,11 +256,11 @@ func (it *InsertMsg) rowBasedIndexRequest(index int) msgpb.InsertRequest { } } -func (it *InsertMsg) columnBasedIndexRequest(index int) msgpb.InsertRequest { +func (it *InsertMsg) columnBasedIndexRequest(index int) *msgpb.InsertRequest { colNum := len(it.GetFieldsData()) fieldsData := make([]*schemapb.FieldData, colNum) typeutil.AppendFieldData(fieldsData, it.GetFieldsData(), int64(index)) - return msgpb.InsertRequest{ + return &msgpb.InsertRequest{ Base: commonpbutil.NewMsgBase( commonpbutil.WithMsgType(commonpb.MsgType_Insert), commonpbutil.WithMsgID(it.Base.MsgID), @@ -282,7 +282,7 @@ func (it *InsertMsg) columnBasedIndexRequest(index int) msgpb.InsertRequest { } } -func (it *InsertMsg) IndexRequest(index int) msgpb.InsertRequest { +func (it *InsertMsg) IndexRequest(index int) *msgpb.InsertRequest { if it.IsRowBased() { return it.rowBasedIndexRequest(index) } @@ -303,7 +303,7 @@ func (it *InsertMsg) IndexMsg(index int) *InsertMsg { } func (it *InsertMsg) Size() int { - return proto.Size(&it.InsertRequest) + return proto.Size(it.InsertRequest) } /////////////////////////////////////////Delete////////////////////////////////////////// @@ -311,7 +311,7 @@ func (it *InsertMsg) Size() int { // DeleteMsg is a message pack that contains delete request type DeleteMsg struct { BaseMsg - msgpb.DeleteRequest + *msgpb.DeleteRequest } // interface implementation validation @@ -340,7 +340,7 @@ func (dt *DeleteMsg) SourceID() int64 { // Marshal is used to serializing a message pack to byte array func (dt *DeleteMsg) Marshal(input TsMsg) (MarshalType, error) { deleteMsg := input.(*DeleteMsg) - deleteRequest := &deleteMsg.DeleteRequest + deleteRequest := deleteMsg.DeleteRequest mb, err := proto.Marshal(deleteRequest) if err != nil { return nil, err @@ -351,12 +351,12 @@ func (dt *DeleteMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserializing a message pack from byte array func (dt *DeleteMsg) Unmarshal(input MarshalType) (TsMsg, error) { - deleteRequest := msgpb.DeleteRequest{} + deleteRequest := &msgpb.DeleteRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &deleteRequest) + err = proto.Unmarshal(in, deleteRequest) if err != nil { return nil, err } @@ -406,7 +406,7 @@ func (dt *DeleteMsg) CheckAligned() error { } func (dt *DeleteMsg) Size() int { - return proto.Size(&dt.DeleteRequest) + return proto.Size(dt.DeleteRequest) } // ///////////////////////////////////////Upsert////////////////////////////////////////// @@ -420,7 +420,7 @@ type UpsertMsg struct { // TimeTickMsg is a message pack that contains time tick only type TimeTickMsg struct { BaseMsg - msgpb.TimeTickMsg + *msgpb.TimeTickMsg } // interface implementation validation @@ -449,7 +449,7 @@ func (tst *TimeTickMsg) SourceID() int64 { // Marshal is used to serializing a message pack to byte array func (tst *TimeTickMsg) Marshal(input TsMsg) (MarshalType, error) { timeTickTask := input.(*TimeTickMsg) - timeTick := &timeTickTask.TimeTickMsg + timeTick := timeTickTask.TimeTickMsg mb, err := proto.Marshal(timeTick) if err != nil { return nil, err @@ -459,12 +459,12 @@ func (tst *TimeTickMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserializing a message pack from byte array func (tst *TimeTickMsg) Unmarshal(input MarshalType) (TsMsg, error) { - timeTickMsg := msgpb.TimeTickMsg{} + timeTickMsg := &msgpb.TimeTickMsg{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &timeTickMsg) + err = proto.Unmarshal(in, timeTickMsg) if err != nil { return nil, err } @@ -476,7 +476,7 @@ func (tst *TimeTickMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (tst *TimeTickMsg) Size() int { - return proto.Size(&tst.TimeTickMsg) + return proto.Size(tst.TimeTickMsg) } /////////////////////////////////////////CreateCollection////////////////////////////////////////// @@ -484,7 +484,7 @@ func (tst *TimeTickMsg) Size() int { // CreateCollectionMsg is a message pack that contains create collection request type CreateCollectionMsg struct { BaseMsg - msgpb.CreateCollectionRequest + *msgpb.CreateCollectionRequest } // interface implementation validation @@ -513,7 +513,7 @@ func (cc *CreateCollectionMsg) SourceID() int64 { // Marshal is used to serializing a message pack to byte array func (cc *CreateCollectionMsg) Marshal(input TsMsg) (MarshalType, error) { createCollectionMsg := input.(*CreateCollectionMsg) - createCollectionRequest := &createCollectionMsg.CreateCollectionRequest + createCollectionRequest := createCollectionMsg.CreateCollectionRequest mb, err := proto.Marshal(createCollectionRequest) if err != nil { return nil, err @@ -523,12 +523,12 @@ func (cc *CreateCollectionMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserializing a message pack from byte array func (cc *CreateCollectionMsg) Unmarshal(input MarshalType) (TsMsg, error) { - createCollectionRequest := msgpb.CreateCollectionRequest{} + createCollectionRequest := &msgpb.CreateCollectionRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &createCollectionRequest) + err = proto.Unmarshal(in, createCollectionRequest) if err != nil { return nil, err } @@ -540,7 +540,7 @@ func (cc *CreateCollectionMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (cc *CreateCollectionMsg) Size() int { - return proto.Size(&cc.CreateCollectionRequest) + return proto.Size(cc.CreateCollectionRequest) } /////////////////////////////////////////DropCollection////////////////////////////////////////// @@ -548,7 +548,7 @@ func (cc *CreateCollectionMsg) Size() int { // DropCollectionMsg is a message pack that contains drop collection request type DropCollectionMsg struct { BaseMsg - msgpb.DropCollectionRequest + *msgpb.DropCollectionRequest } // interface implementation validation @@ -577,7 +577,7 @@ func (dc *DropCollectionMsg) SourceID() int64 { // Marshal is used to serializing a message pack to byte array func (dc *DropCollectionMsg) Marshal(input TsMsg) (MarshalType, error) { dropCollectionMsg := input.(*DropCollectionMsg) - dropCollectionRequest := &dropCollectionMsg.DropCollectionRequest + dropCollectionRequest := dropCollectionMsg.DropCollectionRequest mb, err := proto.Marshal(dropCollectionRequest) if err != nil { return nil, err @@ -587,12 +587,12 @@ func (dc *DropCollectionMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserializing a message pack from byte array func (dc *DropCollectionMsg) Unmarshal(input MarshalType) (TsMsg, error) { - dropCollectionRequest := msgpb.DropCollectionRequest{} + dropCollectionRequest := &msgpb.DropCollectionRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &dropCollectionRequest) + err = proto.Unmarshal(in, dropCollectionRequest) if err != nil { return nil, err } @@ -604,7 +604,7 @@ func (dc *DropCollectionMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (dc *DropCollectionMsg) Size() int { - return proto.Size(&dc.DropCollectionRequest) + return proto.Size(dc.DropCollectionRequest) } /////////////////////////////////////////CreatePartition////////////////////////////////////////// @@ -612,7 +612,7 @@ func (dc *DropCollectionMsg) Size() int { // CreatePartitionMsg is a message pack that contains create partition request type CreatePartitionMsg struct { BaseMsg - msgpb.CreatePartitionRequest + *msgpb.CreatePartitionRequest } // interface implementation validation @@ -641,7 +641,7 @@ func (cp *CreatePartitionMsg) SourceID() int64 { // Marshal is used to serializing a message pack to byte array func (cp *CreatePartitionMsg) Marshal(input TsMsg) (MarshalType, error) { createPartitionMsg := input.(*CreatePartitionMsg) - createPartitionRequest := &createPartitionMsg.CreatePartitionRequest + createPartitionRequest := createPartitionMsg.CreatePartitionRequest mb, err := proto.Marshal(createPartitionRequest) if err != nil { return nil, err @@ -651,12 +651,12 @@ func (cp *CreatePartitionMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserializing a message pack from byte array func (cp *CreatePartitionMsg) Unmarshal(input MarshalType) (TsMsg, error) { - createPartitionRequest := msgpb.CreatePartitionRequest{} + createPartitionRequest := &msgpb.CreatePartitionRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &createPartitionRequest) + err = proto.Unmarshal(in, createPartitionRequest) if err != nil { return nil, err } @@ -668,7 +668,7 @@ func (cp *CreatePartitionMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (cp *CreatePartitionMsg) Size() int { - return proto.Size(&cp.CreatePartitionRequest) + return proto.Size(cp.CreatePartitionRequest) } /////////////////////////////////////////DropPartition////////////////////////////////////////// @@ -676,7 +676,7 @@ func (cp *CreatePartitionMsg) Size() int { // DropPartitionMsg is a message pack that contains drop partition request type DropPartitionMsg struct { BaseMsg - msgpb.DropPartitionRequest + *msgpb.DropPartitionRequest } // interface implementation validation @@ -705,7 +705,7 @@ func (dp *DropPartitionMsg) SourceID() int64 { // Marshal is used to serializing a message pack to byte array func (dp *DropPartitionMsg) Marshal(input TsMsg) (MarshalType, error) { dropPartitionMsg := input.(*DropPartitionMsg) - dropPartitionRequest := &dropPartitionMsg.DropPartitionRequest + dropPartitionRequest := dropPartitionMsg.DropPartitionRequest mb, err := proto.Marshal(dropPartitionRequest) if err != nil { return nil, err @@ -715,12 +715,12 @@ func (dp *DropPartitionMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserializing a message pack from byte array func (dp *DropPartitionMsg) Unmarshal(input MarshalType) (TsMsg, error) { - dropPartitionRequest := msgpb.DropPartitionRequest{} + dropPartitionRequest := &msgpb.DropPartitionRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &dropPartitionRequest) + err = proto.Unmarshal(in, dropPartitionRequest) if err != nil { return nil, err } @@ -732,7 +732,7 @@ func (dp *DropPartitionMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (dp *DropPartitionMsg) Size() int { - return proto.Size(&dp.DropPartitionRequest) + return proto.Size(dp.DropPartitionRequest) } /////////////////////////////////////////DataNodeTtMsg////////////////////////////////////////// @@ -740,7 +740,7 @@ func (dp *DropPartitionMsg) Size() int { // DataNodeTtMsg is a message pack that contains datanode time tick type DataNodeTtMsg struct { BaseMsg - msgpb.DataNodeTtMsg + *msgpb.DataNodeTtMsg } // interface implementation validation @@ -769,7 +769,7 @@ func (m *DataNodeTtMsg) SourceID() int64 { // Marshal is used to serializing a message pack to byte array func (m *DataNodeTtMsg) Marshal(input TsMsg) (MarshalType, error) { msg := input.(*DataNodeTtMsg) - t, err := proto.Marshal(&msg.DataNodeTtMsg) + t, err := proto.Marshal(msg.DataNodeTtMsg) if err != nil { return nil, err } @@ -778,12 +778,12 @@ func (m *DataNodeTtMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserializing a message pack from byte array func (m *DataNodeTtMsg) Unmarshal(input MarshalType) (TsMsg, error) { - msg := msgpb.DataNodeTtMsg{} + msg := &msgpb.DataNodeTtMsg{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &msg) + err = proto.Unmarshal(in, msg) if err != nil { return nil, err } @@ -793,5 +793,5 @@ func (m *DataNodeTtMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (m *DataNodeTtMsg) Size() int { - return proto.Size(&m.DataNodeTtMsg) + return proto.Size(m.DataNodeTtMsg) } diff --git a/pkg/mq/msgstream/msg_for_collection.go b/pkg/mq/msgstream/msg_for_collection.go index cd87c4dfc3bdb..ae08317fe7173 100644 --- a/pkg/mq/msgstream/msg_for_collection.go +++ b/pkg/mq/msgstream/msg_for_collection.go @@ -27,7 +27,7 @@ import ( // LoadCollectionMsg is a message pack that contains load collection request type LoadCollectionMsg struct { BaseMsg - milvuspb.LoadCollectionRequest + *milvuspb.LoadCollectionRequest } // interface implementation validation @@ -51,7 +51,7 @@ func (l *LoadCollectionMsg) SourceID() int64 { func (l *LoadCollectionMsg) Marshal(input TsMsg) (MarshalType, error) { loadCollectionMsg := input.(*LoadCollectionMsg) - loadCollectionRequest := &loadCollectionMsg.LoadCollectionRequest + loadCollectionRequest := loadCollectionMsg.LoadCollectionRequest mb, err := proto.Marshal(loadCollectionRequest) if err != nil { return nil, err @@ -60,12 +60,12 @@ func (l *LoadCollectionMsg) Marshal(input TsMsg) (MarshalType, error) { } func (l *LoadCollectionMsg) Unmarshal(input MarshalType) (TsMsg, error) { - loadCollectionRequest := milvuspb.LoadCollectionRequest{} + loadCollectionRequest := &milvuspb.LoadCollectionRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &loadCollectionRequest) + err = proto.Unmarshal(in, loadCollectionRequest) if err != nil { return nil, err } @@ -77,13 +77,13 @@ func (l *LoadCollectionMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (l *LoadCollectionMsg) Size() int { - return proto.Size(&l.LoadCollectionRequest) + return proto.Size(l.LoadCollectionRequest) } // ReleaseCollectionMsg is a message pack that contains release collection request type ReleaseCollectionMsg struct { BaseMsg - milvuspb.ReleaseCollectionRequest + *milvuspb.ReleaseCollectionRequest } var _ TsMsg = &ReleaseCollectionMsg{} @@ -106,7 +106,7 @@ func (r *ReleaseCollectionMsg) SourceID() int64 { func (r *ReleaseCollectionMsg) Marshal(input TsMsg) (MarshalType, error) { releaseCollectionMsg := input.(*ReleaseCollectionMsg) - releaseCollectionRequest := &releaseCollectionMsg.ReleaseCollectionRequest + releaseCollectionRequest := releaseCollectionMsg.ReleaseCollectionRequest mb, err := proto.Marshal(releaseCollectionRequest) if err != nil { return nil, err @@ -115,12 +115,12 @@ func (r *ReleaseCollectionMsg) Marshal(input TsMsg) (MarshalType, error) { } func (r *ReleaseCollectionMsg) Unmarshal(input MarshalType) (TsMsg, error) { - releaseCollectionRequest := milvuspb.ReleaseCollectionRequest{} + releaseCollectionRequest := &milvuspb.ReleaseCollectionRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &releaseCollectionRequest) + err = proto.Unmarshal(in, releaseCollectionRequest) if err != nil { return nil, err } @@ -132,12 +132,12 @@ func (r *ReleaseCollectionMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (r *ReleaseCollectionMsg) Size() int { - return proto.Size(&r.ReleaseCollectionRequest) + return proto.Size(r.ReleaseCollectionRequest) } type FlushMsg struct { BaseMsg - milvuspb.FlushRequest + *milvuspb.FlushRequest } var _ TsMsg = &FlushMsg{} @@ -160,7 +160,7 @@ func (f *FlushMsg) SourceID() int64 { func (f *FlushMsg) Marshal(input TsMsg) (MarshalType, error) { flushMsg := input.(*FlushMsg) - flushRequest := &flushMsg.FlushRequest + flushRequest := flushMsg.FlushRequest mb, err := proto.Marshal(flushRequest) if err != nil { return nil, err @@ -169,12 +169,12 @@ func (f *FlushMsg) Marshal(input TsMsg) (MarshalType, error) { } func (f *FlushMsg) Unmarshal(input MarshalType) (TsMsg, error) { - flushRequest := milvuspb.FlushRequest{} + flushRequest := &milvuspb.FlushRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &flushRequest) + err = proto.Unmarshal(in, flushRequest) if err != nil { return nil, err } @@ -186,5 +186,5 @@ func (f *FlushMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (f *FlushMsg) Size() int { - return proto.Size(&f.FlushRequest) + return proto.Size(f.FlushRequest) } diff --git a/pkg/mq/msgstream/msg_for_collection_test.go b/pkg/mq/msgstream/msg_for_collection_test.go index f84f17fefd408..665baa0d0ad07 100644 --- a/pkg/mq/msgstream/msg_for_collection_test.go +++ b/pkg/mq/msgstream/msg_for_collection_test.go @@ -29,7 +29,7 @@ import ( func TestFlushMsg(t *testing.T) { var msg TsMsg = &FlushMsg{ - FlushRequest: milvuspb.FlushRequest{ + FlushRequest: &milvuspb.FlushRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Flush, MsgID: 100, @@ -68,7 +68,7 @@ func TestFlushMsg(t *testing.T) { func TestLoadCollection(t *testing.T) { var msg TsMsg = &LoadCollectionMsg{ - LoadCollectionRequest: milvuspb.LoadCollectionRequest{ + LoadCollectionRequest: &milvuspb.LoadCollectionRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_LoadCollection, MsgID: 100, @@ -107,7 +107,7 @@ func TestLoadCollection(t *testing.T) { func TestReleaseCollection(t *testing.T) { var msg TsMsg = &ReleaseCollectionMsg{ - ReleaseCollectionRequest: milvuspb.ReleaseCollectionRequest{ + ReleaseCollectionRequest: &milvuspb.ReleaseCollectionRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_ReleaseCollection, MsgID: 100, diff --git a/pkg/mq/msgstream/msg_for_database.go b/pkg/mq/msgstream/msg_for_database.go index 584ce72edee2c..c094ef76cd03f 100644 --- a/pkg/mq/msgstream/msg_for_database.go +++ b/pkg/mq/msgstream/msg_for_database.go @@ -26,7 +26,7 @@ import ( type CreateDatabaseMsg struct { BaseMsg - milvuspb.CreateDatabaseRequest + *milvuspb.CreateDatabaseRequest } var _ TsMsg = &CreateDatabaseMsg{} @@ -49,7 +49,7 @@ func (c *CreateDatabaseMsg) SourceID() int64 { func (c *CreateDatabaseMsg) Marshal(input TsMsg) (MarshalType, error) { createDataBaseMsg := input.(*CreateDatabaseMsg) - createDatabaseRequest := &createDataBaseMsg.CreateDatabaseRequest + createDatabaseRequest := createDataBaseMsg.CreateDatabaseRequest mb, err := proto.Marshal(createDatabaseRequest) if err != nil { return nil, err @@ -58,12 +58,12 @@ func (c *CreateDatabaseMsg) Marshal(input TsMsg) (MarshalType, error) { } func (c *CreateDatabaseMsg) Unmarshal(input MarshalType) (TsMsg, error) { - createDatabaseRequest := milvuspb.CreateDatabaseRequest{} + createDatabaseRequest := &milvuspb.CreateDatabaseRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &createDatabaseRequest) + err = proto.Unmarshal(in, createDatabaseRequest) if err != nil { return nil, err } @@ -75,12 +75,12 @@ func (c *CreateDatabaseMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (c *CreateDatabaseMsg) Size() int { - return proto.Size(&c.CreateDatabaseRequest) + return proto.Size(c.CreateDatabaseRequest) } type DropDatabaseMsg struct { BaseMsg - milvuspb.DropDatabaseRequest + *milvuspb.DropDatabaseRequest } var _ TsMsg = &DropDatabaseMsg{} @@ -103,7 +103,7 @@ func (d *DropDatabaseMsg) SourceID() int64 { func (d *DropDatabaseMsg) Marshal(input TsMsg) (MarshalType, error) { dropDataBaseMsg := input.(*DropDatabaseMsg) - dropDatabaseRequest := &dropDataBaseMsg.DropDatabaseRequest + dropDatabaseRequest := dropDataBaseMsg.DropDatabaseRequest mb, err := proto.Marshal(dropDatabaseRequest) if err != nil { return nil, err @@ -112,12 +112,12 @@ func (d *DropDatabaseMsg) Marshal(input TsMsg) (MarshalType, error) { } func (d *DropDatabaseMsg) Unmarshal(input MarshalType) (TsMsg, error) { - dropDatabaseRequest := milvuspb.DropDatabaseRequest{} + dropDatabaseRequest := &milvuspb.DropDatabaseRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &dropDatabaseRequest) + err = proto.Unmarshal(in, dropDatabaseRequest) if err != nil { return nil, err } @@ -129,5 +129,5 @@ func (d *DropDatabaseMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (d *DropDatabaseMsg) Size() int { - return proto.Size(&d.DropDatabaseRequest) + return proto.Size(d.DropDatabaseRequest) } diff --git a/pkg/mq/msgstream/msg_for_database_test.go b/pkg/mq/msgstream/msg_for_database_test.go index e3d9579599fb6..941b96ed8a5b8 100644 --- a/pkg/mq/msgstream/msg_for_database_test.go +++ b/pkg/mq/msgstream/msg_for_database_test.go @@ -29,7 +29,7 @@ import ( func TestCreateDatabase(t *testing.T) { var msg TsMsg = &CreateDatabaseMsg{ - CreateDatabaseRequest: milvuspb.CreateDatabaseRequest{ + CreateDatabaseRequest: &milvuspb.CreateDatabaseRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_CreateDatabase, MsgID: 100, @@ -66,7 +66,7 @@ func TestCreateDatabase(t *testing.T) { func TestDropDatabase(t *testing.T) { var msg TsMsg = &DropDatabaseMsg{ - DropDatabaseRequest: milvuspb.DropDatabaseRequest{ + DropDatabaseRequest: &milvuspb.DropDatabaseRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_DropDatabase, MsgID: 100, diff --git a/pkg/mq/msgstream/msg_for_index.go b/pkg/mq/msgstream/msg_for_index.go index 6de6b910181ae..3c2cc62f930d6 100644 --- a/pkg/mq/msgstream/msg_for_index.go +++ b/pkg/mq/msgstream/msg_for_index.go @@ -27,7 +27,7 @@ import ( // CreateIndexMsg is a message pack that contains create index request type CreateIndexMsg struct { BaseMsg - milvuspb.CreateIndexRequest + *milvuspb.CreateIndexRequest } // interface implementation validation @@ -56,7 +56,7 @@ func (it *CreateIndexMsg) SourceID() int64 { // Marshal is used to serialize a message pack to byte array func (it *CreateIndexMsg) Marshal(input TsMsg) (MarshalType, error) { createIndexMsg := input.(*CreateIndexMsg) - createIndexRequest := &createIndexMsg.CreateIndexRequest + createIndexRequest := createIndexMsg.CreateIndexRequest mb, err := proto.Marshal(createIndexRequest) if err != nil { return nil, err @@ -66,12 +66,12 @@ func (it *CreateIndexMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserialize a message pack from byte array func (it *CreateIndexMsg) Unmarshal(input MarshalType) (TsMsg, error) { - createIndexRequest := milvuspb.CreateIndexRequest{} + createIndexRequest := &milvuspb.CreateIndexRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &createIndexRequest) + err = proto.Unmarshal(in, createIndexRequest) if err != nil { return nil, err } @@ -83,13 +83,13 @@ func (it *CreateIndexMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (it *CreateIndexMsg) Size() int { - return proto.Size(&it.CreateIndexRequest) + return proto.Size(it.CreateIndexRequest) } // AlterIndexMsg is a message pack that contains create index request type AlterIndexMsg struct { BaseMsg - milvuspb.AlterIndexRequest + *milvuspb.AlterIndexRequest } // interface implementation validation @@ -118,7 +118,7 @@ func (it *AlterIndexMsg) SourceID() int64 { // Marshal is used to serialize a message pack to byte array func (it *AlterIndexMsg) Marshal(input TsMsg) (MarshalType, error) { AlterIndexMsg := input.(*AlterIndexMsg) - AlterIndexRequest := &AlterIndexMsg.AlterIndexRequest + AlterIndexRequest := AlterIndexMsg.AlterIndexRequest mb, err := proto.Marshal(AlterIndexRequest) if err != nil { return nil, err @@ -128,12 +128,12 @@ func (it *AlterIndexMsg) Marshal(input TsMsg) (MarshalType, error) { // Unmarshal is used to deserialize a message pack from byte array func (it *AlterIndexMsg) Unmarshal(input MarshalType) (TsMsg, error) { - alterIndexRequest := milvuspb.AlterIndexRequest{} + alterIndexRequest := &milvuspb.AlterIndexRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &alterIndexRequest) + err = proto.Unmarshal(in, alterIndexRequest) if err != nil { return nil, err } @@ -145,13 +145,13 @@ func (it *AlterIndexMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (it *AlterIndexMsg) Size() int { - return proto.Size(&it.AlterIndexRequest) + return proto.Size(it.AlterIndexRequest) } // DropIndexMsg is a message pack that contains drop index request type DropIndexMsg struct { BaseMsg - milvuspb.DropIndexRequest + *milvuspb.DropIndexRequest } var _ TsMsg = &DropIndexMsg{} @@ -174,7 +174,7 @@ func (d *DropIndexMsg) SourceID() int64 { func (d *DropIndexMsg) Marshal(input TsMsg) (MarshalType, error) { dropIndexMsg := input.(*DropIndexMsg) - dropIndexRequest := &dropIndexMsg.DropIndexRequest + dropIndexRequest := dropIndexMsg.DropIndexRequest mb, err := proto.Marshal(dropIndexRequest) if err != nil { return nil, err @@ -183,12 +183,12 @@ func (d *DropIndexMsg) Marshal(input TsMsg) (MarshalType, error) { } func (d *DropIndexMsg) Unmarshal(input MarshalType) (TsMsg, error) { - dropIndexRequest := milvuspb.DropIndexRequest{} + dropIndexRequest := &milvuspb.DropIndexRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &dropIndexRequest) + err = proto.Unmarshal(in, dropIndexRequest) if err != nil { return nil, err } @@ -200,5 +200,5 @@ func (d *DropIndexMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (d *DropIndexMsg) Size() int { - return proto.Size(&d.DropIndexRequest) + return proto.Size(d.DropIndexRequest) } diff --git a/pkg/mq/msgstream/msg_for_index_test.go b/pkg/mq/msgstream/msg_for_index_test.go index 590231c16380e..bbbf64f650956 100644 --- a/pkg/mq/msgstream/msg_for_index_test.go +++ b/pkg/mq/msgstream/msg_for_index_test.go @@ -29,7 +29,7 @@ import ( func TestCreateIndex(t *testing.T) { var msg TsMsg = &CreateIndexMsg{ - CreateIndexRequest: milvuspb.CreateIndexRequest{ + CreateIndexRequest: &milvuspb.CreateIndexRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_CreateIndex, MsgID: 100, @@ -65,7 +65,7 @@ func TestCreateIndex(t *testing.T) { func TestDropIndex(t *testing.T) { var msg TsMsg = &DropIndexMsg{ - DropIndexRequest: milvuspb.DropIndexRequest{ + DropIndexRequest: &milvuspb.DropIndexRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_DropIndex, MsgID: 100, diff --git a/pkg/mq/msgstream/msg_for_partition.go b/pkg/mq/msgstream/msg_for_partition.go index b92a9d8ded876..d600ba854febf 100644 --- a/pkg/mq/msgstream/msg_for_partition.go +++ b/pkg/mq/msgstream/msg_for_partition.go @@ -26,7 +26,7 @@ import ( type LoadPartitionsMsg struct { BaseMsg - milvuspb.LoadPartitionsRequest + *milvuspb.LoadPartitionsRequest } var _ TsMsg = &LoadPartitionsMsg{} @@ -49,7 +49,7 @@ func (l *LoadPartitionsMsg) SourceID() int64 { func (l *LoadPartitionsMsg) Marshal(input TsMsg) (MarshalType, error) { loadPartitionsMsg := input.(*LoadPartitionsMsg) - loadPartitionsRequest := &loadPartitionsMsg.LoadPartitionsRequest + loadPartitionsRequest := loadPartitionsMsg.LoadPartitionsRequest mb, err := proto.Marshal(loadPartitionsRequest) if err != nil { return nil, err @@ -58,12 +58,12 @@ func (l *LoadPartitionsMsg) Marshal(input TsMsg) (MarshalType, error) { } func (l *LoadPartitionsMsg) Unmarshal(input MarshalType) (TsMsg, error) { - loadPartitionsRequest := milvuspb.LoadPartitionsRequest{} + loadPartitionsRequest := &milvuspb.LoadPartitionsRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &loadPartitionsRequest) + err = proto.Unmarshal(in, loadPartitionsRequest) if err != nil { return nil, err } @@ -75,12 +75,12 @@ func (l *LoadPartitionsMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (l *LoadPartitionsMsg) Size() int { - return proto.Size(&l.LoadPartitionsRequest) + return proto.Size(l.LoadPartitionsRequest) } type ReleasePartitionsMsg struct { BaseMsg - milvuspb.ReleasePartitionsRequest + *milvuspb.ReleasePartitionsRequest } var _ TsMsg = &ReleasePartitionsMsg{} @@ -103,7 +103,7 @@ func (r *ReleasePartitionsMsg) SourceID() int64 { func (r *ReleasePartitionsMsg) Marshal(input TsMsg) (MarshalType, error) { releasePartitionsMsg := input.(*ReleasePartitionsMsg) - releasePartitionsRequest := &releasePartitionsMsg.ReleasePartitionsRequest + releasePartitionsRequest := releasePartitionsMsg.ReleasePartitionsRequest mb, err := proto.Marshal(releasePartitionsRequest) if err != nil { return nil, err @@ -112,12 +112,12 @@ func (r *ReleasePartitionsMsg) Marshal(input TsMsg) (MarshalType, error) { } func (r *ReleasePartitionsMsg) Unmarshal(input MarshalType) (TsMsg, error) { - releasePartitionsRequest := milvuspb.ReleasePartitionsRequest{} + releasePartitionsRequest := &milvuspb.ReleasePartitionsRequest{} in, err := convertToByteArray(input) if err != nil { return nil, err } - err = proto.Unmarshal(in, &releasePartitionsRequest) + err = proto.Unmarshal(in, releasePartitionsRequest) if err != nil { return nil, err } @@ -128,5 +128,5 @@ func (r *ReleasePartitionsMsg) Unmarshal(input MarshalType) (TsMsg, error) { } func (r *ReleasePartitionsMsg) Size() int { - return proto.Size(&r.ReleasePartitionsRequest) + return proto.Size(r.ReleasePartitionsRequest) } diff --git a/pkg/mq/msgstream/msg_for_partition_test.go b/pkg/mq/msgstream/msg_for_partition_test.go index 981be41bc6c3a..caed9a9b92d67 100644 --- a/pkg/mq/msgstream/msg_for_partition_test.go +++ b/pkg/mq/msgstream/msg_for_partition_test.go @@ -29,7 +29,7 @@ import ( func TestLoadPartitions(t *testing.T) { msg := &LoadPartitionsMsg{ - LoadPartitionsRequest: milvuspb.LoadPartitionsRequest{ + LoadPartitionsRequest: &milvuspb.LoadPartitionsRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_LoadPartitions, MsgID: 100, @@ -74,7 +74,7 @@ func TestLoadPartitions(t *testing.T) { func TestReleasePartitions(t *testing.T) { msg := &ReleasePartitionsMsg{ - ReleasePartitionsRequest: milvuspb.ReleasePartitionsRequest{ + ReleasePartitionsRequest: &milvuspb.ReleasePartitionsRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_ReleasePartitions, MsgID: 100, diff --git a/pkg/mq/msgstream/msg_test.go b/pkg/mq/msgstream/msg_test.go index 20e7b4c81c1e7..67e3a9286c22a 100644 --- a/pkg/mq/msgstream/msg_test.go +++ b/pkg/mq/msgstream/msg_test.go @@ -83,7 +83,7 @@ func generateBaseMsg() BaseMsg { func TestInsertMsg(t *testing.T) { insertMsg := &InsertMsg{ BaseMsg: generateBaseMsg(), - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 1, @@ -136,7 +136,7 @@ func TestInsertMsg_Unmarshal_IllegalParameter(t *testing.T) { func TestInsertMsg_RowBasedFormat(t *testing.T) { msg := &InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Version: msgpb.InsertDataVersion_RowBased, }, } @@ -145,7 +145,7 @@ func TestInsertMsg_RowBasedFormat(t *testing.T) { func TestInsertMsg_ColumnBasedFormat(t *testing.T) { msg := &InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Version: msgpb.InsertDataVersion_ColumnBased, }, } @@ -154,7 +154,7 @@ func TestInsertMsg_ColumnBasedFormat(t *testing.T) { func TestInsertMsg_NRows(t *testing.T) { msg1 := &InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ RowData: []*commonpb.Blob{ {}, {}, @@ -165,7 +165,7 @@ func TestInsertMsg_NRows(t *testing.T) { } assert.Equal(t, uint64(2), msg1.NRows()) msg2 := &InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ RowData: nil, FieldsData: []*schemapb.FieldData{ {}, @@ -179,7 +179,7 @@ func TestInsertMsg_NRows(t *testing.T) { func TestInsertMsg_CheckAligned(t *testing.T) { msg1 := &InsertMsg{ - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Timestamps: []uint64{1}, RowIDs: []int64{1}, RowData: []*commonpb.Blob{ @@ -217,7 +217,7 @@ func TestInsertMsg_IndexMsg(t *testing.T) { BeginTimestamp: 1, EndTimestamp: 2, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 3, @@ -272,7 +272,7 @@ func TestInsertMsg_IndexMsg(t *testing.T) { func TestDeleteMsg(t *testing.T) { deleteMsg := &DeleteMsg{ BaseMsg: generateBaseMsg(), - DeleteRequest: msgpb.DeleteRequest{ + DeleteRequest: &msgpb.DeleteRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Delete, MsgID: 1, @@ -321,7 +321,7 @@ func TestDeleteMsg_Unmarshal_IllegalParameter(t *testing.T) { func TestTimeTickMsg(t *testing.T) { timeTickMsg := &TimeTickMsg{ BaseMsg: generateBaseMsg(), - TimeTickMsg: msgpb.TimeTickMsg{ + TimeTickMsg: &msgpb.TimeTickMsg{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_TimeTick, MsgID: 1, @@ -364,7 +364,7 @@ func TestTimeTickMsg_Unmarshal_IllegalParameter(t *testing.T) { func TestCreateCollectionMsg(t *testing.T) { createCollectionMsg := &CreateCollectionMsg{ BaseMsg: generateBaseMsg(), - CreateCollectionRequest: msgpb.CreateCollectionRequest{ + CreateCollectionRequest: &msgpb.CreateCollectionRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_CreateCollection, MsgID: 1, @@ -416,7 +416,7 @@ func TestCreateCollectionMsg_Unmarshal_IllegalParameter(t *testing.T) { func TestDropCollectionMsg(t *testing.T) { dropCollectionMsg := &DropCollectionMsg{ BaseMsg: generateBaseMsg(), - DropCollectionRequest: msgpb.DropCollectionRequest{ + DropCollectionRequest: &msgpb.DropCollectionRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_DropCollection, MsgID: 1, @@ -463,7 +463,7 @@ func TestDropCollectionMsg_Unmarshal_IllegalParameter(t *testing.T) { func TestCreatePartitionMsg(t *testing.T) { createPartitionMsg := &CreatePartitionMsg{ BaseMsg: generateBaseMsg(), - CreatePartitionRequest: msgpb.CreatePartitionRequest{ + CreatePartitionRequest: &msgpb.CreatePartitionRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_CreatePartition, MsgID: 1, @@ -512,7 +512,7 @@ func TestCreatePartitionMsg_Unmarshal_IllegalParameter(t *testing.T) { func TestDropPartitionMsg(t *testing.T) { dropPartitionMsg := &DropPartitionMsg{ BaseMsg: generateBaseMsg(), - DropPartitionRequest: msgpb.DropPartitionRequest{ + DropPartitionRequest: &msgpb.DropPartitionRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_DropPartition, MsgID: 1, @@ -561,7 +561,7 @@ func TestDropPartitionMsg_Unmarshal_IllegalParameter(t *testing.T) { func TestDataNodeTtMsg(t *testing.T) { dataNodeTtMsg := &DataNodeTtMsg{ BaseMsg: generateBaseMsg(), - DataNodeTtMsg: msgpb.DataNodeTtMsg{ + DataNodeTtMsg: &msgpb.DataNodeTtMsg{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_DataNodeTt, MsgID: 1, diff --git a/pkg/mq/msgstream/unmarshal_test.go b/pkg/mq/msgstream/unmarshal_test.go index a1971f5c367d4..cabc70044d539 100644 --- a/pkg/mq/msgstream/unmarshal_test.go +++ b/pkg/mq/msgstream/unmarshal_test.go @@ -34,7 +34,7 @@ func Test_ProtoUnmarshalDispatcher(t *testing.T) { EndTimestamp: 0, HashValues: []uint32{1}, }, - InsertRequest: msgpb.InsertRequest{ + InsertRequest: &msgpb.InsertRequest{ Base: &commonpb.MsgBase{ MsgType: commonpb.MsgType_Insert, MsgID: 1, diff --git a/pkg/util/funcutil/policy.go b/pkg/util/funcutil/policy.go index db10e6a7a1d5b..fc0482b35c579 100644 --- a/pkg/util/funcutil/policy.go +++ b/pkg/util/funcutil/policy.go @@ -1,10 +1,10 @@ package funcutil import ( - "errors" "fmt" "strings" + "github.com/cockroachdb/errors" "go.uber.org/zap" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" diff --git a/pkg/util/testutils/gen_data.go b/pkg/util/testutils/gen_data.go index 0eb692a2249b0..15b39933858ff 100644 --- a/pkg/util/testutils/gen_data.go +++ b/pkg/util/testutils/gen_data.go @@ -301,6 +301,48 @@ func GenerateFloat16VectorsWithInvalidData(numRows, dim int) []byte { return ret } +func GenerateSparseFloatVectorsData(numRows int) ([][]byte, int64) { + dim := 700 + avgNnz := 20 + var contents [][]byte + maxDim := 0 + + uniqueAndSort := func(indices []uint32) []uint32 { + seen := make(map[uint32]bool) + var result []uint32 + for _, value := range indices { + if _, ok := seen[value]; !ok { + seen[value] = true + result = append(result, value) + } + } + sort.Slice(result, func(i, j int) bool { + return result[i] < result[j] + }) + return result + } + + for i := 0; i < numRows; i++ { + nnz := rand.Intn(avgNnz*2) + 1 + indices := make([]uint32, 0, nnz) + for j := 0; j < nnz; j++ { + indices = append(indices, uint32(rand.Intn(dim))) + } + indices = uniqueAndSort(indices) + values := make([]float32, 0, len(indices)) + for j := 0; j < len(indices); j++ { + values = append(values, rand.Float32()) + } + if len(indices) > 0 && int(indices[len(indices)-1])+1 > maxDim { + maxDim = int(indices[len(indices)-1]) + 1 + } + rowBytes := typeutil.CreateSparseFloatRow(indices, values) + + contents = append(contents, rowBytes) + } + return contents, int64(maxDim) +} + func GenerateSparseFloatVectors(numRows int) *schemapb.SparseFloatArray { dim := 700 avgNnz := 20 diff --git a/pkg/util/typeutil/schema_test.go b/pkg/util/typeutil/schema_test.go index e564a6bff4db2..48dc3c14915bc 100644 --- a/pkg/util/typeutil/schema_test.go +++ b/pkg/util/typeutil/schema_test.go @@ -1100,7 +1100,7 @@ func TestDeleteFieldData(t *testing.T) { assert.Equal(t, BFloat16Vector[2*Dim:4*Dim], result2[BFloat16VectorFieldID-common.StartOfUserFieldID].GetVectors().Data.(*schemapb.VectorField_Bfloat16Vector).Bfloat16Vector) tmpSparseFloatVector = proto.Clone(SparseFloatVector).(*schemapb.SparseFloatArray) tmpSparseFloatVector.Contents = [][]byte{SparseFloatVector.Contents[1]} - assert.EqualExportedValues(t, *tmpSparseFloatVector, *result2[SparseFloatVectorFieldID-common.StartOfUserFieldID].GetVectors().GetSparseFloatVector()) + assert.EqualExportedValues(t, tmpSparseFloatVector, result2[SparseFloatVectorFieldID-common.StartOfUserFieldID].GetVectors().GetSparseFloatVector()) } func TestEstimateEntitySize(t *testing.T) {