ToBackupKey returns the key in the format used for writing backups.
()
| 416 | |
| 417 | // ToBackupKey returns the key in the format used for writing backups. |
| 418 | func (p ParsedKey) ToBackupKey() *pb.BackupKey { |
| 419 | ns, attr := ParseNamespaceAttr(p.Attr) |
| 420 | key := pb.BackupKey{} |
| 421 | key.Namespace = ns |
| 422 | key.Attr = attr |
| 423 | key.Uid = p.Uid |
| 424 | key.StartUid = p.StartUid |
| 425 | key.Term = []byte(p.Term) |
| 426 | key.Count = p.Count |
| 427 | |
| 428 | switch { |
| 429 | case p.IsData(): |
| 430 | key.Type = pb.BackupKey_DATA |
| 431 | case p.IsIndex(): |
| 432 | key.Type = pb.BackupKey_INDEX |
| 433 | case p.IsReverse(): |
| 434 | key.Type = pb.BackupKey_REVERSE |
| 435 | case p.IsCount(): |
| 436 | key.Type = pb.BackupKey_COUNT |
| 437 | case p.IsCountRev(): |
| 438 | key.Type = pb.BackupKey_COUNT_REV |
| 439 | case p.IsSchema(): |
| 440 | key.Type = pb.BackupKey_SCHEMA |
| 441 | case p.IsType(): |
| 442 | key.Type = pb.BackupKey_TYPE |
| 443 | } |
| 444 | |
| 445 | return &key |
| 446 | } |
| 447 | |
| 448 | // FromBackupKey takes a key in the format used for backups and converts it to a key. |
| 449 | func FromBackupKey(backupKey *pb.BackupKey) []byte { |
no test coverage detected