diff --git a/CMakeLists.txt b/CMakeLists.txt index 50bd9ea68..a9a86c025 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,6 +218,7 @@ FILE(COPY ${include_dir}/storage/model/properties/double.hpp DESTINATION ${build 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/array.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) @@ -370,6 +371,8 @@ option(MEMGRAPH "Build memgraph binary" ON) message(STATUS "MEMGRAPH binary: ${MEMGRAPH}") option(POC "Build proof of concept binaries" ON) message(STATUS "POC binaries: ${POC}") +option(TOOLS "Build tool executables" ON) +message(STATUS "TOOLS binaries: ${TOOLS}") option(TESTS "Build test binaries" ON) message(STATUS "TESTS binaries: ${TESTS}") # -- binaries ----------------------------------------------------------------- @@ -423,6 +426,7 @@ set(memgraph_src_files ${src_dir}/storage/model/properties/null.cpp ${src_dir}/storage/model/properties/bool.cpp ${src_dir}/storage/model/properties/string.cpp + ${src_dir}/storage/model/properties/array.cpp ${src_dir}/storage/model/properties/properties.cpp ${src_dir}/storage/model/properties/property_family.cpp ${src_dir}/storage/indexes/impl/nonunique_unordered_index.cpp @@ -461,6 +465,11 @@ if (POC) add_subdirectory(poc) endif() +# proof of concepts +if (TOOLS) + add_subdirectory(tools) +endif() + # memgraph build name execute_process( OUTPUT_VARIABLE COMMIT_BRANCH diff --git a/include/data_structures/map/rh_common.hpp b/include/data_structures/map/rh_common.hpp index 244e1ec52..c3a016943 100644 --- a/include/data_structures/map/rh_common.hpp +++ b/include/data_structures/map/rh_common.hpp @@ -77,16 +77,17 @@ protected: { protected: IteratorBase() : map(nullptr) { advanced = index = ~((size_t)0); } - IteratorBase(const RhBase *map) : map(map) + IteratorBase(const RhBase *map) { index = 0; while (index < map->capacity && !map->array[index].valid()) { index++; } - if (index == map->capacity) { - map = nullptr; + if (index >= map->capacity) { + this->map = nullptr; advanced = index = ~((size_t)0); } else { + this->map = map; advanced = index; } } diff --git a/include/database/db_accessor.hpp b/include/database/db_accessor.hpp index 32cc0d075..6f6bb9fb6 100644 --- a/include/database/db_accessor.hpp +++ b/include/database/db_accessor.hpp @@ -3,6 +3,7 @@ #include "database/db_transaction.hpp" #include "storage/vertex_accessor.hpp" #include "utils/border.hpp" +// #include "utils/iterator/iterator.hpp" #include "utils/option.hpp" namespace tx @@ -61,15 +62,15 @@ public: // ******************* LABEL METHODS - const Label &label_find_or_create(const std::string &name); + const Label &label_find_or_create(const char *name); - bool label_contains(const std::string &name); + bool label_contains(const char *name); // ******************** TYPE METHODS - const EdgeType &type_find_or_create(const std::string &name); + const EdgeType &type_find_or_create(const char *name); - bool type_contains(const std::string &name); + bool type_contains(const char *name); // ******************** PROPERTY METHODS diff --git a/include/storage/edge_type/edge_type.hpp b/include/storage/edge_type/edge_type.hpp index 364161cd6..2dd64262c 100644 --- a/include/storage/edge_type/edge_type.hpp +++ b/include/storage/edge_type/edge_type.hpp @@ -1,25 +1,29 @@ #pragma once -#include #include +#include -#include "utils/total_ordering.hpp" +#include "utils/char_str.hpp" #include "utils/reference_wrapper.hpp" +#include "utils/total_ordering.hpp" class EdgeType : public TotalOrdering { public: EdgeType(); - EdgeType(const std::string& id); - EdgeType(std::string&& id); + EdgeType(const std::string &id); + EdgeType(const char *id); + EdgeType(std::string &&id); - friend bool operator<(const EdgeType& lhs, const EdgeType& rhs); + friend bool operator<(const EdgeType &lhs, const EdgeType &rhs); - friend bool operator==(const EdgeType& lhs, const EdgeType& rhs); + friend bool operator==(const EdgeType &lhs, const EdgeType &rhs); - friend std::ostream& operator<<(std::ostream& stream, const EdgeType& type); + friend std::ostream &operator<<(std::ostream &stream, const EdgeType &type); - operator const std::string&() const; + operator const std::string &() const; + + CharStr char_str() { return CharStr(&id[0]); } private: std::string id; diff --git a/include/storage/edge_type/edge_type_store.hpp b/include/storage/edge_type/edge_type_store.hpp index ff0cad4d9..1268f7acf 100644 --- a/include/storage/edge_type/edge_type_store.hpp +++ b/include/storage/edge_type/edge_type_store.hpp @@ -2,27 +2,27 @@ #include +#include "data_structures/concurrent/concurrent_map.hpp" #include "storage/edge_type/edge_type.hpp" -#include "data_structures/concurrent/concurrent_set.hpp" +#include "utils/char_str.hpp" class EdgeTypeStore { public: + const EdgeType &find_or_create(const char *name); - const EdgeType& find_or_create(const std::string& name); - - bool contains(const std::string& name); // TODO: const + bool contains(const char *name); // TODO: const // TODO: implement find method // return { EdgeType, is_found } - + // TODO: find by reference if it is possible (should be faster) // figure out the fastest way to store and find types // do the same for labels - + // TODO: EdgeTypeStore and LabelStore are almost the same // templetize the two of them private: - ConcurrentSet edge_types; + ConcurrentMap> edge_types; }; diff --git a/include/storage/indexes/index_base.hpp b/include/storage/indexes/index_base.hpp index aa7603848..dd5e01529 100644 --- a/include/storage/indexes/index_base.hpp +++ b/include/storage/indexes/index_base.hpp @@ -37,7 +37,7 @@ public: // nonunique => always succeds. virtual bool insert(IndexRecord &&value) = 0; - // Returns iterator which returns valid records in range. + // Returns iterator which returns valid filled records in range. // order==noe => doesn't guarantee any order of returned records. // order==Ascending => guarantees order of returnd records will be from // smallest to largest. diff --git a/include/storage/label/label.hpp b/include/storage/label/label.hpp index 0e45795c7..441ff5ab2 100644 --- a/include/storage/label/label.hpp +++ b/include/storage/label/label.hpp @@ -6,19 +6,20 @@ #include "storage/indexes/impl/nonunique_unordered_index.hpp" #include "storage/vertex.hpp" #include "storage/vertex_accessor.hpp" +#include "utils/char_str.hpp" #include "utils/reference_wrapper.hpp" #include "utils/total_ordering.hpp" + using LabelIndexRecord = VertexIndexRecord; -class Label : public TotalOrdering