FromBackupKey takes a key in the format used for backups and converts it to a key.
(backupKey *pb.BackupKey)
| 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 { |
| 450 | if backupKey == nil { |
| 451 | return nil |
| 452 | } |
| 453 | |
| 454 | attr := NamespaceAttr(backupKey.Namespace, backupKey.Attr) |
| 455 | |
| 456 | var key []byte |
| 457 | switch backupKey.Type { |
| 458 | case pb.BackupKey_DATA: |
| 459 | key = DataKey(attr, backupKey.Uid) |
| 460 | case pb.BackupKey_INDEX: |
| 461 | key = IndexKey(attr, string(backupKey.Term)) |
| 462 | case pb.BackupKey_REVERSE: |
| 463 | key = ReverseKey(attr, backupKey.Uid) |
| 464 | case pb.BackupKey_COUNT: |
| 465 | key = CountKey(attr, backupKey.Count, false) |
| 466 | case pb.BackupKey_COUNT_REV: |
| 467 | key = CountKey(attr, backupKey.Count, true) |
| 468 | case pb.BackupKey_SCHEMA: |
| 469 | key = SchemaKey(attr) |
| 470 | case pb.BackupKey_TYPE: |
| 471 | key = TypeKey(attr) |
| 472 | } |
| 473 | |
| 474 | if backupKey.StartUid > 0 { |
| 475 | var err error |
| 476 | key, err = SplitKey(key, backupKey.StartUid) |
| 477 | Check(err) |
| 478 | } |
| 479 | return key |
| 480 | } |
| 481 | |
| 482 | // SchemaPrefix returns the prefix for Schema keys. |
| 483 | func SchemaPrefix() []byte { |
no test coverage detected