Dressipi CRUD queries are dummy implemented; Fixes T99 and T131
Summary: Dressipi CRUD queries are dummy implemented; Fixes T99 and T131 Test Plan: manual Reviewers: sale Subscribers: buda, sale Maniphest Tasks: T131, T99 Differential Revision: https://memgraph.phacility.com/D9
This commit is contained in:
parent
e1e345ccbb
commit
21788d003a
210
CMakeLists.txt
210
CMakeLists.txt
@ -91,6 +91,7 @@ set(yaml_static_lib ${yaml_source_dir}/libyaml-cpp.a)
|
|||||||
set(catch_source_dir "${libs_dir}/Catch")
|
set(catch_source_dir "${libs_dir}/Catch")
|
||||||
|
|
||||||
# load cmake modules: cmake/*.cmake
|
# load cmake modules: cmake/*.cmake
|
||||||
|
include(gtest)
|
||||||
include(gbenchmark)
|
include(gbenchmark)
|
||||||
|
|
||||||
# build memgraph's cypher grammar
|
# build memgraph's cypher grammar
|
||||||
@ -134,188 +135,7 @@ 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()
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
include(copy_includes)
|
||||||
# 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}/barrier/barrier.hpp DESTINATION ${build_include_dir}/barrier)
|
|
||||||
FILE(COPY ${include_dir}/database/db.hpp DESTINATION ${build_include_dir}/database)
|
|
||||||
FILE(COPY ${include_dir}/database/db_transaction.hpp DESTINATION ${build_include_dir}/database)
|
|
||||||
FILE(COPY ${include_dir}/database/db_accessor.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_record.hpp DESTINATION ${build_include_dir}/storage)
|
|
||||||
FILE(COPY ${include_dir}/storage/vertex_record.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}/storage/model/edge_map.hpp DESTINATION ${build_include_dir}/storage/model)
|
|
||||||
FILE(COPY ${include_dir}/storage/model/properties/flags.hpp DESTINATION ${build_include_dir}/storage/model/properties)
|
|
||||||
FILE(COPY ${include_dir}/storage/model/properties/stored_property.hpp DESTINATION ${build_include_dir}/storage/model/properties)
|
|
||||||
FILE(COPY ${include_dir}/storage/model/properties/property_holder.hpp DESTINATION ${build_include_dir}/storage/model/properties)
|
|
||||||
FILE(COPY ${include_dir}/storage/type_group_edge.hpp DESTINATION ${build_include_dir}/storage)
|
|
||||||
FILE(COPY ${include_dir}/storage/type_group_vertex.hpp DESTINATION ${build_include_dir}/storage)
|
|
||||||
|
|
||||||
FILE(COPY ${include_dir}/query/util.hpp DESTINATION ${build_include_dir}/query)
|
|
||||||
FILE(COPY ${include_dir}/query/i_plan_cpu.hpp DESTINATION ${build_include_dir}/query)
|
|
||||||
FILE(COPY ${include_dir}/query/strip/stripped.hpp DESTINATION ${build_include_dir}/query/strip)
|
|
||||||
|
|
||||||
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/concurrent_list.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/map/rh_hashmultimap.hpp DESTINATION ${build_include_dir}/data_structures/map)
|
|
||||||
FILE(COPY ${include_dir}/data_structures/map/rh_common.hpp DESTINATION ${build_include_dir}/data_structures/map)
|
|
||||||
|
|
||||||
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}/garbage)
|
|
||||||
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}/transactions/transaction_read.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/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/null.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/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)
|
|
||||||
FILE(COPY ${include_dir}/storage/model/properties/property_family.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_record.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
|
||||||
FILE(COPY ${include_dir}/storage/indexes/index_base.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
|
||||||
FILE(COPY ${include_dir}/storage/indexes/impl/nonunique_unordered_index.hpp DESTINATION ${build_include_dir}/storage/indexes/impl)
|
|
||||||
FILE(COPY ${include_dir}/storage/indexes/index_holder.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
|
||||||
FILE(COPY ${include_dir}/storage/indexes/index_definition.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
|
||||||
FILE(COPY ${include_dir}/storage/indexes/index_update.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
|
||||||
|
|
||||||
FILE(COPY ${include_dir}/storage/garbage/delete_sensitive.hpp DESTINATION ${build_include_dir}/storage/garbage)
|
|
||||||
FILE(COPY ${include_dir}/storage/garbage/garbage.hpp DESTINATION ${build_include_dir}/storage/garbage)
|
|
||||||
|
|
||||||
FILE(COPY ${include_dir}/utils/sys.hpp DESTINATION ${build_include_dir}/utils)
|
|
||||||
FILE(COPY ${include_dir}/utils/char_str.hpp DESTINATION ${build_include_dir}/utils)
|
|
||||||
FILE(COPY ${include_dir}/utils/void.hpp DESTINATION ${build_include_dir}/utils)
|
|
||||||
FILE(COPY ${include_dir}/utils/array_store.hpp DESTINATION ${build_include_dir}/utils)
|
|
||||||
FILE(COPY ${include_dir}/utils/bswap.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)
|
|
||||||
FILE(COPY ${include_dir}/utils/datetime/timestamp.hpp DESTINATION ${build_include_dir}/utils/datetime)
|
|
||||||
FILE(COPY ${include_dir}/utils/datetime/datetime_error.hpp DESTINATION ${build_include_dir}/utils/datetime)
|
|
||||||
FILE(COPY ${include_dir}/utils/types/byte.hpp DESTINATION ${build_include_dir}/utils/types)
|
|
||||||
FILE(COPY ${include_dir}/utils/option_ptr.hpp DESTINATION ${build_include_dir}/utils)
|
|
||||||
FILE(COPY ${include_dir}/utils/option.hpp DESTINATION ${build_include_dir}/utils)
|
|
||||||
FILE(COPY ${include_dir}/utils/border.hpp DESTINATION ${build_include_dir}/utils)
|
|
||||||
FILE(COPY ${include_dir}/utils/order.hpp DESTINATION ${build_include_dir}/utils)
|
|
||||||
FILE(COPY ${include_dir}/utils/numerics/saturate.hpp DESTINATION ${build_include_dir}/utils/numerics)
|
|
||||||
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/iterator_base.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/virtual_iter.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/iterator.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/composable.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/count.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/accessor.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/combined.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/count.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/filter.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/flat_map.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/for_all.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/inspect.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/iterator_accessor.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/lambda_iterator.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/limited_map.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/map.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
FILE(COPY ${include_dir}/utils/iterator/range_iterator.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
|
||||||
|
|
||||||
FILE(COPY ${include_dir}/communication/communication.hpp DESTINATION ${build_include_dir}/communication)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/config.hpp DESTINATION ${build_include_dir}/communication/bolt/v1)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/serialization/record_stream.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/serialization)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/serialization/bolt_serializer.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/serialization)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/transport/bolt_encoder.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/transport/chunked_buffer.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/transport/chunked_encoder.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/transport/socket_stream.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/transport/stream_error.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/packing/codes.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/packing)
|
|
||||||
FILE(COPY ${include_dir}/communication/bolt/v1/messaging/codes.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/messaging)
|
|
||||||
|
|
||||||
FILE(COPY ${include_dir}/io/network/socket.hpp DESTINATION ${build_include_dir}/io/network)
|
|
||||||
FILE(COPY ${include_dir}/io/network/addrinfo.hpp DESTINATION ${build_include_dir}/io/network)
|
|
||||||
FILE(COPY ${include_dir}/io/network/network_error.hpp DESTINATION ${build_include_dir}/io/network)
|
|
||||||
FILE(COPY ${include_dir}/io/network/socket.hpp DESTINATION ${build_include_dir}/io/network)
|
|
||||||
|
|
||||||
FILE(COPY ${include_dir}/logging/default.hpp DESTINATION ${build_include_dir}/logging)
|
|
||||||
FILE(COPY ${include_dir}/logging/log.hpp DESTINATION ${build_include_dir}/logging)
|
|
||||||
FILE(COPY ${include_dir}/logging/logger.hpp DESTINATION ${build_include_dir}/logging)
|
|
||||||
FILE(COPY ${include_dir}/logging/levels.hpp DESTINATION ${build_include_dir}/logging)
|
|
||||||
|
|
||||||
FILE(COPY ${include_dir}/snapshot/snapshot_engine.hpp DESTINATION ${build_include_dir}/snapshot)
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# 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)
|
||||||
@ -417,16 +237,6 @@ message(STATUS "TESTS binaries: ${TESTS}")
|
|||||||
option(BENCHMARK "Build benchmark binaries" ON)
|
option(BENCHMARK "Build benchmark binaries" ON)
|
||||||
message(STATUS "BENCHMARK binaries: ${BENCHMARK}")
|
message(STATUS "BENCHMARK binaries: ${BENCHMARK}")
|
||||||
# -- binaries -----------------------------------------------------------------
|
# -- binaries -----------------------------------------------------------------
|
||||||
# -- barrier - this is the way how the engine is isolated so it can be shipped
|
|
||||||
# wherever, the code is completely hidden behind the barrier, during the
|
|
||||||
# development the barrier can be turned off because it is much easier to
|
|
||||||
# debug
|
|
||||||
option(BARRIER "Barrier" ON)
|
|
||||||
message(STATUS "BARRIER: ${BARRIER} (Source code isolation)")
|
|
||||||
if(BARRIER)
|
|
||||||
add_definitions( -DBARRIER )
|
|
||||||
endif()
|
|
||||||
# -- barrier ------------------------------------------------------------------
|
|
||||||
# -- configure defines --------------------------------------------------------
|
# -- configure defines --------------------------------------------------------
|
||||||
|
|
||||||
# -- includes -----------------------------------------------------------------
|
# -- includes -----------------------------------------------------------------
|
||||||
@ -460,7 +270,6 @@ set(memgraph_src_files
|
|||||||
${src_dir}/utils/string/join.cpp
|
${src_dir}/utils/string/join.cpp
|
||||||
${src_dir}/utils/string/file.cpp
|
${src_dir}/utils/string/file.cpp
|
||||||
${src_dir}/utils/numerics/saturate.cpp
|
${src_dir}/utils/numerics/saturate.cpp
|
||||||
${src_dir}/query_engine/util.cpp
|
|
||||||
${src_dir}/communication/bolt/v1/bolt.cpp
|
${src_dir}/communication/bolt/v1/bolt.cpp
|
||||||
${src_dir}/communication/bolt/v1/states.cpp
|
${src_dir}/communication/bolt/v1/states.cpp
|
||||||
${src_dir}/communication/bolt/v1/session.cpp
|
${src_dir}/communication/bolt/v1/session.cpp
|
||||||
@ -482,6 +291,7 @@ set(memgraph_src_files
|
|||||||
${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
|
||||||
|
${src_dir}/storage/label/labels_writer.cpp
|
||||||
${src_dir}/storage/edge_type/edge_type.cpp
|
${src_dir}/storage/edge_type/edge_type.cpp
|
||||||
${src_dir}/storage/edge_type/edge_type_store.cpp
|
${src_dir}/storage/edge_type/edge_type_store.cpp
|
||||||
${src_dir}/storage/model/properties/null.cpp
|
${src_dir}/storage/model/properties/null.cpp
|
||||||
@ -531,15 +341,6 @@ add_library(memgraph STATIC ${memgraph_src_files})
|
|||||||
add_library(memgraph_pic STATIC ${memgraph_src_files})
|
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)
|
||||||
|
|
||||||
if (BARRIER)
|
|
||||||
# create static barrier lib
|
|
||||||
add_library(barrier STATIC ${memgraph_src_files})
|
|
||||||
|
|
||||||
# create pic static barrier lib
|
|
||||||
add_library(barrier_pic STATIC ${memgraph_src_files})
|
|
||||||
set_property(TARGET barrier_pic PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# tests
|
# tests
|
||||||
if (TESTS)
|
if (TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
@ -583,12 +384,7 @@ message(STATUS "Release flags: ${CMAKE_CXX_FLAGS_RELEASE}")
|
|||||||
if (MEMGRAPH)
|
if (MEMGRAPH)
|
||||||
add_executable(${MEMGRAPH_BUILD_NAME} ${src_dir}/memgraph_bolt.cpp)
|
add_executable(${MEMGRAPH_BUILD_NAME} ${src_dir}/memgraph_bolt.cpp)
|
||||||
|
|
||||||
if (BARRIER)
|
|
||||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} barrier)
|
|
||||||
elseif (NOT BARRIER)
|
|
||||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} memgraph)
|
target_link_libraries(${MEMGRAPH_BUILD_NAME} memgraph)
|
||||||
endif ()
|
|
||||||
|
|
||||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} stdc++fs)
|
target_link_libraries(${MEMGRAPH_BUILD_NAME} stdc++fs)
|
||||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} Threads::Threads)
|
target_link_libraries(${MEMGRAPH_BUILD_NAME} Threads::Threads)
|
||||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} cypher_lib)
|
target_link_libraries(${MEMGRAPH_BUILD_NAME} cypher_lib)
|
||||||
|
186
cmake/copy_includes.cmake
Normal file
186
cmake/copy_includes.cmake
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# COPY header files required by query engine (query compiler)
|
||||||
|
# TODO: create a copy function, COPY_RELATIVE(base relative_path dst)
|
||||||
|
# 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}/database/db_transaction.hpp DESTINATION ${build_include_dir}/database)
|
||||||
|
FILE(COPY ${include_dir}/database/db_accessor.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_record.hpp DESTINATION ${build_include_dir}/storage)
|
||||||
|
FILE(COPY ${include_dir}/storage/vertex_record.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}/storage/label/labels_writer.hpp DESTINATION ${build_include_dir}/storage/label)
|
||||||
|
FILE(COPY ${include_dir}/storage/model/edge_map.hpp DESTINATION ${build_include_dir}/storage/model)
|
||||||
|
FILE(COPY ${include_dir}/storage/model/properties/flags.hpp DESTINATION ${build_include_dir}/storage/model/properties)
|
||||||
|
FILE(COPY ${include_dir}/storage/model/properties/stored_property.hpp DESTINATION ${build_include_dir}/storage/model/properties)
|
||||||
|
FILE(COPY ${include_dir}/storage/model/properties/property_holder.hpp DESTINATION ${build_include_dir}/storage/model/properties)
|
||||||
|
FILE(COPY ${include_dir}/storage/type_group_edge.hpp DESTINATION ${build_include_dir}/storage)
|
||||||
|
FILE(COPY ${include_dir}/storage/type_group_vertex.hpp DESTINATION ${build_include_dir}/storage)
|
||||||
|
|
||||||
|
FILE(COPY ${include_dir}/query/util.hpp DESTINATION ${build_include_dir}/query)
|
||||||
|
FILE(COPY ${include_dir}/query/i_plan_cpu.hpp DESTINATION ${build_include_dir}/query)
|
||||||
|
FILE(COPY ${include_dir}/query/strip/stripped.hpp DESTINATION ${build_include_dir}/query/strip)
|
||||||
|
|
||||||
|
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/concurrent_list.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/map/rh_hashmultimap.hpp DESTINATION ${build_include_dir}/data_structures/map)
|
||||||
|
FILE(COPY ${include_dir}/data_structures/map/rh_common.hpp DESTINATION ${build_include_dir}/data_structures/map)
|
||||||
|
|
||||||
|
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}/transactions/transaction_read.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/json_writer.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/null.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/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)
|
||||||
|
FILE(COPY ${include_dir}/storage/model/properties/property_family.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_record.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
||||||
|
FILE(COPY ${include_dir}/storage/indexes/index_base.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
||||||
|
FILE(COPY ${include_dir}/storage/indexes/impl/nonunique_unordered_index.hpp DESTINATION ${build_include_dir}/storage/indexes/impl)
|
||||||
|
FILE(COPY ${include_dir}/storage/indexes/index_holder.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
||||||
|
FILE(COPY ${include_dir}/storage/indexes/index_definition.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
||||||
|
FILE(COPY ${include_dir}/storage/indexes/index_update.hpp DESTINATION ${build_include_dir}/storage/indexes)
|
||||||
|
|
||||||
|
FILE(COPY ${include_dir}/storage/garbage/delete_sensitive.hpp DESTINATION ${build_include_dir}/storage/garbage)
|
||||||
|
FILE(COPY ${include_dir}/storage/garbage/garbage.hpp DESTINATION ${build_include_dir}/storage/garbage)
|
||||||
|
|
||||||
|
FILE(COPY ${include_dir}/utils/string_buffer.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/handle_write.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/sys.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/char_str.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/void.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/array_store.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/bswap.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)
|
||||||
|
FILE(COPY ${include_dir}/utils/datetime/timestamp.hpp DESTINATION ${build_include_dir}/utils/datetime)
|
||||||
|
FILE(COPY ${include_dir}/utils/datetime/datetime_error.hpp DESTINATION ${build_include_dir}/utils/datetime)
|
||||||
|
FILE(COPY ${include_dir}/utils/types/byte.hpp DESTINATION ${build_include_dir}/utils/types)
|
||||||
|
FILE(COPY ${include_dir}/utils/option_ptr.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/option.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/border.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/order.hpp DESTINATION ${build_include_dir}/utils)
|
||||||
|
FILE(COPY ${include_dir}/utils/numerics/saturate.hpp DESTINATION ${build_include_dir}/utils/numerics)
|
||||||
|
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/iterator_base.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/virtual_iter.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/iterator.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/composable.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/count.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/accessor.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/combined.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/count.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/filter.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/flat_map.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/for_all.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/inspect.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/iterator_accessor.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/lambda_iterator.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/limited_map.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/map.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
FILE(COPY ${include_dir}/utils/iterator/range_iterator.hpp DESTINATION ${build_include_dir}/utils/iterator)
|
||||||
|
|
||||||
|
FILE(COPY ${include_dir}/communication/communication.hpp DESTINATION ${build_include_dir}/communication)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/config.hpp DESTINATION ${build_include_dir}/communication/bolt/v1)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/serialization/record_stream.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/serialization)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/serialization/bolt_serializer.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/serialization)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/transport/bolt_encoder.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/transport/chunked_buffer.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/transport/chunked_encoder.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/transport/socket_stream.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/transport/stream_error.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/transport)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/packing/codes.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/packing)
|
||||||
|
FILE(COPY ${include_dir}/communication/bolt/v1/messaging/codes.hpp DESTINATION ${build_include_dir}/communication/bolt/v1/messaging)
|
||||||
|
|
||||||
|
FILE(COPY ${include_dir}/io/network/socket.hpp DESTINATION ${build_include_dir}/io/network)
|
||||||
|
FILE(COPY ${include_dir}/io/network/addrinfo.hpp DESTINATION ${build_include_dir}/io/network)
|
||||||
|
FILE(COPY ${include_dir}/io/network/network_error.hpp DESTINATION ${build_include_dir}/io/network)
|
||||||
|
FILE(COPY ${include_dir}/io/network/socket.hpp DESTINATION ${build_include_dir}/io/network)
|
||||||
|
|
||||||
|
FILE(COPY ${include_dir}/logging/default.hpp DESTINATION ${build_include_dir}/logging)
|
||||||
|
FILE(COPY ${include_dir}/logging/log.hpp DESTINATION ${build_include_dir}/logging)
|
||||||
|
FILE(COPY ${include_dir}/logging/logger.hpp DESTINATION ${build_include_dir}/logging)
|
||||||
|
FILE(COPY ${include_dir}/logging/levels.hpp DESTINATION ${build_include_dir}/logging)
|
||||||
|
FILE(COPY ${include_dir}/logging/loggable.hpp DESTINATION ${build_include_dir}/logging)
|
||||||
|
|
||||||
|
FILE(COPY ${include_dir}/snapshot/snapshot_engine.hpp DESTINATION ${build_include_dir}/snapshot)
|
||||||
|
# -----------------------------------------------------------------------------
|
19
cmake/gtest.cmake
Normal file
19
cmake/gtest.cmake
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
if (CMAKE_VERSION VERSION_LESS 3.2)
|
||||||
|
set(UPDATE_DISCONNECTED_IF_AVAILABLE "")
|
||||||
|
else()
|
||||||
|
set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(DownloadProject/DownloadProject)
|
||||||
|
|
||||||
|
download_project(
|
||||||
|
PROJ googletest
|
||||||
|
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||||
|
GIT_TAG master
|
||||||
|
${UPDATE_DISCONNECTED_IF_AVAILABLE}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
|
||||||
|
|
||||||
|
include_directories("${googletest_SOURCE_DIR}/googletest/include")
|
||||||
|
include_directories("${googletest_SOURCE_DIR}/googlemock/include")
|
@ -1,8 +1,27 @@
|
|||||||
|
###########################
|
||||||
|
# MEMGRAPH DEFAULT CONFIG #
|
||||||
|
###########################
|
||||||
|
|
||||||
|
# NOTE: all paths are relative to the run folder
|
||||||
|
# (where the executable is runned)
|
||||||
|
|
||||||
|
# path to the codes which will be compiled
|
||||||
compile_cpu_path: "./compiled/cpu/"
|
compile_cpu_path: "./compiled/cpu/"
|
||||||
|
|
||||||
|
# path to the template (cpp) for codes generation
|
||||||
template_cpu_cpp_path: "./template/template_code_cpu.cpp"
|
template_cpu_cpp_path: "./template/template_code_cpu.cpp"
|
||||||
barrier_template_cpu_cpp_path: "./template/barrier_template_code_cpu.cpp"
|
|
||||||
|
# path to the template (hpp) for codes generation
|
||||||
template_cpu_hpp_path: "./template/template_code_cpu.hpp"
|
template_cpu_hpp_path: "./template/template_code_cpu.hpp"
|
||||||
|
|
||||||
|
# path to the folder with snapshots
|
||||||
snapshots_path: "snapshots"
|
snapshots_path: "snapshots"
|
||||||
|
|
||||||
|
# leaning cycle interval
|
||||||
cleaning_cycle_sec: "300"
|
cleaning_cycle_sec: "300"
|
||||||
|
|
||||||
|
# snapshot cycle interval
|
||||||
snapshot_cycle_sec: "60"
|
snapshot_cycle_sec: "60"
|
||||||
|
|
||||||
|
# max number of snapshots which will be kept on the disk at some point
|
||||||
max_retained_snapshots: "3"
|
max_retained_snapshots: "3"
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
FROM ubuntu:16.04
|
|
||||||
|
|
||||||
# apt-get setup
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y cmake git python clang wget \
|
|
||||||
&& apt-get install -y check libpcre3 libpcre3-dev libjemalloc-dev \
|
|
||||||
libjemalloc1 build-essential libtool automake \
|
|
||||||
autoconf pkg-config
|
|
||||||
# && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
|
||||||
|
|
||||||
# prepare source
|
|
||||||
RUN mkdir -p /memgraph/build
|
|
||||||
RUN mkdir -p /memgraph/libs
|
|
||||||
COPY libs/setup.sh /memgraph/libs/setup.sh
|
|
||||||
COPY src /memgraph/src
|
|
||||||
COPY tests /memgraph/tests
|
|
||||||
COPY CMakeLists.txt /memgraph/CMakeLists.txt
|
|
||||||
|
|
||||||
# setup libs
|
|
||||||
WORKDIR /memgraph/libs
|
|
||||||
RUN ./setup.sh
|
|
||||||
|
|
||||||
# build
|
|
||||||
WORKDIR /memgraph/build
|
|
||||||
RUN cmake -DCMAKE_C_COMPILER=clang \
|
|
||||||
-DCMAKE_CXX_COMPILER=clang++ \
|
|
||||||
-DRUNTIME_ASSERT=OFF \
|
|
||||||
-DTHROW_EXCEPTION_ON_ERROR=OFF \
|
|
||||||
-DNDEBUG=OFF ..
|
|
||||||
RUN make
|
|
||||||
|
|
||||||
# run
|
|
||||||
CMD /memgraph/build/memgraph 7474
|
|
@ -1,588 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef BARRIER
|
|
||||||
|
|
||||||
#include "barrier/common.hpp"
|
|
||||||
|
|
||||||
// This namespace is holding header parts of barrier classes. Barrier class
|
|
||||||
// object is in fact object from other class inside memgraph. Main purpose of
|
|
||||||
// barrier classes is to hide real classes from outside viewers. This header
|
|
||||||
// should be only to be included from memgraph into generated/compiled query.
|
|
||||||
// And this header must ensure that it defines all classes and methods required
|
|
||||||
// for querys.
|
|
||||||
namespace barrier
|
|
||||||
{
|
|
||||||
// Every class from database which must be visible to outside the barrier should
|
|
||||||
// have there barrier class defined here.
|
|
||||||
|
|
||||||
// ************ Here should be forward declarations of Sized barrier classes
|
|
||||||
// ACCESSORS
|
|
||||||
class DbAccessor;
|
|
||||||
class VertexAccessor;
|
|
||||||
class EdgeAccessor;
|
|
||||||
|
|
||||||
// GENERIC ITERATORS
|
|
||||||
class VertexIterator;
|
|
||||||
class EdgeIterator;
|
|
||||||
|
|
||||||
// TYPED ITERATORS
|
|
||||||
class VertexAccessIterator;
|
|
||||||
class EdgeAccessIterator;
|
|
||||||
class OutEdgesIterator;
|
|
||||||
class InEdgesIterator;
|
|
||||||
|
|
||||||
// PROPERTY
|
|
||||||
class VertexPropertyKey;
|
|
||||||
class EdgePropertyKey;
|
|
||||||
template <class T>
|
|
||||||
class VertexPropertyType;
|
|
||||||
template <class T>
|
|
||||||
class EdgePropertyType;
|
|
||||||
|
|
||||||
// BOLT
|
|
||||||
template <class Stream>
|
|
||||||
class RecordStream;
|
|
||||||
|
|
||||||
// ************ Here should be forward declarations of Unsized barrier classes
|
|
||||||
// COMMON
|
|
||||||
class Db;
|
|
||||||
class Label;
|
|
||||||
class EdgeType;
|
|
||||||
|
|
||||||
// GENERIC INDEXES
|
|
||||||
template <class K>
|
|
||||||
class VertexIndex;
|
|
||||||
template <class K>
|
|
||||||
class EdgeIndex;
|
|
||||||
|
|
||||||
// PROPERTY
|
|
||||||
class VertexPropertyFamily;
|
|
||||||
class EdgePropertyFamily;
|
|
||||||
|
|
||||||
// ************* Here should be defined usings
|
|
||||||
using label_ref_t = ReferenceWrapper<const Label>;
|
|
||||||
using VertexStoredProperty = PropertyHolder<VertexPropertyKey>;
|
|
||||||
using EdgeStoredProperty = PropertyHolder<EdgePropertyKey>;
|
|
||||||
|
|
||||||
// ************ Here should be definitions of Sized barrier classes
|
|
||||||
// Original class should have Sized barrier class if it can't be Unsized.
|
|
||||||
// Sized barrier classes should:
|
|
||||||
// --Have same name as original class.
|
|
||||||
// --Inherit Sized class from common.hpp as public. Blueprint:
|
|
||||||
// class class_name: public Sized<size_of_t,aligment_of_t>
|
|
||||||
// --Sized template arguments must be hardcoded numbers equal to sizeof(T) and
|
|
||||||
// alignof(T) where T is original class.
|
|
||||||
// --It should have undefined public constructor which is specialized in .cpp
|
|
||||||
// Blueprint:
|
|
||||||
// public:
|
|
||||||
// template<class T> class_name(T &&d);
|
|
||||||
// --It should delete or specify following methods depending on the behavior of
|
|
||||||
// the original class:
|
|
||||||
// public:
|
|
||||||
// class_name(const class_name &other);
|
|
||||||
// class_name(class_name &&other);
|
|
||||||
// ~class_name();
|
|
||||||
// class_name &operator=(const class_name &other);
|
|
||||||
// class_name &operator=(class_name &&other);
|
|
||||||
// --It should specify public methods which can be called on the original class.
|
|
||||||
//
|
|
||||||
// Blueprint:
|
|
||||||
// class class_name : public Sized<,>
|
|
||||||
// {
|
|
||||||
// public:
|
|
||||||
// template <class T>
|
|
||||||
// class_name(T &&d);
|
|
||||||
//
|
|
||||||
// class_name(const class_name &other);
|
|
||||||
// class_name(class_name &&other);
|
|
||||||
// ~class_name();
|
|
||||||
//
|
|
||||||
// class_name &operator=(const class_name &other);
|
|
||||||
// class_name &operator=(class_name &&other);
|
|
||||||
//
|
|
||||||
// };
|
|
||||||
|
|
||||||
// TODO: Extract methods od RecordAccessor for VertexAccessor and EdgeAccessor
|
|
||||||
// into joined class.
|
|
||||||
class VertexAccessor : private Sized<24, 8>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
VertexAccessor(T &&d);
|
|
||||||
|
|
||||||
VertexAccessor(VertexAccessor &other);
|
|
||||||
VertexAccessor(const VertexAccessor &other);
|
|
||||||
VertexAccessor(VertexAccessor &&other);
|
|
||||||
VertexAccessor(VertexAccessor const &&other);
|
|
||||||
~VertexAccessor();
|
|
||||||
|
|
||||||
VertexAccessor &operator=(const VertexAccessor &other);
|
|
||||||
VertexAccessor &operator=(VertexAccessor &&other);
|
|
||||||
|
|
||||||
bool isolated() const;
|
|
||||||
|
|
||||||
size_t out_degree() const;
|
|
||||||
|
|
||||||
size_t in_degree() const;
|
|
||||||
|
|
||||||
size_t degree() const;
|
|
||||||
|
|
||||||
bool add_label(const Label &label);
|
|
||||||
|
|
||||||
bool remove_label(const Label &label);
|
|
||||||
|
|
||||||
bool has_label(const Label &label) const;
|
|
||||||
|
|
||||||
const std::vector<label_ref_t> &labels() const;
|
|
||||||
|
|
||||||
OutEdgesIterator out() const;
|
|
||||||
|
|
||||||
InEdgesIterator in() const;
|
|
||||||
|
|
||||||
bool in_contains(VertexAccessor const &other) const;
|
|
||||||
|
|
||||||
bool empty() const;
|
|
||||||
|
|
||||||
bool fill() const;
|
|
||||||
|
|
||||||
const Id &id() const;
|
|
||||||
|
|
||||||
VertexAccessor update() const;
|
|
||||||
|
|
||||||
void remove() const;
|
|
||||||
|
|
||||||
// template <class TG>
|
|
||||||
// bool contains(property_key<TG> &key) const;
|
|
||||||
|
|
||||||
const VertexStoredProperty &at(VertexPropertyFamily &key) const;
|
|
||||||
|
|
||||||
const VertexStoredProperty &at(VertexPropertyKey &key) const;
|
|
||||||
|
|
||||||
template <class V>
|
|
||||||
OptionPtr<const V> at(VertexPropertyType<V> &key) const;
|
|
||||||
|
|
||||||
void set(VertexPropertyKey &key, Property &&value);
|
|
||||||
|
|
||||||
void clear(VertexPropertyKey &key);
|
|
||||||
|
|
||||||
void clear(VertexPropertyFamily &key);
|
|
||||||
|
|
||||||
template <class Handler>
|
|
||||||
void accept(Handler &handler) const;
|
|
||||||
|
|
||||||
explicit operator bool() const;
|
|
||||||
|
|
||||||
friend bool operator==(const VertexAccessor &a, const VertexAccessor &b);
|
|
||||||
|
|
||||||
friend bool operator!=(const VertexAccessor &a, const VertexAccessor &b);
|
|
||||||
};
|
|
||||||
|
|
||||||
class EdgeAccessor : private Sized<24, 8>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
EdgeAccessor(T &&d);
|
|
||||||
|
|
||||||
EdgeAccessor(EdgeAccessor &other);
|
|
||||||
EdgeAccessor(const EdgeAccessor &other);
|
|
||||||
EdgeAccessor(EdgeAccessor &&other);
|
|
||||||
EdgeAccessor(EdgeAccessor const &&other);
|
|
||||||
~EdgeAccessor();
|
|
||||||
|
|
||||||
EdgeAccessor &operator=(const EdgeAccessor &other);
|
|
||||||
EdgeAccessor &operator=(EdgeAccessor &&other);
|
|
||||||
|
|
||||||
void edge_type(const EdgeType &edge_type);
|
|
||||||
|
|
||||||
const EdgeType &edge_type() const;
|
|
||||||
|
|
||||||
const VertexAccessor from() const;
|
|
||||||
|
|
||||||
const VertexAccessor to() const;
|
|
||||||
|
|
||||||
bool empty() const;
|
|
||||||
|
|
||||||
bool fill() const;
|
|
||||||
|
|
||||||
const Id &id() const;
|
|
||||||
|
|
||||||
EdgeAccessor update() const;
|
|
||||||
|
|
||||||
void remove() const;
|
|
||||||
|
|
||||||
const EdgeStoredProperty &at(EdgePropertyFamily &key) const;
|
|
||||||
|
|
||||||
const EdgeStoredProperty &at(EdgePropertyKey &key) const;
|
|
||||||
|
|
||||||
template <class V>
|
|
||||||
OptionPtr<const V> at(EdgePropertyType<V> &key) const;
|
|
||||||
|
|
||||||
void set(EdgePropertyKey &key, Property &&value);
|
|
||||||
|
|
||||||
void clear(EdgePropertyKey &key);
|
|
||||||
|
|
||||||
void clear(EdgePropertyFamily &key);
|
|
||||||
|
|
||||||
template <class Handler>
|
|
||||||
void accept(Handler &handler) const;
|
|
||||||
|
|
||||||
explicit operator bool() const;
|
|
||||||
|
|
||||||
friend bool operator==(const EdgeAccessor &a, const EdgeAccessor &b);
|
|
||||||
|
|
||||||
friend bool operator!=(const EdgeAccessor &a, const EdgeAccessor &b);
|
|
||||||
};
|
|
||||||
|
|
||||||
class DbAccessor : protected Sized<40, 8>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DbAccessor(Db &d);
|
|
||||||
|
|
||||||
DbAccessor(const DbAccessor &other) = delete;
|
|
||||||
DbAccessor(DbAccessor &&other) = delete;
|
|
||||||
~DbAccessor();
|
|
||||||
|
|
||||||
DbAccessor &operator=(const DbAccessor &other) = delete;
|
|
||||||
DbAccessor &operator=(DbAccessor &&other) = delete;
|
|
||||||
|
|
||||||
VertexAccessIterator vertex_access();
|
|
||||||
|
|
||||||
Option<const VertexAccessor> vertex_find(const Id &id);
|
|
||||||
|
|
||||||
VertexAccessor vertex_insert();
|
|
||||||
|
|
||||||
EdgeAccessIterator edge_access();
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> edge_find(const Id &id);
|
|
||||||
|
|
||||||
EdgeAccessor edge_insert(VertexAccessor const &from,
|
|
||||||
VertexAccessor const &to);
|
|
||||||
|
|
||||||
const Label &label_find_or_create(const char *name);
|
|
||||||
|
|
||||||
bool label_contains(const char *name);
|
|
||||||
|
|
||||||
const EdgeType &type_find_or_create(const char *name);
|
|
||||||
|
|
||||||
bool type_contains(const char *name);
|
|
||||||
|
|
||||||
VertexPropertyFamily &vertex_property_family_get(const std::string &name);
|
|
||||||
|
|
||||||
EdgePropertyFamily &edge_property_family_get(const std::string &name);
|
|
||||||
|
|
||||||
VertexPropertyKey vertex_property_key(const std::string &name, Type type);
|
|
||||||
|
|
||||||
EdgePropertyKey edge_property_key(const std::string &name, Type type);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
VertexPropertyType<T> vertex_property_key(const std::string &name);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
EdgePropertyType<T> edge_property_key(const std::string &name);
|
|
||||||
|
|
||||||
bool commit();
|
|
||||||
void abort();
|
|
||||||
};
|
|
||||||
|
|
||||||
class VertexIterator
|
|
||||||
: public Sized<8, 8>,
|
|
||||||
public iter::Composable<const VertexAccessor, VertexIterator>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
VertexIterator(T &&d);
|
|
||||||
|
|
||||||
VertexIterator(const VertexIterator &other) = delete;
|
|
||||||
VertexIterator(VertexIterator &&other);
|
|
||||||
~VertexIterator();
|
|
||||||
VertexIterator &operator=(const VertexIterator &other) = delete;
|
|
||||||
VertexIterator &operator=(VertexIterator &&other) = delete;
|
|
||||||
|
|
||||||
Option<const VertexAccessor> next();
|
|
||||||
|
|
||||||
Count count();
|
|
||||||
};
|
|
||||||
|
|
||||||
// NOTE: This large size is because of SkipList accessor which is embeded into
|
|
||||||
// iterator. The accessor has 64 fields of pointers which is in total 512 B.
|
|
||||||
class VertexAccessIterator
|
|
||||||
: public Sized<560, 8>,
|
|
||||||
public iter::Composable<const VertexAccessor, VertexAccessIterator>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
VertexAccessIterator(T &&d);
|
|
||||||
|
|
||||||
VertexAccessIterator(const VertexAccessIterator &other) = delete;
|
|
||||||
VertexAccessIterator(VertexAccessIterator &&other);
|
|
||||||
~VertexAccessIterator();
|
|
||||||
VertexAccessIterator &operator=(const VertexAccessIterator &other) = delete;
|
|
||||||
VertexAccessIterator &operator=(VertexAccessIterator &&other) = delete;
|
|
||||||
|
|
||||||
Option<const VertexAccessor> next();
|
|
||||||
|
|
||||||
Count count();
|
|
||||||
};
|
|
||||||
|
|
||||||
// NOTE: This large size is because of SkipList accessor which is embeded into
|
|
||||||
// iterator. The accessor has 64 fields of pointers which is in total 512 B.
|
|
||||||
class EdgeAccessIterator
|
|
||||||
: public Sized<560, 8>,
|
|
||||||
public iter::Composable<const EdgeAccessor, EdgeAccessIterator>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
EdgeAccessIterator(T &&d);
|
|
||||||
|
|
||||||
EdgeAccessIterator(const EdgeAccessIterator &other) = delete;
|
|
||||||
EdgeAccessIterator(EdgeAccessIterator &&other);
|
|
||||||
~EdgeAccessIterator();
|
|
||||||
EdgeAccessIterator &operator=(const EdgeAccessIterator &other) = delete;
|
|
||||||
EdgeAccessIterator &operator=(EdgeAccessIterator &&other) = delete;
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> next();
|
|
||||||
|
|
||||||
Count count();
|
|
||||||
};
|
|
||||||
|
|
||||||
class OutEdgesIterator
|
|
||||||
: public Sized<48, 8>,
|
|
||||||
public iter::Composable<const EdgeAccessor, OutEdgesIterator>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
OutEdgesIterator(T &&d);
|
|
||||||
|
|
||||||
OutEdgesIterator(const OutEdgesIterator &other) = delete;
|
|
||||||
OutEdgesIterator(OutEdgesIterator &&other);
|
|
||||||
~OutEdgesIterator();
|
|
||||||
OutEdgesIterator &operator=(const OutEdgesIterator &other) = delete;
|
|
||||||
OutEdgesIterator &operator=(OutEdgesIterator &&other) = delete;
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> next();
|
|
||||||
|
|
||||||
Count count();
|
|
||||||
};
|
|
||||||
|
|
||||||
class InEdgesIterator
|
|
||||||
: public Sized<64, 8>,
|
|
||||||
public iter::Composable<const EdgeAccessor, InEdgesIterator>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
InEdgesIterator(T &&d);
|
|
||||||
|
|
||||||
InEdgesIterator(const InEdgesIterator &other) = delete;
|
|
||||||
InEdgesIterator(InEdgesIterator &&other);
|
|
||||||
~InEdgesIterator();
|
|
||||||
InEdgesIterator &operator=(const InEdgesIterator &other) = delete;
|
|
||||||
InEdgesIterator &operator=(InEdgesIterator &&other) = delete;
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> next();
|
|
||||||
|
|
||||||
Count count();
|
|
||||||
};
|
|
||||||
|
|
||||||
class EdgeIterator : public Sized<8, 8>,
|
|
||||||
public iter::Composable<const EdgeAccessor, EdgeIterator>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
EdgeIterator(T &&d);
|
|
||||||
|
|
||||||
EdgeIterator(const EdgeIterator &other) = delete;
|
|
||||||
EdgeIterator(EdgeIterator &&other);
|
|
||||||
~EdgeIterator();
|
|
||||||
EdgeIterator &operator=(const EdgeIterator &other) = delete;
|
|
||||||
EdgeIterator &operator=(EdgeIterator &&other) = delete;
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> next();
|
|
||||||
|
|
||||||
Count count();
|
|
||||||
|
|
||||||
EdgeIterator &operator->() { return *this; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class VertexPropertyKey : private Sized<8, 8>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
VertexPropertyKey(T &&d);
|
|
||||||
|
|
||||||
VertexPropertyKey(const VertexPropertyKey &other) = default;
|
|
||||||
VertexPropertyKey(VertexPropertyKey &&other) = default;
|
|
||||||
~VertexPropertyKey();
|
|
||||||
|
|
||||||
VertexPropertyKey &operator=(const VertexPropertyKey &other) = default;
|
|
||||||
VertexPropertyKey &operator=(VertexPropertyKey &&other) = default;
|
|
||||||
|
|
||||||
Type get_type() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
class EdgePropertyKey : private Sized<8, 8>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
EdgePropertyKey(T &&d);
|
|
||||||
|
|
||||||
EdgePropertyKey(const EdgePropertyKey &other) = default;
|
|
||||||
EdgePropertyKey(EdgePropertyKey &&other) = default;
|
|
||||||
~EdgePropertyKey();
|
|
||||||
|
|
||||||
EdgePropertyKey &operator=(const EdgePropertyKey &other) = default;
|
|
||||||
EdgePropertyKey &operator=(EdgePropertyKey &&other) = default;
|
|
||||||
|
|
||||||
Type get_type() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class K>
|
|
||||||
class VertexPropertyType : private Sized<8, 8>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
VertexPropertyType(T &&d);
|
|
||||||
|
|
||||||
VertexPropertyType(const VertexPropertyType &other) = default;
|
|
||||||
VertexPropertyType(VertexPropertyType &&other) = default;
|
|
||||||
~VertexPropertyType(){};
|
|
||||||
|
|
||||||
VertexPropertyType &operator=(const VertexPropertyType &other) = default;
|
|
||||||
VertexPropertyType &operator=(VertexPropertyType &&other) = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class K>
|
|
||||||
class EdgePropertyType : private Sized<8, 8>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
EdgePropertyType(T &&d);
|
|
||||||
|
|
||||||
EdgePropertyType(const EdgePropertyType &other) = default;
|
|
||||||
EdgePropertyType(EdgePropertyType &&other) = default;
|
|
||||||
~EdgePropertyType(){};
|
|
||||||
|
|
||||||
EdgePropertyType &operator=(const EdgePropertyType &other) = default;
|
|
||||||
EdgePropertyType &operator=(EdgePropertyType &&other) = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
class RecordStream : private Sized<8, 8>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <class T>
|
|
||||||
RecordStream(T &&d);
|
|
||||||
|
|
||||||
RecordStream(const RecordStream &other) = default;
|
|
||||||
RecordStream(RecordStream &&other) = default;
|
|
||||||
~RecordStream();
|
|
||||||
|
|
||||||
RecordStream &operator=(const RecordStream &other) = default;
|
|
||||||
RecordStream &operator=(RecordStream &&other) = default;
|
|
||||||
|
|
||||||
void write(const VertexAccessor &vertex);
|
|
||||||
void write(const EdgeAccessor &edge);
|
|
||||||
void write(const VertexStoredProperty &prop);
|
|
||||||
void write(const EdgeStoredProperty &prop);
|
|
||||||
void write(const Null &v);
|
|
||||||
void write(const Bool &prop);
|
|
||||||
void write(const Float &prop);
|
|
||||||
void write(const Double &prop);
|
|
||||||
void write(const Int32 &prop);
|
|
||||||
void write(const Int64 &prop);
|
|
||||||
void write(const String &prop);
|
|
||||||
void write(const ArrayBool &);
|
|
||||||
void write(const ArrayInt32 &);
|
|
||||||
void write(const ArrayInt64 &);
|
|
||||||
void write(const ArrayFloat &);
|
|
||||||
void write(const ArrayDouble &);
|
|
||||||
void write(const ArrayString &);
|
|
||||||
|
|
||||||
void write_empty_fields();
|
|
||||||
void write_success();
|
|
||||||
void write_success_empty();
|
|
||||||
void write_ignored();
|
|
||||||
void write_fields(const std::vector<std::string> &fields);
|
|
||||||
void write_field(const std::string &field);
|
|
||||||
void write_list_header(size_t size);
|
|
||||||
void write_record();
|
|
||||||
void write_meta(const std::string &type);
|
|
||||||
void write_failure(const std::map<std::string, std::string> &data);
|
|
||||||
void send();
|
|
||||||
void chunk();
|
|
||||||
};
|
|
||||||
|
|
||||||
// ************ Here should be definitions of Unsized barrier classes
|
|
||||||
// Original class can be Unsized barrier class if they are only used outside the
|
|
||||||
// barrier through reference/pointer.
|
|
||||||
// Usized barrier classes should:
|
|
||||||
// --Have same name as original class or somethin more specific if it is
|
|
||||||
// partialy specialized.
|
|
||||||
// --Inherit Unsized class from common.hpp as protected. Blueprint:
|
|
||||||
// class class_name: protected Unsized
|
|
||||||
// --It should specify public methods which can be called on the original class.
|
|
||||||
//
|
|
||||||
// Blueprint:
|
|
||||||
// class class_name : protected Unsized
|
|
||||||
// {
|
|
||||||
// public:
|
|
||||||
//
|
|
||||||
// };
|
|
||||||
|
|
||||||
class VertexPropertyFamily : protected Unsized
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OptionPtr<VertexIndex<std::nullptr_t>> index();
|
|
||||||
};
|
|
||||||
|
|
||||||
class EdgePropertyFamily : protected Unsized
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OptionPtr<EdgeIndex<std::nullptr_t>> index();
|
|
||||||
};
|
|
||||||
|
|
||||||
class Label : protected Unsized
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VertexIndex<std::nullptr_t> &index() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
class EdgeType : protected Unsized
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
friend bool operator<(const EdgeType &lhs, const EdgeType &rhs);
|
|
||||||
|
|
||||||
friend bool operator==(const EdgeType &lhs, const EdgeType &rhs);
|
|
||||||
|
|
||||||
EdgeIndex<std::nullptr_t> &index() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class K>
|
|
||||||
class VertexIndex : protected Unsized
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// TODO: This iterator sometimes has known type. It can be added to this
|
|
||||||
// border to avoid dynamic dispatch
|
|
||||||
VertexIterator for_range(DbAccessor &, Border<K> from = Border<K>(),
|
|
||||||
Border<K> to = Border<K>());
|
|
||||||
|
|
||||||
IndexType type();
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class K>
|
|
||||||
class EdgeIndex : protected Unsized
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// TODO: This iterator has known type. It can be added to this border to
|
|
||||||
// avoid dynamic dispatch
|
|
||||||
EdgeIterator for_range(DbAccessor &, Border<K> from = Border<K>(),
|
|
||||||
Border<K> to = Border<K>());
|
|
||||||
|
|
||||||
IndexType type();
|
|
||||||
};
|
|
||||||
|
|
||||||
class Db : protected Unsized
|
|
||||||
{
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,142 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef BARRIER
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <map>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// This shoul be the only place to include code from memgraph other than
|
|
||||||
// barrier.cpp
|
|
||||||
#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"
|
|
||||||
|
|
||||||
// Contains common classes and functions for barrier.hpp and barrier.cpp.
|
|
||||||
namespace barrier
|
|
||||||
{
|
|
||||||
|
|
||||||
// This define accepts other define which accepts property type to instantiate
|
|
||||||
// template. Recieved define will be called for all property types.
|
|
||||||
#define INSTANTIATE_FOR_PROPERTY(x) \
|
|
||||||
x(Int32) x(Int64) x(Float) x(Double) x(Bool) x(String) x(ArrayInt32) \
|
|
||||||
x(ArrayInt64) x(ArrayFloat) x(ArrayDouble) x(ArrayBool) x(ArrayString)
|
|
||||||
|
|
||||||
// **************************** HELPER FUNCTIONS **************************** //
|
|
||||||
// CASTS FROM& -> TO&
|
|
||||||
template <class TO, class FROM>
|
|
||||||
TO &ref_as(FROM &ref)
|
|
||||||
{
|
|
||||||
return (*reinterpret_cast<TO *>(&ref));
|
|
||||||
}
|
|
||||||
|
|
||||||
// CASTS FROM const& -> TO const&
|
|
||||||
template <class TO, class FROM>
|
|
||||||
TO const &ref_as(FROM const &ref)
|
|
||||||
{
|
|
||||||
return (*reinterpret_cast<TO const *>(&ref));
|
|
||||||
}
|
|
||||||
|
|
||||||
// CASTS FROM* -> TO*
|
|
||||||
template <class TO, class FROM>
|
|
||||||
TO *ptr_as(FROM *ref)
|
|
||||||
{
|
|
||||||
return (reinterpret_cast<TO *>(ref));
|
|
||||||
}
|
|
||||||
|
|
||||||
// CASTS FROM const* -> TO const*
|
|
||||||
template <class TO, class FROM>
|
|
||||||
TO const *ptr_as(FROM const *ref)
|
|
||||||
{
|
|
||||||
return (reinterpret_cast<TO const *>(ref));
|
|
||||||
}
|
|
||||||
|
|
||||||
// CASTS FROM&& -> TO&&
|
|
||||||
template <class TO, class FROM>
|
|
||||||
TO &&value_as(FROM &&ref)
|
|
||||||
{
|
|
||||||
static_assert(sizeof(TO) == sizeof(FROM), "Border class size mismatch");
|
|
||||||
static_assert(alignof(TO) == alignof(FROM),
|
|
||||||
"Border class aligment mismatch");
|
|
||||||
return (reinterpret_cast<TO &&>(std::move(ref)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// CASTS FROM const&& -> TO const&&
|
|
||||||
template <class TO, class FROM>
|
|
||||||
const TO &&value_as(const FROM &&ref)
|
|
||||||
{
|
|
||||||
static_assert(sizeof(TO) == sizeof(FROM), "Border class size mismatch");
|
|
||||||
static_assert(alignof(TO) == alignof(FROM),
|
|
||||||
"Border class aligment mismatch");
|
|
||||||
return (reinterpret_cast<TO const &&>(std::move(ref)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Barrier classes which will be used only through reference/pointer should
|
|
||||||
// inherit this class. Outside of barrier derived classes will be used only
|
|
||||||
// through reference/pointer.
|
|
||||||
class Unsized
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Deleting following constructors/destroyers and opertators will assure
|
|
||||||
// that this class/derived classes can't be created,copyed,deleted or moved.
|
|
||||||
// This way the other side can't "accidentaly" create/copy/destroy or move
|
|
||||||
// objects which inherit this class because that would be erroneous.
|
|
||||||
Unsized() = delete;
|
|
||||||
Unsized(const Unsized &other) = delete;
|
|
||||||
Unsized(Unsized &&other) = delete;
|
|
||||||
~Unsized() = delete;
|
|
||||||
Unsized &operator=(const Unsized &other) = delete;
|
|
||||||
Unsized &operator=(Unsized &&other) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Barrier classes which will be used as value should inherit this class.
|
|
||||||
// Template accepts size_B in B of object of original class from memgraph.
|
|
||||||
// Template accepts alignment_B in B of object of original class from memgraph.
|
|
||||||
template <std::size_t size_B, std::size_t alignment_B>
|
|
||||||
class Sized
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
// This will ensure that this/derived class can't be instantiated.
|
|
||||||
// Something outside the barrier can't "accidentaly" create this/derived
|
|
||||||
// type because that would be erroneous.
|
|
||||||
Sized() = delete;
|
|
||||||
|
|
||||||
// This constructor serves as a check for correctness of size_B and
|
|
||||||
// alignment_B template parametars. Derived class MUST call this constructor
|
|
||||||
// with T which it holds where T is original class from memgraph.
|
|
||||||
template <class T>
|
|
||||||
Sized(T &&d)
|
|
||||||
{
|
|
||||||
new (ptr_as<T>(&data)) T(std::move(d));
|
|
||||||
static_assert(size_B == sizeof(T), "Border class size mismatch");
|
|
||||||
static_assert(alignment_B == alignof(T),
|
|
||||||
"Border class aligment mismatch");
|
|
||||||
}
|
|
||||||
|
|
||||||
// This constructor serves as a check for correctness of size_B and
|
|
||||||
// alignment_B template parametars. Derived class MUST call this constructor
|
|
||||||
// with T which it holds where T is original class from memgraph.
|
|
||||||
template <class T>
|
|
||||||
Sized(const T &&d)
|
|
||||||
{
|
|
||||||
new (ptr_as<T>(&data)) T(std::move(d));
|
|
||||||
static_assert(size_B == sizeof(T), "Border class size mismatch");
|
|
||||||
static_assert(alignment_B == alignof(T),
|
|
||||||
"Border class aligment mismatch");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Here is the aligned storage which imitates size and aligment of object of
|
|
||||||
// original class from memgraph.
|
|
||||||
typename std::aligned_storage<size_B, alignment_B>::type data;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,269 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef BARRIER
|
|
||||||
|
|
||||||
#include "barrier/barrier.hpp"
|
|
||||||
|
|
||||||
// This is the place for imports from memgraph .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"
|
|
||||||
|
|
||||||
// This is the place for imports from memgraph .cpp
|
|
||||||
|
|
||||||
// **************************** HELPER DEFINES *******************************//
|
|
||||||
// Creates 8 functions for transformation of refereces between types x and y.
|
|
||||||
// Where x is a border type.
|
|
||||||
// DANGEROUS
|
|
||||||
#define TRANSFORM_REF(x, y) \
|
|
||||||
x &trans(y &l) { return ref_as<x>(l); } \
|
|
||||||
x const &trans(y const &l) { return ref_as<x const>(l); } \
|
|
||||||
y &trans(x &l) { return ref_as<y>(l); } \
|
|
||||||
y const &trans(x const &l) { return ref_as<y const>(l); } \
|
|
||||||
x *trans(y *l) { return ptr_as<x>(l); } \
|
|
||||||
x const *trans(y const *l) { return ptr_as<x const>(l); } \
|
|
||||||
y *trans(x *l) { return ptr_as<y>(l); } \
|
|
||||||
y const *trans(x const *l) { return ptr_as<y const>(l); }
|
|
||||||
|
|
||||||
// Creates 4 functions for transformation of refereces between types x and y.
|
|
||||||
// Where x is a sized border type.
|
|
||||||
// DANGEROUS
|
|
||||||
#define TRANSFORM_REF_SIZED(x, y) \
|
|
||||||
y &trans(x &l) { return ref_as<y>(l._data_ref()); } \
|
|
||||||
y const &trans(x const &l) \
|
|
||||||
{ \
|
|
||||||
return ref_as<y const>(l._data_ref_const()); \
|
|
||||||
} \
|
|
||||||
y *trans(x *l) { return ptr_as<y>(&(l->_data_ref())); } \
|
|
||||||
y const *trans(x const *l) \
|
|
||||||
{ \
|
|
||||||
return ptr_as<y const>(&(l->_data_ref_const())); \
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates 8 functions for transformation of refereces between types x and y.
|
|
||||||
// Where both x and y are templates over T. Where x is a border type.
|
|
||||||
// DANGEROUS
|
|
||||||
#define TRANSFORM_REF_TEMPLATED(x, y) \
|
|
||||||
x &trans(y &l) { return ref_as<x>(l); } \
|
|
||||||
template <class T> \
|
|
||||||
x const &trans(y const &l) \
|
|
||||||
{ \
|
|
||||||
return ref_as<const x>(l); \
|
|
||||||
} \
|
|
||||||
template <class T> \
|
|
||||||
y &trans(x &l) \
|
|
||||||
{ \
|
|
||||||
return ref_as<y>(l); \
|
|
||||||
} \
|
|
||||||
template <class T> \
|
|
||||||
y const &trans(x const &l) \
|
|
||||||
{ \
|
|
||||||
return ref_as<const y>(l); \
|
|
||||||
} \
|
|
||||||
template <class T> \
|
|
||||||
x *trans(y *l) \
|
|
||||||
{ \
|
|
||||||
return ptr_as<x>(l); \
|
|
||||||
} \
|
|
||||||
template <class T> \
|
|
||||||
const x *trans(const y *l) \
|
|
||||||
{ \
|
|
||||||
return ptr_as<const x>(l); \
|
|
||||||
} \
|
|
||||||
template <class T> \
|
|
||||||
y *trans(x *l) \
|
|
||||||
{ \
|
|
||||||
return ptr_as<y>(l); \
|
|
||||||
} \
|
|
||||||
template <class T> \
|
|
||||||
const y *trans(const x *l) \
|
|
||||||
{ \
|
|
||||||
return ptr_as<const y>(l); \
|
|
||||||
}
|
|
||||||
|
|
||||||
// For certain classes trans evaluates into ref which doesnt work for Sized
|
|
||||||
// constructor. This Move forces type y.
|
|
||||||
// DANGEROUS
|
|
||||||
#define MOVE_CONSTRUCTOR_FORCED(x, y) \
|
|
||||||
x::x(x &&other) : Sized(value_as<y>(std::move(other))) {}
|
|
||||||
|
|
||||||
// Creates constructor x(y) where x is border type and y shpuld be his original
|
|
||||||
// type.
|
|
||||||
// DANGEROUS
|
|
||||||
#define VALID_CONSTRUCTION(x, y) \
|
|
||||||
template <> \
|
|
||||||
barrier::x::x(y &&d) : Sized(std::move(d)) \
|
|
||||||
{ \
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates const constructor x(y) where x is border type and y shpuld be his
|
|
||||||
// original type.
|
|
||||||
// DANGEROUS
|
|
||||||
#define VALID_CONSTRUCTION_CONST(x, y) \
|
|
||||||
template <> \
|
|
||||||
barrier::x::x(y const &&d) : Sized(std::move(d)) \
|
|
||||||
{ \
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates value transformation function from original type y to border type x.
|
|
||||||
// DANGEROUS
|
|
||||||
#define TRANSFORM_VALUE_ONE_RAW(x, y) \
|
|
||||||
x trans(y &&d) { return x(std::move(d)); }
|
|
||||||
|
|
||||||
// Creates value transformation function and constructor from original type y to
|
|
||||||
// border type x.
|
|
||||||
// DANGEROUS
|
|
||||||
#define TRANSFORM_VALUE_ONE(x, y) \
|
|
||||||
VALID_CONSTRUCTION(x, y) \
|
|
||||||
x trans(y &&d) { return x(std::move(d)); }
|
|
||||||
|
|
||||||
// Creates value transformation functions and constructor between border type x
|
|
||||||
// and original type y. Only mutable values.
|
|
||||||
// DANGEROUS
|
|
||||||
#define TRANSFORM_VALUE_MUT(x, y) \
|
|
||||||
TRANSFORM_VALUE_ONE(x, y) \
|
|
||||||
y trans(x &&d) { return value_as<y>(std::move(d)); }
|
|
||||||
|
|
||||||
// Creates value transformation functions and constructors between border type x
|
|
||||||
// and original type y.
|
|
||||||
// DANGEROUS
|
|
||||||
#define TRANSFORM_VALUE(x, y) \
|
|
||||||
TRANSFORM_VALUE_MUT(x, y) \
|
|
||||||
VALID_CONSTRUCTION_CONST(x, y) \
|
|
||||||
const x trans(const y &&d) { return x(std::move(d)); } \
|
|
||||||
const y trans(const x &&d) { return value_as<const y>(std::move(d)); }
|
|
||||||
|
|
||||||
// Duplicates given x to call y with x and ::x
|
|
||||||
#define DUP(x, y) y(x, ::x)
|
|
||||||
|
|
||||||
// ********************** TYPES OF AUTO
|
|
||||||
using vertex_access_iterator_t =
|
|
||||||
decltype(((::DbAccessor *)(std::nullptr_t()))->vertex_access());
|
|
||||||
|
|
||||||
using edge_access_iterator_t =
|
|
||||||
decltype(((::DbAccessor *)(std::nullptr_t()))->edge_access());
|
|
||||||
|
|
||||||
using out_edge_iterator_t =
|
|
||||||
decltype(((::VertexAccessor *)(std::nullptr_t()))->out());
|
|
||||||
|
|
||||||
using in_edge_iterator_t =
|
|
||||||
decltype(((::VertexAccessor *)(std::nullptr_t()))->in());
|
|
||||||
|
|
||||||
// ******************** OVERLOADED trans FUNCTIONS.
|
|
||||||
// This enclosure is the only dangerous part of barrier except of Sized class in
|
|
||||||
// common.hpp
|
|
||||||
namespace barrier
|
|
||||||
{
|
|
||||||
// Blueprint for valid transformation of references:
|
|
||||||
// TRANSFORM_REF(, ::);
|
|
||||||
// template <class T> TRANSFORM_REF_TEMPLATED(<T>,::<T>);
|
|
||||||
// TODO: Strongest assurance that evertyhing is correct is for all of following
|
|
||||||
// transformation to use DUP for defining theres transformation. This would mean
|
|
||||||
// that names of classes exported in barrier and names from real class in
|
|
||||||
// database are equal.
|
|
||||||
|
|
||||||
// ***************** TRANSFORMS of reference and pointers
|
|
||||||
DUP(Label, TRANSFORM_REF);
|
|
||||||
DUP(EdgeType, TRANSFORM_REF);
|
|
||||||
DUP(VertexPropertyFamily, TRANSFORM_REF);
|
|
||||||
DUP(EdgePropertyFamily, TRANSFORM_REF);
|
|
||||||
DUP(VertexAccessor, TRANSFORM_REF);
|
|
||||||
DUP(EdgeAccessor, TRANSFORM_REF);
|
|
||||||
DUP(Db, TRANSFORM_REF);
|
|
||||||
DUP(DbAccessor, TRANSFORM_REF);
|
|
||||||
TRANSFORM_REF(std::vector<label_ref_t>, std::vector<::label_ref_t>);
|
|
||||||
TRANSFORM_REF(VertexPropertyKey,
|
|
||||||
::VertexPropertyFamily::PropertyType::PropertyFamilyKey);
|
|
||||||
TRANSFORM_REF(EdgePropertyKey,
|
|
||||||
::EdgePropertyFamily::PropertyType::PropertyFamilyKey);
|
|
||||||
TRANSFORM_REF(VertexStoredProperty, ::StoredProperty<TypeGroupVertex>);
|
|
||||||
TRANSFORM_REF(EdgeStoredProperty, ::StoredProperty<TypeGroupEdge>);
|
|
||||||
|
|
||||||
// ITERATORS
|
|
||||||
TRANSFORM_REF(VertexIterator, ::iter::Virtual<const ::VertexAccessor>);
|
|
||||||
TRANSFORM_REF(EdgeIterator, ::iter::Virtual<const ::EdgeAccessor>);
|
|
||||||
TRANSFORM_REF(VertexAccessIterator, vertex_access_iterator_t);
|
|
||||||
TRANSFORM_REF(EdgeAccessIterator, edge_access_iterator_t);
|
|
||||||
TRANSFORM_REF(OutEdgesIterator, out_edge_iterator_t);
|
|
||||||
TRANSFORM_REF(InEdgesIterator, in_edge_iterator_t);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
TRANSFORM_REF_TEMPLATED(VertexIndex<T>, VertexIndexBase<T>);
|
|
||||||
template <class T>
|
|
||||||
TRANSFORM_REF_TEMPLATED(EdgeIndex<T>, EdgeIndexBase<T>);
|
|
||||||
template <class T>
|
|
||||||
TRANSFORM_REF_TEMPLATED(RecordStream<T>, ::bolt::RecordStream<T>);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
TRANSFORM_REF_TEMPLATED(
|
|
||||||
VertexPropertyType<T>,
|
|
||||||
::VertexPropertyFamily::PropertyType::PropertyTypeKey<T>);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
TRANSFORM_REF_TEMPLATED(EdgePropertyType<T>,
|
|
||||||
::EdgePropertyFamily::PropertyType::PropertyTypeKey<T>);
|
|
||||||
|
|
||||||
// ****************** TRANSFORMS of value
|
|
||||||
// Blueprint for valid transformation of value:
|
|
||||||
// TRANSFORM_VALUE(, ::);
|
|
||||||
DUP(VertexAccessor, TRANSFORM_VALUE);
|
|
||||||
DUP(EdgeAccessor, TRANSFORM_VALUE);
|
|
||||||
TRANSFORM_VALUE(EdgePropertyKey,
|
|
||||||
::EdgePropertyFamily::PropertyType::PropertyFamilyKey);
|
|
||||||
TRANSFORM_VALUE(VertexPropertyKey,
|
|
||||||
::VertexPropertyFamily::PropertyType::PropertyFamilyKey);
|
|
||||||
TRANSFORM_VALUE_ONE(VertexAccessIterator, vertex_access_iterator_t);
|
|
||||||
MOVE_CONSTRUCTOR_FORCED(VertexAccessIterator, vertex_access_iterator_t);
|
|
||||||
TRANSFORM_VALUE_ONE(EdgeAccessIterator, edge_access_iterator_t);
|
|
||||||
MOVE_CONSTRUCTOR_FORCED(EdgeAccessIterator, edge_access_iterator_t);
|
|
||||||
TRANSFORM_VALUE_ONE(OutEdgesIterator, out_edge_iterator_t);
|
|
||||||
MOVE_CONSTRUCTOR_FORCED(OutEdgesIterator, out_edge_iterator_t);
|
|
||||||
TRANSFORM_VALUE_ONE(InEdgesIterator, in_edge_iterator_t);
|
|
||||||
MOVE_CONSTRUCTOR_FORCED(InEdgesIterator, in_edge_iterator_t);
|
|
||||||
TRANSFORM_VALUE_ONE(VertexIterator, ::iter::Virtual<const ::VertexAccessor>);
|
|
||||||
MOVE_CONSTRUCTOR_FORCED(VertexIterator,
|
|
||||||
::iter::Virtual<const ::VertexAccessor>);
|
|
||||||
TRANSFORM_VALUE_ONE(EdgeIterator, ::iter::Virtual<const ::EdgeAccessor>);
|
|
||||||
MOVE_CONSTRUCTOR_FORCED(EdgeIterator, ::iter::Virtual<const ::EdgeAccessor>);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
TRANSFORM_VALUE_ONE_RAW(
|
|
||||||
VertexPropertyType<T>,
|
|
||||||
::VertexPropertyFamily::PropertyType::PropertyTypeKey<T>);
|
|
||||||
template <class T>
|
|
||||||
TRANSFORM_VALUE_ONE_RAW(EdgePropertyType<T>,
|
|
||||||
::EdgePropertyFamily::PropertyType::PropertyTypeKey<T>)
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
TRANSFORM_VALUE_ONE_RAW(RecordStream<T>, ::bolt::RecordStream<T>)
|
|
||||||
|
|
||||||
// ********************* SPECIAL CONSTRUCTORS
|
|
||||||
#define VertexPropertyType_constructor(x) \
|
|
||||||
template <> \
|
|
||||||
template <> \
|
|
||||||
VertexPropertyType<x>::VertexPropertyType( \
|
|
||||||
::VertexPropertyFamily::PropertyType::PropertyTypeKey<x> &&d) \
|
|
||||||
: Sized(std::move(d)) \
|
|
||||||
{ \
|
|
||||||
}
|
|
||||||
INSTANTIATE_FOR_PROPERTY(VertexPropertyType_constructor);
|
|
||||||
|
|
||||||
#define EdgePropertyType_constructor(x) \
|
|
||||||
template <> \
|
|
||||||
template <> \
|
|
||||||
EdgePropertyType<x>::EdgePropertyType( \
|
|
||||||
::EdgePropertyFamily::PropertyType::PropertyTypeKey<x> &&d) \
|
|
||||||
: Sized(std::move(d)) \
|
|
||||||
{ \
|
|
||||||
}
|
|
||||||
INSTANTIATE_FOR_PROPERTY(EdgePropertyType_constructor);
|
|
||||||
|
|
||||||
DbAccessor::DbAccessor(Db &db) : Sized(::DbAccessor(trans(db))) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -105,10 +105,32 @@ public:
|
|||||||
serializer.write_failure(data);
|
serializer.write_failure(data);
|
||||||
chunk();
|
chunk();
|
||||||
}
|
}
|
||||||
// -- BOLT SPECIFIC METHODS -----------------------------------------------
|
|
||||||
|
void write_count(const size_t count)
|
||||||
|
{
|
||||||
|
write_record();
|
||||||
|
write_list_header(1);
|
||||||
|
write(Int64(count));
|
||||||
|
chunk();
|
||||||
|
}
|
||||||
|
|
||||||
void write(const VertexAccessor &vertex) { serializer.write(vertex); }
|
void write(const VertexAccessor &vertex) { serializer.write(vertex); }
|
||||||
|
void write_vertex_record(const VertexAccessor& va)
|
||||||
|
{
|
||||||
|
write_record();
|
||||||
|
write_list_header(1);
|
||||||
|
write(va);
|
||||||
|
chunk();
|
||||||
|
}
|
||||||
|
|
||||||
void write(const EdgeAccessor &edge) { serializer.write(edge); }
|
void write(const EdgeAccessor &edge) { serializer.write(edge); }
|
||||||
|
void write_edge_record(const EdgeAccessor& ea)
|
||||||
|
{
|
||||||
|
write_record();
|
||||||
|
write_list_header(1);
|
||||||
|
write(ea);
|
||||||
|
chunk();
|
||||||
|
}
|
||||||
|
|
||||||
void write(const StoredProperty<TypeGroupEdge> &prop)
|
void write(const StoredProperty<TypeGroupEdge> &prop)
|
||||||
{
|
{
|
||||||
|
@ -20,8 +20,6 @@ public:
|
|||||||
// -- all possible Memgraph's keys --
|
// -- all possible Memgraph's keys --
|
||||||
constexpr const char *COMPILE_CPU_PATH = "compile_cpu_path";
|
constexpr const char *COMPILE_CPU_PATH = "compile_cpu_path";
|
||||||
constexpr const char *TEMPLATE_CPU_CPP_PATH = "template_cpu_cpp_path";
|
constexpr const char *TEMPLATE_CPU_CPP_PATH = "template_cpu_cpp_path";
|
||||||
constexpr const char *BARRIER_TEMPLATE_CPU_CPP_PATH =
|
|
||||||
"barrier_template_cpu_cpp_path";
|
|
||||||
constexpr const char *SNAPSHOTS_PATH = "snapshots_path";
|
constexpr const char *SNAPSHOTS_PATH = "snapshots_path";
|
||||||
constexpr const char *CLEANING_CYCLE_SEC = "cleaning_cycle_sec";
|
constexpr const char *CLEANING_CYCLE_SEC = "cleaning_cycle_sec";
|
||||||
constexpr const char *SNAPSHOT_CYCLE_SEC = "snapshot_cycle_sec";
|
constexpr const char *SNAPSHOT_CYCLE_SEC = "snapshot_cycle_sec";
|
||||||
|
@ -49,9 +49,11 @@ class DbAccessor
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
DbAccessor(Db &db);
|
DbAccessor(Db &db);
|
||||||
|
|
||||||
DbAccessor(Db &db, tx::Transaction &t);
|
DbAccessor(Db &db, tx::Transaction &t);
|
||||||
|
|
||||||
|
DbAccessor(const DbAccessor& other) = delete;
|
||||||
|
DbAccessor(DbAccessor&& other) = delete;
|
||||||
|
|
||||||
//*******************VERTEX METHODS
|
//*******************VERTEX METHODS
|
||||||
// Returns iterator of VertexAccessor for all vertices.
|
// Returns iterator of VertexAccessor for all vertices.
|
||||||
// TODO: Implement class specaily for this return
|
// TODO: Implement class specaily for this return
|
||||||
@ -140,6 +142,7 @@ public:
|
|||||||
.template type_key<T>();
|
.template type_key<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool update_indexes();
|
||||||
// ******************** TRANSACTION METHODS
|
// ******************** TRANSACTION METHODS
|
||||||
|
|
||||||
// True if commit was successful, or false if transaction was aborted.
|
// True if commit was successful, or false if transaction was aborted.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "logging/loggable.hpp"
|
||||||
#include "storage/indexes/index_update.hpp"
|
#include "storage/indexes/index_update.hpp"
|
||||||
#include "transactions/transaction.hpp"
|
#include "transactions/transaction.hpp"
|
||||||
|
|
||||||
@ -13,13 +14,19 @@ using index_updates_t = std::vector<IndexUpdate>;
|
|||||||
// its methods.
|
// its methods.
|
||||||
// Also serves as a barrier for calling methods defined public but meant for
|
// Also serves as a barrier for calling methods defined public but meant for
|
||||||
// internal use. That kind of method should request DbTransaction&.
|
// internal use. That kind of method should request DbTransaction&.
|
||||||
class DbTransaction
|
class DbTransaction : public Loggable
|
||||||
{
|
{
|
||||||
friend DbAccessor;
|
friend DbAccessor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DbTransaction(Db &db);
|
DbTransaction(Db &db);
|
||||||
DbTransaction(Db &db, tx::Transaction &trans) : db(db), trans(trans) {}
|
DbTransaction(Db &db, tx::Transaction &trans)
|
||||||
|
: Loggable("DbTransaction"), db(db), trans(trans)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DbTransaction(const DbTransaction& other) = delete;
|
||||||
|
DbTransaction(DbTransaction&& other) = default;
|
||||||
|
|
||||||
// Global transactional algorithms,operations and general methods meant for
|
// Global transactional algorithms,operations and general methods meant for
|
||||||
// internal use should be here or should be routed through this object.
|
// internal use should be here or should be routed through this object.
|
||||||
@ -48,14 +55,9 @@ public:
|
|||||||
// with call update_indexes
|
// with call update_indexes
|
||||||
template <class TG>
|
template <class TG>
|
||||||
void to_update_index(typename TG::vlist_t *vlist,
|
void to_update_index(typename TG::vlist_t *vlist,
|
||||||
typename TG::record_t *record)
|
typename TG::record_t *record);
|
||||||
{
|
|
||||||
index_updates.push_back(make_index_update(vlist, record));
|
|
||||||
}
|
|
||||||
|
|
||||||
index_updates_t index_updates;
|
index_updates_t index_updates;
|
||||||
|
|
||||||
tx::Transaction &trans;
|
|
||||||
|
|
||||||
Db &db;
|
Db &db;
|
||||||
|
tx::Transaction &trans;
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
class Loggable
|
class Loggable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Loggable(const std::string& name) : logger(logging::log->logger(name)) {}
|
Loggable(std::string &&name)
|
||||||
|
: logger(logging::log->logger(std::forward<std::string>(name)))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~Loggable() {}
|
virtual ~Loggable() {}
|
||||||
|
|
||||||
|
@ -76,8 +76,10 @@ public:
|
|||||||
template <class... Args>
|
template <class... Args>
|
||||||
void debug(Args&&... args)
|
void debug(Args&&... args)
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
#ifndef LOG_NO_DEBUG
|
#ifndef LOG_NO_DEBUG
|
||||||
emit<Debug>(std::forward<Args>(args)...);
|
emit<Debug>(std::forward<Args>(args)...);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,13 +14,8 @@ class CypherBackend
|
|||||||
public:
|
public:
|
||||||
CypherBackend() : logger(logging::log->logger("CypherBackend"))
|
CypherBackend() : logger(logging::log->logger("CypherBackend"))
|
||||||
{
|
{
|
||||||
// load template file
|
// load template file
|
||||||
#ifdef BARRIER
|
|
||||||
std::string template_path =
|
|
||||||
CONFIG(config::BARRIER_TEMPLATE_CPU_CPP_PATH);
|
|
||||||
#else
|
|
||||||
std::string template_path = CONFIG(config::TEMPLATE_CPU_CPP_PATH);
|
std::string template_path = CONFIG(config::TEMPLATE_CPU_CPP_PATH);
|
||||||
#endif
|
|
||||||
template_text = utils::read_text(fs::path(template_path));
|
template_text = utils::read_text(fs::path(template_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,11 +41,7 @@ public:
|
|||||||
template_text.str(), {{"class_name", "CodeCPU"},
|
template_text.str(), {{"class_name", "CodeCPU"},
|
||||||
{"stripped_hash", std::to_string(stripped_hash)},
|
{"stripped_hash", std::to_string(stripped_hash)},
|
||||||
{"query", query},
|
{"query", query},
|
||||||
#ifdef BARRIER
|
|
||||||
{"stream", "RecordStream<::io::Socket>"},
|
|
||||||
#else
|
|
||||||
{"stream", type_name<Stream>().to_string()},
|
{"stream", type_name<Stream>().to_string()},
|
||||||
#endif
|
|
||||||
{"code", cpp_traverser.code}});
|
{"code", cpp_traverser.code}});
|
||||||
|
|
||||||
logger.trace("generated code: {}", generated);
|
logger.trace("generated code: {}", generated);
|
||||||
|
@ -1,123 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "includes.hpp"
|
|
||||||
|
|
||||||
namespace hardcode
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO: decouple hashes from the code because hashes could and should be
|
|
||||||
// tested separately
|
|
||||||
|
|
||||||
auto load_dressipi_functions(Db &db)
|
|
||||||
{
|
|
||||||
query_functions_t functions;
|
|
||||||
|
|
||||||
// Query: CREATE (n {garment_id: 1234, garment_category_id: 1}) RETURN n
|
|
||||||
// Hash: 12139093029838549530
|
|
||||||
functions[12139093029838549530u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: CREATE (p:profile {profile_id: 111, partner_id: 55}) RETURN p
|
|
||||||
// Hash: 17158428452166262783
|
|
||||||
functions[17158428452166262783u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (g:garment {garment_id: 1234}) SET g:FF RETURN labels(g)
|
|
||||||
// Hash: 11123780635391515946
|
|
||||||
functions[11123780635391515946u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (p:profile {profile_id: 111, partner_id: 55})-[s:score]-(g:garment{garment_id: 1234}) SET s.score = 1550 RETURN s.score
|
|
||||||
// Hash: 674581607834128909
|
|
||||||
functions[674581607834128909u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (g:garment {garment_id: 3456}) SET g.reveals = 50 RETURN g
|
|
||||||
// Hash: 2839969099736071844
|
|
||||||
functions[2839969099736071844u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MERGE (g1:garment {garment_id: 1234})-[r:default_outfit]-(g2:garment {garment_id: 2345}) RETURN r
|
|
||||||
// Hash: 3782642357973971504
|
|
||||||
functions[3782642357973971504u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MERGE (p:profile {profile_id: 111, partner_id: 55})-[s:score]-(g.garment {garment_id: 1234}) SET s.score=1500 RETURN s
|
|
||||||
// Hash: 7871009397157280694
|
|
||||||
functions[7871009397157280694u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (p:profile {profile_id: 111, partner_id: 55})-[s:score]-(g.garment {garment_id: 1234}) DELETE s
|
|
||||||
// Hash: 9459600951073026137
|
|
||||||
functions[9459600951073026137u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (p:profile {profile_id: 113}) DELETE p
|
|
||||||
// Hash: 6763665709953344106
|
|
||||||
functions[6763665709953344106u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (n) DETACH DELETE n
|
|
||||||
// Hash: 4798158026600988079
|
|
||||||
functions[4798158026600988079u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (p:profile) RETURN p
|
|
||||||
// Hash: 15599970964909894866
|
|
||||||
functions[15599970964909894866u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (g:garment) RETURN COUNT(g)
|
|
||||||
// Hash: 11458306387621940265
|
|
||||||
functions[11458306387621940265u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (g:garment {garment_id: 1234}) RETURN g
|
|
||||||
// Hash: 7756609649964321221
|
|
||||||
functions[7756609649964321221u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (p:profile {partner_id: 55}) RETURN p
|
|
||||||
// Hash: 17506488413143988006
|
|
||||||
functions[17506488413143988006u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Query: MATCH (n) RETURN count(n)
|
|
||||||
// Hash: 10510787599699014973
|
|
||||||
functions[10510787599699014973u] = [&db](properties_t &&args) {
|
|
||||||
DbAccessor t(db);
|
|
||||||
return t.commit();
|
|
||||||
};
|
|
||||||
|
|
||||||
return functions;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <iostream>
|
|
||||||
#include <map>
|
|
||||||
#include <map>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
|
||||||
#include "communication/bolt/v1/serialization/record_stream.hpp"
|
|
||||||
#include "database/db.hpp"
|
|
||||||
#include "database/db.hpp"
|
|
||||||
#include "database/db_accessor.hpp"
|
|
||||||
#include "database/db_accessor.hpp"
|
|
||||||
#include "io/network/socket.hpp"
|
|
||||||
#include "mvcc/id.hpp"
|
|
||||||
#include "query/util.hpp"
|
|
||||||
#include "storage/edge_type/edge_type.hpp"
|
|
||||||
#include "storage/edge_x_vertex.hpp"
|
|
||||||
#include "storage/indexes/index_definition.hpp"
|
|
||||||
#include "storage/label/label.hpp"
|
|
||||||
#include "storage/model/properties/all.hpp"
|
|
||||||
#include "storage/model/properties/property.hpp"
|
|
||||||
#include "utils/border.hpp"
|
|
||||||
#include "utils/iterator/iterator.hpp"
|
|
||||||
#include "utils/iterator/iterator.hpp"
|
|
||||||
#include "utils/option_ptr.hpp"
|
|
||||||
#include "utils/reference_wrapper.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
namespace hardcode
|
|
||||||
{
|
|
||||||
using query_functions_t =
|
|
||||||
std::map<uint64_t, std::function<bool(properties_t &&)>>;
|
|
||||||
}
|
|
@ -1,25 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "query/strip/stripped.hpp"
|
|
||||||
|
|
||||||
#ifdef BARRIER
|
|
||||||
#include "barrier/barrier.hpp"
|
|
||||||
#include "io/network/socket.hpp"
|
|
||||||
#else
|
|
||||||
#include "communication/communication.hpp"
|
#include "communication/communication.hpp"
|
||||||
#include "database/db.hpp"
|
#include "database/db.hpp"
|
||||||
#include "database/db_accessor.hpp"
|
#include "database/db_accessor.hpp"
|
||||||
#endif
|
#include "query/strip/stripped.hpp"
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
class IPlanCPU
|
class IPlanCPU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#ifdef BARRIER
|
|
||||||
virtual bool run(barrier::Db &db, plan_args_t &args, Stream &stream) = 0;
|
|
||||||
#else
|
|
||||||
virtual bool run(Db &db, plan_args_t &args, Stream &stream) = 0;
|
virtual bool run(Db &db, plan_args_t &args, Stream &stream) = 0;
|
||||||
#endif
|
|
||||||
virtual ~IPlanCPU() {}
|
virtual ~IPlanCPU() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
class Traverser : public ast::AstVisitor
|
class Traverser : public ast::AstVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using uptr = std::unique_ptr<Traverser>;
|
using uptr = std::unique_ptr<Traverser>;
|
||||||
using sptr = std::shared_ptr<Traverser>;
|
using sptr = std::shared_ptr<Traverser>;
|
||||||
|
|
||||||
|
@ -12,14 +12,6 @@
|
|||||||
// execution
|
// execution
|
||||||
// postprocess the results
|
// postprocess the results
|
||||||
|
|
||||||
// BARRIER!
|
|
||||||
#ifdef BARRIER
|
|
||||||
namespace barrier
|
|
||||||
{
|
|
||||||
Db &trans(::Db &ref);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
class ProgramExecutor
|
class ProgramExecutor
|
||||||
{
|
{
|
||||||
@ -29,13 +21,7 @@ public:
|
|||||||
auto execute(QueryProgram<Stream> &program, Db &db, Stream &stream)
|
auto execute(QueryProgram<Stream> &program, Db &db, Stream &stream)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// TODO: return result of query/code exection
|
|
||||||
#ifdef BARRIER
|
|
||||||
return program.plan->run(barrier::trans(db),
|
|
||||||
program.stripped.arguments, stream);
|
|
||||||
#else
|
|
||||||
return program.plan->run(db, program.stripped.arguments, stream);
|
return program.plan->run(db, program.stripped.arguments, stream);
|
||||||
#endif
|
|
||||||
// TODO: catch more exceptions
|
// TODO: catch more exceptions
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw PlanExecutionException("");
|
throw PlanExecutionException("");
|
||||||
|
@ -80,6 +80,7 @@ private:
|
|||||||
// TODO ifdef MEMGRAPH64 problem, how to use this kind
|
// TODO ifdef MEMGRAPH64 problem, how to use this kind
|
||||||
// of ifdef functions?
|
// of ifdef functions?
|
||||||
// uint64_t depends on fnv function
|
// uint64_t depends on fnv function
|
||||||
|
// TODO: faster datastructure
|
||||||
std::unordered_map<uint64_t, sptr_code_lib> code_libs;
|
std::unordered_map<uint64_t, sptr_code_lib> code_libs;
|
||||||
|
|
||||||
QueryPreprocessor preprocessor;
|
QueryPreprocessor preprocessor;
|
||||||
|
@ -9,32 +9,17 @@
|
|||||||
#include "logging/default.hpp"
|
#include "logging/default.hpp"
|
||||||
#include "storage/model/properties/properties.hpp"
|
#include "storage/model/properties/properties.hpp"
|
||||||
#include "storage/model/properties/property.hpp"
|
#include "storage/model/properties/property.hpp"
|
||||||
#include "storage/model/properties/traversers/consolewriter.hpp"
|
#include "storage/model/properties/json_writer.hpp"
|
||||||
#include "storage/model/properties/traversers/jsonwriter.hpp"
|
|
||||||
#include "utils/types/byte.hpp"
|
#include "utils/types/byte.hpp"
|
||||||
#include "utils/exceptions/basic_exception.hpp"
|
#include "utils/exceptions/basic_exception.hpp"
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void print_props(const Properties<T> &properties);
|
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
#define PRINT_PROPS(_)
|
|
||||||
#else
|
|
||||||
#define PRINT_PROPS(_PROPS_) print_props(_PROPS_);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void cout_properties(const Properties<T> &properties);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void cout_property(const StoredProperty<T> &property);
|
|
||||||
|
|
||||||
// this is a nice way how to avoid multiple definition problem with
|
// this is a nice way how to avoid multiple definition problem with
|
||||||
// headers because it will create a unique namespace for each compilation unit
|
// headers because it will create a unique namespace for each compilation unit
|
||||||
// http://stackoverflow.com/questions/2727582/multiple-definition-in-header-file
|
// http://stackoverflow.com/questions/2727582/multiple-definition-in-header-file
|
||||||
|
// but sometimes that might be a problem
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -61,9 +46,9 @@ std::string code_line(const std::string &format_str, const Args &... args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
using name_properties_t = std::vector<std::pair<std::string, Property>>;
|
using name_properties_t = std::vector<std::pair<std::string, Property>>;
|
||||||
|
using indices_t = std::map<std::string, int>;
|
||||||
|
|
||||||
auto query_properties(const std::map<std::string, int64_t> &indices,
|
auto query_properties(indices_t &indices, properties_t &values)
|
||||||
properties_t &values)
|
|
||||||
{
|
{
|
||||||
name_properties_t properties;
|
name_properties_t properties;
|
||||||
for (auto &property_index : indices) {
|
for (auto &property_index : indices) {
|
||||||
|
@ -2,9 +2,15 @@
|
|||||||
|
|
||||||
#include "mvcc/record.hpp"
|
#include "mvcc/record.hpp"
|
||||||
#include "storage/model/edge_model.hpp"
|
#include "storage/model/edge_model.hpp"
|
||||||
|
#include "utils/string_buffer.hpp"
|
||||||
|
#include "storage/model/properties/json_writer.hpp"
|
||||||
|
#include "utils/handle_write.hpp"
|
||||||
|
|
||||||
class Edge : public mvcc::Record<Edge>
|
class Edge : public mvcc::Record<Edge>
|
||||||
{
|
{
|
||||||
|
using buffer_t = utils::StringBuffer;
|
||||||
|
using props_writer_t = JsonWriter<buffer_t>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Accessor;
|
class Accessor;
|
||||||
|
|
||||||
@ -19,4 +25,14 @@ public:
|
|||||||
Edge &operator=(Edge &&) = delete;
|
Edge &operator=(Edge &&) = delete;
|
||||||
|
|
||||||
EdgeModel data;
|
EdgeModel data;
|
||||||
|
|
||||||
|
template <typename Stream>
|
||||||
|
void stream_repr(Stream &stream) const
|
||||||
|
{
|
||||||
|
auto props = handle_write<buffer_t, props_writer_t>(data.props);
|
||||||
|
|
||||||
|
stream << "Edge(cre = " << tx.cre() << ", "
|
||||||
|
<< "exp = " << tx.exp() << ", "
|
||||||
|
<< "props = " << props.str() << ")";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -19,8 +19,9 @@ class EdgeAccessor : public RecordAccessor<TypeGroupEdge, EdgeAccessor>
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
using RecordAccessor::RecordAccessor;
|
using RecordAccessor::RecordAccessor;
|
||||||
typedef Edge record_t;
|
|
||||||
typedef EdgeRecord record_list_t;
|
using record_t = Edge;
|
||||||
|
using record_list_t = EdgeRecord;
|
||||||
|
|
||||||
// Removes self and disconects vertices from it.
|
// Removes self and disconects vertices from it.
|
||||||
void remove() const;
|
void remove() const;
|
||||||
@ -34,4 +35,21 @@ public:
|
|||||||
|
|
||||||
// EdgeAccessor doesnt need to be filled
|
// EdgeAccessor doesnt need to be filled
|
||||||
VertexAccessor to() const;
|
VertexAccessor to() const;
|
||||||
|
|
||||||
|
template <typename Stream>
|
||||||
|
void stream_repr(Stream& stream) const
|
||||||
|
{
|
||||||
|
auto from_va = from();
|
||||||
|
auto to_va = to();
|
||||||
|
|
||||||
|
from_va.fill();
|
||||||
|
to_va.fill();
|
||||||
|
|
||||||
|
from_va.stream_repr(stream);
|
||||||
|
stream << '-';
|
||||||
|
this->record->stream_repr(stream);
|
||||||
|
stream << "->";
|
||||||
|
to_va.stream_repr(stream);
|
||||||
|
stream << '\n';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
auto VertexAccessor::out() const
|
auto VertexAccessor::out() const
|
||||||
{
|
{
|
||||||
DbTransaction &t = this->db;
|
DbTransaction &t = this->db;
|
||||||
|
std::cout << "VA OUT" << std::endl;
|
||||||
|
std::cout << record->data.out.size() << std::endl;
|
||||||
return iter::make_map(iter::make_iter_ref(record->data.out),
|
return iter::make_map(iter::make_iter_ref(record->data.out),
|
||||||
[&](auto e) -> auto { return EdgeAccessor(*e, t); });
|
[&](auto e) -> auto { return EdgeAccessor(*e, t); });
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "mvcc/id.hpp"
|
#include "mvcc/id.hpp"
|
||||||
|
|
||||||
// #include "storage/indexes/index_record.hpp"
|
// #include "storage/indexes/index_record.hpp"
|
||||||
|
#include "logging/loggable.hpp"
|
||||||
#include "storage/garbage/delete_sensitive.hpp"
|
#include "storage/garbage/delete_sensitive.hpp"
|
||||||
#include "storage/indexes/index_definition.hpp"
|
#include "storage/indexes/index_definition.hpp"
|
||||||
#include "utils/border.hpp"
|
#include "utils/border.hpp"
|
||||||
@ -26,13 +27,14 @@ class Transaction;
|
|||||||
// TG type group
|
// TG type group
|
||||||
// K type of key on which records are ordered
|
// K type of key on which records are ordered
|
||||||
template <class TG, class K>
|
template <class TG, class K>
|
||||||
class IndexBase : public DeleteSensitive
|
class IndexBase : public DeleteSensitive, public Loggable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Created with the database
|
// Created with the database
|
||||||
IndexBase(IndexDefinition &&it);
|
IndexBase(IndexDefinition &&it, std::string &&logger_name = "IndexBase");
|
||||||
|
|
||||||
IndexBase(IndexDefinition &&it, const tx::Transaction &t);
|
IndexBase(IndexDefinition &&it, const tx::Transaction &t,
|
||||||
|
std::string &&logger_name = "IndexBase");
|
||||||
|
|
||||||
virtual ~IndexBase(){};
|
virtual ~IndexBase(){};
|
||||||
|
|
||||||
@ -70,6 +72,9 @@ public:
|
|||||||
|
|
||||||
const IndexDefinition &definition() const { return it; }
|
const IndexDefinition &definition() const { return it; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Logger logger;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const IndexDefinition it;
|
const IndexDefinition it;
|
||||||
// Id of transaction which created this index.
|
// Id of transaction which created this index.
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// #include "storage/label/label.hpp"
|
|
||||||
#include "utils/reference_wrapper.hpp"
|
#include "utils/reference_wrapper.hpp"
|
||||||
|
|
||||||
class Label;
|
class Label;
|
||||||
@ -11,13 +10,13 @@ using label_ref_t = ReferenceWrapper<const Label>;
|
|||||||
class LabelCollection
|
class LabelCollection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
auto begin() { return _labels.begin(); }
|
auto begin() { return labels_.begin(); }
|
||||||
auto begin() const { return _labels.begin(); }
|
auto begin() const { return labels_.begin(); }
|
||||||
auto cbegin() const { return _labels.begin(); }
|
auto cbegin() const { return labels_.begin(); }
|
||||||
|
|
||||||
auto end() { return _labels.end(); }
|
auto end() { return labels_.end(); }
|
||||||
auto end() const { return _labels.end(); }
|
auto end() const { return labels_.end(); }
|
||||||
auto cend() const { return _labels.end(); }
|
auto cend() const { return labels_.end(); }
|
||||||
|
|
||||||
bool add(const Label &label);
|
bool add(const Label &label);
|
||||||
bool has(const Label &label) const;
|
bool has(const Label &label) const;
|
||||||
@ -26,6 +25,13 @@ public:
|
|||||||
void clear();
|
void clear();
|
||||||
const std::vector<label_ref_t> &operator()() const;
|
const std::vector<label_ref_t> &operator()() const;
|
||||||
|
|
||||||
|
template <class Handler>
|
||||||
|
void handle(Handler &handler) const
|
||||||
|
{
|
||||||
|
for (auto &label : labels_)
|
||||||
|
handler.handle(label.get());
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<label_ref_t> _labels;
|
std::vector<label_ref_t> labels_;
|
||||||
};
|
};
|
||||||
|
15
include/storage/label/labels_writer.hpp
Normal file
15
include/storage/label/labels_writer.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class Label;
|
||||||
|
|
||||||
|
template <class Buffer>
|
||||||
|
class LabelsWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LabelsWriter(Buffer &buffer) : buffer_(buffer) {}
|
||||||
|
|
||||||
|
void handle(const Label& label);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Buffer& buffer_;
|
||||||
|
};
|
@ -16,7 +16,7 @@ public:
|
|||||||
auto end() const { return edges.end(); }
|
auto end() const { return edges.end(); }
|
||||||
auto cend() const { return edges.end(); }
|
auto cend() const { return edges.end(); }
|
||||||
|
|
||||||
void add(EdgeRecord *edge) { edges.push_back(edge); }
|
void add(EdgeRecord *edge) { edges.emplace_back(edge); }
|
||||||
|
|
||||||
size_t degree() const { return edges.size(); }
|
size_t degree() const { return edges.size(); }
|
||||||
|
|
||||||
|
@ -70,30 +70,3 @@ private:
|
|||||||
bool first{true};
|
bool first{true};
|
||||||
Buffer &buffer;
|
Buffer &buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StringBuffer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
StringBuffer &operator<<(const std::string &str)
|
|
||||||
{
|
|
||||||
data += str;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuffer &operator<<(const char *str)
|
|
||||||
{
|
|
||||||
data += str;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuffer &operator<<(char c)
|
|
||||||
{
|
|
||||||
data += c;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string &str() { return data; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string data;
|
|
||||||
};
|
|
@ -1,72 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "storage/model/properties/properties.hpp"
|
|
||||||
#include "storage/type_group_edge.hpp"
|
|
||||||
#include "storage/type_group_vertex.hpp"
|
|
||||||
|
|
||||||
using std::cout;
|
|
||||||
using std::endl;
|
|
||||||
|
|
||||||
class ConsoleWriter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ConsoleWriter() {}
|
|
||||||
|
|
||||||
void handle(const StoredProperty<TypeGroupEdge> &value)
|
|
||||||
{
|
|
||||||
handle<TypeGroupEdge>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void handle(const StoredProperty<TypeGroupVertex> &value)
|
|
||||||
{
|
|
||||||
handle<TypeGroupVertex>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void handle(StoredProperty<T> const &value)
|
|
||||||
{
|
|
||||||
cout << "KEY: " << value.key.family_name() << "; VALUE: ";
|
|
||||||
|
|
||||||
value.accept(*this);
|
|
||||||
|
|
||||||
// value.accept(*this);
|
|
||||||
|
|
||||||
cout << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void handle(const Null &v) { cout << "NULL"; }
|
|
||||||
|
|
||||||
void handle(const Bool &b) { cout << b; }
|
|
||||||
|
|
||||||
void handle(const String &s) { cout << s; }
|
|
||||||
|
|
||||||
void handle(const Int32 &int32) { cout << int32; }
|
|
||||||
|
|
||||||
void handle(const Int64 &int64) { cout << int64; }
|
|
||||||
|
|
||||||
void handle(const Float &f) { cout << f; }
|
|
||||||
|
|
||||||
void handle(const Double &d) { cout << d; }
|
|
||||||
|
|
||||||
// Not yet implemented
|
|
||||||
void handle(const ArrayBool &) { assert(false); }
|
|
||||||
|
|
||||||
// Not yet implemented
|
|
||||||
void handle(const ArrayInt32 &) { assert(false); }
|
|
||||||
|
|
||||||
// Not yet implemented
|
|
||||||
void handle(const ArrayInt64 &) { assert(false); }
|
|
||||||
|
|
||||||
// Not yet implemented
|
|
||||||
void handle(const ArrayFloat &) { assert(false); }
|
|
||||||
|
|
||||||
// Not yet implemented
|
|
||||||
void handle(const ArrayDouble &) { assert(false); }
|
|
||||||
|
|
||||||
// Not yet implemented
|
|
||||||
void handle(const ArrayString &) { assert(false); }
|
|
||||||
|
|
||||||
void finish() {}
|
|
||||||
};
|
|
@ -1,11 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "mvcc/record.hpp"
|
#include "mvcc/record.hpp"
|
||||||
#include "storage/model/properties/traversers/jsonwriter.hpp"
|
#include "storage/label/labels_writer.hpp"
|
||||||
|
#include "storage/model/properties/json_writer.hpp"
|
||||||
#include "storage/model/vertex_model.hpp"
|
#include "storage/model/vertex_model.hpp"
|
||||||
|
#include "utils/handle_write.hpp"
|
||||||
|
#include "utils/string_buffer.hpp"
|
||||||
|
|
||||||
class Vertex : public mvcc::Record<Vertex>
|
class Vertex : public mvcc::Record<Vertex>
|
||||||
{
|
{
|
||||||
|
using buffer_t = utils::StringBuffer;
|
||||||
|
using props_writer_t = JsonWriter<buffer_t>;
|
||||||
|
using labels_writer_t = LabelsWriter<buffer_t>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Accessor;
|
class Accessor;
|
||||||
|
|
||||||
@ -20,18 +27,16 @@ public:
|
|||||||
Vertex &operator=(Vertex &&) = delete;
|
Vertex &operator=(Vertex &&) = delete;
|
||||||
|
|
||||||
VertexModel data;
|
VertexModel data;
|
||||||
|
|
||||||
|
template <typename Stream>
|
||||||
|
void stream_repr(Stream &stream) const
|
||||||
|
{
|
||||||
|
auto props = handle_write<buffer_t, props_writer_t>(data.props);
|
||||||
|
auto labels = handle_write<buffer_t, labels_writer_t>(data.labels);
|
||||||
|
|
||||||
|
stream << "Vertex(cre = " << tx.cre() << ", "
|
||||||
|
<< "exp = " << tx.exp() << ", "
|
||||||
|
<< "props = " << props.str() << ", "
|
||||||
|
<< "labels = " << labels.str() << ")";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream &operator<<(std::ostream &stream, const Vertex &record)
|
|
||||||
{
|
|
||||||
StringBuffer buffer;
|
|
||||||
JsonWriter<StringBuffer> writer(buffer);
|
|
||||||
|
|
||||||
// dump properties in this buffer
|
|
||||||
record.data.props.handle(writer);
|
|
||||||
writer.finish();
|
|
||||||
|
|
||||||
return stream << "Vertex"
|
|
||||||
<< "(cre = " << record.tx.cre()
|
|
||||||
<< ", exp = " << record.tx.exp() << "): " << buffer.str();
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "storage/label/label_collection.hpp"
|
||||||
#include "storage/record_accessor.hpp"
|
#include "storage/record_accessor.hpp"
|
||||||
#include "storage/vertex.hpp"
|
#include "storage/vertex.hpp"
|
||||||
#include "utils/iterator/iterator.hpp"
|
#include "utils/iterator/iterator.hpp"
|
||||||
@ -51,4 +52,14 @@ public:
|
|||||||
|
|
||||||
// True if there exists edge between other vertex and this vertex.
|
// True if there exists edge between other vertex and this vertex.
|
||||||
bool in_contains(VertexAccessor const &other) const;
|
bool in_contains(VertexAccessor const &other) const;
|
||||||
|
|
||||||
|
template <typename Stream>
|
||||||
|
void stream_repr(Stream& stream) const
|
||||||
|
{
|
||||||
|
if (this->record != nullptr)
|
||||||
|
this->record->stream_repr(stream);
|
||||||
|
else
|
||||||
|
std::cout << "TRACE: record is nullptr" << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
16
include/utils/handle_write.hpp
Normal file
16
include/utils/handle_write.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Source object is going to be traversed by Writer and Writer will
|
||||||
|
* write that data into the Destination object.
|
||||||
|
*
|
||||||
|
* Writer object defines write format.
|
||||||
|
*/
|
||||||
|
template <typename Destination, typename Writer, typename Source>
|
||||||
|
Destination handle_write(const Source& source)
|
||||||
|
{
|
||||||
|
Destination destination;
|
||||||
|
Writer writter(destination);
|
||||||
|
source.handle(writter);
|
||||||
|
return destination;
|
||||||
|
}
|
@ -6,7 +6,8 @@
|
|||||||
namespace iter
|
namespace iter
|
||||||
{
|
{
|
||||||
|
|
||||||
// Class which Combined two iterators IT1 and IT2. Both return values T
|
// Class which Combined two iterators IT1 and IT2.
|
||||||
|
// Both return values T
|
||||||
// T - type of return value
|
// T - type of return value
|
||||||
// IT1 - first iterator type
|
// IT1 - first iterator type
|
||||||
// IT2 - second iterator type
|
// IT2 - second iterator type
|
||||||
|
@ -116,6 +116,12 @@ public:
|
|||||||
move(), [](auto vr) { return vr.out().fill(); });
|
move(), [](auto vr) { return vr.out().fill(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto in()
|
||||||
|
{
|
||||||
|
return iter::make_flat_map<Derived>(
|
||||||
|
move(), [](auto vr) { return vr.in().fill(); });
|
||||||
|
}
|
||||||
|
|
||||||
// Filters with label on from vertex.
|
// Filters with label on from vertex.
|
||||||
template <class LABEL>
|
template <class LABEL>
|
||||||
auto from_label(LABEL const &label)
|
auto from_label(LABEL const &label)
|
||||||
@ -153,6 +159,12 @@ public:
|
|||||||
move(), [&](auto &v) mutable { t = Option<const T>(v); });
|
move(), [&](auto &v) mutable { t = Option<const T>(v); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// auto clone_to(Option<T> &t)
|
||||||
|
// {
|
||||||
|
// return iter::make_inspect<Derived>(
|
||||||
|
// move(), [&](auto &e) mutable { t = Option<T>(e); });
|
||||||
|
// }
|
||||||
|
|
||||||
// Filters with call to method fill()
|
// Filters with call to method fill()
|
||||||
auto fill()
|
auto fill()
|
||||||
{
|
{
|
||||||
|
@ -6,27 +6,31 @@
|
|||||||
namespace iter
|
namespace iter
|
||||||
{
|
{
|
||||||
|
|
||||||
// Class which inspects values returned by I iterator before passing thenm as
|
// Class which inspects values returned by I iterator
|
||||||
// result.
|
// before passing them as a result.
|
||||||
// function.
|
// function.
|
||||||
// T - type of return value
|
// T - type of return value
|
||||||
// I - iterator type
|
// I - iterator type
|
||||||
// OP - type of inspector function. OP: T&->void
|
// OP - type of inspector function. OP: T&->void
|
||||||
template <class T, class I, class OP>
|
template <class T, class I, class OP>
|
||||||
class Inspect : public IteratorBase<T>, public Composable<T, Inspect<T, I, OP>>
|
class Inspect : public IteratorBase<T>,
|
||||||
|
public Composable<T, Inspect<T, I, OP>>
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Inspect() = delete;
|
Inspect() = delete;
|
||||||
|
|
||||||
// Inspect operation is designed to be used in chained calls which operate
|
// Inspect operation is designed to be used
|
||||||
// on a
|
// in chained calls which operate on an
|
||||||
// iterator. Inspect will in that usecase receive other iterator by value
|
// iterator. Inspect will in that usecase
|
||||||
// and
|
// receive other iterator by value and
|
||||||
// std::move is a optimization for it.
|
// std::move is a optimization for it.
|
||||||
Inspect(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {}
|
Inspect(I &&iter, OP &&op) :
|
||||||
|
iter(std::move(iter)),
|
||||||
|
op(std::move(op))
|
||||||
|
{}
|
||||||
|
|
||||||
Inspect(Inspect &&m) : iter(std::move(m.iter)), op(std::move(m.op)) {}
|
Inspect(Inspect &&m) :
|
||||||
|
iter(std::move(m.iter)), op(std::move(m.op)) {}
|
||||||
|
|
||||||
~Inspect() final {}
|
~Inspect() final {}
|
||||||
|
|
||||||
@ -52,7 +56,7 @@ template <class I, class OP>
|
|||||||
auto make_inspect(I &&iter, OP &&op)
|
auto make_inspect(I &&iter, OP &&op)
|
||||||
{
|
{
|
||||||
// Compiler cant deduce type T. decltype is here to help with it.
|
// Compiler cant deduce type T. decltype is here to help with it.
|
||||||
return Inspect<decltype(iter.next().take()), I, OP>(std::move(iter),
|
return Inspect<decltype(iter.next().take()), I, OP>
|
||||||
std::move(op));
|
(std::move(iter), std::move(op));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "query_engine/exceptions/exceptions.hpp"
|
|
||||||
|
#include "utils/exceptions/out_of_memory.hpp"
|
||||||
#include "utils/memory/block_allocator.hpp"
|
#include "utils/memory/block_allocator.hpp"
|
||||||
|
|
||||||
// http://en.cppreference.com/w/cpp/language/new
|
// http://en.cppreference.com/w/cpp/language/new
|
||||||
@ -24,7 +25,8 @@ public:
|
|||||||
// until it eats all the memory.
|
// until it eats all the memory.
|
||||||
static_assert(sizeof(T) <= page_size,
|
static_assert(sizeof(T) <= page_size,
|
||||||
"Cant allocate objects larger than page_size");
|
"Cant allocate objects larger than page_size");
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
// Mask which has log2(alignof(T)) lower bits setted to 0 and the
|
// Mask which has log2(alignof(T)) lower bits setted to 0 and the
|
||||||
// rest to 1.
|
// rest to 1.
|
||||||
// example:
|
// example:
|
||||||
@ -56,7 +58,8 @@ public:
|
|||||||
|
|
||||||
// If the new_head is greater than end that means that there isn't
|
// If the new_head is greater than end that means that there isn't
|
||||||
// enough space for object T in current block of memory.
|
// enough space for object T in current block of memory.
|
||||||
if (LIKELY(new_head <= end)) {
|
if (LIKELY(new_head <= end))
|
||||||
|
{
|
||||||
|
|
||||||
// All is fine, head can become new_head
|
// All is fine, head can become new_head
|
||||||
head = new_head;
|
head = new_head;
|
||||||
@ -99,7 +102,8 @@ public:
|
|||||||
// Relases all memory.
|
// Relases all memory.
|
||||||
void free()
|
void free()
|
||||||
{
|
{
|
||||||
while (allocated_blocks.size() > 0) {
|
while (allocated_blocks.size() > 0)
|
||||||
|
{
|
||||||
blocks.release(allocated_blocks.back());
|
blocks.release(allocated_blocks.back());
|
||||||
allocated_blocks.pop_back();
|
allocated_blocks.pop_back();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
// Optional object storage. It maybe has and maybe dosent have objet of type T.
|
// Optional object storage. It maybe has and maybe
|
||||||
|
// dosent have objet of type T.
|
||||||
template <class T>
|
template <class T>
|
||||||
class Option
|
class Option
|
||||||
{
|
{
|
||||||
@ -33,12 +34,14 @@ public:
|
|||||||
std::memset(data._M_addr(), 0, sizeof(T));
|
std::memset(data._M_addr(), 0, sizeof(T));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Containers from std which have strong exception guarantees wont use move
|
|
||||||
// constructors and operators wihtout noexcept. "Optimized C++,2016 , Kurt
|
// Containers from std which have strong exception
|
||||||
// Guntheroth, page: 142, title: Moving instances into std::vector"
|
// guarantees wont use move constructors and operators
|
||||||
|
// wihtout noexcept. "Optimized C++,2016 , Kurt
|
||||||
|
// Guntheroth, page: 142, title: Moving instances into
|
||||||
|
// std::vector"
|
||||||
Option(Option &&other) noexcept
|
Option(Option &&other) noexcept
|
||||||
{
|
{
|
||||||
|
|
||||||
if (other.initialized) {
|
if (other.initialized) {
|
||||||
new (data._M_addr()) T(std::move(other.get()));
|
new (data._M_addr()) T(std::move(other.get()));
|
||||||
other.initialized = false;
|
other.initialized = false;
|
||||||
@ -69,6 +72,7 @@ public:
|
|||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Option &operator=(Option &&other)
|
Option &operator=(Option &&other)
|
||||||
{
|
{
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
@ -180,8 +184,9 @@ public:
|
|||||||
explicit operator bool() const { return initialized; }
|
explicit operator bool() const { return initialized; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Aligned buffer is here to ensure aligment for data of type T. It isn't
|
// Aligned buffer is here to ensure aligment for
|
||||||
// applicable to just put T field because the field has to be able to be
|
// data of type T. It isn't applicable to just put T
|
||||||
|
// field because the field has to be able to be
|
||||||
// uninitialized to fulfill the semantics of Option class.
|
// uninitialized to fulfill the semantics of Option class.
|
||||||
__gnu_cxx::__aligned_buffer<T> data;
|
__gnu_cxx::__aligned_buffer<T> data;
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
35
include/utils/string_buffer.hpp
Normal file
35
include/utils/string_buffer.hpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
class StringBuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StringBuffer &operator<<(const std::string &str)
|
||||||
|
{
|
||||||
|
data += str;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuffer &operator<<(const char *str)
|
||||||
|
{
|
||||||
|
data += str;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuffer &operator<<(char c)
|
||||||
|
{
|
||||||
|
data += c;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string &str() { return data; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string data;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -9,11 +9,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
||||||
#include "data_structures/map/rh_hashmap.hpp"
|
#include "data_structures/map/rh_hashmap.hpp"
|
||||||
#include "database/db.hpp"
|
#include "database/db.hpp"
|
||||||
#include "database/db_accessor.cpp"
|
#include "database/db_accessor.cpp"
|
||||||
#include "database/db_accessor.hpp"
|
#include "database/db_accessor.hpp"
|
||||||
|
|
||||||
#include "import/csv_import.hpp"
|
#include "import/csv_import.hpp"
|
||||||
#include "logging/default.hpp"
|
#include "logging/default.hpp"
|
||||||
#include "logging/streams/stdout.hpp"
|
#include "logging/streams/stdout.hpp"
|
||||||
@ -23,8 +23,6 @@
|
|||||||
#include "storage/indexes/impl/nonunique_unordered_index.cpp"
|
#include "storage/indexes/impl/nonunique_unordered_index.cpp"
|
||||||
#include "storage/model/properties/properties.cpp"
|
#include "storage/model/properties/properties.cpp"
|
||||||
#include "storage/record_accessor.cpp"
|
#include "storage/record_accessor.cpp"
|
||||||
// #include "storage/vertex_accessor.cpp"
|
|
||||||
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
|
||||||
#include "storage/vertex_accessor.hpp"
|
#include "storage/vertex_accessor.hpp"
|
||||||
#include "storage/vertices.cpp"
|
#include "storage/vertices.cpp"
|
||||||
#include "storage/vertices.hpp"
|
#include "storage/vertices.hpp"
|
||||||
@ -62,7 +60,8 @@ public:
|
|||||||
{
|
{
|
||||||
auto now = this;
|
auto now = this;
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
sum += (now->vacc.at(tkey).get())->value();
|
sum += (now->vacc.at(tkey).get())->value();
|
||||||
now = now->parent;
|
now = now->parent;
|
||||||
} while (now != nullptr);
|
} while (now != nullptr);
|
||||||
@ -84,8 +83,11 @@ void found_result(Node *res)
|
|||||||
|
|
||||||
std::cout << "{score: " << sum << endl;
|
std::cout << "{score: " << sum << endl;
|
||||||
auto bef = res;
|
auto bef = res;
|
||||||
while (bef != nullptr) {
|
while (bef != nullptr)
|
||||||
std::cout << " " << *(bef->vacc.operator->()) << endl;
|
{
|
||||||
|
std::cout << " ";
|
||||||
|
bef->vacc.operator->()->stream_repr(std::cout);
|
||||||
|
std::cout << std::endl;
|
||||||
bef = bef->parent;
|
bef = bef->parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,18 +115,23 @@ bool vertex_filter_dummy(DbAccessor &t, VertexAccessor &va, Node *before)
|
|||||||
bool vertex_filter_contained_dummy(DbAccessor &t, VertexAccessor &v,
|
bool vertex_filter_contained_dummy(DbAccessor &t, VertexAccessor &v,
|
||||||
Node *before)
|
Node *before)
|
||||||
{
|
{
|
||||||
if (v.fill()) {
|
if (v.fill())
|
||||||
|
{
|
||||||
bool found;
|
bool found;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
found = false;
|
found = false;
|
||||||
before = before->parent;
|
before = before->parent;
|
||||||
if (before == nullptr) {
|
if (before == nullptr)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto it = before->vacc.out();
|
auto it = before->vacc.out();
|
||||||
for (auto e = it.next(); e.is_present(); e = it.next()) {
|
for (auto e = it.next(); e.is_present(); e = it.next())
|
||||||
|
{
|
||||||
VertexAccessor va = e.get().to();
|
VertexAccessor va = e.get().to();
|
||||||
if (va == v) {
|
if (va == v)
|
||||||
|
{
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -136,12 +143,15 @@ bool vertex_filter_contained_dummy(DbAccessor &t, VertexAccessor &v,
|
|||||||
|
|
||||||
bool vertex_filter_contained(DbAccessor &t, VertexAccessor &v, Node *before)
|
bool vertex_filter_contained(DbAccessor &t, VertexAccessor &v, Node *before)
|
||||||
{
|
{
|
||||||
if (v.fill()) {
|
if (v.fill())
|
||||||
|
{
|
||||||
bool found;
|
bool found;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
found = false;
|
found = false;
|
||||||
before = before->parent;
|
before = before->parent;
|
||||||
if (before == nullptr) {
|
if (before == nullptr)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} while (v.in_contains(before->vacc));
|
} while (v.in_contains(before->vacc));
|
||||||
@ -163,7 +173,9 @@ auto a_star(
|
|||||||
DbAccessor t(db);
|
DbAccessor t(db);
|
||||||
|
|
||||||
type_key_t<TypeGroupVertex, Double> type_key =
|
type_key_t<TypeGroupVertex, Double> type_key =
|
||||||
t.vertex_property_family_get("score").get(Flags::Double).type_key<Double>();
|
t.vertex_property_family_get("score")
|
||||||
|
.get(Flags::Double)
|
||||||
|
.type_key<Double>();
|
||||||
|
|
||||||
auto best_found = new std::map<Id, Score>[max_depth];
|
auto best_found = new std::map<Id, Score>[max_depth];
|
||||||
|
|
||||||
@ -177,17 +189,20 @@ auto a_star(
|
|||||||
Node *start = new Node(start_vr.take(), 0, type_key);
|
Node *start = new Node(start_vr.take(), 0, type_key);
|
||||||
queue.push(start);
|
queue.push(start);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
auto now = queue.top();
|
auto now = queue.top();
|
||||||
queue.pop();
|
queue.pop();
|
||||||
// if(!visited.insert(now)){
|
// if(!visited.insert(now)){
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (max_depth <= now->depth) {
|
if (max_depth <= now->depth)
|
||||||
|
{
|
||||||
best.push_back(now);
|
best.push_back(now);
|
||||||
count++;
|
count++;
|
||||||
if (count >= limit) {
|
if (count >= limit)
|
||||||
|
{
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -202,9 +217,11 @@ auto a_star(
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
iter::for_all(now->vacc.out(), [&](auto edge) {
|
iter::for_all(now->vacc.out(), [&](auto edge) {
|
||||||
if (e_filter[now->depth](t, edge, now)) {
|
if (e_filter[now->depth](t, edge, now))
|
||||||
|
{
|
||||||
VertexAccessor va = edge.to();
|
VertexAccessor va = edge.to();
|
||||||
if (v_filter[now->depth](t, va, now)) {
|
if (v_filter[now->depth](t, va, now))
|
||||||
|
{
|
||||||
auto cost = calc_heuristic_cost(type_key, edge, va);
|
auto cost = calc_heuristic_cost(type_key, edge, va);
|
||||||
Node *n = new Node(va, now->cost + cost, now, type_key);
|
Node *n = new Node(va, now->cost + cost, now, type_key);
|
||||||
queue.push(n);
|
queue.push(n);
|
||||||
@ -246,7 +263,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
std::vector<Node *> best;
|
std::vector<Node *> best;
|
||||||
for (int i = 0; i < bench_n; i++) {
|
for (int i = 0; i < bench_n; i++)
|
||||||
|
{
|
||||||
auto start_vertex_index = std::rand() % loaded.first;
|
auto start_vertex_index = std::rand() % loaded.first;
|
||||||
|
|
||||||
auto begin = clock();
|
auto begin = clock();
|
||||||
@ -260,12 +278,14 @@ int main(int argc, char **argv)
|
|||||||
if ((best.size() < best_print_n && found.size() > best.size()) ||
|
if ((best.size() < best_print_n && found.size() > best.size()) ||
|
||||||
(pick_best_found && found.size() > 0 &&
|
(pick_best_found && found.size() > 0 &&
|
||||||
found.front()->sum_vertex_score() >
|
found.front()->sum_vertex_score() >
|
||||||
best.front()->sum_vertex_score())) {
|
best.front()->sum_vertex_score()))
|
||||||
|
{
|
||||||
best = found;
|
best = found;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just to be safe
|
// Just to be safe
|
||||||
if (i + 1 == bench_n && best.size() == 0) {
|
if (i + 1 == bench_n && best.size() == 0)
|
||||||
|
{
|
||||||
bench_n++;
|
bench_n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,7 +294,8 @@ int main(int argc, char **argv)
|
|||||||
<< " results has runing time of:\n avg: " << sum / bench_n
|
<< " results has runing time of:\n avg: " << sum / bench_n
|
||||||
<< " [ms]\n";
|
<< " [ms]\n";
|
||||||
std::cout << "\nExample of best result:\n";
|
std::cout << "\nExample of best result:\n";
|
||||||
for (int i = 0; i < best_print_n && best.size() > 0; i++) {
|
for (int i = 0; i < best_print_n && best.size() > 0; i++)
|
||||||
|
{
|
||||||
found_result(best.front());
|
found_result(best.front());
|
||||||
best.erase(best.begin());
|
best.erase(best.begin());
|
||||||
}
|
}
|
||||||
@ -292,7 +313,8 @@ void add_scores(Db &db)
|
|||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
iter::for_all(t.vertex_access(), [&](auto v) {
|
iter::for_all(t.vertex_access(), [&](auto v) {
|
||||||
if (v.fill()) {
|
if (v.fill())
|
||||||
|
{
|
||||||
// any random number is OK
|
// any random number is OK
|
||||||
std::srand(i ^ 0x7482616);
|
std::srand(i ^ 0x7482616);
|
||||||
v.set(StoredProperty<TypeGroupVertex>(
|
v.set(StoredProperty<TypeGroupVertex>(
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
#include "queries/astar.cpp"
|
|
||||||
|
|
||||||
#include "barrier/barrier.cpp"
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
@ -21,6 +17,7 @@
|
|||||||
#include "import/csv_import.hpp"
|
#include "import/csv_import.hpp"
|
||||||
#include "logging/default.hpp"
|
#include "logging/default.hpp"
|
||||||
#include "logging/streams/stdout.hpp"
|
#include "logging/streams/stdout.hpp"
|
||||||
|
#include "queries/astar.hpp"
|
||||||
#include "storage/edge_x_vertex.hpp"
|
#include "storage/edge_x_vertex.hpp"
|
||||||
#include "storage/edges.cpp"
|
#include "storage/edges.cpp"
|
||||||
#include "storage/edges.hpp"
|
#include "storage/edges.hpp"
|
||||||
@ -41,21 +38,23 @@ int main(int argc, char **argv)
|
|||||||
auto para = all_arguments(argc, argv);
|
auto para = all_arguments(argc, argv);
|
||||||
|
|
||||||
Db db("astar");
|
Db db("astar");
|
||||||
barrier::CodeCPU cp;
|
PlanCPU plan;
|
||||||
int bench_n = 1000;
|
int bench_n = 1000;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
for (int i = 0; i < bench_n; i++) {
|
for (int i = 0; i < bench_n; i++)
|
||||||
|
{
|
||||||
auto start_vertex_index =
|
auto start_vertex_index =
|
||||||
std::rand() % db.graph.vertices.access().size();
|
std::rand() % db.graph.vertices.access().size();
|
||||||
|
|
||||||
auto begin = clock();
|
auto begin = clock();
|
||||||
|
|
||||||
code_args_t args;
|
plan_args_t args;
|
||||||
args.push_back(Property(Int64(start_vertex_index), Int64::type));
|
args.push_back(Property(Int64(start_vertex_index), Int64::type));
|
||||||
|
|
||||||
cp.run(barrier::trans(db), args, std::cout);
|
plan.run(db, args, std::cout);
|
||||||
|
|
||||||
clock_t end = clock();
|
clock_t end = clock();
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ int main(int argc, char **argv)
|
|||||||
sum += elapsed_ms;
|
sum += elapsed_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "\nSearch for best " << barrier::limit
|
std::cout << "\nSearch for best " << limit
|
||||||
<< " results has runing time of:\n avg: " << sum / bench_n
|
<< " results has runing time of:\n avg: " << sum / bench_n
|
||||||
<< " [ms]\n";
|
<< " [ms]\n";
|
||||||
} while (true);
|
} while (true);
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
// TODO: remove barrier
|
|
||||||
#include "barrier/barrier.cpp"
|
|
||||||
|
|
||||||
#include "database/db.hpp"
|
#include "database/db.hpp"
|
||||||
#include "database/db_accessor.hpp"
|
#include "database/db_accessor.hpp"
|
||||||
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
||||||
@ -20,7 +17,7 @@ using namespace std;
|
|||||||
|
|
||||||
// (company, {type_name, score})
|
// (company, {type_name, score})
|
||||||
using company_profile_type =
|
using company_profile_type =
|
||||||
pair<barrier::VertexAccessor, unordered_map<string, double>>;
|
pair<VertexAccessor, unordered_map<string, double>>;
|
||||||
|
|
||||||
// Accepted flags for CSV import.
|
// Accepted flags for CSV import.
|
||||||
// -db name # will create database with that name.
|
// -db name # will create database with that name.
|
||||||
@ -44,7 +41,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
// query benchmark
|
// query benchmark
|
||||||
auto begin = clock();
|
auto begin = clock();
|
||||||
int n = for_all_companys(barrier::trans(t), company_profiles);
|
int n = for_all_companys(t, company_profiles);
|
||||||
clock_t end = clock();
|
clock_t end = clock();
|
||||||
double elapsed_s = (double(end - begin) / CLOCKS_PER_SEC);
|
double elapsed_s = (double(end - begin) / CLOCKS_PER_SEC);
|
||||||
|
|
||||||
@ -71,8 +68,8 @@ int main(int argc, char **argv)
|
|||||||
for (auto &company_profile : company_profiles) {
|
for (auto &company_profile : company_profiles) {
|
||||||
auto prop_vertex_id = t.vertex_property_key<Int64>("company_id");
|
auto prop_vertex_id = t.vertex_property_key<Int64>("company_id");
|
||||||
auto db_company_id =
|
auto db_company_id =
|
||||||
*barrier::trans(company_profile.first).at(prop_vertex_id).get();
|
company_profile.first.at(prop_vertex_id).get();
|
||||||
if (db_company_id == company_id) {
|
if (db_company_id->value() == company_id) {
|
||||||
cout << endl << "CompanyID: " << company_id << endl;
|
cout << endl << "CompanyID: " << company_id << endl;
|
||||||
for (auto e : company_profile.second) {
|
for (auto e : company_profile.second) {
|
||||||
cout << e.first << " = " << e.second << endl;
|
cout << e.first << " = " << e.second << endl;
|
||||||
|
@ -8,13 +8,10 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "barrier/barrier.hpp"
|
#include "storage/edge_x_vertex.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace barrier
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO: Turn next template, expand on it, standardize it, and use it for query
|
// TODO: Turn next template, expand on it, standardize it, and use it for query
|
||||||
// generation.
|
// generation.
|
||||||
|
|
||||||
@ -334,10 +331,9 @@ size_t for_all_companys(
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
iter::for_all_fill(
|
iter::for_all_fill(
|
||||||
t.label_find_or_create("Company").index().for_range(t), [&](auto v) {
|
t.label_find_or_create("Company").index().for_range(t), [&](auto v) {
|
||||||
coll.push_back(make_pair(v, barrier::query(t, v.id())));
|
coll.push_back(make_pair(v, query(t, v.id())));
|
||||||
i++;
|
i++;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "query/i_code_cpu.hpp"
|
#include "query/i_plan_cpu.hpp"
|
||||||
#include "storage/model/properties/all.hpp"
|
#include "storage/model/properties/all.hpp"
|
||||||
|
#include "storage/vertex_accessor.hpp"
|
||||||
|
#include "storage/edge_x_vertex.hpp"
|
||||||
#include "utils/memory/stack_allocator.hpp"
|
#include "utils/memory/stack_allocator.hpp"
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
@ -12,12 +14,7 @@ using std::endl;
|
|||||||
|
|
||||||
// Dressipi astar query of 4 clicks.
|
// Dressipi astar query of 4 clicks.
|
||||||
|
|
||||||
// BARRIER!
|
using Stream = std::ostream;
|
||||||
namespace barrier
|
|
||||||
{
|
|
||||||
|
|
||||||
using STREAM = std::ostream;
|
|
||||||
// using STREAM = RecordStream<::io::Socket>;
|
|
||||||
|
|
||||||
constexpr size_t max_depth = 3;
|
constexpr size_t max_depth = 3;
|
||||||
constexpr size_t limit = 10;
|
constexpr size_t limit = 10;
|
||||||
@ -47,7 +44,8 @@ public:
|
|||||||
{
|
{
|
||||||
auto now = this;
|
auto now = this;
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
sum += (now->vacc.at(tkey).get())->value();
|
sum += (now->vacc.at(tkey).get())->value();
|
||||||
now = now->parent;
|
now = now->parent;
|
||||||
} while (now != nullptr);
|
} while (now != nullptr);
|
||||||
@ -57,12 +55,15 @@ public:
|
|||||||
|
|
||||||
bool vertex_filter_contained(DbAccessor &t, VertexAccessor &v, Node *before)
|
bool vertex_filter_contained(DbAccessor &t, VertexAccessor &v, Node *before)
|
||||||
{
|
{
|
||||||
if (v.fill()) {
|
if (v.fill())
|
||||||
|
{
|
||||||
bool found;
|
bool found;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
found = false;
|
found = false;
|
||||||
before = before->parent;
|
before = before->parent;
|
||||||
if (before == nullptr) {
|
if (before == nullptr)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} while (v.in_contains(before->vacc));
|
} while (v.in_contains(before->vacc));
|
||||||
@ -70,7 +71,7 @@ bool vertex_filter_contained(DbAccessor &t, VertexAccessor &v, Node *before)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void astar(DbAccessor &t, code_args_t &args, STREAM &stream)
|
void astar(DbAccessor &t, plan_args_t &args, Stream &stream)
|
||||||
{
|
{
|
||||||
StackAllocator stack;
|
StackAllocator stack;
|
||||||
VertexPropertyType<Double> tkey = t.vertex_property_key<Double>("score");
|
VertexPropertyType<Double> tkey = t.vertex_property_key<Double>("score");
|
||||||
@ -79,7 +80,8 @@ void astar(DbAccessor &t, code_args_t &args, STREAM &stream)
|
|||||||
std::priority_queue<Node *, std::vector<Node *>, decltype(cmp)> queue(cmp);
|
std::priority_queue<Node *, std::vector<Node *>, decltype(cmp)> queue(cmp);
|
||||||
|
|
||||||
auto start_vr = t.vertex_find(Id(args[0].as<Int64>().value()));
|
auto start_vr = t.vertex_find(Id(args[0].as<Int64>().value()));
|
||||||
if (!start_vr.is_present()) {
|
if (!start_vr.is_present())
|
||||||
|
{
|
||||||
// stream.write_failure({{}});
|
// stream.write_failure({{}});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -89,15 +91,18 @@ void astar(DbAccessor &t, code_args_t &args, STREAM &stream)
|
|||||||
queue.push(start);
|
queue.push(start);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
auto now = queue.top();
|
auto now = queue.top();
|
||||||
queue.pop();
|
queue.pop();
|
||||||
|
|
||||||
if (max_depth <= now->depth) {
|
if (max_depth <= now->depth)
|
||||||
|
{
|
||||||
// stream.write_success_empty();
|
// stream.write_success_empty();
|
||||||
// best.push_back(now);
|
// best.push_back(now);
|
||||||
count++;
|
count++;
|
||||||
if (count >= limit) {
|
if (count >= limit)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -105,7 +110,8 @@ void astar(DbAccessor &t, code_args_t &args, STREAM &stream)
|
|||||||
|
|
||||||
iter::for_all(now->vacc.out(), [&](auto edge) {
|
iter::for_all(now->vacc.out(), [&](auto edge) {
|
||||||
VertexAccessor va = edge.to();
|
VertexAccessor va = edge.to();
|
||||||
if (vertex_filter_contained(t, va, now)) {
|
if (vertex_filter_contained(t, va, now))
|
||||||
|
{
|
||||||
auto cost = 1 - va.at(tkey).get()->value();
|
auto cost = 1 - va.at(tkey).get()->value();
|
||||||
Node *n = new (stack.allocate<Node>())
|
Node *n = new (stack.allocate<Node>())
|
||||||
Node(va, now->cost + cost, now, tkey);
|
Node(va, now->cost + cost, now, tkey);
|
||||||
@ -117,10 +123,10 @@ void astar(DbAccessor &t, code_args_t &args, STREAM &stream)
|
|||||||
stack.free();
|
stack.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
class CodeCPU : public ICodeCPU<STREAM>
|
class PlanCPU : public IPlanCPU<Stream>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool run(Db &db, code_args_t &args, STREAM &stream) override
|
bool run(Db &db, plan_args_t &args, Stream &stream) override
|
||||||
{
|
{
|
||||||
DbAccessor t(db);
|
DbAccessor t(db);
|
||||||
|
|
||||||
@ -129,14 +135,9 @@ public:
|
|||||||
return t.commit();
|
return t.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
~CodeCPU() {}
|
~PlanCPU() {}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" ICodeCPU<barrier::STREAM> *produce()
|
extern "C" IPlanCPU<Stream> *produce() { return new PlanCPU(); }
|
||||||
{
|
|
||||||
// BARRIER!
|
|
||||||
return new barrier::CodeCPU();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void destruct(ICodeCPU<barrier::STREAM> *p) { delete p; }
|
extern "C" void destruct(IPlanCPU<Stream> *p) { delete p; }
|
@ -11,8 +11,6 @@
|
|||||||
#include "storage/edge_x_vertex.hpp"
|
#include "storage/edge_x_vertex.hpp"
|
||||||
#include "storage/indexes/impl/nonunique_unordered_index.cpp"
|
#include "storage/indexes/impl/nonunique_unordered_index.cpp"
|
||||||
#include "storage/model/properties/properties.cpp"
|
#include "storage/model/properties/properties.cpp"
|
||||||
// #include "storage/record_accessor.cpp"
|
|
||||||
// #include "storage/vertex_accessor.cpp"
|
|
||||||
#include "utils/command_line/arguments.hpp"
|
#include "utils/command_line/arguments.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
FROM ubuntu:16.04
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y clang libssl-dev \
|
|
||||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
|
||||||
|
|
||||||
RUN mkdir -p /libs
|
|
||||||
|
|
||||||
ENV BINARY_NAME memgraph_414_dba2610_dev_debug
|
|
||||||
|
|
||||||
COPY barrier_$BINARY_NAME /memgraph
|
|
||||||
COPY libs/fmt /libs/fmt
|
|
||||||
|
|
||||||
WORKDIR /memgraph
|
|
||||||
|
|
||||||
CMD ./$BINARY_NAME
|
|
@ -1,54 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
binary_name=$1
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
release_folder="barrier_$binary_name"
|
|
||||||
release_path="release/$release_folder"
|
|
||||||
compile_template_path="template/barrier_template_code_cpu.cpp"
|
|
||||||
|
|
||||||
mkdir -p $release_path/compiled/cpu
|
|
||||||
|
|
||||||
mkdir -p $release_path/include/barrier
|
|
||||||
mkdir -p $release_path/include/query/strip
|
|
||||||
mkdir -p $release_path/include/query/exception
|
|
||||||
mkdir -p $release_path/include/io/network
|
|
||||||
mkdir -p $release_path/include/logging
|
|
||||||
mkdir -p $release_path/include/mvcc
|
|
||||||
mkdir -p $release_path/include/storage/indexes
|
|
||||||
mkdir -p $release_path/include/storage/model/properties/traversers
|
|
||||||
mkdir -p $release_path/include/storage/model/properties/utils
|
|
||||||
mkdir -p $release_path/include/utils/datetime
|
|
||||||
mkdir -p $release_path/include/utils/exceptions
|
|
||||||
mkdir -p $release_path/include/utils/iterator
|
|
||||||
mkdir -p $release_path/include/utils/memory
|
|
||||||
mkdir -p $release_path/include/utils/numerics
|
|
||||||
|
|
||||||
mkdir -p $release_path/template
|
|
||||||
|
|
||||||
# COPY
|
|
||||||
# dressipi query
|
|
||||||
# TODO: for loop
|
|
||||||
# hardcoded_queries="135757557963690525.cpp"
|
|
||||||
# for query in $hardcoded_queries
|
|
||||||
# do
|
|
||||||
# cp build/compiled/cpu/hardcode/$query $release_path/compiled/cpu/hardcode/$query
|
|
||||||
# done
|
|
||||||
|
|
||||||
cp src/query_engine/$compile_template_path $release_path/$compile_template_path
|
|
||||||
|
|
||||||
paths="barrier/barrier.hpp barrier/common.hpp storage/model/properties/floating.hpp storage/model/properties/all.hpp storage/model/properties/bool.hpp storage/model/properties/traversers/consolewriter.hpp storage/model/properties/traversers/jsonwriter.hpp storage/model/properties/array.hpp storage/model/properties/property_family.hpp storage/model/properties/property.hpp storage/model/properties/properties.hpp storage/model/properties/integral.hpp storage/model/properties/double.hpp storage/model/properties/string.hpp storage/model/properties/utils/math_operations.hpp storage/model/properties/utils/unary_negation.hpp storage/model/properties/utils/modulo.hpp storage/model/properties/property_holder.hpp storage/model/properties/float.hpp storage/model/properties/null.hpp storage/model/properties/flags.hpp storage/model/properties/int32.hpp storage/model/properties/number.hpp storage/model/properties/int64.hpp logging/default.hpp logging/log.hpp logging/logger.hpp logging/levels.hpp io/network/addrinfo.hpp io/network/network_error.hpp io/network/socket.hpp mvcc/id.hpp utils/exceptions/basic_exception.hpp utils/border.hpp utils/total_ordering.hpp utils/auto_scope.hpp utils/crtp.hpp utils/order.hpp utils/likely.hpp utils/option.hpp utils/option_ptr.hpp utils/memory/block_allocator.hpp utils/memory/stack_allocator.hpp utils/iterator/query.hpp utils/iterator/composable.hpp utils/iterator/for_all.hpp utils/iterator/range_iterator.hpp utils/iterator/limited_map.hpp utils/iterator/iterator_accessor.hpp utils/iterator/count.hpp utils/iterator/iterator_base.hpp utils/iterator/filter.hpp utils/iterator/inspect.hpp utils/iterator/accessor.hpp utils/iterator/map.hpp utils/iterator/virtual_iter.hpp utils/iterator/flat_map.hpp utils/iterator/combined.hpp utils/iterator/lambda_iterator.hpp utils/iterator/iterator.hpp utils/array_store.hpp utils/void.hpp storage/indexes/index_definition.hpp utils/stacktrace.hpp utils/datetime/datetime_error.hpp utils/datetime/timestamp.hpp utils/reference_wrapper.hpp utils/underlying_cast.hpp utils/numerics/saturate.hpp query/i_plan_cpu.hpp query/property_util.hpp query/strip/stripped.hpp query/exception/cpp_code_generator.hpp query/exception/decoder_exception.hpp query/exception/out_of_memory.hpp query/exception/plan_compilation.hpp query/exception/plan_execution.hpp query/exception/query_engine.hpp"
|
|
||||||
|
|
||||||
for path in $paths
|
|
||||||
do
|
|
||||||
cp include/$path $release_path/include/$path
|
|
||||||
done
|
|
||||||
|
|
||||||
cp config/memgraph.yaml $release_path/config.yaml
|
|
||||||
|
|
||||||
cp build/$binary_name $release_path/$binary_name
|
|
||||||
cp build/libmemgraph_pic.a $release_path/libmemgraph_pic.a
|
|
||||||
cp build/libbarrier_pic.a $release_path/libbarrier_pic.a
|
|
||||||
|
|
||||||
echo "DONE"
|
|
@ -1,766 +0,0 @@
|
|||||||
#include "barrier/trans.hpp"
|
|
||||||
|
|
||||||
// ************************* Implementations
|
|
||||||
// This file should contain all implementations of methods from barrier classes
|
|
||||||
// defined in barrier.hpp.
|
|
||||||
// Implementations should follow the form:
|
|
||||||
// border_return_type border_class::method_name(arguments){
|
|
||||||
// return
|
|
||||||
// CALL(method_name(trans(arguments)))
|
|
||||||
// or
|
|
||||||
// HALF_CALL(method_name(trans(arguments)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// **************************** HELPER DEFINES *******************************//
|
|
||||||
// returns transformed this pointer
|
|
||||||
#define THIS (trans(this))
|
|
||||||
// In border class performs call x on original class.
|
|
||||||
#define HALF_CALL(x) (THIS->x)
|
|
||||||
// In border class performs call x on original class and produces transformed
|
|
||||||
// output.
|
|
||||||
#define CALL(x) trans(HALF_CALL(x))
|
|
||||||
|
|
||||||
// Creates destructor for border type x which is original type y.
|
|
||||||
#define DESTRUCTOR(x, y) \
|
|
||||||
x::~x() { HALF_CALL(~y()); }
|
|
||||||
|
|
||||||
// Creates copy constructor for mutable ref to border class x which is original
|
|
||||||
// class y.
|
|
||||||
#define COPY_CONSTRUCTOR_MUT(x, y) \
|
|
||||||
x::x(x &other) : Sized(y(trans(other))) {}
|
|
||||||
|
|
||||||
// Creates copy constructor for const ref to border class x which is original
|
|
||||||
// class y.
|
|
||||||
#define COPY_CONSTRUCTOR(x, y) \
|
|
||||||
x::x(const x &other) : Sized(y(trans(other))) {}
|
|
||||||
|
|
||||||
// Creates move constructor for mutable border type x.
|
|
||||||
#define MOVE_CONSTRUCTOR(x) \
|
|
||||||
x::x(x &&other) : Sized(trans(std::move(other))) {}
|
|
||||||
|
|
||||||
// Creates move constructor for const border type x.
|
|
||||||
#define MOVE_CONST_CONSTRUCTOR(x) \
|
|
||||||
x::x(x const &&other) : Sized(trans(std::move(other))) {}
|
|
||||||
|
|
||||||
// Creates copy operator for border type x.
|
|
||||||
#define COPY_OPERATOR(x) \
|
|
||||||
x &x::operator=(const x &other) \
|
|
||||||
{ \
|
|
||||||
HALF_CALL(operator=(trans(other))); \
|
|
||||||
return *this; \
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates move operator for border type x.
|
|
||||||
#define MOVE_OPERATOR(x) \
|
|
||||||
x &x::operator=(x &&other) \
|
|
||||||
{ \
|
|
||||||
HALF_CALL(operator=(trans(std::move(other)))); \
|
|
||||||
return *this; \
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace barrier
|
|
||||||
{
|
|
||||||
|
|
||||||
// ***************** Label
|
|
||||||
VertexIndex<std::nullptr_t> &Label::index() const { return CALL(index()); }
|
|
||||||
|
|
||||||
// **************** EdgeType
|
|
||||||
bool operator<(const EdgeType &lhs, const EdgeType &rhs)
|
|
||||||
{
|
|
||||||
return trans(lhs) < trans(rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const EdgeType &lhs, const EdgeType &rhs)
|
|
||||||
{
|
|
||||||
return trans(lhs) == trans(rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgeIndex<std::nullptr_t> &EdgeType::index() const { return CALL(index()); }
|
|
||||||
|
|
||||||
// **************** VertexIndex
|
|
||||||
template <class K>
|
|
||||||
VertexIterator VertexIndex<K>::for_range(DbAccessor &t, Border<K> from,
|
|
||||||
Border<K> to)
|
|
||||||
{
|
|
||||||
return CALL(for_range(trans(t), std::move(from), std::move(to)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class K>
|
|
||||||
IndexType VertexIndex<K>::type()
|
|
||||||
{
|
|
||||||
return HALF_CALL(type());
|
|
||||||
}
|
|
||||||
|
|
||||||
// INSTANCES OF VERTEX INDEX
|
|
||||||
template class VertexIndex<std::nullptr_t>;
|
|
||||||
|
|
||||||
// **************** EdgeIndex
|
|
||||||
template <class K>
|
|
||||||
EdgeIterator EdgeIndex<K>::for_range(DbAccessor &t, Border<K> from,
|
|
||||||
Border<K> to)
|
|
||||||
{
|
|
||||||
return CALL(for_range(trans(t), std::move(from), std::move(to)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class K>
|
|
||||||
IndexType EdgeIndex<K>::type()
|
|
||||||
{
|
|
||||||
return HALF_CALL(type());
|
|
||||||
}
|
|
||||||
|
|
||||||
// INSTANCES OF EDGE INDEX
|
|
||||||
template class EdgeIndex<std::nullptr_t>;
|
|
||||||
|
|
||||||
// ************************* DbAccessor
|
|
||||||
DESTRUCTOR(DbAccessor, DbAccessor);
|
|
||||||
|
|
||||||
VertexAccessIterator DbAccessor::vertex_access()
|
|
||||||
{
|
|
||||||
return CALL(vertex_access());
|
|
||||||
}
|
|
||||||
|
|
||||||
Option<const VertexAccessor> DbAccessor::vertex_find(const Id &id)
|
|
||||||
{
|
|
||||||
return HALF_CALL(vertex_find(id)).map<const VertexAccessor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
VertexAccessor DbAccessor::vertex_insert() { return CALL(vertex_insert()); }
|
|
||||||
|
|
||||||
EdgeAccessIterator DbAccessor::edge_access() { return CALL(edge_access()); }
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> DbAccessor::edge_find(const Id &id)
|
|
||||||
{
|
|
||||||
return HALF_CALL(edge_find(id)).map<const EdgeAccessor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgeAccessor DbAccessor::edge_insert(VertexAccessor const &from,
|
|
||||||
VertexAccessor const &to)
|
|
||||||
{
|
|
||||||
return CALL(edge_insert(trans(from), trans(to)));
|
|
||||||
}
|
|
||||||
|
|
||||||
const Label &DbAccessor::label_find_or_create(const char *name)
|
|
||||||
{
|
|
||||||
return CALL(label_find_or_create(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DbAccessor::label_contains(const char *name)
|
|
||||||
{
|
|
||||||
return HALF_CALL(label_contains(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
const EdgeType &DbAccessor::type_find_or_create(const char *name)
|
|
||||||
{
|
|
||||||
return CALL(type_find_or_create(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DbAccessor::type_contains(const char *name)
|
|
||||||
{
|
|
||||||
return HALF_CALL(type_contains(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
VertexPropertyFamily &
|
|
||||||
DbAccessor::vertex_property_family_get(const std::string &name)
|
|
||||||
{
|
|
||||||
return CALL(vertex_property_family_get(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgePropertyFamily &
|
|
||||||
DbAccessor::edge_property_family_get(const std::string &name)
|
|
||||||
{
|
|
||||||
return CALL(edge_property_family_get(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
VertexPropertyKey DbAccessor::vertex_property_key(const std::string &name,
|
|
||||||
Type type)
|
|
||||||
{
|
|
||||||
return CALL(vertex_property_key(name, type));
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgePropertyKey DbAccessor::edge_property_key(const std::string &name,
|
|
||||||
Type type)
|
|
||||||
{
|
|
||||||
return CALL(edge_property_key(name, type));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
VertexPropertyType<T> DbAccessor::vertex_property_key(const std::string &name)
|
|
||||||
{
|
|
||||||
return CALL(vertex_property_key<T>(name));
|
|
||||||
}
|
|
||||||
#define DbAccessor_vertex_property_key(x) \
|
|
||||||
template VertexPropertyType<x> DbAccessor::vertex_property_key<x>( \
|
|
||||||
const std::string &name);
|
|
||||||
INSTANTIATE_FOR_PROPERTY(DbAccessor_vertex_property_key)
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
EdgePropertyType<T> DbAccessor::edge_property_key(const std::string &name)
|
|
||||||
{
|
|
||||||
return CALL(edge_property_key<T>(name));
|
|
||||||
}
|
|
||||||
#define DbAccessor_edge_property_key(x) \
|
|
||||||
template EdgePropertyType<x> DbAccessor::edge_property_key<x>( \
|
|
||||||
const std::string &name);
|
|
||||||
INSTANTIATE_FOR_PROPERTY(DbAccessor_edge_property_key)
|
|
||||||
|
|
||||||
bool DbAccessor::commit() { return HALF_CALL(commit()); }
|
|
||||||
void DbAccessor::abort() { HALF_CALL(abort()); }
|
|
||||||
|
|
||||||
// ************************** VertexAccessor
|
|
||||||
DUP(VertexAccessor, COPY_CONSTRUCTOR);
|
|
||||||
DUP(VertexAccessor, COPY_CONSTRUCTOR_MUT);
|
|
||||||
MOVE_CONSTRUCTOR(VertexAccessor);
|
|
||||||
MOVE_CONST_CONSTRUCTOR(VertexAccessor);
|
|
||||||
DESTRUCTOR(VertexAccessor, VertexAccessor);
|
|
||||||
COPY_OPERATOR(VertexAccessor);
|
|
||||||
MOVE_OPERATOR(VertexAccessor);
|
|
||||||
|
|
||||||
bool VertexAccessor::isolated() const { return HALF_CALL(isolated()); }
|
|
||||||
|
|
||||||
size_t VertexAccessor::out_degree() const { return HALF_CALL(out_degree()); }
|
|
||||||
|
|
||||||
size_t VertexAccessor::in_degree() const { return HALF_CALL(in_degree()); }
|
|
||||||
|
|
||||||
size_t VertexAccessor::degree() const { return HALF_CALL(degree()); }
|
|
||||||
|
|
||||||
bool VertexAccessor::add_label(const Label &label)
|
|
||||||
{
|
|
||||||
return HALF_CALL(add_label(trans(label)));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VertexAccessor::remove_label(const Label &label)
|
|
||||||
{
|
|
||||||
return HALF_CALL(remove_label(trans(label)));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VertexAccessor::has_label(const Label &label) const
|
|
||||||
{
|
|
||||||
return HALF_CALL(has_label(trans(label)));
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<label_ref_t> &VertexAccessor::labels() const
|
|
||||||
{
|
|
||||||
return CALL(labels());
|
|
||||||
}
|
|
||||||
|
|
||||||
OutEdgesIterator VertexAccessor::out() const { return CALL(out()); }
|
|
||||||
|
|
||||||
InEdgesIterator VertexAccessor::in() const { return CALL(in()); }
|
|
||||||
|
|
||||||
bool VertexAccessor::in_contains(VertexAccessor const &other) const
|
|
||||||
{
|
|
||||||
return HALF_CALL(in_contains(trans(other)));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VertexAccessor::empty() const { return HALF_CALL(empty()); }
|
|
||||||
|
|
||||||
bool VertexAccessor::fill() const { return HALF_CALL(fill()); }
|
|
||||||
|
|
||||||
const Id &VertexAccessor::id() const { return HALF_CALL(id()); }
|
|
||||||
|
|
||||||
VertexAccessor VertexAccessor::update() const { return CALL(update()); }
|
|
||||||
|
|
||||||
void VertexAccessor::remove() const { HALF_CALL(remove()); }
|
|
||||||
|
|
||||||
const VertexStoredProperty &VertexAccessor::at(VertexPropertyFamily &key) const
|
|
||||||
{
|
|
||||||
return CALL(at(trans(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
const VertexStoredProperty &VertexAccessor::at(VertexPropertyKey &key) const
|
|
||||||
{
|
|
||||||
return CALL(at(trans(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// template <class TG>
|
|
||||||
// bool VertexAccessor::contains(property_key<TG> &key) const
|
|
||||||
// {
|
|
||||||
// return HALF_CALL(contains<TG>(key));
|
|
||||||
// }
|
|
||||||
|
|
||||||
template <class V>
|
|
||||||
OptionPtr<const V> VertexAccessor::at(VertexPropertyType<V> &key) const
|
|
||||||
{
|
|
||||||
return HALF_CALL(at(trans<V>(key)));
|
|
||||||
}
|
|
||||||
#define VertexAccessor_at(x) \
|
|
||||||
template OptionPtr<const x> VertexAccessor::at(VertexPropertyType<x> &key) \
|
|
||||||
const;
|
|
||||||
INSTANTIATE_FOR_PROPERTY(VertexAccessor_at);
|
|
||||||
|
|
||||||
void VertexAccessor::set(VertexPropertyKey &key, Property &&value)
|
|
||||||
{
|
|
||||||
HALF_CALL(set(trans(key), std::move(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void VertexAccessor::clear(VertexPropertyKey &key)
|
|
||||||
{
|
|
||||||
HALF_CALL(clear(trans(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void VertexAccessor::clear(VertexPropertyFamily &key)
|
|
||||||
{
|
|
||||||
HALF_CALL(clear(trans(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: I am not quite sure if this method will have any use
|
|
||||||
template <class Handler>
|
|
||||||
void VertexAccessor::accept(Handler &handler) const
|
|
||||||
{
|
|
||||||
HALF_CALL(accept(handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
VertexAccessor::operator bool() const { return HALF_CALL(operator bool()); }
|
|
||||||
|
|
||||||
bool operator==(const VertexAccessor &a, const VertexAccessor &b)
|
|
||||||
{
|
|
||||||
return trans(a) == trans(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const VertexAccessor &a, const VertexAccessor &b)
|
|
||||||
{
|
|
||||||
return trans(a) != trans(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ************************** EdgeAccessor
|
|
||||||
DUP(EdgeAccessor, COPY_CONSTRUCTOR);
|
|
||||||
DUP(EdgeAccessor, COPY_CONSTRUCTOR_MUT);
|
|
||||||
MOVE_CONSTRUCTOR(EdgeAccessor);
|
|
||||||
MOVE_CONST_CONSTRUCTOR(EdgeAccessor);
|
|
||||||
DESTRUCTOR(EdgeAccessor, EdgeAccessor);
|
|
||||||
COPY_OPERATOR(EdgeAccessor);
|
|
||||||
MOVE_OPERATOR(EdgeAccessor);
|
|
||||||
|
|
||||||
void EdgeAccessor::edge_type(const EdgeType &edge_type)
|
|
||||||
{
|
|
||||||
HALF_CALL(edge_type(trans(edge_type)));
|
|
||||||
}
|
|
||||||
|
|
||||||
const EdgeType &EdgeAccessor::edge_type() const { return CALL(edge_type()); }
|
|
||||||
|
|
||||||
const VertexAccessor EdgeAccessor::from() const { return CALL(from()); }
|
|
||||||
|
|
||||||
const VertexAccessor EdgeAccessor::to() const { return CALL(to()); }
|
|
||||||
|
|
||||||
bool EdgeAccessor::empty() const { return HALF_CALL(empty()); }
|
|
||||||
|
|
||||||
bool EdgeAccessor::fill() const { return HALF_CALL(fill()); }
|
|
||||||
|
|
||||||
const Id &EdgeAccessor::id() const { return HALF_CALL(id()); }
|
|
||||||
|
|
||||||
EdgeAccessor EdgeAccessor::update() const { return CALL(update()); }
|
|
||||||
|
|
||||||
void EdgeAccessor::remove() const { HALF_CALL(remove()); }
|
|
||||||
|
|
||||||
const EdgeStoredProperty &EdgeAccessor::at(EdgePropertyFamily &key) const
|
|
||||||
{
|
|
||||||
return CALL(at(trans(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
const EdgeStoredProperty &EdgeAccessor::at(EdgePropertyKey &key) const
|
|
||||||
{
|
|
||||||
return CALL(at(trans(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class V>
|
|
||||||
OptionPtr<const V> EdgeAccessor::at(EdgePropertyType<V> &key) const
|
|
||||||
{
|
|
||||||
return HALF_CALL(at(trans<V>(key)));
|
|
||||||
}
|
|
||||||
#define EdgeAccessor_at(x) \
|
|
||||||
template OptionPtr<const x> EdgeAccessor::at(EdgePropertyType<x> &key) \
|
|
||||||
const;
|
|
||||||
INSTANTIATE_FOR_PROPERTY(EdgeAccessor_at);
|
|
||||||
|
|
||||||
void EdgeAccessor::set(EdgePropertyKey &key, Property &&value)
|
|
||||||
{
|
|
||||||
HALF_CALL(set(trans(key), std::move(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EdgeAccessor::clear(EdgePropertyKey &key) { HALF_CALL(clear(trans(key))); }
|
|
||||||
|
|
||||||
void EdgeAccessor::clear(EdgePropertyFamily &key)
|
|
||||||
{
|
|
||||||
HALF_CALL(clear(trans(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: I am not quite sure if this method will have any use
|
|
||||||
template <class Handler>
|
|
||||||
void EdgeAccessor::accept(Handler &handler) const
|
|
||||||
{
|
|
||||||
HALF_CALL(accept(handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgeAccessor::operator bool() const { return HALF_CALL(operator bool()); }
|
|
||||||
|
|
||||||
bool operator==(const EdgeAccessor &a, const EdgeAccessor &b)
|
|
||||||
{
|
|
||||||
return trans(a) == trans(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const EdgeAccessor &a, const EdgeAccessor &b)
|
|
||||||
{
|
|
||||||
return trans(a) != trans(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ************************* VertexIterator
|
|
||||||
DESTRUCTOR(VertexIterator, Virtual);
|
|
||||||
|
|
||||||
Option<const VertexAccessor> VertexIterator::next()
|
|
||||||
{
|
|
||||||
return HALF_CALL(next()).map<const VertexAccessor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
Count VertexIterator::count() { return HALF_CALL(count()); }
|
|
||||||
|
|
||||||
// ************************* EdgeIterator
|
|
||||||
DESTRUCTOR(EdgeIterator, Virtual);
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> EdgeIterator::next()
|
|
||||||
{
|
|
||||||
return HALF_CALL(next()).map<const EdgeAccessor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
Count EdgeIterator::count() { return HALF_CALL(count()); }
|
|
||||||
|
|
||||||
// ************************* OutEdgesIterator
|
|
||||||
DESTRUCTOR(OutEdgesIterator, out_edge_iterator_t);
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> OutEdgesIterator::next()
|
|
||||||
{
|
|
||||||
return HALF_CALL(next()).map<const EdgeAccessor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
Count OutEdgesIterator::count() { return HALF_CALL(count()); }
|
|
||||||
|
|
||||||
// ************************* InEdgesIterator
|
|
||||||
DESTRUCTOR(InEdgesIterator, in_edge_iterator_t);
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> InEdgesIterator::next()
|
|
||||||
{
|
|
||||||
return HALF_CALL(next()).map<const EdgeAccessor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
Count InEdgesIterator::count() { return HALF_CALL(count()); }
|
|
||||||
|
|
||||||
// ************************* VertexAccessIterator
|
|
||||||
DESTRUCTOR(VertexAccessIterator, vertex_access_iterator_t);
|
|
||||||
|
|
||||||
Option<const VertexAccessor> VertexAccessIterator::next()
|
|
||||||
{
|
|
||||||
return HALF_CALL(next()).map<const VertexAccessor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
Count VertexAccessIterator::count() { return HALF_CALL(count()); }
|
|
||||||
|
|
||||||
// ************************* EdgeAccessIterator
|
|
||||||
DESTRUCTOR(EdgeAccessIterator, edge_access_iterator_t);
|
|
||||||
|
|
||||||
Option<const EdgeAccessor> EdgeAccessIterator::next()
|
|
||||||
{
|
|
||||||
return HALF_CALL(next()).map<const EdgeAccessor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
Count EdgeAccessIterator::count() { return HALF_CALL(count()); }
|
|
||||||
|
|
||||||
// ************************* VertexPropertyKey
|
|
||||||
DESTRUCTOR(VertexPropertyKey, PropertyFamilyKey);
|
|
||||||
|
|
||||||
Type VertexPropertyKey::get_type() const { return HALF_CALL(get_type()); }
|
|
||||||
|
|
||||||
// ************************* EdgePropertyKey
|
|
||||||
DESTRUCTOR(EdgePropertyKey, PropertyFamilyKey);
|
|
||||||
|
|
||||||
Type EdgePropertyKey::get_type() const { return HALF_CALL(get_type()); }
|
|
||||||
|
|
||||||
// ************************* VertexPropertyType
|
|
||||||
#define VERTEX_PROPERTY_TYPE(x) template class VertexPropertyType<x>;
|
|
||||||
INSTANTIATE_FOR_PROPERTY(VERTEX_PROPERTY_TYPE)
|
|
||||||
|
|
||||||
// ************************* VertexPropertyFamily
|
|
||||||
OptionPtr<VertexIndex<std::nullptr_t>> VertexPropertyFamily::index()
|
|
||||||
{
|
|
||||||
OptionPtr<IndexBase<TypeGroupVertex, std::nullptr_t>> ret =
|
|
||||||
THIS->index.get_read();
|
|
||||||
if (ret.is_present()) {
|
|
||||||
return OptionPtr<VertexIndex<std::nullptr_t>>(&trans(*ret.get()));
|
|
||||||
} else {
|
|
||||||
return OptionPtr<VertexIndex<std::nullptr_t>>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ************************* VertexPropertyFamily
|
|
||||||
OptionPtr<EdgeIndex<std::nullptr_t>> EdgePropertyFamily::index()
|
|
||||||
{
|
|
||||||
OptionPtr<IndexBase<TypeGroupEdge, std::nullptr_t>> ret =
|
|
||||||
THIS->index.get_read();
|
|
||||||
if (ret.is_present()) {
|
|
||||||
return OptionPtr<EdgeIndex<std::nullptr_t>>(&trans(*ret.get()));
|
|
||||||
} else {
|
|
||||||
return OptionPtr<EdgeIndex<std::nullptr_t>>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ************************* BOLT SERIALIZER
|
|
||||||
template <class Stream>
|
|
||||||
RecordStream<Stream>::~RecordStream()
|
|
||||||
{
|
|
||||||
// TODO: solve this
|
|
||||||
// THIS->~RecordStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const VertexAccessor &vertex)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(trans(vertex)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const EdgeAccessor &edge)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(trans(edge)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const VertexStoredProperty &prop)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(trans(prop)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const EdgeStoredProperty &prop)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(trans(prop)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const Null &v)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const Bool &prop)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(prop));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const Float &prop)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(prop));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const Double &prop)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(prop));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const Int32 &prop)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(prop));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const Int64 &prop)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(prop));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const String &value)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const ArrayBool &arr)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(arr));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const ArrayInt32 &arr)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(arr));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const ArrayInt64 &arr)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(arr));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const ArrayFloat &arr)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(arr));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const ArrayDouble &arr)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(arr));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write(const ArrayString &arr)
|
|
||||||
{
|
|
||||||
HALF_CALL(write(arr));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_empty_fields()
|
|
||||||
{
|
|
||||||
HALF_CALL(write_empty_fields());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_success()
|
|
||||||
{
|
|
||||||
HALF_CALL(write_success());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_success_empty()
|
|
||||||
{
|
|
||||||
HALF_CALL(write_success_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_ignored()
|
|
||||||
{
|
|
||||||
HALF_CALL(write_ignored());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_fields(const std::vector<std::string> &fields)
|
|
||||||
{
|
|
||||||
HALF_CALL(write_fields(fields));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_field(const std::string &field)
|
|
||||||
{
|
|
||||||
HALF_CALL(write_field(field));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_list_header(size_t size)
|
|
||||||
{
|
|
||||||
HALF_CALL(write_list_header(size));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_record()
|
|
||||||
{
|
|
||||||
HALF_CALL(write_record());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_meta(const std::string &type)
|
|
||||||
{
|
|
||||||
HALF_CALL(write_meta(type));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::write_failure(
|
|
||||||
const std::map<std::string, std::string> &data)
|
|
||||||
{
|
|
||||||
HALF_CALL(write_failure(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::send()
|
|
||||||
{
|
|
||||||
HALF_CALL(send());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Stream>
|
|
||||||
void RecordStream<Stream>::chunk()
|
|
||||||
{
|
|
||||||
HALF_CALL(chunk());
|
|
||||||
}
|
|
||||||
|
|
||||||
template class RecordStream<io::Socket>;
|
|
||||||
}
|
|
||||||
|
|
||||||
// **************************** ERROR EXAMPLES ****************************** //
|
|
||||||
// **************************** COMPILE TIME
|
|
||||||
/*
|
|
||||||
### error:
|
|
||||||
../libmemgraph.a(barrier.cpp.o): In function `Option<barrier::VertexAccessor
|
|
||||||
const> Option<VertexAccessor const>::map<barrier::VertexAccessor const>()':
|
|
||||||
/home/ktf/Workspace/memgraph/include/utils/option.hpp:111: undefined reference
|
|
||||||
to `barrier::VertexAccessor::VertexAccessor<VertexAccessor const>(VertexAccessor
|
|
||||||
const&&)'
|
|
||||||
|
|
||||||
# description:
|
|
||||||
Constructor VertexAccessor<::VertexAccessor const>(::VertexAccessor const&&)
|
|
||||||
isn't written.
|
|
||||||
|
|
||||||
|
|
||||||
### error:
|
|
||||||
../libmemgraph.a(barrier.cpp.o): In function `barrier::EdgeAccessor::from()
|
|
||||||
const':
|
|
||||||
/home/ktf/Workspace/memgraph/src/barrier/barrier.cpp:501: undefined reference to
|
|
||||||
`barrier::VertexAccessor::VertexAccessor<barrier::VertexAccessor
|
|
||||||
const>(barrier::VertexAccessor const&&)'
|
|
||||||
|
|
||||||
# description:
|
|
||||||
Move constructor VertexAccessor<VertexAccessor const>(VertexAccessor const&&)
|
|
||||||
isn't defined.
|
|
||||||
|
|
||||||
|
|
||||||
### error:
|
|
||||||
/home/ktf/Workspace/memgraph/src/barrier/barrier.cpp:282:12: error: call to
|
|
||||||
'trans' is ambiguous
|
|
||||||
return CALL(at(trans(key)));
|
|
||||||
^~~~~~~~~~~~~~~~~~~~
|
|
||||||
/home/ktf/Workspace/memgraph/src/barrier/barrier.cpp:18:17: note: expanded from
|
|
||||||
macro 'CALL'
|
|
||||||
#define CALL(x) trans(HALF_CALL(x))
|
|
||||||
^~~~~
|
|
||||||
/home/ktf/Workspace/memgraph/include/barrier/trans.hpp:208:21: note: candidate
|
|
||||||
function
|
|
||||||
DUP(VertexAccessor, TRANSFORM_VALUE);
|
|
||||||
^
|
|
||||||
/home/ktf/Workspace/memgraph/include/barrier/trans.hpp:169:21: note: candidate
|
|
||||||
function
|
|
||||||
DUP(VertexAccessor, TRANSFORM_REF);
|
|
||||||
^
|
|
||||||
/home/ktf/Workspace/memgraph/include/barrier/trans.hpp:170:19: note: candidate
|
|
||||||
function
|
|
||||||
DUP(EdgeAccessor, TRANSFORM_REF);
|
|
||||||
^
|
|
||||||
/home/ktf/Workspace/memgraph/include/barrier/trans.hpp:174:1: note: candidate
|
|
||||||
function
|
|
||||||
TRANSFORM_REF(VertexPropertyKey,
|
|
||||||
^
|
|
||||||
/home/ktf/Workspace/memgraph/include/barrier/trans.hpp:25:14: note: expanded
|
|
||||||
from macro 'TRANSFORM_REF'
|
|
||||||
y const &trans(x const &l) { return ref_as<y const>(l); } \
|
|
||||||
^
|
|
||||||
/home/ktf/Workspace/memgraph/include/barrier/trans.hpp:176:1: note: candidate
|
|
||||||
function
|
|
||||||
TRANSFORM_REF(EdgePropertyKey,
|
|
||||||
^
|
|
||||||
/home/ktf/Workspace/memgraph/include/barrier/trans.hpp:25:14: note: expanded
|
|
||||||
from macro 'TRANSFORM_REF'
|
|
||||||
y const &trans(x const &l) { return ref_as<y const>(l); } \
|
|
||||||
^
|
|
||||||
/home/ktf/Workspace/memgraph/include/barrier/trans.hpp:182:1: note: candidate
|
|
||||||
function
|
|
||||||
TRANSFORM_REF(VertexIterator, ::iter::Virtual<const ::VertexAccessor>);
|
|
||||||
^
|
|
||||||
/home/ktf/Workspace/memgraph/include/barrier/trans.hpp:23:14: note: expanded
|
|
||||||
from macro 'TRANSFORM_REF'
|
|
||||||
x const &trans(y const &l) { return ref_as<x const>(l); } \
|
|
||||||
...
|
|
||||||
|
|
||||||
# description:
|
|
||||||
There is no valid transformation for types on which trans is called.
|
|
||||||
|
|
||||||
*/
|
|
@ -3,12 +3,12 @@
|
|||||||
#include "utils/iterator/iterator.hpp"
|
#include "utils/iterator/iterator.hpp"
|
||||||
|
|
||||||
DbAccessor::DbAccessor(Db &db)
|
DbAccessor::DbAccessor(Db &db)
|
||||||
: db_transaction(DbTransaction(db, db.tx_engine.begin()))
|
: db_transaction(std::move(DbTransaction(db, db.tx_engine.begin())))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DbAccessor::DbAccessor(Db &db, tx::Transaction &t)
|
DbAccessor::DbAccessor(Db &db, tx::Transaction &t)
|
||||||
: db_transaction(DbTransaction(db, t))
|
: db_transaction(std::move(DbTransaction(db, t)))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +105,11 @@ DbAccessor::edge_property_key(const std::string &name, Type type)
|
|||||||
return edge_property_family_get(name).get(type).family_key();
|
return edge_property_family_get(name).get(type).family_key();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DbAccessor::update_indexes()
|
||||||
|
{
|
||||||
|
return db_transaction.update_indexes();
|
||||||
|
}
|
||||||
|
|
||||||
// TRANSACTION METHODS
|
// TRANSACTION METHODS
|
||||||
bool DbAccessor::commit()
|
bool DbAccessor::commit()
|
||||||
{
|
{
|
||||||
|
@ -9,18 +9,24 @@
|
|||||||
#include "storage/vertex.hpp"
|
#include "storage/vertex.hpp"
|
||||||
|
|
||||||
#define TRY(x) \
|
#define TRY(x) \
|
||||||
if (!x) { \
|
if (!x) \
|
||||||
|
{ \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
DbTransaction::DbTransaction(Db &db) : db(db), trans(db.tx_engine.begin()) {}
|
DbTransaction::DbTransaction(Db &db)
|
||||||
|
: Loggable("DbTransaction"), db(db), trans(db.tx_engine.begin())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Cleaning for version lists
|
// Cleaning for version lists
|
||||||
template <class A>
|
template <class A>
|
||||||
void clean_version_lists(A &&acc, Id oldest_active)
|
void clean_version_lists(A &&acc, Id oldest_active)
|
||||||
{
|
{
|
||||||
for (auto &vlist : acc) {
|
for (auto &vlist : acc)
|
||||||
if (vlist.second.gc_deleted(oldest_active)) {
|
{
|
||||||
|
if (vlist.second.gc_deleted(oldest_active))
|
||||||
|
{
|
||||||
// TODO: Optimization, iterator with remove method.
|
// TODO: Optimization, iterator with remove method.
|
||||||
bool succ = acc.remove(vlist.first);
|
bool succ = acc.remove(vlist.first);
|
||||||
assert(succ); // There is other cleaner here
|
assert(succ); // There is other cleaner here
|
||||||
@ -48,8 +54,7 @@ void DbTransaction::clean_vertex_section()
|
|||||||
Id oldest_active = trans.oldest_active();
|
Id oldest_active = trans.oldest_active();
|
||||||
|
|
||||||
// Clean indexes
|
// Clean indexes
|
||||||
db.indexes().vertex_indexes(
|
db.indexes().vertex_indexes([&](auto &in) { in.clean(oldest_active); });
|
||||||
[&](auto &in) { in.clean(oldest_active); });
|
|
||||||
|
|
||||||
// Clean vertex list
|
// Clean vertex list
|
||||||
clean_version_lists(db.graph.vertices.access(), oldest_active);
|
clean_version_lists(db.graph.vertices.access(), oldest_active);
|
||||||
@ -57,36 +62,58 @@ void DbTransaction::clean_vertex_section()
|
|||||||
|
|
||||||
bool DbTransaction::update_indexes()
|
bool DbTransaction::update_indexes()
|
||||||
{
|
{
|
||||||
while (!index_updates.empty()) {
|
logger.debug("index_updates: {}, instance: {}, transaction: {}",
|
||||||
auto iu = index_updates.back();
|
index_updates.size(), static_cast<void *>(this), trans.id);
|
||||||
|
|
||||||
if (iu.tag == IndexUpdate::EDGE) {
|
while (!index_updates.empty())
|
||||||
auto e = iu.e;
|
{
|
||||||
|
auto index_update = index_updates.back();
|
||||||
|
|
||||||
|
if (index_update.tag == IndexUpdate::EDGE)
|
||||||
|
{
|
||||||
|
auto edge = index_update.e;
|
||||||
|
|
||||||
// TODO: This could be done in batch
|
// TODO: This could be done in batch
|
||||||
// NOTE: This assumes that type index is created with the database.
|
// NOTE: This assumes that type index is created with the database.
|
||||||
TRY(e.record->data.edge_type->index().insert(
|
TRY(edge.record->data.edge_type->index().insert(EdgeTypeIndexRecord(
|
||||||
EdgeTypeIndexRecord(std::nullptr_t(), e.record, e.vlist)));
|
std::nullptr_t(), edge.record, edge.vlist)));
|
||||||
|
|
||||||
TRY(db.indexes().update_property_indexes<TypeGroupEdge>(
|
TRY(db.indexes().update_property_indexes<TypeGroupEdge>(edge,
|
||||||
e, trans));
|
trans));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto vertex = index_update.v;
|
||||||
|
|
||||||
} else {
|
for (auto label : vertex.record->data.labels())
|
||||||
auto v = iu.v;
|
{
|
||||||
|
|
||||||
for (auto l : v.record->data.labels()) {
|
|
||||||
// TODO: This could be done in batch
|
// TODO: This could be done in batch
|
||||||
// NOTE: This assumes that label index is created with the
|
// NOTE: This assumes that label index is created with the
|
||||||
// database.
|
// database.
|
||||||
TRY(l.get().index().insert(
|
TRY(label.get().index().insert(LabelIndexRecord(
|
||||||
LabelIndexRecord(std::nullptr_t(), v.record, v.vlist)));
|
std::nullptr_t(), vertex.record, vertex.vlist)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TRY(db.indexes().update_property_indexes<TypeGroupVertex>(
|
TRY(db.indexes().update_property_indexes<TypeGroupVertex>(vertex,
|
||||||
v, trans));
|
trans));
|
||||||
}
|
}
|
||||||
|
|
||||||
index_updates.pop_back();
|
index_updates.pop_back();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class TG>
|
||||||
|
void DbTransaction::to_update_index(typename TG::vlist_t *vlist,
|
||||||
|
typename TG::record_t *record)
|
||||||
|
{
|
||||||
|
index_updates.emplace_back(make_index_update(vlist, record));
|
||||||
|
logger.debug("update_index, updates_no: {}, instance: {}, transaction: {}",
|
||||||
|
index_updates.size(), static_cast<void *>(this), trans.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
template void DbTransaction::to_update_index<TypeGroupVertex>(
|
||||||
|
TypeGroupVertex::vlist_t *vlist, TypeGroupVertex::record_t *record);
|
||||||
|
template void
|
||||||
|
DbTransaction::to_update_index<TypeGroupEdge>(TypeGroupEdge::vlist_t *vlist,
|
||||||
|
TypeGroupEdge::record_t *record);
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
#include "db.hpp"
|
|
||||||
|
|
||||||
class memsql : public db
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
void name() const override
|
|
||||||
{
|
|
||||||
cout << "MemSQL" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void type() const override
|
|
||||||
{
|
|
||||||
cout << "InMemory" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
~memsql() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
extern "C" db* produce()
|
|
||||||
{
|
|
||||||
return new memsql();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void destruct(db* p)
|
|
||||||
{
|
|
||||||
delete p;
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
#include "db.hpp"
|
|
||||||
|
|
||||||
class mysql : public db
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void name() const
|
|
||||||
{
|
|
||||||
cout << "MySQL" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void type() const
|
|
||||||
{
|
|
||||||
cout << "Relational" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
~mysql() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
extern "C" db* produce()
|
|
||||||
{
|
|
||||||
return new mysql();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void destruct(db* p)
|
|
||||||
{
|
|
||||||
delete p;
|
|
||||||
}
|
|
@ -8,28 +8,9 @@
|
|||||||
namespace logging
|
namespace logging
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// per object log source
|
||||||
std::unique_ptr<Log> log;
|
std::unique_ptr<Log> log;
|
||||||
|
|
||||||
std::unique_ptr<Log> debug_log = std::make_unique<SyncLog>();
|
|
||||||
|
|
||||||
Logger init_debug_logger()
|
|
||||||
{
|
|
||||||
debug_log->pipe(std::make_unique<Stdout>());
|
|
||||||
return debug_log->logger("DEBUG");
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger debug_logger = init_debug_logger();
|
|
||||||
|
|
||||||
std::unique_ptr<Log> info_log = std::make_unique<SyncLog>();
|
|
||||||
|
|
||||||
Logger init_info_logger()
|
|
||||||
{
|
|
||||||
info_log->pipe(std::make_unique<Stdout>());
|
|
||||||
return info_log->logger("INFO");
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger info_logger = init_info_logger();
|
|
||||||
|
|
||||||
void init_async()
|
void init_async()
|
||||||
{
|
{
|
||||||
log = std::make_unique<AsyncLog>();
|
log = std::make_unique<AsyncLog>();
|
||||||
@ -40,4 +21,26 @@ void init_sync()
|
|||||||
log = std::make_unique<SyncLog>();
|
log = std::make_unique<SyncLog>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "global" DEBUG logger
|
||||||
|
std::unique_ptr<Log> debug_log = std::make_unique<SyncLog>();
|
||||||
|
|
||||||
|
Logger init_debug_logger()
|
||||||
|
{
|
||||||
|
debug_log->pipe(std::make_unique<Stdout>());
|
||||||
|
return debug_log->logger("DEBUG");
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger debug_logger = init_debug_logger();
|
||||||
|
|
||||||
|
// "global" INFO logger
|
||||||
|
std::unique_ptr<Log> info_log = std::make_unique<SyncLog>();
|
||||||
|
|
||||||
|
Logger init_info_logger()
|
||||||
|
{
|
||||||
|
info_log->pipe(std::make_unique<Stdout>());
|
||||||
|
return info_log->logger("INFO");
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger info_logger = init_info_logger();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "query/property_util.hpp"
|
|
||||||
#include "query/i_plan_cpu.hpp"
|
|
||||||
#include "storage/model/properties/all.hpp"
|
|
||||||
|
|
||||||
using std::cout;
|
|
||||||
using std::endl;
|
|
||||||
|
|
||||||
// query: {{query}}
|
|
||||||
|
|
||||||
// BARRIER!
|
|
||||||
namespace barrier
|
|
||||||
{
|
|
||||||
|
|
||||||
class {{class_name}} : public IPlanCPU<{{stream}}>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool run(Db &db, plan_args_t &args,
|
|
||||||
{{stream}} &stream) override
|
|
||||||
{
|
|
||||||
{{code}}
|
|
||||||
}
|
|
||||||
|
|
||||||
~{{class_name}}() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" IPlanCPU<barrier::{{stream}}>* produce()
|
|
||||||
{
|
|
||||||
// BARRIER!
|
|
||||||
return new barrier::{{class_name}}();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void destruct(IPlanCPU<barrier::{{stream}}>* p)
|
|
||||||
{
|
|
||||||
delete p;
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
#include "query/util.hpp"
|
|
||||||
|
|
||||||
#include "storage/type_group_edge.hpp"
|
|
||||||
#include "storage/type_group_vertex.hpp"
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void print_props(const Properties<T> &properties)
|
|
||||||
{
|
|
||||||
StringBuffer buffer;
|
|
||||||
JsonWriter<StringBuffer> writer(buffer);
|
|
||||||
properties.accept(writer);
|
|
||||||
cout << buffer.str() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void cout_properties(const Properties<T> &properties)
|
|
||||||
{
|
|
||||||
ConsoleWriter writer;
|
|
||||||
properties.accept(writer);
|
|
||||||
cout << "----" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void cout_property(const StoredProperty<T> &property)
|
|
||||||
{
|
|
||||||
ConsoleWriter writer;
|
|
||||||
property.accept(writer);
|
|
||||||
cout << "----" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
template void
|
|
||||||
print_props<TypeGroupEdge>(const Properties<TypeGroupEdge> &properties);
|
|
||||||
|
|
||||||
template void
|
|
||||||
print_props<TypeGroupVertex>(const Properties<TypeGroupVertex> &properties);
|
|
||||||
|
|
||||||
template void
|
|
||||||
cout_properties<TypeGroupEdge>(const Properties<TypeGroupEdge> &properties);
|
|
||||||
|
|
||||||
template void
|
|
||||||
cout_properties<TypeGroupVertex>(const Properties<TypeGroupVertex> &properties);
|
|
||||||
|
|
||||||
template void
|
|
||||||
cout_property<TypeGroupEdge>(const StoredProperty<TypeGroupEdge> &property);
|
|
||||||
|
|
||||||
template void
|
|
||||||
cout_property<TypeGroupVertex>(const StoredProperty<TypeGroupVertex> &property);
|
|
@ -3,22 +3,20 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "storage/vertex_record.hpp"
|
#include "storage/vertex_record.hpp"
|
||||||
|
#include "storage/edge_type/edge_type.hpp"
|
||||||
|
|
||||||
void EdgeAccessor::remove() const
|
void EdgeAccessor::remove() const
|
||||||
{
|
{
|
||||||
RecordAccessor::remove();
|
RecordAccessor::remove();
|
||||||
|
|
||||||
auto from_v = from();
|
auto from_va = from();
|
||||||
bool f_from = from_v.fill();
|
assert(from_va.fill());
|
||||||
assert(f_from);
|
|
||||||
|
|
||||||
auto to_v = to();
|
auto to_va = to();
|
||||||
bool f_to = to_v.fill();
|
assert(to_va.fill());
|
||||||
assert(f_to);
|
|
||||||
|
|
||||||
// Detach edge from vertices.
|
from_va.update().record->data.out.remove(vlist);
|
||||||
from_v.update().record->data.out.remove(vlist);
|
to_va.update().record->data.in.remove(vlist);
|
||||||
to_v.update().record->data.in.remove(vlist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EdgeAccessor::edge_type(const EdgeType &edge_type)
|
void EdgeAccessor::edge_type(const EdgeType &edge_type)
|
||||||
|
@ -14,14 +14,16 @@
|
|||||||
|
|
||||||
template <class T, class K>
|
template <class T, class K>
|
||||||
NonUniqueUnorderedIndex<T, K>::NonUniqueUnorderedIndex(IndexLocation &&loc)
|
NonUniqueUnorderedIndex<T, K>::NonUniqueUnorderedIndex(IndexLocation &&loc)
|
||||||
: IndexBase<T, K>(IndexDefinition{loc, IndexType{false, None}})
|
: IndexBase<T, K>(IndexDefinition{loc, IndexType{false, None}},
|
||||||
|
"NonUniqueUnorderedIndex")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class K>
|
template <class T, class K>
|
||||||
NonUniqueUnorderedIndex<T, K>::NonUniqueUnorderedIndex(IndexLocation &&loc,
|
NonUniqueUnorderedIndex<T, K>::NonUniqueUnorderedIndex(IndexLocation &&loc,
|
||||||
tx::Transaction const &t)
|
tx::Transaction const &t)
|
||||||
: IndexBase<T, K>(IndexDefinition{loc, IndexType{false, None}}, t)
|
: IndexBase<T, K>(IndexDefinition{loc, IndexType{false, None}}, t,
|
||||||
|
"NonUniqueUnorderedIndex")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,18 +51,22 @@ auto NonUniqueUnorderedIndex<T, K>::for_range_exact(DbAccessor &t_v,
|
|||||||
return iter::make_iterator(
|
return iter::make_iterator(
|
||||||
[
|
[
|
||||||
it = list.cbegin(), end = list.cend(), from = from_v, to = to_v,
|
it = list.cbegin(), end = list.cend(), from = from_v, to = to_v,
|
||||||
t = t_v
|
// &t_v is passed by reference because otherwise
|
||||||
]() mutable->auto {
|
// DbAccessor would be copied that means that t_v.db_transaction would
|
||||||
|
// also be copied and that wouldn't be good because
|
||||||
|
// db_transaction contains index_updates
|
||||||
|
t = &t_v
|
||||||
|
]() mutable -> auto {
|
||||||
// NonUniqueUnorderedIndex is stupid so it must iterate through all
|
// NonUniqueUnorderedIndex is stupid so it must iterate through all
|
||||||
// index records to determine which are iniside borders.
|
// index records to determine which are iniside borders.
|
||||||
while (it != end) {
|
while (it != end) {
|
||||||
const IndexRecord<T, K> &r = *it;
|
const IndexRecord<T, K> &r = *it;
|
||||||
if (from < r.key && to > r.key &&
|
if (from < r.key && to > r.key &&
|
||||||
r.is_valid(t.db_transaction.trans)) {
|
r.is_valid(t->db_transaction.trans)) {
|
||||||
// record r is inside borders and is valid for current
|
// record r is inside borders and is valid for current
|
||||||
// transaction.
|
// transaction.
|
||||||
const typename T::accessor_t acc =
|
const typename T::accessor_t acc =
|
||||||
r.access(t.db_transaction);
|
r.access(t->db_transaction);
|
||||||
it++;
|
it++;
|
||||||
return make_option(std::move(acc));
|
return make_option(std::move(acc));
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,16 @@
|
|||||||
|
|
||||||
template <class T, class K>
|
template <class T, class K>
|
||||||
UniqueOrderedIndex<T, K>::UniqueOrderedIndex(IndexLocation loc, Order order)
|
UniqueOrderedIndex<T, K>::UniqueOrderedIndex(IndexLocation loc, Order order)
|
||||||
: IndexBase<T, K>(IndexDefinition{loc, IndexType{true, order}})
|
: IndexBase<T, K>(IndexDefinition{loc, IndexType{true, order}},
|
||||||
|
"UniqueOrderedIndex")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class K>
|
template <class T, class K>
|
||||||
UniqueOrderedIndex<T, K>::UniqueOrderedIndex(IndexLocation loc, Order order,
|
UniqueOrderedIndex<T, K>::UniqueOrderedIndex(IndexLocation loc, Order order,
|
||||||
tx::Transaction const &t)
|
tx::Transaction const &t)
|
||||||
: IndexBase<T, K>(IndexDefinition{loc, IndexType{true, order}}, t)
|
: IndexBase<T, K>(IndexDefinition{loc, IndexType{true, order}},
|
||||||
|
t, "UniqueOrderedIndex")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ auto UniqueOrderedIndex<T, K>::for_range_exact(DbAccessor &t_v,
|
|||||||
|
|
||||||
return iter::make_iterator(
|
return iter::make_iterator(
|
||||||
[
|
[
|
||||||
it = std::move(begin), b_end = std::move(end), t = t_v,
|
it = std::move(begin), b_end = std::move(end), t = &t_v,
|
||||||
hold_acc = std::move(acc)
|
hold_acc = std::move(acc)
|
||||||
]() mutable->auto {
|
]() mutable->auto {
|
||||||
// UniqueOrderedIndex is smart so he has to iterate only through
|
// UniqueOrderedIndex is smart so he has to iterate only through
|
||||||
@ -81,11 +83,11 @@ auto UniqueOrderedIndex<T, K>::for_range_exact(DbAccessor &t_v,
|
|||||||
// reached end border.
|
// reached end border.
|
||||||
while (b_end >= it->key) {
|
while (b_end >= it->key) {
|
||||||
const IndexRecord<T, K> &r = *it;
|
const IndexRecord<T, K> &r = *it;
|
||||||
if (r.is_valid(t.db_transaction.trans)) {
|
if (r.is_valid(t->db_transaction.trans)) {
|
||||||
// record r is inside borders and is valid for current
|
// record r is inside borders and is valid for current
|
||||||
// transaction.
|
// transaction.
|
||||||
const typename T::accessor_t acc =
|
const typename T::accessor_t acc =
|
||||||
r.access(t.db_transaction);
|
r.access(t->db_transaction);
|
||||||
it++;
|
it++;
|
||||||
return make_option(std::move(acc));
|
return make_option(std::move(acc));
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
#include "transactions/transaction.hpp"
|
#include "transactions/transaction.hpp"
|
||||||
|
|
||||||
template <class TG, class K>
|
template <class TG, class K>
|
||||||
IndexBase<TG, K>::IndexBase(IndexDefinition &&it)
|
IndexBase<TG, K>::IndexBase(IndexDefinition &&it, std::string&& logger_name)
|
||||||
: it(it), created(Id(0)), active(true)
|
: Loggable(std::forward<std::string>(logger_name)), it(it), created(Id(0)), active(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class TG, class K>
|
template <class TG, class K>
|
||||||
IndexBase<TG, K>::IndexBase(IndexDefinition &&it, const tx::Transaction &t)
|
IndexBase<TG, K>::IndexBase(IndexDefinition &&it, const tx::Transaction &t, std::string&& logger_name)
|
||||||
: it(it), created(t.id)
|
: Loggable(std::forward<std::string>(logger_name)), it(it), created(t.id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "storage/type_group_edge.hpp"
|
#include "storage/type_group_edge.hpp"
|
||||||
#include "storage/type_group_vertex.hpp"
|
#include "storage/type_group_vertex.hpp"
|
||||||
|
#include "transactions/transaction.hpp"
|
||||||
|
|
||||||
template <class TG, class K>
|
template <class TG, class K>
|
||||||
IndexRecord<TG, K>::IndexRecord(K key, typename TG::record_t *record,
|
IndexRecord<TG, K>::IndexRecord(K key, typename TG::record_t *record,
|
||||||
@ -28,7 +29,15 @@ template <class TG, class K>
|
|||||||
bool IndexRecord<TG, K>::is_valid(tx::Transaction &t) const
|
bool IndexRecord<TG, K>::is_valid(tx::Transaction &t) const
|
||||||
{
|
{
|
||||||
assert(!empty());
|
assert(!empty());
|
||||||
return record == vlist->find(t);
|
// TODO: this has to be tested extensively
|
||||||
|
// before here was only (record == newest_record)
|
||||||
|
// but it doesn't work if single transaction updates something from
|
||||||
|
// this index and then tries to access to the same element again through
|
||||||
|
// the same index
|
||||||
|
auto newest_record = vlist->find(t);
|
||||||
|
if (newest_record == nullptr)
|
||||||
|
return false;
|
||||||
|
return (record == newest_record) || (newest_record->tx.cre() == t.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class TG, class K>
|
template <class TG, class K>
|
||||||
|
@ -7,15 +7,14 @@ bool LabelCollection::add(const Label &label)
|
|||||||
if (has(label)) {
|
if (has(label)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
_labels.push_back(label_ref_t(label));
|
labels_.push_back(label_ref_t(label));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// return _labels.(label_ref_t(label)).second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LabelCollection::has(const Label &label) const
|
bool LabelCollection::has(const Label &label) const
|
||||||
{
|
{
|
||||||
for (auto l : _labels) {
|
for (auto l : labels_) {
|
||||||
if (l == label) {
|
if (l == label) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -23,14 +22,14 @@ bool LabelCollection::has(const Label &label) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t LabelCollection::count() const { return _labels.size(); }
|
size_t LabelCollection::count() const { return labels_.size(); }
|
||||||
|
|
||||||
bool LabelCollection::remove(const Label &label)
|
bool LabelCollection::remove(const Label &label)
|
||||||
{
|
{
|
||||||
auto end = _labels.end();
|
auto end = labels_.end();
|
||||||
for (auto it = _labels.begin(); it != end; it++) {
|
for (auto it = labels_.begin(); it != end; it++) {
|
||||||
if (*it == label) {
|
if (*it == label) {
|
||||||
_labels.erase(it);
|
labels_.erase(it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,9 +37,9 @@ bool LabelCollection::remove(const Label &label)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelCollection::clear() { _labels.clear(); }
|
void LabelCollection::clear() { labels_.clear(); }
|
||||||
|
|
||||||
const std::vector<label_ref_t> &LabelCollection::operator()() const
|
const std::vector<label_ref_t> &LabelCollection::operator()() const
|
||||||
{
|
{
|
||||||
return _labels;
|
return labels_;
|
||||||
}
|
}
|
||||||
|
13
src/storage/label/labels_writer.cpp
Normal file
13
src/storage/label/labels_writer.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "storage/label/labels_writer.hpp"
|
||||||
|
|
||||||
|
#include "storage/label/label.hpp"
|
||||||
|
#include "utils/string_buffer.hpp"
|
||||||
|
|
||||||
|
template <typename Buffer>
|
||||||
|
void LabelsWriter<Buffer>::handle(const Label& label)
|
||||||
|
{
|
||||||
|
buffer_ << ':' << label.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE! template instantiations
|
||||||
|
template class LabelsWriter<utils::StringBuffer>;
|
@ -7,10 +7,6 @@ set(src_dir ${CMAKE_SOURCE_DIR}/src)
|
|||||||
include_directories(${catch_source_dir}/include)
|
include_directories(${catch_source_dir}/include)
|
||||||
|
|
||||||
# TODO: modular approach (REFACTOR)
|
# TODO: modular approach (REFACTOR)
|
||||||
# add_executable()
|
|
||||||
# target_link_libraries()
|
|
||||||
# add_test(NAME COMMAND)
|
|
||||||
# set_property(TARGET PROPERTY CXX_STANDARD 14)
|
|
||||||
|
|
||||||
## UNIT TESTS
|
## UNIT TESTS
|
||||||
|
|
||||||
@ -111,15 +107,6 @@ target_link_libraries(manual_cypher_ast ${yaml_static_lib})
|
|||||||
target_link_libraries(manual_cypher_ast cypher_lib)
|
target_link_libraries(manual_cypher_ast cypher_lib)
|
||||||
set_property(TARGET manual_cypher_ast PROPERTY CXX_STANDARD 14)
|
set_property(TARGET manual_cypher_ast PROPERTY CXX_STANDARD 14)
|
||||||
|
|
||||||
# queries
|
|
||||||
add_executable(manual_queries manual/queries.cpp)
|
|
||||||
target_link_libraries(manual_queries memgraph)
|
|
||||||
target_link_libraries(manual_queries Threads::Threads)
|
|
||||||
target_link_libraries(manual_queries ${fmt_static_lib})
|
|
||||||
target_link_libraries(manual_queries ${yaml_static_lib})
|
|
||||||
target_link_libraries(manual_queries cypher_lib)
|
|
||||||
set_property(TARGET manual_queries PROPERTY CXX_STANDARD 14)
|
|
||||||
|
|
||||||
# query_engine
|
# query_engine
|
||||||
add_executable(manual_query_engine manual/query_engine.cpp)
|
add_executable(manual_query_engine manual/query_engine.cpp)
|
||||||
target_link_libraries(manual_query_engine stdc++fs)
|
target_link_libraries(manual_query_engine stdc++fs)
|
||||||
@ -139,10 +126,3 @@ target_link_libraries(manual_query_hasher ${fmt_static_lib})
|
|||||||
target_link_libraries(manual_query_hasher ${yaml_static_lib})
|
target_link_libraries(manual_query_hasher ${yaml_static_lib})
|
||||||
target_link_libraries(manual_query_hasher Threads::Threads)
|
target_link_libraries(manual_query_hasher Threads::Threads)
|
||||||
set_property(TARGET manual_query_hasher PROPERTY CXX_STANDARD 14)
|
set_property(TARGET manual_query_hasher PROPERTY CXX_STANDARD 14)
|
||||||
|
|
||||||
# query_action_processor
|
|
||||||
add_executable(manual_cpp_generator manual/cpp_generator.cpp)
|
|
||||||
target_link_libraries(manual_cpp_generator memgraph)
|
|
||||||
target_link_libraries(manual_cpp_generator ${fmt_static_lib})
|
|
||||||
target_link_libraries(manual_cpp_generator ${yaml_static_lib})
|
|
||||||
set_property(TARGET manual_cpp_generator PROPERTY CXX_STANDARD 14)
|
|
||||||
|
@ -1,15 +1,41 @@
|
|||||||
CREATE (n {garment_id: 1234, garment_category_id: 1}) RETURN n
|
CREATE (g:garment {garment_id: 1, garment_category_id: 1}) RETURN g
|
||||||
CREATE (p:profile {profile_id: 111, partner_id: 55}) RETURN p
|
CREATE (g:garment {garment_id: 2, garment_category_id: 2}) RETURN g
|
||||||
MATCH (g:garment {garment_id: 1234}) SET g:FF RETURN labels(g)
|
CREATE (g:garment {garment_id: 3, garment_category_id: 3}) RETURN g
|
||||||
MATCH (p:profile {profile_id: 111, partner_id: 55})-[s:score]-(g:garment{garment_id: 1234}) SET s.score = 1550 RETURN s.score
|
|
||||||
MATCH (g:garment {garment_id: 3456}) SET g.reveals = 50 RETURN g
|
MATCH (g:garment {garment_id: 3}) SET g.reveals = 50 RETURN g
|
||||||
MERGE (g1:garment {garment_id: 1234})-[r:default_outfit]-(g2:garment {garment_id: 2345}) RETURN r
|
|
||||||
MERGE (p:profile {profile_id: 111, partner_id: 55})-[s:score]-(g.garment {garment_id: 1234}) SET s.score=1500 RETURN s
|
MERGE (g1:garment {garment_id: 1})-[r:default_outfit]-(g2:garment {garment_id: 2}) RETURN r
|
||||||
MATCH (p:profile {profile_id: 111, partner_id: 55})-[s:score]-(g.garment {garment_id: 1234}) DELETE s
|
MERGE (g1:garment {garment_id: 2})-[r:default_outfit]-(g2:garment {garment_id: 3}) RETURN r
|
||||||
MATCH (p:profile {profile_id: 113}) DELETE p
|
MERGE (g1:garment {garment_id: 3})-[r:default_outfit]-(g2:garment {garment_id: 1}) RETURN r
|
||||||
MATCH (n) DETACH DELETE n
|
|
||||||
MATCH (p:profile) RETURN p
|
CREATE (p:profile {profile_id: 1, partner_id: 1}) RETURN p
|
||||||
|
CREATE (p:profile {profile_id: 2, partner_id: 2}) RETURN p
|
||||||
|
CREATE (p:profile {profile_id: 3, partner_id: 2}) RETURN p
|
||||||
|
|
||||||
MATCH (g:garment) RETURN COUNT(g)
|
MATCH (g:garment) RETURN COUNT(g)
|
||||||
MATCH (g:garment {garment_id: 1234}) RETURN g
|
MATCH (g:garment) RETURN g
|
||||||
MATCH (p:profile {partner_id: 55}) RETURN p
|
|
||||||
|
MATCH (p:profile) RETURN count(p)
|
||||||
|
MATCH (p:profile) RETURN p
|
||||||
|
|
||||||
|
MATCH (g:garment {garment_id: 1}) RETURN g
|
||||||
|
MATCH (p:profile {partner_id: 1}) RETURN p
|
||||||
|
|
||||||
|
MATCH (n) RETURN count(n)
|
||||||
|
|
||||||
|
MATCH (g:garment {garment_id: 2}) SET g:FF RETURN labels(g)
|
||||||
|
|
||||||
|
MERGE (p:profile {profile_id: 1, partner_id: 1})-[s:score]-(g.garment {garment_id: 1}) SET s.score = 1500 RETURN s
|
||||||
|
MATCH (p:profile {profile_id: 1, partner_id: 1})-[s:score]-(g:garment {garment_id: 1}) SET s.score = 1550 RETURN s.score
|
||||||
|
MATCH (p:profile {profile_id: 1, partner_id: 1})-[s:score]-(g.garment {garment_id: 1}) DELETE s
|
||||||
|
|
||||||
|
MATCH (g:garment {garment_id: 1}) DELETE g
|
||||||
|
MATCH (p:profile {profile_id: 1}) DELETE p
|
||||||
|
|
||||||
|
MATCH (n) RETURN count(n)
|
||||||
|
|
||||||
|
MATCH (g:garment) RETURN COUNT(g)
|
||||||
|
|
||||||
|
MATCH (n) DETACH DELETE n
|
||||||
|
|
||||||
MATCH (n) RETURN count(n)
|
MATCH (n) RETURN count(n)
|
||||||
|
2
tests/data/queries/core/pool.txt
Normal file
2
tests/data/queries/core/pool.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
MERGE (g1:garment {garment_id: 1234})-[r:default_outfit]-(g2:garment {garment_id: 2345}) RETURN r
|
||||||
|
MATCH (p:profile {profile_id: 111, partner_id: 55})-[s:score]-(g.garment {garment_id: 1234}) DELETE s
|
@ -305,7 +305,7 @@ auto load_basic_functions(Db &db)
|
|||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Going through edges wiil probably be faster
|
// Going through edges will probably be faster
|
||||||
it_type.to().for_all([&](auto m) {
|
it_type.to().for_all([&](auto m) {
|
||||||
// PRINT m
|
// PRINT m
|
||||||
});
|
});
|
||||||
@ -319,7 +319,8 @@ auto load_basic_functions(Db &db)
|
|||||||
DbAccessor t(db);
|
DbAccessor t(db);
|
||||||
|
|
||||||
auto &type = t.type_find_or_create("TYPE");
|
auto &type = t.type_find_or_create("TYPE");
|
||||||
auto prop_name = t.vertex_property_key("name", args[0].key.flags());
|
auto prop_name =
|
||||||
|
t.vertex_property_key("name", args[0].key.flags());
|
||||||
|
|
||||||
Option<const VertexAccessor> n;
|
Option<const VertexAccessor> n;
|
||||||
Option<const EdgeAccessor> r;
|
Option<const EdgeAccessor> r;
|
||||||
@ -437,7 +438,7 @@ auto load_basic_functions(Db &db)
|
|||||||
|
|
||||||
// MATCH (n:LABEL {name: "TEST01"}) RETURN n;
|
// MATCH (n:LABEL {name: "TEST01"}) RETURN n;
|
||||||
auto match_label_property = [&db](properties_t &&args) {
|
auto match_label_property = [&db](properties_t &&args) {
|
||||||
std::map<std::string, int64_t> indices{{"name", 0}};
|
indices_t indices{{"name", 0}};
|
||||||
auto properties = query_properties(indices, args);
|
auto properties = query_properties(indices, args);
|
||||||
DbAccessor t(db);
|
DbAccessor t(db);
|
||||||
try {
|
try {
|
632
tests/integration/_hardcoded_query/dressipi.hpp
Normal file
632
tests/integration/_hardcoded_query/dressipi.hpp
Normal file
@ -0,0 +1,632 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "includes.hpp"
|
||||||
|
|
||||||
|
namespace hardcode
|
||||||
|
{
|
||||||
|
|
||||||
|
// TODO: decouple hashes from the code because hashes could and should be
|
||||||
|
// tested separately
|
||||||
|
|
||||||
|
auto load_dressipi_functions(Db &db)
|
||||||
|
{
|
||||||
|
query_functions_t functions;
|
||||||
|
|
||||||
|
// Query: CREATE (g:garment {garment_id: 1234, garment_category_id: 1}) RETURN g
|
||||||
|
// Hash: 18071907865596388702
|
||||||
|
functions[18071907865596388702u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto garment_id =
|
||||||
|
t.vertex_property_key("garment_id", args[0].key.flags());
|
||||||
|
auto garment_category_id =
|
||||||
|
t.vertex_property_key("garment_category_id", args[1].key.flags());
|
||||||
|
|
||||||
|
// vertex_accessor
|
||||||
|
auto va = t.vertex_insert();
|
||||||
|
va.set(garment_id, std::move(args[0]));
|
||||||
|
va.set(garment_category_id, std::move(args[1]));
|
||||||
|
|
||||||
|
auto &garment = t.label_find_or_create("garment");
|
||||||
|
va.add_label(garment);
|
||||||
|
|
||||||
|
// stream.write_field("g");
|
||||||
|
// stream.write_vertex_record(va);
|
||||||
|
// stream.write_meta("w");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: CREATE (p:profile {profile_id: 111, partner_id: 55}) RETURN p
|
||||||
|
// Hash: 17158428452166262783
|
||||||
|
functions[17158428452166262783u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto profile_id =
|
||||||
|
t.vertex_property_key("profile_id", args[0].key.flags());
|
||||||
|
auto partner_id =
|
||||||
|
t.vertex_property_key("partner_id", args[1].key.flags());
|
||||||
|
|
||||||
|
auto va = t.vertex_insert();
|
||||||
|
va.set(profile_id, std::move(args[0]));
|
||||||
|
va.set(partner_id, std::move(args[1]));
|
||||||
|
|
||||||
|
auto &profile = t.label_find_or_create("profile");
|
||||||
|
va.add_label(profile);
|
||||||
|
|
||||||
|
// stream.write_field("p");
|
||||||
|
// stream.write_vertex_record(va);
|
||||||
|
// stream.write_meta("w");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (g:garment {garment_id: 1234}) SET g:FF RETURN labels(g)
|
||||||
|
// Hash: 11123780635391515946
|
||||||
|
functions[11123780635391515946u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
indices_t indices = {{"garment_id", 0}};
|
||||||
|
auto properties = query_properties(indices, args);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
// stream.write_field("labels(g)");
|
||||||
|
|
||||||
|
label.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, properties)
|
||||||
|
.for_all([&](auto va) -> void {
|
||||||
|
va.stream_repr(std::cout);
|
||||||
|
auto &ff_label = t.label_find_or_create("FF");
|
||||||
|
va.add_label(ff_label);
|
||||||
|
auto &labels = va.labels();
|
||||||
|
|
||||||
|
// stream.write_record();
|
||||||
|
// stream.write_list_header(1);
|
||||||
|
// stream.write_list_header(labels.size());
|
||||||
|
|
||||||
|
for (auto &label : labels)
|
||||||
|
{
|
||||||
|
// stream.write(label.get().str());
|
||||||
|
|
||||||
|
utils::println("LABELS: ", label.get().str());
|
||||||
|
}
|
||||||
|
// stream.chunk();
|
||||||
|
});
|
||||||
|
// stream.write_meta(\"rw");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (p:profile {profile_id: 111, partner_id:55})-[s:score]-(g:garment {garment_id: 1234}) SET s.score = 1550 RETURN s.score
|
||||||
|
// Hash: 674581607834128909
|
||||||
|
functions[674581607834128909u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto &profile = t.label_find_or_create("profile");
|
||||||
|
auto &score = t.type_find_or_create("score");
|
||||||
|
auto &garment = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}};
|
||||||
|
indices_t garment_ind = {{"garment_id", 2}};
|
||||||
|
|
||||||
|
auto profile_prop = query_properties(profile_ind, args);
|
||||||
|
auto garment_prop = query_properties(garment_ind, args);
|
||||||
|
|
||||||
|
auto score_key = t.edge_property_key("score", args[3].key.flags());
|
||||||
|
|
||||||
|
// TODO: decide path (which index is better)
|
||||||
|
// 3 options p->s->g, g->s->p, g<-s->p
|
||||||
|
// NOTE! both direections have to be chacked
|
||||||
|
// because pattern is non directional
|
||||||
|
// OR
|
||||||
|
// even better, use index on label and property
|
||||||
|
|
||||||
|
// just one option p->s->g!
|
||||||
|
Option<const EdgeAccessor> e1;
|
||||||
|
profile.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, profile_prop)
|
||||||
|
.out()
|
||||||
|
.type(score)
|
||||||
|
.clone_to(e1)
|
||||||
|
.to()
|
||||||
|
.label(garment)
|
||||||
|
.properties_filter(t, garment_prop)
|
||||||
|
.for_all([&](auto va) -> void {
|
||||||
|
auto ea = e1.get().update();
|
||||||
|
ea.set(score_key, std::move(args[3]));
|
||||||
|
});
|
||||||
|
|
||||||
|
Option<const EdgeAccessor> e2;
|
||||||
|
profile.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, profile_prop)
|
||||||
|
.in()
|
||||||
|
.type(score)
|
||||||
|
.clone_to(e1)
|
||||||
|
.from()
|
||||||
|
.label(garment)
|
||||||
|
.properties_filter(t, garment_prop)
|
||||||
|
.for_all([&](auto va) -> void {
|
||||||
|
auto ea = e2.get().update();
|
||||||
|
ea.set(score_key, std::move(args[3]));
|
||||||
|
});
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (g:garment {garment_id: 3456}) SET g.reveals = 50 RETURN g
|
||||||
|
// Hash: 2839969099736071844
|
||||||
|
functions[2839969099736071844u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto reveals_key =
|
||||||
|
t.vertex_property_key("reveals", args[1].key.flags());
|
||||||
|
|
||||||
|
indices_t indices = {{"garment_id", 0}};
|
||||||
|
auto properties = query_properties(indices, args);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
// stream.write_field("g");
|
||||||
|
|
||||||
|
label.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, properties)
|
||||||
|
.fill()
|
||||||
|
.for_all([&](auto va) {
|
||||||
|
va.set(reveals_key, args[1]);
|
||||||
|
|
||||||
|
// stream.write_vertex_record(va);
|
||||||
|
});
|
||||||
|
|
||||||
|
// stream.write_meta("w");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MERGE (g1:garment {garment_id:1234})-[r:default_outfit]-(g2:garment {garment_id: 2345}) RETURN r
|
||||||
|
// Hash: 3782642357973971504
|
||||||
|
functions[3782642357973971504u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
// TODO: support for index on label and property
|
||||||
|
|
||||||
|
// prepare iterator for g1
|
||||||
|
indices_t indices_1 = {{"garment_id", 0}};
|
||||||
|
auto properties_1 = query_properties(indices_1, args);
|
||||||
|
auto &label_1 = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
auto it_vertex_1 =
|
||||||
|
label_1.index().for_range(t).properties_filter(t, properties_1);
|
||||||
|
|
||||||
|
// prepare iterator for g1
|
||||||
|
indices_t indices_2 = {{"garment_id", 1}};
|
||||||
|
auto properties_2 = query_properties(indices_2, args);
|
||||||
|
auto &label_2 = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
auto it_vertex_2 =
|
||||||
|
label_2.index().for_range(t).properties_filter(t, properties_2);
|
||||||
|
|
||||||
|
auto &edge_type = t.type_find_or_create("default_outfit");
|
||||||
|
|
||||||
|
// TODO: create g1 and g2 if don't exist
|
||||||
|
|
||||||
|
// TODO: figure out something better
|
||||||
|
|
||||||
|
// stream.write_field("r");
|
||||||
|
|
||||||
|
it_vertex_1.fill().for_all([&](auto va1) -> void {
|
||||||
|
it_vertex_2.fill().for_all([&](auto va2) -> void {
|
||||||
|
auto edge_accessor = t.edge_insert(va1, va2);
|
||||||
|
edge_accessor.edge_type(edge_type);
|
||||||
|
|
||||||
|
// stream.write_edge_record(edge_accessor);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// stream.write_meta("w");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MERGE (p:profile {profile_id: 111, partner_id: 55})-[s:score]-(g.garment {garment_id: 1234}) SET s.score=1500 RETURN s
|
||||||
|
// Hash: 7871009397157280694
|
||||||
|
functions[7871009397157280694u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto &profile = t.label_find_or_create("profile");
|
||||||
|
auto &score = t.type_find_or_create("score");
|
||||||
|
auto &garment = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}};
|
||||||
|
indices_t garment_ind = {{"garment_id", 2}};
|
||||||
|
|
||||||
|
auto profile_prop = query_properties(profile_ind, args);
|
||||||
|
auto garment_prop = query_properties(garment_ind, args);
|
||||||
|
|
||||||
|
auto score_key = t.edge_property_key("score", args[3].key.flags());
|
||||||
|
|
||||||
|
// TODO: implement
|
||||||
|
bool exists = false;
|
||||||
|
Option<const EdgeAccessor> e1;
|
||||||
|
profile.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, profile_prop)
|
||||||
|
.out()
|
||||||
|
.type(score)
|
||||||
|
.clone_to(e1)
|
||||||
|
.to()
|
||||||
|
.label(garment)
|
||||||
|
.properties_filter(t, garment_prop)
|
||||||
|
.for_all([&](auto va) -> void {
|
||||||
|
exists = true;
|
||||||
|
auto ea = e1.get().update();
|
||||||
|
ea.set(score_key, args[3]);
|
||||||
|
});
|
||||||
|
|
||||||
|
Option<const EdgeAccessor> e2;
|
||||||
|
profile.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, profile_prop)
|
||||||
|
.in()
|
||||||
|
.type(score)
|
||||||
|
.clone_to(e1)
|
||||||
|
.from()
|
||||||
|
.label(garment)
|
||||||
|
.properties_filter(t, garment_prop)
|
||||||
|
.for_all([&](auto va) -> void {
|
||||||
|
exists = true;
|
||||||
|
auto ea = e2.get().update();
|
||||||
|
ea.set(score_key, args[3]);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!exists) {
|
||||||
|
auto it_vertex_garment =
|
||||||
|
garment.index().for_range(t).properties_filter(t, garment_prop);
|
||||||
|
auto it_vertex_profile =
|
||||||
|
profile.index().for_range(t).properties_filter(t, profile_prop);
|
||||||
|
|
||||||
|
it_vertex_profile.fill().for_all([&](auto va1) -> void {
|
||||||
|
it_vertex_garment.fill().for_all([&](auto va2) -> void {
|
||||||
|
auto ea = t.edge_insert(va1, va2);
|
||||||
|
ea.edge_type(score);
|
||||||
|
ea.set(score_key, args[3]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// stream.write_field("r.score");
|
||||||
|
// write_record();
|
||||||
|
// write_list_header(1);
|
||||||
|
// write(Float(args[3]));
|
||||||
|
// chunk();
|
||||||
|
// stream.write_field("w");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (p:profile {profile_id: 111, partner_id:55})-[s:score]-(g.garment {garment_id: 1234}) DELETE s
|
||||||
|
// Hash: 9459600951073026137
|
||||||
|
functions[9459600951073026137u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto &profile = t.label_find_or_create("profile");
|
||||||
|
auto &score = t.type_find_or_create("score");
|
||||||
|
auto &garment = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}};
|
||||||
|
indices_t garment_ind = {{"garment_id", 2}};
|
||||||
|
|
||||||
|
auto profile_prop = query_properties(profile_ind, args);
|
||||||
|
auto garment_prop = query_properties(garment_ind, args);
|
||||||
|
|
||||||
|
auto score_key = t.edge_property_key("score", args[3].key.flags());
|
||||||
|
|
||||||
|
// TODO: decide path (which index is better)
|
||||||
|
// 3 options p->s->g, g->s->p, g<-s->p
|
||||||
|
// NOTE! both direections have to be chacked
|
||||||
|
// because pattern is non directional
|
||||||
|
// OR
|
||||||
|
// even better, use index on label and property
|
||||||
|
|
||||||
|
// just one option p->s->g!
|
||||||
|
Option<const EdgeAccessor> e1;
|
||||||
|
profile.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, profile_prop)
|
||||||
|
.out()
|
||||||
|
.type(score)
|
||||||
|
.clone_to(e1)
|
||||||
|
.to()
|
||||||
|
.label(garment)
|
||||||
|
.properties_filter(t, garment_prop)
|
||||||
|
.for_all([&](auto va) -> void {
|
||||||
|
auto ea = e1.get().update();
|
||||||
|
ea.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
Option<const EdgeAccessor> e2;
|
||||||
|
profile.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, profile_prop)
|
||||||
|
.in()
|
||||||
|
.type(score)
|
||||||
|
.clone_to(e1)
|
||||||
|
.from()
|
||||||
|
.label(garment)
|
||||||
|
.properties_filter(t, garment_prop)
|
||||||
|
.for_all([&](auto va) -> void {
|
||||||
|
auto ea = e2.get().update();
|
||||||
|
ea.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
// stream.write_empty_fields();
|
||||||
|
// stream.write_meta("w");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (p:garment {garment_id: 1}) DELETE g
|
||||||
|
// Hash: 11538263096707897794
|
||||||
|
functions[11538263096707897794u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
indices_t indices = {{"garment_id", 0}};
|
||||||
|
auto properties = query_properties(indices, args);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
label.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, properties)
|
||||||
|
.for_all([&](auto va) { va.remove(); });
|
||||||
|
|
||||||
|
// stream.write_empty_fields();
|
||||||
|
// stream.write_meta("w");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (p:profile {profile_id: 1}) DELETE p
|
||||||
|
// Hash: 6763665709953344106
|
||||||
|
functions[6763665709953344106u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
indices_t indices = {{"profile_id", 0}};
|
||||||
|
auto properties = query_properties(indices, args);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("profile");
|
||||||
|
|
||||||
|
label.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, properties)
|
||||||
|
.for_all([&](auto va) { va.remove(); });
|
||||||
|
|
||||||
|
// stream.write_empty_fields();
|
||||||
|
// stream.write_meta("w");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (n) RETURN n
|
||||||
|
// Hash: 5949923385370229113
|
||||||
|
functions[5949923385370229113u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
// stream.write_field("n");
|
||||||
|
|
||||||
|
t.vertex_access().fill().for_all([&](auto va) {
|
||||||
|
// stream.write_vertex_record(va);
|
||||||
|
|
||||||
|
va.stream_repr(std::cout);
|
||||||
|
utils::println("");
|
||||||
|
});
|
||||||
|
|
||||||
|
// stream.write_meta("r");
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (g:garment) RETURN g
|
||||||
|
// Hash: 2645003052555435977
|
||||||
|
functions[2645003052555435977u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
// stream.write_field("p");
|
||||||
|
label.index().for_range(t).for_all([&](auto va) -> void {
|
||||||
|
// stream.write_vertex_record(va);
|
||||||
|
|
||||||
|
va.stream_repr(std::cout);
|
||||||
|
utils::println("");
|
||||||
|
});
|
||||||
|
|
||||||
|
// stream.write_meta("r");
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (p:profile) RETURN p
|
||||||
|
// Hash: 15599970964909894866
|
||||||
|
functions[15599970964909894866u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("profile");
|
||||||
|
|
||||||
|
// stream.write_field("p");
|
||||||
|
|
||||||
|
label.index().for_range(t).for_all([&](auto va) {
|
||||||
|
|
||||||
|
// stream.write_vertex_record(va);
|
||||||
|
|
||||||
|
va.stream_repr(std::cout);
|
||||||
|
utils::println("");
|
||||||
|
});
|
||||||
|
|
||||||
|
// stream.write_meta("r");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (g:garment {garment_id: 1}) RETURN g
|
||||||
|
// Hash: 7756609649964321221
|
||||||
|
functions[7756609649964321221u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
indices_t indices = {{"garment_id", 0}};
|
||||||
|
auto properties = query_properties(indices, args);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
// stream.write_field("g");
|
||||||
|
|
||||||
|
label.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, properties)
|
||||||
|
.for_all([&](auto va) -> void {
|
||||||
|
// stream.write_vertex_record(va);
|
||||||
|
|
||||||
|
va.stream_repr(std::cout);
|
||||||
|
});
|
||||||
|
|
||||||
|
// stream.write_meta("w");
|
||||||
|
|
||||||
|
utils::println("");
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (p:profile {partner_id: 1}) RETURN p
|
||||||
|
// Hash: 17506488413143988006
|
||||||
|
functions[17506488413143988006u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
indices_t indices = {{"partner_id", 0}};
|
||||||
|
auto properties = query_properties(indices, args);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("profile");
|
||||||
|
|
||||||
|
// stream.write_field("p");
|
||||||
|
|
||||||
|
label.index()
|
||||||
|
.for_range(t)
|
||||||
|
.properties_filter(t, properties)
|
||||||
|
.for_all([&](auto va) {
|
||||||
|
// stream.write_vertex_record(va);
|
||||||
|
|
||||||
|
va.stream_repr(std::cout);
|
||||||
|
});
|
||||||
|
|
||||||
|
// stream.write_meta("r");
|
||||||
|
|
||||||
|
utils::println("");
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (n) RETURN count(n)
|
||||||
|
// Hash: 10510787599699014973
|
||||||
|
functions[10510787599699014973u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
size_t count = 0;
|
||||||
|
t.vertex_access().fill().for_all([&](auto va) { ++count; });
|
||||||
|
|
||||||
|
// stream.write_field("count(n)");
|
||||||
|
// stream.write_count(count);
|
||||||
|
// stream.write_meta("r");
|
||||||
|
|
||||||
|
utils::println("COUNT: ", count);
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (g:garment) RETURN count(g)
|
||||||
|
// Hash: 11458306387621940265
|
||||||
|
functions[11458306387621940265u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("garment");
|
||||||
|
|
||||||
|
size_t count = 0;
|
||||||
|
label.index().for_range(t).for_all([&](auto va) { ++count; });
|
||||||
|
|
||||||
|
// stream.write_field("count(g)");
|
||||||
|
// stream.write_count(count);
|
||||||
|
// stream.write_meta("r");
|
||||||
|
|
||||||
|
utils::println("COUNT: ", count);
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (p:profile) RETURN count(p)
|
||||||
|
// Hash: 7104933247859974916
|
||||||
|
functions[7104933247859974916u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto &label = t.label_find_or_create("profile");
|
||||||
|
|
||||||
|
size_t count = 0;
|
||||||
|
label.index().for_range(t).for_all([&](auto va) { ++count; });
|
||||||
|
|
||||||
|
// stream.write_field("count(p)");
|
||||||
|
// stream.write_count(count);
|
||||||
|
// stream.write_meta("r");
|
||||||
|
|
||||||
|
utils::println("COUNT: ", count);
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Query: MATCH (n) DETACH DELETE n
|
||||||
|
// Hash: 4798158026600988079
|
||||||
|
functions[4798158026600988079u] = [&db](properties_t &&args) {
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
t.edge_access().fill().for_all([&](auto e) { e.remove(); });
|
||||||
|
t.vertex_access().fill().isolated().for_all(
|
||||||
|
[&](auto a) { a.remove(); });
|
||||||
|
|
||||||
|
// stream.write_empty_fields();
|
||||||
|
// stream.write_meta("w");
|
||||||
|
|
||||||
|
print_entities(t);
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
};
|
||||||
|
|
||||||
|
return functions;
|
||||||
|
}
|
||||||
|
}
|
110
tests/integration/_hardcoded_query/includes.hpp
Normal file
110
tests/integration/_hardcoded_query/includes.hpp
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include <map>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
||||||
|
#include "communication/bolt/v1/serialization/record_stream.hpp"
|
||||||
|
#include "database/db.hpp"
|
||||||
|
#include "database/db.hpp"
|
||||||
|
#include "database/db_accessor.hpp"
|
||||||
|
#include "database/db_accessor.hpp"
|
||||||
|
#include "io/network/socket.hpp"
|
||||||
|
#include "mvcc/id.hpp"
|
||||||
|
#include "query/util.hpp"
|
||||||
|
#include "storage/edge_type/edge_type.hpp"
|
||||||
|
#include "storage/edge_x_vertex.hpp"
|
||||||
|
#include "storage/indexes/index_definition.hpp"
|
||||||
|
#include "storage/label/label.hpp"
|
||||||
|
#include "storage/model/properties/all.hpp"
|
||||||
|
#include "storage/model/properties/property.hpp"
|
||||||
|
#include "utils/border.hpp"
|
||||||
|
#include "utils/iterator/iterator.hpp"
|
||||||
|
#include "utils/iterator/iterator.hpp"
|
||||||
|
#include "utils/option_ptr.hpp"
|
||||||
|
#include "utils/reference_wrapper.hpp"
|
||||||
|
#include "utils/variadic/variadic.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
namespace hardcode
|
||||||
|
{
|
||||||
|
|
||||||
|
using namespace utils;
|
||||||
|
|
||||||
|
using query_functions_t =
|
||||||
|
std::map<uint64_t, std::function<bool(properties_t &&)>>;
|
||||||
|
|
||||||
|
size_t edge_count(DbAccessor& t)
|
||||||
|
{
|
||||||
|
size_t count = 0;
|
||||||
|
t.edge_access().fill().for_all([&](auto ea) { ++count; });
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t vertex_count(DbAccessor& t)
|
||||||
|
{
|
||||||
|
size_t count = 0;
|
||||||
|
t.vertex_access().fill().for_all([&](auto va) { ++count; });
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEBUG HELPER METHODS
|
||||||
|
|
||||||
|
void print(const VertexAccessor& va)
|
||||||
|
{
|
||||||
|
va.stream_repr(std::cout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(const EdgeAccessor& ea)
|
||||||
|
{
|
||||||
|
ea.stream_repr(std::cout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_vertices(DbAccessor& t)
|
||||||
|
{
|
||||||
|
utils::println("Vertices:");
|
||||||
|
t.vertex_access().fill().for_all(
|
||||||
|
[&](auto va) {
|
||||||
|
va.stream_repr(std::cout);
|
||||||
|
utils::println("");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
utils::println("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_edges(DbAccessor& t)
|
||||||
|
{
|
||||||
|
utils::println("Edges:");
|
||||||
|
t.edge_access().fill().for_all(
|
||||||
|
[&](auto ea) {
|
||||||
|
ea.stream_repr(std::cout);
|
||||||
|
println("");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_entities(DbAccessor& t)
|
||||||
|
{
|
||||||
|
print_vertices(t);
|
||||||
|
print_edges(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_edge_count_(DbAccessor& t)
|
||||||
|
{
|
||||||
|
utils::println("");
|
||||||
|
utils::println("__EDGE_COUNT:", edge_count(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_vertex_count_(DbAccessor& t)
|
||||||
|
{
|
||||||
|
utils::println("");
|
||||||
|
utils::println("__VERTEX_COUNT:", vertex_count(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
|
#include "_hardcoded_query/basic.hpp"
|
||||||
#include "logging/default.hpp"
|
#include "logging/default.hpp"
|
||||||
#include "logging/streams/stdout.hpp"
|
#include "logging/streams/stdout.hpp"
|
||||||
#include "query/hardcode/basic.hpp"
|
|
||||||
#include "query/strip/stripper.hpp"
|
#include "query/strip/stripper.hpp"
|
||||||
#include "utils/sysinfo/memory.hpp"
|
#include "utils/sysinfo/memory.hpp"
|
||||||
|
|
||||||
|
52
tests/integration/hardcoded_query/18071907865596388702.cpp
Normal file
52
tests/integration/hardcoded_query/18071907865596388702.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "query/util.hpp"
|
||||||
|
#include "query/i_plan_cpu.hpp"
|
||||||
|
#include "storage/model/properties/all.hpp"
|
||||||
|
#include "using.hpp"
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
// query: CREATE (g:garment {garment_id: 1234, garment_category_id: 1}) RETURN g
|
||||||
|
|
||||||
|
class CodeCPU : public IPlanCPU<Stream>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool run(Db &db, plan_args_t &args, Stream &stream) override
|
||||||
|
{
|
||||||
|
DbAccessor t(db);
|
||||||
|
|
||||||
|
auto garment_id =
|
||||||
|
t.vertex_property_key("garment_id", args[0].key.flags());
|
||||||
|
auto garment_category_id =
|
||||||
|
t.vertex_property_key("garment_category_id", args[1].key.flags());
|
||||||
|
|
||||||
|
auto va = t.vertex_insert();
|
||||||
|
va.set(garment_id, std::move(args[0]));
|
||||||
|
va.set(garment_category_id, std::move(args[1]));
|
||||||
|
|
||||||
|
auto &garment = t.label_find_or_create("garment");
|
||||||
|
va.add_label(garment);
|
||||||
|
|
||||||
|
stream.write_field("g");
|
||||||
|
stream.write_vertex_record(va);
|
||||||
|
stream.write_meta("w");
|
||||||
|
|
||||||
|
return t.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
~CodeCPU() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" IPlanCPU<Stream>* produce()
|
||||||
|
{
|
||||||
|
return new CodeCPU();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void destruct(IPlanCPU<Stream>* p)
|
||||||
|
{
|
||||||
|
delete p;
|
||||||
|
}
|
33
tests/integration/hardcoded_query/template
Normal file
33
tests/integration/hardcoded_query/template
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "query/util.hpp"
|
||||||
|
#include "query/i_plan_cpu.hpp"
|
||||||
|
#include "storage/model/properties/all.hpp"
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
// query:
|
||||||
|
|
||||||
|
class CodeCPU : public IPlanCPU<{{stream}}>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool run(Db &db, plan_args_t &args, {{stream}} &stream) override
|
||||||
|
{
|
||||||
|
{{code}}
|
||||||
|
}
|
||||||
|
|
||||||
|
~{{class_name}}() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" IPlanCPU<{{stream}}>* produce()
|
||||||
|
{
|
||||||
|
return new {{class_name}}();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void destruct(IPlanCPU<{{stream}}>* p)
|
||||||
|
{
|
||||||
|
delete p;
|
||||||
|
}
|
5
tests/integration/hardcoded_query/using.hpp
Normal file
5
tests/integration/hardcoded_query/using.hpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "communication/communication.hpp"
|
||||||
|
|
||||||
|
using Stream = communication::OutputStream;
|
@ -1,6 +1,6 @@
|
|||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#include "query/hardcode/basic.hpp"
|
#include "_hardcoded_query/basic.hpp"
|
||||||
#include "logging/default.hpp"
|
#include "logging/default.hpp"
|
||||||
#include "logging/streams/stdout.hpp"
|
#include "logging/streams/stdout.hpp"
|
||||||
#include "query/strip/stripper.hpp"
|
#include "query/strip/stripper.hpp"
|
||||||
|
@ -2,13 +2,15 @@
|
|||||||
#include "database/db.hpp"
|
#include "database/db.hpp"
|
||||||
#include "logging/default.hpp"
|
#include "logging/default.hpp"
|
||||||
#include "logging/streams/stdout.hpp"
|
#include "logging/streams/stdout.hpp"
|
||||||
#include "query/hardcode/basic.hpp"
|
#include "_hardcoded_query/basic.hpp"
|
||||||
#include "query/hardcode/dressipi.hpp"
|
#include "_hardcoded_query/dressipi.hpp"
|
||||||
#include "query/strip/stripper.hpp"
|
#include "query/strip/stripper.hpp"
|
||||||
#include "utils/string/file.hpp"
|
#include "utils/string/file.hpp"
|
||||||
#include "utils/variadic/variadic.hpp"
|
#include "utils/variadic/variadic.hpp"
|
||||||
#include "utils/command_line/arguments.hpp"
|
#include "utils/command_line/arguments.hpp"
|
||||||
|
|
||||||
|
Logger logger;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
auto arguments = all_arguments(argc, argv);
|
auto arguments = all_arguments(argc, argv);
|
||||||
@ -19,8 +21,10 @@ int main(int argc, char *argv[])
|
|||||||
auto work_mode = get_argument(arguments, "-w", "query_execution");
|
auto work_mode = get_argument(arguments, "-w", "query_execution");
|
||||||
|
|
||||||
// init logging
|
// init logging
|
||||||
logging::init_async();
|
logging::init_sync();
|
||||||
logging::log->pipe(std::make_unique<Stdout>());
|
logging::log->pipe(std::make_unique<Stdout>());
|
||||||
|
auto log = logging::log->logger("test");
|
||||||
|
log.info("bla");
|
||||||
|
|
||||||
// init db, functions and stripper
|
// init db, functions and stripper
|
||||||
Db db;
|
Db db;
|
||||||
@ -42,11 +46,17 @@ int main(int argc, char *argv[])
|
|||||||
// execute all queries
|
// execute all queries
|
||||||
for (auto &query : queries)
|
for (auto &query : queries)
|
||||||
{
|
{
|
||||||
|
if (query.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
utils::println("");
|
||||||
utils::println("Query: ", query);
|
utils::println("Query: ", query);
|
||||||
|
|
||||||
auto stripped = stripper.strip(query);
|
auto stripped = stripper.strip(query);
|
||||||
utils::println("Hash: ", stripped.hash);
|
utils::println("Hash: ", stripped.hash);
|
||||||
|
|
||||||
|
utils::println("------------------------");
|
||||||
|
|
||||||
// TODO: more robust solution (enum like)
|
// TODO: more robust solution (enum like)
|
||||||
if (work_mode == "hash_generation") continue;
|
if (work_mode == "hash_generation") continue;
|
||||||
|
|
||||||
@ -54,7 +64,7 @@ int main(int argc, char *argv[])
|
|||||||
query_functions[stripped.hash](std::move(stripped.arguments));
|
query_functions[stripped.hash](std::move(stripped.arguments));
|
||||||
permanent_assert(result == true,
|
permanent_assert(result == true,
|
||||||
"Result retured from query function is not true");
|
"Result retured from query function is not true");
|
||||||
utils::println("------------------------ PASS");
|
utils::println("------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "logging/default.hpp"
|
#include "logging/default.hpp"
|
||||||
#include "logging/streams/stdout.hpp"
|
#include "logging/streams/stdout.hpp"
|
||||||
#include "query/hardcode/basic.hpp"
|
#include "_hardcoded_query/basic.hpp"
|
||||||
#include "query/strip/stripper.hpp"
|
#include "query/strip/stripper.hpp"
|
||||||
#include "storage/indexes/indexes.hpp"
|
#include "storage/indexes/indexes.hpp"
|
||||||
#include "utils/sysinfo/memory.hpp"
|
#include "utils/sysinfo/memory.hpp"
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "query/backend/cpp_old/cypher.hpp"
|
|
||||||
|
|
||||||
using ParameterIndexKey::Type::InternalId;
|
|
||||||
using ParameterIndexKey::Type::Projection;
|
|
||||||
|
|
||||||
auto main() -> int
|
|
||||||
{
|
|
||||||
CppGenerator generator;
|
|
||||||
|
|
||||||
// MATCH
|
|
||||||
generator.add_action(QueryAction::Match);
|
|
||||||
|
|
||||||
auto& data_match = generator.action_data();
|
|
||||||
data_match.actions["n1"] = ClauseAction::MatchNode;
|
|
||||||
data_match.actions["n2"] = ClauseAction::MatchNode;
|
|
||||||
|
|
||||||
// CREATE
|
|
||||||
generator.add_action(QueryAction::Create);
|
|
||||||
|
|
||||||
auto& data_create = generator.action_data();
|
|
||||||
data_create.actions["r"] = ClauseAction::CreateRelationship;
|
|
||||||
|
|
||||||
// RETURN
|
|
||||||
generator.add_action(QueryAction::Return);
|
|
||||||
|
|
||||||
auto& data_return = generator.action_data();
|
|
||||||
data_return.actions["r"] = ClauseAction::ReturnRelationship;
|
|
||||||
|
|
||||||
generator.generate();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
|
||||||
#include "database/db.hpp"
|
|
||||||
#include "logging/default.hpp"
|
|
||||||
#include "logging/streams/stdout.hpp"
|
|
||||||
#include "query/hardcode/basic.hpp"
|
|
||||||
#include "query/hardcode/dressipi.hpp"
|
|
||||||
#include "query/strip/stripper.hpp"
|
|
||||||
#include "storage/edges.cpp"
|
|
||||||
#include "storage/edges.hpp"
|
|
||||||
#include "storage/vertices.cpp"
|
|
||||||
#include "storage/vertices.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
logging::init_async();
|
|
||||||
logging::log->pipe(std::make_unique<Stdout>());
|
|
||||||
|
|
||||||
Db db;
|
|
||||||
auto queries = hardcode::load_basic_functions(db);
|
|
||||||
|
|
||||||
auto stripper = make_query_stripper(TK_LONG, TK_FLOAT, TK_STR, TK_BOOL);
|
|
||||||
|
|
||||||
vector<string> history;
|
|
||||||
string command;
|
|
||||||
cout << "-- Memgraph query engine --" << endl;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
|
|
||||||
cout << "> ";
|
|
||||||
getline(cin, command);
|
|
||||||
history.push_back(command);
|
|
||||||
auto stripped = stripper.strip(command);
|
|
||||||
|
|
||||||
if (queries.find(stripped.hash) == queries.end())
|
|
||||||
{
|
|
||||||
cout << "unsupported query" << endl;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto result = queries[stripped.hash](std::move(stripped.arguments));
|
|
||||||
cout << "RETURN: " << result << endl;
|
|
||||||
|
|
||||||
} while (command != "quit");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user