Documentation ¶
Index ¶
- Constants
- func EmptyRewriteRulesMap() map[int64]*RewriteRules
- func EncodeKeyPrefix(key []byte) []byte
- func FindMatchedRewriteRule(file AppliedFile, rules *RewriteRules) *import_sstpb.RewriteRule
- func GetIndexIDMap(newTable, oldTable *model.TableInfo) map[int64]int64
- func GetPartitionIDMap(newTable, oldTable *model.TableInfo) map[int64]int64
- func GetRewriteEncodedKeys(file AppliedFile, rewriteRules *RewriteRules) (startKey, endKey []byte, err error)
- func GetRewriteRawKeys(file AppliedFile, rewriteRules *RewriteRules) (startKey, endKey []byte, err error)
- func GetRewriteRulesMap(newTable, oldTable *model.TableInfo, newTimeStamp uint64, getDetailRule bool) map[int64]*RewriteRules
- func GetRewriteTableID(tableID int64, rewriteRules *RewriteRules) int64
- func GetTableIDMap(newTable, oldTable *model.TableInfo) map[int64]int64
- func RewriteAndEncodeRawKey(key []byte, rule *import_sstpb.RewriteRule) []byte
- func RewriteRange(rg *rtree.Range, rewriteRules *RewriteRules) (*rtree.Range, error)
- func TruncateTS(key []byte) []byte
- func ValidateFileRewriteRule(file *backuppb.File, rewriteRules *RewriteRules) error
- type AppliedFile
- type MergeRangesStat
- type RewriteRules
Constants ¶
const ( WriteCFName = "write" DefaultCFName = "default" )
Variables ¶
This section is empty.
Functions ¶
func EmptyRewriteRulesMap ¶
func EmptyRewriteRulesMap() map[int64]*RewriteRules
EmptyRewriteRule make a map of new, empty rewrite rules.
func EncodeKeyPrefix ¶
func FindMatchedRewriteRule ¶
func FindMatchedRewriteRule(file AppliedFile, rules *RewriteRules) *import_sstpb.RewriteRule
func GetIndexIDMap ¶
GetIndexIDMap creates a map maping old indexID to new indexID.
func GetPartitionIDMap ¶
GetPartitionIDMap creates a map maping old physical ID to new physical ID.
func GetRewriteEncodedKeys ¶
func GetRewriteEncodedKeys(file AppliedFile, rewriteRules *RewriteRules) (startKey, endKey []byte, err error)
GetRewriteRawKeys rewrites rules to the encoded key
func GetRewriteRawKeys ¶
func GetRewriteRawKeys(file AppliedFile, rewriteRules *RewriteRules) (startKey, endKey []byte, err error)
GetRewriteRawKeys rewrites rules to the raw key.
func GetRewriteRulesMap ¶
func GetRewriteTableID ¶
func GetRewriteTableID(tableID int64, rewriteRules *RewriteRules) int64
GetRewriteTableID gets rewrite table id by the rewrite rule and original table id
func GetTableIDMap ¶
GetTableIDMap creates a map maping old tableID to new tableID.
func RewriteAndEncodeRawKey ¶
func RewriteAndEncodeRawKey(key []byte, rule *import_sstpb.RewriteRule) []byte
func RewriteRange ¶
func TruncateTS ¶
func ValidateFileRewriteRule ¶
func ValidateFileRewriteRule(file *backuppb.File, rewriteRules *RewriteRules) error
ValidateFileRewriteRule uses rewrite rules to validate the ranges of a file.
Types ¶
type AppliedFile ¶
AppliedFile has two types for now. 1. SST file used by full backup/restore. 2. KV file used by pitr restore.
type MergeRangesStat ¶
type MergeRangesStat struct { TotalFiles int TotalWriteCFFile int TotalDefaultCFFile int TotalRegions int RegionKeysAvg int RegionBytesAvg int MergedRegions int MergedRegionKeysAvg int MergedRegionBytesAvg int }
MergeRangesStat holds statistics for the MergeRanges.
func MergeAndRewriteFileRanges ¶
func MergeAndRewriteFileRanges( files []*backuppb.File, rewriteRules *RewriteRules, splitSizeBytes, splitKeyCount uint64, ) ([]rtree.RangeStats, *MergeRangesStat, error)
MergeAndRewriteFileRanges returns ranges of the files are merged based on splitSizeBytes and splitKeyCount.
By merging small ranges, it speeds up restoring a backup that contains many small ranges (regions) as it reduces split region and scatter region.
type RewriteRules ¶
type RewriteRules struct { Data []*import_sstpb.RewriteRule OldKeyspace []byte NewKeyspace []byte // used to record checkpoint data NewTableID int64 }
RewriteRules contains rules for rewriting keys of tables.
func EmptyRewriteRule ¶
func EmptyRewriteRule() *RewriteRules
EmptyRewriteRule make a new, empty rewrite rule.
func GetRewriteRuleOfTable ¶
func GetRewriteRuleOfTable( oldTableID, newTableID int64, newTimeStamp uint64, indexIDs map[int64]int64, getDetailRule bool, ) *RewriteRules
GetRewriteRuleOfTable returns a rewrite rule from t_{oldID} to t_{newID}.
func GetRewriteRules ¶
func GetRewriteRules( newTable, oldTable *model.TableInfo, newTimeStamp uint64, getDetailRule bool, ) *RewriteRules
GetRewriteRules returns the rewrite rule of the new table and the old table. getDetailRule is used for normal backup & restore. if set to true, means we collect the rules like tXXX_r, tYYY_i. if set to false, means we only collect the rules contain table_id, tXXX, tYYY.
func (*RewriteRules) Append ¶
func (r *RewriteRules) Append(other RewriteRules)
Append append its argument to this rewrite rules.
func (*RewriteRules) String ¶
func (r *RewriteRules) String() string