Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer committed Mar 12, 2024
1 parent eae73b8 commit 6b45741
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions br/pkg/restore/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ type DrainResult struct {
TablesToSend []CreatedTable
// BlankTablesAfterSend are tables that will be full-restored after this batch send.
BlankTablesAfterSend []CreatedTable
RewriteRules map[int64]*RewriteRules
Ranges []rtree.Range
// RewriteRules are the rewrite rules for the tables.
// the key is the table id after rewritten.
RewriteRulesMap map[int64]*RewriteRules
Ranges []rtree.Range
// Record which part of ranges belongs to the table
TableEndOffsetInRanges []int
}
Expand All @@ -244,7 +246,7 @@ func (result DrainResult) Files() []TableIDWithFiles {
files = append(files, rg.Files...)
}
var rules *RewriteRules
if r, ok := result.RewriteRules[tableID]; ok {
if r, ok := result.RewriteRulesMap[tableID]; ok {
rules = r
}
tableIDWithFiles = append(tableIDWithFiles, TableIDWithFiles{
Expand All @@ -264,7 +266,7 @@ func newDrainResult() DrainResult {
return DrainResult{
TablesToSend: make([]CreatedTable, 0),
BlankTablesAfterSend: make([]CreatedTable, 0),
RewriteRules: EmptyRewriteRulesMap(),
RewriteRulesMap: EmptyRewriteRulesMap(),
Ranges: make([]rtree.Range, 0),
TableEndOffsetInRanges: make([]int, 0),
}
Expand Down Expand Up @@ -332,7 +334,7 @@ func (b *Batcher) drainRanges() DrainResult {
thisTableLen := len(thisTable.Range)
collected := len(result.Ranges)

result.RewriteRules[thisTable.Table.ID] = thisTable.RewriteRule
result.RewriteRulesMap[thisTable.Table.ID] = thisTable.RewriteRule
result.TablesToSend = append(result.TablesToSend, thisTable.CreatedTable)

// the batch is full, we should stop here!
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/restore/batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (sender *drySender) RestoreBatch(ranges restore.DrainResult) {
defer sender.mu.Unlock()
log.Info("fake restore range", rtree.ZapRanges(ranges.Ranges))
sender.nBatch++
for _, r := range ranges.RewriteRules {
for _, r := range ranges.RewriteRulesMap {
sender.rewriteRules.Append(*r)
}
sender.ranges = append(sender.ranges, ranges.Ranges...)
Expand Down

0 comments on commit 6b45741

Please sign in to comment.