|
|
|
@ -54,21 +54,6 @@ func newVidMap(dataCenter string) *vidMap { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// shallowClone creates a shallow copy of the vidMap for use in cache chaining.
|
|
|
|
// The caller is responsible for ensuring thread safety.
|
|
|
|
func (vc *vidMap) shallowClone() *vidMap { |
|
|
|
newMap := &vidMap{ |
|
|
|
vid2Locations: vc.vid2Locations, |
|
|
|
ecVid2Locations: vc.ecVid2Locations, |
|
|
|
DataCenter: vc.DataCenter, |
|
|
|
} |
|
|
|
// Atomically copy the cache pointer
|
|
|
|
if cachedMap := vc.cache.Load(); cachedMap != nil { |
|
|
|
newMap.cache.Store(cachedMap) |
|
|
|
} |
|
|
|
return newMap |
|
|
|
} |
|
|
|
|
|
|
|
func (vc *vidMap) getLocationIndex(length int) (int, error) { |
|
|
|
if length <= 0 { |
|
|
|
return 0, fmt.Errorf("invalid length: %d", length) |
|
|
|
|