mirror of https://github.com/milvus-io/milvus.git
[skip-ci]Add comment for Cache and allocator (#7924)
Signed-off-by: yangxuan <xuan.yang@zilliz.com>pull/7939/head
parent
cf1d773259
commit
376d39fa02
|
@ -40,6 +40,7 @@ func newAllocator(s types.RootCoord) *allocator {
|
|||
}
|
||||
}
|
||||
|
||||
// allocID allocat one ID from rootCoord
|
||||
func (alloc *allocator) allocID() (UniqueID, error) {
|
||||
ctx := context.TODO()
|
||||
resp, err := alloc.rootCoord.AllocID(ctx, &rootcoordpb.AllocIDRequest{
|
||||
|
|
|
@ -4,6 +4,8 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
// Cache stores flusing segments' ids to prevent flushing the same segment again and again.
|
||||
// Once the segment is flushed, its id will be removed from the cache.
|
||||
type Cache struct {
|
||||
cacheMu sync.RWMutex
|
||||
cacheMap map[UniqueID]bool
|
||||
|
@ -23,6 +25,7 @@ func (c *Cache) checkIfCached(key UniqueID) bool {
|
|||
return ok
|
||||
}
|
||||
|
||||
// Cache caches a specific segment ID into the cache
|
||||
func (c *Cache) Cache(segID UniqueID) {
|
||||
c.cacheMu.Lock()
|
||||
defer c.cacheMu.Unlock()
|
||||
|
@ -30,6 +33,7 @@ func (c *Cache) Cache(segID UniqueID) {
|
|||
c.cacheMap[segID] = true
|
||||
}
|
||||
|
||||
// Remove removes a set of segment IDs from the cache
|
||||
func (c *Cache) Remove(segIDs ...UniqueID) {
|
||||
c.cacheMu.Lock()
|
||||
defer c.cacheMu.Unlock()
|
||||
|
|
Loading…
Reference in New Issue