All files for the Release are now isolated

This commit is contained in:
Marko Budiselic 2016-08-10 09:39:02 +01:00
parent 95aa385e31
commit 869da8dcda
228 changed files with 672 additions and 475 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ memgraph
tags tags
.gdb_history .gdb_history
Testing/ Testing/
ve/

View File

@ -116,19 +116,22 @@ FILE(MAKE_DIRECTORY ${cypher_build_include_dir})
FILE(RENAME ${CMAKE_BINARY_DIR}/cypher.h ${cypher_build_include_dir}/cypher.h) FILE(RENAME ${CMAKE_BINARY_DIR}/cypher.h ${cypher_build_include_dir}/cypher.h)
# prepare template and destination folders for query engine (tests) # prepare template and destination folders for query engine (tests)
# and memgraph server binary
# copy query_engine's templates file # copy query_engine's templates file
FILE(COPY ${src_dir}/query_engine/template DESTINATION ${CMAKE_BINARY_DIR}/tests) FILE(COPY ${src_dir}/query_engine/template DESTINATION ${CMAKE_BINARY_DIR}/tests)
FILE(COPY ${src_dir}/query_engine/template DESTINATION ${CMAKE_BINARY_DIR})
# create destination folder for compiled queries # create destination folder for compiled queries
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tests/compiled/cpu) FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tests/compiled/cpu)
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/compiled/cpu)
# TODO: filter header files, all files don't need to be copied # TODO: filter header files, all files don't need to be copied
# they are all copied because query engine needs header files during # they are all copied because query engine needs header files during
# query compilation # query compilation
# TODO: make a function (REMOVE copy pasted part) # TODO: make a function (REMOVE copy pasted part)
SUBDIRLIST(source_folders ${src_dir}) # SUBDIRLIST(source_folders ${src_dir})
foreach(source_folder ${source_folders}) # foreach(source_folder ${source_folders})
file(COPY ${src_dir}/${source_folder} DESTINATION ${build_include_dir}) # file(COPY ${src_dir}/${source_folder} DESTINATION ${build_include_dir})
endforeach() # endforeach()
SUBDIRLIST(source_folders ${src_dir}) SUBDIRLIST(source_folders ${src_dir})
foreach(source_folder ${source_folders}) foreach(source_folder ${source_folders})
file(COPY ${src_dir}/${source_folder} DESTINATION ${test_src_dir}) file(COPY ${src_dir}/${source_folder} DESTINATION ${test_src_dir})
@ -138,16 +141,130 @@ foreach(source_foler ${source_folders})
file(COPY ${include_dir}/${source_folder} DESTINATION ${test_include_dir}) file(COPY ${include_dir}/${source_folder} DESTINATION ${test_include_dir})
endforeach() 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}/database/db.hpp DESTINATION ${build_include_dir}/database)
FILE(COPY ${include_dir}/storage/common.hpp DESTINATION ${build_include_dir}/storage)
FILE(COPY ${include_dir}/storage/graph.hpp DESTINATION ${build_include_dir}/storage)
FILE(COPY ${include_dir}/storage/edge.hpp DESTINATION ${build_include_dir}/storage)
FILE(COPY ${include_dir}/storage/edge_accessor.hpp DESTINATION ${build_include_dir}/storage)
FILE(COPY ${include_dir}/storage/edges.hpp DESTINATION ${build_include_dir}/storage)
FILE(COPY ${include_dir}/storage/vertices.hpp DESTINATION ${build_include_dir}/storage)
FILE(COPY ${include_dir}/storage/vertex.hpp DESTINATION ${build_include_dir}/storage)
FILE(COPY ${include_dir}/storage/vertex_accessor.hpp DESTINATION ${build_include_dir}/storage)
FILE(COPY ${include_dir}/storage/record_accessor.hpp DESTINATION ${build_include_dir}/storage)
FILE(COPY ${include_dir}/storage/locking/record_lock.hpp DESTINATION ${build_include_dir}/storage/locking)
FILE(COPY ${include_dir}/storage/locking/lock_status.hpp DESTINATION ${build_include_dir}/storage/locking)
FILE(COPY ${include_dir}/storage/edge_type/edge_type_store.hpp DESTINATION ${build_include_dir}/storage/edge_type)
FILE(COPY ${include_dir}/storage/edge_type/edge_type.hpp DESTINATION ${build_include_dir}/storage/edge_type)
FILE(COPY ${include_dir}/storage/label/label_store.hpp DESTINATION ${build_include_dir}/storage/label)
FILE(COPY ${include_dir}/query_engine/util.hpp DESTINATION ${build_include_dir}/query_engine)
FILE(COPY ${include_dir}/query_engine/i_code_cpu.hpp DESTINATION ${build_include_dir}/query_engine)
FILE(COPY ${include_dir}/query_engine/query_result.hpp DESTINATION ${build_include_dir}/query_engine)
FILE(COPY ${include_dir}/query_engine/query_stripped.hpp DESTINATION ${build_include_dir}/query_engine)
FILE(COPY ${include_dir}/data_structures/concurrent/concurrent_map.hpp DESTINATION ${build_include_dir}/data_structures/concurrent)
FILE(COPY ${include_dir}/data_structures/concurrent/concurrent_set.hpp DESTINATION ${build_include_dir}/data_structures/concurrent)
FILE(COPY ${include_dir}/data_structures/concurrent/common.hpp DESTINATION ${build_include_dir}/data_structures/concurrent)
FILE(COPY ${include_dir}/data_structures/concurrent/skiplist.hpp DESTINATION ${build_include_dir}/data_structures/concurrent)
FILE(COPY ${include_dir}/data_structures/concurrent/skiplist_gc.hpp DESTINATION ${build_include_dir}/data_structures/concurrent)
FILE(COPY ${include_dir}/data_structures/bitset/dynamic_bitset.hpp DESTINATION ${build_include_dir}/data_structures/bitset)
FILE(COPY ${include_dir}/threading/sync/lockable.hpp DESTINATION ${build_include_dir}/threading/sync)
FILE(COPY ${include_dir}/threading/sync/spinlock.hpp DESTINATION ${build_include_dir}/threading/sync)
FILE(COPY ${include_dir}/threading/sync/futex.hpp DESTINATION ${build_include_dir}/threading/sync)
FILE(COPY ${include_dir}/threading/sync/lock_timeout_error.hpp DESTINATION ${build_include_dir}/threading/sync)
FILE(COPY ${include_dir}/memory/freelist.hpp DESTINATION ${build_include_dir}/memory)
FILE(COPY ${include_dir}/memory/lazy_gc.hpp DESTINATION ${build_include_dir}/memory)
FILE(COPY ${include_dir}/mvcc/cre_exp.hpp DESTINATION ${build_include_dir}/mvcc)
FILE(COPY ${include_dir}/mvcc/hints.hpp DESTINATION ${build_include_dir}/mvcc)
FILE(COPY ${include_dir}/mvcc/id.hpp DESTINATION ${build_include_dir}/mvcc)
FILE(COPY ${include_dir}/mvcc/mvcc_error.hpp DESTINATION ${build_include_dir}/mvcc)
FILE(COPY ${include_dir}/mvcc/record.hpp DESTINATION ${build_include_dir}/mvcc)
FILE(COPY ${include_dir}/mvcc/serialization_error.hpp DESTINATION ${build_include_dir}/mvcc)
FILE(COPY ${include_dir}/mvcc/version.hpp DESTINATION ${build_include_dir}/mvcc)
FILE(COPY ${include_dir}/mvcc/version_list.hpp DESTINATION ${build_include_dir}/mvcc)
FILE(COPY ${include_dir}/transactions/transaction.hpp DESTINATION ${build_include_dir}/transactions)
FILE(COPY ${include_dir}/transactions/lock_store.hpp DESTINATION ${build_include_dir}/transactions)
FILE(COPY ${include_dir}/transactions/snapshot.hpp DESTINATION ${build_include_dir}/transactions)
FILE(COPY ${include_dir}/transactions/commit_log.hpp DESTINATION ${build_include_dir}/transactions)
FILE(COPY ${include_dir}/transactions/engine.hpp DESTINATION ${build_include_dir}/transactions)
FILE(COPY ${include_dir}/transactions/transaction_store.hpp DESTINATION ${build_include_dir}/transactions)
FILE(COPY ${include_dir}/storage/model/properties/properties.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/property.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/traversers/consolewriter.hpp DESTINATION ${build_include_dir}/storage/model/properties/traversers)
FILE(COPY ${include_dir}/storage/model/properties/traversers/jsonwriter.hpp DESTINATION ${build_include_dir}/storage/model/properties/traversers)
FILE(COPY ${include_dir}/storage/model/properties/handler.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/all.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/bool.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/float.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/double.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/int32.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/int64.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/string.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/floating.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/number.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/integral.hpp DESTINATION ${build_include_dir}/storage/model/properties)
FILE(COPY ${include_dir}/storage/model/properties/utils/math_operations.hpp DESTINATION ${build_include_dir}/storage/model/properties/utils)
FILE(COPY ${include_dir}/storage/model/properties/utils/unary_negation.hpp DESTINATION ${build_include_dir}/storage/model/properties/utils)
FILE(COPY ${include_dir}/storage/model/properties/utils/modulo.hpp DESTINATION ${build_include_dir}/storage/model/properties/utils)
FILE(COPY ${include_dir}/storage/model/edge_model.hpp DESTINATION ${build_include_dir}/storage/model)
FILE(COPY ${include_dir}/storage/model/property_model.hpp DESTINATION ${build_include_dir}/storage/model)
FILE(COPY ${include_dir}/storage/model/vertex_model.hpp DESTINATION ${build_include_dir}/storage/model)
FILE(COPY ${include_dir}/storage/model/edge_list.hpp DESTINATION ${build_include_dir}/storage/model)
FILE(COPY ${include_dir}/storage/label/label.hpp DESTINATION ${build_include_dir}/storage/label)
FILE(COPY ${include_dir}/storage/label/label_collection.hpp DESTINATION ${build_include_dir}/storage/label)
FILE(COPY ${include_dir}/storage/label/label_store.hpp DESTINATION ${build_include_dir}/storage/label)
FILE(COPY ${include_dir}/storage/indexes/index.hpp DESTINATION ${build_include_dir}/storage/indexes)
FILE(COPY ${include_dir}/storage/indexes/index_record.hpp DESTINATION ${build_include_dir}/storage/indexes)
FILE(COPY ${include_dir}/storage/indexes/index_record_collection.hpp DESTINATION ${build_include_dir}/storage/indexes)
FILE(COPY ${include_dir}/utils/sys.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/stacktrace.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/auto_scope.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/assert.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/reference_wrapper.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/underlying_cast.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/total_ordering.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/crtp.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/placeholder.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/likely.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/cpu_relax.hpp DESTINATION ${build_include_dir}/utils)
FILE(COPY ${include_dir}/utils/counters/atomic_counter.hpp DESTINATION ${build_include_dir}/utils/counters)
FILE(COPY ${include_dir}/utils/counters/simple_counter.hpp DESTINATION ${build_include_dir}/utils/counters)
FILE(COPY ${include_dir}/utils/random/fast_binomial.hpp DESTINATION ${build_include_dir}/utils/random)
FILE(COPY ${include_dir}/utils/random/xorshift128plus.hpp DESTINATION ${build_include_dir}/utils/random)
FILE(COPY ${include_dir}/utils/exceptions/basic_exception.hpp DESTINATION ${build_include_dir}/utils/exceptions)
# -----------------------------------------------------------------------------
# add all cpp file recursive into sourceFiles varibale # add all cpp file recursive into sourceFiles varibale
# FILE(GLOB_RECURSE sourceFiles ${src_dir}/*.cpp) # FILE(GLOB_RECURSE sourceFiles ${src_dir}/*.cpp)
# print list of source files # print list of source files
# MESSAGE(STATUS "All source files are: ${sourceFiles}") # MESSAGE(STATUS "All source files are: ${sourceFiles}")
# compiler options # debug flags
# SET(COMPILE_OPTIONS "-O2 -Wall -Werror -fmessage-length=0") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native") # set(CMAKE_CXX_FLAGS_DEBUG "-Wl,--export-dynamic ${CMAKE_CXX_FLAGS_DEBUG}")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# set(CMAKE_CXX_FLAGS_DEBUG "-rdynamic ${CMAKE_CXX_FLAGS_DEBUG}")
endif()
# manual defines at configure time # release flags
set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} -march=native -Wall -Werror")
# -- configure time variables -------------------------------------------------
option(RUNTIME_ASSERT "Enable runtime assertions" OFF) option(RUNTIME_ASSERT "Enable runtime assertions" OFF)
if(RUNTIME_ASSERT) if(RUNTIME_ASSERT)
add_definitions( -DRUNTIME_ASSERT_ON ) add_definitions( -DRUNTIME_ASSERT_ON )
@ -163,7 +280,11 @@ if(NDEBUG)
add_definitions( -DNDEBUG ) add_definitions( -DNDEBUG )
endif() endif()
# includes option(MEMGRAPH "Build memgraph binary" ON)
option(POC "Build proof of concept binaries" ON)
option(TESTS "Build test binaries" ON)
# -- includes -----------------------------------------------------------------
include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${src_dir}) include_directories(${src_dir})
include_directories(${build_include_dir}) include_directories(${build_include_dir})
@ -173,6 +294,7 @@ include_directories(${lexertl_dir})
include_directories(${libuv_source_dir}/include) include_directories(${libuv_source_dir}/include)
include_directories(${rapidjson_source_dir}/include) include_directories(${rapidjson_source_dir}/include)
include_directories(${r3_source_dir}/include) include_directories(${r3_source_dir}/include)
# -----------------------------------------------------------------------------
# creates build/libcypher_lib.a # creates build/libcypher_lib.a
add_library(cypher_lib STATIC ${CMAKE_BINARY_DIR}/cypher.cpp) add_library(cypher_lib STATIC ${CMAKE_BINARY_DIR}/cypher.cpp)
@ -183,30 +305,24 @@ EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/api WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/api
) )
# # memgraph executable # TODO: create separate static library from bolt code
# 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})
# # query_engine executable
# add_executable(query_engine src/query_engine/main_query_engine.cpp)
# # query_engine link libraries
# target_link_libraries(query_engine Threads::Threads)
# target_link_libraries(query_engine dl)
# target_link_libraries(query_engine cypher_lib)
# target_link_libraries(query_engine ${fmt_static_lib})
# # query hasher executable
# add_executable(query_hasher src/query_engine/main_query_hasher.cpp)
# target_link_libraries(query_hasher ${fmt_static_lib})
set(memgraph_src_files set(memgraph_src_files
${src_dir}/utils/string/transform.cpp
${src_dir}/utils/string/join.cpp
${src_dir}/utils/string/file.cpp
${src_dir}/query_engine/util.cpp
${src_dir}/bolt/v1/bolt.cpp
${src_dir}/bolt/v1/states.cpp
${src_dir}/bolt/v1/session.cpp
${src_dir}/bolt/v1/states/error.cpp
${src_dir}/bolt/v1/states/executor.cpp
${src_dir}/bolt/v1/states/init.cpp
${src_dir}/bolt/v1/states/handshake.cpp
${src_dir}/bolt/v1/transport/bolt_decoder.cpp
${src_dir}/bolt/v1/transport/buffer.cpp
${src_dir}/mvcc/id.cpp ${src_dir}/mvcc/id.cpp
${src_dir}/storage/vertices.cpp ${src_dir}/storage/vertices.cpp
${src_dir}/storage/edges.cpp
${src_dir}/storage/label/label.cpp ${src_dir}/storage/label/label.cpp
${src_dir}/storage/label/label_collection.cpp ${src_dir}/storage/label/label_collection.cpp
${src_dir}/storage/label/label_store.cpp ${src_dir}/storage/label/label_store.cpp
@ -221,6 +337,13 @@ set(memgraph_src_files
${src_dir}/storage/vertex_accessor.cpp ${src_dir}/storage/vertex_accessor.cpp
${src_dir}/transactions/transaction.cpp ${src_dir}/transactions/transaction.cpp
${src_dir}/template_engine/engine.cpp ${src_dir}/template_engine/engine.cpp
${src_dir}/logging/streams/stdout.cpp
${src_dir}/logging/levels.cpp
${src_dir}/logging/logs/sync_log.cpp
${src_dir}/logging/logs/async_log.cpp
${src_dir}/logging/default.cpp
${src_dir}/logging/log.cpp
${src_dir}/io/network/tls.cpp
) )
# STATIC library used by memgraph executables # STATIC library used by memgraph executables
@ -231,11 +354,15 @@ add_library(memgraph_pic STATIC ${memgraph_src_files})
set_property(TARGET memgraph_pic PROPERTY POSITION_INDEPENDENT_CODE TRUE) set_property(TARGET memgraph_pic PROPERTY POSITION_INDEPENDENT_CODE TRUE)
# tests # tests
enable_testing() if (TESTS)
add_subdirectory(tests) enable_testing()
add_subdirectory(tests)
endif()
# proof of concept # proof of concepts
add_subdirectory(poc) if (POC)
add_subdirectory(poc)
endif()
# memgraph build name # memgraph build name
execute_process( execute_process(
@ -248,8 +375,28 @@ execute_process(
) )
string(STRIP ${COMMIT_HASH} COMMIT_HASH) string(STRIP ${COMMIT_HASH} COMMIT_HASH)
string(STRIP ${COMMIT_NO} COMMIT_NO) string(STRIP ${COMMIT_NO} COMMIT_NO)
set(MEMGRAPH_BUILD_NAME "memgraph_${COMMIT_HASH}_${COMMIT_NO}") set(MEMGRAPH_BUILD_NAME
message(STATUS ${CMAKE_BUILD_TYPE}) "memgraph_${COMMIT_HASH}_${COMMIT_NO}_${CMAKE_BUILD_TYPE}")
# memgraph main executable # memgraph main executable
add_executable(${MEMGRAPH_BUILD_NAME}_${CMAKE_BUILD_TYPE} ${src_dir}/memgraph_bolt.cpp) 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} Threads::Threads)
target_link_libraries(${MEMGRAPH_BUILD_NAME} cypher_lib)
if (UNIX)
target_link_libraries(${MEMGRAPH_BUILD_NAME} crypto)
# target_link_libraries(${MEMGRAPH_BUILD_NAME} ssl)
target_link_libraries(${MEMGRAPH_BUILD_NAME} ${fmt_static_lib})
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

