@@ -156,11 +156,6 @@ type Table struct {
156
156
Stats * util.JSONTable
157
157
}
158
158
159
- // NoChecksum checks whether the table has a calculated checksum.
160
- func (tbl * Table ) NoChecksum () bool {
161
- return tbl .Crc64Xor == 0 && tbl .TotalKvs == 0 && tbl .TotalBytes == 0
162
- }
163
-
164
159
// MetaReader wraps a reader to read both old and new version of backupmeta.
165
160
type MetaReader struct {
166
161
storage storage.ExternalStorage
@@ -225,14 +220,38 @@ func (reader *MetaReader) readDataFiles(ctx context.Context, output func(*backup
225
220
}
226
221
227
222
// ArchiveSize return the size of Archive data
228
- func ( * MetaReader ) ArchiveSize (_ context. Context , files []* backuppb.File ) uint64 {
223
+ func ArchiveSize (files []* backuppb.File ) uint64 {
229
224
total := uint64 (0 )
230
225
for _ , file := range files {
231
226
total += file .Size_
232
227
}
233
228
return total
234
229
}
235
230
231
+ type ChecksumStats struct {
232
+ Crc64Xor uint64
233
+ TotalKvs uint64
234
+ TotalBytes uint64
235
+ }
236
+
237
+ func (stats ChecksumStats ) ChecksumExists () bool {
238
+ if stats .Crc64Xor == 0 && stats .TotalKvs == 0 && stats .TotalBytes == 0 {
239
+ return false
240
+ }
241
+ return true
242
+ }
243
+
244
+ // CalculateChecksumStatsOnFiles returns the ChecksumStats for the given files
245
+ func CalculateChecksumStatsOnFiles (files []* backuppb.File ) ChecksumStats {
246
+ var stats ChecksumStats
247
+ for _ , file := range files {
248
+ stats .Crc64Xor ^= file .Crc64Xor
249
+ stats .TotalKvs += file .TotalKvs
250
+ stats .TotalBytes += file .TotalBytes
251
+ }
252
+ return stats
253
+ }
254
+
236
255
// ReadDDLs reads the ddls from the backupmeta.
237
256
// This function is compatible with the old backupmeta.
238
257
func (reader * MetaReader ) ReadDDLs (ctx context.Context ) ([]byte , error ) {
0 commit comments