mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
enhance: Remove unnecessary clone in SetState (#37697)
issue: https://github.com/milvus-io/milvus/issues/37637 --------- Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
parent
81fa7dd52c
commit
18a64782dc
@ -642,7 +642,7 @@ func (m *meta) SetState(segmentID UniqueID, targetState commonpb.SegmentState) e
|
||||
// Apply segment metric update after successful meta update.
|
||||
metricMutation.commit()
|
||||
// Update in-memory meta.
|
||||
m.segments.SetState(segmentID, targetState)
|
||||
m.segments.SetSegment(segmentID, clonedSegment)
|
||||
}
|
||||
log.Info("meta update: setting segment state - complete",
|
||||
zap.Int64("segmentID", segmentID),
|
||||
|
||||
@ -219,14 +219,6 @@ func (s *SegmentsInfo) SetRowCount(segmentID UniqueID, rowCount int64) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetState sets Segment State info for SegmentInfo with provided segmentID
|
||||
// if SegmentInfo not found, do nothing
|
||||
func (s *SegmentsInfo) SetState(segmentID UniqueID, state commonpb.SegmentState) {
|
||||
if segment, ok := s.segments[segmentID]; ok {
|
||||
s.segments[segmentID] = segment.Clone(SetState(state))
|
||||
}
|
||||
}
|
||||
|
||||
// SetDmlPosition sets DmlPosition info (checkpoint for recovery) for SegmentInfo with provided segmentID
|
||||
// if SegmentInfo not found, do nothing
|
||||
func (s *SegmentsInfo) SetDmlPosition(segmentID UniqueID, pos *msgpb.MsgPosition) {
|
||||
|
||||
@ -546,10 +546,12 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() {
|
||||
|
||||
s.Run("normal case", func() {
|
||||
catalog := catalogmocks.NewDataCoordCatalog(s.T())
|
||||
catalog.EXPECT().AlterSegments(mock.Anything, mock.Anything, mock.Anything).Return(nil)
|
||||
s.mt.catalog = catalog
|
||||
s.mt.statsTaskMeta.catalog = catalog
|
||||
s.mt.segments.SetState(s.segID, commonpb.SegmentState_Flushed)
|
||||
catalog.EXPECT().AlterSegments(mock.Anything, mock.Anything, mock.Anything).Return(nil)
|
||||
updateStateOp := UpdateStatusOperator(s.segID, commonpb.SegmentState_Flushed)
|
||||
err := s.mt.UpdateSegmentsInfo(updateStateOp)
|
||||
s.NoError(err)
|
||||
catalog.EXPECT().SaveStatsTask(mock.Anything, mock.Anything).Return(nil)
|
||||
|
||||
s.NoError(st.SetJobInfo(s.mt))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user