@ -20,6 +20,10 @@ on a 64 bit linux kernel.
* lemon (parser generator) * lemon (parser generator)
* catch (for compiling tests) * catch (for compiling tests)
### Bolt
sudo apt-get install libssl-dev
## build ## build
``` ```
cd build cd build
@ -30,8 +34,9 @@ cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DRUNTIME_ASSERT=OFF
# -DCMAKE_CXX_COMPILER=clang++ # -DCMAKE_CXX_COMPILER=clang++
# -DRUNTIME_ASSERT=OFF # -DRUNTIME_ASSERT=OFF
# -DTHROW_EXCEPTION_ON_ERROR=OFF # -DTHROW_EXCEPTION_ON_ERROR=OFF
# -DCMAKE_BUILD_TYPE:STRING=Debug
# -DNDEBUG=ON # -DNDEBUG=ON
# -DCMAKE_BUILD_TYPE:STRING=debug
# -DCMAKE_BUILD_TYPE:STRING=release
make make
ctest ctest

View File

@ -1,7 +1,8 @@
#pragma once #pragma once
#include "states.hpp" #include "bolt/v1/states.hpp"
#include "io/network/socket.hpp" #include "io/network/socket.hpp"
#include "dbms/dbms.hpp"
namespace bolt namespace bolt
{ {
@ -19,6 +20,7 @@ public:
void close(Session* session); void close(Session* session);
States states; States states;
Dbms dbms;
}; };
} }

