Documentation ¶
Index ¶
Constants ¶
const ( SplitRetryTimes = 16 SplitWaitMaxRetryTimes = 64 SplitWaitInterval = 8 * time.Millisecond SplitMaxWaitInterval = time.Second ScatterWaitMaxRetryTimes = 128 ScatterWaitInterval = 50 * time.Millisecond ScatterMaxWaitInterval = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // GetStore gets a store by a store id. GetStore(ctx context.Context, storeID uint64) (*metapb.Store, error) // GetRegion gets a region which includes a specified key. GetRegion(ctx context.Context, key []byte) (*RegionInfo, error) // GetRegionByID gets a region by a region id. GetRegionByID(ctx context.Context, regionID uint64) (*RegionInfo, error) // SplitRegion splits a region from a key, if key is not included in the region, it will return nil. // note: the key should not be encoded SplitRegion(ctx context.Context, regionInfo *RegionInfo, key []byte) (*RegionInfo, error) // ScatterRegion scatters a specified region. ScatterRegion(ctx context.Context, regionInfo *RegionInfo) error // GetOperator gets the status of operator of the specified region. GetOperator(ctx context.Context, regionID uint64) (*pdpb.GetOperatorResponse, error) // ScanRegion gets a list of regions, starts from the region that contains key. // Limit limits the maximum number of regions returned. ScanRegions(ctx context.Context, key, endKey []byte, limit int) ([]*RegionInfo, error) }
Client is a external client used by RegionSplitter.
type Range ¶
Range represents a range of keys.
func (*Range) Less ¶
Less compares a range with a btree.Item
type RangeIterator ¶
RangeIterator allows callers of Ascend to iterate in-order over portions of the tree. When this function returns false, iteration will stop and the associated Ascend function will immediately return.
type RangeTree ¶
type RangeTree struct {
// contains filtered or unexported fields
}
RangeTree stores the ranges in an orderly manner. All the ranges it stored do not overlap.
func (*RangeTree) Ascend ¶
func (rt *RangeTree) Ascend(iterator RangeIterator)
Ascend calls the iterator for every value in the tree within [first, last], until the iterator returns false.
func (*RangeTree) Find ¶
Find returns nil or a range in the range tree
type RegionInfo ¶
RegionInfo includes a region and the leader of the region.
type RegionSplitter ¶
type RegionSplitter struct {
// contains filtered or unexported fields
}
RegionSplitter is a executor of region split by rules.
func NewRegionSplitter ¶
func NewRegionSplitter(client Client) *RegionSplitter
NewRegionSplitter returns a new RegionSplitter.
func (*RegionSplitter) Split ¶
func (rs *RegionSplitter) Split(ctx context.Context, ranges []Range, rewriteRules *RewriteRules) error
Split executes a region split. It will split regions by the rewrite rules, then it will split regions by the end key of each range. tableRules includes the prefix of a table, since some ranges may have a prefix with record sequence or index sequence. note: all ranges and rewrite rules must have raw key.
type RewriteRules ¶
type RewriteRules struct { Table []*import_sstpb.RewriteRule Data []*import_sstpb.RewriteRule }