work in progress engine <-> barrier integration

This commit is contained in:
Marko Budiselic 2016-08-29 01:01:42 +01:00
parent eaf2025cab
commit 12880ba990
17 changed files with 160 additions and 69 deletions

View File

@ -144,6 +144,7 @@ endforeach()
# -----------------------------------------------------------------------------
# COPY header files required by query engine (query compiler)
# TODO: somehow automate (in destination dir should be only required include files)
FILE(COPY ${include_dir}/barrier/barrier.hpp DESTINATION ${build_include_dir}/barrier)
FILE(COPY ${include_dir}/database/db.hpp DESTINATION ${build_include_dir}/database)
FILE(COPY ${include_dir}/database/db_transaction.hpp DESTINATION ${build_include_dir}/database)
FILE(COPY ${include_dir}/database/db_accessor.hpp DESTINATION ${build_include_dir}/database)
@ -455,7 +456,6 @@ set(memgraph_src_files
${src_dir}/storage/record_accessor.cpp
)
# STATIC library used by memgraph executables
add_library(memgraph STATIC ${memgraph_src_files})
@ -463,6 +463,10 @@ 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 ${memgraph_src_files})
add_library(barrier_pic STATIC ${memgraph_src_files})
set_property(TARGET barrier_pic PROPERTY POSITION_INDEPENDENT_CODE TRUE)
# tests
if (TESTS)
@ -498,7 +502,7 @@ set(MEMGRAPH_BUILD_NAME
# memgraph main executable
if (MEMGRAPH)
add_executable(${MEMGRAPH_BUILD_NAME} ${src_dir}/memgraph_bolt.cpp)
target_link_libraries(${MEMGRAPH_BUILD_NAME} memgraph)
target_link_libraries(${MEMGRAPH_BUILD_NAME} barrier)
target_link_libraries(${MEMGRAPH_BUILD_NAME} Threads::Threads)
target_link_libraries(${MEMGRAPH_BUILD_NAME} cypher_lib)
if (UNIX)
@ -508,12 +512,3 @@ if (MEMGRAPH)
target_link_libraries(${MEMGRAPH_BUILD_NAME} dl)
endif (UNIX)
endif()
# # memgraph executable HTTP TODO: DEPRICATED
# add_executable(memgraph_http src/memgraph.cpp)
# add_dependencies(memgraph_http cypher_lib)
# target_link_libraries(memgraph_http Threads::Threads)
# target_link_libraries(memgraph_http pcre)
# target_link_libraries(memgraph_http ${libuv_static_lib})
# target_link_libraries(memgraph_http ${r3_static_lib})
# target_link_libraries(memgraph_http ${http_parser_static_lib})

View File

@ -38,7 +38,7 @@ class EdgePropertyType;
// BOLT
template <class Stream>
class BoltSerializer;
class RecordStream;
// ************ Here should be forward declarations of Unsized barrier classes
// COMMON
@ -413,43 +413,41 @@ public:
};
template <class Stream>
class BoltSerializer : private Sized<8, 8>
class RecordStream : private Sized<8, 8>
{
public:
template <class T>
BoltSerializer(T &&d);
RecordStream(T &&d);
BoltSerializer(const BoltSerializer &other) = default;
BoltSerializer(BoltSerializer &&other) = default;
~BoltSerializer();
RecordStream(const RecordStream &other) = default;
RecordStream(RecordStream &&other) = default;
~RecordStream();
BoltSerializer &operator=(const BoltSerializer &other) = default;
BoltSerializer &operator=(BoltSerializer &&other) = default;
RecordStream &operator=(const RecordStream &other) = default;
RecordStream &operator=(RecordStream &&other) = default;
void write(const VertexAccessor &vertex);
void write(const EdgeAccessor &edge);
void write(const Property &prop);
void write_null();
void write(const Bool &prop);
void write(const Float &prop);
void write(const Double &prop);
void write(const Int32 &prop);
void write(const Int64 &prop);
void write(const std::string &value);
void write(const String &prop);
template <class T>
void handle(const T &prop);
void write_success();
void write_success_empty();
void write_ignored();
void write_fields(const std::vector<std::string> &fields);
void write_field(const std::string& field);
void write_list_header(size_t size);
void write_record();
void write_meta(const std::string& type);
void send();
void chunk();
};
// ************ Here should be definitions of Unsized barrier classes

View File

