Add no-op state delta

Summary: No-op `StateDelta` needed for Raft protocol.

Reviewers: ipaljak

Reviewed By: ipaljak

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1784
This commit is contained in:
Matija Santl 2019-01-02 14:59:45 +01:00
parent 72ee3fda85
commit 0f8571a926
2 changed files with 14 additions and 1 deletions

View File

@ -126,6 +126,11 @@ StateDelta StateDelta::DropIndex(tx::TransactionId tx_id, storage::Label label,
return op;
}
StateDelta StateDelta::NoOp() {
StateDelta op(StateDelta::Type::NO_OP);
return op;
}
void StateDelta::Encode(
HashedFileWriter &writer,
communication::bolt::BaseEncoder<HashedFileWriter> &encoder) const {
@ -136,6 +141,7 @@ void StateDelta::Encode(
case Type::TRANSACTION_BEGIN:
case Type::TRANSACTION_COMMIT:
case Type::TRANSACTION_ABORT:
case Type::NO_OP:
break;
case Type::CREATE_VERTEX:
encoder.WriteInt(vertex_id);
@ -215,6 +221,7 @@ std::experimental::optional<StateDelta> StateDelta::Decode(
case Type::TRANSACTION_BEGIN:
case Type::TRANSACTION_COMMIT:
case Type::TRANSACTION_ABORT:
case Type::NO_OP:
break;
case Type::CREATE_VERTEX:
DECODE_MEMBER(vertex_id, ValueInt)
@ -334,6 +341,8 @@ void StateDelta::Apply(GraphDbAccessor &dba) const {
LOG(FATAL) << "Index handling not handled in Apply";
break;
}
case Type::NO_OP:
break;
}
}

View File

@ -89,7 +89,8 @@ in StateDeltas.")
remove-vertex ;; vertex_id, check_empty
remove-edge ;; edge_id
build-index ;; label, label_name, property, property_name, unique
drop-index ;; label, label_name, property, property_name
drop-index ;; label, label_name, property, property_name
no-op ;; no-op state delta required by Raft protocol
)
(:documentation
"Defines StateDelta type. For each type the comment indicates which values
@ -98,6 +99,7 @@ omitted in the comment.")
(:serialize))
#>cpp
StateDelta() = default;
StateDelta(const enum Type &type) : type(type) {}
StateDelta(const enum Type &type, tx::TransactionId tx_id)
: type(type), transaction_id(tx_id) {}
@ -150,6 +152,8 @@ omitted in the comment.")
storage::Property property,
const std::string &property_name);
static StateDelta NoOp();
/// Applies CRUD delta to database accessor. Fails on other types of deltas
void Apply(GraphDbAccessor &dba) const;
cpp<#)