@@ -146,6 +146,7 @@ func walkLeafMetaFile(
146146
147147// Table wraps the schema and files of a table.
148148type Table struct {
149+ << << << < HEAD
149150 DB * model.DBInfo
150151 Info * model.TableInfo
151152 Crc64Xor uint64
@@ -154,6 +155,18 @@ type Table struct {
154155 Files []* backuppb.File
155156 TiFlashReplicas int
156157 Stats * util.JSONTable
158+ == == == =
159+ DB * model.DBInfo
160+ Info * model.TableInfo
161+ Crc64Xor uint64
162+ TotalKvs uint64
163+ TotalBytes uint64
164+ Files []* backuppb.File
165+ TotalKvsMap map [int64 ]uint64
166+ TiFlashReplicas int
167+ Stats * util.JSONTable
168+ StatsFileIndexes []* backuppb.StatsFileIndex
169+ >> >> >> > e589efdb9a8 (br : fix stats meta count is zero if no checksum 8.5 (#63420 ))
157170}
158171
159172// MetaReader wraps a reader to read both old and new version of backupmeta.
@@ -241,6 +254,14 @@ func (stats ChecksumStats) ChecksumExists() bool {
241254 return true
242255}
243256
257+ func CalculateTotalKvsOnFiles (files []* backuppb.File ) uint64 {
258+ totalKvs := uint64 (0 )
259+ for _ , file := range files {
260+ totalKvs += file .TotalKvs
261+ }
262+ return totalKvs
263+ }
264+
244265// CalculateChecksumStatsOnFiles returns the ChecksumStats for the given files
245266func CalculateChecksumStatsOnFiles (files []* backuppb.File ) ChecksumStats {
246267 var stats ChecksumStats
@@ -382,13 +403,19 @@ func (reader *MetaReader) ReadSchemasFiles(ctx context.Context, output chan<- *T
382403 }
383404 if tableInfo != nil {
384405 if fileMap != nil {
406+ << << << < HEAD
385407 if files , ok := fileMap [tableInfo .ID ]; ok {
408+ == == == =
409+ if files , ok := fileMap [table .Info .ID ]; ok {
410+ table .TotalKvsMap [table .Info .ID ] = CalculateTotalKvsOnFiles (files )
411+ >> >> >> > e589efdb9a8 (br : fix stats meta count is zero if no checksum 8.5 (#63420 ))
386412 table .Files = append (table .Files , files ... )
387413 }
388414 if tableInfo .Partition != nil {
389415 // Partition table can have many table IDs (partition IDs).
390416 for _ , p := range tableInfo .Partition .Definitions {
391417 if files , ok := fileMap [p .ID ]; ok {
418+ table .TotalKvsMap [p .ID ] = CalculateTotalKvsOnFiles (files )
392419 table .Files = append (table .Files , files ... )
393420 }
394421 }
@@ -414,6 +441,47 @@ func (reader *MetaReader) ReadSchemasFiles(ctx context.Context, output chan<- *T
414441 }
415442}
416443
444+ << << << < HEAD
445+ == == == =
446+ func parseSchemaFile (s * backuppb.Schema ) (* Table , error ) {
447+ dbInfo := & model.DBInfo {}
448+ if err := json .Unmarshal (s .Db , dbInfo ); err != nil {
449+ return nil , errors .Trace (err )
450+ }
451+
452+ var tableInfo * model.TableInfo
453+ if s .Table != nil {
454+ tableInfo = & model.TableInfo {}
455+ if err := json .Unmarshal (s .Table , tableInfo ); err != nil {
456+ return nil , errors .Trace (err )
457+ }
458+ }
459+ var stats * util.JSONTable
460+ if s .Stats != nil {
461+ stats = & util.JSONTable {}
462+ if err := json .Unmarshal (s .Stats , stats ); err != nil {
463+ return nil , errors .Trace (err )
464+ }
465+ }
466+ var statsFileIndexes []* backuppb.StatsFileIndex
467+ if len (s .StatsIndex ) > 0 {
468+ statsFileIndexes = s .StatsIndex
469+ }
470+
471+ return & Table {
472+ DB : dbInfo ,
473+ Info : tableInfo ,
474+ Crc64Xor : s .Crc64Xor ,
475+ TotalKvs : s .TotalKvs ,
476+ TotalBytes : s .TotalBytes ,
477+ TotalKvsMap : make (map [int64 ]uint64 ),
478+ TiFlashReplicas : int (s .TiflashReplicas ),
479+ Stats : stats ,
480+ StatsFileIndexes : statsFileIndexes ,
481+ }, nil
482+ }
483+
484+ >> >> >> > e589efdb9a8 (br : fix stats meta count is zero if no checksum 8.5 (#63420 ))
417485func receiveBatch (
418486 ctx context .Context , errCh chan error , ch < - chan interface {}, maxBatchSize int ,
419487 collectItem func (interface {}) error ,
0 commit comments