From 6a4e2d8d648792ec6542b6712a0901e2f0e4ff99 Mon Sep 17 00:00:00 2001 From: Kruno Tomola Fabro <krunotf@memgraph.io> Date: Sun, 28 Aug 2016 21:10:13 +0100 Subject: [PATCH] Final barrier commit. --- CMakeLists.txt | 1 + include/barrier/trans.hpp | 1 + .../bolt/v1/serialization/bolt_serializer.hpp | 27 +---------------- include/storage/edge_accessor.hpp | 4 +-- include/storage/edge_x_vertex.hpp | 4 +-- .../bolt/v1/serialization/bolt_serializer.cpp | 30 +++++++++++++++++++ 6 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 src/communication/bolt/v1/serialization/bolt_serializer.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c2d91e246..01bfbe64f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,6 +414,7 @@ set(memgraph_src_files ${src_dir}/communication/bolt/v1/states/handshake.cpp ${src_dir}/communication/bolt/v1/transport/bolt_decoder.cpp ${src_dir}/communication/bolt/v1/transport/buffer.cpp + ${src_dir}/communication/bolt/v1/serialization/bolt_serializer.cpp ${src_dir}/mvcc/id.cpp ${src_dir}/storage/vertices.cpp ${src_dir}/storage/edges.cpp diff --git a/include/barrier/trans.hpp b/include/barrier/trans.hpp index 44bba845a..b4fc8a567 100644 --- a/include/barrier/trans.hpp +++ b/include/barrier/trans.hpp @@ -6,6 +6,7 @@ #include "database/db.hpp" #include "database/db_accessor.hpp" #include "storage/edge_type/edge_type.hpp" +#include "storage/edge_x_vertex.hpp" #include "storage/label/label.hpp" // **************************** HELPER DEFINES *******************************// diff --git a/include/communication/bolt/v1/serialization/bolt_serializer.hpp b/include/communication/bolt/v1/serialization/bolt_serializer.hpp index 0f8ee6b2e..e34323cdd 100644 --- a/include/communication/bolt/v1/serialization/bolt_serializer.hpp +++ b/include/communication/bolt/v1/serialization/bolt_serializer.hpp @@ -4,7 +4,6 @@ #include "communication/bolt/v1/transport/bolt_encoder.hpp" #include "storage/edge_accessor.hpp" -#include "storage/edge_x_vertex.hpp" #include "storage/vertex_accessor.hpp" #include "storage/model/properties/all.hpp" @@ -73,31 +72,7 @@ public: * } * */ - void write(const EdgeAccessor &edge) - { - // write signatures for the edge struct and edge data type - encoder.write_struct_header(5); - encoder.write(underlying_cast(pack::Relationship)); - - // write the identifier for the node - encoder.write_integer(edge.id()); - - encoder.write_integer(edge.from().id()); - encoder.write_integer(edge.to().id()); - - // write the type of the edge - encoder.write_string(edge.edge_type()); - - // write the property map - auto props = edge.properties(); - - encoder.write_map_header(props.size()); - - for (auto &prop : props) { - write(prop.first.family_name()); - write(*prop.second); - } - } + void write(const EdgeAccessor &edge); void write(const Property &prop) { accept(prop, *this); } diff --git a/include/storage/edge_accessor.hpp b/include/storage/edge_accessor.hpp index 2070e5dec..ddf638494 100644 --- a/include/storage/edge_accessor.hpp +++ b/include/storage/edge_accessor.hpp @@ -23,7 +23,7 @@ public: const EdgeType &edge_type() const; - const auto from() const; + auto from() const; - const auto to() const; + auto to() const; }; diff --git a/include/storage/edge_x_vertex.hpp b/include/storage/edge_x_vertex.hpp index f364ec0c4..9a92ea1fc 100644 --- a/include/storage/edge_x_vertex.hpp +++ b/include/storage/edge_x_vertex.hpp @@ -5,12 +5,12 @@ #include "storage/edge_accessor.hpp" #include "storage/vertex_accessor.hpp" -const auto EdgeAccessor::from() const +auto EdgeAccessor::from() const { return VertexAccessor(this->vlist->from(), this->db); } -const auto EdgeAccessor::to() const +auto EdgeAccessor::to() const { return VertexAccessor(this->vlist->to(), this->db); } diff --git a/src/communication/bolt/v1/serialization/bolt_serializer.cpp b/src/communication/bolt/v1/serialization/bolt_serializer.cpp new file mode 100644 index 000000000..4ff4c7f56 --- /dev/null +++ b/src/communication/bolt/v1/serialization/bolt_serializer.cpp @@ -0,0 +1,30 @@ +#include "communication/bolt/v1/serialization/bolt_serializer.hpp" + +#include "storage/edge_x_vertex.hpp" + +template <class Stream> +void bolt::BoltSerializer<Stream>::write(const EdgeAccessor &edge) +{ + // write signatures for the edge struct and edge data type + encoder.write_struct_header(5); + encoder.write(underlying_cast(pack::Relationship)); + + // write the identifier for the node + encoder.write_integer(edge.id()); + + encoder.write_integer(edge.from().id()); + encoder.write_integer(edge.to().id()); + + // write the type of the edge + encoder.write_string(edge.edge_type()); + + // write the property map + auto props = edge.properties(); + + encoder.write_map_header(props.size()); + + for (auto &prop : props) { + write(prop.first.family_name()); + write(*prop.second); + } +}