Skip to content

Commit 8ac3adc

Browse files
authored
enhance: Cherry pick commits for client/2.5.5 (#43316)
Cherry pick from master pr: #43126 #43243 Also bump client version to v2.5.5 preparing for releasing --------- Signed-off-by: Congqi Xia <[email protected]>
1 parent b08d9ef commit 8ac3adc

File tree

4 files changed

+85
-28
lines changed

4 files changed

+85
-28
lines changed

client/column/columns.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func parseScalarData[T any, COL Column, NCOL Column](
9898
}
9999
data = data[start:end]
100100
if len(validData) > 0 {
101+
validData = validData[start:end]
101102
ncol, err := nullableCreator(name, data, validData, WithSparseNullableMode[T](true))
102103
return ncol, err
103104
}

client/common/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ package common
1818

1919
const (
2020
// SDKVersion const value for current version
21-
SDKVersion = `2.5.4`
21+
SDKVersion = `2.5.5`
2222
)

client/milvusclient/read.go

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,35 +64,42 @@ func (c *Client) handleSearchResult(schema *entity.Schema, outputFields []string
6464
fieldDataList := results.GetFieldsData()
6565
gb := results.GetGroupByFieldValue()
6666
for i := 0; i < int(results.GetNumQueries()); i++ {
67-
rc := int(results.GetTopks()[i]) // result entry count for current query
68-
entry := ResultSet{
69-
ResultCount: rc,
70-
Scores: results.GetScores()[offset : offset+rc],
71-
sch: schema,
72-
}
67+
func() {
68+
var rc int
69+
entry := ResultSet{
70+
sch: schema,
71+
}
72+
defer func() {
73+
offset += rc
74+
sr = append(sr, entry)
75+
}()
7376

74-
// set recall if returned
75-
if i < len(results.Recalls) {
76-
entry.Recall = results.Recalls[i]
77-
}
77+
if i >= len(results.Topks) {
78+
entry.Err = errors.Newf("topk not returned for nq %d", i)
79+
return
80+
}
81+
rc = int(results.GetTopks()[i]) // result entry count for current query
82+
entry.ResultCount = rc
83+
entry.Scores = results.GetScores()[offset : offset+rc]
7884

79-
entry.IDs, entry.Err = column.IDColumns(schema, results.GetIds(), offset, offset+rc)
80-
if entry.Err != nil {
81-
offset += rc
82-
continue
83-
}
84-
// parse group-by values
85-
if gb != nil {
86-
entry.GroupByValue, entry.Err = column.FieldDataColumn(gb, offset, offset+rc)
87-
if entry.Err != nil {
88-
offset += rc
89-
continue
85+
// set recall if returned
86+
if i < len(results.Recalls) {
87+
entry.Recall = results.Recalls[i]
9088
}
91-
}
92-
entry.Fields, entry.Err = c.parseSearchResult(schema, outputFields, fieldDataList, i, offset, offset+rc)
93-
sr = append(sr, entry)
9489

95-
offset += rc
90+
entry.IDs, entry.Err = column.IDColumns(schema, results.GetIds(), offset, offset+rc)
91+
if entry.Err != nil {
92+
return
93+
}
94+
// parse group-by values
95+
if gb != nil {
96+
entry.GroupByValue, entry.Err = column.FieldDataColumn(gb, offset, offset+rc)
97+
if entry.Err != nil {
98+
return
99+
}
100+
}
101+
entry.Fields, entry.Err = c.parseSearchResult(schema, outputFields, fieldDataList, i, offset, offset+rc)
102+
}()
96103
}
97104
return sr, nil
98105
}

client/milvusclient/read_test.go

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ func (s *ReadSuite) TestSearch() {
6262
},
6363
},
6464
},
65-
Scores: make([]float32, 10),
66-
Topks: []int64{10},
65+
Scores: make([]float32, 10),
66+
Topks: []int64{10},
67+
Recalls: []float32{0.9},
6768
},
6869
}, nil
6970
}).Once()
@@ -122,6 +123,54 @@ func (s *ReadSuite) TestSearch() {
122123
s.NoError(err)
123124
})
124125

126+
s.Run("bad_result", func() {
127+
collectionName := fmt.Sprintf("coll_%s", s.randString(6))
128+
partitionName := fmt.Sprintf("part_%s", s.randString(6))
129+
s.setupCache(collectionName, s.schema)
130+
s.mock.EXPECT().Search(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, sr *milvuspb.SearchRequest) (*milvuspb.SearchResults, error) {
131+
s.Equal(collectionName, sr.GetCollectionName())
132+
s.ElementsMatch([]string{partitionName}, sr.GetPartitionNames())
133+
134+
return &milvuspb.SearchResults{
135+
Status: merr.Success(),
136+
Results: &schemapb.SearchResultData{
137+
NumQueries: 1,
138+
TopK: 10,
139+
FieldsData: []*schemapb.FieldData{
140+
s.getInt64FieldData("ID", []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}),
141+
},
142+
Ids: &schemapb.IDs{
143+
IdField: &schemapb.IDs_IntId{
144+
IntId: &schemapb.LongArray{
145+
Data: []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
146+
},
147+
},
148+
},
149+
Scores: make([]float32, 10),
150+
Topks: []int64{},
151+
},
152+
}, nil
153+
}).Once()
154+
155+
ap := index.NewCustomAnnParam()
156+
ap.WithExtraParam("custom_level", 1)
157+
rss, err := s.client.Search(ctx, NewSearchOption(collectionName, 10, []entity.Vector{
158+
entity.FloatVector(lo.RepeatBy(128, func(_ int) float32 {
159+
return rand.Float32()
160+
})),
161+
}).WithPartitions(partitionName).
162+
WithFilter("id > {tmpl_id}").
163+
WithTemplateParam("tmpl_id", 100).
164+
WithGroupByField("group_by").
165+
WithSearchParam("ignore_growing", "true").
166+
WithAnnParam(ap),
167+
)
168+
s.NoError(err)
169+
s.Len(rss, 1)
170+
rs := rss[0]
171+
s.Error(rs.Err)
172+
})
173+
125174
s.Run("failure", func() {
126175
collectionName := fmt.Sprintf("coll_%s", s.randString(6))
127176
s.setupCache(collectionName, s.schemaDyn)

0 commit comments

Comments
 (0)