diff --git a/internal/datacoord/segment_manager.go b/internal/datacoord/segment_manager.go index 42fbc13900..0f6b4b553d 100644 --- a/internal/datacoord/segment_manager.go +++ b/internal/datacoord/segment_manager.go @@ -29,6 +29,7 @@ import ( ) var ( + // allocPool pool of Allocation, to reduce allocation of Allocation allocPool = sync.Pool{ New: func() interface{} { return &Allocation{} @@ -59,6 +60,8 @@ func putAllocation(a *Allocation) { allocPool.Put(a) } +// segmentMaxLifetime default segment max lifetime value +// TODO needs to be configurable const segmentMaxLifetime = 24 * time.Hour // Manager manage segment related operations. @@ -326,6 +329,7 @@ func (s *SegmentManager) estimateMaxNumOfRows(collectionID UniqueID) (int, error return s.estimatePolicy(collMeta.Schema) } +// DropSegment puts back all the allocation of provided segment func (s *SegmentManager) DropSegment(ctx context.Context, segmentID UniqueID) { sp, _ := trace.StartSpanFromContext(ctx) defer sp.Finish() @@ -347,6 +351,7 @@ func (s *SegmentManager) DropSegment(ctx context.Context, segmentID UniqueID) { } } +// SealAllSegments seals all segments of provided collectionID func (s *SegmentManager) SealAllSegments(ctx context.Context, collectionID UniqueID) ([]UniqueID, error) { sp, _ := trace.StartSpanFromContext(ctx) defer sp.Finish() @@ -374,6 +379,7 @@ func (s *SegmentManager) SealAllSegments(ctx context.Context, collectionID Uniqu return ret, nil } +// GetFlushableSegments get segment ids with Sealed State and flushable (meets flushPolicy) func (s *SegmentManager) GetFlushableSegments(ctx context.Context, channel string, t Timestamp) ([]UniqueID, error) { s.mu.Lock()