@ -1,8 +1,11 @@
#pragma once
#include "barrier/barrier.hpp"
// This is the place for imports from memgraph .hpp
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
#include "communication/bolt/v1/serialization/record_stream.hpp"
#include "io/network/socket.hpp"
#include "database/db.hpp"
#include "database/db_accessor.hpp"
#include "storage/edge_type/edge_type.hpp"
@ -165,7 +168,7 @@ TRANSFORM_REF_TEMPLATED(VertexIndex<T>, VertexIndexBase<T>);
template <class T>
TRANSFORM_REF_TEMPLATED(EdgeIndex<T>, EdgeIndexBase<T>);
template <class T>
TRANSFORM_REF_TEMPLATED(BoltSerializer<T>, ::bolt::BoltSerializer<T>);
TRANSFORM_REF_TEMPLATED(RecordStream<T>, ::bolt::RecordStream<T>);
template <class T>
TRANSFORM_REF_TEMPLATED(
@ -209,7 +212,7 @@ TRANSFORM_VALUE_ONE_RAW(EdgePropertyType<T>,
::EdgePropertyFamily::PropertyType::PropertyTypeKey<T>)
template <class T>
TRANSFORM_VALUE_ONE_RAW(BoltSerializer<T>, ::bolt::BoltSerializer<T>)
TRANSFORM_VALUE_ONE_RAW(RecordStream<T>, ::bolt::RecordStream<T>)
// ********************* SPECIAL CONSTRUCTORS
#define VertexPropertyType_constructor(x) \

View File

@ -8,6 +8,9 @@
#include "storage/model/properties/all.hpp"
#include "storage/model/properties/properties.hpp"
#include "storage/label/label.hpp"
#include "storage/edge_type/edge_type.hpp"
#include "storage/vertex_record.hpp"
namespace bolt
{

View File

@ -22,6 +22,8 @@ public:
logger = logging::log->logger("Record Stream");
}
~RecordStream() = default;
// TODO: create apstract methods that are not bolt specific ---------------
void write_success()
{

View File

@ -52,6 +52,7 @@ public:
"-I../../libs/fmt",
"-L./ -L../",
"-lmemgraph_pic",
"-lbarrier_pic",
"-shared -fPIC" // shared library flags
);

View File

@ -55,7 +55,8 @@ public:
template_file, {{"class_name", "CodeCPU"},
{"stripped_hash", std::to_string(stripped_hash)},
{"query", query},
{"stream", type_name<Stream>().to_string()},
// {"stream", type_name<Stream>().to_string()},
{"stream", "RecordStream<io::Socket>"},
{"code", cpp_traverser.code}});
// logger.trace("generated code: {}", generated);

View File

