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
congqixia 2022-10-12 17:19:23 +08:00 committed by GitHub
parent b48c37cb44
commit 04e1333552
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 2 deletions

View File

@ -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)
}
}

View File

@ -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)
})
}
}