From 01c8341a2e6031accd7322b2d1618a0b42652801 Mon Sep 17 00:00:00 2001 From: congqixia <congqi.xia@zilliz.com> Date: Thu, 16 Sep 2021 19:55:49 +0800 Subject: [PATCH] [skip ci]Add comments for SegmentManager (#8087) Signed-off-by: Congqi Xia <congqi.xia@zilliz.com> --- internal/datacoord/segment_manager.go | 6 ++++++ 1 file changed, 6 insertions(+) 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()