CRU operations are fully supported, D (delete) is missing
This commit is contained in:
parent
d04cf101b4
commit
f05c1f6dab
@ -4,30 +4,30 @@
|
||||
#include "storage/model/properties/all.hpp"
|
||||
|
||||
template <class Handler>
|
||||
void accept(Property &property, Handler &h)
|
||||
void accept(const Property &property, Handler &h)
|
||||
{
|
||||
switch (property.flags) {
|
||||
|
||||
case Property::Flags::True:
|
||||
return h.handle(static_cast<Bool &>(property));
|
||||
return h.handle(static_cast<const Bool &>(property));
|
||||
|
||||
case Property::Flags::False:
|
||||
return h.handle(static_cast<Bool &>(property));
|
||||
return h.handle(static_cast<const Bool &>(property));
|
||||
|
||||
case Property::Flags::String:
|
||||
return h.handle(static_cast<String &>(property));
|
||||
return h.handle(static_cast<const String &>(property));
|
||||
|
||||
case Property::Flags::Int32:
|
||||
return h.handle(static_cast<Int32 &>(property));
|
||||
return h.handle(static_cast<const Int32 &>(property));
|
||||
|
||||
case Property::Flags::Int64:
|
||||
return h.handle(static_cast<Int64 &>(property));
|
||||
return h.handle(static_cast<const Int64 &>(property));
|
||||
|
||||
case Property::Flags::Float:
|
||||
return h.handle(static_cast<Float &>(property));
|
||||
return h.handle(static_cast<const Float &>(property));
|
||||
|
||||
case Property::Flags::Double:
|
||||
return h.handle(static_cast<Double &>(property));
|
||||
return h.handle(static_cast<const Double &>(property));
|
||||
|
||||
default:
|
||||
return;
|
||||
|
@ -2,23 +2,6 @@
|
||||
|
||||
#include "query_engine/code_generator/handlers/includes.hpp"
|
||||
|
||||
using Direction = RelationshipData::Direction;
|
||||
|
||||
auto update_properties(const QueryActionData &action_data,
|
||||
const std::string &name)
|
||||
{
|
||||
std::string code = "";
|
||||
|
||||
auto entity_data = action_data.get_entity_property(name);
|
||||
for (auto &property : entity_data.properties) {
|
||||
auto index =
|
||||
action_data.parameter_index.at(ParameterIndexKey(name, property));
|
||||
code += LINE(fmt::format(code::set_property, name, property, index));
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
auto create_query_action =
|
||||
[](CypherStateData &cypher_data,
|
||||
const QueryActionData &action_data) -> std::string {
|
||||
|
@ -6,9 +6,26 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "query_engine/util.hpp"
|
||||
#include "query_engine/code_generator/cypher_state.hpp"
|
||||
#include "query_engine/code_generator/query_action_data.hpp"
|
||||
#include "query_engine/traverser/code.hpp"
|
||||
#include "query_engine/exceptions/errors.hpp"
|
||||
|
||||
using ParameterIndexKey::Type::InternalId;
|
||||
using Direction = RelationshipData::Direction;
|
||||
|
||||
auto update_properties(const QueryActionData &action_data,
|
||||
const std::string &name)
|
||||
{
|
||||
std::string code = "";
|
||||
|
||||
auto entity_data = action_data.get_entity_property(name);
|
||||
for (auto &property : entity_data.properties) {
|
||||
auto index =
|
||||
action_data.parameter_index.at(ParameterIndexKey(name, property));
|
||||
code += LINE(fmt::format(code::set_property, name, property, index));
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -19,10 +19,10 @@ auto return_query_action =
|
||||
fmt::format("{} couldn't be found (RETURN clause).", entity));
|
||||
}
|
||||
if (element.is_entity_only()) {
|
||||
code += LINE(fmt::format("// RETURN: {}", entity));
|
||||
code += LINE(fmt::format(code::print_properties, entity));
|
||||
} else if (element.is_projection()) {
|
||||
auto &property = element.property;
|
||||
code += LINE(fmt::format("// RETURN: {}.{}", entity, property));
|
||||
code += LINE(fmt::format(code::print_property, entity, property));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,14 +3,8 @@
|
||||
#include "database/db.hpp"
|
||||
#include "query_engine/query_stripper.hpp"
|
||||
#include "storage/model/properties/property.hpp"
|
||||
#include "storage/model/properties/traversers/consolewriter.hpp"
|
||||
#include "utils/command_line/arguments.hpp"
|
||||
|
||||
void cout_properties(const Properties &properties)
|
||||
{
|
||||
ConsoleWriter writer;
|
||||
properties.accept(writer);
|
||||
}
|
||||
#include "query_engine/util.hpp"
|
||||
|
||||
auto load_queries(Db& db)
|
||||
{
|
||||
@ -147,7 +141,7 @@ auto load_queries(Db& db)
|
||||
return true;
|
||||
};
|
||||
|
||||
// MATCH (n1), (n2) WHERE ID(n1)=0 AND ID(n2)=1 CREATE (n1)<-[r:IS {age: 25, weight: 70}]-(n2) RETURN r]
|
||||
// MATCH (n1), (n2) WHERE ID(n1)=0 AND ID(n2)=1 CREATE (n1)<-[r:IS {age: 25, weight: 70}]-(n2) RETURN r
|
||||
auto create_edge_v2 = [&db](const properties_t &args)
|
||||
{
|
||||
auto& t = db.tx_engine.begin();
|
||||
@ -178,6 +172,5 @@ auto load_queries(Db& db)
|
||||
queries[6813335159006269041u] = update_node;
|
||||
queries[4857652843629217005u] = find_by_label;
|
||||
|
||||
|
||||
return queries;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "query_engine/util.hpp"
|
||||
#include "query_engine/i_code_cpu.hpp"
|
||||
#include "storage/model/properties/all.hpp"
|
||||
|
||||
|
@ -34,7 +34,7 @@ const std::string find_type =
|
||||
"auto &{0} = db.graph.edge_type_store.find_or_create(\"{0}\");";
|
||||
const std::string set_type = "{}.edge_type({});";
|
||||
const std::string node_out = "{}.vlist->update(t)->data.out.add({}.vlist);";
|
||||
const std::string node_in = "{}.vlist->update(t)->data.in.add({}.vlist);";
|
||||
const std::string node_in = "{}.vlist->update(t)->data.in.add({}.vlist);";
|
||||
const std::string edge_from = "{}.from({}.vlist);";
|
||||
const std::string edge_to = "{}.to({}.vlist);";
|
||||
|
||||
@ -50,13 +50,17 @@ const std::string match_edge_by_id =
|
||||
"auto {0} = db.graph.edges.find(t, args[{1}]->as<Int64>().value);\n"
|
||||
" if (!{0}) return t.commit(), std::make_shared<QueryResult>();";
|
||||
|
||||
|
||||
const std::string return_empty_result =
|
||||
"return std::make_shared<QueryResult>();";
|
||||
|
||||
const std::string update_property = "{}.property(\"{}\", args[{}]);";
|
||||
|
||||
const std::string todo = "// TODO: {}";
|
||||
const std::string print_properties =
|
||||
"cout << \"{0}\" << endl;\n"
|
||||
" cout_properties({0}.properties());";
|
||||
const std::string print_property =
|
||||
"cout_property(\"{0}\", {0}.property(\"{1}\"));";
|
||||
|
||||
std::string debug_print_vertex_labels()
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "storage/model/properties/properties.hpp"
|
||||
#include "storage/model/properties/traversers/jsonwriter.hpp"
|
||||
#include "storage/model/properties/traversers/consolewriter.hpp"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@ -24,3 +25,17 @@ void print_props(const Properties &properties)
|
||||
#else
|
||||
#define PRINT_PROPS(_)
|
||||
#endif
|
||||
|
||||
void cout_properties(const Properties &properties)
|
||||
{
|
||||
ConsoleWriter writer;
|
||||
properties.accept(writer);
|
||||
cout << "----" << endl;
|
||||
}
|
||||
|
||||
void cout_property(const std::string& key, const Property& property)
|
||||
{
|
||||
ConsoleWriter writer;
|
||||
writer.handle(key, property);
|
||||
cout << "----" << endl;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class ConsoleWriter
|
||||
public:
|
||||
ConsoleWriter() {}
|
||||
|
||||
void handle(const std::string &key, Property &value)
|
||||
void handle(const std::string &key, const Property &value)
|
||||
{
|
||||
cout << "KEY: " << key << "; VALUE: ";
|
||||
|
||||
@ -24,17 +24,17 @@ public:
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
void handle(Bool &b) { cout << b.value(); }
|
||||
void handle(const Bool &b) { cout << b.value(); }
|
||||
|
||||
void handle(String &s) { cout << s.value; }
|
||||
void handle(const String &s) { cout << s.value; }
|
||||
|
||||
void handle(Int32 &int32) { cout << int32.value; }
|
||||
void handle(const Int32 &int32) { cout << int32.value; }
|
||||
|
||||
void handle(Int64 &int64) { cout << int64.value; }
|
||||
void handle(const Int64 &int64) { cout << int64.value; }
|
||||
|
||||
void handle(Float &f) { cout << f.value; }
|
||||
void handle(const Float &f) { cout << f.value; }
|
||||
|
||||
void handle(Double &d) { cout << d.value; }
|
||||
void handle(const Double &d) { cout << d.value; }
|
||||
|
||||
void finish() {}
|
||||
};
|
||||
|
@ -9,7 +9,7 @@ struct JsonWriter
|
||||
public:
|
||||
JsonWriter(Buffer &buffer) : buffer(buffer) { buffer << '{'; };
|
||||
|
||||
void handle(const std::string &key, Property &value)
|
||||
void handle(const std::string &key, const Property &value)
|
||||
{
|
||||
if (!first) buffer << ',';
|
||||
|
||||
@ -20,17 +20,17 @@ public:
|
||||
accept(value, *this);
|
||||
}
|
||||
|
||||
void handle(Bool &b) { buffer << (b.value() ? "true" : "false"); }
|
||||
void handle(const Bool &b) { buffer << (b.value() ? "true" : "false"); }
|
||||
|
||||
void handle(String &s) { buffer << '"' << s.value << '"'; }
|
||||
void handle(const String &s) { buffer << '"' << s.value << '"'; }
|
||||
|
||||
void handle(Int32 &int32) { buffer << std::to_string(int32.value); }
|
||||
void handle(const Int32 &int32) { buffer << std::to_string(int32.value); }
|
||||
|
||||
void handle(Int64 &int64) { buffer << std::to_string(int64.value); }
|
||||
void handle(const Int64 &int64) { buffer << std::to_string(int64.value); }
|
||||
|
||||
void handle(Float &f) { buffer << std::to_string(f.value); }
|
||||
void handle(const Float &f) { buffer << std::to_string(f.value); }
|
||||
|
||||
void handle(Double &d) { buffer << std::to_string(d.value); }
|
||||
void handle(const Double &d) { buffer << std::to_string(d.value); }
|
||||
|
||||
void finish() { buffer << '}'; }
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "exceptions/basic_exception.hpp"
|
||||
|
@ -6,6 +6,12 @@ set(src_dir ${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
include_directories(${catch_source_dir}/include)
|
||||
|
||||
# TODO: modular approach (REFACTOR)
|
||||
# add_executable()
|
||||
# target_link_libraries()
|
||||
# add_test(NAME COMMAND)
|
||||
# set_property(TARGET PROPERTY CXX_STANDARD 14)
|
||||
|
||||
## UNIT TESTS
|
||||
|
||||
# find unit tests
|
||||
@ -52,13 +58,24 @@ endforeach()
|
||||
|
||||
## INTEGRATION TESTS
|
||||
|
||||
# build integration tests
|
||||
# message(STATUS ${memgraph_src_files})
|
||||
# test hard coded queries
|
||||
add_executable(integration_queries integration/queries.cpp ${memgraph_src_files})
|
||||
target_link_libraries(integration_queries ${fmt_static_lib})
|
||||
add_test(NAME integration_queries COMMAND integration_queries)
|
||||
set_property(TARGET integration_queries PROPERTY CXX_STANDARD 14)
|
||||
|
||||
# test query engine
|
||||
add_executable(integration_query_engine integration/query_engine.cpp)
|
||||
# target_link_libraries()
|
||||
add_test(NAME integration_query_engine COMMAND integration_query_engine)
|
||||
set_property(TARGET integration_query_engine PROPERTY CXX_STANDARD 14)
|
||||
|
||||
# test memgraph with bolt protocol
|
||||
add_executable(integration_memgraph_bolt integration/memgraph_bolt.cpp)
|
||||
# target_link_libraries()
|
||||
add_test(NAME integration_memgraph_bolt COMMAND integration_memgraph_bolt)
|
||||
set_property(TARGET integration_memgraph_bolt PROPERTY CXX_STANDARD 14)
|
||||
|
||||
## MANUAL TESTS
|
||||
|
||||
# cypher_ast
|
||||
|
7
tests/integration/memgraph_bolt.cpp
Normal file
7
tests/integration/memgraph_bolt.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "utils/assert.hpp"
|
||||
|
||||
auto main() -> int
|
||||
{
|
||||
permanent_assert(false, "TODO: implement memgraph bolt integration test");
|
||||
return 0;
|
||||
}
|
7
tests/integration/query_engine.cpp
Normal file
7
tests/integration/query_engine.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "utils/assert.hpp"
|
||||
|
||||
auto main() -> int
|
||||
{
|
||||
permanent_assert(false, "TODO: implement query engine integration test");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user