(db *badger.DB, req *pb.BackupRequest)
| 459 | } |
| 460 | |
| 461 | func NewBackupProcessor(db *badger.DB, req *pb.BackupRequest) *BackupProcessor { |
| 462 | bp := &BackupProcessor{ |
| 463 | DB: db, |
| 464 | Request: req, |
| 465 | threads: make([]*threadLocal, x.WorkerConfig.Badger.NumGoroutines), |
| 466 | } |
| 467 | if req.SinceTs > 0 && db != nil { |
| 468 | bp.txn = db.NewTransactionAt(req.ReadTs, false) |
| 469 | } |
| 470 | for i := range bp.threads { |
| 471 | buf := z.NewBuffer(32<<20, "Worker.BackupProcessor") |
| 472 | |
| 473 | bp.threads[i] = &threadLocal{ |
| 474 | Request: bp.Request, |
| 475 | buf: buf, |
| 476 | } |
| 477 | if bp.txn != nil { |
| 478 | iopt := badger.DefaultIteratorOptions |
| 479 | iopt.AllVersions = true |
| 480 | bp.threads[i].itr = bp.txn.NewIterator(iopt) |
| 481 | } |
| 482 | } |
| 483 | return bp |
| 484 | } |
| 485 | |
| 486 | func (pr *BackupProcessor) Close() { |
| 487 | for _, th := range pr.threads { |
no test coverage detected