Tidied up barrier files.

MEMGRAPH has linked/definistion errors during compile.
This commit is contained in:
Kruno Tomola Fabro 2016-08-28 20:46:30 +01:00
parent 8ace2927c9
commit e908d6588b
15 changed files with 159 additions and 169 deletions

View File

@ -454,8 +454,6 @@ set(memgraph_src_files
${src_dir}/storage/record_accessor.cpp
)
set(barrier_src_files
${src_dir}/barrier/barrier.cpp)
# STATIC library used by memgraph executables
add_library(memgraph STATIC ${memgraph_src_files})
@ -464,7 +462,6 @@ add_library(memgraph STATIC ${memgraph_src_files})
add_library(memgraph_pic STATIC ${memgraph_src_files})
set_property(TARGET memgraph_pic PROPERTY POSITION_INDEPENDENT_CODE TRUE)
add_library(barrier STATIC ${barrier_src_files})
# tests
if (TESTS)

View File

@ -14,44 +14,47 @@ namespace barrier
// barrier class defined here.
// ************ Here should be forward declarations of Sized barrier classes
class DbAccessor; // DONE // .cpp
// ACCESSORS
class DbAccessor;
class VertexAccessor;
class EdgeAccessor;
class VertexAccessor; // DONE // .cpp
class EdgeAccessor; // DONE // .cpp
// GENERIC ITERATORS
class VertexIterator;
class EdgeIterator;
class VertexIterator; // DONE // .cpp
class EdgeIterator; // DONE // .cpp
class VertexAccessIterator; // DONE // .cpp
class OutEdgesIterator; // DONE // .cpp
class InEdgesIterator; // DONE // .cpp
class VertexPropertyKey; // DONE // .cpp
class EdgePropertyKey; // DONE // .cpp
// TYPED ITERATORS
class VertexAccessIterator;
class OutEdgesIterator;
class InEdgesIterator;
// PROPERTY
class VertexPropertyKey;
class EdgePropertyKey;
template <class T>
class VertexPropertyType; // DONE // .cpp
class VertexPropertyType;
template <class T>
class EdgePropertyType; // DONE // .cpp
class EdgePropertyType;
// BOLT
template <class Stream>
class BoltSerializer; // DONE // .cpp
class BoltSerializer;
// ************ Here should be forward declarations of Unsized barrier classes
class Label; // DONE // .cpp
class EdgeType; // DONE // .cpp
class Db; // DONE // .cpp
class VertexPropertyFamily; // DONE // .cpp
class EdgePropertyFamily; // DONE // .cpp
// COMMON
class Db;
class Label;
class EdgeType;
// GENERIC INDEXES
template <class K>
class VertexIndex; // DONE // .cpp
class VertexIndex;
template <class K>
class EdgeIndex; // DONE // .cpp
class EdgeIndex;
// PROPERTY
class VertexPropertyFamily;
class EdgePropertyFamily;
// ************* Here should be defined usings
using label_ref_t = ReferenceWrapper<const Label>;
@ -64,7 +67,6 @@ using label_ref_t = ReferenceWrapper<const Label>;
// class class_name: Sized<size_of_t,aligment_of_t>
// --Sized template arguments must be hardcoded numbers equal to sizeof(T) and
// alignof(T) where T is original class.
// --It should have friends barrier classes which are permitted to construct it.
// --It should have undefined public constructor which is specialized in .cpp
// Blueprint:
// public:
@ -78,28 +80,11 @@ using label_ref_t = ReferenceWrapper<const Label>;
// class_name &operator=(const class_name &other);
// class_name &operator=(class_name &&other);
// --It should specify public methods which can be called on the original class.
// An example of such Sized barrier class:
//
// class Accessor : private Sized<16, 8>
// {
// public://
// template <class T>
// Accessor(T &&d);
//
// Accessor(const Accessor &other);
// Accessor(Accessor &&other);
// ~Accessor();
//
// Accessor &operator=(const Accessor &other);
// Accessor &operator=(Accessor &&other);
//
// int get_prop(Name &name);
// };
//
// Blueprint:
// class class_name : private Sized<,>
// {
// public://
// public:
// template <class T>
// class_name(T &&d);
//
@ -476,14 +461,6 @@ public:
// --Inherit Unsized class from common.hpp as protected. Blueprint:
// class class_name: protected Unsized
// --It should specify public methods which can be called on the original class.
// An example of such Unsized barrier class:
//
// class Db : protected Unsized
// {
// public:
// Accessor access();
// Name &get_name(const char *str);
// };
//
// Blueprint:
// class class_name : protected Unsized

View File

