Everything is prepared for code generation for query like MATCH (n:Label {properties}) RETURN n
This commit is contained in:
parent
6cce530b6c
commit
8ff79c3ace
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@
|
|||||||
*.swo
|
*.swo
|
||||||
*.out
|
*.out
|
||||||
*.so
|
*.so
|
||||||
|
*.o
|
||||||
*.dSYM/
|
*.dSYM/
|
||||||
memgraph
|
memgraph
|
||||||
*~
|
*~
|
||||||
|
@ -10,8 +10,8 @@ namespace logging
|
|||||||
{
|
{
|
||||||
namespace format
|
namespace format
|
||||||
{
|
{
|
||||||
std::string out = "{} {:<5} [{}] {}\n";
|
static const std::string out = "{} {:<5} [{}] {}\n";
|
||||||
std::string err = out;
|
static const std::string err = out;
|
||||||
|
|
||||||
// TODO: configurable formats
|
// TODO: configurable formats
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,19 @@ enum class EntitySource : uint8_t
|
|||||||
MainStorage
|
MainStorage
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: reduce copying
|
||||||
class CypherStateData
|
class CypherStateData
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
using tags_type = std::vector<std::string>;
|
||||||
|
using properties_type = std::map<std::string, int64_t>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, EntityStatus> entity_status;
|
std::map<std::string, EntityStatus> entity_status;
|
||||||
std::map<std::string, EntityType> entity_type;
|
std::map<std::string, EntityType> entity_type;
|
||||||
std::map<std::string, EntitySource> entity_source;
|
std::map<std::string, EntitySource> entity_source;
|
||||||
std::map<std::string, std::vector<std::string>> entity_tags;
|
std::map<std::string, tags_type> entity_tags;
|
||||||
|
std::map<std::string, properties_type> entity_properties;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool exist(const std::string &name) const
|
bool exist(const std::string &name) const
|
||||||
@ -83,14 +89,7 @@ public:
|
|||||||
return entity_source.at(name);
|
return entity_source.at(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto tags(const std::string& name) const
|
const std::map<std::string, EntityType> &all_typed_enteties()
|
||||||
{
|
|
||||||
if (entity_tags.find(name) == entity_tags.end())
|
|
||||||
throw CppGeneratorException("No tags for specified entity");
|
|
||||||
return entity_tags.at(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::map<std::string, EntityType> &all_typed_enteties()
|
|
||||||
{
|
{
|
||||||
return entity_type;
|
return entity_type;
|
||||||
}
|
}
|
||||||
@ -123,8 +122,16 @@ public:
|
|||||||
{
|
{
|
||||||
entity_source[name] = source;
|
entity_source[name] = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// entity tags
|
||||||
|
auto tags(const std::string& name) const
|
||||||
|
{
|
||||||
|
if (entity_tags.find(name) == entity_tags.end())
|
||||||
|
throw CppGeneratorException("No tags for specified entity");
|
||||||
|
return entity_tags.at(name);
|
||||||
|
}
|
||||||
|
|
||||||
void tags(const std::string& name, std::vector<std::string> tags)
|
void tags(const std::string& name, tags_type tags)
|
||||||
{
|
{
|
||||||
entity_tags[name] = tags;
|
entity_tags[name] = tags;
|
||||||
}
|
}
|
||||||
@ -137,4 +144,40 @@ public:
|
|||||||
}
|
}
|
||||||
entity_tags[name].emplace_back(new_tag);
|
entity_tags[name].emplace_back(new_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// entity properties
|
||||||
|
auto properties(const std::string& name) const
|
||||||
|
{
|
||||||
|
if (entity_properties.find(name) == entity_properties.end())
|
||||||
|
throw CppGeneratorException("No properties for specified entity");
|
||||||
|
return entity_properties.at(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void properties(const std::string& name, properties_type properties)
|
||||||
|
{
|
||||||
|
entity_properties[name] = properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
void index(const std::string& entity, const std::string& property, int64_t index)
|
||||||
|
{
|
||||||
|
if (entity_properties.find(entity) != entity_properties.end())
|
||||||
|
{
|
||||||
|
entity_properties[entity] = properties_type{};
|
||||||
|
}
|
||||||
|
entity_properties[entity][property] = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto index(const std::string& entity, const std::string& property_name)
|
||||||
|
{
|
||||||
|
if (entity_properties.find(entity) != entity_properties.end())
|
||||||
|
throw CppGeneratorException("No properties for specified entity");
|
||||||
|
|
||||||
|
auto properties = entity_properties.at(entity);
|
||||||
|
|
||||||
|
if (properties.find(property_name) != properties.end())
|
||||||
|
throw CppGeneratorException("No property for specified property name");
|
||||||
|
|
||||||
|
return properties[property_name];
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -48,6 +48,8 @@ auto return_query_action =
|
|||||||
code += code_line(code::find_and_write_vertices_by_label,
|
code += code_line(code::find_and_write_vertices_by_label,
|
||||||
entity, label);
|
entity, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: 16/10/2016 create match code if properties exist
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cypher_data.source(entity) == EntitySource::TypeIndex)
|
if (cypher_data.source(entity) == EntitySource::TypeIndex)
|
||||||
|
@ -409,9 +409,14 @@ public:
|
|||||||
auto prop = property_state.property_name;
|
auto prop = property_state.property_name;
|
||||||
auto index = property_state.property_index;
|
auto index = property_state.property_index;
|
||||||
|
|
||||||
auto &data = generator.action_data();
|
// update action data
|
||||||
data.parameter_index.emplace(ParameterIndexKey(entity, prop), index);
|
auto &action_data = generator.action_data();
|
||||||
data.add_entitiy_property(entity, prop);
|
action_data.parameter_index.emplace(ParameterIndexKey(entity, prop), index);
|
||||||
|
action_data.add_entitiy_property(entity, prop);
|
||||||
|
|
||||||
|
// update cypher data
|
||||||
|
auto &cypher_data = generator.cypher_data();
|
||||||
|
cypher_data.index(entity, prop, index);
|
||||||
|
|
||||||
clear_state();
|
clear_state();
|
||||||
}
|
}
|
||||||
|
48
tests/try/glibcpp_problem/Makefile
Normal file
48
tests/try/glibcpp_problem/Makefile
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# compiler
|
||||||
|
CXX=clang++
|
||||||
|
|
||||||
|
# compile flags
|
||||||
|
CFLAGS=-std=c++1y -pthread -g2 # -D_GLIBCXX_DEBUG
|
||||||
|
|
||||||
|
# includes and libraries
|
||||||
|
INCLUDE_PATHS=-I../../../include -I../../../libs/fmt -I../../../src
|
||||||
|
LIB_PATHS=-L../../../libs/fmt/fmt
|
||||||
|
LDFLAGS=-lfmt
|
||||||
|
|
||||||
|
# source and executable
|
||||||
|
LOG_SRC_PATH=../../..
|
||||||
|
SOURCES=main.cpp async_log.o sync_log.o stderr.o stdout.o default.o levels.o log.o
|
||||||
|
EXECUTABLE=a.out
|
||||||
|
|
||||||
|
# release target
|
||||||
|
all: $(EXECUTABLE)
|
||||||
|
|
||||||
|
$(EXECUTABLE): $(SOURCES)
|
||||||
|
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) $(SOURCES) -o $(EXECUTABLE) $(LIB_PATHS) $(LDFLAGS)
|
||||||
|
|
||||||
|
# TODO: auto
|
||||||
|
async_log.o: ../../../src/logging/logs/async_log.cpp
|
||||||
|
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/logs/async_log.cpp
|
||||||
|
|
||||||
|
sync_log.o: ../../../src/logging/logs/sync_log.cpp
|
||||||
|
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/logs/sync_log.cpp
|
||||||
|
|
||||||
|
stderr.o: ../../../src/logging/streams/stderr.cpp
|
||||||
|
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/streams/stderr.cpp
|
||||||
|
|
||||||
|
stdout.o: ../../../src/logging/streams/stdout.cpp
|
||||||
|
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/streams/stdout.cpp
|
||||||
|
|
||||||
|
default.o: ../../../src/logging/default.cpp
|
||||||
|
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/default.cpp
|
||||||
|
|
||||||
|
levels.o: ../../../src/logging/levels.cpp
|
||||||
|
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/levels.cpp
|
||||||
|
|
||||||
|
log.o: ../../../src/logging/log.cpp
|
||||||
|
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/log.cpp
|
||||||
|
|
||||||
|
.PHONY:
|
||||||
|
clean:
|
||||||
|
rm -f a.out
|
||||||
|
rm -f *.o
|
20
tests/try/glibcpp_problem/main.cpp
Normal file
20
tests/try/glibcpp_problem/main.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "logging/default.hpp"
|
||||||
|
#include "logging/streams/stdout.hpp"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// init logging
|
||||||
|
logging::init_sync();
|
||||||
|
logging::log->pipe(std::make_unique<Stdout>());
|
||||||
|
|
||||||
|
// get Main logger
|
||||||
|
Logger logger;
|
||||||
|
logger = logging::log->logger("Main");
|
||||||
|
logger.info("{}", logging::log->type());
|
||||||
|
|
||||||
|
std::string* test = new std::string("test_value");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user