@ -1,15 +1,19 @@
#pragma once
#include "communication/communication.hpp"
#include "database/db.hpp"
#include "database/db_accessor.hpp"
#include "query_engine/query_stripped.hpp"
// #include "database/db.hpp"
// #include "database/db_accessor.hpp"
// BARRIER!
#include "barrier/barrier.hpp"
template <typename Stream>
class ICodeCPU
{
public:
virtual bool run(Db &db, code_args_t &args,
virtual bool run(barrier::Db &db, code_args_t &args,
Stream &stream) = 0;
virtual ~ICodeCPU() {}
};

View File

@ -11,6 +11,12 @@
// execution
// postprocess the results
// BARRIER!
namespace barrier
{
Db& trans(::Db& ref);
}
template <typename Stream>
class ProgramExecutor
{
@ -22,7 +28,7 @@ public:
{
try {
// TODO: return result of query/code exection
return program.code->run(db, program.stripped.arguments, stream);
return program.code->run(barrier::trans(db), program.stripped.arguments, stream);
} catch (...) {
// TODO: return more information about the error
throw QueryEngineException("code execution error");

View File

@ -25,6 +25,7 @@
#include "storage/vertices.cpp"
#include "storage/vertices.hpp"
#include "utils/command_line/arguments.hpp"
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
const int max_score = 1000000;

View File

@ -12,6 +12,7 @@
#include <unordered_map>
#include "import/csv_import.hpp"
#include "utils/command_line/arguments.hpp"
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
using namespace std;

View File

@ -499,83 +499,140 @@ OptionPtr<EdgeIndex<std::nullptr_t>> EdgePropertyFamily::index()
// ************************* BOLT SERIALIZER
template <class Stream>
BoltSerializer<Stream>::~BoltSerializer()
RecordStream<Stream>::~RecordStream()
{
THIS->~BoltSerializer();
// TODO: solve this
// THIS->~RecordStream();
}
template <class Stream>
void BoltSerializer<Stream>::write(const VertexAccessor &vertex)
void RecordStream<Stream>::write(const VertexAccessor &vertex)
{
HALF_CALL(write(trans(vertex)));
}
template <class Stream>
void BoltSerializer<Stream>::write(const EdgeAccessor &edge)
void RecordStream<Stream>::write(const EdgeAccessor &edge)
{
HALF_CALL(write(trans(edge)));
}
template <class Stream>
void BoltSerializer<Stream>::write(const Property &prop)
void RecordStream<Stream>::write(const Property &prop)
{
HALF_CALL(write(prop));
}
// template <class Stream>
// void RecordStream<Stream>::write_null()
// {
// HALF_CALL(write_null());
// }
template <class Stream>
void RecordStream<Stream>::write(const Bool &prop)
{
HALF_CALL(write(prop));
}
template <class Stream>
void BoltSerializer<Stream>::write_null()
{
HALF_CALL(write_null());
}
template <class Stream>
void BoltSerializer<Stream>::write(const Bool &prop)
void RecordStream<Stream>::write(const Float &prop)
{
HALF_CALL(write(prop));
}
template <class Stream>
void BoltSerializer<Stream>::write(const Float &prop)
void RecordStream<Stream>::write(const Double &prop)
{
HALF_CALL(write(prop));
}
template <class Stream>
void BoltSerializer<Stream>::write(const Double &prop)
void RecordStream<Stream>::write(const Int32 &prop)
{
HALF_CALL(write(prop));
}
template <class Stream>
void BoltSerializer<Stream>::write(const Int32 &prop)
void RecordStream<Stream>::write(const Int64 &prop)
{
HALF_CALL(write(prop));
}
template <class Stream>
void BoltSerializer<Stream>::write(const Int64 &prop)
{
HALF_CALL(write(prop));
}
template <class Stream>
void BoltSerializer<Stream>::write(const std::string &value)
void RecordStream<Stream>::write(const std::string &value)
{
HALF_CALL(write(value));
}
template <class Stream>
void BoltSerializer<Stream>::write(const String &prop)
void RecordStream<Stream>::write(const String &prop)
{
HALF_CALL(write(prop));
}
template <class Stream>
template <class T>
void BoltSerializer<Stream>::handle(const T &prop)
void RecordStream<Stream>::write_success()
{
HALF_CALL(template handle<T>(prop));
HALF_CALL(write_success());
}
template <class Stream>
void RecordStream<Stream>::write_success_empty()
{
HALF_CALL(write_success_empty());
}
template <class Stream>
void RecordStream<Stream>::write_ignored()
{
HALF_CALL(write_ignored());
}
template <class Stream>
void RecordStream<Stream>::write_fields(const std::vector<std::string> &fields)
{
HALF_CALL(write_fields(fields));
}
template <class Stream>
void RecordStream<Stream>::write_field(const std::string& field)
{
HALF_CALL(write_field(field));
}
template <class Stream>
void RecordStream<Stream>::write_list_header(size_t size)
{
HALF_CALL(write_list_header(size));
}
template <class Stream>
void RecordStream<Stream>::write_record()
{
HALF_CALL(write_record());
}
template <class Stream>
void RecordStream<Stream>::write_meta(const std::string& type)
{
HALF_CALL(write_meta(type));
}
template <class Stream>
void RecordStream<Stream>::send()
{
HALF_CALL(send());
}
template <class Stream>
void RecordStream<Stream>::chunk()
{
HALF_CALL(chunk());
}
template class RecordStream<io::Socket>;
}
// **************************** ERROR EXAMPLES ****************************** //

View File

@ -1,5 +1,9 @@
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
#include "communication/bolt/v1/transport/chunked_buffer.hpp"
#include "communication/bolt/v1/transport/chunked_encoder.hpp"
#include "communication/bolt/v1/transport/socket_stream.hpp"
#include "io/network/socket.hpp"
#include "storage/edge_x_vertex.hpp"
template <class Stream>
@ -28,3 +32,6 @@ void bolt::BoltSerializer<Stream>::write(const EdgeAccessor &edge)
write(*prop.second);
}
}
template class bolt::BoltSerializer<bolt::BoltEncoder<
bolt::ChunkedEncoder<bolt::ChunkedBuffer<bolt::SocketStream<io::Socket>>>>>;

View File

@ -1,6 +1,9 @@
#include "communication/bolt/v1/states/executor.hpp"
#include "communication/bolt/v1/messaging/codes.hpp"
// BARRIER! TODO: ATTENTION: HACK!!!!!
#include "barrier/barrier.cpp"
namespace bolt
{

View File

@ -10,6 +10,10 @@ using std::endl;
// query: {{query}}
// BARRIER!
namespace barrier
{
class {{class_name}} : public ICodeCPU<{{stream}}>
{
public:
@ -23,13 +27,16 @@ public:
~{{class_name}}() {}
};
extern "C" ICodeCPU<{{stream}}>* produce()
{
return new {{class_name}}();
}
extern "C" void destruct(ICodeCPU<{{stream}}>* p)
extern "C" ICodeCPU<barrier::{{stream}}>* produce()
{
// BARRIER!
return new barrier::{{class_name}}();
}
extern "C" void destruct(ICodeCPU<barrier::{{stream}}>* p)
{
delete p;
}

View File

@ -4,6 +4,7 @@
#include "database/db.hpp"
#include "query_engine/query_stripper.hpp"
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
// #include "storage/edges.cpp"
// #include "storage/edges.hpp"
// #include "storage/vertices.cpp"

View File

@ -10,6 +10,7 @@
#include "storage/edges.hpp"
#include "storage/vertices.cpp"
#include "storage/vertices.hpp"
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
using namespace std;