Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce backup data formats for cross-version compatibility. #3575

Merged
merged 4 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions posting/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -1258,3 +1258,32 @@ func (l *List) PartSplits() []uint64 {
copy(splits, l.plist.Splits)
return splits
}

// ToBackupPostingList converts a posting list into its representation used for storing backups.
func ToBackupPostingList(l *pb.PostingList) *pb.BackupPostingList {
bl := pb.BackupPostingList{}
if l == nil {
return &bl
}

bl.Uids = codec.Decode(l.Pack, 0)
bl.Postings = l.Postings
bl.CommitTs = l.CommitTs
bl.Splits = l.Splits
return &bl
}

// FromBackupPostingList converts a posting list in the format used for backups to a
// normal posting list.
func FromBackupPostingList(bl *pb.BackupPostingList) *pb.PostingList {
l := pb.PostingList{}
if bl == nil {
return &l
}

l.Pack = codec.Encode(bl.Uids, blockSize)
l.Postings = bl.Postings
l.CommitTs = bl.CommitTs
l.Splits = bl.Splits
return &l
}
19 changes: 19 additions & 0 deletions protos/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,23 @@ message ExportRequest {
string format = 4;
}

// A key stored in the format used for writing backups.
message BackupKey {
bytes byteType = 1;
string attr = 2;
uint64 uid = 3;
uint64 start_uid = 4;
string term = 5;
uint32 count = 6;
bytes byte_prefix = 7;
}

// A posting list stored in the format used for writing backups.
message BackupPostingList {
repeated uint64 uids = 1;
repeated Posting postings = 2;
uint64 commit_ts = 3;
repeated uint64 splits = 4;
}

// vim: noexpandtab sw=2 ts=2
Loading