Copy deltas
This commit is contained in:
parent
7ef4114835
commit
9dc16deae2
@ -31,12 +31,12 @@ struct CommitInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Transaction {
|
struct Transaction {
|
||||||
Transaction(coordinator::Hlc start_timestamp, CommitInfo commit_info, uint64_t command_id,
|
Transaction(coordinator::Hlc start_timestamp, CommitInfo new_commit_info, uint64_t command_id, bool must_abort,
|
||||||
const std::list<Delta> &deltas, bool must_abort, bool is_aborted, IsolationLevel isolation_level)
|
bool is_aborted, IsolationLevel isolation_level)
|
||||||
: start_timestamp{start_timestamp},
|
: start_timestamp{start_timestamp},
|
||||||
commit_info{std::make_unique<CommitInfo>(commit_info)},
|
commit_info{std::make_unique<CommitInfo>(new_commit_info)},
|
||||||
command_id(command_id),
|
command_id(command_id),
|
||||||
deltas(CopyDeltas(deltas)),
|
deltas(CopyDeltas(commit_info.get())),
|
||||||
must_abort(must_abort),
|
must_abort(must_abort),
|
||||||
is_aborted(is_aborted),
|
is_aborted(is_aborted),
|
||||||
isolation_level(isolation_level){};
|
isolation_level(isolation_level){};
|
||||||
@ -64,10 +64,50 @@ struct Transaction {
|
|||||||
|
|
||||||
~Transaction() {}
|
~Transaction() {}
|
||||||
|
|
||||||
std::list<Delta> CopyDeltas(const std::list<Delta> &deltas) const { return std::list<Delta>{}; }
|
std::list<Delta> CopyDeltas(CommitInfo *commit_info) const {
|
||||||
|
std::list<Delta> copied_deltas;
|
||||||
|
for (const auto &delta : deltas) {
|
||||||
|
switch (delta.action) {
|
||||||
|
case Delta::Action::DELETE_OBJECT:
|
||||||
|
copied_deltas.emplace_back(Delta::DeleteObjectTag{}, commit_info, command_id);
|
||||||
|
break;
|
||||||
|
case Delta::Action::RECREATE_OBJECT:
|
||||||
|
copied_deltas.emplace_back(Delta::RecreateObjectTag{}, commit_info, command_id);
|
||||||
|
break;
|
||||||
|
case Delta::Action::ADD_LABEL:
|
||||||
|
copied_deltas.emplace_back(Delta::AddLabelTag{}, delta.label, commit_info, command_id);
|
||||||
|
break;
|
||||||
|
case Delta::Action::REMOVE_LABEL:
|
||||||
|
copied_deltas.emplace_back(Delta::RemoveLabelTag{}, delta.label, commit_info, command_id);
|
||||||
|
break;
|
||||||
|
case Delta::Action::ADD_IN_EDGE:
|
||||||
|
copied_deltas.emplace_back(Delta::AddInEdgeTag{}, delta.vertex_edge.edge_type, delta.vertex_edge.vertex_id,
|
||||||
|
delta.vertex_edge.edge, commit_info, command_id);
|
||||||
|
break;
|
||||||
|
case Delta::Action::ADD_OUT_EDGE:
|
||||||
|
copied_deltas.emplace_back(Delta::AddOutEdgeTag{}, delta.vertex_edge.edge_type, delta.vertex_edge.vertex_id,
|
||||||
|
delta.vertex_edge.edge, commit_info, command_id);
|
||||||
|
break;
|
||||||
|
case Delta::Action::REMOVE_IN_EDGE:
|
||||||
|
copied_deltas.emplace_back(Delta::RemoveInEdgeTag{}, delta.vertex_edge.edge_type, delta.vertex_edge.vertex_id,
|
||||||
|
delta.vertex_edge.edge, commit_info, command_id);
|
||||||
|
break;
|
||||||
|
case Delta::Action::REMOVE_OUT_EDGE:
|
||||||
|
copied_deltas.emplace_back(Delta::RemoveOutEdgeTag{}, delta.vertex_edge.edge_type,
|
||||||
|
delta.vertex_edge.vertex_id, delta.vertex_edge.edge, commit_info, command_id);
|
||||||
|
break;
|
||||||
|
case Delta::Action::SET_PROPERTY:
|
||||||
|
copied_deltas.emplace_back(Delta::SetPropertyTag{}, delta.property.key, delta.property.value, commit_info,
|
||||||
|
command_id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return copied_deltas;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This does not solve the whole problem of copying deltas
|
||||||
Transaction Clone() const {
|
Transaction Clone() const {
|
||||||
return {start_timestamp, *commit_info, command_id, deltas, must_abort, is_aborted, isolation_level};
|
return {start_timestamp, *commit_info, command_id, must_abort, is_aborted, isolation_level};
|
||||||
}
|
}
|
||||||
|
|
||||||
coordinator::Hlc start_timestamp;
|
coordinator::Hlc start_timestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user