View File

@ -0,0 +1,8 @@
#pragma once
namespace bolt
{
// TODO: what should be here? (Question for Dominik)
}

View File

@ -3,7 +3,7 @@
#include "bolt/v1/transport/bolt_encoder.hpp" #include "bolt/v1/transport/bolt_encoder.hpp"
#include "bolt/v1/packing/codes.hpp" #include "bolt/v1/packing/codes.hpp"
#include "include/storage/vertex_accessor.hpp" #include "storage/vertex_accessor.hpp"
#include "storage/edge_accessor.hpp" #include "storage/edge_accessor.hpp"
#include "storage/model/properties/properties.hpp" #include "storage/model/properties/properties.hpp"

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "bolt_serializer.hpp" #include "bolt/v1/serialization/bolt_serializer.hpp"
namespace bolt namespace bolt
{ {

View File

@ -4,13 +4,11 @@
#include "io/network/socket.hpp" #include "io/network/socket.hpp"
#include "bolt/v1/states/state.hpp" #include "bolt/v1/states/state.hpp"
#include "bolt/v1/transport/bolt_decoder.hpp" #include "bolt/v1/transport/bolt_decoder.hpp"
#include "bolt/v1/transport/bolt_encoder.hpp" #include "bolt/v1/transport/bolt_encoder.hpp"
#include "bolt/v1/serialization/socket_serializer.hpp" #include "bolt/v1/serialization/socket_serializer.hpp"
#include "bolt/v1/bolt.hpp"
#include "bolt.hpp"
#include "logging/default.hpp" #include "logging/default.hpp"
namespace bolt namespace bolt
@ -31,6 +29,8 @@ public:
Bolt& bolt; Bolt& bolt;
Db& active_db();
Decoder decoder; Decoder decoder;
Encoder encoder {socket}; Encoder encoder {socket};

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "states/state.hpp" #include "bolt/v1/states/state.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
namespace bolt namespace bolt

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "bolt/v1/session.hpp"
#include "bolt/v1/states/state.hpp" #include "bolt/v1/states/state.hpp"
namespace bolt namespace bolt
@ -8,7 +9,7 @@ namespace bolt
class Error : public State class Error : public State
{ {
public: public:
State* run(Session& session) override; State *run(Session &session) override;
}; };
} }

