func (h *hotScheduler) selectDstStoreByHot(candidates map[uint64]struct{}, regionBytesRate float64, srcStoreID uint64, storesStat statistics.StoreHotPeersStat) (dstStoreID uint64) {
	srcBytesRate := storesStat[srcStoreID].FutureBytesRate
	srcCount := len(storesStat[srcStoreID].Stats)
	var (
		minBytesRate = srcBytesRate*hotRegionScheduleFactor - regionBytesRate
		minCount     = math.MaxInt32
	)
	for storeID := range candidates {
		if s, ok := storesStat[storeID]; ok {
			dstCount, dstBytesRate := len(s.Stats), math.Max(s.StoreBytesRate, s.FutureBytesRate)
			// pick by count
			if srcCount < dstCount+2 { // ensure srcCount >= dstCount after the operation.
				continue
			}
			if minCount > dstCount || (minCount == dstCount && minBytesRate > dstBytesRate) {
				dstStoreID = storeID
				minBytesRate = dstBytesRate
				minCount = dstCount
			}
		} else {
			return storeID
		}
	}
	return dstStoreID
}
// selectDstStoreByHot selects a target store to hold the region of the source region.
// We choose a target store based on the hot region number and flow bytes of this store.
selectDstStoreByHot selects a target store to hold the region of the source region.
We choose a target store based on the hot region number and flow bytes of this store.
// selectDstStoreByHot selects a target store to hold the region of the source region . // We choose a target store based on the hot region number and flow bytes of this store .
func (h *hotScheduler) selectDstStoreByHot(candidates map[uint64]struct{}, regionBytesRate float64, srcStoreID uint64, storesStat statistics.StoreHotPeersStat) (dstStoreID uint64) {
	srcBytesRate := storesStat[srcStoreID].FutureBytesRate
	srcCount := len(storesStat[srcStoreID].Stats)
	var (
		minBytesRate = srcBytesRate*hotRegionScheduleFactor - regionBytesRate
		minCount     = math.MaxInt32
	)
	for storeID := range candidates {
		if s, ok := storesStat[storeID]; ok {
			dstCount, dstBytesRate := len(s.Stats), math.Max(s.StoreBytesRate, s.FutureBytesRate)
			if srcCount < dstCount+2 { 
				continue
			}
			if minCount > dstCount || (minCount == dstCount && minBytesRate > dstBytesRate) {
				dstStoreID = storeID
				minBytesRate = dstBytesRate
				minCount = dstCount
			}
		} else {
			return storeID
		}
	}
	return dstStoreID
}
func ( h * hotScheduler ) selectDstStoreByHot ( candidates map [ uint64 ] struct { } , regionBytesRate float64 , srcStoreID uint64 , storesStat statistics . StoreHotPeersStat ) ( dstStoreID uint64 ) { srcBytesRate := storesStat [ srcStoreID ] . FutureBytesRate srcCount := len ( storesStat [ srcStoreID ] . Stats ) var ( minBytesRate = srcBytesRate * hotRegionScheduleFactor - regionBytesRate minCount = math . MaxInt32 ) for storeID := range candidates { if s , ok := storesStat [ storeID ] ; ok { dstCount , dstBytesRate := len ( s . Stats ) , math . Max ( s . StoreBytesRate , s . FutureBytesRate ) if srcCount < dstCount + 2 { continue } if minCount > dstCount || ( minCount == dstCount && minBytesRate > dstBytesRate ) { dstStoreID = storeID minBytesRate = dstBytesRate minCount = dstCount } } else { return storeID } } return dstStoreID }
selectDstStoreByHot selects a target store to hold the region of the source region.
selectDstStoreByHot selects a target store to hold the region of the source region .
// pick by count // ensure srcCount >= dstCount after the operation.