mirror of https://github.com/milvus-io/milvus.git
enhance: Remove unnecessary clone in SetState (#37697)
issue: https://github.com/milvus-io/milvus/issues/37637 --------- Signed-off-by: bigsheeper <yihao.dai@zilliz.com>pull/37724/head
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.
|
// Apply segment metric update after successful meta update.
|
||||||
metricMutation.commit()
|
metricMutation.commit()
|
||||||
// Update in-memory meta.
|
// Update in-memory meta.
|
||||||
m.segments.SetState(segmentID, targetState)
|
m.segments.SetSegment(segmentID, clonedSegment)
|
||||||
}
|
}
|
||||||
log.Info("meta update: setting segment state - complete",
|
log.Info("meta update: setting segment state - complete",
|
||||||
zap.Int64("segmentID", segmentID),
|
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
|
// SetDmlPosition sets DmlPosition info (checkpoint for recovery) for SegmentInfo with provided segmentID
|
||||||
// if SegmentInfo not found, do nothing
|
// if SegmentInfo not found, do nothing
|
||||||
func (s *SegmentsInfo) SetDmlPosition(segmentID UniqueID, pos *msgpb.MsgPosition) {
|
func (s *SegmentsInfo) SetDmlPosition(segmentID UniqueID, pos *msgpb.MsgPosition) {
|
||||||
|
|
|
@ -546,10 +546,12 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() {
|
||||||
|
|
||||||
s.Run("normal case", func() {
|
s.Run("normal case", func() {
|
||||||
catalog := catalogmocks.NewDataCoordCatalog(s.T())
|
catalog := catalogmocks.NewDataCoordCatalog(s.T())
|
||||||
|
catalog.EXPECT().AlterSegments(mock.Anything, mock.Anything, mock.Anything).Return(nil)
|
||||||
s.mt.catalog = catalog
|
s.mt.catalog = catalog
|
||||||
s.mt.statsTaskMeta.catalog = catalog
|
s.mt.statsTaskMeta.catalog = catalog
|
||||||
s.mt.segments.SetState(s.segID, commonpb.SegmentState_Flushed)
|
updateStateOp := UpdateStatusOperator(s.segID, commonpb.SegmentState_Flushed)
|
||||||
catalog.EXPECT().AlterSegments(mock.Anything, mock.Anything, mock.Anything).Return(nil)
|
err := s.mt.UpdateSegmentsInfo(updateStateOp)
|
||||||
|
s.NoError(err)
|
||||||
catalog.EXPECT().SaveStatsTask(mock.Anything, mock.Anything).Return(nil)
|
catalog.EXPECT().SaveStatsTask(mock.Anything, mock.Anything).Return(nil)
|
||||||
|
|
||||||
s.NoError(st.SetJobInfo(s.mt))
|
s.NoError(st.SetJobInfo(s.mt))
|
||||||
|
|
Loading…
Reference in New Issue