Improve ajdusting of prev ptr
This commit is contained in:
parent
bc46a9f54b
commit
fd18ff0196
@ -238,16 +238,15 @@ void Splitter::AdjustClonedTransaction(Transaction &cloned_transaction, const Tr
|
|||||||
const auto *delta = &*delta_it;
|
const auto *delta = &*delta_it;
|
||||||
auto *cloned_delta = &*cloned_delta_it;
|
auto *cloned_delta = &*cloned_delta_it;
|
||||||
Delta *cloned_delta_prev_ptr = cloned_delta;
|
Delta *cloned_delta_prev_ptr = cloned_delta;
|
||||||
|
// The head of delta chains contain either vertex/edge as prev ptr so we adjust
|
||||||
|
// it just at the beginning of delta chain
|
||||||
|
AdjustDeltaPrevPtr(*delta, *cloned_delta_prev_ptr, cloned_transactions, cloned_edges);
|
||||||
|
|
||||||
while (delta->next != nullptr) {
|
while (delta->next != nullptr) {
|
||||||
AdjustEdgeRef(*cloned_delta, cloned_edges);
|
AdjustEdgeRef(*cloned_delta, cloned_edges);
|
||||||
|
|
||||||
// Align next ptr
|
// Align next ptr and prev ptr
|
||||||
AdjustDeltaNext(*delta, *cloned_delta, cloned_transactions);
|
AdjustDeltaNextAndPrev(*delta, *cloned_delta, cloned_transactions);
|
||||||
|
|
||||||
// Align prev ptr
|
|
||||||
if (cloned_delta_prev_ptr != nullptr) {
|
|
||||||
AdjustDeltaPrevPtr(*delta, *cloned_delta_prev_ptr, cloned_transactions, cloned_vertices, cloned_edges);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Next delta might not belong to the cloned transaction and thats
|
// TODO Next delta might not belong to the cloned transaction and thats
|
||||||
// why we skip this delta of the delta chain
|
// why we skip this delta of the delta chain
|
||||||
@ -261,7 +260,7 @@ void Splitter::AdjustClonedTransaction(Transaction &cloned_transaction, const Tr
|
|||||||
}
|
}
|
||||||
// Align prev ptr
|
// Align prev ptr
|
||||||
if (cloned_delta_prev_ptr != nullptr) {
|
if (cloned_delta_prev_ptr != nullptr) {
|
||||||
AdjustDeltaPrevPtr(*delta, *cloned_delta_prev_ptr, cloned_transactions, cloned_vertices, cloned_edges);
|
AdjustDeltaPrevPtr(*delta, *cloned_delta_prev_ptr, cloned_transactions, cloned_edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
++delta_it;
|
++delta_it;
|
||||||
@ -299,7 +298,7 @@ void Splitter::AdjustEdgeRef(Delta &cloned_delta, EdgeContainer &cloned_edges) c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Splitter::AdjustDeltaNext(const Delta &original, Delta &cloned,
|
void Splitter::AdjustDeltaNextAndPrev(const Delta &original, Delta &cloned,
|
||||||
std::map<uint64_t, std::unique_ptr<Transaction>> &cloned_transactions) {
|
std::map<uint64_t, std::unique_ptr<Transaction>> &cloned_transactions) {
|
||||||
// Get cloned_delta->next transaction, using delta->next original transaction
|
// Get cloned_delta->next transaction, using delta->next original transaction
|
||||||
// cloned_transactions key is start_timestamp
|
// cloned_transactions key is start_timestamp
|
||||||
@ -319,15 +318,16 @@ void Splitter::AdjustDeltaNext(const Delta &original, Delta &cloned,
|
|||||||
cloned_transaction_it->second->deltas, [&original](const auto &elem) { return elem.id == original.next->id; });
|
cloned_transaction_it->second->deltas, [&original](const auto &elem) { return elem.id == original.next->id; });
|
||||||
MG_ASSERT(found_cloned_delta_it != cloned_transaction_it->second->deltas.end(), "Delta with given uuid must exist!");
|
MG_ASSERT(found_cloned_delta_it != cloned_transaction_it->second->deltas.end(), "Delta with given uuid must exist!");
|
||||||
cloned.next = &*found_cloned_delta_it;
|
cloned.next = &*found_cloned_delta_it;
|
||||||
|
found_cloned_delta_it->prev.Set(&cloned);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Splitter::AdjustDeltaPrevPtr(const Delta &original, Delta &cloned,
|
void Splitter::AdjustDeltaPrevPtr(const Delta &original, Delta &cloned,
|
||||||
std::map<uint64_t, std::unique_ptr<Transaction>> &cloned_transactions,
|
std::map<uint64_t, std::unique_ptr<Transaction>> &cloned_transactions,
|
||||||
VertexContainer & /*cloned_vertices*/, EdgeContainer &cloned_edges) {
|
EdgeContainer &cloned_edges) {
|
||||||
auto ptr = original.prev.Get();
|
auto ptr = original.prev.Get();
|
||||||
switch (ptr.type) {
|
switch (ptr.type) {
|
||||||
case PreviousPtr::Type::NULLPTR: {
|
case PreviousPtr::Type::NULLPTR: {
|
||||||
// noop
|
MG_ASSERT(false, "PreviousPtr cannot be a nullptr!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PreviousPtr::Type::DELTA: {
|
case PreviousPtr::Type::DELTA: {
|
||||||
|
@ -87,12 +87,12 @@ class Splitter final {
|
|||||||
|
|
||||||
void AdjustEdgeRef(Delta &cloned_delta, EdgeContainer &cloned_edges) const;
|
void AdjustEdgeRef(Delta &cloned_delta, EdgeContainer &cloned_edges) const;
|
||||||
|
|
||||||
static void AdjustDeltaNext(const Delta &original, Delta &cloned,
|
static void AdjustDeltaNextAndPrev(const Delta &original, Delta &cloned,
|
||||||
std::map<uint64_t, std::unique_ptr<Transaction>> &cloned_transactions);
|
std::map<uint64_t, std::unique_ptr<Transaction>> &cloned_transactions);
|
||||||
|
|
||||||
static void AdjustDeltaPrevPtr(const Delta &original, Delta &cloned,
|
static void AdjustDeltaPrevPtr(const Delta &original, Delta &cloned,
|
||||||
std::map<uint64_t, std::unique_ptr<Transaction>> &cloned_transactions,
|
std::map<uint64_t, std::unique_ptr<Transaction>> &cloned_transactions,
|
||||||
VertexContainer &cloned_vertices, EdgeContainer &cloned_edges);
|
EdgeContainer &cloned_edges);
|
||||||
|
|
||||||
const LabelId primary_label_;
|
const LabelId primary_label_;
|
||||||
VertexContainer &vertices_;
|
VertexContainer &vertices_;
|
||||||
|
Loading…
Reference in New Issue
Block a user