barrier ifdefs (TODO: barrier should be removed)
This commit is contained in:
parent
51b17c2402
commit
6cce530b6c
@ -14,12 +14,6 @@ find_package(Threads REQUIRED)
|
||||
# c++14
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
|
||||
|
||||
# glibcxx debug (useful for gdb)
|
||||
# the problem is that the query engine doesn't work as it should work if
|
||||
# this flag is present
|
||||
# TODO: find more appropriate way to use this flag only when it is needed
|
||||
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
|
||||
|
||||
# functions
|
||||
|
||||
# prints all included directories
|
||||
@ -305,7 +299,10 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
endif()
|
||||
|
||||
# release flags
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
|
||||
#debug flags
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g2 ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
|
||||
# TODO: find a way how to applay the defines at the query compile time
|
||||
# -- configure defines -- default is ON | true | enabled ----------------------
|
||||
@ -367,6 +364,16 @@ if(NDEBUG)
|
||||
add_definitions( -DNDEBUG )
|
||||
endif()
|
||||
# -- ndebug -------------------------------------------------------------------
|
||||
# -- GLIBCXX_DEBUG ------------------------------------------------------------
|
||||
# glibcxx debug (useful for gdb)
|
||||
# the problem is that the query engine doesn't work as it should work if
|
||||
# this flag is present
|
||||
option(GLIBCXX_DEBUG "glibc debug" OFF)
|
||||
message(STATUS "GLIBCXX_DEBUG: ${GLIBCXX_DEBUG} (solves problem with _M_dataplus member during a debugging process")
|
||||
if(GLIBCXX_DEBUG)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-D_GLIBCXX_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
endif()
|
||||
# -----------------------------------------------------------------------------
|
||||
# -- binaries -----------------------------------------------------------------
|
||||
option(MEMGRAPH "Build memgraph binary" ON)
|
||||
message(STATUS "MEMGRAPH binary: ${MEMGRAPH}")
|
||||
@ -537,6 +544,10 @@ string(STRIP ${COMMIT_HASH} COMMIT_HASH)
|
||||
set(MEMGRAPH_BUILD_NAME
|
||||
"memgraph_${COMMIT_NO}_${COMMIT_HASH}_${COMMIT_BRANCH}_${CMAKE_BUILD_TYPE}")
|
||||
|
||||
message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}")
|
||||
message(STATUS "Debug flags: ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
message(STATUS "Release flags: ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
|
||||
# memgraph main executable
|
||||
if (MEMGRAPH)
|
||||
add_executable(${MEMGRAPH_BUILD_NAME} ${src_dir}/memgraph_bolt.cpp)
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef BARRIER
|
||||
|
||||
#include "barrier/common.hpp"
|
||||
|
||||
// This namespace is holding header parts of barrier classes. Barrier class
|
||||
@ -578,3 +580,5 @@ class Db : protected Unsized
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef BARRIER
|
||||
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <type_traits>
|
||||
@ -136,3 +138,5 @@ private:
|
||||
typename std::aligned_storage<size_B, alignment_B>::type data;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef BARRIER
|
||||
|
||||
#include "barrier/barrier.hpp"
|
||||
|
||||
// This is the place for imports from memgraph .hpp
|
||||
@ -263,3 +265,5 @@ INSTANTIATE_FOR_PROPERTY(EdgePropertyType_constructor);
|
||||
|
||||
DbAccessor::DbAccessor(Db &db) : Sized(::DbAccessor(trans(db))) {}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -54,8 +54,6 @@ private:
|
||||
std::map<std::string, EntitySource> entity_source;
|
||||
std::map<std::string, std::vector<std::string>> entity_tags;
|
||||
|
||||
// TODO: container that keeps track about c++ variable names
|
||||
|
||||
public:
|
||||
bool exist(const std::string &name) const
|
||||
{
|
||||
@ -130,4 +128,13 @@ public:
|
||||
{
|
||||
entity_tags[name] = tags;
|
||||
}
|
||||
|
||||
void tag(const std::string& name, const std::string& new_tag)
|
||||
{
|
||||
if (entity_tags.find(name) != entity_tags.end())
|
||||
{
|
||||
entity_tags[name] = std::vector<std::string>{};
|
||||
}
|
||||
entity_tags[name].emplace_back(new_tag);
|
||||
}
|
||||
};
|
||||
|
@ -73,12 +73,26 @@ auto return_query_action =
|
||||
for (auto const &kv : action_data.actions)
|
||||
{
|
||||
auto name = kv.first;
|
||||
|
||||
if (kv.second == ClauseAction::ReturnCount)
|
||||
{
|
||||
if (cypher_data.source(name) == EntitySource::MainStorage)
|
||||
{
|
||||
code += code_line(code::count, name);
|
||||
}
|
||||
|
||||
if (cypher_data.source(name) == EntitySource::LabelIndex)
|
||||
{
|
||||
auto tags = cypher_data.tags(name);
|
||||
if (tags.size() == 1) {
|
||||
auto label = tags.at(0);
|
||||
code += code_line(code::count_vertices_for_one_label,
|
||||
name, label);
|
||||
}
|
||||
// TODO: do for more, isn't easy because of
|
||||
// multiple iterators, but we have iterator infrastructure
|
||||
// to do that
|
||||
}
|
||||
}
|
||||
if (kv.second == ClauseAction::ReturnLabels)
|
||||
{
|
||||
|
@ -3,12 +3,43 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "barrier/barrier.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef BARRIER
|
||||
|
||||
#include "barrier/barrier.hpp"
|
||||
namespace barrier
|
||||
{
|
||||
|
||||
#else
|
||||
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "mvcc/id.hpp"
|
||||
#include "storage/indexes/index_definition.hpp"
|
||||
#include "storage/model/properties/all.hpp"
|
||||
#include "storage/model/properties/property.hpp"
|
||||
#include "utils/border.hpp"
|
||||
#include "utils/iterator/iterator.hpp"
|
||||
#include "utils/option_ptr.hpp"
|
||||
#include "utils/reference_wrapper.hpp"
|
||||
#include "database/db.hpp"
|
||||
#include "database/db_accessor.hpp"
|
||||
#include "utils/iterator/iterator.hpp"
|
||||
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
||||
#include "communication/bolt/v1/serialization/record_stream.hpp"
|
||||
#include "database/db.hpp"
|
||||
#include "database/db_accessor.hpp"
|
||||
#include "io/network/socket.hpp"
|
||||
#include "storage/edge_type/edge_type.hpp"
|
||||
#include "storage/edge_x_vertex.hpp"
|
||||
#include "storage/label/label.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
auto load_queries(Db &db)
|
||||
{
|
||||
std::map<uint64_t, std::function<bool(properties_t &&)>> queries;
|
||||
@ -475,4 +506,7 @@ auto load_queries(Db &db)
|
||||
|
||||
return queries;
|
||||
}
|
||||
|
||||
#ifdef BARRIER
|
||||
}
|
||||
#endif
|
||||
|
@ -105,6 +105,19 @@ const std::string find_and_write_edges_by_type =
|
||||
" }});\n"
|
||||
" stream.write_meta(\"rw\");\n";
|
||||
|
||||
const std::string count_vertices_for_one_label =
|
||||
"size_t count = 0;\n"
|
||||
"auto &label = t.label_find_or_create(\"{1}\");\n"
|
||||
" label.index().for_range(t).for_all([&](auto vertex) {{\n"
|
||||
" count++;\n"
|
||||
" }});\n"
|
||||
" stream.write_field(\"count({0})\");\n"
|
||||
" stream.write_record();\n"
|
||||
" stream.write_list_header(1);\n"
|
||||
" stream.write(Int64(count));\n"
|
||||
" stream.chunk();\n"
|
||||
" stream.write_meta(\"r\");\n";
|
||||
|
||||
// TODO: vertices and edges
|
||||
const std::string count =
|
||||
"size_t count = 0;\n"
|
||||
|
@ -209,7 +209,6 @@ public:
|
||||
query_action = QueryAction::Return;
|
||||
|
||||
Traverser::visit(ast_return);
|
||||
|
||||
}
|
||||
|
||||
void visit(ast::ReturnList &ast_return_list) override
|
||||
@ -374,6 +373,7 @@ public:
|
||||
void visit(ast::LabelList &ast_label_list) override
|
||||
{
|
||||
auto &action_data = generator.action_data();
|
||||
auto &cypher_data = generator.cypher_data();
|
||||
|
||||
if (!ast_label_list.has_value()) return;
|
||||
|
||||
@ -382,6 +382,9 @@ public:
|
||||
action_data.add_entity_tag(entity, label);
|
||||
action_data.csm.search_cost(entity, entity_search::search_label_index,
|
||||
entity_search::label_cost);
|
||||
cypher_data.tag(entity, label);
|
||||
// TODO: it shouldn't be decided here
|
||||
cypher_data.source(entity, EntitySource::LabelIndex);
|
||||
|
||||
Traverser::visit(ast_label_list);
|
||||
}
|
||||
@ -525,9 +528,9 @@ public:
|
||||
auto &action_data = generator.action_data();
|
||||
auto &cypher_data = generator.cypher_data();
|
||||
|
||||
if (state == CypherState::Return)
|
||||
{
|
||||
// if (state == CypherState::Return)
|
||||
// {
|
||||
action_data.actions[ast_count.argument] = ClauseAction::ReturnCount;
|
||||
}
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "query_engine/hardcode/queries.hpp"
|
||||
|
||||
#ifdef BARRIER
|
||||
#include "barrier/barrier.cpp"
|
||||
#endif
|
||||
|
||||
#include "logging/default.hpp"
|
||||
#include "logging/streams/stdout.hpp"
|
||||
@ -35,7 +37,11 @@ int main(void)
|
||||
|
||||
Db db("cleaning");
|
||||
|
||||
#ifdef BARRIER
|
||||
auto query_functions = load_queries(barrier::trans(db));
|
||||
#else
|
||||
auto query_functions = load_queries(db);
|
||||
#endif
|
||||
|
||||
auto stripper = make_query_stripper(TK_LONG, TK_FLOAT, TK_STR, TK_BOOL);
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
#include <random>
|
||||
|
||||
#ifdef BARRIER
|
||||
#include "barrier/barrier.cpp"
|
||||
#endif
|
||||
|
||||
#include "logging/default.hpp"
|
||||
#include "logging/streams/stdout.hpp"
|
||||
@ -21,7 +23,13 @@ auto rand_gen(size_t n)
|
||||
void run(size_t n, std::string &query, Db &db)
|
||||
{
|
||||
auto stripper = make_query_stripper(TK_LONG, TK_FLOAT, TK_STR, TK_BOOL);
|
||||
|
||||
#ifdef BARRIER
|
||||
auto qf = load_queries(barrier::trans(db));
|
||||
#else
|
||||
auto qf = load_queries(db);
|
||||
#endif
|
||||
|
||||
auto stripped = stripper.strip(query);
|
||||
std::cout << "Running query [" << stripped.hash << "] for " << n << " time."
|
||||
<< std::endl;
|
||||
@ -34,7 +42,13 @@ void run(size_t n, std::string &query, Db &db)
|
||||
void add_edge(size_t n, Db &db)
|
||||
{
|
||||
auto stripper = make_query_stripper(TK_LONG, TK_FLOAT, TK_STR, TK_BOOL);
|
||||
|
||||
#ifdef BARRIER
|
||||
auto qf = load_queries(barrier::trans(db));
|
||||
#else
|
||||
auto qf = load_queries(db);
|
||||
#endif
|
||||
|
||||
std::string query = "MATCH (n1), (n2) WHERE ID(n1)=0 AND "
|
||||
"ID(n2)=1 CREATE (n1)<-[r:IS {age: "
|
||||
"25,weight: 70}]-(n2) RETURN r";
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "query_engine/hardcode/queries.hpp"
|
||||
|
||||
#ifdef BARRIER
|
||||
#include "barrier/barrier.cpp"
|
||||
#endif
|
||||
|
||||
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
||||
#include "database/db.hpp"
|
||||
@ -20,7 +22,11 @@ int main(void)
|
||||
|
||||
Db db;
|
||||
|
||||
#ifdef BARRIER
|
||||
auto query_functions = load_queries(barrier::trans(db));
|
||||
#else
|
||||
auto query_functions = load_queries(db);
|
||||
#endif
|
||||
|
||||
auto stripper = make_query_stripper(TK_LONG, TK_FLOAT, TK_STR, TK_BOOL);
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
#include <random>
|
||||
|
||||
#ifdef BARRIER
|
||||
#include "barrier/barrier.cpp"
|
||||
#endif
|
||||
|
||||
#include "logging/default.hpp"
|
||||
#include "logging/streams/stdout.hpp"
|
||||
@ -21,7 +23,13 @@ auto rand_gen(size_t n)
|
||||
void run(size_t n, std::string &query, Db &db)
|
||||
{
|
||||
auto stripper = make_query_stripper(TK_LONG, TK_FLOAT, TK_STR, TK_BOOL);
|
||||
|
||||
#ifdef BARRIER
|
||||
auto qf = load_queries(barrier::trans(db));
|
||||
#else
|
||||
auto qf = load_queries(db);
|
||||
#endif
|
||||
|
||||
auto stripped = stripper.strip(query);
|
||||
std::cout << "Running query [" << stripped.hash << "] for " << n << " time."
|
||||
<< std::endl;
|
||||
@ -34,7 +42,12 @@ void run(size_t n, std::string &query, Db &db)
|
||||
void add_edge(size_t n, Db &db)
|
||||
{
|
||||
auto stripper = make_query_stripper(TK_LONG, TK_FLOAT, TK_STR, TK_BOOL);
|
||||
#ifdef BARRIER
|
||||
auto qf = load_queries(barrier::trans(db));
|
||||
#else
|
||||
auto qf = load_queries(db);
|
||||
#endif
|
||||
|
||||
std::string query = "MATCH (n1), (n2) WHERE ID(n1)=0 AND "
|
||||
"ID(n2)=1 CREATE (n1)<-[r:IS {age: "
|
||||
"25,weight: 70}]-(n2) RETURN r";
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
#include "query_engine/hardcode/queries.hpp"
|
||||
|
||||
#ifdef BARRIER
|
||||
#include "barrier/barrier.cpp"
|
||||
#endif
|
||||
|
||||
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
||||
#include "database/db.hpp"
|
||||
@ -17,7 +19,11 @@ using namespace std;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Db db;
|
||||
#ifdef BARRIER
|
||||
auto queries = load_queries(barrier::trans(db));
|
||||
#else
|
||||
auto queries = load_queries(db);
|
||||
#endif
|
||||
|
||||
// auto arguments = all_arguments(argc, argv);
|
||||
// auto input_query = extract_query(arguments);
|
||||
|
Loading…
Reference in New Issue
Block a user