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 Hybrid vector clock #786

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ func (c *Client) ListChangeSummaries(
seq,
snapshotMeta.Msg.Lamport,
snapshotMeta.Msg.Snapshot,
snapshotMeta.Msg.SyncedVectorMap,
)

if err != nil {
Expand Down
15 changes: 8 additions & 7 deletions api/converter/from_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ func FromChangePack(pbPack *api.ChangePack) (*change.Pack, error) {
return nil, err
}

syncedVectorMap, err := time.NewSyncedVectorMapFromJSON(pbPack.SyncedVectorMap)
if err != nil {
return nil, err
}

return &change.Pack{
DocumentKey: key.Key(pbPack.DocumentKey),
Checkpoint: fromCheckpoint(pbPack.Checkpoint),
Changes: changes,
Snapshot: pbPack.Snapshot,
MinSyncedTicket: minSyncedTicket,
IsRemoved: pbPack.IsRemoved,
SyncedVectorMap: syncedVectorMap,
}, nil
}

Expand Down Expand Up @@ -136,6 +142,7 @@ func FromChanges(pbChanges []*api.Change) ([]*change.Change, error) {
pbChange.Message,
ops,
FromPresenceChange(pbChange.PresenceChange),
pbChange.VectorClock,
))
}

Expand Down Expand Up @@ -372,12 +379,6 @@ func fromEdit(pbEdit *api.Operation_Edit) (*operations.Edit, error) {
if err != nil {
return nil, err
}
createdAtMapByActor, err := fromCreatedAtMapByActor(
pbEdit.CreatedAtMapByActor,
)
if err != nil {
return nil, err
}
executedAt, err := fromTimeTicket(pbEdit.ExecutedAt)
if err != nil {
return nil, err
Expand All @@ -386,7 +387,7 @@ func fromEdit(pbEdit *api.Operation_Edit) (*operations.Edit, error) {
parentCreatedAt,
from,
to,
createdAtMapByActor,
pbEdit.VectorClock,
pbEdit.Content,
pbEdit.Attributes,
executedAt,
Expand Down
15 changes: 8 additions & 7 deletions api/converter/to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ func ToChanges(changes []*change.Change) ([]*api.Change, error) {
Message: c.Message(),
Operations: pbOperations,
PresenceChange: ToPresenceChange(c.PresenceChange()),
VectorClock: c.VectorClock(),
})
}

Expand Down Expand Up @@ -308,13 +309,13 @@ func toRemove(remove *operations.Remove) (*api.Operation_Remove_, error) {
func toEdit(e *operations.Edit) (*api.Operation_Edit_, error) {
return &api.Operation_Edit_{
Edit: &api.Operation_Edit{
ParentCreatedAt: ToTimeTicket(e.ParentCreatedAt()),
From: toTextNodePos(e.From()),
To: toTextNodePos(e.To()),
CreatedAtMapByActor: toCreatedAtMapByActor(e.CreatedAtMapByActor()),
Content: e.Content(),
Attributes: e.Attributes(),
ExecutedAt: ToTimeTicket(e.ExecutedAt()),
ParentCreatedAt: ToTimeTicket(e.ParentCreatedAt()),
From: toTextNodePos(e.From()),
To: toTextNodePos(e.To()),
VectorClock: e.VectorClock(),
Content: e.Content(),
Attributes: e.Attributes(),
ExecutedAt: ToTimeTicket(e.ExecutedAt()),
},
}, nil
}
Expand Down
215 changes: 113 additions & 102 deletions api/yorkie/v1/admin.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/yorkie/v1/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ message GetSnapshotMetaRequest {
message GetSnapshotMetaResponse {
bytes snapshot = 1;
int64 lamport = 2 [jstype = JS_STRING];
string synced_vector_map = 3;
}

message SearchDocumentsRequest {
Expand Down
Loading
Loading