View File

@ -2,6 +2,7 @@
#include "bolt/v1/states/state.hpp" #include "bolt/v1/states/state.hpp"
#include "bolt/v1/session.hpp" #include "bolt/v1/session.hpp"
#include "query_engine/query_engine.hpp"
namespace bolt namespace bolt
{ {
@ -35,6 +36,10 @@ protected:
* *
*/ */
void discard_all(Session& session); void discard_all(Session& session);
private:
QueryEngine query_engine;
}; };
} }

View File

@ -1,9 +1,8 @@
#pragma once #pragma once
#include "state.hpp"
#include "utils/crtp.hpp"
#include "bolt/v1/session.hpp" #include "bolt/v1/session.hpp"
#include "bolt/v1/states/state.hpp"
#include "utils/crtp.hpp"
namespace bolt namespace bolt
{ {
@ -12,10 +11,9 @@ template <class Derived>
class MessageParser : public State, public Crtp<Derived> class MessageParser : public State, public Crtp<Derived>
{ {
public: public:
MessageParser(Logger&& logger) MessageParser(Logger &&logger) : logger(std::forward<Logger>(logger)) {}
: logger(std::forward<Logger>(logger)) {}
State* run(Session& session) override final State *run(Session &session) override final
{ {
typename Derived::Message message; typename Derived::Message message;
@ -23,8 +21,7 @@ public:
auto next = this->derived().parse(session, message); auto next = this->derived().parse(session, message);
// return next state if parsing was unsuccessful (i.e. error state) // return next state if parsing was unsuccessful (i.e. error state)
if(next != &this->derived()) if (next != &this->derived()) return next;
return next;
logger.debug("Executing state"); logger.debug("Executing state");
return this->derived().execute(session, message); return this->derived().execute(session, message);
@ -33,5 +30,4 @@ public:
protected: protected:
Logger logger; Logger logger;
}; };
} }

View File

@ -1,8 +1,7 @@
#pragma once #pragma once
#include "buffer.hpp" #include "bolt/v1/transport/buffer.hpp"
#include "chunked_decoder.hpp" #include "bolt/v1/transport/chunked_decoder.hpp"
#include "utils/types/byte.hpp" #include "utils/types/byte.hpp"
namespace bolt namespace bolt
@ -11,15 +10,15 @@ namespace bolt
class BoltDecoder class BoltDecoder
{ {
public: public:
void handshake(const byte*& data, size_t len); void handshake(const byte *&data, size_t len);
bool decode(const byte*& data, size_t len); bool decode(const byte *&data, size_t len);
bool empty() const; bool empty() const;
void reset(); void reset();
byte peek() const; byte peek() const;
byte read_byte(); byte read_byte();
void read_bytes(void* dest, size_t n); void read_bytes(void *dest, size_t n);
int16_t read_int16(); int16_t read_int16();
uint16_t read_uint16(); uint16_t read_uint16();
@ -36,10 +35,9 @@ public:
private: private:
Buffer buffer; Buffer buffer;
ChunkedDecoder<Buffer> decoder {buffer}; ChunkedDecoder<Buffer> decoder{buffer};
size_t pos {0}; size_t pos{0};
const byte* raw() const; const byte *raw() const;
}; };
} }