@ -8,21 +8,10 @@
#include "storage/edge_type/edge_type.hpp"
#include "storage/label/label.hpp"
// This is the place for imports from memgraph .cpp
// #include "database/db_accessor.cpp"
#include "storage/vertex_accessor.cpp"
// TODO: Extract trans functions to other hpp for easy including into other
// code.
// **************************** HELPER DEFINES *******************************//
// returns transformed pointer
#define THIS (trans(this))
// Performs call x on transformed border class.
#define HALF_CALL(x) (THIS->x)
// Performs call x on transformed border class and returns transformed output.
#define CALL(x) trans(HALF_CALL(x))
// Creates 8 functions for transformation of refereces between types x and y.
// Where x is a border type.
// DANGEROUS
#define TRANSFORM_REF(x, y) \
x &trans(y &l) { return ref_as<x>(l); } \
x const &trans(y const &l) { return ref_as<x const>(l); } \
@ -33,6 +22,9 @@
y *trans(x *l) { return ptr_as<y>(l); } \
y const *trans(x const *l) { return ptr_as<y const>(l); }
// Creates 8 functions for transformation of refereces between types x and y.
// Where both x and y are templates over T. Where x is a border type.
// DANGEROUS
#define TRANSFORM_REF_TEMPLATED(x, y) \
x &trans(y &l) { return ref_as<x>(l); } \
template <class T> \
@ -70,71 +62,60 @@
{ \
return ptr_as<const y>(l); \
}
#define DESTRUCTOR(x, y) \
x::~x() { HALF_CALL(~y()); }
#define COPY_CONSTRUCTOR_MUT(x, y) \
x::x(x &other) : Sized(y(trans(other))) {}
#define COPY_CONSTRUCTOR(x, y) \
x::x(const x &other) : Sized(y(trans(other))) {}
#define MOVE_CONSTRUCTOR(x) \
x::x(x &&other) : Sized(trans(std::move(other))) {}
#define MOVE_CONST_CONSTRUCTOR(x) \
x::x(x const &&other) : Sized(trans(std::move(other))) {}
// For certain classes trans evaluates into ref which doesnt work for Sized
// constructor. This Move forces type.
// constructor. This Move forces type y.
// DANGEROUS
#define MOVE_CONSTRUCTOR_FORCED(x, y) \
x::x(x &&other) : Sized(value_as<y>(std::move(other))) {}
#define COPY_OPERATOR(x) \
x &x::operator=(const x &other) \
{ \
HALF_CALL(operator=(trans(other))); \
return *this; \
}
#define MOVE_OPERATOR(x) \
x &x::operator=(x &&other) \
{ \
HALF_CALL(operator=(trans(std::move(other)))); \
return *this; \
}
// Creates constructor x(y) where x is border type and y shpuld be his original
// type.
// DANGEROUS
#define VALID_CONSTRUCTION(x, y) \
template <> \
barrier::x::x(y &&d) : Sized(std::move(d)) \
{ \
}
// Creates const constructor x(y) where x is border type and y shpuld be his
// original type.
// DANGEROUS
#define VALID_CONSTRUCTION_CONST(x, y) \
template <> \
barrier::x::x(y const &&d) : Sized(std::move(d)) \
{ \
}
// Generates transformation function from original class to border class.
// Creates value transformation function from original type y to border type x.
// DANGEROUS
#define TRANSFORM_VALUE_ONE_RAW(x, y) \
x trans(y &&d) { return x(std::move(d)); }
// Generates transformation function from original class to border class.
// Creates value transformation function and constructor from original type y to
// border type x.
// DANGEROUS
#define TRANSFORM_VALUE_ONE(x, y) \
VALID_CONSTRUCTION(x, y) \
x trans(y &&d) { return x(std::move(d)); }
// Generates transformation functions between border class x and original class
// y by value. Only mutable values.
// Creates value transformation functions and constructor between border type x
// and original type y. Only mutable values.
// DANGEROUS
#define TRANSFORM_VALUE_MUT(x, y) \
TRANSFORM_VALUE_ONE(x, y) \
y trans(x &&d) { return value_as<y>(std::move(d)); }
// Generates transformation functions between border class x and original class
// y by value.
// Creates value transformation functions and constructors between border type x
// and original type y.
// DANGEROUS
#define TRANSFORM_VALUE(x, y) \
TRANSFORM_VALUE_MUT(x, y) \
VALID_CONSTRUCTION_CONST(x, y) \
const x trans(const y &&d) { return x(std::move(d)); } \
const y trans(const x &&d) { return value_as<const y>(std::move(d)); }
// Duplicates given first name to call second given with name and ::name
// Duplicates given x to call y with x and ::x
#define DUP(x, y) y(x, ::x)
// ********************** TYPES OF AUTO
@ -147,17 +128,6 @@ using out_edge_iterator_t =
using in_edge_iterator_t =
decltype(((::VertexAccessor *)(std::nullptr_t()))->in());
// This file should contain all implementations of methods from barrier classes
// defined in barrier.hpp.
// Implementations should follow the form:
// border_return_type border_class::method_name(arguments){
// return
// CALL(method_name(trans(arguments)))/HALF_CALL(method_name(trans(arguments)));
// }
// ********************** ALL VALID CONVERSIONS ***************************** //
// Implementations must use exclusivly trans functions to cast between types.
// ******************** OVERLOADED trans FUNCTIONS.
// This enclosure is the only dangerous part of barrier except of Sized class in
// common.hpp
@ -240,7 +210,7 @@ TRANSFORM_VALUE_ONE_RAW(EdgePropertyType<T>,
template <class T>
TRANSFORM_VALUE_ONE_RAW(BoltSerializer<T>, ::bolt::BoltSerializer<T>)
// ********************* SPECIAL SIZED CONSTRUCTORS
// ********************* SPECIAL CONSTRUCTORS
#define VertexPropertyType_constructor(x) \
template <> \
template <> \

View File

@ -4,6 +4,7 @@
#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"

View File

@ -3,7 +3,6 @@
#include "storage/edge.hpp"
#include "storage/edge_record.hpp"
#include "storage/record_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "utils/assert.hpp"
#include "utils/reference_wrapper.hpp"
@ -12,6 +11,7 @@ using edge_type_ref_t = ReferenceWrapper<const EdgeType>;
class Edges;
// There exists circular dependecy with VertexAccessor.
class EdgeAccessor : public RecordAccessor<TypeGroupEdge, EdgeAccessor>
{
public:
@ -23,7 +23,7 @@ public:
const EdgeType &edge_type() const;
const VertexAccessor from() const;
const auto from() const;
const VertexAccessor to() const;
const auto to() const;
};

View File

@ -0,0 +1,30 @@
#pragma once
// There exists circular dependecy with EdgeAccessor. This file serves to break
// that circularity.
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
const auto EdgeAccessor::from() const
{
return VertexAccessor(this->vlist->from(), this->db);
}
const auto EdgeAccessor::to() const
{
return VertexAccessor(this->vlist->to(), this->db);
}
auto VertexAccessor::out() const
{
DbTransaction &t = this->db;
return iter::make_map(iter::make_iter_ref(record->data.out),
[&](auto e) -> auto { return EdgeAccessor(*e, t); });
}
auto VertexAccessor::in() const
{
DbTransaction &t = this->db;
return iter::make_map(iter::make_iter_ref(record->data.in),
[&](auto e) -> auto { return EdgeAccessor(e, t); });
}

View File

@ -1,12 +1,12 @@
#pragma once
// #include "storage/edge_accessor.hpp"
#include "storage/record_accessor.hpp"
#include "storage/vertex.hpp"
// #include "utils/iterator/iterator.hpp"
#include "utils/iterator/iterator.hpp"
class Vertices;
// There exists circular dependecy with EdgeAccessor.
class VertexAccessor : public RecordAccessor<TypeGroupVertex, VertexAccessor>
{
public:

View File

@ -2,8 +2,10 @@ cmake_minimum_required(VERSION 3.1)
project(memgraph_poc)
include_directories(${CMAKE_SOURCE_DIR}/poc)
add_executable(poc_astar astar.cpp)
target_link_libraries(poc_astar memgraph)
target_link_libraries(poc_astar Threads::Threads)
@ -11,16 +13,15 @@ target_link_libraries(poc_astar ${fmt_static_lib})
add_executable(profile profile.cpp)
target_link_libraries(profile memgraph)
target_link_libraries(profile barrier)
target_link_libraries(profile Threads::Threads)
target_link_libraries(profile ${fmt_static_lib})
add_executable(isolation isolation.cpp isolation/header.cpp)
target_link_libraries(isolation ${fmt_static_lib})
add_executable(size_aligment size_aligment.cpp)
target_link_libraries(size_aligment memgraph)
target_link_libraries(size_aligment Threads::Threads)
target_link_libraries(size_aligment ${fmt_static_lib})
add_executable(isolation isolation.cpp isolation/header.cpp)
target_link_libraries(isolation ${fmt_static_lib})

View File

@ -14,12 +14,13 @@
#include "database/db_accessor.cpp"
#include "database/db_accessor.hpp"
#include "import/csv_import.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/edges.cpp"
#include "storage/edges.hpp"
#include "storage/indexes/impl/nonunique_unordered_index.cpp"
#include "storage/model/properties/properties.cpp"
#include "storage/record_accessor.cpp"
#include "storage/vertex_accessor.cpp"
// #include "storage/vertex_accessor.cpp"
#include "storage/vertex_accessor.hpp"
#include "storage/vertices.cpp"
#include "storage/vertices.hpp"

View File

@ -11,15 +11,8 @@
#include <unistd.h>
#include <unordered_map>
#include "import/csv_import.hpp"
// #include "storage/indexes/impl/nonunique_unordered_index.cpp"
// #include "storage/model/properties/properties.cpp"
// #include "storage/record_accessor.cpp"
// #include "storage/vertex_accessor.cpp"
#include "utils/command_line/arguments.hpp"
// #include "barrier/trans.hpp"
// #include "barrier/barrier.cpp"
using namespace std;
int main(int argc, char **argv)

View File

@ -8,10 +8,11 @@
#include <unordered_map>
#include "database/db_accessor.cpp"
#include "import/csv_import.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/indexes/impl/nonunique_unordered_index.cpp"
#include "storage/model/properties/properties.cpp"
#include "storage/record_accessor.cpp"
#include "storage/vertex_accessor.cpp"
// #include "storage/record_accessor.cpp"
// #include "storage/vertex_accessor.cpp"
#include "utils/command_line/arguments.hpp"
using namespace std;

View File

@ -2,6 +2,60 @@
#include "barrier/trans.hpp"
// ************************* Implementations
// This file should contain all implementations of methods from barrier classes
// defined in barrier.hpp.
// Implementations should follow the form:
// border_return_type border_class::method_name(arguments){
// return
// CALL(method_name(trans(arguments)))/HALF_CALL(method_name(trans(arguments)));
// }
// **************************** HELPER DEFINES *******************************//
// returns transformed pointer
#define THIS (trans(this))
// Performs call x on transformed border class.
#define HALF_CALL(x) (THIS->x)
// Performs call x on transformed border class and returns transformed output.
#define CALL(x) trans(HALF_CALL(x))
// Creates destructor for border type x which is original type y.
#define DESTRUCTOR(x, y) \
x::~x() { HALF_CALL(~y()); }
// Creates copy constructor for mutable ref to border class x which is original
// class y.
#define COPY_CONSTRUCTOR_MUT(x, y) \
x::x(x &other) : Sized(y(trans(other))) {}
// Creates copy constructor for const ref to border class x which is original
// class y.
#define COPY_CONSTRUCTOR(x, y) \
x::x(const x &other) : Sized(y(trans(other))) {}
// Creates move constructor for mutable border type x.
#define MOVE_CONSTRUCTOR(x) \
x::x(x &&other) : Sized(trans(std::move(other))) {}
// Creates move constructor for const border type x.
#define MOVE_CONST_CONSTRUCTOR(x) \
x::x(x const &&other) : Sized(trans(std::move(other))) {}
// Creates copy operator for border type x.
#define COPY_OPERATOR(x) \
x &x::operator=(const x &other) \
{ \
HALF_CALL(operator=(trans(other))); \
return *this; \
}
// Creates move operator for border type x.
#define MOVE_OPERATOR(x) \
x &x::operator=(x &&other) \
{ \
HALF_CALL(operator=(trans(std::move(other)))); \
return *this; \
}
namespace barrier
{
@ -549,9 +603,4 @@ const>(barrier::VertexAccessor const&&)'
description:
Move constructor VertexAccessor<VertexAccessor const>(VertexAccessor const&&)
isn't defined.
*/

View File

@ -1,5 +1,3 @@
#pragma once
#include "database/db.hpp"
#include "database/db_accessor.hpp"
#include "utils/iterator/iterator.hpp"

View File

@ -10,13 +10,3 @@ const EdgeType &EdgeAccessor::edge_type() const
runtime_assert(this->record->data.edge_type != nullptr, "EdgeType is null");
return *this->record->data.edge_type;
}
const VertexAccessor EdgeAccessor::from() const
{
return VertexAccessor(this->vlist->from(), this->db);
}
const VertexAccessor EdgeAccessor::to() const
{
return VertexAccessor(this->vlist->to(), this->db);
}

View File

@ -1,5 +1,3 @@
#pragma once
#include "storage/vertex_accessor.hpp"
#include "database/db.hpp"
@ -41,22 +39,6 @@ const std::vector<label_ref_t> &VertexAccessor::labels() const
return this->record->data.labels();
}
// Returns unfilled accessors
auto VertexAccessor::out() const
{
DbTransaction &t = this->db;
return iter::make_map(iter::make_iter_ref(record->data.out),
[&](auto e) -> auto { return EdgeAccessor(*e, t); });
}
// Returns unfilled accessors
auto VertexAccessor::in() const
{
DbTransaction &t = this->db;
return iter::make_map(iter::make_iter_ref(record->data.in),
[&](auto e) -> auto { return EdgeAccessor(e, t); });
}
bool VertexAccessor::in_contains(VertexAccessor const &other) const
{
return record->data.in.contains(other.vlist);