mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
fix: [2.4]DeleteData merge wrong data casuing data loss (#33821)
See also: #33819 pr: #33820 Signed-off-by: yangxuan <xuan.yang@zilliz.com>
This commit is contained in:
parent
c9fa167a38
commit
a446e754b4
@ -945,8 +945,8 @@ func (data *DeleteData) AppendBatch(pks []PrimaryKey, tss []Timestamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (data *DeleteData) Merge(other *DeleteData) {
|
func (data *DeleteData) Merge(other *DeleteData) {
|
||||||
data.Pks = append(other.Pks, other.Pks...)
|
data.Pks = append(data.Pks, other.Pks...)
|
||||||
data.Tss = append(other.Tss, other.Tss...)
|
data.Tss = append(data.Tss, other.Tss...)
|
||||||
data.RowCount += other.RowCount
|
data.RowCount += other.RowCount
|
||||||
data.memSize += other.Size()
|
data.memSize += other.Size()
|
||||||
|
|
||||||
|
@ -878,9 +878,12 @@ func TestDeleteData(t *testing.T) {
|
|||||||
pks, err := GenInt64PrimaryKeys(1, 2, 3)
|
pks, err := GenInt64PrimaryKeys(1, 2, 3)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
pks2, err := GenInt64PrimaryKeys(4, 5, 6)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
t.Run("merge", func(t *testing.T) {
|
t.Run("merge", func(t *testing.T) {
|
||||||
first := NewDeleteData(pks, []Timestamp{100, 101, 102})
|
first := NewDeleteData(pks, []Timestamp{100, 101, 102})
|
||||||
second := NewDeleteData(pks, []Timestamp{100, 101, 102})
|
second := NewDeleteData(pks2, []Timestamp{103, 104, 105})
|
||||||
require.EqualValues(t, first.RowCount, second.RowCount)
|
require.EqualValues(t, first.RowCount, second.RowCount)
|
||||||
require.EqualValues(t, first.Size(), second.Size())
|
require.EqualValues(t, first.Size(), second.Size())
|
||||||
require.EqualValues(t, 3, first.RowCount)
|
require.EqualValues(t, 3, first.RowCount)
|
||||||
@ -891,6 +894,8 @@ func TestDeleteData(t *testing.T) {
|
|||||||
assert.Equal(t, len(first.Tss), 6)
|
assert.Equal(t, len(first.Tss), 6)
|
||||||
assert.EqualValues(t, first.RowCount, 6)
|
assert.EqualValues(t, first.RowCount, 6)
|
||||||
assert.EqualValues(t, first.Size(), 144)
|
assert.EqualValues(t, first.Size(), 144)
|
||||||
|
assert.ElementsMatch(t, first.Pks, append(pks, pks2...))
|
||||||
|
assert.ElementsMatch(t, first.Tss, []Timestamp{100, 101, 102, 103, 104, 105})
|
||||||
|
|
||||||
assert.NotNil(t, second)
|
assert.NotNil(t, second)
|
||||||
assert.EqualValues(t, 0, second.RowCount)
|
assert.EqualValues(t, 0, second.RowCount)
|
||||||
|
Loading…
Reference in New Issue
Block a user