View File

@ -5,7 +5,7 @@
#include <cstdio> #include <cstdio>
#include "io/network/socket.hpp" #include "io/network/socket.hpp"
#include "stream_error.hpp" #include "bolt/v1/transport/stream_error.hpp"
namespace bolt namespace bolt
{ {

View File

@ -16,7 +16,6 @@ public:
friend constexpr bool operator<(const Item &lhs, const Item &rhs) friend constexpr bool operator<(const Item &lhs, const Item &rhs)
{ {
std::pair<const K, T> *a;
return lhs.first < rhs.first; return lhs.first < rhs.first;
} }

View File

@ -9,12 +9,18 @@ class Db
public: public:
using sptr = std::shared_ptr<Db>; using sptr = std::shared_ptr<Db>;
Db() = default;
Db(const std::string& name) : name_(name) {}
Db(const Db& db) = delete;
Graph graph; Graph graph;
tx::Engine tx_engine; tx::Engine tx_engine;
// only for test purposes std::string& name()
std::string identifier()
{ {
return "memgraph"; return name_;
} }
private:
std::string name_;
}; };

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "log.hpp" #include "logging/log.hpp"
#include "logger.hpp" #include "logging/logger.hpp"
namespace logging namespace logging
{ {

View File

@ -3,8 +3,8 @@
#include <cassert> #include <cassert>
#include <fmt/format.h> #include <fmt/format.h>
#include "log.hpp" #include "logging/log.hpp"
#include "levels.hpp" #include "logging/levels.hpp"
class Logger class Logger
{ {

View File

@ -8,9 +8,9 @@
#include "transactions/engine.hpp" #include "transactions/engine.hpp"
#include "mvcc/id.hpp" #include "mvcc/id.hpp"
#include "cre_exp.hpp" #include "mvcc/cre_exp.hpp"
#include "version.hpp" #include "mvcc/version.hpp"
#include "hints.hpp" #include "mvcc/hints.hpp"
#include "storage/locking/record_lock.hpp" #include "storage/locking/record_lock.hpp"
// the mvcc implementation used here is very much like postgresql's // the mvcc implementation used here is very much like postgresql's

View File

@ -19,11 +19,11 @@ public:
auto compile_command = auto compile_command =
utils::prints("clang++", utils::prints("clang++",
// "-std=c++1y -O2 -DNDEBUG", // compile flags // "-std=c++1y -O2 -DNDEBUG", // compile flags
"-std=c++1y -DDEBUG", // compile flags "-std=c++1y -DDEBUG", // compile flags // TODO: load from config file
in_file, // input file in_file, // input file
"-o", out_file, // ouput file "-o", out_file, // ouput file
"-I./include", // include paths (TODO: parameter) "-I./include", // include paths (TODO: parameter)
"-I./src", "-I../../libs/fmt", "-I../libs/fmt", // TODO: load from config
"-L./ -lmemgraph_pic", "-L./ -lmemgraph_pic",
"-shared -fPIC" // shared library flags "-shared -fPIC" // shared library flags
); );

View File

@ -15,6 +15,9 @@
using ParameterIndexKey::Type::InternalId; using ParameterIndexKey::Type::InternalId;
using Direction = RelationshipData::Direction; using Direction = RelationshipData::Direction;
namespace
{
auto update_properties(const QueryActionData &action_data, auto update_properties(const QueryActionData &action_data,
const std::string &name) const std::string &name)
{ {
@ -29,3 +32,5 @@ auto update_properties(const QueryActionData &action_data,
return code; return code;
} }
}

View File

@ -2,6 +2,9 @@
#include "query_engine/code_generator/handlers/includes.hpp" #include "query_engine/code_generator/handlers/includes.hpp"
namespace
{
bool already_matched(CypherStateData &cypher_data, const std::string &name, bool already_matched(CypherStateData &cypher_data, const std::string &name,
EntityType type) EntityType type)
{ {
@ -18,6 +21,8 @@ auto fetch_internal_index(const QueryActionData &action_data,
return action_data.parameter_index.at(ParameterIndexKey(InternalId, name)); return action_data.parameter_index.at(ParameterIndexKey(InternalId, name));
} }
}
auto match_query_action = auto match_query_action =
[](CypherStateData &cypher_data, [](CypherStateData &cypher_data,
const QueryActionData &action_data) -> std::string { const QueryActionData &action_data) -> std::string {

View File

@ -2,7 +2,7 @@
#include "database/db.hpp" #include "database/db.hpp"
#include "query_engine/query_result.hpp" #include "query_engine/query_result.hpp"
#include "query_stripped.hpp" #include "query_engine/query_stripped.hpp"
class ICodeCPU class ICodeCPU
{ {

View File

@ -1,8 +1,11 @@
#pragma once #pragma once
#include "i_code_cpu.hpp" #include "query_engine/i_code_cpu.hpp"
#include "dc/dynamic_lib.hpp" #include "dc/dynamic_lib.hpp"
namespace
{
class MemgraphDynamicLib class MemgraphDynamicLib
{ {
public: public:
@ -16,3 +19,5 @@ const std::string MemgraphDynamicLib::produce_name = "produce";
const std::string MemgraphDynamicLib::destruct_name = "destruct"; const std::string MemgraphDynamicLib::destruct_name = "destruct";
using CodeLib = DynamicLib<MemgraphDynamicLib>; using CodeLib = DynamicLib<MemgraphDynamicLib>;
}

View File

@ -15,7 +15,7 @@
class ProgramExecutor class ProgramExecutor
{ {
public: public:
auto execute(QueryProgram &program) auto execute(QueryProgram &program, Db& db)
{ {
try { try {
// TODO: return result of query/code exection // TODO: return result of query/code exection
@ -25,9 +25,4 @@ public:
throw QueryEngineException("code execution error"); throw QueryEngineException("code execution error");
} }
} }
public:
// TODO: here shoud be one database from DBMS, not local instance of
// DB
Db db;
}; };

View File

@ -6,12 +6,12 @@
#define NOT_LOG_INFO #define NOT_LOG_INFO
#include "code_compiler.hpp"
#include "code_generator.hpp"
#include "config/config.hpp" #include "config/config.hpp"
#include "memgraph_dynamic_lib.hpp" #include "query_engine/code_compiler.hpp"
#include "query_program.hpp" #include "query_engine/code_generator.hpp"
#include "query_stripper.hpp" #include "query_engine/memgraph_dynamic_lib.hpp"
#include "query_engine/query_program.hpp"
#include "query_engine/query_stripper.hpp"
#include "utils/hashing/fnv.hpp" #include "utils/hashing/fnv.hpp"
#include "utils/log/logger.hpp" #include "utils/log/logger.hpp"

View File

@ -3,6 +3,7 @@
#include "program_executor.hpp" #include "program_executor.hpp"
#include "program_loader.hpp" #include "program_loader.hpp"
#include "query_result.hpp" #include "query_result.hpp"
#include "database/db.hpp"
// //
// Current arhitecture: // Current arhitecture:
@ -17,11 +18,11 @@
class QueryEngine class QueryEngine
{ {
public: public:
auto execute(const std::string &query) auto execute(const std::string &query, Db& db)
{ {
// TODO: error handling // TODO: error handling
auto program = program_loader.load(query); auto program = program_loader.load(query);
auto result = program_executor.execute(program); auto result = program_executor.execute(program, db);
return result; return result;
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "i_code_cpu.hpp" #include "query_engine/i_code_cpu.hpp"
#include "query_stripped.hpp" #include "query_engine/query_stripped.hpp"
struct QueryProgram struct QueryProgram
{ {

View File

@ -62,15 +62,4 @@ const std::string print_properties =
const std::string print_property = const std::string print_property =
"cout_property(\"{0}\", {0}.property(\"{1}\"));"; "cout_property(\"{0}\", {0}.property(\"{1}\"));";
std::string debug_print_vertex_labels()
{
#ifdef DEBUG
return code_line("PRINT_PROPS(vertex_accessor.properties());") +
code_line("cout << \"LABELS:\" << endl;") +
code_line("for (auto label_ref : vertex_accessor.labels()) {") +
code_line("cout << label_ref.get() << endl;") + code_line("}");
#else
return "";
#endif
}
} }

View File

@ -92,6 +92,13 @@ private:
// TODO: remove this constraint // TODO: remove this constraint
bool has_return; bool has_return;
void finish_query_execution()
{
generator.add_action(QueryAction::TransactionCommit);
code += generator.generate();
generator.clear();
}
public: public:
void semantic_check() const void semantic_check() const
{ {
@ -108,6 +115,9 @@ public:
generator.add_action(QueryAction::TransactionBegin); generator.add_action(QueryAction::TransactionBegin);
Traverser::visit(write_query); Traverser::visit(write_query);
// TODO: put this inside the top level mentioned above
finish_query_execution();
} }
void visit(ast::ReadQuery &read_query) override void visit(ast::ReadQuery &read_query) override
@ -115,6 +125,8 @@ public:
generator.add_action(QueryAction::TransactionBegin); generator.add_action(QueryAction::TransactionBegin);
Traverser::visit(read_query); Traverser::visit(read_query);
finish_query_execution();
} }
void visit(ast::UpdateQuery &update_query) override void visit(ast::UpdateQuery &update_query) override
@ -122,6 +134,8 @@ public:
generator.add_action(QueryAction::TransactionBegin); generator.add_action(QueryAction::TransactionBegin);
Traverser::visit(update_query); Traverser::visit(update_query);
finish_query_execution();
} }
void visit(ast::DeleteQuery &delete_query) override void visit(ast::DeleteQuery &delete_query) override
@ -129,6 +143,8 @@ public:
generator.add_action(QueryAction::TransactionBegin); generator.add_action(QueryAction::TransactionBegin);
Traverser::visit(delete_query); Traverser::visit(delete_query);
finish_query_execution();
} }
void visit(ast::ReadWriteQuery &read_write_query) override void visit(ast::ReadWriteQuery &read_write_query) override
@ -136,6 +152,8 @@ public:
generator.add_action(QueryAction::TransactionBegin); generator.add_action(QueryAction::TransactionBegin);
Traverser::visit(read_write_query); Traverser::visit(read_write_query);
finish_query_execution();
} }
void visit(ast::Match &ast_match) override void visit(ast::Match &ast_match) override
@ -188,12 +206,6 @@ public:
Traverser::visit(ast_return); Traverser::visit(ast_return);
// TODO: move commit somewhare that is more appropriate
generator.add_action(QueryAction::TransactionCommit);
code += generator.generate();
generator.clear();
} }
void visit(ast::ReturnList &ast_return_list) override void visit(ast::ReturnList &ast_return_list) override

View File

@ -11,46 +11,34 @@
using std::cout; using std::cout;
using std::endl; using std::endl;
void print_props(const Properties &properties) void print_props(const Properties &properties);
{
StringBuffer buffer;
JsonWriter<StringBuffer> writer(buffer);
properties.accept(writer);
cout << buffer.str() << endl;
}
#ifdef DEBUG #ifdef NDEBUG
#define PRINT_PROPS(_PROPS_) print_props(_PROPS_);
#else
#define PRINT_PROPS(_) #define PRINT_PROPS(_)
#else
#define PRINT_PROPS(_PROPS_) print_props(_PROPS_);
#endif #endif
void cout_properties(const Properties &properties) void cout_properties(const Properties &properties);
{
ConsoleWriter writer;
properties.accept(writer);
cout << "----" << endl;
}
void cout_property(const std::string &key, const Property &property) void cout_property(const std::string &key, const Property &property);
{
ConsoleWriter writer; // this is a nice way how to avoid multiple definition problem with
writer.handle(key, property); // headers because it will create a unique namespace for each compilation unit
cout << "----" << endl; // http://stackoverflow.com/questions/2727582/multiple-definition-in-header-file
} namespace
{
// wrapper for fmt format
template <typename... Args> template <typename... Args>
std::string format(const std::string &format_str, const Args &... args) std::string format(const std::string &format_str, const Args &... args)
{ {
return fmt::format(format_str, args...); return fmt::format(format_str, args...);
} }
// wrapper for single code line
template <typename... Args> template <typename... Args>
std::string code_line(const std::string &format_str, const Args &... args) std::string code_line(const std::string &format_str, const Args &... args)
{ {
return "\t" + format(format_str, args...) + "\n"; return "\t" + format(format_str, args...) + "\n";
} }
}

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include "mvcc/record.hpp" #include "mvcc/record.hpp"
#include "model/edge_model.hpp" #include "storage/model/edge_model.hpp"
#include "model/properties/traversers/jsonwriter.hpp" #include "storage/model/properties/traversers/jsonwriter.hpp"
class Edge : public mvcc::Record<Edge> class Edge : public mvcc::Record<Edge>
{ {

16
include/storage/edges.hpp Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include "data_structures/concurrent/concurrent_map.hpp"
#include "storage/common.hpp"
#include "storage/edge_accessor.hpp"
class Edges
{
public:
Edge::Accessor find(tx::Transaction &t, const Id &id);
Edge::Accessor insert(tx::Transaction &t);
private:
ConcurrentMap<uint64_t, EdgeRecord> edges;
AtomicCounter<uint64_t> counter;
};

View File

@ -10,8 +10,8 @@ class Graph
public: public:
Graph() {} Graph() {}
Edges edges;
Vertices vertices; Vertices vertices;
Edges edges;
LabelStore label_store; LabelStore label_store;
EdgeTypeStore edge_type_store; EdgeTypeStore edge_type_store;

Some files were not shown because too many files have changed in this diff Show More