mirror of https://github.com/milvus-io/milvus.git
Fix insert buffer node time range uint64 conversion error (#19725)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com> Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/19755/head
parent
b48c37cb44
commit
04e1333552
|
@ -598,10 +598,10 @@ func (ibNode *insertBufferNode) getTimestampRange(tsData *storage.Int64FieldData
|
|||
}
|
||||
|
||||
for _, data := range tsData.Data {
|
||||
if data < int64(tr.timestampMin) {
|
||||
if uint64(data) < tr.timestampMin {
|
||||
tr.timestampMin = Timestamp(data)
|
||||
}
|
||||
if data > int64(tr.timestampMax) {
|
||||
if uint64(data) > tr.timestampMax {
|
||||
tr.timestampMax = Timestamp(data)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1107,3 +1107,47 @@ func TestInsertBufferNode_BufferData_updateTimeRange(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInsertBufferNode_getTimestampRange(t *testing.T) {
|
||||
|
||||
type testCase struct {
|
||||
tag string
|
||||
|
||||
timestamps []int64
|
||||
expectFrom Timestamp
|
||||
expectTo Timestamp
|
||||
}
|
||||
|
||||
cases := []testCase{
|
||||
{
|
||||
tag: "no input",
|
||||
timestamps: []int64{},
|
||||
expectFrom: math.MaxUint64,
|
||||
expectTo: 0,
|
||||
},
|
||||
{
|
||||
tag: "only one input",
|
||||
timestamps: []int64{1234},
|
||||
expectFrom: 1234,
|
||||
expectTo: 1234,
|
||||
},
|
||||
{
|
||||
tag: "input reverse order",
|
||||
timestamps: []int64{3, 2, 1},
|
||||
expectFrom: 1,
|
||||
expectTo: 3,
|
||||
},
|
||||
}
|
||||
|
||||
ibNode := &insertBufferNode{}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.tag, func(t *testing.T) {
|
||||
tr := ibNode.getTimestampRange(&storage.Int64FieldData{
|
||||
Data: tc.timestamps,
|
||||
})
|
||||
|
||||
assert.Equal(t, tc.expectFrom, tr.timestampMin)
|
||||
assert.Equal(t, tc.expectTo, tr.timestampMax)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue