Fix datanode update segment statistics bug

Signed-off-by: XuanYang-cn <xuan.yang@zilliz.com>
pull/4973/head^2
XuanYang-cn 2021-03-02 15:47:37 +08:00 committed by yefu.chen
parent 795cb74c85
commit c0edffc63f
2 changed files with 14 additions and 4 deletions

View File

@ -151,10 +151,11 @@ func (replica *ReplicaImpl) getSegmentStatisticsUpdates(segmentID UniqueID) (*in
for _, ele := range replica.segments {
if ele.segmentID == segmentID {
updates := &internalpb2.SegmentStatisticsUpdates{
SegmentID: segmentID,
MemorySize: ele.memorySize,
NumRows: ele.numRows,
IsNewSegment: ele.isNew,
SegmentID: segmentID,
MemorySize: ele.memorySize,
NumRows: ele.numRows,
IsNewSegment: ele.isNew,
StartPosition: new(internalpb2.MsgPosition),
}
if ele.isNew {

View File

@ -124,6 +124,15 @@ func TestReplica_Segment(t *testing.T) {
assert.Equal(t, UniqueID(0), update.SegmentID)
assert.Equal(t, int64(100), update.NumRows)
assert.True(t, update.IsNewSegment)
update, err = replica.getSegmentStatisticsUpdates(0)
assert.NoError(t, err)
assert.False(t, update.IsNewSegment)
assert.NotNil(t, update.StartPosition)
assert.Equal(t, UniqueID(0), update.SegmentID)
assert.Equal(t, int64(100), update.NumRows)
assert.Zero(t, update.StartPosition.Timestamp)
assert.Zero(t, update.StartPosition.MsgID)
})
t.Run("Test errors", func(t *testing.T) {