func (r *RangeCluster) SetTolerantSizeRatio(ratio float64) {
	r.tolerantSizeRatio = ratio
}
SetTolerantSizeRatio sets the tolerant size ratio.
package schedule
import (
	"github.com/gogo/protobuf/proto"
	"github.com/pingcap/kvproto/pkg/pdpb"
	"github.com/tikv/pd/server/core"
	"github.com/tikv/pd/server/schedule/opt"
)
type RangeCluster struct {
	opt.Cluster
	subCluster        *core.BasicCluster  
	tolerantSizeRatio float64
}
func GenRangeCluster(cluster opt.Cluster, startKey, endKey []byte) *RangeCluster {
	subCluster := core.NewBasicCluster()
	for _, r := range cluster.ScanRegions(startKey, endKey, -1) {
		subCluster.Regions.SetRegion(r)
	}
	return &RangeCluster{
		Cluster:    cluster,
		subCluster: subCluster,
	}
}
func (r *RangeCluster) updateStoreInfo(s *core.StoreInfo) *core.StoreInfo {
	id := s.GetID()
	used := float64(s.GetUsedSize()) / (1 << 20)
	if used == 0 {
		return s
	}
	amplification := float64(s.GetRegionSize()) / used
	leaderCount := r.subCluster.GetStoreLeaderCount(id)
	leaderSize := r.subCluster.GetStoreLeaderRegionSize(id)
	regionCount := r.subCluster.GetStoreRegionCount(id)
	regionSize := r.subCluster.GetStoreRegionSize(id)
	pendingPeerCount := r.subCluster.GetStorePendingPeerCount(id)
	newStats := proto.Clone(s.GetStoreStats()).(*pdpb.StoreStats)
	newStats.UsedSize = uint64(float64(regionSize)/amplification) * (1 << 20)
	newStats.Available = s.GetCapacity() - newStats.UsedSize
	newStore := s.Clone(
		core.SetNewStoreStats(newStats),  
		core.SetLeaderCount(leaderCount),
		core.SetRegionCount(regionCount),
		core.SetPendingPeerCount(pendingPeerCount),
		core.SetLeaderSize(leaderSize),
		core.SetRegionSize(regionSize),
	)
	return newStore
}
func (r *RangeCluster) GetStore(id uint64) *core.StoreInfo {
	s := r.Cluster.GetStore(id)
	if s == nil {
		return nil
	}
	return r.updateStoreInfo(s)
}
func (r *RangeCluster) GetStores() []*core.StoreInfo {
	stores := r.Cluster.GetStores()
	newStores := make([]*core.StoreInfo, 0, len(stores))
	for _, s := range stores {
		newStores = append(newStores, r.updateStoreInfo(s))
	}
	return newStores
}