CreateTables creates multiple tables, and returns their rewrite rules.
( dom *domain.Domain, tables []*metautil.Table, newTS uint64, )
| 83 | |
| 84 | // CreateTables creates multiple tables, and returns their rewrite rules. |
| 85 | func (rc *SnapClient) CreateTablesTest( |
| 86 | dom *domain.Domain, |
| 87 | tables []*metautil.Table, |
| 88 | newTS uint64, |
| 89 | ) (*restoreutils.RewriteRules, []*model.TableInfo, error) { |
| 90 | rc.dom = dom |
| 91 | rc.AllocTableIDs(context.TODO(), tables, false, false, nil) |
| 92 | rewriteRules := &restoreutils.RewriteRules{ |
| 93 | Data: make([]*import_sstpb.RewriteRule, 0), |
| 94 | } |
| 95 | newTables := make([]*model.TableInfo, 0, len(tables)) |
| 96 | tbMapping := map[string]int{} |
| 97 | for i, t := range tables { |
| 98 | tbMapping[t.Info.Name.String()] = i |
| 99 | } |
| 100 | rc.AllocTableIDs(context.Background(), tables, false, false, nil) |
| 101 | createdTables, err := rc.CreateTables(context.TODO(), tables, newTS) |
| 102 | if err != nil { |
| 103 | return nil, nil, err |
| 104 | } |
| 105 | for _, table := range createdTables { |
| 106 | rules := table.RewriteRule |
| 107 | rewriteRules.Data = append(rewriteRules.Data, rules.Data...) |
| 108 | newTables = append(newTables, table.Table) |
| 109 | } |
| 110 | // Let's ensure that it won't break the original order. |
| 111 | slices.SortFunc(newTables, func(i, j *model.TableInfo) int { |
| 112 | return cmp.Compare(tbMapping[i.Name.String()], tbMapping[j.Name.String()]) |
| 113 | }) |
| 114 | return rewriteRules, newTables, nil |
| 115 | } |
| 116 | |
| 117 | func (rc *SnapClient) RegisterUpdateMetaAndLoadStats( |
| 118 | builder *PipelineConcurrentBuilder, |
no test coverage detected