From 12b4ec1589265d6598aa768d74442c83c9dd3507 Mon Sep 17 00:00:00 2001 From: jbajic Date: Tue, 22 Feb 2022 13:33:45 +0100 Subject: [PATCH] Add memgraph namespace --- .githooks/pre-commit | 4 +- src/audit/log.cpp | 4 +- src/audit/log.hpp | 4 +- src/auth/auth.cpp | 4 +- src/auth/auth.hpp | 4 +- src/auth/crypto.cpp | 4 +- src/auth/crypto.hpp | 4 +- src/auth/exceptions.hpp | 4 +- src/auth/models.cpp | 2 + src/auth/models.hpp | 2 + src/auth/module.cpp | 6 +- src/auth/module.hpp | 4 +- src/communication/bolt/client.hpp | 6 +- src/communication/bolt/v1/codes.hpp | 6 +- src/communication/bolt/v1/constants.hpp | 6 +- .../v1/decoder/chunked_decoder_buffer.hpp | 6 +- src/communication/bolt/v1/decoder/decoder.hpp | 6 +- .../bolt/v1/encoder/base_encoder.hpp | 6 +- .../v1/encoder/chunked_encoder_buffer.hpp | 6 +- .../bolt/v1/encoder/client_encoder.hpp | 6 +- src/communication/bolt/v1/encoder/encoder.hpp | 6 +- src/communication/bolt/v1/exceptions.hpp | 6 +- src/communication/bolt/v1/session.hpp | 6 +- src/communication/bolt/v1/state.hpp | 6 +- src/communication/bolt/v1/states/error.hpp | 6 +- .../bolt/v1/states/executing.hpp | 6 +- src/communication/bolt/v1/states/handlers.hpp | 6 +- .../bolt/v1/states/handshake.hpp | 6 +- src/communication/bolt/v1/states/init.hpp | 6 +- src/communication/bolt/v1/value.cpp | 6 +- src/communication/bolt/v1/value.hpp | 6 +- src/communication/buffer.cpp | 6 +- src/communication/buffer.hpp | 6 +- src/communication/client.cpp | 6 +- src/communication/client.hpp | 8 +- src/communication/context.cpp | 4 +- src/communication/context.hpp | 4 +- src/communication/exceptions.hpp | 6 +- src/communication/helpers.cpp | 6 +- src/communication/helpers.hpp | 6 +- src/communication/init.cpp | 6 +- src/communication/init.hpp | 6 +- src/communication/listener.hpp | 6 +- src/communication/result_stream_faker.hpp | 30 +- src/communication/server.hpp | 8 +- src/communication/session.hpp | 6 +- src/communication/websocket/auth.cpp | 4 +- src/communication/websocket/auth.hpp | 4 +- src/communication/websocket/listener.cpp | 4 +- src/communication/websocket/listener.hpp | 4 +- src/communication/websocket/server.cpp | 4 +- src/communication/websocket/server.hpp | 4 +- src/communication/websocket/session.cpp | 4 +- src/communication/websocket/session.hpp | 6 +- src/data_structures/ring_buffer.hpp | 10 +- src/glue/auth.cpp | 48 +- src/glue/auth.hpp | 10 +- src/glue/communication.cpp | 75 +- src/glue/communication.hpp | 22 +- src/integrations/constants.hpp | 6 +- src/integrations/kafka/consumer.cpp | 4 +- src/integrations/kafka/consumer.hpp | 4 +- src/integrations/kafka/exceptions.hpp | 4 +- src/integrations/pulsar/consumer.cpp | 6 +- src/integrations/pulsar/consumer.hpp | 6 +- src/integrations/pulsar/exceptions.hpp | 6 +- src/io/network/addrinfo.cpp | 6 +- src/io/network/addrinfo.hpp | 6 +- src/io/network/endpoint.cpp | 6 +- src/io/network/endpoint.hpp | 6 +- src/io/network/epoll.hpp | 6 +- src/io/network/network_error.hpp | 6 +- src/io/network/serialization.hpp | 22 +- src/io/network/socket.cpp | 6 +- src/io/network/socket.hpp | 6 +- src/io/network/stream_buffer.hpp | 6 +- src/io/network/utils.cpp | 6 +- src/io/network/utils.hpp | 6 +- src/kvstore/kvstore.cpp | 6 +- src/kvstore/kvstore.hpp | 6 +- src/kvstore/kvstore_dummy.cpp | 6 +- src/lisp/lcp.lisp | 10 +- src/lisp/slk.lisp | 34 +- src/lisp/test.lisp | 156 +- src/lisp/types.lisp | 12 +- src/memgraph.cpp | 469 +-- src/memory/memory_control.cpp | 6 +- src/memory/memory_control.hpp | 6 +- src/memory/new_delete.cpp | 18 +- src/mg_import_csv.cpp | 120 +- src/py/py.hpp | 6 +- src/query/auth_checker.hpp | 12 +- src/query/common.cpp | 6 +- src/query/common.hpp | 6 +- src/query/config.hpp | 6 +- src/query/constants.hpp | 6 +- src/query/context.hpp | 6 +- src/query/cypher_query_interpreter.cpp | 13 +- src/query/cypher_query_interpreter.hpp | 4 +- src/query/db_accessor.hpp | 14 +- src/query/discard_value_stream.hpp | 8 +- src/query/dump.cpp | 44 +- src/query/dump.hpp | 14 +- src/query/exceptions.hpp | 6 +- src/query/frontend/ast/ast.lcp | 134 +- src/query/frontend/ast/ast_visitor.hpp | 20 +- .../frontend/ast/cypher_main_visitor.cpp | 10 +- .../frontend/ast/cypher_main_visitor.hpp | 4 +- src/query/frontend/ast/pretty_print.cpp | 6 +- src/query/frontend/ast/pretty_print.hpp | 6 +- src/query/frontend/opencypher/parser.hpp | 8 +- src/query/frontend/parsing.cpp | 6 +- src/query/frontend/parsing.hpp | 6 +- .../frontend/semantic/required_privileges.cpp | 4 +- .../frontend/semantic/required_privileges.hpp | 4 +- src/query/frontend/semantic/symbol.lcp | 8 +- .../frontend/semantic/symbol_generator.cpp | 6 +- .../frontend/semantic/symbol_generator.hpp | 6 +- src/query/frontend/semantic/symbol_table.hpp | 6 +- src/query/frontend/stripped.cpp | 6 +- src/query/frontend/stripped.hpp | 6 +- .../frontend/stripped_lexer_constants.hpp | 4 +- .../interpret/awesome_memgraph_functions.cpp | 12 +- .../interpret/awesome_memgraph_functions.hpp | 4 +- src/query/interpret/eval.cpp | 6 +- src/query/interpret/eval.hpp | 12 +- src/query/interpret/frame.hpp | 6 +- src/query/interpreter.cpp | 34 +- src/query/interpreter.hpp | 18 +- src/query/metadata.cpp | 6 +- src/query/metadata.hpp | 6 +- src/query/parameters.hpp | 6 +- src/query/path.hpp | 6 +- src/query/plan/cost_estimator.hpp | 8 +- src/query/plan/operator.cpp | 20 +- src/query/plan/operator.lcp | 142 +- src/query/plan/planner.hpp | 8 +- src/query/plan/preprocess.cpp | 14 +- src/query/plan/preprocess.hpp | 6 +- src/query/plan/pretty_print.cpp | 60 +- src/query/plan/pretty_print.hpp | 8 +- src/query/plan/profile.cpp | 6 +- src/query/plan/profile.hpp | 6 +- src/query/plan/read_write_type_checker.cpp | 6 +- src/query/plan/read_write_type_checker.hpp | 6 +- src/query/plan/rewrite/index_lookup.cpp | 6 +- src/query/plan/rewrite/index_lookup.hpp | 6 +- src/query/plan/rule_based_planner.cpp | 6 +- src/query/plan/rule_based_planner.hpp | 30 +- src/query/plan/scoped_profile.hpp | 11 +- src/query/plan/variable_start_planner.cpp | 6 +- src/query/plan/variable_start_planner.hpp | 6 +- src/query/plan/vertex_count_cache.hpp | 26 +- src/query/procedure/cypher_type_ptr.hpp | 6 +- src/query/procedure/cypher_types.hpp | 42 +- src/query/procedure/mg_procedure_helpers.cpp | 6 +- src/query/procedure/mg_procedure_helpers.hpp | 6 +- src/query/procedure/mg_procedure_impl.cpp | 637 ++-- src/query/procedure/mg_procedure_impl.hpp | 418 ++- src/query/procedure/module.cpp | 4 +- src/query/procedure/module.hpp | 4 +- src/query/procedure/py_module.cpp | 4 +- src/query/procedure/py_module.hpp | 8 +- src/query/serialization/property_value.cpp | 6 +- src/query/serialization/property_value.hpp | 6 +- src/query/stream.hpp | 6 +- src/query/stream/common.cpp | 6 +- src/query/stream/common.hpp | 6 +- src/query/stream/sources.cpp | 4 +- src/query/stream/sources.hpp | 4 +- src/query/stream/streams.cpp | 6 +- src/query/stream/streams.hpp | 4 +- src/query/trigger.cpp | 14 +- src/query/trigger.hpp | 14 +- src/query/trigger_context.cpp | 11 +- src/query/trigger_context.hpp | 6 +- src/query/typed_value.cpp | 6 +- src/query/typed_value.hpp | 6 +- src/requests/requests.cpp | 6 +- src/requests/requests.hpp | 6 +- src/rpc/client.cpp | 6 +- src/rpc/client.hpp | 32 +- src/rpc/client_pool.hpp | 6 +- src/rpc/exceptions.hpp | 6 +- src/rpc/messages.hpp | 6 +- src/rpc/protocol.cpp | 6 +- src/rpc/protocol.hpp | 6 +- src/rpc/server.cpp | 6 +- src/rpc/server.hpp | 15 +- src/slk/serialization.hpp | 14 +- src/slk/streams.cpp | 6 +- src/slk/streams.hpp | 6 +- src/storage/v2/commit_log.cpp | 6 +- src/storage/v2/commit_log.hpp | 6 +- src/storage/v2/config.hpp | 6 +- src/storage/v2/constraints.cpp | 6 +- src/storage/v2/constraints.hpp | 6 +- src/storage/v2/delta.hpp | 4 +- src/storage/v2/durability/durability.cpp | 9 +- src/storage/v2/durability/durability.hpp | 6 +- src/storage/v2/durability/exceptions.hpp | 6 +- src/storage/v2/durability/marker.hpp | 6 +- src/storage/v2/durability/metadata.hpp | 6 +- src/storage/v2/durability/paths.hpp | 6 +- src/storage/v2/durability/serialization.cpp | 6 +- src/storage/v2/durability/serialization.hpp | 6 +- src/storage/v2/durability/snapshot.cpp | 6 +- src/storage/v2/durability/snapshot.hpp | 6 +- src/storage/v2/durability/version.hpp | 6 +- src/storage/v2/durability/wal.cpp | 6 +- src/storage/v2/durability/wal.hpp | 6 +- src/storage/v2/edge.hpp | 6 +- src/storage/v2/edge_accessor.cpp | 6 +- src/storage/v2/edge_accessor.hpp | 10 +- src/storage/v2/edge_ref.hpp | 6 +- src/storage/v2/id_types.hpp | 22 +- src/storage/v2/indices.cpp | 6 +- src/storage/v2/indices.hpp | 6 +- src/storage/v2/isolation_level.hpp | 6 +- src/storage/v2/mvcc.hpp | 6 +- src/storage/v2/name_id_mapper.hpp | 6 +- src/storage/v2/property_store.cpp | 6 +- src/storage/v2/property_store.hpp | 10 +- src/storage/v2/property_value.hpp | 6 +- src/storage/v2/replication/config.hpp | 6 +- src/storage/v2/replication/enums.hpp | 6 +- .../v2/replication/replication_client.cpp | 28 +- .../v2/replication/replication_client.hpp | 18 +- .../v2/replication/replication_server.cpp | 77 +- .../v2/replication/replication_server.hpp | 16 +- src/storage/v2/replication/rpc.lcp | 8 +- src/storage/v2/replication/serialization.cpp | 34 +- src/storage/v2/replication/serialization.hpp | 14 +- src/storage/v2/replication/slk.cpp | 166 +- src/storage/v2/replication/slk.hpp | 22 +- src/storage/v2/result.hpp | 6 +- src/storage/v2/storage.cpp | 8 +- src/storage/v2/storage.hpp | 6 +- src/storage/v2/temporal.cpp | 6 +- src/storage/v2/temporal.hpp | 6 +- src/storage/v2/transaction.hpp | 6 +- src/storage/v2/vertex.hpp | 6 +- src/storage/v2/vertex_accessor.cpp | 6 +- src/storage/v2/vertex_accessor.hpp | 10 +- src/storage/v2/view.hpp | 6 +- src/telemetry/collectors.cpp | 6 +- src/telemetry/collectors.hpp | 6 +- src/telemetry/system_info.cpp | 6 +- src/telemetry/system_info.hpp | 6 +- src/telemetry/telemetry.cpp | 6 +- src/telemetry/telemetry.hpp | 6 +- src/utils/algorithm.hpp | 6 +- src/utils/async_timer.cpp | 8 +- src/utils/async_timer.hpp | 6 +- src/utils/base64.cpp | 6 +- src/utils/base64.hpp | 6 +- src/utils/bound.hpp | 6 +- src/utils/cache.hpp | 6 +- src/utils/cast.hpp | 6 +- src/utils/concepts.hpp | 6 +- src/utils/csv_parsing.cpp | 6 +- src/utils/csv_parsing.hpp | 6 +- src/utils/endian.hpp | 6 +- src/utils/exceptions.hpp | 6 +- src/utils/file.cpp | 6 +- src/utils/file.hpp | 6 +- src/utils/file_locker.cpp | 6 +- src/utils/file_locker.hpp | 6 +- src/utils/fnv.hpp | 6 +- src/utils/license.cpp | 24 +- src/utils/license.hpp | 6 +- src/utils/linux.hpp | 6 +- src/utils/logging.hpp | 8 +- src/utils/math.hpp | 6 +- src/utils/memory.cpp | 6 +- src/utils/memory.hpp | 6 +- src/utils/memory_tracker.cpp | 6 +- src/utils/memory_tracker.hpp | 6 +- src/utils/message.hpp | 6 +- src/utils/on_scope_exit.hpp | 6 +- src/utils/pmr/list.hpp | 6 +- src/utils/pmr/map.hpp | 6 +- src/utils/pmr/string.hpp | 6 +- src/utils/pmr/unordered_map.hpp | 6 +- src/utils/pmr/unordered_set.hpp | 6 +- src/utils/pmr/vector.hpp | 6 +- src/utils/readable_size.cpp | 6 +- src/utils/readable_size.hpp | 6 +- src/utils/result.hpp | 6 +- src/utils/rw_lock.hpp | 6 +- src/utils/scheduler.hpp | 6 +- src/utils/settings.cpp | 6 +- src/utils/settings.hpp | 6 +- src/utils/signals.cpp | 6 +- src/utils/signals.hpp | 6 +- src/utils/skip_list.hpp | 6 +- src/utils/small_vector.hpp | 18 +- src/utils/spin_lock.hpp | 6 +- src/utils/stack.hpp | 6 +- src/utils/stacktrace.hpp | 6 +- src/utils/stat.hpp | 6 +- src/utils/string.hpp | 6 +- src/utils/synchronized.hpp | 6 +- src/utils/sysinfo/memory.cpp | 6 +- src/utils/sysinfo/memory.hpp | 6 +- src/utils/temporal.cpp | 18 +- src/utils/temporal.hpp | 4 +- src/utils/terminate_handler.hpp | 6 +- src/utils/thread.cpp | 6 +- src/utils/thread.hpp | 6 +- src/utils/thread_pool.cpp | 6 +- src/utils/thread_pool.hpp | 6 +- src/utils/timer.hpp | 6 +- src/utils/timestamp.hpp | 6 +- src/utils/tsc.cpp | 4 +- src/utils/tsc.hpp | 4 +- src/utils/typeinfo.hpp | 6 +- src/utils/uuid.cpp | 6 +- src/utils/uuid.hpp | 6 +- src/utils/variant_helpers.hpp | 6 +- src/utils/visitor.hpp | 6 +- tests/benchmark/expansion.cpp | 10 +- tests/benchmark/query/eval.cpp | 52 +- tests/benchmark/query/execution.cpp | 276 +- tests/benchmark/query/planner.cpp | 107 +- tests/benchmark/query/profile.cpp | 18 +- tests/benchmark/query/stripped.cpp | 4 +- tests/benchmark/rpc.cpp | 36 +- tests/benchmark/skip_list_random.cpp | 4 +- tests/benchmark/skip_list_real_world.cpp | 4 +- tests/benchmark/skip_list_same_item.cpp | 4 +- tests/benchmark/skip_list_vs_stl.cpp | 76 +- tests/benchmark/storage_v2_gc.cpp | 32 +- tests/benchmark/storage_v2_property_store.cpp | 30 +- tests/concurrent/network_common.hpp | 18 +- tests/concurrent/network_read_hang.cpp | 18 +- tests/concurrent/skip_list_insert.cpp | 4 +- .../skip_list_insert_competitive.cpp | 4 +- tests/concurrent/skip_list_mixed.cpp | 4 +- tests/concurrent/skip_list_remove.cpp | 4 +- .../skip_list_remove_competitive.cpp | 4 +- tests/concurrent/spin_lock.cpp | 6 +- tests/concurrent/stack.cpp | 6 +- tests/concurrent/storage_indices.cpp | 34 +- .../concurrent/storage_unique_constraints.cpp | 37 +- .../e2e/isolation_levels/isolation_levels.cpp | 4 +- tests/e2e/memory/memory_control.cpp | 4 +- .../e2e/memory/memory_limit_global_alloc.cpp | 4 +- .../memory/memory_limit_global_alloc_proc.cpp | 2 +- .../module_file_manager.cpp | 4 +- tests/e2e/replication/common.hpp | 12 +- tests/e2e/replication/constraints.cpp | 6 +- .../e2e/replication/read_write_benchmark.cpp | 12 +- tests/e2e/temporal_types/roundtrip.cpp | 90 +- tests/e2e/triggers/common.cpp | 4 +- tests/e2e/triggers/on_create_triggers.cpp | 4 +- tests/e2e/triggers/on_delete_triggers.cpp | 2 +- tests/e2e/triggers/on_update_triggers.cpp | 2 +- tests/e2e/triggers/privilige_check.cpp | 2 +- tests/e2e/websocket/websocket.cpp | 2 +- tests/e2e/websocket/websocket_ssl.cpp | 2 +- tests/integration/audit/tester.cpp | 21 +- tests/integration/auth/checker.cpp | 12 +- tests/integration/auth/tester.cpp | 12 +- tests/integration/ldap/tester.cpp | 14 +- tests/integration/mg_import_csv/tester.cpp | 12 +- tests/integration/ssl/tester.cpp | 25 +- tests/integration/telemetry/client.cpp | 7 +- tests/integration/transactions/tester.cpp | 11 +- .../clients/bfs_pokec_client.cpp | 10 +- tests/macro_benchmark/clients/bolt_client.hpp | 12 +- .../clients/card_fraud_client.cpp | 16 +- tests/macro_benchmark/clients/common.hpp | 24 +- .../clients/long_running_common.hpp | 26 +- .../macro_benchmark/clients/pokec_client.cpp | 18 +- .../macro_benchmark/clients/query_client.cpp | 19 +- tests/manual/antlr_sigsegv.cpp | 10 +- tests/manual/bolt_client.cpp | 14 +- tests/manual/expression_pretty_printer.cpp | 20 +- tests/manual/interactive_planning.cpp | 99 +- tests/manual/interactive_planning.hpp | 20 +- tests/manual/kvstore_console.cpp | 6 +- tests/manual/query_hash.cpp | 4 +- tests/manual/query_planner.cpp | 6 +- tests/manual/single_query.cpp | 12 +- tests/manual/ssl_client.cpp | 12 +- tests/manual/ssl_server.cpp | 20 +- tests/manual/stripped_timing.cpp | 4 +- tests/mgbench/client.cpp | 39 +- tests/property_based/random_graph.cpp | 16 +- tests/stress/long_running.cpp | 18 +- tests/unit/auth.cpp | 31 +- tests/unit/bfs_common.hpp | 220 +- tests/unit/bfs_single_node.cpp | 27 +- tests/unit/bolt_chunked_decoder_buffer.cpp | 10 +- tests/unit/bolt_chunked_encoder_buffer.cpp | 10 +- tests/unit/bolt_decoder.cpp | 98 +- tests/unit/bolt_encoder.cpp | 106 +- tests/unit/bolt_session.cpp | 16 +- tests/unit/commit_log_v2.cpp | 10 +- tests/unit/communication_buffer.cpp | 4 +- tests/unit/cypher_main_visitor.cpp | 57 +- tests/unit/formatters.hpp | 67 +- tests/unit/integrations_kafka_consumer.cpp | 4 +- tests/unit/interpreter.cpp | 181 +- tests/unit/kvstore.cpp | 26 +- tests/unit/main.cpp | 4 +- tests/unit/mgp_kafka_c_api.cpp | 10 +- tests/unit/mgp_trans_c_api.cpp | 4 +- tests/unit/network_endpoint.cpp | 8 +- tests/unit/network_timeouts.cpp | 24 +- tests/unit/network_utils.cpp | 4 +- tests/unit/plan_pretty_print.cpp | 69 +- tests/unit/property_value_v2.cpp | 489 +-- tests/unit/query_common.hpp | 216 +- tests/unit/query_cost_estimator.cpp | 46 +- tests/unit/query_dump.cpp | 357 +- tests/unit/query_expression_evaluator.cpp | 194 +- tests/unit/query_plan.cpp | 200 +- .../unit/query_plan_accumulate_aggregate.cpp | 122 +- tests/unit/query_plan_bag_semantics.cpp | 115 +- tests/unit/query_plan_checker.hpp | 91 +- tests/unit/query_plan_common.hpp | 36 +- .../query_plan_create_set_remove_delete.cpp | 433 +-- tests/unit/query_plan_edge_cases.cpp | 10 +- tests/unit/query_plan_match_filter_return.cpp | 504 +-- .../unit/query_plan_read_write_typecheck.cpp | 37 +- ...query_plan_v2_create_set_remove_delete.cpp | 64 +- tests/unit/query_pretty_print.cpp | 42 +- tests/unit/query_procedure_mgp_module.cpp | 20 +- tests/unit/query_procedure_mgp_type.cpp | 83 +- tests/unit/query_procedure_py_module.cpp | 108 +- tests/unit/query_procedures_mgp_graph.cpp | 223 +- tests/unit/query_profile.cpp | 4 +- tests/unit/query_required_privileges.cpp | 2 +- tests/unit/query_semantic.cpp | 198 +- .../query_serialization_property_value.cpp | 69 +- tests/unit/query_streams.cpp | 46 +- tests/unit/query_trigger.cpp | 660 ++-- tests/unit/query_variable_start_planner.cpp | 93 +- tests/unit/ring_buffer.cpp | 6 +- tests/unit/rpc.cpp | 100 +- tests/unit/rpc_messages.hpp | 38 +- tests/unit/skip_list.cpp | 137 +- tests/unit/slk_advanced.cpp | 138 +- tests/unit/slk_common.hpp | 26 +- tests/unit/slk_core.cpp | 200 +- tests/unit/slk_streams.cpp | 218 +- tests/unit/small_vector.cpp | 66 +- tests/unit/socket.cpp | 14 +- tests/unit/storage_test_utils.cpp | 4 +- tests/unit/storage_test_utils.hpp | 4 +- tests/unit/storage_v2.cpp | 1720 ++++----- tests/unit/storage_v2_constraints.cpp | 4 +- tests/unit/storage_v2_decoder_encoder.cpp | 344 +- tests/unit/storage_v2_durability.cpp | 885 +++-- tests/unit/storage_v2_edge.cpp | 3311 +++++++++-------- tests/unit/storage_v2_gc.cpp | 63 +- tests/unit/storage_v2_indices.cpp | 179 +- tests/unit/storage_v2_isolation_level.cpp | 33 +- tests/unit/storage_v2_name_id_mapper.cpp | 6 +- tests/unit/storage_v2_property_store.cpp | 448 +-- tests/unit/storage_v2_replication.cpp | 279 +- tests/unit/storage_v2_wal_file.cpp | 271 +- tests/unit/stripped.cpp | 10 +- tests/unit/typed_value.cpp | 86 +- tests/unit/utils_algorithm.cpp | 4 +- tests/unit/utils_async_timer.cpp | 4 +- tests/unit/utils_csv_parsing.cpp | 92 +- tests/unit/utils_exceptions.cpp | 10 +- tests/unit/utils_file.cpp | 83 +- tests/unit/utils_file_locker.cpp | 14 +- tests/unit/utils_license.cpp | 37 +- tests/unit/utils_math.cpp | 4 +- tests/unit/utils_memory.cpp | 99 +- tests/unit/utils_memory_tracker.cpp | 18 +- tests/unit/utils_on_scope_exit.cpp | 4 +- tests/unit/utils_rwlock.cpp | 28 +- tests/unit/utils_scheduler.cpp | 4 +- tests/unit/utils_settings.cpp | 20 +- tests/unit/utils_signals.cpp | 10 +- tests/unit/utils_string.cpp | 4 +- tests/unit/utils_synchronized.cpp | 23 +- tests/unit/utils_temporal.cpp | 479 +-- tests/unit/utils_thread_pool.cpp | 4 +- tests/unit/utils_timestamp.cpp | 14 +- tests/unit/websocket.cpp | 12 +- tools/gdb-plugins/operator_tree.py | 4 +- tools/gdb-plugins/pretty_printers.py | 24 +- 489 files changed, 10995 insertions(+), 10420 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index a8d7a7ee7..f9e017bff 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -34,10 +34,8 @@ for file in $modified_files; do echo "Running header checker..." $project_folder/tools/header-checker.py $tmpdir/$file $file --amend-year code=$? + # Do not break header checker - if [ $code -ne 0 ]; then - break - fi done; return $code diff --git a/src/audit/log.cpp b/src/audit/log.cpp index 0605d38e7..2d9380fb0 100644 --- a/src/audit/log.cpp +++ b/src/audit/log.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Licensed as a Memgraph Enterprise file under the Memgraph Enterprise // License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use @@ -18,6 +18,7 @@ #include "utils/logging.hpp" #include "utils/string.hpp" +namespace memgraph { namespace audit { // Helper function that converts a `storage::PropertyValue` to `nlohmann::json`. @@ -144,3 +145,4 @@ void Log::Flush() { } } // namespace audit +} // namespace memgraph diff --git a/src/audit/log.hpp b/src/audit/log.hpp index 9c515c65c..12d42fbb4 100644 --- a/src/audit/log.hpp +++ b/src/audit/log.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Licensed as a Memgraph Enterprise file under the Memgraph Enterprise // License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use @@ -17,6 +17,7 @@ #include "utils/file.hpp" #include "utils/scheduler.hpp" +namespace memgraph { namespace audit { const uint64_t kBufferSizeDefault = 100000; @@ -72,3 +73,4 @@ class Log { }; } // namespace audit +} // namespace memgraph diff --git a/src/auth/auth.cpp b/src/auth/auth.cpp index a2d8c93a2..76b68bcb4 100644 --- a/src/auth/auth.cpp +++ b/src/auth/auth.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Licensed as a Memgraph Enterprise file under the Memgraph Enterprise // License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use @@ -42,6 +42,7 @@ DEFINE_VALIDATED_int32(auth_module_timeout_ms, 10000, "response from the auth module.", FLAG_IN_RANGE(100, 1800000)); +namespace memgraph { namespace auth { const std::string kUserPrefix = "user:"; @@ -317,3 +318,4 @@ std::vector Auth::AllUsersForRole(const std::string &rolename_orig) } } // namespace auth +} // namespace memgraph diff --git a/src/auth/auth.hpp b/src/auth/auth.hpp index c39ddb459..aab78c90e 100644 --- a/src/auth/auth.hpp +++ b/src/auth/auth.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Licensed as a Memgraph Enterprise file under the Memgraph Enterprise // License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use @@ -18,6 +18,7 @@ #include "kvstore/kvstore.hpp" #include "utils/settings.hpp" +namespace memgraph { namespace auth { /** @@ -164,3 +165,4 @@ class Auth final { auth::Module module_; }; } // namespace auth +} // namespace memgraph diff --git a/src/auth/crypto.cpp b/src/auth/crypto.cpp index fefe79f57..1c4e62168 100644 --- a/src/auth/crypto.cpp +++ b/src/auth/crypto.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Licensed as a Memgraph Enterprise file under the Memgraph Enterprise // License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use @@ -12,6 +12,7 @@ #include "auth/exceptions.hpp" +namespace memgraph { namespace auth { const std::string EncryptPassword(const std::string &password) { @@ -41,3 +42,4 @@ bool VerifyPassword(const std::string &password, const std::string &hash) { } } // namespace auth +} // namespace memgraph diff --git a/src/auth/crypto.hpp b/src/auth/crypto.hpp index f37e03c24..773ddf46f 100644 --- a/src/auth/crypto.hpp +++ b/src/auth/crypto.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Licensed as a Memgraph Enterprise file under the Memgraph Enterprise // License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use @@ -10,6 +10,7 @@ #include +namespace memgraph { namespace auth { /// @throw AuthException if unable to encrypt the password. @@ -19,3 +20,4 @@ const std::string EncryptPassword(const std::string &password); bool VerifyPassword(const std::string &password, const std::string &hash); } // namespace auth +} // namespace memgraph diff --git a/src/auth/exceptions.hpp b/src/auth/exceptions.hpp index 8c58ef972..5c91d7b50 100644 --- a/src/auth/exceptions.hpp +++ b/src/auth/exceptions.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,6 +13,7 @@ #include "utils/exceptions.hpp" +namespace memgraph { namespace auth { /** @@ -24,3 +25,4 @@ class AuthException : public utils::BasicException { using utils::BasicException::BasicException; }; } // namespace auth +} // namespace memgraph diff --git a/src/auth/models.cpp b/src/auth/models.cpp index 179185ce3..4e18b3598 100644 --- a/src/auth/models.cpp +++ b/src/auth/models.cpp @@ -28,6 +28,7 @@ DEFINE_string(auth_password_strength_regex, default_password_regex.data(), "The regular expression that should be used to match the entire " "entered password to ensure its strength."); +namespace memgraph { namespace auth { namespace { @@ -304,3 +305,4 @@ bool operator==(const User &first, const User &second) { first.permissions_ == second.permissions_ && first.role_ == second.role_; } } // namespace auth +} // namespace memgraph diff --git a/src/auth/models.hpp b/src/auth/models.hpp index e3cde4e67..bfb70ae24 100644 --- a/src/auth/models.hpp +++ b/src/auth/models.hpp @@ -13,6 +13,7 @@ #include +namespace memgraph { namespace auth { // These permissions must have values that are applicable for usage in a @@ -155,3 +156,4 @@ class User final { bool operator==(const User &first, const User &second); } // namespace auth +} // namespace memgraph diff --git a/src/auth/module.cpp b/src/auth/module.cpp index f8e8dc1c7..47968128a 100644 --- a/src/auth/module.cpp +++ b/src/auth/module.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Licensed as a Memgraph Enterprise file under the Memgraph Enterprise // License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use @@ -153,7 +153,7 @@ int Target(void *arg) { // process and something really bad could happen. // Get a pointer to the passed arguments. - auto *ta = reinterpret_cast(arg); + auto *ta = reinterpret_cast(arg); // Redirect `stdin` to `/dev/null`. int fd = open("/dev/null", O_RDONLY | O_CLOEXEC); @@ -312,6 +312,7 @@ nlohmann::json GetData(int fd, int timeout_millisec) { } // namespace +namespace memgraph { namespace auth { Module::Module(const std::filesystem::path &module_executable_path) { @@ -448,3 +449,4 @@ void Module::Shutdown() { Module::~Module() { Shutdown(); } } // namespace auth +} // namespace memgraph diff --git a/src/auth/module.hpp b/src/auth/module.hpp index 894226fe8..71ee69302 100644 --- a/src/auth/module.hpp +++ b/src/auth/module.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Licensed as a Memgraph Enterprise file under the Memgraph Enterprise // License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use @@ -16,6 +16,7 @@ #include +namespace memgraph { namespace auth { struct TargetArguments { @@ -71,3 +72,4 @@ class Module final { }; } // namespace auth +} // namespace memgraph diff --git a/src/communication/bolt/client.hpp b/src/communication/bolt/client.hpp index 25da8f37e..c427a3470 100644 --- a/src/communication/bolt/client.hpp +++ b/src/communication/bolt/client.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "utils/exceptions.hpp" #include "utils/logging.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { /// This exception is thrown whenever an error occurs during query execution /// that isn't fatal (eg. mistyped query or some transient error occurred). @@ -315,4 +315,4 @@ class Client final { ChunkedEncoderBuffer encoder_buffer_{output_stream_}; ClientEncoder> encoder_{encoder_buffer_}; }; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/codes.hpp b/src/communication/bolt/v1/codes.hpp index 02a7bf2b7..aa5abd2e0 100644 --- a/src/communication/bolt/v1/codes.hpp +++ b/src/communication/bolt/v1/codes.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace communication::bolt { +namespace memgraph::communication::bolt { static constexpr uint8_t kPreamble[4] = {0x60, 0x60, 0xB0, 0x17}; static constexpr uint8_t kProtocol[4] = {0x00, 0x00, 0x00, 0x01}; @@ -100,4 +100,4 @@ static constexpr Marker MarkerTiny[3] = {Marker::TinyString, Marker::TinyList, M static constexpr Marker Marker8[3] = {Marker::String8, Marker::List8, Marker::Map8}; static constexpr Marker Marker16[3] = {Marker::String16, Marker::List16, Marker::Map16}; static constexpr Marker Marker32[3] = {Marker::String32, Marker::List32, Marker::Map32}; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/constants.hpp b/src/communication/bolt/v1/constants.hpp index 8249b4b51..711474db2 100644 --- a/src/communication/bolt/v1/constants.hpp +++ b/src/communication/bolt/v1/constants.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include #include -namespace communication::bolt { +namespace memgraph::communication::bolt { /** * Sizes related to the chunk defined in Bolt protocol. @@ -32,4 +32,4 @@ static constexpr uint16_t kSupportedVersions[] = {0x0100, 0x0400, 0x0401, 0x0403 static constexpr int kPullAll = -1; static constexpr int kPullLast = -1; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/decoder/chunked_decoder_buffer.hpp b/src/communication/bolt/v1/decoder/chunked_decoder_buffer.hpp index 4d268aec6..0d096352b 100644 --- a/src/communication/bolt/v1/decoder/chunked_decoder_buffer.hpp +++ b/src/communication/bolt/v1/decoder/chunked_decoder_buffer.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "communication/bolt/v1/constants.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { /** * This class is used as the return value of the GetChunk function of the @@ -136,4 +136,4 @@ class ChunkedDecoderBuffer { std::vector data_; size_t pos_{0}; }; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/decoder/decoder.hpp b/src/communication/bolt/v1/decoder/decoder.hpp index 23df59067..7c157d187 100644 --- a/src/communication/bolt/v1/decoder/decoder.hpp +++ b/src/communication/bolt/v1/decoder/decoder.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ #include "utils/logging.hpp" #include "utils/temporal.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { /** * Bolt Decoder. @@ -591,4 +591,4 @@ class Decoder { return true; } }; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/encoder/base_encoder.hpp b/src/communication/bolt/v1/encoder/base_encoder.hpp index d09cfa2fd..064cd0f95 100644 --- a/src/communication/bolt/v1/encoder/base_encoder.hpp +++ b/src/communication/bolt/v1/encoder/base_encoder.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ static_assert(std::is_same_v || std::is_same_v { return buffer_.Flush(); } }; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/encoder/encoder.hpp b/src/communication/bolt/v1/encoder/encoder.hpp index e5e3ba5ce..33c8ae06b 100644 --- a/src/communication/bolt/v1/encoder/encoder.hpp +++ b/src/communication/bolt/v1/encoder/encoder.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include "communication/bolt/v1/codes.hpp" #include "communication/bolt/v1/encoder/base_encoder.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { /** * Bolt Encoder. @@ -158,4 +158,4 @@ class Encoder : private BaseEncoder { return buffer_.Flush(); } }; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/exceptions.hpp b/src/communication/bolt/v1/exceptions.hpp index 2dd70ee6c..fac66aba3 100644 --- a/src/communication/bolt/v1/exceptions.hpp +++ b/src/communication/bolt/v1/exceptions.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "utils/exceptions.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { /** * Used to indicate something is wrong with the client but the transaction is @@ -83,4 +83,4 @@ class VerboseError : public utils::BasicException { std::string code_; }; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/session.hpp b/src/communication/bolt/v1/session.hpp index e5aced462..633cb9341 100644 --- a/src/communication/bolt/v1/session.hpp +++ b/src/communication/bolt/v1/session.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,7 +27,7 @@ #include "utils/exceptions.hpp" #include "utils/logging.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { /** * Bolt Session Exception @@ -195,4 +195,4 @@ class Session { } }; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/state.hpp b/src/communication/bolt/v1/state.hpp index 97e1db72e..9b2b27a74 100644 --- a/src/communication/bolt/v1/state.hpp +++ b/src/communication/bolt/v1/state.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace communication::bolt { +namespace memgraph::communication::bolt { /** * This class represents states in execution of the Bolt protocol. @@ -55,4 +55,4 @@ enum class State : uint8_t { */ Close }; -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/states/error.hpp b/src/communication/bolt/v1/states/error.hpp index fad400805..3b37923b7 100644 --- a/src/communication/bolt/v1/states/error.hpp +++ b/src/communication/bolt/v1/states/error.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/likely.hpp" #include "utils/logging.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { /** * Error state run function @@ -95,4 +95,4 @@ State StateErrorRun(TSession &session, State state) { return state; } } -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/states/executing.hpp b/src/communication/bolt/v1/states/executing.hpp index 0a73ec219..54504985b 100644 --- a/src/communication/bolt/v1/states/executing.hpp +++ b/src/communication/bolt/v1/states/executing.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,7 +26,7 @@ #include "utils/logging.hpp" #include "utils/message.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { template State RunHandlerV1(Signature signature, TSession &session, State state, Marker marker) { @@ -118,4 +118,4 @@ State StateExecutingRun(TSession &session, State state) { return State::Close; } } -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/states/handlers.hpp b/src/communication/bolt/v1/states/handlers.hpp index 269c466cc..f89ceae74 100644 --- a/src/communication/bolt/v1/states/handlers.hpp +++ b/src/communication/bolt/v1/states/handlers.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,7 +24,7 @@ #include "utils/logging.hpp" #include "utils/message.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { // TODO: Revise these error messages inline std::pair ExceptionToErrorMessage(const std::exception &e) { if (const auto *verbose = dynamic_cast(&e)) { @@ -415,4 +415,4 @@ State HandleRoute(TSession &session) { } return State::Error; } -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/states/handshake.hpp b/src/communication/bolt/v1/states/handshake.hpp index 33ea0b256..2e2f5b6c0 100644 --- a/src/communication/bolt/v1/states/handshake.hpp +++ b/src/communication/bolt/v1/states/handshake.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ #include "utils/likely.hpp" #include "utils/logging.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { inline bool CopyProtocolInformationIfSupported(uint16_t version, uint8_t *protocol) { const auto *supported_version = std::find(std::begin(kSupportedVersions), std::end(kSupportedVersions), version); @@ -110,4 +110,4 @@ State StateHandshakeRun(TSession &session) { return State::Init; } -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/states/init.hpp b/src/communication/bolt/v1/states/init.hpp index fe003a6bb..adab15d82 100644 --- a/src/communication/bolt/v1/states/init.hpp +++ b/src/communication/bolt/v1/states/init.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "utils/likely.hpp" #include "utils/logging.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { namespace details { template @@ -212,4 +212,4 @@ State StateInitRun(TSession &session) { spdlog::trace("Unsupported bolt version:{}.{})!", session.version_.major, session.version_.minor); return State::Close; } -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/value.cpp b/src/communication/bolt/v1/value.cpp index 1b59d0230..a370f78d5 100644 --- a/src/communication/bolt/v1/value.cpp +++ b/src/communication/bolt/v1/value.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include "utils/algorithm.hpp" #include "utils/string.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { #define DEF_GETTER_BY_VAL(type, value_type, field) \ value_type &Value::Value##type() { \ @@ -461,4 +461,4 @@ std::ostream &operator<<(std::ostream &os, const Value::Type type) { return os << "duration"; } } -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/value.hpp b/src/communication/bolt/v1/value.hpp index dea0c39e8..442e8060d 100644 --- a/src/communication/bolt/v1/value.hpp +++ b/src/communication/bolt/v1/value.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/exceptions.hpp" #include "utils/temporal.hpp" -namespace communication::bolt { +namespace memgraph::communication::bolt { /** Forward declaration of Value class. */ class Value; @@ -282,4 +282,4 @@ std::ostream &operator<<(std::ostream &os, const UnboundedEdge &edge); std::ostream &operator<<(std::ostream &os, const Path &path); std::ostream &operator<<(std::ostream &os, const Value &value); std::ostream &operator<<(std::ostream &os, const Value::Type type); -} // namespace communication::bolt +} // namespace memgraph::communication::bolt diff --git a/src/communication/buffer.cpp b/src/communication/buffer.cpp index 4e96a600f..1878cba4e 100644 --- a/src/communication/buffer.cpp +++ b/src/communication/buffer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include "utils/logging.hpp" -namespace communication { +namespace memgraph::communication { Buffer::Buffer() : data_(kBufferInitialSize, 0), read_end_(this), write_end_(this) {} @@ -77,4 +77,4 @@ void Buffer::Resize(size_t len) { void Buffer::Clear() { have_ = 0; } -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/buffer.hpp b/src/communication/buffer.hpp index 0ab6e8510..9843edc95 100644 --- a/src/communication/buffer.hpp +++ b/src/communication/buffer.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "io/network/stream_buffer.hpp" -namespace communication { +namespace memgraph::communication { /** * @brief Buffer @@ -171,4 +171,4 @@ class Buffer final { ReadEnd read_end_; WriteEnd write_end_; }; -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/client.cpp b/src/communication/client.cpp index 606d2268d..bd7fd6e7f 100644 --- a/src/communication/client.cpp +++ b/src/communication/client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include "communication/helpers.hpp" #include "utils/logging.hpp" -namespace communication { +namespace memgraph::communication { Client::Client(ClientContext *context) : context_(context) {} @@ -239,4 +239,4 @@ bool ClientOutputStream::Write(const uint8_t *data, size_t len, bool have_more) } bool ClientOutputStream::Write(const std::string &str, bool have_more) { return client_.Write(str, have_more); } -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/client.hpp b/src/communication/client.hpp index e7aa71226..851c9f003 100644 --- a/src/communication/client.hpp +++ b/src/communication/client.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,14 +21,14 @@ #include "io/network/endpoint.hpp" #include "io/network/socket.hpp" -namespace communication { +namespace memgraph::communication { /** * This class implements a generic network Client. * It uses blocking sockets and provides an API that can be used to receive/send * data over the network connection. * - * NOTE: If you use this client you **must** create `communication::SSLInit` + * NOTE: If you use this client you **must** create `memgraph::communication::SSLInit` * from the `main` function before using the client! */ class Client final { @@ -167,4 +167,4 @@ class ClientOutputStream final { Client &client_; }; -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/context.cpp b/src/communication/context.cpp index dee0ea519..860ba9adc 100644 --- a/src/communication/context.cpp +++ b/src/communication/context.cpp @@ -13,7 +13,7 @@ #include "utils/logging.hpp" -namespace communication { +namespace memgraph::communication { ClientContext::ClientContext(bool use_ssl) : use_ssl_(use_ssl), ctx_(nullptr) { if (use_ssl_) { @@ -140,4 +140,4 @@ boost::asio::ssl::context &ServerContext::context_clone() { bool ServerContext::use_ssl() const { return ctx_.has_value(); } -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/context.hpp b/src/communication/context.hpp index aa1e0ac89..e99cdacef 100644 --- a/src/communication/context.hpp +++ b/src/communication/context.hpp @@ -17,7 +17,7 @@ #include #include -namespace communication { +namespace memgraph::communication { /** * This class represents a context that should be used with network clients. One @@ -104,4 +104,4 @@ class ServerContext final { std::optional ctx_; }; -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/exceptions.hpp b/src/communication/exceptions.hpp index 624077321..4e4e3fdc7 100644 --- a/src/communication/exceptions.hpp +++ b/src/communication/exceptions.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include "utils/exceptions.hpp" -namespace communication { +namespace memgraph::communication { /** * This exception is thrown to indicate to the communication stack that the @@ -22,4 +22,4 @@ namespace communication { class SessionClosedException : public utils::BasicException { using utils::BasicException::BasicException; }; -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/helpers.cpp b/src/communication/helpers.cpp index d02d6f01e..0f91c0ff6 100644 --- a/src/communication/helpers.cpp +++ b/src/communication/helpers.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include "communication/helpers.hpp" -namespace communication { +namespace memgraph::communication { const std::string SslGetLastError() { char buff[2048]; @@ -21,4 +21,4 @@ const std::string SslGetLastError() { ERR_error_string_n(err, buff, sizeof(buff)); return std::string(buff); } -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/helpers.hpp b/src/communication/helpers.hpp index 8ca21eb36..b82b68a38 100644 --- a/src/communication/helpers.hpp +++ b/src/communication/helpers.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,11 +13,11 @@ #include -namespace communication { +namespace memgraph::communication { /** * This function reads and returns a string describing the last OpenSSL error. */ const std::string SslGetLastError(); -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/init.cpp b/src/communication/init.cpp index e4113be87..7f8aa2a84 100644 --- a/src/communication/init.cpp +++ b/src/communication/init.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/signals.hpp" #include "utils/spin_lock.hpp" -namespace communication { +namespace memgraph::communication { namespace { // OpenSSL before 1.1 did not have a out-of-the-box multithreading support @@ -72,4 +72,4 @@ SSLInit::SSLInit() { } SSLInit::~SSLInit() { Cleanup(); } -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/init.hpp b/src/communication/init.hpp index 315a705d1..188bf50a9 100644 --- a/src/communication/init.hpp +++ b/src/communication/init.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #pragma once -namespace communication { +namespace memgraph::communication { /** * Create this object in each `main` file that uses the Communication stack. It @@ -36,4 +36,4 @@ struct SSLInit { ~SSLInit(); }; -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/listener.hpp b/src/communication/listener.hpp index fbe8477f4..f3a53cb15 100644 --- a/src/communication/listener.hpp +++ b/src/communication/listener.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -28,7 +28,7 @@ #include "utils/spin_lock.hpp" #include "utils/thread.hpp" -namespace communication { +namespace memgraph::communication { /** * This class listens to events on an epoll object and processes them. @@ -273,4 +273,4 @@ class Listener final { const std::string service_name_; const size_t workers_count_; }; -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/result_stream_faker.hpp b/src/communication/result_stream_faker.hpp index 07c0fa7c9..1c899b31b 100644 --- a/src/communication/result_stream_faker.hpp +++ b/src/communication/result_stream_faker.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -29,7 +29,7 @@ */ class ResultStreamFaker { public: - explicit ResultStreamFaker(storage::Storage *store) : store_(store) {} + explicit ResultStreamFaker(memgraph::storage::Storage *store) : store_(store) {} ResultStreamFaker(const ResultStreamFaker &) = delete; ResultStreamFaker &operator=(const ResultStreamFaker &) = delete; @@ -38,25 +38,25 @@ class ResultStreamFaker { void Header(const std::vector &fields) { header_ = fields; } - void Result(const std::vector &values) { results_.push_back(values); } + void Result(const std::vector &values) { results_.push_back(values); } - void Result(const std::vector &values) { - std::vector bvalues; + void Result(const std::vector &values) { + std::vector bvalues; bvalues.reserve(values.size()); for (const auto &value : values) { - auto maybe_value = glue::ToBoltValue(value, *store_, storage::View::NEW); + auto maybe_value = memgraph::glue::ToBoltValue(value, *store_, memgraph::storage::View::NEW); MG_ASSERT(maybe_value.HasValue()); bvalues.push_back(std::move(*maybe_value)); } results_.push_back(std::move(bvalues)); } - void Summary(const std::map &summary) { summary_ = summary; } + void Summary(const std::map &summary) { summary_ = summary; } - void Summary(const std::map &summary) { - std::map bsummary; + void Summary(const std::map &summary) { + std::map bsummary; for (const auto &item : summary) { - auto maybe_value = glue::ToBoltValue(item.second, *store_, storage::View::NEW); + auto maybe_value = memgraph::glue::ToBoltValue(item.second, *store_, memgraph::storage::View::NEW); MG_ASSERT(maybe_value.HasValue()); bsummary.insert({item.first, std::move(*maybe_value)}); } @@ -119,17 +119,17 @@ class ResultStreamFaker { // output the summary os << "Query summary: {"; - utils::PrintIterable(os, results.GetSummary(), ", ", - [&](auto &stream, const auto &kv) { stream << kv.first << ": " << kv.second; }); + memgraph::utils::PrintIterable(os, results.GetSummary(), ", ", + [&](auto &stream, const auto &kv) { stream << kv.first << ": " << kv.second; }); os << "}" << std::endl; return os; } private: - storage::Storage *store_; + memgraph::storage::Storage *store_; // the data that the record stream can accept std::vector header_; - std::vector> results_; - std::map summary_; + std::vector> results_; + std::map summary_; }; diff --git a/src/communication/server.hpp b/src/communication/server.hpp index 8b3a5dc2d..5eb27199d 100644 --- a/src/communication/server.hpp +++ b/src/communication/server.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,7 +27,7 @@ #include "utils/message.hpp" #include "utils/thread.hpp" -namespace communication { +namespace memgraph::communication { /** * Communication server. @@ -40,7 +40,7 @@ namespace communication { * Current Server achitecture: * incoming connection -> server -> listener -> session * - * NOTE: If you use this server you **must** create `communication::SSLInit` + * NOTE: If you use this server you **must** create `memgraph::communication::SSLInit` * from the `main` function before using the server! * * @tparam TSession the server can handle different Sessions, each session @@ -161,4 +161,4 @@ class Server final { const std::string service_name_; }; -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/session.hpp b/src/communication/session.hpp index 3df7331b6..98ab417ef 100644 --- a/src/communication/session.hpp +++ b/src/communication/session.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -33,7 +33,7 @@ #include "utils/on_scope_exit.hpp" #include "utils/spin_lock.hpp" -namespace communication { +namespace memgraph::communication { /** * This is used to provide input to user sessions. All sessions used with the @@ -327,4 +327,4 @@ class Session final { SSL *ssl_{nullptr}; BIO *bio_{nullptr}; }; // namespace communication -} // namespace communication +} // namespace memgraph::communication diff --git a/src/communication/websocket/auth.cpp b/src/communication/websocket/auth.cpp index 89ab35f23..6efa97a08 100644 --- a/src/communication/websocket/auth.cpp +++ b/src/communication/websocket/auth.cpp @@ -13,7 +13,7 @@ #include -namespace communication::websocket { +namespace memgraph::communication::websocket { bool SafeAuth::Authenticate(const std::string &username, const std::string &password) const { return auth_->Lock()->Authenticate(username, password).has_value(); @@ -27,4 +27,4 @@ bool SafeAuth::HasUserPermission(const std::string &username, const auth::Permis } bool SafeAuth::HasAnyUsers() const { return auth_->ReadLock()->HasUsers(); } -} // namespace communication::websocket +} // namespace memgraph::communication::websocket diff --git a/src/communication/websocket/auth.hpp b/src/communication/websocket/auth.hpp index 3bcebe620..b3d59ade7 100644 --- a/src/communication/websocket/auth.hpp +++ b/src/communication/websocket/auth.hpp @@ -17,7 +17,7 @@ #include "utils/spin_lock.hpp" #include "utils/synchronized.hpp" -namespace communication::websocket { +namespace memgraph::communication::websocket { class AuthenticationInterface { public: @@ -41,4 +41,4 @@ class SafeAuth : public AuthenticationInterface { private: utils::Synchronized *auth_; }; -} // namespace communication::websocket +} // namespace memgraph::communication::websocket diff --git a/src/communication/websocket/listener.cpp b/src/communication/websocket/listener.cpp index ec62b0f44..7c8efe203 100644 --- a/src/communication/websocket/listener.cpp +++ b/src/communication/websocket/listener.cpp @@ -11,7 +11,7 @@ #include "communication/websocket/listener.hpp" -namespace communication::websocket { +namespace memgraph::communication::websocket { namespace { void LogError(boost::beast::error_code ec, const std::string_view what) { spdlog::warn("Websocket listener failed on {}: {}", what, ec.message()); @@ -87,4 +87,4 @@ void Listener::OnAccept(boost::beast::error_code ec, tcp::socket socket) { DoAccept(); } -} // namespace communication::websocket +} // namespace memgraph::communication::websocket diff --git a/src/communication/websocket/listener.hpp b/src/communication/websocket/listener.hpp index 1c91ce8fb..9a0ba0dc0 100644 --- a/src/communication/websocket/listener.hpp +++ b/src/communication/websocket/listener.hpp @@ -27,7 +27,7 @@ #include "utils/spin_lock.hpp" #include "utils/synchronized.hpp" -namespace communication::websocket { +namespace memgraph::communication::websocket { class Listener : public std::enable_shared_from_this { using tcp = boost::asio::ip::tcp; @@ -54,4 +54,4 @@ class Listener : public std::enable_shared_from_this { utils::Synchronized>, utils::SpinLock> sessions_; AuthenticationInterface &auth_; }; -} // namespace communication::websocket +} // namespace memgraph::communication::websocket diff --git a/src/communication/websocket/server.cpp b/src/communication/websocket/server.cpp index 4b54ff912..406e3b8ea 100644 --- a/src/communication/websocket/server.cpp +++ b/src/communication/websocket/server.cpp @@ -13,7 +13,7 @@ #include -namespace communication::websocket { +namespace memgraph::communication::websocket { Server::~Server() { MG_ASSERT(!background_thread_ || (ioc_.stopped() && !background_thread_->joinable()), @@ -81,4 +81,4 @@ std::shared_ptr Server::GetLoggingSink() { return sink; } -} // namespace communication::websocket +} // namespace memgraph::communication::websocket diff --git a/src/communication/websocket/server.hpp b/src/communication/websocket/server.hpp index bda046260..18c377a7d 100644 --- a/src/communication/websocket/server.hpp +++ b/src/communication/websocket/server.hpp @@ -22,7 +22,7 @@ #include "communication/websocket/listener.hpp" #include "io/network/endpoint.hpp" -namespace communication::websocket { +namespace memgraph::communication::websocket { class Server final { using tcp = boost::asio::ip::tcp; @@ -65,4 +65,4 @@ class Server final { std::shared_ptr listener_; std::optional background_thread_; }; -} // namespace communication::websocket +} // namespace memgraph::communication::websocket diff --git a/src/communication/websocket/session.cpp b/src/communication/websocket/session.cpp index dc094609e..540cb00c7 100644 --- a/src/communication/websocket/session.cpp +++ b/src/communication/websocket/session.cpp @@ -26,7 +26,7 @@ #include "communication/websocket/auth.hpp" #include "utils/logging.hpp" -namespace communication::websocket { +namespace memgraph::communication::websocket { namespace { void LogError(const boost::beast::error_code ec, const std::string_view what) { spdlog::warn("Websocket session failed on {}: {}", what, ec.message()); @@ -232,4 +232,4 @@ void Session::DoShutdown() { ws_); } -} // namespace communication::websocket +} // namespace memgraph::communication::websocket diff --git a/src/communication/websocket/session.hpp b/src/communication/websocket/session.hpp index 085b648d6..232ef5e15 100644 --- a/src/communication/websocket/session.hpp +++ b/src/communication/websocket/session.hpp @@ -32,7 +32,7 @@ #include "utils/synchronized.hpp" #include "utils/variant_helpers.hpp" -namespace communication::websocket { +namespace memgraph::communication::websocket { class Session : public std::enable_shared_from_this { using tcp = boost::asio::ip::tcp; @@ -78,7 +78,7 @@ class Session : public std::enable_shared_from_this { std::variant CreateWebSocket(tcp::socket &&socket, ServerContext &context); - std::optional ssl_context_; + std::optional> ssl_context_; std::variant ws_; boost::beast::flat_buffer buffer_; std::deque> messages_; @@ -88,4 +88,4 @@ class Session : public std::enable_shared_from_this { bool close_{false}; AuthenticationInterface &auth_; }; -} // namespace communication::websocket +} // namespace memgraph::communication::websocket diff --git a/src/data_structures/ring_buffer.hpp b/src/data_structures/ring_buffer.hpp index d90b030c4..c583d4309 100644 --- a/src/data_structures/ring_buffer.hpp +++ b/src/data_structures/ring_buffer.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -49,7 +49,7 @@ class RingBuffer { void emplace(TArgs &&...args) { while (true) { { - std::lock_guard guard(lock_); + std::lock_guard guard(lock_); if (size_ < capacity_) { buffer_[write_pos_++] = TElement(std::forward(args)...); write_pos_ %= capacity_; @@ -70,7 +70,7 @@ class RingBuffer { * empty, nullopt is returned. */ std::optional pop() { - std::lock_guard guard(lock_); + std::lock_guard guard(lock_); if (size_ == 0) return std::nullopt; size_--; std::optional result(std::move(buffer_[read_pos_++])); @@ -80,7 +80,7 @@ class RingBuffer { /** Removes all elements from the buffer. */ void clear() { - std::lock_guard guard(lock_); + std::lock_guard guard(lock_); read_pos_ = 0; write_pos_ = 0; size_ = 0; @@ -89,7 +89,7 @@ class RingBuffer { private: int capacity_; std::unique_ptr buffer_; - utils::SpinLock lock_; + memgraph::utils::SpinLock lock_; int read_pos_{0}; int write_pos_{0}; int size_{0}; diff --git a/src/glue/auth.cpp b/src/glue/auth.cpp index 5e8c203a0..175382d17 100644 --- a/src/glue/auth.cpp +++ b/src/glue/auth.cpp @@ -11,52 +11,52 @@ #include "glue/auth.hpp" -namespace glue { +namespace memgraph::glue { -auth::Permission PrivilegeToPermission(query::AuthQuery::Privilege privilege) { +auth::Permission PrivilegeToPermission(memgraph::query::AuthQuery::Privilege privilege) { switch (privilege) { - case query::AuthQuery::Privilege::MATCH: + case memgraph::query::AuthQuery::Privilege::MATCH: return auth::Permission::MATCH; - case query::AuthQuery::Privilege::CREATE: + case memgraph::query::AuthQuery::Privilege::CREATE: return auth::Permission::CREATE; - case query::AuthQuery::Privilege::MERGE: + case memgraph::query::AuthQuery::Privilege::MERGE: return auth::Permission::MERGE; - case query::AuthQuery::Privilege::DELETE: + case memgraph::query::AuthQuery::Privilege::DELETE: return auth::Permission::DELETE; - case query::AuthQuery::Privilege::SET: + case memgraph::query::AuthQuery::Privilege::SET: return auth::Permission::SET; - case query::AuthQuery::Privilege::REMOVE: + case memgraph::query::AuthQuery::Privilege::REMOVE: return auth::Permission::REMOVE; - case query::AuthQuery::Privilege::INDEX: + case memgraph::query::AuthQuery::Privilege::INDEX: return auth::Permission::INDEX; - case query::AuthQuery::Privilege::STATS: + case memgraph::query::AuthQuery::Privilege::STATS: return auth::Permission::STATS; - case query::AuthQuery::Privilege::CONSTRAINT: + case memgraph::query::AuthQuery::Privilege::CONSTRAINT: return auth::Permission::CONSTRAINT; - case query::AuthQuery::Privilege::DUMP: + case memgraph::query::AuthQuery::Privilege::DUMP: return auth::Permission::DUMP; - case query::AuthQuery::Privilege::REPLICATION: + case memgraph::query::AuthQuery::Privilege::REPLICATION: return auth::Permission::REPLICATION; - case query::AuthQuery::Privilege::DURABILITY: + case memgraph::query::AuthQuery::Privilege::DURABILITY: return auth::Permission::DURABILITY; - case query::AuthQuery::Privilege::READ_FILE: + case memgraph::query::AuthQuery::Privilege::READ_FILE: return auth::Permission::READ_FILE; - case query::AuthQuery::Privilege::FREE_MEMORY: + case memgraph::query::AuthQuery::Privilege::FREE_MEMORY: return auth::Permission::FREE_MEMORY; - case query::AuthQuery::Privilege::TRIGGER: + case memgraph::query::AuthQuery::Privilege::TRIGGER: return auth::Permission::TRIGGER; - case query::AuthQuery::Privilege::CONFIG: + case memgraph::query::AuthQuery::Privilege::CONFIG: return auth::Permission::CONFIG; - case query::AuthQuery::Privilege::AUTH: + case memgraph::query::AuthQuery::Privilege::AUTH: return auth::Permission::AUTH; - case query::AuthQuery::Privilege::STREAM: + case memgraph::query::AuthQuery::Privilege::STREAM: return auth::Permission::STREAM; - case query::AuthQuery::Privilege::MODULE_READ: + case memgraph::query::AuthQuery::Privilege::MODULE_READ: return auth::Permission::MODULE_READ; - case query::AuthQuery::Privilege::MODULE_WRITE: + case memgraph::query::AuthQuery::Privilege::MODULE_WRITE: return auth::Permission::MODULE_WRITE; - case query::AuthQuery::Privilege::WEBSOCKET: + case memgraph::query::AuthQuery::Privilege::WEBSOCKET: return auth::Permission::WEBSOCKET; } } -} // namespace glue +} // namespace memgraph::glue diff --git a/src/glue/auth.hpp b/src/glue/auth.hpp index bf8c978c0..9b4b92c64 100644 --- a/src/glue/auth.hpp +++ b/src/glue/auth.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -12,12 +12,12 @@ #include "auth/models.hpp" #include "query/frontend/ast/ast.hpp" -namespace glue { +namespace memgraph::glue { /** - * This function converts query::AuthQuery::Privilege to its corresponding + * This function converts memgraph::query::AuthQuery::Privilege to its corresponding * auth::Permission. */ -auth::Permission PrivilegeToPermission(query::AuthQuery::Privilege privilege); +auth::Permission PrivilegeToPermission(memgraph::query::AuthQuery::Privilege privilege); -} // namespace glue +} // namespace memgraph::glue diff --git a/src/glue/communication.cpp b/src/glue/communication.cpp index 9ff58f3ab..da729c9f6 100644 --- a/src/glue/communication.cpp +++ b/src/glue/communication.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,32 +20,32 @@ #include "storage/v2/vertex_accessor.hpp" #include "utils/temporal.hpp" -using communication::bolt::Value; +using memgraph::communication::bolt::Value; -namespace glue { +namespace memgraph::glue { -query::TypedValue ToTypedValue(const Value &value) { +memgraph::query::TypedValue ToTypedValue(const Value &value) { switch (value.type()) { case Value::Type::Null: - return query::TypedValue(); + return memgraph::query::TypedValue(); case Value::Type::Bool: - return query::TypedValue(value.ValueBool()); + return memgraph::query::TypedValue(value.ValueBool()); case Value::Type::Int: - return query::TypedValue(value.ValueInt()); + return memgraph::query::TypedValue(value.ValueInt()); case Value::Type::Double: - return query::TypedValue(value.ValueDouble()); + return memgraph::query::TypedValue(value.ValueDouble()); case Value::Type::String: - return query::TypedValue(value.ValueString()); + return memgraph::query::TypedValue(value.ValueString()); case Value::Type::List: { - std::vector list; + std::vector list; list.reserve(value.ValueList().size()); for (const auto &v : value.ValueList()) list.push_back(ToTypedValue(v)); - return query::TypedValue(std::move(list)); + return memgraph::query::TypedValue(std::move(list)); } case Value::Type::Map: { - std::map map; + std::map map; for (const auto &kv : value.ValueMap()) map.emplace(kv.first, ToTypedValue(kv.second)); - return query::TypedValue(std::move(map)); + return memgraph::query::TypedValue(std::move(map)); } case Value::Type::Vertex: case Value::Type::Edge: @@ -53,39 +53,40 @@ query::TypedValue ToTypedValue(const Value &value) { case Value::Type::Path: throw communication::bolt::ValueException("Unsupported conversion from Value to TypedValue"); case Value::Type::Date: - return query::TypedValue(value.ValueDate()); + return memgraph::query::TypedValue(value.ValueDate()); case Value::Type::LocalTime: - return query::TypedValue(value.ValueLocalTime()); + return memgraph::query::TypedValue(value.ValueLocalTime()); case Value::Type::LocalDateTime: - return query::TypedValue(value.ValueLocalDateTime()); + return memgraph::query::TypedValue(value.ValueLocalDateTime()); case Value::Type::Duration: - return query::TypedValue(value.ValueDuration()); + return memgraph::query::TypedValue(value.ValueDuration()); } } -storage::Result ToBoltVertex(const query::VertexAccessor &vertex, +storage::Result ToBoltVertex(const memgraph::query::VertexAccessor &vertex, const storage::Storage &db, storage::View view) { return ToBoltVertex(vertex.impl_, db, view); } -storage::Result ToBoltEdge(const query::EdgeAccessor &edge, const storage::Storage &db, - storage::View view) { +storage::Result ToBoltEdge(const memgraph::query::EdgeAccessor &edge, + const storage::Storage &db, storage::View view) { return ToBoltEdge(edge.impl_, db, view); } -storage::Result ToBoltValue(const query::TypedValue &value, const storage::Storage &db, storage::View view) { +storage::Result ToBoltValue(const memgraph::query::TypedValue &value, const storage::Storage &db, + storage::View view) { switch (value.type()) { - case query::TypedValue::Type::Null: + case memgraph::query::TypedValue::Type::Null: return Value(); - case query::TypedValue::Type::Bool: + case memgraph::query::TypedValue::Type::Bool: return Value(value.ValueBool()); - case query::TypedValue::Type::Int: + case memgraph::query::TypedValue::Type::Int: return Value(value.ValueInt()); - case query::TypedValue::Type::Double: + case memgraph::query::TypedValue::Type::Double: return Value(value.ValueDouble()); - case query::TypedValue::Type::String: + case memgraph::query::TypedValue::Type::String: return Value(std::string(value.ValueString())); - case query::TypedValue::Type::List: { + case memgraph::query::TypedValue::Type::List: { std::vector values; values.reserve(value.ValueList().size()); for (const auto &v : value.ValueList()) { @@ -95,7 +96,7 @@ storage::Result ToBoltValue(const query::TypedValue &value, const storage } return Value(std::move(values)); } - case query::TypedValue::Type::Map: { + case memgraph::query::TypedValue::Type::Map: { std::map map; for (const auto &kv : value.ValueMap()) { auto maybe_value = ToBoltValue(kv.second, db, view); @@ -104,28 +105,28 @@ storage::Result ToBoltValue(const query::TypedValue &value, const storage } return Value(std::move(map)); } - case query::TypedValue::Type::Vertex: { + case memgraph::query::TypedValue::Type::Vertex: { auto maybe_vertex = ToBoltVertex(value.ValueVertex(), db, view); if (maybe_vertex.HasError()) return maybe_vertex.GetError(); return Value(std::move(*maybe_vertex)); } - case query::TypedValue::Type::Edge: { + case memgraph::query::TypedValue::Type::Edge: { auto maybe_edge = ToBoltEdge(value.ValueEdge(), db, view); if (maybe_edge.HasError()) return maybe_edge.GetError(); return Value(std::move(*maybe_edge)); } - case query::TypedValue::Type::Path: { + case memgraph::query::TypedValue::Type::Path: { auto maybe_path = ToBoltPath(value.ValuePath(), db, view); if (maybe_path.HasError()) return maybe_path.GetError(); return Value(std::move(*maybe_path)); } - case query::TypedValue::Type::Date: + case memgraph::query::TypedValue::Type::Date: return Value(value.ValueDate()); - case query::TypedValue::Type::LocalTime: + case memgraph::query::TypedValue::Type::LocalTime: return Value(value.ValueLocalTime()); - case query::TypedValue::Type::LocalDateTime: + case memgraph::query::TypedValue::Type::LocalDateTime: return Value(value.ValueLocalDateTime()); - case query::TypedValue::Type::Duration: + case memgraph::query::TypedValue::Type::Duration: return Value(value.ValueDuration()); } } @@ -164,7 +165,7 @@ storage::Result ToBoltEdge(const storage::EdgeAccesso return communication::bolt::Edge{id, from, to, type, properties}; } -storage::Result ToBoltPath(const query::Path &path, const storage::Storage &db, +storage::Result ToBoltPath(const memgraph::query::Path &path, const storage::Storage &db, storage::View view) { std::vector vertices; vertices.reserve(path.vertices().size()); @@ -271,4 +272,4 @@ Value ToBoltValue(const storage::PropertyValue &value) { } } -} // namespace glue +} // namespace memgraph::glue diff --git a/src/glue/communication.hpp b/src/glue/communication.hpp index 0eb726245..bcb26fd45 100644 --- a/src/glue/communication.hpp +++ b/src/glue/communication.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,13 +18,13 @@ #include "storage/v2/result.hpp" #include "storage/v2/view.hpp" -namespace storage { +namespace memgraph::storage { class EdgeAccessor; class Storage; class VertexAccessor; -} // namespace storage +} // namespace memgraph::storage -namespace glue { +namespace memgraph::glue { /// @param storage::VertexAccessor for converting to /// communication::bolt::Vertex. @@ -43,26 +43,26 @@ storage::Result ToBoltVertex(const storage::VertexA storage::Result ToBoltEdge(const storage::EdgeAccessor &edge, const storage::Storage &db, storage::View view); -/// @param query::Path for converting to communication::bolt::Path. +/// @param memgraph::query::Path for converting to communication::bolt::Path. /// @param storage::Storage for ToBoltVertex and ToBoltEdge. /// @param storage::View for ToBoltVertex and ToBoltEdge. /// /// @throw std::bad_alloc -storage::Result ToBoltPath(const query::Path &path, const storage::Storage &db, +storage::Result ToBoltPath(const memgraph::query::Path &path, const storage::Storage &db, storage::View view); -/// @param query::TypedValue for converting to communication::bolt::Value. +/// @param memgraph::query::TypedValue for converting to communication::bolt::Value. /// @param storage::Storage for ToBoltVertex and ToBoltEdge. /// @param storage::View for ToBoltVertex and ToBoltEdge. /// /// @throw std::bad_alloc -storage::Result ToBoltValue(const query::TypedValue &value, const storage::Storage &db, - storage::View view); +storage::Result ToBoltValue(const memgraph::query::TypedValue &value, + const storage::Storage &db, storage::View view); -query::TypedValue ToTypedValue(const communication::bolt::Value &value); +memgraph::query::TypedValue ToTypedValue(const communication::bolt::Value &value); communication::bolt::Value ToBoltValue(const storage::PropertyValue &value); storage::PropertyValue ToPropertyValue(const communication::bolt::Value &value); -} // namespace glue +} // namespace memgraph::glue diff --git a/src/integrations/constants.hpp b/src/integrations/constants.hpp index 95782e7e2..3ad963efa 100644 --- a/src/integrations/constants.hpp +++ b/src/integrations/constants.hpp @@ -14,10 +14,12 @@ #include #include -namespace integrations { +namespace memgraph::integrations { + constexpr int64_t kDefaultCheckBatchLimit{1}; constexpr std::chrono::milliseconds kDefaultCheckTimeout{30000}; constexpr std::chrono::milliseconds kMinimumInterval{1}; constexpr int64_t kMinimumSize{1}; const std::string kReducted{""}; -} // namespace integrations + +} // namespace memgraph::integrations diff --git a/src/integrations/kafka/consumer.cpp b/src/integrations/kafka/consumer.cpp index 051e0e4b8..8a2842e66 100644 --- a/src/integrations/kafka/consumer.cpp +++ b/src/integrations/kafka/consumer.cpp @@ -27,7 +27,7 @@ #include "utils/on_scope_exit.hpp" #include "utils/thread.hpp" -namespace integrations::kafka { +namespace memgraph::integrations::kafka { namespace { utils::BasicResult> GetBatch(RdKafka::KafkaConsumer &consumer, @@ -448,4 +448,4 @@ void Consumer::ConsumerRebalanceCb::rebalance_cb(RdKafka::KafkaConsumer *consume } } void Consumer::ConsumerRebalanceCb::set_offset(int64_t offset) { offset_ = offset; } -} // namespace integrations::kafka +} // namespace memgraph::integrations::kafka diff --git a/src/integrations/kafka/consumer.hpp b/src/integrations/kafka/consumer.hpp index 725f03a61..dcc0f8125 100644 --- a/src/integrations/kafka/consumer.hpp +++ b/src/integrations/kafka/consumer.hpp @@ -26,7 +26,7 @@ #include #include "utils/result.hpp" -namespace integrations::kafka { +namespace memgraph::integrations::kafka { /// Wraps the message returned from librdkafka. /// @@ -183,4 +183,4 @@ class Consumer final : public RdKafka::EventCb { std::thread thread_; ConsumerRebalanceCb cb_; }; -} // namespace integrations::kafka +} // namespace memgraph::integrations::kafka diff --git a/src/integrations/kafka/exceptions.hpp b/src/integrations/kafka/exceptions.hpp index 3e8d70285..e17221615 100644 --- a/src/integrations/kafka/exceptions.hpp +++ b/src/integrations/kafka/exceptions.hpp @@ -15,7 +15,7 @@ #include "utils/exceptions.hpp" -namespace integrations::kafka { +namespace memgraph::integrations::kafka { class KafkaStreamException : public utils::BasicException { using utils::BasicException::BasicException; }; @@ -64,4 +64,4 @@ class TopicNotFoundException : public KafkaStreamException { TopicNotFoundException(const std::string_view consumer_name, const std::string_view topic_name) : KafkaStreamException("Kafka consumer {} cannot find topic {}", consumer_name, topic_name) {} }; -} // namespace integrations::kafka +} // namespace memgraph::integrations::kafka diff --git a/src/integrations/pulsar/consumer.cpp b/src/integrations/pulsar/consumer.cpp index 42be39088..109b6b798 100644 --- a/src/integrations/pulsar/consumer.cpp +++ b/src/integrations/pulsar/consumer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,7 +26,7 @@ #include "utils/result.hpp" #include "utils/thread.hpp" -namespace integrations::pulsar { +namespace memgraph::integrations::pulsar { namespace { @@ -284,4 +284,4 @@ void Consumer::StopConsuming() { } } -} // namespace integrations::pulsar +} // namespace memgraph::integrations::pulsar diff --git a/src/integrations/pulsar/consumer.hpp b/src/integrations/pulsar/consumer.hpp index 8a37f5fb0..f3771f1f4 100644 --- a/src/integrations/pulsar/consumer.hpp +++ b/src/integrations/pulsar/consumer.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include -namespace integrations::pulsar { +namespace memgraph::integrations::pulsar { namespace pulsar_client = ::pulsar; @@ -79,4 +79,4 @@ class Consumer final { pulsar_client::MessageId last_message_id_{pulsar_client::MessageId::earliest()}; std::thread thread_; }; -} // namespace integrations::pulsar +} // namespace memgraph::integrations::pulsar diff --git a/src/integrations/pulsar/exceptions.hpp b/src/integrations/pulsar/exceptions.hpp index dbe1a7212..87bb442af 100644 --- a/src/integrations/pulsar/exceptions.hpp +++ b/src/integrations/pulsar/exceptions.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "utils/exceptions.hpp" -namespace integrations::pulsar { +namespace memgraph::integrations::pulsar { class PulsarStreamException : public utils::BasicException { using utils::BasicException::BasicException; }; @@ -55,4 +55,4 @@ class TopicNotFoundException : public PulsarStreamException { TopicNotFoundException(const std::string &consumer_name, const std::string &topic_name) : PulsarStreamException("Pulsar consumer {} cannot find topic {}", consumer_name, topic_name) {} }; -} // namespace integrations::pulsar +} // namespace memgraph::integrations::pulsar diff --git a/src/io/network/addrinfo.cpp b/src/io/network/addrinfo.cpp index b9f947bbc..7b8ce9e9a 100644 --- a/src/io/network/addrinfo.cpp +++ b/src/io/network/addrinfo.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "io/network/network_error.hpp" -namespace io::network { +namespace memgraph::io::network { AddrInfo::AddrInfo(struct addrinfo *info) : info(info) {} @@ -39,4 +39,4 @@ AddrInfo AddrInfo::Get(const char *addr, const char *port) { } AddrInfo::operator struct addrinfo *() { return info; } -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/io/network/addrinfo.hpp b/src/io/network/addrinfo.hpp index e8ebc4457..4828eea8b 100644 --- a/src/io/network/addrinfo.hpp +++ b/src/io/network/addrinfo.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #pragma once -namespace io::network { +namespace memgraph::io::network { /** * Wrapper class for getaddrinfo. @@ -30,4 +30,4 @@ class AddrInfo { private: struct addrinfo *info; }; -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/io/network/endpoint.cpp b/src/io/network/endpoint.cpp index 2e9b8e24b..0a4ee690e 100644 --- a/src/io/network/endpoint.cpp +++ b/src/io/network/endpoint.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "utils/message.hpp" #include "utils/string.hpp" -namespace io::network { +namespace memgraph::io::network { Endpoint::IpFamily Endpoint::GetIpFamily(const std::string &ip_address) { in_addr addr4; @@ -110,4 +110,4 @@ std::ostream &operator<<(std::ostream &os, const Endpoint &endpoint) { return os << endpoint.address << ":" << endpoint.port; } -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/io/network/endpoint.hpp b/src/io/network/endpoint.hpp index 3b586e807..2ddf5b50a 100644 --- a/src/io/network/endpoint.hpp +++ b/src/io/network/endpoint.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include #include -namespace io::network { +namespace memgraph::io::network { /** * This class represents a network endpoint that is used in Socket. @@ -55,4 +55,4 @@ struct Endpoint { static IpFamily GetIpFamily(const std::string &ip_address); }; -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/io/network/epoll.hpp b/src/io/network/epoll.hpp index 31beb4685..09c485eb5 100644 --- a/src/io/network/epoll.hpp +++ b/src/io/network/epoll.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "utils/likely.hpp" #include "utils/logging.hpp" -namespace io::network { +namespace memgraph::io::network { /** * Wrapper class for epoll. @@ -104,4 +104,4 @@ class Epoll { private: const int epoll_fd_; }; -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/io/network/network_error.hpp b/src/io/network/network_error.hpp index 449c7a452..0bc579bcc 100644 --- a/src/io/network/network_error.hpp +++ b/src/io/network/network_error.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,10 +13,10 @@ #include "utils/exceptions.hpp" -namespace io::network { +namespace memgraph::io::network { class NetworkError : public utils::StacktraceException { public: using utils::StacktraceException::StacktraceException; }; -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/io/network/serialization.hpp b/src/io/network/serialization.hpp index 84e3d2ea2..1ef583f01 100644 --- a/src/io/network/serialization.hpp +++ b/src/io/network/serialization.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,18 +14,18 @@ #include "io/network/endpoint.hpp" #include "slk/serialization.hpp" -namespace slk { +namespace memgraph::slk { -inline void Save(const io::network::Endpoint &endpoint, slk::Builder *builder) { - slk::Save(endpoint.address_, builder); - slk::Save(endpoint.port_, builder); - slk::Save(endpoint.family_, builder); +inline void Save(const io::network::Endpoint &endpoint, memgraph::slk::Builder *builder) { + memgraph::slk::Save(endpoint.address_, builder); + memgraph::slk::Save(endpoint.port_, builder); + memgraph::slk::Save(endpoint.family_, builder); } -inline void Load(io::network::Endpoint *endpoint, slk::Reader *reader) { - slk::Load(&endpoint->address_, reader); - slk::Load(&endpoint->port_, reader); - slk::Load(&endpoint->family_, reader); +inline void Load(io::network::Endpoint *endpoint, memgraph::slk::Reader *reader) { + memgraph::slk::Load(&endpoint->address_, reader); + memgraph::slk::Load(&endpoint->port_, reader); + memgraph::slk::Load(&endpoint->family_, reader); } -} // namespace slk +} // namespace memgraph::slk diff --git a/src/io/network/socket.cpp b/src/io/network/socket.cpp index 8760ed6b6..4bc79da2c 100644 --- a/src/io/network/socket.cpp +++ b/src/io/network/socket.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -32,7 +32,7 @@ #include "utils/likely.hpp" #include "utils/logging.hpp" -namespace io::network { +namespace memgraph::io::network { Socket::Socket(Socket &&other) { socket_ = other.socket_; @@ -268,4 +268,4 @@ bool Socket::WaitForReadyWrite() { return p.revents & POLLOUT; } -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/io/network/socket.hpp b/src/io/network/socket.hpp index 570c95dd0..faa127399 100644 --- a/src/io/network/socket.hpp +++ b/src/io/network/socket.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "io/network/endpoint.hpp" -namespace io::network { +namespace memgraph::io::network { /** * This class creates a network socket. @@ -206,4 +206,4 @@ class Socket { int socket_ = -1; Endpoint endpoint_; }; -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/io/network/stream_buffer.hpp b/src/io/network/stream_buffer.hpp index b34ffa574..5ed7fc69e 100644 --- a/src/io/network/stream_buffer.hpp +++ b/src/io/network/stream_buffer.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace io::network { +namespace memgraph::io::network { /** * StreamBuffer @@ -25,4 +25,4 @@ struct StreamBuffer { uint8_t *data; size_t len; }; -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/io/network/utils.cpp b/src/io/network/utils.cpp index b403d0eba..9b9652e15 100644 --- a/src/io/network/utils.cpp +++ b/src/io/network/utils.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ #include "utils/logging.hpp" -namespace io::network { +namespace memgraph::io::network { /// Resolves hostname to ip, if already an ip, just returns it std::string ResolveHostname(std::string hostname) { @@ -68,4 +68,4 @@ bool CanEstablishConnection(const io::network::Endpoint &endpoint) { return client.Connect(endpoint); } -}; // namespace io::network +}; // namespace memgraph::io::network diff --git a/src/io/network/utils.hpp b/src/io/network/utils.hpp index c60cd35b7..7cf2c33a3 100644 --- a/src/io/network/utils.hpp +++ b/src/io/network/utils.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "io/network/endpoint.hpp" -namespace io::network { +namespace memgraph::io::network { /// Resolves hostname to ip, if already an ip, just returns it std::string ResolveHostname(std::string hostname); @@ -27,4 +27,4 @@ std::optional GetHostname(); // Try to establish a connection to a remote host bool CanEstablishConnection(const Endpoint &endpoint); -} // namespace io::network +} // namespace memgraph::io::network diff --git a/src/kvstore/kvstore.cpp b/src/kvstore/kvstore.cpp index c28b41622..d13358d52 100644 --- a/src/kvstore/kvstore.cpp +++ b/src/kvstore/kvstore.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "kvstore/kvstore.hpp" #include "utils/file.hpp" -namespace kvstore { +namespace memgraph::kvstore { struct KVStore::impl { std::filesystem::path storage; @@ -169,4 +169,4 @@ bool KVStore::CompactRange(const std::string &begin_prefix, const std::string &e return s.ok(); } -} // namespace kvstore +} // namespace memgraph::kvstore diff --git a/src/kvstore/kvstore.hpp b/src/kvstore/kvstore.hpp index 1fdd389a3..cefadc485 100644 --- a/src/kvstore/kvstore.hpp +++ b/src/kvstore/kvstore.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/exceptions.hpp" -namespace kvstore { +namespace memgraph::kvstore { class KVStoreError : public utils::BasicException { public: @@ -206,4 +206,4 @@ class KVStore final { std::unique_ptr pimpl_; }; -} // namespace kvstore +} // namespace memgraph::kvstore diff --git a/src/kvstore/kvstore_dummy.cpp b/src/kvstore/kvstore_dummy.cpp index e50f08ead..48c1be2fd 100644 --- a/src/kvstore/kvstore_dummy.cpp +++ b/src/kvstore/kvstore_dummy.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include "utils/file.hpp" #include "utils/logging.hpp" -namespace kvstore { +namespace memgraph::kvstore { struct KVStore::impl {}; @@ -108,4 +108,4 @@ bool KVStore::CompactRange(const std::string &begin_prefix, const std::string &e "dummy kvstore"); } -} // namespace kvstore +} // namespace memgraph::kvstore diff --git a/src/lisp/lcp.lisp b/src/lisp/lcp.lisp index 4f5efae95..63949bdf8 100644 --- a/src/lisp/lcp.lisp +++ b/src/lisp/lcp.lisp @@ -56,7 +56,7 @@ NIL, returns a string." (defun type-info-declaration-for-class (cpp-class) (assert (cpp-type-simple-class-p cpp-class)) (with-output-to-string (s) - (write-line "static const utils::TypeInfo kType;" s) + (write-line "static const memgraph::utils::TypeInfo kType;" s) (let* ((type-info-basep (type-info-opts-base (cpp-class-type-info-opts cpp-class))) (virtual (if (and (or type-info-basep @@ -68,7 +68,7 @@ NIL, returns a string." (cpp-class-super-classes cpp-class)) "override" ""))) - (format s "~A const utils::TypeInfo &GetTypeInfo() const ~A { return kType; }" + (format s "~A const memgraph::utils::TypeInfo &GetTypeInfo() const ~A { return kType; }" virtual override)))) (defun type-info-definition-for-class (cpp-class) @@ -83,7 +83,7 @@ NIL, returns a string." (when (> (length super-classes) 1) (error "Unable to generate TypeInfo for class '~A' due to multiple inheritance!" (cpp-type-name cpp-class))) - (format s "const utils::TypeInfo ~A::kType{0x~XULL, \"~A\", ~A};~%" + (format s "const memgraph::utils::TypeInfo ~A::kType{0x~XULL, \"~A\", ~A};~%" (if *generating-cpp-impl-p* (cpp-type-name cpp-class) ;; Use full type declaration if class definition @@ -344,7 +344,7 @@ LCP-FILE, HPP-FILE, CPP-FILE and SLK-SERIALIZE-P are as in PROCESS-LCP." (write-line "// SLK serialization declarations" out) (write-line "#include \"slk/serialization.hpp\"" out) (with-namespaced-output (out open-namespace) - (open-namespace '("slk")) + (open-namespace '("memgraph::slk")) (dolist (type-for-slk types-for-slk) (ctypecase type-for-slk (cpp-class @@ -383,7 +383,7 @@ LCP-FILE, HPP-FILE, CPP-FILE and SLK-SERIALIZE-P are as in PROCESS-LCP." (remove-if (complement #'cpp-enum-serializep) *cpp-enums*))))) (write-line "// Autogenerated SLK serialization code" out) (with-namespaced-output (out open-namespace) - (open-namespace '("slk")) + (open-namespace '("memgraph::slk")) (dolist (cpp-type types-for-slk) (ctypecase cpp-type (cpp-class diff --git a/src/lisp/slk.lisp b/src/lisp/slk.lisp index bd0f1d026..933794a0c 100644 --- a/src/lisp/slk.lisp +++ b/src/lisp/slk.lisp @@ -58,7 +58,7 @@ generation expects the declarations and definitions to be in `slk` namespace." (let ((self-arg (list (lcp::ensure-namestring-for-variable 'self) (lcp::cpp-type-wrap cpp-class '("const" "&")))) (builder-arg (list (lcp::ensure-namestring-for-variable 'builder) - (lcp::ensure-cpp-type "slk::Builder *")))) + (lcp::ensure-cpp-type "memgraph::slk::Builder *")))) (lcp::cpp-function-declaration "Save" :args (list* self-arg builder-arg (save-extra-args cpp-class)) :type-params (lcp::cpp-type-type-params cpp-class)))) @@ -78,7 +78,7 @@ namespace." (let ((self-arg (list (lcp::ensure-namestring-for-variable 'self) (lcp::cpp-type-wrap cpp-class '("std::unique_ptr" "*")))) (reader-arg (list (lcp::ensure-namestring-for-variable 'reader) - (lcp::ensure-cpp-type "slk::Reader *")))) + (lcp::ensure-cpp-type "memgraph::slk::Reader *")))) (lcp::cpp-function-declaration "ConstructAndLoad" :args (list* self-arg reader-arg (load-extra-args cpp-class)) @@ -97,7 +97,7 @@ generation expects the declarations and definitions to be in `slk` namespace." (let ((self-arg (list (lcp::ensure-namestring-for-variable 'self) (lcp::cpp-type-wrap cpp-class '("*")))) (reader-arg (list (lcp::ensure-namestring-for-variable 'reader) - (lcp::ensure-cpp-type "slk::Reader *")))) + (lcp::ensure-cpp-type "memgraph::slk::Reader *")))) (lcp::cpp-function-declaration "Load" :args (list* self-arg reader-arg (load-extra-args cpp-class)) :type-params (lcp::cpp-type-type-params cpp-class)))) @@ -125,7 +125,7 @@ serializable member has no public access." (lcp::cpp-type-name cpp-class))) ;; TODO: Extra args for cpp-class members (t - (format s "slk::Save(self.~A, builder);~%" member-name))))))) + (format s "memgraph::slk::Save(self.~A, builder);~%" member-name))))))) (defun members-for-load (cpp-class) (remove-if (lambda (m) @@ -155,7 +155,7 @@ serializable member has no public access." (lcp::cpp-type-name cpp-class))) ;; TODO: Extra args for cpp-class members (t - (format s "slk::Load(&self->~A, reader);~%" member-name))))))) + (format s "memgraph::slk::Load(&self->~A, reader);~%" member-name))))))) (defun save-parents-recursively (cpp-class) "Generate code for saving members of all parents, recursively. Raise @@ -220,7 +220,7 @@ CPP-CLASS. Raise `SLK-ERROR' if a derived class has template parameters." (derived-var (lcp::cpp-name-for-variable (lcp::cpp-type-name subclass))) (extra-args (mapcar #'first (save-extra-args cpp-class)))) (format s "if (const auto *~A_derived = utils::Downcast(&self)) { - return slk::Save(*~A_derived, builder~{, ~A~}); }~%" + return memgraph::slk::Save(*~A_derived, builder~{, ~A~}); }~%" derived-var derived-class derived-var extra-args)))))) (defun save-function-code-for-class (cpp-class) @@ -239,14 +239,14 @@ constructs, mostly related to templates." (lcp::cpp-type-name cpp-class)) (progn ;; We aren't abstract, so save our data. - (format s "slk::Save(~A::kType.id, builder);~%" + (format s "memgraph::slk::Save(~A::kType.id, builder);~%" (lcp::cpp-type-decl cpp-class)) (write-string (save-parents-recursively cpp-class) s) (write-string (save-members cpp-class) s)))) (t (when (cpp-class-super-classes-for-slk cpp-class) ;; Write type ID for the (final) derived classes. - (format s "slk::Save(~A::kType.id, builder);~%" + (format s "memgraph::slk::Save(~A::kType.id, builder);~%" (lcp::cpp-type-decl cpp-class))) (write-string (save-parents-recursively cpp-class) s) (write-string (save-members cpp-class) s))))) @@ -268,7 +268,7 @@ constructs, mostly related to templates." (append concrete-classes (concrete-subclasses-rec subclass))))))) (with-output-to-string (s) (write-line "uint64_t type_id;" s) - (write-line "slk::Load(&type_id, reader);" s) + (write-line "memgraph::slk::Load(&type_id, reader);" s) (let ((concrete-classes (concrete-subclasses-rec cpp-class))) (unless (lcp::cpp-class-abstractp cpp-class) (push cpp-class concrete-classes)) @@ -279,9 +279,9 @@ constructs, mostly related to templates." (lcp::with-cpp-block-output (s :name (format nil "if (~A::kType.id == type_id)" type-decl)) (format s "auto ~A_instance = std::make_unique<~A>();~%" var-name type-decl) - (format s "slk::Load(~A_instance.get(), reader~{, ~A~});~%" var-name extra-args) + (format s "memgraph::slk::Load(~A_instance.get(), reader~{, ~A~});~%" var-name extra-args) (format s "*self = std::move(~A_instance); return;~%" var-name)))) - (write-line "throw slk::SlkDecodeException(\"Trying to load unknown derived type!\");" s))))) + (write-line "throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\");" s))))) (defun load-function-code-for-class (cpp-class) "Generate code for serializing CPP-CLASS. Raise `SLK-ERROR' on unsupported C++ @@ -296,7 +296,7 @@ constructs, mostly related to templates." ;; derived ones. (when (lcp::cpp-class-direct-subclasses cpp-class) (format s "if (self->GetTypeInfo() != ~A::kType)~%" (lcp::cpp-type-decl cpp-class)) - (write-line "throw slk::SlkDecodeException(\"Trying to load incorrect derived type!\");" s)) + (write-line "throw memgraph::slk::SlkDecodeException(\"Trying to load incorrect derived type!\");" s)) (write-string (load-parents-recursively cpp-class) s) (write-string (load-members cpp-class) s))) @@ -341,7 +341,7 @@ generation expects the declarations and definitions to be in `slk` namespace." (let ((self-arg (list (lcp::ensure-namestring-for-variable 'self) (lcp::cpp-type-wrap cpp-enum '("const" "&")))) (builder-arg (list (lcp::ensure-namestring-for-variable 'builder) - (lcp::ensure-cpp-type "slk::Builder *")))) + (lcp::ensure-cpp-type "memgraph::slk::Builder *")))) (lcp::cpp-function-declaration "Save" :args (list self-arg builder-arg)))) (defun save-function-code-for-enum (cpp-enum) @@ -354,7 +354,7 @@ generation expects the declarations and definitions to be in `slk` namespace." (lcp::cpp-type-decl cpp-enum) enum-value enum-ix))) - (write-line "slk::Save(enum_value, builder);" s))) + (write-line "memgraph::slk::Save(enum_value, builder);" s))) (defun save-function-definition-for-enum (cpp-enum) "Generate SLK save function. Note that the code generation expects the @@ -372,13 +372,13 @@ generation expects the declarations and definitions to be in `slk` namespace." (let ((self-arg (list (lcp::ensure-namestring-for-variable 'self) (lcp::cpp-type-wrap cpp-enum '("*")))) (reader-arg (list (lcp::ensure-namestring-for-variable 'reader) - (lcp::ensure-cpp-type "slk::Reader *")))) + (lcp::ensure-cpp-type "memgraph::slk::Reader *")))) (lcp::cpp-function-declaration "Load" :args (list self-arg reader-arg)))) (defun load-function-code-for-enum (cpp-enum) (with-output-to-string (s) (write-line "uint8_t enum_value;" s) - (write-line "slk::Load(&enum_value, reader);" s) + (write-line "memgraph::slk::Load(&enum_value, reader);" s) (lcp::with-cpp-block-output (s :name "switch (enum_value)") (loop :for enum-value :in (lcp::cpp-enum-values cpp-enum) :and enum-ix :from 0 :do @@ -386,7 +386,7 @@ generation expects the declarations and definitions to be in `slk` namespace." enum-ix (lcp::cpp-type-decl cpp-enum) enum-value)) - (write-line "default: throw slk::SlkDecodeException(\"Trying to load unknown enum value!\");" s)))) + (write-line "default: throw memgraph::slk::SlkDecodeException(\"Trying to load unknown enum value!\");" s)))) (defun load-function-definition-for-enum (cpp-enum) "Generate SLK save function. Note that the code generation expects the diff --git a/src/lisp/test.lisp b/src/lisp/test.lisp index 41187d132..852101372 100644 --- a/src/lisp/test.lisp +++ b/src/lisp/test.lisp @@ -197,25 +197,25 @@ CPP-TYPE-DECL." (let ((test-struct (lcp:define-struct test-struct () ()))) (is-generated (lcp.slk:save-function-declaration-for-class test-struct) - "void Save(const TestStruct &self, slk::Builder *builder)") + "void Save(const TestStruct &self, memgraph::slk::Builder *builder)") (is-generated (lcp.slk:load-function-declaration-for-class test-struct) - "void Load(TestStruct *self, slk::Reader *reader)")) + "void Load(TestStruct *self, memgraph::slk::Reader *reader)")) (undefine-cpp-types) (let ((derived (lcp:define-class derived (base) ()))) (is-generated (lcp.slk:save-function-declaration-for-class derived) - "void Save(const Derived &self, slk::Builder *builder)") + "void Save(const Derived &self, memgraph::slk::Builder *builder)") (is-generated (lcp.slk:load-function-declaration-for-class derived) - "void Load(Derived *self, slk::Reader *reader)")) + "void Load(Derived *self, memgraph::slk::Reader *reader)")) (undefine-cpp-types) (let ((test-struct (lcp:define-struct test-struct () () (:serialize (:slk :save-args '((extra-arg "SaveArgType")) :load-args '((extra-arg "LoadArgType"))))))) (is-generated (lcp.slk:save-function-declaration-for-class test-struct) - "void Save(const TestStruct &self, slk::Builder *builder, SaveArgType extra_arg)") + "void Save(const TestStruct &self, memgraph::slk::Builder *builder, SaveArgType extra_arg)") (is-generated (lcp.slk:load-function-declaration-for-class test-struct) - "void Load(TestStruct *self, slk::Reader *reader, LoadArgType extra_arg)")) + "void Load(TestStruct *self, memgraph::slk::Reader *reader, LoadArgType extra_arg)")) (undefine-cpp-types) (let ((base-class (lcp:define-struct base () () @@ -225,18 +225,18 @@ CPP-TYPE-DECL." ()))) (declare (ignore base-class)) (is-generated (lcp.slk:save-function-declaration-for-class derived-class) - "void Save(const Derived &self, slk::Builder *builder, SaveArgType extra_arg)") + "void Save(const Derived &self, memgraph::slk::Builder *builder, SaveArgType extra_arg)") (is-generated (lcp.slk:load-function-declaration-for-class derived-class) - "void Load(Derived *self, slk::Reader *reader, LoadArgType extra_arg)") + "void Load(Derived *self, memgraph::slk::Reader *reader, LoadArgType extra_arg)") (is-generated (lcp.slk:construct-and-load-function-declaration-for-class derived-class) - "void ConstructAndLoad(std::unique_ptr *self, slk::Reader *reader, LoadArgType extra_arg)")) + "void ConstructAndLoad(std::unique_ptr *self, memgraph::slk::Reader *reader, LoadArgType extra_arg)")) (undefine-cpp-types) (let ((my-enum (lcp:define-enum my-enum (first-value second-value)))) (is-generated (lcp.slk:save-function-declaration-for-enum my-enum) - "void Save(const MyEnum &self, slk::Builder *builder)") + "void Save(const MyEnum &self, memgraph::slk::Builder *builder)") (is-generated (lcp.slk:load-function-declaration-for-enum my-enum) - "void Load(MyEnum *self, slk::Reader *reader)")) + "void Load(MyEnum *self, memgraph::slk::Reader *reader)")) (undefine-cpp-types) ;; Unsupported multiple inheritance (is-error (lcp.slk:save-function-declaration-for-class @@ -249,7 +249,7 @@ CPP-TYPE-DECL." (lcp:define-class derived (fst-base snd-base) () (:serialize (:slk :ignore-other-base-classes t)))) - "void Save(const Derived &self, slk::Builder *builder)") + "void Save(const Derived &self, memgraph::slk::Builder *builder)") (undefine-cpp-types) ;; Unsupported class templates (is-error (lcp.slk:save-function-declaration-for-class @@ -268,22 +268,22 @@ CPP-TYPE-DECL." (let ((my-enum (lcp:define-enum my-enum (first-value second-value)))) (is-generated (lcp.slk:save-function-definition-for-enum my-enum) - "void Save(const MyEnum &self, slk::Builder *builder) { + "void Save(const MyEnum &self, memgraph::slk::Builder *builder) { uint8_t enum_value; switch (self) { case MyEnum::FIRST_VALUE: enum_value = 0; break; case MyEnum::SECOND_VALUE: enum_value = 1; break; } - slk::Save(enum_value, builder); + memgraph::slk::Save(enum_value, builder); }") (is-generated (lcp.slk:load-function-definition-for-enum my-enum) - "void Load(MyEnum *self, slk::Reader *reader) { + "void Load(MyEnum *self, memgraph::slk::Reader *reader) { uint8_t enum_value; - slk::Load(&enum_value, reader); + memgraph::slk::Load(&enum_value, reader); switch (enum_value) { case static_cast(0): *self = MyEnum::FIRST_VALUE; break; case static_cast(1): *self = MyEnum::SECOND_VALUE; break; - default: throw slk::SlkDecodeException(\"Trying to load unknown enum value!\"); + default: throw memgraph::slk::SlkDecodeException(\"Trying to load unknown enum value!\"); } }"))) @@ -293,22 +293,22 @@ CPP-TYPE-DECL." ((int-member :int64_t) (vec-member "std::vector"))))) (is-generated (lcp.slk:save-function-definition-for-class test-struct) - "void Save(const TestStruct &self, slk::Builder *builder) { - slk::Save(self.int_member, builder); - slk::Save(self.vec_member, builder); + "void Save(const TestStruct &self, memgraph::slk::Builder *builder) { + memgraph::slk::Save(self.int_member, builder); + memgraph::slk::Save(self.vec_member, builder); }") (is-generated (lcp.slk:load-function-definition-for-class test-struct) - "void Load (TestStruct *self, slk::Reader *reader) { - slk::Load(&self->int_member, reader); - slk::Load(&self->vec_member, reader); + "void Load (TestStruct *self, memgraph::slk::Reader *reader) { + memgraph::slk::Load(&self->int_member, reader); + memgraph::slk::Load(&self->vec_member, reader); }")) (undefine-cpp-types) (let ((test-struct (lcp:define-struct test-struct () ((skip-member :int64_t :dont-save t))))) (is-generated (lcp.slk:save-function-definition-for-class test-struct) - "void Save(const TestStruct &self, slk::Builder *builder) {}") + "void Save(const TestStruct &self, memgraph::slk::Builder *builder) {}") (is-generated (lcp.slk:load-function-definition-for-class test-struct) - "void Load(TestStruct *self, slk::Reader *reader) {}")) + "void Load(TestStruct *self, memgraph::slk::Reader *reader) {}")) (undefine-cpp-types) (let ((test-struct (lcp:define-struct test-struct () @@ -320,11 +320,11 @@ CPP-TYPE-DECL." (check-type member-name string) (format nil "self->~A.CustomLoad(reader);" member-name))))))) (is-generated (lcp.slk:save-function-definition-for-class test-struct) - "void Save(const TestStruct &self, slk::Builder *builder) { + "void Save(const TestStruct &self, memgraph::slk::Builder *builder) { { self.custom_member.CustomSave(builder); } }") (is-generated (lcp.slk:load-function-definition-for-class test-struct) - "void Load(TestStruct *self, slk::Reader *reader) { + "void Load(TestStruct *self, memgraph::slk::Reader *reader) { { self->custom_member.CustomLoad(reader); } }")) (undefine-cpp-types) @@ -360,10 +360,10 @@ CPP-TYPE-DECL." :slk-load #'custom-load))))) (dolist (ptr-class (list raw-ptr-class shared-ptr-class unique-ptr-class)) (is-generated (lcp.slk:save-function-definition-for-class ptr-class) - (format nil "void Save(const ~A &self, slk::Builder *builder) { { CustomSave(); } }" + (format nil "void Save(const ~A &self, memgraph::slk::Builder *builder) { { CustomSave(); } }" (lcp::cpp-type-decl ptr-class))) (is-generated (lcp.slk:load-function-definition-for-class ptr-class) - (format nil "void Load(~A *self, slk::Reader *reader) { { CustomLoad(); } }" + (format nil "void Load(~A *self, memgraph::slk::Reader *reader) { { CustomLoad(); } }" (lcp::cpp-type-decl ptr-class))))))) (subtest "class inheritance serialization" @@ -378,61 +378,61 @@ CPP-TYPE-DECL." ;; We will test single inheritance and ignored multiple inheritance, both ;; should generate the same code that follows. (let ((base-save-code - "void Save(const Base &self, slk::Builder *builder) { + "void Save(const Base &self, memgraph::slk::Builder *builder) { if (const auto *derived_derived = utils::Downcast(&self)) { - return slk::Save(*derived_derived, builder); + return memgraph::slk::Save(*derived_derived, builder); } - slk::Save(Base::kType.id, builder); - slk::Save(self.base_member, builder); + memgraph::slk::Save(Base::kType.id, builder); + memgraph::slk::Save(self.base_member, builder); }") (base-construct-code - "void ConstructAndLoad(std::unique_ptr *self, slk::Reader *reader) { + "void ConstructAndLoad(std::unique_ptr *self, memgraph::slk::Reader *reader) { uint64_t type_id; - slk::Load(&type_id, reader); + memgraph::slk::Load(&type_id, reader); if (Base::kType.id == type_id) { auto base_instance = std::make_unique(); - slk::Load(base_instance.get(), reader); + memgraph::slk::Load(base_instance.get(), reader); *self = std::move(base_instance); return; } if (Derived::kType.id == type_id) { auto derived_instance = std::make_unique(); - slk::Load(derived_instance.get(), reader); + memgraph::slk::Load(derived_instance.get(), reader); *self = std::move(derived_instance); return; } - throw slk::SlkDecodeException(\"Trying to load unknown derived type!\"); + throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\"); }") (base-load-code - "void Load(Base *self, slk::Reader *reader) { + "void Load(Base *self, memgraph::slk::Reader *reader) { if (self->GetTypeInfo() != Base::kType) - throw slk::SlkDecodeException(\"Trying to load incorrect derived type!\"); - slk::Load(&self->base_member, reader); + throw memgraph::slk::SlkDecodeException(\"Trying to load incorrect derived type!\"); + memgraph::slk::Load(&self->base_member, reader); }") (derived-save-code - "void Save(const Derived &self, slk::Builder *builder) { - slk::Save(Derived::kType.id, builder); + "void Save(const Derived &self, memgraph::slk::Builder *builder) { + memgraph::slk::Save(Derived::kType.id, builder); // Save parent Base - { slk::Save(self.base_member, builder); } - slk::Save(self.derived_member, builder); + { memgraph::slk::Save(self.base_member, builder); } + memgraph::slk::Save(self.derived_member, builder); }") (derived-construct-code - "void ConstructAndLoad(std::unique_ptr *self, slk::Reader *reader) { + "void ConstructAndLoad(std::unique_ptr *self, memgraph::slk::Reader *reader) { uint64_t type_id; - slk::Load(&type_id, reader); + memgraph::slk::Load(&type_id, reader); if (Derived::kType.id == type_id) { auto derived_instance = std::make_unique(); - slk::Load(derived_instance.get(), reader); + memgraph::slk::Load(derived_instance.get(), reader); *self = std::move(derived_instance); return; } - throw slk::SlkDecodeException(\"Trying to load unknown derived type!\"); + throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\"); }") (derived-load-code - "void Load(Derived *self, slk::Reader *reader) { + "void Load(Derived *self, memgraph::slk::Reader *reader) { // Load parent Base - { slk::Load(&self->base_member, reader); } - slk::Load(&self->derived_member, reader); + { memgraph::slk::Load(&self->base_member, reader); } + memgraph::slk::Load(&self->derived_member, reader); }")) ;; Single inheritance (let ((base-class (lcp:define-struct base () @@ -478,48 +478,48 @@ CPP-TYPE-DECL." (derived-class (lcp:define-struct derived (abstract-base) ((derived-member :int64_t))))) (is-generated (lcp.slk:save-function-definition-for-class abstract-base-class) - "void Save(const AbstractBase &self, slk::Builder *builder) { + "void Save(const AbstractBase &self, memgraph::slk::Builder *builder) { if (const auto *derived_derived = utils::Downcast(&self)) { - return slk::Save(*derived_derived, builder); + return memgraph::slk::Save(*derived_derived, builder); } LOG(FATAL) << \"`AbstractBase` is marked as an abstract class!\"; }") (is-generated (lcp.slk:construct-and-load-function-definition-for-class abstract-base-class) - "void ConstructAndLoad(std::unique_ptr *self, slk::Reader *reader) { + "void ConstructAndLoad(std::unique_ptr *self, memgraph::slk::Reader *reader) { uint64_t type_id; - slk::Load(&type_id, reader); + memgraph::slk::Load(&type_id, reader); if (Derived::kType.id == type_id) { auto derived_instance = std::make_unique(); - slk::Load(derived_instance.get(), reader); + memgraph::slk::Load(derived_instance.get(), reader); *self = std::move(derived_instance); return; } - throw slk::SlkDecodeException(\"Trying to load unknown derived type!\"); + throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\"); }") (is-generated (lcp.slk:save-function-definition-for-class derived-class) - "void Save(const Derived &self, slk::Builder *builder) { - slk::Save(Derived::kType.id, builder); + "void Save(const Derived &self, memgraph::slk::Builder *builder) { + memgraph::slk::Save(Derived::kType.id, builder); // Save parent AbstractBase - { slk::Save(self.base_member, builder); } - slk::Save(self.derived_member, builder); + { memgraph::slk::Save(self.base_member, builder); } + memgraph::slk::Save(self.derived_member, builder); }") (is-generated (lcp.slk:construct-and-load-function-definition-for-class derived-class) - "void ConstructAndLoad(std::unique_ptr *self, slk::Reader *reader) { + "void ConstructAndLoad(std::unique_ptr *self, memgraph::slk::Reader *reader) { uint64_t type_id; - slk::Load(&type_id, reader); + memgraph::slk::Load(&type_id, reader); if (Derived::kType.id == type_id) { auto derived_instance = std::make_unique(); - slk::Load(derived_instance.get(), reader); + memgraph::slk::Load(derived_instance.get(), reader); *self = std::move(derived_instance); return; } - throw slk::SlkDecodeException(\"Trying to load unknown derived type!\"); + throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\"); }") (is-generated (lcp.slk:load-function-definition-for-class derived-class) - "void Load(Derived *self, slk::Reader *reader) { + "void Load(Derived *self, memgraph::slk::Reader *reader) { // Load parent AbstractBase - { slk::Load(&self->base_member, reader); } - slk::Load(&self->derived_member, reader); + { memgraph::slk::Load(&self->base_member, reader); } + memgraph::slk::Load(&self->derived_member, reader); }")) (undefine-cpp-types) (let ((base-class-template (lcp:define-struct (base t-param) () @@ -552,9 +552,9 @@ CPP-TYPE-DECL." ((member :bool)) (:serialize (:slk :base t))))) (is-generated (lcp.slk:save-function-definition-for-class class) - "void Save(const Derived &self, slk::Builder *builder) { slk::Save(self.member, builder); }") + "void Save(const Derived &self, memgraph::slk::Builder *builder) { memgraph::slk::Save(self.member, builder); }") (is-generated (lcp.slk:load-function-definition-for-class class) - "void Load(Derived *self, slk::Reader *reader) { slk::Load(&self->member, reader); }")) + "void Load(Derived *self, memgraph::slk::Reader *reader) { memgraph::slk::Load(&self->member, reader); }")) (undefine-cpp-types) (let ((base-class (lcp:define-struct base () @@ -566,23 +566,23 @@ CPP-TYPE-DECL." ()))) (declare (ignore derived-class)) (is-generated (lcp.slk:save-function-definition-for-class base-class) - "void Save(const Base &self, slk::Builder *builder, SaveArg extra_arg) { + "void Save(const Base &self, memgraph::slk::Builder *builder, SaveArg extra_arg) { if (const auto *derived_derived = utils::Downcast(&self)) { - return slk::Save(*derived_derived, builder, extra_arg); + return memgraph::slk::Save(*derived_derived, builder, extra_arg); } LOG(FATAL) << \"`Base` is marked as an abstract class!\"; }") (is-generated (lcp.slk:construct-and-load-function-definition-for-class base-class) - "void ConstructAndLoad(std::unique_ptr *self, slk::Reader *reader, LoadArg extra_arg) { + "void ConstructAndLoad(std::unique_ptr *self, memgraph::slk::Reader *reader, LoadArg extra_arg) { uint64_t type_id; - slk::Load(&type_id, reader); + memgraph::slk::Load(&type_id, reader); if (Derived::kType.id == type_id) { auto derived_instance = std::make_unique(); - slk::Load(derived_instance.get(), reader, extra_arg); + memgraph::slk::Load(derived_instance.get(), reader, extra_arg); *self = std::move(derived_instance); return; } - throw slk::SlkDecodeException(\"Trying to load unknown derived type!\"); + throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\"); }"))) (subtest "non-public members" @@ -1000,4 +1000,4 @@ CPP-TYPE-DECL." "object.member_ = member_;") (single-member-test (member "UnknownClass") "object.member_ = member_;") - (undefine-cpp-types)))) + (undefine-cpp-types)))) \ No newline at end of file diff --git a/src/lisp/types.lisp b/src/lisp/types.lisp index e5fbd0a09..07c206901 100644 --- a/src/lisp/types.lisp +++ b/src/lisp/types.lisp @@ -1416,26 +1416,26 @@ structure named by the string NAME." (unless (lcp.slk::save-extra-args class) (push ,(progn #>cpp - static void Save(const ${name} &self, slk::Builder *builder); + static void Save(const ${name} &self, memgraph::slk::Builder *builder); cpp<#) (cpp-class-public class)) (in-impl ,(progn #>cpp - void ${name}::Save(const ${name} &self, slk::Builder *builder) { - slk::Save(self, builder); + void ${name}::Save(const ${name} &self, memgraph::slk::Builder *builder) { + memgraph::slk::Save(self, builder); } cpp<#))) (unless (lcp.slk::load-extra-args class) (push ,(progn #>cpp - static void Load(${name} *self, slk::Reader *reader); + static void Load(${name} *self, memgraph::slk::Reader *reader); cpp<#) (cpp-class-public class)) (in-impl ,(progn #>cpp - void ${name}::Load(${name} *self, slk::Reader *reader) { - slk::Load(self, reader); + void ${name}::Load(${name} *self, memgraph::slk::Reader *reader) { + memgraph::slk::Load(self, reader); } cpp<#))))) diff --git a/src/memgraph.cpp b/src/memgraph.cpp index 6cc15db4a..3dece6c86 100644 --- a/src/memgraph.cpp +++ b/src/memgraph.cpp @@ -98,12 +98,12 @@ std::string GetAllowedEnumValuesString(const auto &mappings) { allowed_values.reserve(mappings.size()); std::transform(mappings.begin(), mappings.end(), std::back_inserter(allowed_values), [](const auto &mapping) { return std::string(mapping.first); }); - return utils::Join(allowed_values, ", "); + return memgraph::utils::Join(allowed_values, ", "); } enum class ValidationError : uint8_t { EmptyValue, InvalidValue }; -utils::BasicResult IsValidEnumValueString(const auto &value, const auto &mappings) { +memgraph::utils::BasicResult IsValidEnumValueString(const auto &value, const auto &mappings) { if (value.empty()) { return ValidationError::EmptyValue; } @@ -182,9 +182,10 @@ DEFINE_bool(storage_wal_enabled, false, "WAL periodic snapshots must be enabled."); DEFINE_VALIDATED_uint64(storage_snapshot_retention_count, 3, "The number of snapshots that should always be kept.", FLAG_IN_RANGE(1, 1000000)); -DEFINE_VALIDATED_uint64(storage_wal_file_size_kib, storage::Config::Durability().wal_file_size_kibibytes, +DEFINE_VALIDATED_uint64(storage_wal_file_size_kib, memgraph::storage::Config::Durability().wal_file_size_kibibytes, "Minimum file size of each WAL file.", FLAG_IN_RANGE(1, 1000 * 1024)); -DEFINE_VALIDATED_uint64(storage_wal_file_flush_every_n_tx, storage::Config::Durability().wal_file_flush_every_n_tx, +DEFINE_VALIDATED_uint64(storage_wal_file_flush_every_n_tx, + memgraph::storage::Config::Durability().wal_file_flush_every_n_tx, "Issue a 'fsync' call after this amount of transactions are written to the " "WAL file. Set to 1 for fully synchronous operation.", FLAG_IN_RANGE(1, 1000000)); @@ -215,9 +216,9 @@ DEFINE_string(pulsar_service_url, "", "Default URL used while connecting to Puls // Audit logging flags. #ifdef MG_ENTERPRISE DEFINE_bool(audit_enabled, false, "Set to true to enable audit logging."); -DEFINE_VALIDATED_int32(audit_buffer_size, audit::kBufferSizeDefault, "Maximum number of items in the audit log buffer.", - FLAG_IN_RANGE(1, INT32_MAX)); -DEFINE_VALIDATED_int32(audit_buffer_flush_interval_ms, audit::kBufferFlushIntervalMillisDefault, +DEFINE_VALIDATED_int32(audit_buffer_size, memgraph::audit::kBufferSizeDefault, + "Maximum number of items in the audit log buffer.", FLAG_IN_RANGE(1, INT32_MAX)); +DEFINE_VALIDATED_int32(audit_buffer_flush_interval_ms, memgraph::audit::kBufferFlushIntervalMillisDefault, "Interval (in milliseconds) used for flushing the audit log buffer.", FLAG_IN_RANGE(10, INT32_MAX)); #endif @@ -238,9 +239,9 @@ DEFINE_uint64( namespace { using namespace std::literals; constexpr std::array isolation_level_mappings{ - std::pair{"SNAPSHOT_ISOLATION"sv, storage::IsolationLevel::SNAPSHOT_ISOLATION}, - std::pair{"READ_COMMITTED"sv, storage::IsolationLevel::READ_COMMITTED}, - std::pair{"READ_UNCOMMITTED"sv, storage::IsolationLevel::READ_UNCOMMITTED}}; + std::pair{"SNAPSHOT_ISOLATION"sv, memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION}, + std::pair{"READ_COMMITTED"sv, memgraph::storage::IsolationLevel::READ_COMMITTED}, + std::pair{"READ_UNCOMMITTED"sv, memgraph::storage::IsolationLevel::READ_UNCOMMITTED}}; const std::string isolation_level_help_string = fmt::format("Default isolation level used for the transactions. Allowed values: {}", @@ -269,17 +270,18 @@ DEFINE_VALIDATED_string(isolation_level, "SNAPSHOT_ISOLATION", isolation_level_h }); namespace { -storage::IsolationLevel ParseIsolationLevel() { - const auto isolation_level = StringToEnum(FLAGS_isolation_level, isolation_level_mappings); +memgraph::storage::IsolationLevel ParseIsolationLevel() { + const auto isolation_level = + StringToEnum(FLAGS_isolation_level, isolation_level_mappings); MG_ASSERT(isolation_level, "Invalid isolation level"); return *isolation_level; } int64_t GetMemoryLimit() { if (FLAGS_memory_limit == 0) { - auto maybe_total_memory = utils::sysinfo::TotalMemory(); + auto maybe_total_memory = memgraph::utils::sysinfo::TotalMemory(); MG_ASSERT(maybe_total_memory, "Failed to fetch the total physical memory"); - const auto maybe_swap_memory = utils::sysinfo::SwapTotalMemory(); + const auto maybe_swap_memory = memgraph::utils::sysinfo::SwapTotalMemory(); MG_ASSERT(maybe_swap_memory, "Failed to fetch the total swap memory"); if (*maybe_swap_memory == 0) { @@ -304,9 +306,9 @@ DEFINE_VALIDATED_string(query_modules_directory, "", { query_modules_directories.clear(); if (value.empty()) return true; - const auto directories = utils::Split(value, ","); + const auto directories = memgraph::utils::Split(value, ","); for (const auto &dir : directories) { - if (!utils::DirExists(dir)) { + if (!memgraph::utils::DirExists(dir)) { std::cout << "Expected --" << flagname << " to point to directories." << std::endl; std::cout << dir << " is not a directory." << std::endl; return false; @@ -411,22 +413,23 @@ struct SessionData { // supplied. #if MG_ENTERPRISE - SessionData(storage::Storage *db, query::InterpreterContext *interpreter_context, - utils::Synchronized *auth, audit::Log *audit_log) + SessionData(memgraph::storage::Storage *db, memgraph::query::InterpreterContext *interpreter_context, + memgraph::utils::Synchronized *auth, + memgraph::audit::Log *audit_log) : db(db), interpreter_context(interpreter_context), auth(auth), audit_log(audit_log) {} - storage::Storage *db; - query::InterpreterContext *interpreter_context; - utils::Synchronized *auth; - audit::Log *audit_log; + memgraph::storage::Storage *db; + memgraph::query::InterpreterContext *interpreter_context; + memgraph::utils::Synchronized *auth; + memgraph::audit::Log *audit_log; #else - SessionData(storage::Storage *db, query::InterpreterContext *interpreter_context, - utils::Synchronized *auth) + SessionData(memgraph::storage::Storage *db, memgraph::query::InterpreterContext *interpreter_context, + memgraph::utils::Synchronized *auth) : db(db), interpreter_context(interpreter_context), auth(auth) {} - storage::Storage *db; - query::InterpreterContext *interpreter_context; - utils::Synchronized *auth; + memgraph::storage::Storage *db; + memgraph::query::InterpreterContext *interpreter_context; + memgraph::utils::Synchronized *auth; #endif }; @@ -436,29 +439,30 @@ constexpr std::string_view default_user_role_regex = "[a-zA-Z0-9_.+-@]+"; DEFINE_string(auth_user_or_role_name_regex, default_user_role_regex.data(), "Set to the regular expression that each user or role name must fulfill."); -class AuthQueryHandler final : public query::AuthQueryHandler { - utils::Synchronized *auth_; +class AuthQueryHandler final : public memgraph::query::AuthQueryHandler { + memgraph::utils::Synchronized *auth_; std::string name_regex_string_; std::regex name_regex_; public: - AuthQueryHandler(utils::Synchronized *auth, std::string name_regex_string) + AuthQueryHandler(memgraph::utils::Synchronized *auth, + std::string name_regex_string) : auth_(auth), name_regex_string_(std::move(name_regex_string)), name_regex_(name_regex_string_) {} bool CreateUser(const std::string &username, const std::optional &password) override { if (name_regex_string_ != default_user_role_regex) { if (const auto license_check_result = - utils::license::global_license_checker.IsValidLicense(utils::global_settings); + memgraph::utils::license::global_license_checker.IsValidLicense(memgraph::utils::global_settings); license_check_result.HasError()) { - throw auth::AuthException( + throw memgraph::auth::AuthException( "Custom user/role regex is a Memgraph Enterprise feature. Please set the config " "(\"--auth-user-or-role-name-regex\") to its default value (\"{}\") or remove the flag.\n{}", default_user_role_regex, - utils::license::LicenseCheckErrorToString(license_check_result.GetError(), "user/role regex")); + memgraph::utils::license::LicenseCheckErrorToString(license_check_result.GetError(), "user/role regex")); } } if (!std::regex_match(username, name_regex_)) { - throw query::QueryRuntimeException("Invalid user name."); + throw memgraph::query::QueryRuntimeException("Invalid user name."); } try { const auto [first_user, user_added] = std::invoke([&, this] { @@ -470,253 +474,253 @@ class AuthQueryHandler final : public query::AuthQueryHandler { if (first_user) { spdlog::info("{} is first created user. Granting all privileges.", username); - GrantPrivilege(username, query::kPrivilegesAll); + GrantPrivilege(username, memgraph::query::kPrivilegesAll); } return user_added; - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } bool DropUser(const std::string &username) override { if (!std::regex_match(username, name_regex_)) { - throw query::QueryRuntimeException("Invalid user name."); + throw memgraph::query::QueryRuntimeException("Invalid user name."); } try { auto locked_auth = auth_->Lock(); auto user = locked_auth->GetUser(username); if (!user) return false; return locked_auth->RemoveUser(username); - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } void SetPassword(const std::string &username, const std::optional &password) override { if (!std::regex_match(username, name_regex_)) { - throw query::QueryRuntimeException("Invalid user name."); + throw memgraph::query::QueryRuntimeException("Invalid user name."); } try { auto locked_auth = auth_->Lock(); auto user = locked_auth->GetUser(username); if (!user) { - throw query::QueryRuntimeException("User '{}' doesn't exist.", username); + throw memgraph::query::QueryRuntimeException("User '{}' doesn't exist.", username); } user->UpdatePassword(password); locked_auth->SaveUser(*user); - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } bool CreateRole(const std::string &rolename) override { if (!std::regex_match(rolename, name_regex_)) { - throw query::QueryRuntimeException("Invalid role name."); + throw memgraph::query::QueryRuntimeException("Invalid role name."); } try { auto locked_auth = auth_->Lock(); return locked_auth->AddRole(rolename).has_value(); - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } bool DropRole(const std::string &rolename) override { if (!std::regex_match(rolename, name_regex_)) { - throw query::QueryRuntimeException("Invalid role name."); + throw memgraph::query::QueryRuntimeException("Invalid role name."); } try { auto locked_auth = auth_->Lock(); auto role = locked_auth->GetRole(rolename); if (!role) return false; return locked_auth->RemoveRole(rolename); - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } - std::vector GetUsernames() override { + std::vector GetUsernames() override { try { auto locked_auth = auth_->ReadLock(); - std::vector usernames; + std::vector usernames; const auto &users = locked_auth->AllUsers(); usernames.reserve(users.size()); for (const auto &user : users) { usernames.emplace_back(user.username()); } return usernames; - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } - std::vector GetRolenames() override { + std::vector GetRolenames() override { try { auto locked_auth = auth_->ReadLock(); - std::vector rolenames; + std::vector rolenames; const auto &roles = locked_auth->AllRoles(); rolenames.reserve(roles.size()); for (const auto &role : roles) { rolenames.emplace_back(role.rolename()); } return rolenames; - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } std::optional GetRolenameForUser(const std::string &username) override { if (!std::regex_match(username, name_regex_)) { - throw query::QueryRuntimeException("Invalid user name."); + throw memgraph::query::QueryRuntimeException("Invalid user name."); } try { auto locked_auth = auth_->ReadLock(); auto user = locked_auth->GetUser(username); if (!user) { - throw query::QueryRuntimeException("User '{}' doesn't exist .", username); + throw memgraph::query::QueryRuntimeException("User '{}' doesn't exist .", username); } if (const auto *role = user->role(); role != nullptr) { return role->rolename(); } return std::nullopt; - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } - std::vector GetUsernamesForRole(const std::string &rolename) override { + std::vector GetUsernamesForRole(const std::string &rolename) override { if (!std::regex_match(rolename, name_regex_)) { - throw query::QueryRuntimeException("Invalid role name."); + throw memgraph::query::QueryRuntimeException("Invalid role name."); } try { auto locked_auth = auth_->ReadLock(); auto role = locked_auth->GetRole(rolename); if (!role) { - throw query::QueryRuntimeException("Role '{}' doesn't exist.", rolename); + throw memgraph::query::QueryRuntimeException("Role '{}' doesn't exist.", rolename); } - std::vector usernames; + std::vector usernames; const auto &users = locked_auth->AllUsersForRole(rolename); usernames.reserve(users.size()); for (const auto &user : users) { usernames.emplace_back(user.username()); } return usernames; - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } void SetRole(const std::string &username, const std::string &rolename) override { if (!std::regex_match(username, name_regex_)) { - throw query::QueryRuntimeException("Invalid user name."); + throw memgraph::query::QueryRuntimeException("Invalid user name."); } if (!std::regex_match(rolename, name_regex_)) { - throw query::QueryRuntimeException("Invalid role name."); + throw memgraph::query::QueryRuntimeException("Invalid role name."); } try { auto locked_auth = auth_->Lock(); auto user = locked_auth->GetUser(username); if (!user) { - throw query::QueryRuntimeException("User '{}' doesn't exist .", username); + throw memgraph::query::QueryRuntimeException("User '{}' doesn't exist .", username); } auto role = locked_auth->GetRole(rolename); if (!role) { - throw query::QueryRuntimeException("Role '{}' doesn't exist .", rolename); + throw memgraph::query::QueryRuntimeException("Role '{}' doesn't exist .", rolename); } if (const auto *current_role = user->role(); current_role != nullptr) { - throw query::QueryRuntimeException("User '{}' is already a member of role '{}'.", username, - current_role->rolename()); + throw memgraph::query::QueryRuntimeException("User '{}' is already a member of role '{}'.", username, + current_role->rolename()); } user->SetRole(*role); locked_auth->SaveUser(*user); - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } void ClearRole(const std::string &username) override { if (!std::regex_match(username, name_regex_)) { - throw query::QueryRuntimeException("Invalid user name."); + throw memgraph::query::QueryRuntimeException("Invalid user name."); } try { auto locked_auth = auth_->Lock(); auto user = locked_auth->GetUser(username); if (!user) { - throw query::QueryRuntimeException("User '{}' doesn't exist .", username); + throw memgraph::query::QueryRuntimeException("User '{}' doesn't exist .", username); } user->ClearRole(); locked_auth->SaveUser(*user); - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } - std::vector> GetPrivileges(const std::string &user_or_role) override { + std::vector> GetPrivileges(const std::string &user_or_role) override { if (!std::regex_match(user_or_role, name_regex_)) { - throw query::QueryRuntimeException("Invalid user or role name."); + throw memgraph::query::QueryRuntimeException("Invalid user or role name."); } try { auto locked_auth = auth_->ReadLock(); - std::vector> grants; + std::vector> grants; auto user = locked_auth->GetUser(user_or_role); auto role = locked_auth->GetRole(user_or_role); if (!user && !role) { - throw query::QueryRuntimeException("User or role '{}' doesn't exist.", user_or_role); + throw memgraph::query::QueryRuntimeException("User or role '{}' doesn't exist.", user_or_role); } if (user) { const auto &permissions = user->GetPermissions(); - for (const auto &privilege : query::kPrivilegesAll) { - auto permission = glue::PrivilegeToPermission(privilege); + for (const auto &privilege : memgraph::query::kPrivilegesAll) { + auto permission = memgraph::glue::PrivilegeToPermission(privilege); auto effective = permissions.Has(permission); - if (permissions.Has(permission) != auth::PermissionLevel::NEUTRAL) { + if (permissions.Has(permission) != memgraph::auth::PermissionLevel::NEUTRAL) { std::vector description; auto user_level = user->permissions().Has(permission); - if (user_level == auth::PermissionLevel::GRANT) { + if (user_level == memgraph::auth::PermissionLevel::GRANT) { description.emplace_back("GRANTED TO USER"); - } else if (user_level == auth::PermissionLevel::DENY) { + } else if (user_level == memgraph::auth::PermissionLevel::DENY) { description.emplace_back("DENIED TO USER"); } if (const auto *role = user->role(); role != nullptr) { auto role_level = role->permissions().Has(permission); - if (role_level == auth::PermissionLevel::GRANT) { + if (role_level == memgraph::auth::PermissionLevel::GRANT) { description.emplace_back("GRANTED TO ROLE"); - } else if (role_level == auth::PermissionLevel::DENY) { + } else if (role_level == memgraph::auth::PermissionLevel::DENY) { description.emplace_back("DENIED TO ROLE"); } } - grants.push_back({query::TypedValue(auth::PermissionToString(permission)), - query::TypedValue(auth::PermissionLevelToString(effective)), - query::TypedValue(utils::Join(description, ", "))}); + grants.push_back({memgraph::query::TypedValue(memgraph::auth::PermissionToString(permission)), + memgraph::query::TypedValue(memgraph::auth::PermissionLevelToString(effective)), + memgraph::query::TypedValue(memgraph::utils::Join(description, ", "))}); } } } else { const auto &permissions = role->permissions(); - for (const auto &privilege : query::kPrivilegesAll) { - auto permission = glue::PrivilegeToPermission(privilege); + for (const auto &privilege : memgraph::query::kPrivilegesAll) { + auto permission = memgraph::glue::PrivilegeToPermission(privilege); auto effective = permissions.Has(permission); - if (effective != auth::PermissionLevel::NEUTRAL) { + if (effective != memgraph::auth::PermissionLevel::NEUTRAL) { std::string description; - if (effective == auth::PermissionLevel::GRANT) { + if (effective == memgraph::auth::PermissionLevel::GRANT) { description = "GRANTED TO ROLE"; - } else if (effective == auth::PermissionLevel::DENY) { + } else if (effective == memgraph::auth::PermissionLevel::DENY) { description = "DENIED TO ROLE"; } - grants.push_back({query::TypedValue(auth::PermissionToString(permission)), - query::TypedValue(auth::PermissionLevelToString(effective)), - query::TypedValue(description)}); + grants.push_back({memgraph::query::TypedValue(memgraph::auth::PermissionToString(permission)), + memgraph::query::TypedValue(memgraph::auth::PermissionLevelToString(effective)), + memgraph::query::TypedValue(description)}); } } } return grants; - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } void GrantPrivilege(const std::string &user_or_role, - const std::vector &privileges) override { + const std::vector &privileges) override { EditPermissions(user_or_role, privileges, [](auto *permissions, const auto &permission) { // TODO (mferencevic): should we first check that the // privilege is granted/denied/revoked before @@ -726,7 +730,7 @@ class AuthQueryHandler final : public query::AuthQueryHandler { } void DenyPrivilege(const std::string &user_or_role, - const std::vector &privileges) override { + const std::vector &privileges) override { EditPermissions(user_or_role, privileges, [](auto *permissions, const auto &permission) { // TODO (mferencevic): should we first check that the // privilege is granted/denied/revoked before @@ -736,7 +740,7 @@ class AuthQueryHandler final : public query::AuthQueryHandler { } void RevokePrivilege(const std::string &user_or_role, - const std::vector &privileges) override { + const std::vector &privileges) override { EditPermissions(user_or_role, privileges, [](auto *permissions, const auto &permission) { // TODO (mferencevic): should we first check that the // privilege is granted/denied/revoked before @@ -747,22 +751,22 @@ class AuthQueryHandler final : public query::AuthQueryHandler { private: template - void EditPermissions(const std::string &user_or_role, const std::vector &privileges, - const TEditFun &edit_fun) { + void EditPermissions(const std::string &user_or_role, + const std::vector &privileges, const TEditFun &edit_fun) { if (!std::regex_match(user_or_role, name_regex_)) { - throw query::QueryRuntimeException("Invalid user or role name."); + throw memgraph::query::QueryRuntimeException("Invalid user or role name."); } try { - std::vector permissions; + std::vector permissions; permissions.reserve(privileges.size()); for (const auto &privilege : privileges) { - permissions.push_back(glue::PrivilegeToPermission(privilege)); + permissions.push_back(memgraph::glue::PrivilegeToPermission(privilege)); } auto locked_auth = auth_->Lock(); auto user = locked_auth->GetUser(user_or_role); auto role = locked_auth->GetRole(user_or_role); if (!user && !role) { - throw query::QueryRuntimeException("User or role '{}' doesn't exist.", user_or_role); + throw memgraph::query::QueryRuntimeException("User or role '{}' doesn't exist.", user_or_role); } if (user) { for (const auto &permission : permissions) { @@ -775,26 +779,30 @@ class AuthQueryHandler final : public query::AuthQueryHandler { } locked_auth->SaveRole(*role); } - } catch (const auth::AuthException &e) { - throw query::QueryRuntimeException(e.what()); + } catch (const memgraph::auth::AuthException &e) { + throw memgraph::query::QueryRuntimeException(e.what()); } } }; -class AuthChecker final : public query::AuthChecker { +class AuthChecker final : public memgraph::query::AuthChecker { public: - explicit AuthChecker(utils::Synchronized *auth) : auth_{auth} {} + explicit AuthChecker( + memgraph::utils::Synchronized *auth) + : auth_{auth} {} - static bool IsUserAuthorized(const auth::User &user, const std::vector &privileges) { + static bool IsUserAuthorized(const memgraph::auth::User &user, + const std::vector &privileges) { const auto user_permissions = user.GetPermissions(); return std::all_of(privileges.begin(), privileges.end(), [&user_permissions](const auto privilege) { - return user_permissions.Has(glue::PrivilegeToPermission(privilege)) == auth::PermissionLevel::GRANT; + return user_permissions.Has(memgraph::glue::PrivilegeToPermission(privilege)) == + memgraph::auth::PermissionLevel::GRANT; }); } bool IsUserAuthorized(const std::optional &username, - const std::vector &privileges) const final { - std::optional maybe_user; + const std::vector &privileges) const final { + std::optional maybe_user; { auto locked_auth = auth_->ReadLock(); if (!locked_auth->HasUsers()) { @@ -809,15 +817,16 @@ class AuthChecker final : public query::AuthChecker { } private: - utils::Synchronized *auth_; + memgraph::utils::Synchronized *auth_; }; -class BoltSession final : public communication::bolt::Session { +class BoltSession final : public memgraph::communication::bolt::Session { public: - BoltSession(SessionData *data, const io::network::Endpoint &endpoint, communication::InputStream *input_stream, - communication::OutputStream *output_stream) - : communication::bolt::Session(input_stream, - output_stream), + BoltSession(SessionData *data, const memgraph::io::network::Endpoint &endpoint, + memgraph::communication::InputStream *input_stream, memgraph::communication::OutputStream *output_stream) + : memgraph::communication::bolt::Session(input_stream, output_stream), db_(data->db), interpreter_(data->interpreter_context), auth_(data->auth), @@ -827,7 +836,8 @@ class BoltSession final : public communication::bolt::Session::TEncoder; + using memgraph::communication::bolt::Session::TEncoder; void BeginTransaction() override { interpreter_.BeginTransaction(); } @@ -836,43 +846,44 @@ class BoltSession final : public communication::bolt::Session, std::optional> Interpret( - const std::string &query, const std::map ¶ms) override { - std::map params_pv; - for (const auto &kv : params) params_pv.emplace(kv.first, glue::ToPropertyValue(kv.second)); + const std::string &query, const std::map ¶ms) override { + std::map params_pv; + for (const auto &kv : params) params_pv.emplace(kv.first, memgraph::glue::ToPropertyValue(kv.second)); const std::string *username{nullptr}; if (user_) { username = &user_->username(); } #ifdef MG_ENTERPRISE - if (utils::license::global_license_checker.IsValidLicenseFast()) { - audit_log_->Record(endpoint_.address, user_ ? *username : "", query, storage::PropertyValue(params_pv)); + if (memgraph::utils::license::global_license_checker.IsValidLicenseFast()) { + audit_log_->Record(endpoint_.address, user_ ? *username : "", query, memgraph::storage::PropertyValue(params_pv)); } #endif try { auto result = interpreter_.Prepare(query, params_pv, username); if (user_ && !AuthChecker::IsUserAuthorized(*user_, result.privileges)) { interpreter_.Abort(); - throw communication::bolt::ClientError( + throw memgraph::communication::bolt::ClientError( "You are not authorized to execute this query! Please contact " "your database administrator."); } return {result.headers, result.qid}; - } catch (const query::QueryException &e) { + } catch (const memgraph::query::QueryException &e) { // Wrap QueryException into ClientError, because we want to allow the // client to fix their query. - throw communication::bolt::ClientError(e.what()); + throw memgraph::communication::bolt::ClientError(e.what()); } } - std::map Pull(TEncoder *encoder, std::optional n, - std::optional qid) override { + std::map Pull(TEncoder *encoder, std::optional n, + std::optional qid) override { TypedValueResultStream stream(encoder, db_); return PullResults(stream, n, qid); } - std::map Discard(std::optional n, std::optional qid) override { - query::DiscardValueResultStream stream; + std::map Discard(std::optional n, + std::optional qid) override { + memgraph::query::DiscardValueResultStream stream; return PullResults(stream, n, qid); } @@ -894,30 +905,30 @@ class BoltSession final : public communication::bolt::Session - std::map PullResults(TStream &stream, std::optional n, - std::optional qid) { + std::map PullResults(TStream &stream, std::optional n, + std::optional qid) { try { const auto &summary = interpreter_.Pull(&stream, n, qid); - std::map decoded_summary; + std::map decoded_summary; for (const auto &kv : summary) { - auto maybe_value = glue::ToBoltValue(kv.second, *db_, storage::View::NEW); + auto maybe_value = memgraph::glue::ToBoltValue(kv.second, *db_, memgraph::storage::View::NEW); if (maybe_value.HasError()) { switch (maybe_value.GetError()) { - case storage::Error::DELETED_OBJECT: - case storage::Error::SERIALIZATION_ERROR: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::NONEXISTENT_OBJECT: - throw communication::bolt::ClientError("Unexpected storage error when streaming summary."); + case memgraph::storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::NONEXISTENT_OBJECT: + throw memgraph::communication::bolt::ClientError("Unexpected storage error when streaming summary."); } } decoded_summary.emplace(kv.first, std::move(*maybe_value)); } return decoded_summary; - } catch (const query::QueryException &e) { + } catch (const memgraph::query::QueryException &e) { // Wrap QueryException into ClientError, because we want to allow the // client to fix their query. - throw communication::bolt::ClientError(e.what()); + throw memgraph::communication::bolt::ClientError(e.what()); } } @@ -925,23 +936,23 @@ class BoltSession final : public communication::bolt::Session &values) { - std::vector decoded_values; + void Result(const std::vector &values) { + std::vector decoded_values; decoded_values.reserve(values.size()); for (const auto &v : values) { - auto maybe_value = glue::ToBoltValue(v, *db_, storage::View::NEW); + auto maybe_value = memgraph::glue::ToBoltValue(v, *db_, memgraph::storage::View::NEW); if (maybe_value.HasError()) { switch (maybe_value.GetError()) { - case storage::Error::DELETED_OBJECT: - throw communication::bolt::ClientError("Returning a deleted object as a result."); - case storage::Error::NONEXISTENT_OBJECT: - throw communication::bolt::ClientError("Returning a nonexistent object as a result."); - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: - case storage::Error::PROPERTIES_DISABLED: - throw communication::bolt::ClientError("Unexpected storage error when streaming results."); + case memgraph::storage::Error::DELETED_OBJECT: + throw memgraph::communication::bolt::ClientError("Returning a deleted object as a result."); + case memgraph::storage::Error::NONEXISTENT_OBJECT: + throw memgraph::communication::bolt::ClientError("Returning a nonexistent object as a result."); + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + throw memgraph::communication::bolt::ClientError("Unexpected storage error when streaming results."); } } decoded_values.emplace_back(std::move(*maybe_value)); @@ -952,22 +963,22 @@ class BoltSession final : public communication::bolt::Session *auth_; - std::optional user_; + const memgraph::storage::Storage *db_; + memgraph::query::Interpreter interpreter_; + memgraph::utils::Synchronized *auth_; + std::optional user_; #ifdef MG_ENTERPRISE - audit::Log *audit_log_; + memgraph::audit::Log *audit_log_; #endif - io::network::Endpoint endpoint_; + memgraph::io::network::Endpoint endpoint_; }; -using ServerT = communication::Server; -using communication::ServerContext; +using ServerT = memgraph::communication::Server; +using memgraph::communication::ServerContext; // Needed to correctly handle memgraph destruction from a signal handler. // Without having some sort of a flag, it is possible that a signal is handled @@ -992,9 +1003,11 @@ void InitSignalHandlers(const std::function &shutdown_fun) { shutdown_fun(); }; - MG_ASSERT(utils::SignalHandler::RegisterHandler(utils::Signal::Terminate, shutdown, block_shutdown_signals), + MG_ASSERT(memgraph::utils::SignalHandler::RegisterHandler(memgraph::utils::Signal::Terminate, shutdown, + block_shutdown_signals), "Unable to register SIGTERM handler!"); - MG_ASSERT(utils::SignalHandler::RegisterHandler(utils::Signal::Interupt, shutdown, block_shutdown_signals), + MG_ASSERT(memgraph::utils::SignalHandler::RegisterHandler(memgraph::utils::Signal::Interupt, shutdown, + block_shutdown_signals), "Unable to register SIGINT handler!"); } @@ -1010,7 +1023,7 @@ int main(int argc, char **argv) { InitializeLogger(); // Unhandled exception handler init. - std::set_terminate(&utils::TerminateHandler); + std::set_terminate(&memgraph::utils::TerminateHandler); // Initialize Python auto *program_name = Py_DecodeLocale(argv[0], nullptr); @@ -1018,47 +1031,48 @@ int main(int argc, char **argv) { // Set program name, so Python can find its way to runtime libraries relative // to executable. Py_SetProgramName(program_name); - PyImport_AppendInittab("_mgp", &query::procedure::PyInitMgpModule); + PyImport_AppendInittab("_mgp", &memgraph::query::procedure::PyInitMgpModule); Py_InitializeEx(0 /* = initsigs */); PyEval_InitThreads(); Py_BEGIN_ALLOW_THREADS; // Add our Python modules to sys.path try { - auto exe_path = utils::GetExecutablePath(); + auto exe_path = memgraph::utils::GetExecutablePath(); auto py_support_dir = exe_path.parent_path() / "python_support"; if (std::filesystem::is_directory(py_support_dir)) { - auto gil = py::EnsureGIL(); - auto maybe_exc = py::AppendToSysPath(py_support_dir.c_str()); + auto gil = memgraph::py::EnsureGIL(); + auto maybe_exc = memgraph::py::AppendToSysPath(py_support_dir.c_str()); if (maybe_exc) { - spdlog::error(utils::MessageWithLink("Unable to load support for embedded Python: {}.", *maybe_exc, - "https://memgr.ph/python")); + spdlog::error(memgraph::utils::MessageWithLink("Unable to load support for embedded Python: {}.", *maybe_exc, + "https://memgr.ph/python")); } } else { - spdlog::error(utils::MessageWithLink("Unable to load support for embedded Python: missing directory {}.", + spdlog::error( + memgraph::utils::MessageWithLink("Unable to load support for embedded Python: missing directory {}.", py_support_dir, "https://memgr.ph/python")); } } catch (const std::filesystem::filesystem_error &e) { - spdlog::error( - utils::MessageWithLink("Unable to load support for embedded Python: {}.", e.what(), "https://memgr.ph/python")); + spdlog::error(memgraph::utils::MessageWithLink("Unable to load support for embedded Python: {}.", e.what(), + "https://memgr.ph/python")); } // Initialize the communication library. - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; // Initialize the requests library. - requests::Init(); + memgraph::requests::Init(); // Start memory warning logger. - utils::Scheduler mem_log_scheduler; + memgraph::utils::Scheduler mem_log_scheduler; if (FLAGS_memory_warning_threshold > 0) { - auto free_ram = utils::sysinfo::AvailableMemory(); + auto free_ram = memgraph::utils::sysinfo::AvailableMemory(); if (free_ram) { mem_log_scheduler.Run("Memory warning", std::chrono::seconds(3), [] { - auto free_ram = utils::sysinfo::AvailableMemory(); + auto free_ram = memgraph::utils::sysinfo::AvailableMemory(); if (free_ram && *free_ram / 1024 < FLAGS_memory_warning_threshold) - spdlog::warn(utils::MessageWithLink("Running out of available RAM, only {} MB left.", *free_ram / 1024, - "https://memgr.ph/ram")); + spdlog::warn(memgraph::utils::MessageWithLink("Running out of available RAM, only {} MB left.", + *free_ram / 1024, "https://memgr.ph/ram")); }); } else { // Kernel version for the `MemAvailable` value is from: man procfs @@ -1076,22 +1090,23 @@ int main(int argc, char **argv) { const auto memory_limit = GetMemoryLimit(); // NOLINTNEXTLINE(bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions) - spdlog::info("Memory limit in config is set to {}", utils::GetReadableSize(memory_limit)); - utils::total_memory_tracker.SetMaximumHardLimit(memory_limit); - utils::total_memory_tracker.SetHardLimit(memory_limit); + spdlog::info("Memory limit in config is set to {}", memgraph::utils::GetReadableSize(memory_limit)); + memgraph::utils::total_memory_tracker.SetMaximumHardLimit(memory_limit); + memgraph::utils::total_memory_tracker.SetHardLimit(memory_limit); - utils::global_settings.Initialize(data_directory / "settings"); - utils::OnScopeExit settings_finalizer([&] { utils::global_settings.Finalize(); }); + memgraph::utils::global_settings.Initialize(data_directory / "settings"); + memgraph::utils::OnScopeExit settings_finalizer([&] { memgraph::utils::global_settings.Finalize(); }); // register all runtime settings - utils::license::RegisterLicenseSettings(utils::license::global_license_checker, utils::global_settings); + memgraph::utils::license::RegisterLicenseSettings(memgraph::utils::license::global_license_checker, + memgraph::utils::global_settings); - utils::license::global_license_checker.CheckEnvLicense(); + memgraph::utils::license::global_license_checker.CheckEnvLicense(); if (!FLAGS_organization_name.empty() && !FLAGS_license_key.empty()) { - utils::license::global_license_checker.SetLicenseInfoOverride(FLAGS_license_key, FLAGS_organization_name); + memgraph::utils::license::global_license_checker.SetLicenseInfoOverride(FLAGS_license_key, FLAGS_organization_name); } - utils::license::global_license_checker.StartBackgroundLicenseChecker(utils::global_settings); + memgraph::utils::license::global_license_checker.StartBackgroundLicenseChecker(memgraph::utils::global_settings); // All enterprise features should be constructed before the main database // storage. This will cause them to be destructed *after* the main database @@ -1105,26 +1120,30 @@ int main(int argc, char **argv) { // Begin enterprise features initialization // Auth - utils::Synchronized auth{data_directory / "auth"}; + memgraph::utils::Synchronized auth{data_directory / + "auth"}; #ifdef MG_ENTERPRISE // Audit log - audit::Log audit_log{data_directory / "audit", FLAGS_audit_buffer_size, FLAGS_audit_buffer_flush_interval_ms}; + memgraph::audit::Log audit_log{data_directory / "audit", FLAGS_audit_buffer_size, + FLAGS_audit_buffer_flush_interval_ms}; // Start the log if enabled. if (FLAGS_audit_enabled) { audit_log.Start(); } // Setup SIGUSR2 to be used for reopening audit log files, when e.g. logrotate // rotates our audit logs. - MG_ASSERT(utils::SignalHandler::RegisterHandler(utils::Signal::User2, [&audit_log]() { audit_log.ReopenLog(); }), + MG_ASSERT(memgraph::utils::SignalHandler::RegisterHandler(memgraph::utils::Signal::User2, + [&audit_log]() { audit_log.ReopenLog(); }), "Unable to register SIGUSR2 handler!"); // End enterprise features initialization #endif // Main storage and execution engines initialization - storage::Config db_config{ - .gc = {.type = storage::Config::Gc::Type::PERIODIC, .interval = std::chrono::seconds(FLAGS_storage_gc_cycle_sec)}, + memgraph::storage::Config db_config{ + .gc = {.type = memgraph::storage::Config::Gc::Type::PERIODIC, + .interval = std::chrono::seconds(FLAGS_storage_gc_cycle_sec)}, .items = {.properties_on_edges = FLAGS_storage_properties_on_edges}, .durability = {.storage_directory = FLAGS_data_directory, .recover_on_startup = FLAGS_storage_recover_on_startup, @@ -1139,19 +1158,21 @@ int main(int argc, char **argv) { "In order to use write-ahead-logging you must enable " "periodic snapshots by setting the snapshot interval to a " "value larger than 0!"); - db_config.durability.snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::DISABLED; + db_config.durability.snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::DISABLED; } } else { if (FLAGS_storage_wal_enabled) { - db_config.durability.snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL; + db_config.durability.snapshot_wal_mode = + memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL; } else { - db_config.durability.snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT; + db_config.durability.snapshot_wal_mode = + memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT; } db_config.durability.snapshot_interval = std::chrono::seconds(FLAGS_storage_snapshot_interval_sec); } - storage::Storage db(db_config); + memgraph::storage::Storage db(db_config); - query::InterpreterContext interpreter_context{ + memgraph::query::InterpreterContext interpreter_context{ &db, {.query = {.allow_load_csv = FLAGS_allow_load_csv}, .execution_timeout_sec = FLAGS_query_execution_timeout_sec, @@ -1166,8 +1187,8 @@ int main(int argc, char **argv) { SessionData session_data{&db, &interpreter_context, &auth}; #endif - query::procedure::gModuleRegistry.SetModulesDirectory(query_modules_directories, FLAGS_data_directory); - query::procedure::gModuleRegistry.UnloadAndLoadModulesFromDirectories(); + memgraph::query::procedure::gModuleRegistry.SetModulesDirectory(query_modules_directories, FLAGS_data_directory); + memgraph::query::procedure::gModuleRegistry.UnloadAndLoadModulesFromDirectories(); AuthQueryHandler auth_handler(&auth, FLAGS_auth_user_or_role_name_regex); AuthChecker auth_checker{&auth}; @@ -1178,7 +1199,7 @@ int main(int argc, char **argv) { // Triggers can execute query procedures, so we need to reload the modules first and then // the triggers auto storage_accessor = interpreter_context.db->Access(); - auto dba = query::DbAccessor{&storage_accessor}; + auto dba = memgraph::query::DbAccessor{&storage_accessor}; interpreter_context.trigger_store.RestoreTriggers(&interpreter_context.ast_cache, &dba, &interpreter_context.antlr_lock, interpreter_context.config.query, interpreter_context.auth_checker); @@ -1194,14 +1215,15 @@ int main(int argc, char **argv) { service_name = "BoltS"; spdlog::info("Using secure Bolt connection (with SSL)"); } else { - spdlog::warn(utils::MessageWithLink("Using non-secure Bolt connection (without SSL).", "https://memgr.ph/ssl")); + spdlog::warn( + memgraph::utils::MessageWithLink("Using non-secure Bolt connection (without SSL).", "https://memgr.ph/ssl")); } ServerT server({FLAGS_bolt_address, static_cast(FLAGS_bolt_port)}, &session_data, &context, FLAGS_bolt_session_inactivity_timeout, service_name, FLAGS_bolt_num_workers); // Setup telemetry - std::optional telemetry; + std::optional telemetry; if (FLAGS_telemetry_enabled) { telemetry.emplace("https://telemetry.memgraph.com/88b5e7e8-746a-11e8-9f85-538a9e9690cc/", data_directory / "telemetry", std::chrono::minutes(10)); @@ -1216,12 +1238,13 @@ int main(int argc, char **argv) { } return ret; }); - telemetry->AddCollector("query_module_counters", - []() -> nlohmann::json { return query::plan::CallProcedure::GetAndResetCounters(); }); + telemetry->AddCollector("query_module_counters", []() -> nlohmann::json { + return memgraph::query::plan::CallProcedure::GetAndResetCounters(); + }); } - communication::websocket::SafeAuth websocket_auth{&auth}; - communication::websocket::Server websocket_server{ + memgraph::communication::websocket::SafeAuth websocket_auth{&auth}; + memgraph::communication::websocket::Server websocket_server{ {FLAGS_monitoring_address, static_cast(FLAGS_monitoring_port)}, &context, websocket_auth}; AddLoggerSink(websocket_server.GetLoggingSink()); @@ -1233,7 +1256,7 @@ int main(int argc, char **argv) { // After the server is notified to stop accepting and processing // connections we tell the execution engine to stop processing all pending // queries. - query::Shutdown(&interpreter_context); + memgraph::query::Shutdown(&interpreter_context); websocket_server.Shutdown(); }; @@ -1245,13 +1268,13 @@ int main(int argc, char **argv) { server.AwaitShutdown(); websocket_server.AwaitShutdown(); - query::procedure::gModuleRegistry.UnloadAllModules(); + memgraph::query::procedure::gModuleRegistry.UnloadAllModules(); Py_END_ALLOW_THREADS; // Shutdown Python Py_Finalize(); PyMem_RawFree(program_name); - utils::total_memory_tracker.LogPeakMemoryUsage(); + memgraph::utils::total_memory_tracker.LogPeakMemoryUsage(); return 0; } diff --git a/src/memory/memory_control.cpp b/src/memory/memory_control.cpp index a2f069dbe..2af313d09 100644 --- a/src/memory/memory_control.cpp +++ b/src/memory/memory_control.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include #endif -namespace memory { +namespace memgraph::memory { // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define STRINGIFY_HELPER(x) #x @@ -30,4 +30,4 @@ void PurgeUnusedMemory() { #undef STRINGIFY #undef STRINGIFY_HELPER -} // namespace memory +} // namespace memgraph::memory diff --git a/src/memory/memory_control.hpp b/src/memory/memory_control.hpp index d35fc0eaa..c1258becd 100644 --- a/src/memory/memory_control.hpp +++ b/src/memory/memory_control.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,6 +11,6 @@ #pragma once -namespace memory { +namespace memgraph::memory { void PurgeUnusedMemory(); -} // namespace memory +} // namespace memgraph::memory diff --git a/src/memory/new_delete.cpp b/src/memory/new_delete.cpp index 4264c29dd..9b71bd68e 100644 --- a/src/memory/new_delete.cpp +++ b/src/memory/new_delete.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -92,7 +92,7 @@ void TrackMemory(std::size_t size) { size = nallocx(size, 0); } #endif - utils::total_memory_tracker.Alloc(size); + memgraph::utils::total_memory_tracker.Alloc(size); } void TrackMemory(std::size_t size, const std::align_val_t align) { @@ -101,7 +101,7 @@ void TrackMemory(std::size_t size, const std::align_val_t align) { size = nallocx(size, MALLOCX_ALIGN(align)); // NOLINT(hicpp-signed-bitwise) } #endif - utils::total_memory_tracker.Alloc(size); + memgraph::utils::total_memory_tracker.Alloc(size); } bool TrackMemoryNoExcept(const std::size_t size) { @@ -128,14 +128,14 @@ void UntrackMemory([[maybe_unused]] void *ptr, [[maybe_unused]] std::size_t size try { #if USE_JEMALLOC if (ptr != nullptr) [[likely]] { - utils::total_memory_tracker.Free(sallocx(ptr, 0)); + memgraph::utils::total_memory_tracker.Free(sallocx(ptr, 0)); } #else if (size) { - utils::total_memory_tracker.Free(size); + memgraph::utils::total_memory_tracker.Free(size); } else { // Innaccurate because malloc_usable_size() result is greater or equal to allocated size. - utils::total_memory_tracker.Free(malloc_usable_size(ptr)); + memgraph::utils::total_memory_tracker.Free(malloc_usable_size(ptr)); } #endif } catch (...) { @@ -146,14 +146,14 @@ void UntrackMemory(void *ptr, const std::align_val_t align, [[maybe_unused]] std try { #if USE_JEMALLOC if (ptr != nullptr) [[likely]] { - utils::total_memory_tracker.Free(sallocx(ptr, MALLOCX_ALIGN(align))); // NOLINT(hicpp-signed-bitwise) + memgraph::utils::total_memory_tracker.Free(sallocx(ptr, MALLOCX_ALIGN(align))); // NOLINT(hicpp-signed-bitwise) } #else if (size) { - utils::total_memory_tracker.Free(size); + memgraph::utils::total_memory_tracker.Free(size); } else { // Innaccurate because malloc_usable_size() result is greater or equal to allocated size. - utils::total_memory_tracker.Free(malloc_usable_size(ptr)); + memgraph::utils::total_memory_tracker.Free(malloc_usable_size(ptr)); } #endif } catch (...) { diff --git a/src/mg_import_csv.cpp b/src/mg_import_csv.cpp index 1105c7633..05a1c398a 100644 --- a/src/mg_import_csv.cpp +++ b/src/mg_import_csv.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -41,7 +41,7 @@ bool ValidateControlCharacter(const char *flagname, const std::string &value) { } bool ValidateIdTypeOptions(const char *flagname, const std::string &value) { - std::string upper = utils::ToUpperCase(utils::Trim(value)); + std::string upper = memgraph::utils::ToUpperCase(memgraph::utils::Trim(value)); if (upper != "STRING" && upper != "INTEGER") { printf("Valid options for '%s' are: STRING/INTEGER\n", flagname); return false; @@ -99,9 +99,9 @@ std::vector ParseRepeatedFlag(const std::string &flagname, int argc for (int i = 1; i < argc; ++i) { std::string flag(argv[i]); int matched_flag_dashes = 0; - if (utils::StartsWith(flag, "--" + flagname)) + if (memgraph::utils::StartsWith(flag, "--" + flagname)) matched_flag_dashes = 2; - else if (utils::StartsWith(flag, "-" + flagname)) + else if (memgraph::utils::StartsWith(flag, "-" + flagname)) matched_flag_dashes = 1; // Get the value if we matched the flag. if (matched_flag_dashes != 0) { @@ -157,9 +157,9 @@ struct hash { } // namespace std // Exception used to indicate that something went wrong during data loading. -class LoadException : public utils::BasicException { +class LoadException : public memgraph::utils::BasicException { public: - using utils::BasicException::BasicException; + using memgraph::utils::BasicException::BasicException; }; enum class CsvParserState { @@ -171,7 +171,7 @@ enum class CsvParserState { }; bool SubstringStartsWith(const std::string_view &str, size_t pos, const std::string_view &what) { - return utils::StartsWith(utils::Substr(str, pos), what); + return memgraph::utils::StartsWith(memgraph::utils::Substr(str, pos), what); } /// This function reads a row from a CSV stream. @@ -322,7 +322,8 @@ std::pair, uint64_t> ReadRow(std::istream &stream) { } if (FLAGS_trim_strings) { - std::transform(std::begin(row), std::end(row), std::begin(row), [](const auto &item) { return utils::Trim(item); }); + std::transform(std::begin(row), std::end(row), std::begin(row), + [](const auto &item) { return memgraph::utils::Trim(item); }); } return {std::move(row), lines_count}; @@ -334,7 +335,7 @@ std::pair, uint64_t> ReadHeader(std::istream &stream) { std::vector fields; fields.reserve(row.size()); for (const auto &value : row) { - auto name_and_type = utils::Split(value, ":"); + auto name_and_type = memgraph::utils::Split(value, ":"); if (name_and_type.size() != 1U && name_and_type.size() != 2U) throw LoadException( "Expected a name and optionally a type, got '{}'. Did you specify a " @@ -343,7 +344,7 @@ std::pair, uint64_t> ReadHeader(std::istream &stream) { auto name = name_and_type[0]; // When type is missing, default is string. std::string type("string"); - if (name_and_type.size() == 2U) type = utils::Trim(name_and_type[1]); + if (name_and_type.size() == 2U) type = memgraph::utils::Trim(name_and_type[1]); fields.push_back(Field{name, type}); } return {std::move(fields), lines_count}; @@ -352,7 +353,7 @@ std::pair, uint64_t> ReadHeader(std::istream &stream) { /// @throw LoadException int64_t StringToInt(const std::string &value) { try { - return utils::ParseInt(value); + return memgraph::utils::ParseInt(value); } catch (...) { throw LoadException("'{}' isn't a valid integer", value); } @@ -361,42 +362,42 @@ int64_t StringToInt(const std::string &value) { /// @throw LoadException double StringToDouble(const std::string &value) { try { - return utils::ParseDouble(value); + return memgraph::utils::ParseDouble(value); } catch (...) { throw LoadException("'{}' isn't a valid floating-point value", value); } } /// @throw LoadException -storage::PropertyValue StringToValue(const std::string &str, const std::string &type) { - if (FLAGS_ignore_empty_strings && str.empty()) return storage::PropertyValue(); +memgraph::storage::PropertyValue StringToValue(const std::string &str, const std::string &type) { + if (FLAGS_ignore_empty_strings && str.empty()) return memgraph::storage::PropertyValue(); auto convert = [](const auto &str, const auto &type) { if (type == "integer" || type == "int" || type == "long" || type == "byte" || type == "short") { - return storage::PropertyValue(StringToInt(str)); + return memgraph::storage::PropertyValue(StringToInt(str)); } else if (type == "float" || type == "double") { - return storage::PropertyValue(StringToDouble(str)); + return memgraph::storage::PropertyValue(StringToDouble(str)); } else if (type == "boolean" || type == "bool") { - if (utils::ToLowerCase(str) == "true") { - return storage::PropertyValue(true); + if (memgraph::utils::ToLowerCase(str) == "true") { + return memgraph::storage::PropertyValue(true); } else { - return storage::PropertyValue(false); + return memgraph::storage::PropertyValue(false); } } else if (type == "char" || type == "string") { - return storage::PropertyValue(str); + return memgraph::storage::PropertyValue(str); } throw LoadException("Unexpected type: {}", type); }; // Type *not* ending with '[]', signifies regular value. - if (!utils::EndsWith(type, "[]")) return convert(str, type); + if (!memgraph::utils::EndsWith(type, "[]")) return convert(str, type); // Otherwise, we have an array type. auto elem_type = type.substr(0, type.size() - 2); - auto elems = utils::Split(str, FLAGS_array_delimiter); - std::vector array; + auto elems = memgraph::utils::Split(str, FLAGS_array_delimiter); + std::vector array; array.reserve(elems.size()); for (const auto &elem : elems) { array.push_back(convert(elem, elem_type)); } - return storage::PropertyValue(std::move(array)); + return memgraph::storage::PropertyValue(std::move(array)); } /// @throw LoadException @@ -415,16 +416,16 @@ std::string GetIdSpace(const std::string &type) { } /// @throw LoadException -void ProcessNodeRow(storage::Storage *store, const std::vector &fields, const std::vector &row, - const std::vector &additional_labels, - std::unordered_map *node_id_map) { +void ProcessNodeRow(memgraph::storage::Storage *store, const std::vector &fields, + const std::vector &row, const std::vector &additional_labels, + std::unordered_map *node_id_map) { std::optional id; auto acc = store->Access(); auto node = acc.CreateVertex(); for (size_t i = 0; i < row.size(); ++i) { const auto &field = fields[i]; const auto &value = row[i]; - if (utils::StartsWith(field.type, "ID")) { + if (memgraph::utils::StartsWith(field.type, "ID")) { if (id) throw LoadException("Only one node ID must be specified"); if (FLAGS_id_type == "INTEGER") { // Call `StringToInt` to verify that the ID is a valid integer. @@ -434,7 +435,8 @@ void ProcessNodeRow(storage::Storage *store, const std::vector &fields, c auto it = node_id_map->find(node_id); if (it != node_id_map->end()) { if (FLAGS_skip_duplicate_nodes) { - spdlog::warn(utils::MessageWithLink("Skipping duplicate node with ID '{}'.", node_id, "https://memgr.ph/csv")); + spdlog::warn(memgraph::utils::MessageWithLink("Skipping duplicate node with ID '{}'.", node_id, + "https://memgr.ph/csv")); return; } else { throw LoadException("Node with ID '{}' already exists", node_id); @@ -442,11 +444,11 @@ void ProcessNodeRow(storage::Storage *store, const std::vector &fields, c } node_id_map->emplace(node_id, node.Gid()); if (!field.name.empty()) { - storage::PropertyValue pv_id; + memgraph::storage::PropertyValue pv_id; if (FLAGS_id_type == "INTEGER") { - pv_id = storage::PropertyValue(StringToInt(node_id.id)); + pv_id = memgraph::storage::PropertyValue(StringToInt(node_id.id)); } else { - pv_id = storage::PropertyValue(node_id.id); + pv_id = memgraph::storage::PropertyValue(node_id.id); } auto old_node_property = node.SetProperty(acc.NameToProperty(field.name), pv_id); if (!old_node_property.HasValue()) throw LoadException("Couldn't add property '{}' to the node", field.name); @@ -454,7 +456,7 @@ void ProcessNodeRow(storage::Storage *store, const std::vector &fields, c } id = node_id; } else if (field.type == "LABEL") { - for (const auto &label : utils::Split(value, FLAGS_array_delimiter)) { + for (const auto &label : memgraph::utils::Split(value, FLAGS_array_delimiter)) { auto node_label = node.AddLabel(acc.NameToLabel(label)); if (!node_label.HasValue()) throw LoadException("Couldn't add label '{}' to the node", label); if (!*node_label) throw LoadException("The label '{}' already exists", label); @@ -473,8 +475,9 @@ void ProcessNodeRow(storage::Storage *store, const std::vector &fields, c if (acc.Commit().HasError()) throw LoadException("Couldn't store the node"); } -void ProcessNodes(storage::Storage *store, const std::string &nodes_path, std::optional> *header, - std::unordered_map *node_id_map, +void ProcessNodes(memgraph::storage::Storage *store, const std::string &nodes_path, + std::optional> *header, + std::unordered_map *node_id_map, const std::vector &additional_labels) { std::ifstream nodes_file(nodes_path); MG_ASSERT(nodes_file, "Unable to open '{}'", nodes_path); @@ -506,16 +509,16 @@ void ProcessNodes(storage::Storage *store, const std::string &nodes_path, std::o } /// @throw LoadException -void ProcessRelationshipsRow(storage::Storage *store, const std::vector &fields, +void ProcessRelationshipsRow(memgraph::storage::Storage *store, const std::vector &fields, const std::vector &row, std::optional relationship_type, - const std::unordered_map &node_id_map) { - std::optional start_id; - std::optional end_id; - std::map properties; + const std::unordered_map &node_id_map) { + std::optional start_id; + std::optional end_id; + std::map properties; for (size_t i = 0; i < row.size(); ++i) { const auto &field = fields[i]; const auto &value = row[i]; - if (utils::StartsWith(field.type, "START_ID")) { + if (memgraph::utils::StartsWith(field.type, "START_ID")) { if (start_id) throw LoadException("Only one node ID must be specified"); if (FLAGS_id_type == "INTEGER") { // Call `StringToInt` to verify that the START_ID is a valid integer. @@ -525,15 +528,15 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector & auto it = node_id_map.find(node_id); if (it == node_id_map.end()) { if (FLAGS_skip_bad_relationships) { - spdlog::warn( - utils::MessageWithLink("Skipping bad relationship with START_ID '{}'.", node_id, "https://memgr.ph/csv")); + spdlog::warn(memgraph::utils::MessageWithLink("Skipping bad relationship with START_ID '{}'.", node_id, + "https://memgr.ph/csv")); return; } else { throw LoadException("Node with ID '{}' does not exist", node_id); } } start_id = it->second; - } else if (utils::StartsWith(field.type, "END_ID")) { + } else if (memgraph::utils::StartsWith(field.type, "END_ID")) { if (end_id) throw LoadException("Only one node ID must be specified"); if (FLAGS_id_type == "INTEGER") { // Call `StringToInt` to verify that the END_ID is a valid integer. @@ -543,7 +546,8 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector & auto it = node_id_map.find(node_id); if (it == node_id_map.end()) { if (FLAGS_skip_bad_relationships) { - spdlog::warn(utils::MessageWithLink("Skipping bad relationship with END_ID '{}'.", node_id, "https://memgr.ph/csv")); + spdlog::warn(memgraph::utils::MessageWithLink("Skipping bad relationship with END_ID '{}'.", node_id, + "https://memgr.ph/csv")); return; } else { throw LoadException("Node with ID '{}' does not exist", node_id); @@ -563,9 +567,9 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector & if (!relationship_type) throw LoadException("Relationship TYPE must be set"); auto acc = store->Access(); - auto from_node = acc.FindVertex(*start_id, storage::View::NEW); + auto from_node = acc.FindVertex(*start_id, memgraph::storage::View::NEW); if (!from_node) throw LoadException("From node must be in the storage"); - auto to_node = acc.FindVertex(*end_id, storage::View::NEW); + auto to_node = acc.FindVertex(*end_id, memgraph::storage::View::NEW); if (!to_node) throw LoadException("To node must be in the storage"); auto relationship = acc.CreateEdge(&*from_node, &*to_node, acc.NameToEdgeType(*relationship_type)); @@ -574,7 +578,7 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector & for (const auto &property : properties) { auto ret = relationship->SetProperty(acc.NameToProperty(property.first), property.second); if (!ret.HasValue()) { - if (ret.GetError() != storage::Error::PROPERTIES_DISABLED) { + if (ret.GetError() != memgraph::storage::Error::PROPERTIES_DISABLED) { throw LoadException("Couldn't add property '{}' to the relationship", property.first); } else { throw LoadException( @@ -588,10 +592,10 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector & if (acc.Commit().HasError()) throw LoadException("Couldn't store the relationship"); } -void ProcessRelationships(storage::Storage *store, const std::string &relationships_path, +void ProcessRelationships(memgraph::storage::Storage *store, const std::string &relationships_path, const std::optional &relationship_type, std::optional> *header, - const std::unordered_map &node_id_map) { + const std::unordered_map &node_id_map) { std::ifstream relationships_file(relationships_path); MG_ASSERT(relationships_file, "Unable to open '{}'", relationships_path); uint64_t row_number = 1; @@ -639,11 +643,11 @@ NodesArgument ParseNodesArgument(const std::string &value) { auto pos_equal = value.find('='); if (pos_equal != std::string::npos) { // We have additional labels. - additional_labels = utils::Split(value.substr(0, pos_equal), ":"); + additional_labels = memgraph::utils::Split(value.substr(0, pos_equal), ":"); pos_nodes = pos_equal + 1; } - nodes = utils::Split(value.substr(pos_nodes), ","); + nodes = memgraph::utils::Split(value.substr(pos_nodes), ","); return {std::move(nodes), std::move(additional_labels)}; } @@ -670,7 +674,7 @@ RelationshipsArgument ParseRelationshipsArgument(const std::string &value) { pos_relationships = pos_equal + 1; } - relationships = utils::Split(value.substr(pos_relationships), ","); + relationships = memgraph::utils::Split(value.substr(pos_relationships), ","); return {std::move(relationships), std::move(type)}; } @@ -690,20 +694,20 @@ int main(int argc, char *argv[]) { MG_ASSERT(!nodes.empty(), "The --nodes flag is required!"); { - std::string upper = utils::ToUpperCase(utils::Trim(FLAGS_id_type)); + std::string upper = memgraph::utils::ToUpperCase(memgraph::utils::Trim(FLAGS_id_type)); FLAGS_id_type = upper; } - std::unordered_map node_id_map; - storage::Storage store{{ + std::unordered_map node_id_map; + memgraph::storage::Storage store{{ .items = {.properties_on_edges = FLAGS_storage_properties_on_edges}, .durability = {.storage_directory = FLAGS_data_directory, .recover_on_startup = false, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::DISABLED, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::DISABLED, .snapshot_on_exit = true}, }}; - utils::Timer load_timer; + memgraph::utils::Timer load_timer; // Process all nodes files. for (const auto &value : nodes) { diff --git a/src/py/py.hpp b/src/py/py.hpp index 098f3f93f..14d54d657 100644 --- a/src/py/py.hpp +++ b/src/py/py.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -29,7 +29,7 @@ #include "utils/logging.hpp" -namespace py { +namespace memgraph::py { /// Ensure the current thread is ready to call Python C API. /// @@ -273,4 +273,4 @@ inline void RestoreError(ExceptionInfo exc_info) { return std::nullopt; } -} // namespace py +} // namespace memgraph::py diff --git a/src/query/auth_checker.hpp b/src/query/auth_checker.hpp index 6311159f7..807e3dbbd 100644 --- a/src/query/auth_checker.hpp +++ b/src/query/auth_checker.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,17 +13,17 @@ #include "query/frontend/ast/ast.hpp" -namespace query { +namespace memgraph::query { class AuthChecker { public: virtual bool IsUserAuthorized(const std::optional &username, - const std::vector &privileges) const = 0; + const std::vector &privileges) const = 0; }; -class AllowEverythingAuthChecker final : public query::AuthChecker { +class AllowEverythingAuthChecker final : public memgraph::query::AuthChecker { bool IsUserAuthorized(const std::optional &username, - const std::vector &privileges) const override { + const std::vector &privileges) const override { return true; } }; -} // namespace query \ No newline at end of file +} // namespace memgraph::query \ No newline at end of file diff --git a/src/query/common.cpp b/src/query/common.cpp index b83851e6a..0bf56baa0 100644 --- a/src/query/common.cpp +++ b/src/query/common.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "query/common.hpp" -namespace query { +namespace memgraph::query { namespace impl { @@ -73,4 +73,4 @@ int64_t QueryTimestamp() { return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()) .count(); } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/common.hpp b/src/query/common.hpp index c855d3885..c51c34dee 100644 --- a/src/query/common.hpp +++ b/src/query/common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,7 +27,7 @@ #include "storage/v2/view.hpp" #include "utils/logging.hpp" -namespace query { +namespace memgraph::query { namespace impl { bool TypedValueCompare(const TypedValue &a, const TypedValue &b); @@ -108,4 +108,4 @@ storage::PropertyValue PropsSetChecked(T *record, const storage::PropertyId &key } int64_t QueryTimestamp(); -} // namespace query +} // namespace memgraph::query diff --git a/src/query/config.hpp b/src/query/config.hpp index aaee9326d..0ddaba11b 100644 --- a/src/query/config.hpp +++ b/src/query/config.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include #include -namespace query { +namespace memgraph::query { struct InterpreterConfig { struct Query { bool allow_load_csv{true}; @@ -27,4 +27,4 @@ struct InterpreterConfig { uint32_t stream_transaction_conflict_retries; std::chrono::milliseconds stream_transaction_retry_interval; }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/constants.hpp b/src/query/constants.hpp index 1c9a525ca..3303a65c4 100644 --- a/src/query/constants.hpp +++ b/src/query/constants.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include #include -namespace query { +namespace memgraph::query { constexpr uint16_t kDefaultReplicationPort = 10000; constexpr auto *kDefaultReplicationServerIp = "0.0.0.0"; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/context.hpp b/src/query/context.hpp index f93f7fd2f..12b1f0cac 100644 --- a/src/query/context.hpp +++ b/src/query/context.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "query/trigger.hpp" #include "utils/async_timer.hpp" -namespace query { +namespace memgraph::query { struct EvaluationContext { /// Memory for allocations during evaluation of a *single* Pull call. @@ -86,4 +86,4 @@ inline plan::ProfilingStatsWithTotalTime GetStatsWithTotalTime(const ExecutionCo return plan::ProfilingStatsWithTotalTime{context.stats, context.profile_execution_time}; } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/cypher_query_interpreter.cpp b/src/query/cypher_query_interpreter.cpp index c054be329..1383c4ea9 100644 --- a/src/query/cypher_query_interpreter.cpp +++ b/src/query/cypher_query_interpreter.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ DEFINE_HIDDEN_bool(query_cost_planner, true, "Use the cost-estimating query plan DEFINE_VALIDATED_int32(query_plan_cache_ttl, 60, "Time to live for cached query plans, in seconds.", FLAG_IN_RANGE(0, std::numeric_limits::max())); -namespace query { +namespace memgraph::query { CachedPlan::CachedPlan(std::unique_ptr plan) : plan_(std::move(plan)) {} ParsedQuery ParseQuery(const std::string &query_string, const std::map ¶ms, @@ -37,7 +37,7 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::mapsecond); @@ -91,7 +91,8 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::mapsecond); @@ -101,7 +102,7 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::mapClone(&result.ast_storage); - result.required_privileges = query::GetRequiredPrivileges(visitor.query()); + result.required_privileges = memgraph::query::GetRequiredPrivileges(visitor.query()); is_cacheable = false; } @@ -154,4 +155,4 @@ std::shared_ptr CypherQueryToPlan(uint64_t hash, AstStorage ast_stor } return plan; } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/cypher_query_interpreter.hpp b/src/query/cypher_query_interpreter.hpp index 620fab0da..2318cae3f 100644 --- a/src/query/cypher_query_interpreter.hpp +++ b/src/query/cypher_query_interpreter.hpp @@ -26,7 +26,7 @@ DECLARE_bool(query_cost_planner); // NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables) DECLARE_int32(query_plan_cache_ttl); -namespace query { +namespace memgraph::query { // TODO: Maybe this should move to query/plan/planner. /// Interface for accessing the root operator of a logical plan. @@ -149,4 +149,4 @@ std::shared_ptr CypherQueryToPlan(uint64_t hash, AstStorage ast_stor DbAccessor *db_accessor, const std::vector &predefined_identifiers = {}); -} // namespace query +} // namespace memgraph::query diff --git a/src/query/db_accessor.hpp b/src/query/db_accessor.hpp index 80fd70b84..55514c883 100644 --- a/src/query/db_accessor.hpp +++ b/src/query/db_accessor.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -43,7 +43,7 @@ #include "utils/bound.hpp" #include "utils/exceptions.hpp" -namespace query { +namespace memgraph::query { class VertexAccessor; @@ -358,18 +358,18 @@ class DbAccessor final { storage::ConstraintsInfo ListAllConstraints() const { return accessor_->ListAllConstraints(); } }; -} // namespace query +} // namespace memgraph::query namespace std { template <> -struct hash { - size_t operator()(const query::VertexAccessor &v) const { return std::hash{}(v.impl_); } +struct hash { + size_t operator()(const memgraph::query::VertexAccessor &v) const { return std::hash{}(v.impl_); } }; template <> -struct hash { - size_t operator()(const query::EdgeAccessor &e) const { return std::hash{}(e.impl_); } +struct hash { + size_t operator()(const memgraph::query::EdgeAccessor &e) const { return std::hash{}(e.impl_); } }; } // namespace std diff --git a/src/query/discard_value_stream.hpp b/src/query/discard_value_stream.hpp index 05ffcb267..0f50eb7fd 100644 --- a/src/query/discard_value_stream.hpp +++ b/src/query/discard_value_stream.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,10 +15,10 @@ #include "query/typed_value.hpp" -namespace query { +namespace memgraph::query { struct DiscardValueResultStream final { - void Result(const std::vector & /*values*/) { + void Result(const std::vector & /*values*/) { // do nothing } }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/dump.cpp b/src/query/dump.cpp index f5bfa4392..d12473a55 100644 --- a/src/query/dump.cpp +++ b/src/query/dump.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -32,7 +32,7 @@ #include "utils/string.hpp" #include "utils/temporal.hpp" -namespace query { +namespace memgraph::query { namespace { @@ -121,7 +121,7 @@ void DumpPropertyValue(std::ostream *os, const storage::PropertyValue &value) { *os << (value.ValueBool() ? "true" : "false"); return; case storage::PropertyValue::Type::String: - *os << ::utils::Escape(value.ValueString()); + *os << utils::Escape(value.ValueString()); return; case storage::PropertyValue::Type::Int: *os << value.ValueInt(); @@ -153,7 +153,7 @@ void DumpPropertyValue(std::ostream *os, const storage::PropertyValue &value) { } } -void DumpProperties(std::ostream *os, query::DbAccessor *dba, +void DumpProperties(std::ostream *os, memgraph::query::DbAccessor *dba, const std::map &store, std::optional property_id = std::nullopt) { *os << "{"; @@ -168,20 +168,20 @@ void DumpProperties(std::ostream *os, query::DbAccessor *dba, *os << "}"; } -void DumpVertex(std::ostream *os, query::DbAccessor *dba, const query::VertexAccessor &vertex) { +void DumpVertex(std::ostream *os, memgraph::query::DbAccessor *dba, const memgraph::query::VertexAccessor &vertex) { *os << "CREATE ("; *os << ":" << kInternalVertexLabel; auto maybe_labels = vertex.Labels(storage::View::OLD); if (maybe_labels.HasError()) { switch (maybe_labels.GetError()) { case storage::Error::DELETED_OBJECT: - throw query::QueryRuntimeException("Trying to get labels from a deleted node."); + throw memgraph::query::QueryRuntimeException("Trying to get labels from a deleted node."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get labels from a node that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get labels from a node that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: - throw query::QueryRuntimeException("Unexpected error when getting labels."); + throw memgraph::query::QueryRuntimeException("Unexpected error when getting labels."); } } for (const auto &label : *maybe_labels) { @@ -192,20 +192,20 @@ void DumpVertex(std::ostream *os, query::DbAccessor *dba, const query::VertexAcc if (maybe_props.HasError()) { switch (maybe_props.GetError()) { case storage::Error::DELETED_OBJECT: - throw query::QueryRuntimeException("Trying to get properties from a deleted object."); + throw memgraph::query::QueryRuntimeException("Trying to get properties from a deleted object."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get properties from a node that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get properties from a node that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: - throw query::QueryRuntimeException("Unexpected error when getting properties."); + throw memgraph::query::QueryRuntimeException("Unexpected error when getting properties."); } } DumpProperties(os, dba, *maybe_props, vertex.CypherId()); *os << ");"; } -void DumpEdge(std::ostream *os, query::DbAccessor *dba, const query::EdgeAccessor &edge) { +void DumpEdge(std::ostream *os, memgraph::query::DbAccessor *dba, const memgraph::query::EdgeAccessor &edge) { *os << "MATCH "; *os << "(u:" << kInternalVertexLabel << "), "; *os << "(v:" << kInternalVertexLabel << ")"; @@ -219,13 +219,13 @@ void DumpEdge(std::ostream *os, query::DbAccessor *dba, const query::EdgeAccesso if (maybe_props.HasError()) { switch (maybe_props.GetError()) { case storage::Error::DELETED_OBJECT: - throw query::QueryRuntimeException("Trying to get properties from a deleted object."); + throw memgraph::query::QueryRuntimeException("Trying to get properties from a deleted object."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get properties from an edge that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get properties from an edge that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: - throw query::QueryRuntimeException("Unexpected error when getting properties."); + throw memgraph::query::QueryRuntimeException("Unexpected error when getting properties."); } } if (maybe_props->size() > 0) { @@ -235,23 +235,23 @@ void DumpEdge(std::ostream *os, query::DbAccessor *dba, const query::EdgeAccesso *os << "]->(v);"; } -void DumpLabelIndex(std::ostream *os, query::DbAccessor *dba, const storage::LabelId label) { +void DumpLabelIndex(std::ostream *os, memgraph::query::DbAccessor *dba, const storage::LabelId label) { *os << "CREATE INDEX ON :" << EscapeName(dba->LabelToName(label)) << ";"; } -void DumpLabelPropertyIndex(std::ostream *os, query::DbAccessor *dba, storage::LabelId label, +void DumpLabelPropertyIndex(std::ostream *os, memgraph::query::DbAccessor *dba, storage::LabelId label, storage::PropertyId property) { *os << "CREATE INDEX ON :" << EscapeName(dba->LabelToName(label)) << "(" << EscapeName(dba->PropertyToName(property)) << ");"; } -void DumpExistenceConstraint(std::ostream *os, query::DbAccessor *dba, storage::LabelId label, +void DumpExistenceConstraint(std::ostream *os, memgraph::query::DbAccessor *dba, storage::LabelId label, storage::PropertyId property) { *os << "CREATE CONSTRAINT ON (u:" << EscapeName(dba->LabelToName(label)) << ") ASSERT EXISTS (u." << EscapeName(dba->PropertyToName(property)) << ");"; } -void DumpUniqueConstraint(std::ostream *os, query::DbAccessor *dba, storage::LabelId label, +void DumpUniqueConstraint(std::ostream *os, memgraph::query::DbAccessor *dba, storage::LabelId label, const std::set &properties) { *os << "CREATE CONSTRAINT ON (u:" << EscapeName(dba->LabelToName(label)) << ") ASSERT "; utils::PrintIterable(*os, properties, ", ", [&dba](auto &stream, const auto &property) { @@ -536,6 +536,8 @@ PullPlanDump::PullChunk PullPlanDump::CreateInternalIndexCleanupPullChunk() { }; } -void DumpDatabaseToCypherQueries(query::DbAccessor *dba, AnyStream *stream) { PullPlanDump(dba).Pull(stream, {}); } +void DumpDatabaseToCypherQueries(memgraph::query::DbAccessor *dba, AnyStream *stream) { + PullPlanDump(dba).Pull(stream, {}); +} -} // namespace query +} // namespace memgraph::query diff --git a/src/query/dump.hpp b/src/query/dump.hpp index 546f6a74c..56a1d4d88 100644 --- a/src/query/dump.hpp +++ b/src/query/dump.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,24 +17,24 @@ #include "query/stream.hpp" #include "storage/v2/storage.hpp" -namespace query { +namespace memgraph::query { -void DumpDatabaseToCypherQueries(query::DbAccessor *dba, AnyStream *stream); +void DumpDatabaseToCypherQueries(memgraph::query::DbAccessor *dba, AnyStream *stream); struct PullPlanDump { - explicit PullPlanDump(query::DbAccessor *dba); + explicit PullPlanDump(memgraph::query::DbAccessor *dba); /// Pull the dump results lazily /// @return true if all results were returned, false otherwise bool Pull(AnyStream *stream, std::optional n); private: - query::DbAccessor *dba_ = nullptr; + memgraph::query::DbAccessor *dba_ = nullptr; std::optional indices_info_ = std::nullopt; std::optional constraints_info_ = std::nullopt; - using VertexAccessorIterable = decltype(std::declval().Vertices(storage::View::OLD)); + using VertexAccessorIterable = decltype(std::declval().Vertices(storage::View::OLD)); using VertexAccessorIterableIterator = decltype(std::declval().begin()); using EdgeAccessorIterable = decltype(std::declval().OutEdges(storage::View::OLD)); @@ -63,4 +63,4 @@ struct PullPlanDump { PullChunk CreateDropInternalIndexPullChunk(); PullChunk CreateInternalIndexCleanupPullChunk(); }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/exceptions.hpp b/src/query/exceptions.hpp index 885e7eebb..a18ce0c43 100644 --- a/src/query/exceptions.hpp +++ b/src/query/exceptions.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include -namespace query { +namespace memgraph::query { /** * @brief Base class of all query language related exceptions. All exceptions @@ -224,4 +224,4 @@ class VersionInfoInMulticommandTxException : public QueryException { : QueryException("Version info query not allowed in multicommand transactions.") {} }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/frontend/ast/ast.lcp b/src/query/frontend/ast/ast.lcp index 073bda3ad..13c79550f 100644 --- a/src/query/frontend/ast/ast.lcp +++ b/src/query/frontend/ast/ast.lcp @@ -1,4 +1,4 @@ -;; Copyright 2021 Memgraph Ltd. +;; Copyright 2022 Memgraph Ltd. ;; ;; Use of this software is governed by the Business Source License ;; included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,6 +26,7 @@ cpp<# +(lcp:namespace memgraph) (lcp:namespace query) (defun slk-save-ast-pointer (member) @@ -42,7 +43,7 @@ cpp<# (defun slk-save-ast-vector (member) #>cpp size_t size = self.${member}.size(); - slk::Save(size, builder); + memgraph::slk::Save(size, builder); for (const auto *val : self.${member}) { query::SaveAstPointer(val, builder); } @@ -52,7 +53,7 @@ cpp<# (lambda (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); self->${member}.resize(size); for (size_t i = 0; i < size; ++i) { self->${member}[i] = query::LoadAstPointer(storage, reader); @@ -62,9 +63,9 @@ cpp<# (defun slk-save-property-map (member) #>cpp size_t size = self.${member}.size(); - slk::Save(size, builder); + memgraph::slk::Save(size, builder); for (const auto &entry : self.${member}) { - slk::Save(entry.first, builder); + memgraph::slk::Save(entry.first, builder); query::SaveAstPointer(entry.second, builder); } cpp<#) @@ -72,10 +73,10 @@ cpp<# (defun slk-load-property-map (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); for (size_t i = 0; i < size; ++i) { query::PropertyIx key; - slk::Load(&key, reader, storage); + memgraph::slk::Load(&key, reader, storage); auto *value = query::LoadAstPointer(storage, reader); self->${member}.emplace(key, value); } @@ -92,7 +93,7 @@ cpp<# (defun slk-save-expression-map (member) #>cpp size_t size = self.${member}.size(); - slk::Save(size, builder); + memgraph::slk::Save(size, builder); for (const auto &entry : self.${member}) { query::SaveAstPointer(entry.first, builder); query::SaveAstPointer(entry.second, builder); @@ -102,7 +103,7 @@ cpp<# (defun slk-load-expression-map (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); for (size_t i = 0; i < size; ++i) { auto *key = query::LoadAstPointer(storage, reader); auto *value = query::LoadAstPointer(storage, reader); @@ -190,23 +191,24 @@ inline bool operator!=(const EdgeTypeIx &a, const EdgeTypeIx &b) { cpp<# (lcp:pop-namespace) ;; namespace query +(lcp:pop-namespace) ;; namespace memgraph #>cpp namespace std { template <> -struct hash { - size_t operator()(const query::LabelIx &label) const { return label.ix; } +struct hash { + size_t operator()(const memgraph::query::LabelIx &label) const { return label.ix; } }; template <> -struct hash { - size_t operator()(const query::PropertyIx &prop) const { return prop.ix; } +struct hash { + size_t operator()(const memgraph::query::PropertyIx &prop) const { return prop.ix; } }; template <> -struct hash { - size_t operator()(const query::EdgeTypeIx &edge_type) const { +struct hash { + size_t operator()(const memgraph::query::EdgeTypeIx &edge_type) const { return edge_type.ix; } }; @@ -214,6 +216,7 @@ struct hash { } // namespace std cpp<# +(lcp:namespace memgraph) (lcp:namespace query) #>cpp @@ -296,16 +299,16 @@ cpp<# ;;; Expressions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(lcp:define-class expression (tree "::utils::Visitable" - "::utils::Visitable>" - "::utils::Visitable>") +(lcp:define-class expression (tree "utils::Visitable" + "utils::Visitable>" + "utils::Visitable>") () (:abstractp t) (:public #>cpp - using ::utils::Visitable::Accept; - using ::utils::Visitable>::Accept; - using ::utils::Visitable>::Accept; + using utils::Visitable::Accept; + using utils::Visitable>::Accept; + using utils::Visitable>::Accept; Expression() = default; cpp<#) @@ -317,13 +320,13 @@ cpp<# (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) -(lcp:define-class where (tree "::utils::Visitable") +(lcp:define-class where (tree "utils::Visitable") ((expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression"))) (:public #>cpp - using ::utils::Visitable::Accept; + using utils::Visitable::Accept; Where() = default; @@ -741,7 +744,7 @@ cpp<# (property "PropertyIx" :scope :public :slk-load (lambda (member) #>cpp - slk::Load(&self->${member}, reader, storage); + memgraph::slk::Load(&self->${member}, reader, storage); cpp<#) :clone (lambda (source dest) #>cpp @@ -780,10 +783,10 @@ cpp<# :slk-load (lambda (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); self->${member}.resize(size); for (size_t i = 0; i < size; ++i) { - slk::Load(&self->${member}[i], reader, storage); + memgraph::slk::Load(&self->${member}[i], reader, storage); } cpp<#) :clone (clone-name-ix-vector "Label"))) @@ -1196,9 +1199,9 @@ cpp<# (:serialize (:slk)) (:clone)) -(lcp:define-class named-expression (tree "::utils::Visitable" - "::utils::Visitable>" - "::utils::Visitable>") +(lcp:define-class named-expression (tree "utils::Visitable" + "utils::Visitable>" + "utils::Visitable>") ((name "std::string" :scope :public) (expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer @@ -1209,9 +1212,9 @@ cpp<# :documentation "Symbol table position of the symbol this NamedExpression is mapped to.")) (:public #>cpp - using ::utils::Visitable>::Accept; - using ::utils::Visitable>::Accept; - using ::utils::Visitable::Accept; + using utils::Visitable>::Accept; + using utils::Visitable>::Accept; + using utils::Visitable::Accept; NamedExpression() = default; @@ -1250,14 +1253,14 @@ cpp<# ;;; END Expressions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(lcp:define-class pattern-atom (tree "::utils::Visitable") +(lcp:define-class pattern-atom (tree "utils::Visitable") ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Identifier"))) (:abstractp t) (:public #>cpp - using ::utils::Visitable::Accept; + using utils::Visitable::Accept; PatternAtom() = default; cpp<#) @@ -1291,10 +1294,10 @@ cpp<# :slk-load (lambda (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); self->${member}.resize(size); for (size_t i = 0; i < size; ++i) { - slk::Load(&self->${member}[i], reader, storage); + memgraph::slk::Load(&self->${member}[i], reader, storage); } cpp<#) :clone (clone-name-ix-vector "Label")) @@ -1337,10 +1340,10 @@ cpp<# :slk-load (lambda (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); self->${member}.resize(size); for (size_t i = 0; i < size; ++i) { - slk::Load(&self->${member}[i], reader, storage); + memgraph::slk::Load(&self->${member}[i], reader, storage); } cpp<#) :clone (clone-name-ix-vector "EdgeType")) @@ -1361,13 +1364,13 @@ cpp<# :documentation "Filter lambda for variable length expands. Can have an empty expression, but identifiers must be valid, because an optimization pass may inline other expressions into this lambda." :slk-load (lambda (member) #>cpp - slk::Load(&self->${member}, reader, storage); + memgraph::slk::Load(&self->${member}, reader, storage); cpp<#)) (weight-lambda "Lambda" :scope :public :documentation "Used in weighted shortest path. It must have valid expressions and identifiers. In all other expand types, it is empty." :slk-load (lambda (member) #>cpp - slk::Load(&self->${member}, reader, storage); + memgraph::slk::Load(&self->${member}, reader, storage); cpp<#)) (total-weight "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer @@ -1454,7 +1457,7 @@ cpp<# (:serialize (:slk)) (:clone)) -(lcp:define-class pattern (tree "::utils::Visitable") +(lcp:define-class pattern (tree "utils::Visitable") ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Identifier")) @@ -1464,7 +1467,7 @@ cpp<# :slk-load (slk-load-ast-vector "PatternAtom"))) (:public #>cpp - using ::utils::Visitable::Accept; + using utils::Visitable::Accept; Pattern() = default; @@ -1488,12 +1491,12 @@ cpp<# (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) -(lcp:define-class clause (tree "::utils::Visitable") +(lcp:define-class clause (tree "utils::Visitable") () (:abstractp t) (:public #>cpp - using ::utils::Visitable::Accept; + using utils::Visitable::Accept; Clause() = default; cpp<#) @@ -1505,14 +1508,14 @@ cpp<# (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) -(lcp:define-class single-query (tree "::utils::Visitable") +(lcp:define-class single-query (tree "utils::Visitable") ((clauses "std::vector" :scope :public :slk-save #'slk-save-ast-vector :slk-load (slk-load-ast-vector "Clause"))) (:public #>cpp - using ::utils::Visitable::Accept; + using utils::Visitable::Accept; SingleQuery() = default; @@ -1533,7 +1536,7 @@ cpp<# (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) -(lcp:define-class cypher-union (tree "::utils::Visitable") +(lcp:define-class cypher-union (tree "utils::Visitable") ((single-query "SingleQuery *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "SingleQuery")) @@ -1542,7 +1545,7 @@ cpp<# :documentation "Holds symbols that are created during symbol generation phase. These symbols are used when UNION/UNION ALL combines single query results.")) (:public #>cpp - using ::utils::Visitable::Accept; + using utils::Visitable::Accept; CypherUnion() = default; @@ -1570,12 +1573,12 @@ cpp<# (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) -(lcp:define-class query (tree "::utils::Visitable>") +(lcp:define-class query (tree "utils::Visitable>") () (:abstractp t) (:public #>cpp - using ::utils::Visitable>::Accept; + using utils::Visitable>::Accept; Query() = default; cpp<#) @@ -1657,7 +1660,7 @@ cpp<# (label "LabelIx" :scope :public :slk-load (lambda (member) #>cpp - slk::Load(&self->${member}, reader, storage); + memgraph::slk::Load(&self->${member}, reader, storage); cpp<#) :clone (lambda (source dest) #>cpp @@ -1667,10 +1670,10 @@ cpp<# :slk-load (lambda (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); self->${member}.resize(size); for (size_t i = 0; i < size; ++i) { - slk::Load(&self->${member}[i], reader, storage); + memgraph::slk::Load(&self->${member}[i], reader, storage); } cpp<#) :clone (clone-name-ix-vector "Property"))) @@ -1841,10 +1844,10 @@ cpp<# :slk-load (lambda (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); self->${member}.resize(size); for (size_t i = 0; i < size; ++i) { - slk::Load(&self->${member}[i], reader, storage); + memgraph::slk::Load(&self->${member}[i], reader, storage); } cpp<#) :documentation "Expressions used for ordering the results.") @@ -1864,7 +1867,7 @@ cpp<# ((body "ReturnBody" :scope :public :slk-load (lambda (member) #>cpp - slk::Load(&self->${member}, reader, storage); + memgraph::slk::Load(&self->${member}, reader, storage); cpp<#))) (:public #>cpp @@ -1908,7 +1911,7 @@ cpp<# ((body "ReturnBody" :scope :public :slk-load (lambda (member) #>cpp - slk::Load(&self->${member}, reader, storage); + memgraph::slk::Load(&self->${member}, reader, storage); cpp<#)) (where "Where *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer @@ -2053,10 +2056,10 @@ cpp<# :slk-load (lambda (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); self->${member}.resize(size); for (size_t i = 0; i < size; ++i) { - slk::Load(&self->${member}[i], reader, storage); + memgraph::slk::Load(&self->${member}[i], reader, storage); } cpp<#) :clone (clone-name-ix-vector "Label"))) @@ -2118,10 +2121,10 @@ cpp<# :slk-load (lambda (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); self->${member}.resize(size); for (size_t i = 0; i < size; ++i) { - slk::Load(&self->${member}[i], reader, storage); + memgraph::slk::Load(&self->${member}[i], reader, storage); } cpp<#) :clone (clone-name-ix-vector "Label"))) @@ -2311,7 +2314,7 @@ cpp<# (label "LabelIx" :scope :public :slk-load (lambda (member) #>cpp - slk::Load(&self->${member}, reader, storage); + memgraph::slk::Load(&self->${member}, reader, storage); cpp<#) :clone (lambda (source dest) #>cpp @@ -2321,10 +2324,10 @@ cpp<# :slk-load (lambda (member) #>cpp size_t size = 0; - slk::Load(&size, reader); + memgraph::slk::Load(&size, reader); self->${member}.resize(size); for (size_t i = 0; i < size; ++i) { - slk::Load(&self->${member}[i], reader, storage); + memgraph::slk::Load(&self->${member}[i], reader, storage); } cpp<#) :clone (clone-name-ix-vector "Property"))) @@ -2339,7 +2342,7 @@ cpp<# (constraint "Constraint" :scope :public :slk-load (lambda (member) #>cpp - slk::Load(&self->${member}, reader, storage); + memgraph::slk::Load(&self->${member}, reader, storage); cpp<#))) (:public (lcp:define-enum action-type @@ -2627,3 +2630,4 @@ cpp<# (:clone)) (lcp:pop-namespace) ;; namespace query +(lcp:pop-namespace) ;; namespace memgraph diff --git a/src/query/frontend/ast/ast_visitor.hpp b/src/query/frontend/ast/ast_visitor.hpp index 022af65ef..c5182479c 100644 --- a/src/query/frontend/ast/ast_visitor.hpp +++ b/src/query/frontend/ast/ast_visitor.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include "utils/visitor.hpp" -namespace query { +namespace memgraph::query { // Forward declares for Tree visitors. class CypherQuery; @@ -94,7 +94,7 @@ class StreamQuery; class SettingQuery; class VersionQuery; -using TreeCompositeVisitor = ::utils::CompositeVisitor< +using TreeCompositeVisitor = utils::CompositeVisitor< SingleQuery, CypherUnion, NamedExpression, OrOperator, XorOperator, AndOperator, NotOperator, AdditionOperator, SubtractionOperator, MultiplicationOperator, DivisionOperator, ModOperator, NotEqualOperator, EqualOperator, LessOperator, GreaterOperator, LessEqualOperator, GreaterEqualOperator, InListOperator, SubscriptOperator, @@ -103,7 +103,7 @@ using TreeCompositeVisitor = ::utils::CompositeVisitor< Create, Match, Return, With, Pattern, NodeAtom, EdgeAtom, Delete, Where, SetProperty, SetProperties, SetLabels, RemoveProperty, RemoveLabels, Merge, Unwind, RegexMatch, LoadCsv>; -using TreeLeafVisitor = ::utils::LeafVisitor; +using TreeLeafVisitor = utils::LeafVisitor; class HierarchicalTreeVisitor : public TreeCompositeVisitor, public TreeLeafVisitor { public: @@ -115,7 +115,7 @@ class HierarchicalTreeVisitor : public TreeCompositeVisitor, public TreeLeafVisi template class ExpressionVisitor - : public ::utils::Visitor< + : public utils::Visitor< TResult, NamedExpression, OrOperator, XorOperator, AndOperator, NotOperator, AdditionOperator, SubtractionOperator, MultiplicationOperator, DivisionOperator, ModOperator, NotEqualOperator, EqualOperator, LessOperator, GreaterOperator, LessEqualOperator, GreaterEqualOperator, InListOperator, SubscriptOperator, @@ -124,9 +124,9 @@ class ExpressionVisitor None, ParameterLookup, Identifier, PrimitiveLiteral, RegexMatch> {}; template -class QueryVisitor : public ::utils::Visitor {}; +class QueryVisitor + : public utils::Visitor {}; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/frontend/ast/cypher_main_visitor.cpp b/src/query/frontend/ast/cypher_main_visitor.cpp index af7abef35..b45b7c3de 100644 --- a/src/query/frontend/ast/cypher_main_visitor.cpp +++ b/src/query/frontend/ast/cypher_main_visitor.cpp @@ -38,13 +38,13 @@ #include "utils/logging.hpp" #include "utils/string.hpp" -namespace query::frontend { +namespace memgraph::query::frontend { const std::string CypherMainVisitor::kAnonPrefix = "anon"; namespace { template -std::optional> VisitMemoryLimit( +std::optional> VisitMemoryLimit( MemgraphCypher::MemoryLimitContext *memory_limit_ctx, TVisitor *visitor) { MG_ASSERT(memory_limit_ctx); if (memory_limit_ctx->UNLIMITED()) { @@ -273,7 +273,7 @@ antlrcpp::Any CypherMainVisitor::visitRegisterReplica(MemgraphCypher::RegisterRe replication_query->action_ = ReplicationQuery::Action::REGISTER_REPLICA; replication_query->replica_name_ = ctx->replicaName()->symbolicName()->accept(this).as(); if (ctx->SYNC()) { - replication_query->sync_mode_ = query::ReplicationQuery::SyncMode::SYNC; + replication_query->sync_mode_ = memgraph::query::ReplicationQuery::SyncMode::SYNC; if (ctx->WITH() && ctx->TIMEOUT()) { if (ctx->timeout->numberLiteral()) { // we accept both double and integer literals @@ -286,7 +286,7 @@ antlrcpp::Any CypherMainVisitor::visitRegisterReplica(MemgraphCypher::RegisterRe if (ctx->WITH() && ctx->TIMEOUT()) { throw SyntaxException("Timeout can be set only for the SYNC replication mode!"); } - replication_query->sync_mode_ = query::ReplicationQuery::SyncMode::ASYNC; + replication_query->sync_mode_ = memgraph::query::ReplicationQuery::SyncMode::ASYNC; } if (!ctx->socketAddress()->literal()->StringLiteral()) { @@ -2289,4 +2289,4 @@ PropertyIx CypherMainVisitor::AddProperty(const std::string &name) { return stor EdgeTypeIx CypherMainVisitor::AddEdgeType(const std::string &name) { return storage_->GetEdgeTypeIx(name); } -} // namespace query::frontend +} // namespace memgraph::query::frontend diff --git a/src/query/frontend/ast/cypher_main_visitor.hpp b/src/query/frontend/ast/cypher_main_visitor.hpp index 5b36dc45b..809def3b6 100644 --- a/src/query/frontend/ast/cypher_main_visitor.hpp +++ b/src/query/frontend/ast/cypher_main_visitor.hpp @@ -22,7 +22,7 @@ #include "utils/exceptions.hpp" #include "utils/logging.hpp" -namespace query { +namespace memgraph::query { namespace frontend { using antlropencypher::MemgraphCypher; @@ -880,4 +880,4 @@ class CypherMainVisitor : public antlropencypher::MemgraphCypherBaseVisitor { QueryInfo query_info_; }; } // namespace frontend -} // namespace query +} // namespace memgraph::query diff --git a/src/query/frontend/ast/pretty_print.cpp b/src/query/frontend/ast/pretty_print.cpp index a1ad2e8cb..5f94d6def 100644 --- a/src/query/frontend/ast/pretty_print.cpp +++ b/src/query/frontend/ast/pretty_print.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "utils/algorithm.hpp" #include "utils/string.hpp" -namespace query { +namespace memgraph::query { namespace { @@ -308,4 +308,4 @@ void PrintExpression(NamedExpression *expr, std::ostream *out) { expr->Accept(printer); } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/frontend/ast/pretty_print.hpp b/src/query/frontend/ast/pretty_print.hpp index cbe905a68..276fe060e 100644 --- a/src/query/frontend/ast/pretty_print.hpp +++ b/src/query/frontend/ast/pretty_print.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,9 +15,9 @@ #include "query/frontend/ast/ast.hpp" -namespace query { +namespace memgraph::query { void PrintExpression(Expression *expr, std::ostream *out); void PrintExpression(NamedExpression *expr, std::ostream *out); -} // namespace query +} // namespace memgraph::query diff --git a/src/query/frontend/opencypher/parser.hpp b/src/query/frontend/opencypher/parser.hpp index 87ab7e048..05d48c146 100644 --- a/src/query/frontend/opencypher/parser.hpp +++ b/src/query/frontend/opencypher/parser.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "query/frontend/opencypher/generated/MemgraphCypher.h" #include "query/frontend/opencypher/generated/MemgraphCypherLexer.h" -namespace query { +namespace memgraph::query { namespace frontend { namespace opencypher { @@ -38,7 +38,7 @@ class Parser { parser_.addErrorListener(&error_listener_); tree_ = parser_.cypher(); if (parser_.getNumberOfSyntaxErrors()) { - throw query::SyntaxException(error_listener_.error_); + throw memgraph::query::SyntaxException(error_listener_.error_); } } @@ -69,4 +69,4 @@ class Parser { }; } // namespace opencypher } // namespace frontend -} // namespace query +} // namespace memgraph::query diff --git a/src/query/frontend/parsing.cpp b/src/query/frontend/parsing.cpp index 2603371e9..268b8995c 100644 --- a/src/query/frontend/parsing.cpp +++ b/src/query/frontend/parsing.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/logging.hpp" #include "utils/string.hpp" -namespace query::frontend { +namespace memgraph::query::frontend { int64_t ParseIntegerLiteral(const std::string &s) { try { @@ -181,4 +181,4 @@ std::string ParseParameter(const std::string &s) { return out; } -} // namespace query::frontend +} // namespace memgraph::query::frontend diff --git a/src/query/frontend/parsing.hpp b/src/query/frontend/parsing.hpp index 88b438a4a..5aa97f6d5 100644 --- a/src/query/frontend/parsing.hpp +++ b/src/query/frontend/parsing.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include #include -namespace query::frontend { +namespace memgraph::query::frontend { // These are the functions for parsing literals and parameter names from // opencypher query. @@ -24,4 +24,4 @@ std::string ParseStringLiteral(const std::string &s); double ParseDoubleLiteral(const std::string &s); std::string ParseParameter(const std::string &s); -} // namespace query::frontend +} // namespace memgraph::query::frontend diff --git a/src/query/frontend/semantic/required_privileges.cpp b/src/query/frontend/semantic/required_privileges.cpp index 42f74a4af..e8dbd21e5 100644 --- a/src/query/frontend/semantic/required_privileges.cpp +++ b/src/query/frontend/semantic/required_privileges.cpp @@ -14,7 +14,7 @@ #include "query/procedure/module.hpp" #include "utils/memory.hpp" -namespace query { +namespace memgraph::query { class PrivilegeExtractor : public QueryVisitor, public HierarchicalTreeVisitor { public: @@ -149,4 +149,4 @@ std::vector GetRequiredPrivileges(Query *query) { return extractor.privileges(); } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/frontend/semantic/required_privileges.hpp b/src/query/frontend/semantic/required_privileges.hpp index 8841b7b9c..f5fcf4170 100644 --- a/src/query/frontend/semantic/required_privileges.hpp +++ b/src/query/frontend/semantic/required_privileges.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,6 +13,6 @@ #include "query/frontend/ast/ast.hpp" -namespace query { +namespace memgraph::query { std::vector GetRequiredPrivileges(Query *query); } diff --git a/src/query/frontend/semantic/symbol.lcp b/src/query/frontend/semantic/symbol.lcp index c4b7ff531..b611db492 100644 --- a/src/query/frontend/semantic/symbol.lcp +++ b/src/query/frontend/semantic/symbol.lcp @@ -1,4 +1,4 @@ -;; Copyright 2021 Memgraph Ltd. +;; Copyright 2022 Memgraph Ltd. ;; ;; Use of this software is governed by the Business Source License ;; included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,6 +17,7 @@ #include "utils/typeinfo.hpp" cpp<# +(lcp:namespace memgraph) (lcp:namespace query) (lcp:define-class symbol () @@ -65,13 +66,14 @@ cpp<# (:serialize (:slk))) (lcp:pop-namespace) ;; query +(lcp:pop-namespace) ;; memgraph #>cpp namespace std { template <> -struct hash { - size_t operator()(const query::Symbol &symbol) const { +struct hash { + size_t operator()(const memgraph::query::Symbol &symbol) const { size_t prime = 265443599u; size_t hash = std::hash{}(symbol.position()); hash ^= prime * std::hash{}(symbol.name()); diff --git a/src/query/frontend/semantic/symbol_generator.cpp b/src/query/frontend/semantic/symbol_generator.cpp index 31887ea36..7c9fa97ca 100644 --- a/src/query/frontend/semantic/symbol_generator.cpp +++ b/src/query/frontend/semantic/symbol_generator.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,7 +24,7 @@ #include "utils/algorithm.hpp" #include "utils/logging.hpp" -namespace query { +namespace memgraph::query { namespace { std::unordered_map GeneratePredefinedIdentifierMap( @@ -570,4 +570,4 @@ bool SymbolGenerator::ConsumePredefinedIdentifier(const std::string &name) { return true; } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/frontend/semantic/symbol_generator.hpp b/src/query/frontend/semantic/symbol_generator.hpp index fad272685..fd57175bc 100644 --- a/src/query/frontend/semantic/symbol_generator.hpp +++ b/src/query/frontend/semantic/symbol_generator.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "query/frontend/ast/ast.hpp" #include "query/frontend/semantic/symbol_table.hpp" -namespace query { +namespace memgraph::query { /// Visits the AST and generates symbols for variables. /// @@ -163,4 +163,4 @@ inline SymbolTable MakeSymbolTable(CypherQuery *query, const std::vector table_; }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/frontend/stripped.cpp b/src/query/frontend/stripped.cpp index 5ebbd5ef8..56d29032c 100644 --- a/src/query/frontend/stripped.cpp +++ b/src/query/frontend/stripped.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -28,7 +28,7 @@ #include "utils/logging.hpp" #include "utils/string.hpp" -namespace query::frontend { +namespace memgraph::query::frontend { using namespace lexer_constants; @@ -532,4 +532,4 @@ int StrippedQuery::MatchWhitespaceAndComments(int start) const { return i - start; } -} // namespace query::frontend +} // namespace memgraph::query::frontend diff --git a/src/query/frontend/stripped.hpp b/src/query/frontend/stripped.hpp index 8d408cd0c..006fb1dd6 100644 --- a/src/query/frontend/stripped.hpp +++ b/src/query/frontend/stripped.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "query/parameters.hpp" #include "utils/fnv.hpp" -namespace query::frontend { +namespace memgraph::query::frontend { // Strings used to replace original tokens. Different types are replaced with // different token. @@ -100,4 +100,4 @@ class StrippedQuery { uint64_t hash_; }; -} // namespace query::frontend +} // namespace memgraph::query::frontend diff --git a/src/query/frontend/stripped_lexer_constants.hpp b/src/query/frontend/stripped_lexer_constants.hpp index f69107c03..0dd697c06 100644 --- a/src/query/frontend/stripped_lexer_constants.hpp +++ b/src/query/frontend/stripped_lexer_constants.hpp @@ -17,7 +17,7 @@ #include #include -namespace query { +namespace memgraph::query { namespace lexer_constants { namespace trie { @@ -2920,4 +2920,4 @@ const trie::Trie kSpecialTokens = {";", "\xEF\xB9\xA3", // u8"\ufe63" "\xEF\xBC\x8D"}; // u8"\uff0d" } // namespace lexer_constants -} // namespace query +} // namespace memgraph::query diff --git a/src/query/interpret/awesome_memgraph_functions.cpp b/src/query/interpret/awesome_memgraph_functions.cpp index 353015168..5e0202366 100644 --- a/src/query/interpret/awesome_memgraph_functions.cpp +++ b/src/query/interpret/awesome_memgraph_functions.cpp @@ -26,7 +26,7 @@ #include "utils/string.hpp" #include "utils/temporal.hpp" -namespace query { +namespace memgraph::query { namespace { //////////////////////////////////////////////////////////////////////////////// @@ -394,7 +394,7 @@ TypedValue Properties(const TypedValue *args, int64_t nargs, const FunctionConte case storage::Error::DELETED_OBJECT: throw QueryRuntimeException("Trying to get properties from a deleted object."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get properties from an object that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get properties from an object that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: @@ -448,7 +448,7 @@ size_t UnwrapDegreeResult(storage::Result maybe_degree) { case storage::Error::DELETED_OBJECT: throw QueryRuntimeException("Trying to get degree of a deleted node."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get degree of a node that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get degree of a node that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: @@ -599,7 +599,7 @@ TypedValue Keys(const TypedValue *args, int64_t nargs, const FunctionContext &ct case storage::Error::DELETED_OBJECT: throw QueryRuntimeException("Trying to get keys from a deleted object."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get keys from an object that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get keys from an object that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: @@ -632,7 +632,7 @@ TypedValue Labels(const TypedValue *args, int64_t nargs, const FunctionContext & case storage::Error::DELETED_OBJECT: throw QueryRuntimeException("Trying to get labels from a deleted node."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get labels from a node that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get labels from a node that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: @@ -1262,4 +1262,4 @@ std::function NameToFunction(const std::string &function_name); -} // namespace query +} // namespace memgraph::query diff --git a/src/query/interpret/eval.cpp b/src/query/interpret/eval.cpp index 2cad695bb..c60972234 100644 --- a/src/query/interpret/eval.cpp +++ b/src/query/interpret/eval.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "query/interpret/eval.hpp" -namespace query { +namespace memgraph::query { int64_t EvaluateInt(ExpressionEvaluator *evaluator, Expression *expr, const std::string &what) { TypedValue value = expr->Accept(*evaluator); @@ -32,4 +32,4 @@ std::optional EvaluateMemoryLimit(ExpressionEvaluator *eval, Expression return limit * memory_scale; } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/interpret/eval.hpp b/src/query/interpret/eval.hpp index 0cb792e3a..0eb08b113 100644 --- a/src/query/interpret/eval.hpp +++ b/src/query/interpret/eval.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -29,7 +29,7 @@ #include "query/typed_value.hpp" #include "utils/exceptions.hpp" -namespace query { +namespace memgraph::query { class ExpressionEvaluator : public ExpressionVisitor { public: @@ -394,7 +394,7 @@ class ExpressionEvaluator : public ExpressionVisitor { case storage::Error::DELETED_OBJECT: throw QueryRuntimeException("Trying to access labels on a deleted node."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to access labels from a node that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to access labels from a node that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: @@ -705,7 +705,7 @@ class ExpressionEvaluator : public ExpressionVisitor { case storage::Error::DELETED_OBJECT: throw QueryRuntimeException("Trying to get a property from a deleted object."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get a property from an object that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get a property from an object that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: @@ -732,7 +732,7 @@ class ExpressionEvaluator : public ExpressionVisitor { case storage::Error::DELETED_OBJECT: throw QueryRuntimeException("Trying to get a property from a deleted object."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get a property from an object that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get a property from an object that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: @@ -761,4 +761,4 @@ int64_t EvaluateInt(ExpressionEvaluator *evaluator, Expression *expr, const std: std::optional EvaluateMemoryLimit(ExpressionEvaluator *eval, Expression *memory_limit, size_t memory_scale); -} // namespace query +} // namespace memgraph::query diff --git a/src/query/interpret/frame.hpp b/src/query/interpret/frame.hpp index 35b3f0d4c..7a8c9976c 100644 --- a/src/query/interpret/frame.hpp +++ b/src/query/interpret/frame.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "utils/memory.hpp" #include "utils/pmr/vector.hpp" -namespace query { +namespace memgraph::query { class Frame { public: @@ -42,4 +42,4 @@ class Frame { utils::pmr::vector elems_; }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index f538d2769..4bde59f7c 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -72,7 +72,7 @@ extern const Event StreamsCreated; extern const Event TriggersCreated; } // namespace EventCounter -namespace query { +namespace memgraph::query { namespace { void UpdateTypeCount(const plan::ReadWriteTypeChecker::RWType type) { @@ -103,7 +103,7 @@ TypedValue EvaluateOptionalExpression(Expression *expression, ExpressionEvaluato } template -std::optional GetOptionalValue(query::Expression *expression, ExpressionEvaluator &evaluator) { +std::optional GetOptionalValue(memgraph::query::Expression *expression, ExpressionEvaluator &evaluator) { if (expression != nullptr) { auto int_value = expression->Accept(evaluator); MG_ASSERT(int_value.IsNull() || int_value.IsInt()); @@ -114,7 +114,8 @@ std::optional GetOptionalValue(query::Expression *expression, Expressio return {}; }; -std::optional GetOptionalStringValue(query::Expression *expression, ExpressionEvaluator &evaluator) { +std::optional GetOptionalStringValue(memgraph::query::Expression *expression, + ExpressionEvaluator &evaluator) { if (expression != nullptr) { auto value = expression->Accept(evaluator); MG_ASSERT(value.IsNull() || value.IsString()); @@ -125,7 +126,7 @@ std::optional GetOptionalStringValue(query::Expression *expression, return {}; }; -class ReplQueryHandler final : public query::ReplicationQueryHandler { +class ReplQueryHandler final : public memgraph::query::ReplicationQueryHandler { public: explicit ReplQueryHandler(storage::Storage *db) : db_(db) {} @@ -141,7 +142,7 @@ class ReplQueryHandler final : public query::ReplicationQueryHandler { throw QueryRuntimeException("Port number invalid!"); } if (!db_->SetReplicaRole( - io::network::Endpoint(query::kDefaultReplicationServerIp, static_cast(*port)))) { + io::network::Endpoint(memgraph::query::kDefaultReplicationServerIp, static_cast(*port)))) { throw QueryRuntimeException("Couldn't set role to replica!"); } } @@ -179,7 +180,7 @@ class ReplQueryHandler final : public query::ReplicationQueryHandler { } auto maybe_ip_and_port = - io::network::Endpoint::ParseSocketOrIpAddress(socket_address, query::kDefaultReplicationPort); + io::network::Endpoint::ParseSocketOrIpAddress(socket_address, memgraph::query::kDefaultReplicationPort); if (maybe_ip_and_port) { auto [ip, port] = *maybe_ip_and_port; auto ret = @@ -587,14 +588,15 @@ Callback::CallbackFunction GetKafkaCreateCallback(StreamQuery *stream_query, Exp std::string bootstrap = bootstrap_servers ? std::move(*bootstrap_servers) : std::string{interpreter_context->config.default_kafka_bootstrap_servers}; - interpreter_context->streams.Create(stream_name, - {.common_info = std::move(common_stream_info), - .topics = std::move(topic_names), - .consumer_group = std::move(consumer_group), - .bootstrap_servers = std::move(bootstrap), - .configs = std::move(configs), - .credentials = std::move(credentials)}, - std::move(owner)); + interpreter_context->streams.Create( + stream_name, + {.common_info = std::move(common_stream_info), + .topics = std::move(topic_names), + .consumer_group = std::move(consumer_group), + .bootstrap_servers = std::move(bootstrap), + .configs = std::move(configs), + .credentials = std::move(credentials)}, + std::move(owner)); return std::vector>{}; }; @@ -614,7 +616,7 @@ Callback::CallbackFunction GetPulsarCreateCallback(StreamQuery *stream_query, Ex owner = StringPointerToOptional(username)]() mutable { std::string url = service_url ? std::move(*service_url) : std::string{interpreter_context->config.default_pulsar_service_url}; - interpreter_context->streams.Create( + interpreter_context->streams.Create( stream_name, {.common_info = std::move(common_stream_info), .topics = std::move(topic_names), .service_url = std::move(url)}, std::move(owner)); @@ -2351,4 +2353,4 @@ void Interpreter::SetSessionIsolationLevel(const storage::IsolationLevel isolati interpreter_isolation_level.emplace(isolation_level); } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/interpreter.hpp b/src/query/interpreter.hpp index 133ee3a6e..c89e4132f 100644 --- a/src/query/interpreter.hpp +++ b/src/query/interpreter.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -45,7 +45,7 @@ namespace EventCounter { extern const Event FailedQuery; } // namespace EventCounter -namespace query { +namespace memgraph::query { static constexpr size_t kExecutionMemoryBlockSize = 1U * 1024U * 1024U; @@ -180,7 +180,7 @@ struct InterpreterContext { std::atomic is_shutting_down{false}; AuthQueryHandler *auth{nullptr}; - query::AuthChecker *auth_checker{nullptr}; + memgraph::query::AuthChecker *auth_checker{nullptr}; utils::SkipList ast_cache; utils::SkipList plan_cache; @@ -190,7 +190,7 @@ struct InterpreterContext { const InterpreterConfig config; - query::stream::Streams streams; + memgraph::query::stream::Streams streams; }; /// Function that is used to tell all active interpreters that they should stop @@ -208,7 +208,7 @@ class Interpreter final { struct PrepareResult { std::vector headers; - std::vector privileges; + std::vector privileges; std::optional qid; }; @@ -218,7 +218,7 @@ class Interpreter final { * Preparing a query means to preprocess the query and save it for * future calls of `Pull`. * - * @throw query::QueryException + * @throw memgraph::query::QueryException */ PrepareResult Prepare(const std::string &query, const std::map ¶ms, const std::string *username); @@ -237,7 +237,7 @@ class Interpreter final { * further. * * @throw utils::BasicException - * @throw query::QueryException + * @throw memgraph::query::QueryException */ template std::map PullAll(TStream *result_stream) { @@ -259,7 +259,7 @@ class Interpreter final { * otherwise the last query should be used. * * @throw utils::BasicException - * @throw query::QueryException + * @throw memgraph::query::QueryException */ template std::map Pull(TStream *result_stream, std::optional n = {}, @@ -431,4 +431,4 @@ std::map Interpreter::Pull(TStream *result_stream, std: // don't return the execution summary as it's not finished return {{"has_more", TypedValue(true)}}; } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/metadata.cpp b/src/query/metadata.cpp index d42bc45fd..f4e8512fd 100644 --- a/src/query/metadata.cpp +++ b/src/query/metadata.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include #include -namespace query { +namespace memgraph::query { namespace { using namespace std::literals; @@ -114,4 +114,4 @@ std::string ExecutionStatsKeyToString(const ExecutionStats::Key key) { } } -} // namespace query \ No newline at end of file +} // namespace memgraph::query \ No newline at end of file diff --git a/src/query/metadata.hpp b/src/query/metadata.hpp index 3ca176a72..67f784fa8 100644 --- a/src/query/metadata.hpp +++ b/src/query/metadata.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "query/typed_value.hpp" -namespace query { +namespace memgraph::query { enum class SeverityLevel : uint8_t { INFO, WARNING }; @@ -87,4 +87,4 @@ struct ExecutionStats { std::string ExecutionStatsKeyToString(ExecutionStats::Key key); -} // namespace query +} // namespace memgraph::query diff --git a/src/query/parameters.hpp b/src/query/parameters.hpp index 88a6cb651..08da3f3e7 100644 --- a/src/query/parameters.hpp +++ b/src/query/parameters.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ * Encapsulates user provided parameters (and stripped literals) * and provides ways of obtaining them by position. */ -namespace query { +namespace memgraph::query { struct Parameters { public: @@ -68,4 +68,4 @@ struct Parameters { std::vector> storage_; }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/path.hpp b/src/query/path.hpp index 6929e64c7..832532fbc 100644 --- a/src/query/path.hpp +++ b/src/query/path.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "utils/memory.hpp" #include "utils/pmr/vector.hpp" -namespace query { +namespace memgraph::query { /** * A data structure that holds a graph path. A path consists of at least one @@ -143,4 +143,4 @@ class Path { utils::pmr::vector edges_; }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/plan/cost_estimator.hpp b/src/query/plan/cost_estimator.hpp index 002a3acc8..4525ef928 100644 --- a/src/query/plan/cost_estimator.hpp +++ b/src/query/plan/cost_estimator.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "query/plan/operator.hpp" #include "query/typed_value.hpp" -namespace query::plan { +namespace memgraph::query::plan { /** * Query plan execution time cost estimator, for comparing and choosing optimal @@ -184,7 +184,7 @@ class CostEstimator : public HierarchicalLogicalOperatorVisitor { // if the Unwind expression is a list literal, we can deduce cardinality // exactly, otherwise we approximate double unwind_value; - if (auto *literal = utils::Downcast(unwind.input_expression_)) + if (auto *literal = utils::Downcast(unwind.input_expression_)) unwind_value = literal->elements_.size(); else unwind_value = MiscParam::kUnwindNoLiteral; @@ -245,4 +245,4 @@ double EstimatePlanCost(TDbAccessor *db, const Parameters ¶meters, LogicalOp return estimator.cost(); } -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index ada565853..4ce501d0f 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -107,7 +107,7 @@ extern const Event CartesianOperator; extern const Event CallProcedureOperator; } // namespace EventCounter -namespace query::plan { +namespace memgraph::query::plan { namespace { @@ -620,7 +620,7 @@ auto UnwrapEdgesResult(storage::Result &&result) { case storage::Error::DELETED_OBJECT: throw QueryRuntimeException("Trying to get relationships of a deleted node."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get relationships from a node that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get relationships from a node that doesn't exist."); case storage::Error::VERTEX_HAS_EDGES: case storage::Error::SERIALIZATION_ERROR: case storage::Error::PROPERTIES_DISABLED: @@ -1053,7 +1053,7 @@ class ExpandVariableCursor : public Cursor { } }; -class STShortestPathCursor : public query::plan::Cursor { +class STShortestPathCursor : public memgraph::query::plan::Cursor { public: STShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem) : self_(self), input_cursor_(self_.input()->MakeCursor(mem)) { @@ -1271,7 +1271,7 @@ class STShortestPathCursor : public query::plan::Cursor { } }; -class SingleSourceShortestPathCursor : public query::plan::Cursor { +class SingleSourceShortestPathCursor : public memgraph::query::plan::Cursor { public: SingleSourceShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem) : self_(self), @@ -1427,7 +1427,7 @@ class SingleSourceShortestPathCursor : public query::plan::Cursor { utils::pmr::vector> to_visit_next_; }; -class ExpandWeightedShortestPathCursor : public query::plan::Cursor { +class ExpandWeightedShortestPathCursor : public memgraph::query::plan::Cursor { public: ExpandWeightedShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem) : self_(self), @@ -1729,7 +1729,7 @@ class ConstructNamedPathCursor : public Cursor { } DMG_ASSERT(start_vertex.IsVertex(), "First named path element must be a vertex"); - query::Path path(start_vertex.ValueVertex(), pull_memory); + memgraph::query::Path path(start_vertex.ValueVertex(), pull_memory); // If the last path element symbol was for an edge list, then // the next symbol is a vertex and it should not append to the path @@ -1966,7 +1966,7 @@ bool Delete::DeleteCursor::Pull(Frame &frame, ExecutionContext &context) { } context.trigger_context_collector->RegisterDeletedObject((*res)->first); - if (!context.trigger_context_collector->ShouldRegisterDeletedObject()) { + if (!context.trigger_context_collector->ShouldRegisterDeletedObject()) { return; } for (const auto &edge : (*res)->second) { @@ -2149,7 +2149,7 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr case storage::Error::DELETED_OBJECT: throw QueryRuntimeException("Trying to get properties from a deleted object."); case storage::Error::NONEXISTENT_OBJECT: - throw query::QueryRuntimeException("Trying to get properties from an object that doesn't exist."); + throw memgraph::query::QueryRuntimeException("Trying to get properties from an object that doesn't exist."); case storage::Error::SERIALIZATION_ERROR: case storage::Error::VERTEX_HAS_EDGES: case storage::Error::PROPERTIES_DISABLED: @@ -3721,7 +3721,7 @@ void CallCustomProcedure(const std::string_view &fully_qualified_procedure_name, for (size_t i = 0; i < args.size(); ++i) { auto arg = args[i]->Accept(*evaluator); std::string_view name; - const query::procedure::CypherType *type; + const memgraph::query::procedure::CypherType *type; if (proc.args.size() > i) { name = proc.args[i].first; type = proc.args[i].second; @@ -4024,4 +4024,4 @@ UniqueCursorPtr LoadCsv::MakeCursor(utils::MemoryResource *mem) const { return MakeUniqueCursorPtr(mem, this, mem); }; -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/operator.lcp b/src/query/plan/operator.lcp index b408f9931..d8935e0de 100644 --- a/src/query/plan/operator.lcp +++ b/src/query/plan/operator.lcp @@ -1,4 +1,4 @@ -;; Copyright 2021 Memgraph Ltd. +;; Copyright 2022 Memgraph Ltd. ;; ;; Use of this software is governed by the Business Source License ;; included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -34,6 +34,7 @@ #include "utils/logging.hpp" cpp<# +(lcp:namespace memgraph) (lcp:namespace query) #>cpp @@ -75,12 +76,12 @@ class Cursor { }; /// unique_ptr to Cursor managed with a custom deleter. -/// This allows us to use utils::MemoryResource for allocation. +/// This allows us to use memgraph::utils::MemoryResource for allocation. using UniqueCursorPtr = std::unique_ptr>; template std::unique_ptr> MakeUniqueCursorPtr( - utils::Allocator allocator, TArgs &&... args) { + memgraph::utils::Allocator allocator, TArgs &&... args) { auto *ptr = allocator.allocate(1); try { auto *cursor = new (ptr) TCursor(std::forward(args)...); @@ -131,7 +132,7 @@ class Cartesian; class CallProcedure; class LoadCsv; -using LogicalOperatorCompositeVisitor = ::utils::CompositeVisitor< +using LogicalOperatorCompositeVisitor = memgraph::utils::CompositeVisitor< Once, CreateNode, CreateExpand, ScanAll, ScanAllByLabel, ScanAllByLabelPropertyRange, ScanAllByLabelPropertyValue, ScanAllByLabelProperty, ScanAllById, @@ -140,7 +141,7 @@ using LogicalOperatorCompositeVisitor = ::utils::CompositeVisitor< EdgeUniquenessFilter, Accumulate, Aggregate, Skip, Limit, OrderBy, Merge, Optional, Unwind, Distinct, Union, Cartesian, CallProcedure, LoadCsv>; -using LogicalOperatorLeafVisitor = ::utils::LeafVisitor; +using LogicalOperatorLeafVisitor = memgraph::utils::LeafVisitor; /** * @brief Base class for hierarhical visitors of @c LogicalOperator class @@ -157,7 +158,7 @@ class HierarchicalLogicalOperatorVisitor }; cpp<# -(lcp:define-class logical-operator ("::utils::Visitable") +(lcp:define-class logical-operator ("memgraph::utils::Visitable") () (:abstractp t) (:documentation @@ -172,10 +173,10 @@ can serve as inputs to others and thus a sequence of operations is formed.") /** Construct a @c Cursor which is used to run this operator. * - * @param utils::MemoryResource Memory resource used for allocations during + * @param memgraph::utils::MemoryResource Memory resource used for allocations during * the lifetime of the returned Cursor. */ - virtual UniqueCursorPtr MakeCursor(utils::MemoryResource *) const = 0; + virtual UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const = 0; /** Return @c Symbol vector where the query results will be stored. * @@ -311,7 +312,7 @@ and false on every following Pull.") #>cpp Once(std::vector symbols = {}) : symbols_{std::move(symbols)} {} DEFVISITABLE(HierarchicalLogicalOperatorVisitor); - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override { return symbols_; } @@ -444,7 +445,7 @@ a preceding `MATCH`), or multiple nodes (`MATCH ... CREATE` or CreateNode(const std::shared_ptr &input, const NodeCreationInfo &node_info); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -457,7 +458,7 @@ a preceding `MATCH`), or multiple nodes (`MATCH ... CREATE` or #>cpp class CreateNodeCursor : public Cursor { public: - CreateNodeCursor(const CreateNode &, utils::MemoryResource *); + CreateNodeCursor(const CreateNode &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -559,7 +560,7 @@ chained in cases when longer paths need creating. const std::shared_ptr &input, Symbol input_symbol, bool existing_node); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -572,7 +573,7 @@ chained in cases when longer paths need creating. #>cpp class CreateExpandCursor : public Cursor { public: - CreateExpandCursor(const CreateExpand &, utils::MemoryResource *); + CreateExpandCursor(const CreateExpand &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -623,7 +624,7 @@ with a constructor argument. ScanAll(const std::shared_ptr &input, Symbol output_symbol, storage::View view = storage::View::OLD); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -651,7 +652,7 @@ given label. Symbol output_symbol, storage::LabelId label, storage::View view = storage::View::OLD); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; cpp<#) (:serialize (:slk)) (:clone)) @@ -665,10 +666,10 @@ given label. uint8_t bound_type; const auto &bound = *self.${member}; switch (bound.type()) { - case utils::BoundType::INCLUSIVE: + case memgraph::utils::BoundType::INCLUSIVE: bound_type = 0; break; - case utils::BoundType::EXCLUSIVE: + case memgraph::utils::BoundType::EXCLUSIVE: bound_type = 1; break; } @@ -686,26 +687,26 @@ given label. } uint8_t bound_type_value; slk::Load(&bound_type_value, reader); - utils::BoundType bound_type; + memgraph::utils::BoundType bound_type; switch (bound_type_value) { case static_cast(0): - bound_type = utils::BoundType::INCLUSIVE; + bound_type = memgraph::utils::BoundType::INCLUSIVE; break; case static_cast(1): - bound_type = utils::BoundType::EXCLUSIVE; + bound_type = memgraph::utils::BoundType::EXCLUSIVE; break; default: throw slk::SlkDecodeException("Loading unknown BoundType"); } auto *value = query::LoadAstPointer( &helper->ast_storage, reader); - self->${member}.emplace(utils::Bound(value, bound_type)); + self->${member}.emplace(memgraph::utils::Bound(value, bound_type)); cpp<#) (defun clone-optional-bound (source dest) #>cpp if (${source}) { - ${dest}.emplace(utils::Bound( + ${dest}.emplace(memgraph::utils::Bound( ${source}->value()->Clone(storage), ${source}->type())); } else { @@ -735,7 +736,7 @@ property value which is inside a range (inclusive or exlusive). (:public #>cpp /** Bound with expression which when evaluated produces the bound value. */ - using Bound = utils::Bound; + using Bound = memgraph::utils::Bound; ScanAllByLabelPropertyRange() {} /** * Constructs the operator for given label and property value in range @@ -760,7 +761,7 @@ property value which is inside a range (inclusive or exlusive). storage::View view = storage::View::OLD); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; cpp<#) (:serialize (:slk)) (:clone)) @@ -800,7 +801,7 @@ property value. storage::View view = storage::View::OLD); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; cpp<#) (:serialize (:slk)) (:clone)) @@ -829,7 +830,7 @@ given label and property. const std::string &property_name, storage::View view = storage::View::OLD); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; cpp<#) (:serialize (:slk)) (:clone)) @@ -850,7 +851,7 @@ given label and property. storage::View view = storage::View::OLD); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; cpp<#) (:serialize (:slk)) (:clone)) @@ -915,7 +916,7 @@ pulled.") Expand() {} bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -926,7 +927,7 @@ pulled.") class ExpandCursor : public Cursor { public: - ExpandCursor(const Expand &, utils::MemoryResource *); + ExpandCursor(const Expand &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1064,7 +1065,7 @@ pulled.") std::optional total_weight); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1102,7 +1103,7 @@ pulled.") path_symbol_(path_symbol), path_elements_(path_elements) {} bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1134,7 +1135,7 @@ a boolean value.") Filter(const std::shared_ptr &input_, Expression *expression_); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1147,7 +1148,7 @@ a boolean value.") #>cpp class FilterCursor : public Cursor { public: - FilterCursor(const Filter &, utils::MemoryResource *); + FilterCursor(const Filter &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1184,7 +1185,7 @@ RETURN clause) the Produce's pull succeeds exactly once.") Produce(const std::shared_ptr &input, const std::vector &named_expressions); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -1198,7 +1199,7 @@ RETURN clause) the Produce's pull succeeds exactly once.") #>cpp class ProduceCursor : public Cursor { public: - ProduceCursor(const Produce &, utils::MemoryResource *); + ProduceCursor(const Produce &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1232,7 +1233,7 @@ Has a flag for using DETACH DELETE when deleting vertices.") Delete(const std::shared_ptr &input_, const std::vector &expressions, bool detach_); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1245,7 +1246,7 @@ Has a flag for using DETACH DELETE when deleting vertices.") #>cpp class DeleteCursor : public Cursor { public: - DeleteCursor(const Delete &, utils::MemoryResource *); + DeleteCursor(const Delete &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1282,7 +1283,7 @@ can be stored (a TypedValue that can be converted to PropertyValue).") storage::PropertyId property, PropertyLookup *lhs, Expression *rhs); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1295,7 +1296,7 @@ can be stored (a TypedValue that can be converted to PropertyValue).") #>cpp class SetPropertyCursor : public Cursor { public: - SetPropertyCursor(const SetProperty &, utils::MemoryResource *); + SetPropertyCursor(const SetProperty &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1341,7 +1342,7 @@ that the old properties are discarded and replaced with new ones.") SetProperties(const std::shared_ptr &input, Symbol input_symbol, Expression *rhs, Op op); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1354,7 +1355,7 @@ that the old properties are discarded and replaced with new ones.") #>cpp class SetPropertiesCursor : public Cursor { public: - SetPropertiesCursor(const SetProperties &, utils::MemoryResource *); + SetPropertiesCursor(const SetProperties &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1384,7 +1385,7 @@ It does NOT remove labels that are already set on that Vertex.") SetLabels(const std::shared_ptr &input, Symbol input_symbol, const std::vector &labels); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1397,7 +1398,7 @@ It does NOT remove labels that are already set on that Vertex.") #>cpp class SetLabelsCursor : public Cursor { public: - SetLabelsCursor(const SetLabels &, utils::MemoryResource *); + SetLabelsCursor(const SetLabels &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1427,7 +1428,7 @@ It does NOT remove labels that are already set on that Vertex.") RemoveProperty(const std::shared_ptr &input, storage::PropertyId property, PropertyLookup *lhs); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1440,7 +1441,7 @@ It does NOT remove labels that are already set on that Vertex.") #>cpp class RemovePropertyCursor : public Cursor { public: - RemovePropertyCursor(const RemoveProperty &, utils::MemoryResource *); + RemovePropertyCursor(const RemoveProperty &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1470,7 +1471,7 @@ If a label does not exist on a Vertex, nothing happens.") RemoveLabels(const std::shared_ptr &input, Symbol input_symbol, const std::vector &labels); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1483,7 +1484,7 @@ If a label does not exist on a Vertex, nothing happens.") #>cpp class RemoveLabelsCursor : public Cursor { public: - RemoveLabelsCursor(const RemoveLabels &, utils::MemoryResource *); + RemoveLabelsCursor(const RemoveLabels &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1524,7 +1525,7 @@ edge lists).") Symbol expand_symbol, const std::vector &previous_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1538,7 +1539,7 @@ edge lists).") class EdgeUniquenessFilterCursor : public Cursor { public: EdgeUniquenessFilterCursor(const EdgeUniquenessFilter &, - utils::MemoryResource *); + memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1591,7 +1592,7 @@ has been cached will be reconstructed before Pull returns. Accumulate(const std::shared_ptr &input, const std::vector &symbols, bool advance_command = false); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1669,7 +1670,7 @@ elements are in an undefined state after aggregation.") const std::vector &group_by, const std::vector &remember); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1706,7 +1707,7 @@ operator's implementation does not expect this.") Skip(const std::shared_ptr &input, Expression *expression); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -1720,7 +1721,7 @@ operator's implementation does not expect this.") #>cpp class SkipCursor : public Cursor { public: - SkipCursor(const Skip &, utils::MemoryResource *); + SkipCursor(const Skip &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1765,7 +1766,7 @@ input should be performed).") Limit(const std::shared_ptr &input, Expression *expression); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -1779,7 +1780,7 @@ input should be performed).") #>cpp class LimitCursor : public Cursor { public: - LimitCursor(const Limit &, utils::MemoryResource *); + LimitCursor(const Limit &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1824,7 +1825,7 @@ are valid for usage after the OrderBy operator.") const std::vector &order_by, const std::vector &output_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -1867,7 +1868,7 @@ documentation.") const std::shared_ptr &merge_match, const std::shared_ptr &merge_create); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; // TODO: Consider whether we want to treat Merge as having single input. It @@ -1883,7 +1884,7 @@ documentation.") #>cpp class MergeCursor : public Cursor { public: - MergeCursor(const Merge &, utils::MemoryResource *); + MergeCursor(const Merge &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1927,7 +1928,7 @@ and returns true, once.") const std::shared_ptr &optional, const std::vector &optional_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1940,7 +1941,7 @@ and returns true, once.") #>cpp class OptionalCursor : public Cursor { public: - OptionalCursor(const Optional &, utils::MemoryResource *); + OptionalCursor(const Optional &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1980,7 +1981,7 @@ Input is optional (unwind can be the first clause in a query).") Unwind(const std::shared_ptr &input, Expression *input_expression_, Symbol output_symbol); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { @@ -2013,7 +2014,7 @@ This implementation maintains input ordering.") Distinct(const std::shared_ptr &input, const std::vector &value_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -2052,7 +2053,7 @@ of symbols used by each of the inputs.") const std::vector &left_symbols, const std::vector &right_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -2064,7 +2065,7 @@ of symbols used by each of the inputs.") #>cpp class UnionCursor : public Cursor { public: - UnionCursor(const Union &, utils::MemoryResource *); + UnionCursor(const Union &, memgraph::utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -2104,7 +2105,7 @@ of symbols used by each of the inputs.") right_symbols_(right_symbols) {} bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override; @@ -2133,7 +2134,7 @@ of symbols used by each of the inputs.") LOG_FATAL("OutputTable operator should not be visited!"); } - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override { return output_symbols_; } @@ -2167,7 +2168,7 @@ at once. Instead, each call of the callback should return a single row of the ta LOG_FATAL("OutputTableStream operator should not be visited!"); } - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override { return output_symbols_; } @@ -2207,7 +2208,7 @@ at once. Instead, each call of the callback should return a single row of the ta Expression *memory_limit, size_t memory_scale, bool is_write); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -2222,7 +2223,7 @@ at once. Instead, each call of the callback should return a single row of the ta cpp<#) (:private #>cpp - inline static utils::Synchronized, utils::SpinLock> procedure_counters_; + inline static memgraph::utils::Synchronized, memgraph::utils::SpinLock> procedure_counters_; cpp<#) (:serialize (:slk)) (:clone)) @@ -2247,7 +2248,7 @@ at once. Instead, each call of the callback should return a single row of the ta LoadCsv(std::shared_ptr input, Expression *file, bool with_header, bool ignore_bad, Expression* delimiter, Expression* quote, Symbol row_var); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override; + UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -2262,3 +2263,4 @@ at once. Instead, each call of the callback should return a single row of the ta (lcp:pop-namespace) ;; plan (lcp:pop-namespace) ;; query +(lcp:pop-namespace) ;; memgraph diff --git a/src/query/plan/planner.hpp b/src/query/plan/planner.hpp index c650a04d0..5b4b82bc9 100644 --- a/src/query/plan/planner.hpp +++ b/src/query/plan/planner.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,7 +26,7 @@ #include "query/plan/variable_start_planner.hpp" #include "query/plan/vertex_count_cache.hpp" -namespace query { +namespace memgraph::query { class AstStorage; class SymbolTable; @@ -48,7 +48,7 @@ class PostProcessor final { template double EstimatePlanCost(const std::unique_ptr &plan, TVertexCounts *vertex_counts) { - return ::query::plan::EstimatePlanCost(vertex_counts, parameters_, *plan); + return ::memgraph::query::plan::EstimatePlanCost(vertex_counts, parameters_, *plan); } template @@ -155,4 +155,4 @@ auto MakeLogicalPlan(TPlanningContext *context, const Parameters ¶meters, bo } // namespace plan -} // namespace query +} // namespace memgraph::query diff --git a/src/query/plan/preprocess.cpp b/src/query/plan/preprocess.cpp index 72fb1c1ce..8c6f9416e 100644 --- a/src/query/plan/preprocess.cpp +++ b/src/query/plan/preprocess.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "query/frontend/ast/ast_visitor.hpp" #include "query/plan/preprocess.hpp" -namespace query::plan { +namespace memgraph::query::plan { namespace { @@ -543,12 +543,12 @@ std::vector CollectSingleQueryParts(SymbolTable &symbol_table, } } else { query_part->remaining_clauses.push_back(clause); - if (auto *merge = utils::Downcast(clause)) { + if (auto *merge = utils::Downcast(clause)) { query_part->merge_matching.emplace_back(Matching{}); AddMatching({merge->pattern_}, nullptr, symbol_table, storage, query_part->merge_matching.back()); - } else if (utils::IsSubtype(*clause, With::kType) || utils::IsSubtype(*clause, query::Unwind::kType) || - utils::IsSubtype(*clause, query::CallProcedure::kType) || - utils::IsSubtype(*clause, query::LoadCsv::kType)) { + } else if (utils::IsSubtype(*clause, With::kType) || utils::IsSubtype(*clause, memgraph::query::Unwind::kType) || + utils::IsSubtype(*clause, memgraph::query::CallProcedure::kType) || + utils::IsSubtype(*clause, memgraph::query::LoadCsv::kType)) { // This query part is done, continue with a new one. query_parts.emplace_back(SingleQueryPart{}); query_part = &query_parts.back(); @@ -580,4 +580,4 @@ QueryParts CollectQueryParts(SymbolTable &symbol_table, AstStorage &storage, Cyp return QueryParts{query_parts, distinct}; } -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/preprocess.hpp b/src/query/plan/preprocess.hpp index 17218c65d..d567ff070 100644 --- a/src/query/plan/preprocess.hpp +++ b/src/query/plan/preprocess.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ #include "query/frontend/semantic/symbol_table.hpp" #include "query/plan/operator.hpp" -namespace query::plan { +namespace memgraph::query::plan { /// Collects symbols from identifiers found in visited AST nodes. class UsedSymbolsCollector : public HierarchicalTreeVisitor { @@ -349,4 +349,4 @@ struct QueryParts { /// AST nodes. QueryParts CollectQueryParts(SymbolTable &, AstStorage &, CypherQuery *); -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/pretty_print.cpp b/src/query/plan/pretty_print.cpp index ae3196527..6c305bbf2 100644 --- a/src/query/plan/pretty_print.cpp +++ b/src/query/plan/pretty_print.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "query/frontend/ast/pretty_print.hpp" #include "utils/string.hpp" -namespace query::plan { +namespace memgraph::query::plan { PlanPrinter::PlanPrinter(const DbAccessor *dba, std::ostream *out) : dba_(dba), out_(out) {} @@ -31,9 +31,9 @@ PRE_VISIT(CreateNode); bool PlanPrinter::PreVisit(CreateExpand &op) { WithPrintLn([&](auto &out) { out << "* CreateExpand (" << op.input_symbol_.name() << ")" - << (op.edge_info_.direction == query::EdgeAtom::Direction::IN ? "<-" : "-") << "[" + << (op.edge_info_.direction == memgraph::query::EdgeAtom::Direction::IN ? "<-" : "-") << "[" << op.edge_info_.symbol.name() << ":" << dba_->EdgeTypeToName(op.edge_info_.edge_type) << "]" - << (op.edge_info_.direction == query::EdgeAtom::Direction::OUT ? "->" : "-") << "(" + << (op.edge_info_.direction == memgraph::query::EdgeAtom::Direction::OUT ? "->" : "-") << "(" << op.node_info_.symbol.name() << ")"; }); return true; @@ -41,7 +41,7 @@ bool PlanPrinter::PreVisit(CreateExpand &op) { PRE_VISIT(Delete); -bool PlanPrinter::PreVisit(query::plan::ScanAll &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAll &op) { WithPrintLn([&](auto &out) { out << "* ScanAll" << " (" << op.output_symbol_.name() << ")"; @@ -49,7 +49,7 @@ bool PlanPrinter::PreVisit(query::plan::ScanAll &op) { return true; } -bool PlanPrinter::PreVisit(query::plan::ScanAllByLabel &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabel &op) { WithPrintLn([&](auto &out) { out << "* ScanAllByLabel" << " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << ")"; @@ -57,7 +57,7 @@ bool PlanPrinter::PreVisit(query::plan::ScanAllByLabel &op) { return true; } -bool PlanPrinter::PreVisit(query::plan::ScanAllByLabelPropertyValue &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabelPropertyValue &op) { WithPrintLn([&](auto &out) { out << "* ScanAllByLabelPropertyValue" << " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << " {" @@ -66,7 +66,7 @@ bool PlanPrinter::PreVisit(query::plan::ScanAllByLabelPropertyValue &op) { return true; } -bool PlanPrinter::PreVisit(query::plan::ScanAllByLabelPropertyRange &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabelPropertyRange &op) { WithPrintLn([&](auto &out) { out << "* ScanAllByLabelPropertyRange" << " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << " {" @@ -75,7 +75,7 @@ bool PlanPrinter::PreVisit(query::plan::ScanAllByLabelPropertyRange &op) { return true; } -bool PlanPrinter::PreVisit(query::plan::ScanAllByLabelProperty &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabelProperty &op) { WithPrintLn([&](auto &out) { out << "* ScanAllByLabelProperty" << " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << " {" @@ -92,22 +92,22 @@ bool PlanPrinter::PreVisit(ScanAllById &op) { return true; } -bool PlanPrinter::PreVisit(query::plan::Expand &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::Expand &op) { WithPrintLn([&](auto &out) { *out_ << "* Expand (" << op.input_symbol_.name() << ")" - << (op.common_.direction == query::EdgeAtom::Direction::IN ? "<-" : "-") << "[" + << (op.common_.direction == memgraph::query::EdgeAtom::Direction::IN ? "<-" : "-") << "[" << op.common_.edge_symbol.name(); utils::PrintIterable(*out_, op.common_.edge_types, "|", [this](auto &stream, const auto &edge_type) { stream << ":" << dba_->EdgeTypeToName(edge_type); }); - *out_ << "]" << (op.common_.direction == query::EdgeAtom::Direction::OUT ? "->" : "-") << "(" + *out_ << "]" << (op.common_.direction == memgraph::query::EdgeAtom::Direction::OUT ? "->" : "-") << "(" << op.common_.node_symbol.name() << ")"; }); return true; } -bool PlanPrinter::PreVisit(query::plan::ExpandVariable &op) { - using Type = query::EdgeAtom::Type; +bool PlanPrinter::PreVisit(memgraph::query::plan::ExpandVariable &op) { + using Type = memgraph::query::EdgeAtom::Type; WithPrintLn([&](auto &out) { *out_ << "* "; switch (op.type_) { @@ -124,18 +124,18 @@ bool PlanPrinter::PreVisit(query::plan::ExpandVariable &op) { LOG_FATAL("Unexpected ExpandVariable::type_"); } *out_ << " (" << op.input_symbol_.name() << ")" - << (op.common_.direction == query::EdgeAtom::Direction::IN ? "<-" : "-") << "[" + << (op.common_.direction == memgraph::query::EdgeAtom::Direction::IN ? "<-" : "-") << "[" << op.common_.edge_symbol.name(); utils::PrintIterable(*out_, op.common_.edge_types, "|", [this](auto &stream, const auto &edge_type) { stream << ":" << dba_->EdgeTypeToName(edge_type); }); - *out_ << "]" << (op.common_.direction == query::EdgeAtom::Direction::OUT ? "->" : "-") << "(" + *out_ << "]" << (op.common_.direction == memgraph::query::EdgeAtom::Direction::OUT ? "->" : "-") << "(" << op.common_.node_symbol.name() << ")"; }); return true; } -bool PlanPrinter::PreVisit(query::plan::Produce &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::Produce &op) { WithPrintLn([&](auto &out) { out << "* Produce {"; utils::PrintIterable(out, op.named_expressions_, ", ", [](auto &out, const auto &nexpr) { out << nexpr->name_; }); @@ -154,7 +154,7 @@ PRE_VISIT(RemoveLabels); PRE_VISIT(EdgeUniquenessFilter); PRE_VISIT(Accumulate); -bool PlanPrinter::PreVisit(query::plan::Aggregate &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::Aggregate &op) { WithPrintLn([&](auto &out) { out << "* Aggregate {"; utils::PrintIterable(out, op.aggregations_, ", ", @@ -169,7 +169,7 @@ bool PlanPrinter::PreVisit(query::plan::Aggregate &op) { PRE_VISIT(Skip); PRE_VISIT(Limit); -bool PlanPrinter::PreVisit(query::plan::OrderBy &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::OrderBy &op) { WithPrintLn([&op](auto &out) { out << "* OrderBy {"; utils::PrintIterable(out, op.output_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); }); @@ -178,7 +178,7 @@ bool PlanPrinter::PreVisit(query::plan::OrderBy &op) { return true; } -bool PlanPrinter::PreVisit(query::plan::Merge &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::Merge &op) { WithPrintLn([](auto &out) { out << "* Merge"; }); Branch(*op.merge_match_, "On Match"); Branch(*op.merge_create_, "On Create"); @@ -186,7 +186,7 @@ bool PlanPrinter::PreVisit(query::plan::Merge &op) { return false; } -bool PlanPrinter::PreVisit(query::plan::Optional &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::Optional &op) { WithPrintLn([](auto &out) { out << "* Optional"; }); Branch(*op.optional_); op.input_->Accept(*this); @@ -196,7 +196,7 @@ bool PlanPrinter::PreVisit(query::plan::Optional &op) { PRE_VISIT(Unwind); PRE_VISIT(Distinct); -bool PlanPrinter::PreVisit(query::plan::Union &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::Union &op) { WithPrintLn([&op](auto &out) { out << "* Union {"; utils::PrintIterable(out, op.left_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); }); @@ -209,7 +209,7 @@ bool PlanPrinter::PreVisit(query::plan::Union &op) { return false; } -bool PlanPrinter::PreVisit(query::plan::CallProcedure &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::CallProcedure &op) { WithPrintLn([&op](auto &out) { out << "* CallProcedure<" << op.procedure_name_ << "> {"; utils::PrintIterable(out, op.result_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); }); @@ -218,17 +218,17 @@ bool PlanPrinter::PreVisit(query::plan::CallProcedure &op) { return true; } -bool PlanPrinter::PreVisit(query::plan::LoadCsv &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::LoadCsv &op) { WithPrintLn([&op](auto &out) { out << "* LoadCsv {" << op.row_var_.name() << "}"; }); return true; } -bool PlanPrinter::Visit(query::plan::Once &op) { +bool PlanPrinter::Visit(memgraph::query::plan::Once &op) { WithPrintLn([](auto &out) { out << "* Once"; }); return true; } -bool PlanPrinter::PreVisit(query::plan::Cartesian &op) { +bool PlanPrinter::PreVisit(memgraph::query::plan::Cartesian &op) { WithPrintLn([&op](auto &out) { out << "* Cartesian {"; utils::PrintIterable(out, op.left_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); }); @@ -248,7 +248,7 @@ bool PlanPrinter::DefaultPreVisit() { return true; } -void PlanPrinter::Branch(query::plan::LogicalOperator &op, const std::string &branch_name) { +void PlanPrinter::Branch(memgraph::query::plan::LogicalOperator &op, const std::string &branch_name) { WithPrintLn([&](auto &out) { out << "|\\ " << branch_name; }); ++depth_; op.Accept(*this); @@ -807,7 +807,7 @@ bool PlanToJsonVisitor::PreVisit(Unwind &op) { return false; } -bool PlanToJsonVisitor::PreVisit(query::plan::CallProcedure &op) { +bool PlanToJsonVisitor::PreVisit(memgraph::query::plan::CallProcedure &op) { json self; self["name"] = "CallProcedure"; self["procedure_name"] = op.procedure_name_; @@ -822,7 +822,7 @@ bool PlanToJsonVisitor::PreVisit(query::plan::CallProcedure &op) { return false; } -bool PlanToJsonVisitor::PreVisit(query::plan::LoadCsv &op) { +bool PlanToJsonVisitor::PreVisit(memgraph::query::plan::LoadCsv &op) { json self; self["name"] = "LoadCsv"; self["file"] = ToJson(op.file_); @@ -886,4 +886,4 @@ bool PlanToJsonVisitor::PreVisit(Cartesian &op) { } // namespace impl -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/pretty_print.hpp b/src/query/plan/pretty_print.hpp index 852a496a4..549c85844 100644 --- a/src/query/plan/pretty_print.hpp +++ b/src/query/plan/pretty_print.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,11 +18,11 @@ #include "query/plan/operator.hpp" -namespace query { +namespace memgraph::query { class DbAccessor; } -namespace query::plan { +namespace memgraph::query::plan { class LogicalOperator; @@ -225,4 +225,4 @@ class PlanToJsonVisitor : public virtual HierarchicalLogicalOperatorVisitor { } // namespace impl -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/profile.cpp b/src/query/plan/profile.cpp index d912ac354..1800f661d 100644 --- a/src/query/plan/profile.cpp +++ b/src/query/plan/profile.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "query/context.hpp" #include "utils/likely.hpp" -namespace query::plan { +namespace memgraph::query::plan { namespace { @@ -163,4 +163,4 @@ nlohmann::json ProfilingStatsToJson(const ProfilingStatsWithTotalTime &stats) { return helper.ToJson(); } -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/profile.hpp b/src/query/plan/profile.hpp index 11b7f99e7..b314fd0ef 100644 --- a/src/query/plan/profile.hpp +++ b/src/query/plan/profile.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "query/typed_value.hpp" -namespace query { +namespace memgraph::query { namespace plan { @@ -44,4 +44,4 @@ std::vector> ProfilingStatsToTable(const ProfilingStatsW nlohmann::json ProfilingStatsToJson(const ProfilingStatsWithTotalTime &stats); } // namespace plan -} // namespace query +} // namespace memgraph::query diff --git a/src/query/plan/read_write_type_checker.cpp b/src/query/plan/read_write_type_checker.cpp index 8836e4f8e..a2e65f295 100644 --- a/src/query/plan/read_write_type_checker.cpp +++ b/src/query/plan/read_write_type_checker.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ return continue_visiting; \ } -namespace query::plan { +namespace memgraph::query::plan { PRE_VISIT(CreateNode, RWType::W, true) PRE_VISIT(CreateExpand, RWType::R, true) @@ -120,4 +120,4 @@ std::string ReadWriteTypeChecker::TypeToString(const RWType type) { } } -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/read_write_type_checker.hpp b/src/query/plan/read_write_type_checker.hpp index d1a2062fc..95b014caa 100644 --- a/src/query/plan/read_write_type_checker.hpp +++ b/src/query/plan/read_write_type_checker.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include "query/plan/operator.hpp" -namespace query::plan { +namespace memgraph::query::plan { class ReadWriteTypeChecker : public virtual HierarchicalLogicalOperatorVisitor { public: @@ -91,4 +91,4 @@ class ReadWriteTypeChecker : public virtual HierarchicalLogicalOperatorVisitor { void UpdateType(RWType op_type); }; -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/rewrite/index_lookup.cpp b/src/query/plan/rewrite/index_lookup.cpp index 67334ea87..6ad2735e7 100644 --- a/src/query/plan/rewrite/index_lookup.cpp +++ b/src/query/plan/rewrite/index_lookup.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ DEFINE_VALIDATED_HIDDEN_int64(query_vertex_count_to_expand_existing, 10, "a regular expand. Default is 10, to turn off use -1.", FLAG_IN_RANGE(-1, std::numeric_limits::max())); -namespace query::plan::impl { +namespace memgraph::query::plan::impl { Expression *RemoveAndExpressions(Expression *expr, const std::unordered_set &exprs_to_remove) { auto *and_op = utils::Downcast(expr); @@ -47,4 +47,4 @@ Expression *RemoveAndExpressions(Expression *expr, const std::unordered_set RewriteWithIndexLookup(std::unique_ptr GenUnion(const CypherUnion &cypher_union, std:: } // namespace impl -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/rule_based_planner.hpp b/src/query/plan/rule_based_planner.hpp index 0937f212e..936d4f717 100644 --- a/src/query/plan/rule_based_planner.hpp +++ b/src/query/plan/rule_based_planner.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ #include "query/plan/preprocess.hpp" #include "utils/logging.hpp" -namespace query::plan { +namespace memgraph::query::plan { /// @brief Context which contains variables commonly used during planning. template @@ -184,12 +184,12 @@ class RuleBasedPlanner { if (auto *ret = utils::Downcast(clause)) { input_op = impl::GenReturn(*ret, std::move(input_op), *context.symbol_table, is_write, context.bound_symbols, *context.ast_storage); - } else if (auto *merge = utils::Downcast(clause)) { + } else if (auto *merge = utils::Downcast(clause)) { input_op = GenMerge(*merge, std::move(input_op), query_part.merge_matching[merge_id++]); // Treat MERGE clause as write, because we do not know if it will // create anything. is_write = true; - } else if (auto *with = utils::Downcast(clause)) { + } else if (auto *with = utils::Downcast(clause)) { input_op = impl::GenWith(*with, std::move(input_op), *context.symbol_table, is_write, context.bound_symbols, *context.ast_storage); // WITH clause advances the command, so reset the flag. @@ -197,12 +197,12 @@ class RuleBasedPlanner { } else if (auto op = HandleWriteClause(clause, input_op, *context.symbol_table, context.bound_symbols)) { is_write = true; input_op = std::move(op); - } else if (auto *unwind = utils::Downcast(clause)) { + } else if (auto *unwind = utils::Downcast(clause)) { const auto &symbol = context.symbol_table->at(*unwind->named_expression_); context.bound_symbols.insert(symbol); input_op = std::make_unique(std::move(input_op), unwind->named_expression_->expression_, symbol); - } else if (auto *call_proc = utils::Downcast(clause)) { + } else if (auto *call_proc = utils::Downcast(clause)) { std::vector result_symbols; result_symbols.reserve(call_proc->result_identifiers_.size()); for (const auto *ident : call_proc->result_identifiers_) { @@ -216,7 +216,7 @@ class RuleBasedPlanner { input_op = std::make_unique( std::move(input_op), call_proc->procedure_name_, call_proc->arguments_, call_proc->result_fields_, result_symbols, call_proc->memory_limit_, call_proc->memory_scale_, call_proc->is_write_); - } else if (auto *load_csv = utils::Downcast(clause)) { + } else if (auto *load_csv = utils::Downcast(clause)) { const auto &row_sym = context.symbol_table->at(*load_csv->row_var_); context.bound_symbols.insert(row_sym); @@ -338,16 +338,16 @@ class RuleBasedPlanner { std::unordered_set &bound_symbols) { if (auto *create = utils::Downcast(clause)) { return GenCreate(*create, std::move(input_op), symbol_table, bound_symbols); - } else if (auto *del = utils::Downcast(clause)) { + } else if (auto *del = utils::Downcast(clause)) { return std::make_unique(std::move(input_op), del->expressions_, del->detach_); - } else if (auto *set = utils::Downcast(clause)) { + } else if (auto *set = utils::Downcast(clause)) { return std::make_unique(std::move(input_op), GetProperty(set->property_lookup_->property_), set->property_lookup_, set->expression_); - } else if (auto *set = utils::Downcast(clause)) { + } else if (auto *set = utils::Downcast(clause)) { auto op = set->update_ ? plan::SetProperties::Op::UPDATE : plan::SetProperties::Op::REPLACE; const auto &input_symbol = symbol_table.at(*set->identifier_); return std::make_unique(std::move(input_op), input_symbol, set->expression_, op); - } else if (auto *set = utils::Downcast(clause)) { + } else if (auto *set = utils::Downcast(clause)) { const auto &input_symbol = symbol_table.at(*set->identifier_); std::vector labels; labels.reserve(set->labels_.size()); @@ -355,10 +355,10 @@ class RuleBasedPlanner { labels.push_back(GetLabel(label)); } return std::make_unique(std::move(input_op), input_symbol, labels); - } else if (auto *rem = utils::Downcast(clause)) { + } else if (auto *rem = utils::Downcast(clause)) { return std::make_unique(std::move(input_op), GetProperty(rem->property_lookup_->property_), rem->property_lookup_); - } else if (auto *rem = utils::Downcast(clause)) { + } else if (auto *rem = utils::Downcast(clause)) { const auto &input_symbol = symbol_table.at(*rem->identifier_); std::vector labels; labels.reserve(rem->labels_.size()); @@ -505,7 +505,7 @@ class RuleBasedPlanner { return last_op; } - auto GenMerge(query::Merge &merge, std::unique_ptr input_op, const Matching &matching) { + auto GenMerge(memgraph::query::Merge &merge, std::unique_ptr input_op, const Matching &matching) { // Copy the bound symbol set, because we don't want to use the updated // version when generating the create part. std::unordered_set bound_symbols_copy(context_->bound_symbols); @@ -532,4 +532,4 @@ class RuleBasedPlanner { } }; -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/scoped_profile.hpp b/src/query/plan/scoped_profile.hpp index 4dad0abd8..055cb5c5d 100644 --- a/src/query/plan/scoped_profile.hpp +++ b/src/query/plan/scoped_profile.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/likely.hpp" #include "utils/tsc.hpp" -namespace query { +namespace memgraph::query { namespace plan { @@ -30,7 +30,8 @@ namespace plan { */ class ScopedProfile { public: - ScopedProfile(uint64_t key, const char *name, query::ExecutionContext *context) noexcept : context_(context) { + ScopedProfile(uint64_t key, const char *name, memgraph::query::ExecutionContext *context) noexcept + : context_(context) { if (UNLIKELY(context_->is_profile_query)) { root_ = context_->stats_root; @@ -72,11 +73,11 @@ class ScopedProfile { } private: - query::ExecutionContext *context_; + memgraph::query::ExecutionContext *context_; ProfilingStats *root_; ProfilingStats *stats_; unsigned long long start_time_; }; } // namespace plan -} // namespace query +} // namespace memgraph::query diff --git a/src/query/plan/variable_start_planner.cpp b/src/query/plan/variable_start_planner.cpp index f3dde0c2a..cd1ae3ef7 100644 --- a/src/query/plan/variable_start_planner.cpp +++ b/src/query/plan/variable_start_planner.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ DEFINE_VALIDATED_HIDDEN_uint64(query_max_plans, 1000U, "Maximum number of generated plans for a query.", FLAG_IN_RANGE(1, std::numeric_limits::max())); -namespace query::plan::impl { +namespace memgraph::query::plan::impl { namespace { @@ -293,4 +293,4 @@ bool VaryQueryPartMatching::iterator::operator==(const iterator &other) const { return matchings_it_ == other.matchings_it_ && optional_it_ == other.optional_it_ && merge_it_ == other.merge_it_; } -} // namespace query::plan::impl +} // namespace memgraph::query::plan::impl diff --git a/src/query/plan/variable_start_planner.hpp b/src/query/plan/variable_start_planner.hpp index d6a0a3edc..f6c9dbeac 100644 --- a/src/query/plan/variable_start_planner.hpp +++ b/src/query/plan/variable_start_planner.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ DECLARE_uint64(query_max_plans); -namespace query::plan { +namespace memgraph::query::plan { /// Produces a Cartesian product among vectors between begin and end iterator. /// For example: @@ -333,4 +333,4 @@ class VariableStartPlanner { VariableStartPlanner, std::vector &)>::type; }; -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/plan/vertex_count_cache.hpp b/src/query/plan/vertex_count_cache.hpp index ff9a77e29..277c4c574 100644 --- a/src/query/plan/vertex_count_cache.hpp +++ b/src/query/plan/vertex_count_cache.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/bound.hpp" #include "utils/fnv.hpp" -namespace query::plan { +namespace memgraph::query::plan { /// A stand in class for `TDbAccessor` which provides memoized calls to /// `VerticesCount`. @@ -95,11 +95,11 @@ class VertexCountCache { size_t operator()(const BoundsKey &key) const { const auto &maybe_lower = key.first; const auto &maybe_upper = key.second; - query::TypedValue lower; - query::TypedValue upper; + memgraph::query::TypedValue lower; + memgraph::query::TypedValue upper; if (maybe_lower) lower = TypedValue(maybe_lower->value()); if (maybe_upper) upper = TypedValue(maybe_upper->value()); - query::TypedValue::Hash hash; + memgraph::query::TypedValue::Hash hash; return utils::HashCombine{}(hash(lower), hash(upper)); } }; @@ -108,11 +108,11 @@ class VertexCountCache { bool operator()(const BoundsKey &a, const BoundsKey &b) const { auto bound_equal = [](const auto &maybe_bound_a, const auto &maybe_bound_b) { if (maybe_bound_a && maybe_bound_b && maybe_bound_a->type() != maybe_bound_b->type()) return false; - query::TypedValue bound_a; - query::TypedValue bound_b; + memgraph::query::TypedValue bound_a; + memgraph::query::TypedValue bound_b; if (maybe_bound_a) bound_a = TypedValue(maybe_bound_a->value()); if (maybe_bound_b) bound_b = TypedValue(maybe_bound_b->value()); - return query::TypedValue::BoolEqual{}(bound_a, bound_b); + return memgraph::query::TypedValue::BoolEqual{}(bound_a, bound_b); }; return bound_equal(a.first, b.first) && bound_equal(a.second, b.second); } @@ -122,10 +122,10 @@ class VertexCountCache { std::optional vertices_count_; std::unordered_map label_vertex_count_; std::unordered_map label_property_vertex_count_; - std::unordered_map< - LabelPropertyKey, - std::unordered_map, - LabelPropertyHash> + std::unordered_map, + LabelPropertyHash> property_value_vertex_count_; std::unordered_map, LabelPropertyHash> @@ -137,4 +137,4 @@ auto MakeVertexCountCache(TDbAccessor *db) { return VertexCountCache(db); } -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/src/query/procedure/cypher_type_ptr.hpp b/src/query/procedure/cypher_type_ptr.hpp index 77b37b2a5..6d92dac34 100644 --- a/src/query/procedure/cypher_type_ptr.hpp +++ b/src/query/procedure/cypher_type_ptr.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include #include -namespace query::procedure { +namespace memgraph::query::procedure { class CypherType; using CypherTypePtr = std::unique_ptr>; -} // namespace query::procedure \ No newline at end of file +} // namespace memgraph::query::procedure \ No newline at end of file diff --git a/src/query/procedure/cypher_types.hpp b/src/query/procedure/cypher_types.hpp index d9a980543..39ed3296e 100644 --- a/src/query/procedure/cypher_types.hpp +++ b/src/query/procedure/cypher_types.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,7 +24,7 @@ #include "utils/memory.hpp" #include "utils/pmr/string.hpp" -namespace query::procedure { +namespace memgraph::query::procedure { class ListType; class NullableType; @@ -47,7 +47,7 @@ class CypherType { virtual bool SatisfiesType(const mgp_value &) const = 0; /// Return true if given TypedValue is of the type as described by `this`. - virtual bool SatisfiesType(const query::TypedValue &) const = 0; + virtual bool SatisfiesType(const memgraph::query::TypedValue &) const = 0; // The following methods are a simple replacement for RTTI because we have // some special cases we need to handle. @@ -63,7 +63,7 @@ class AnyType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type != MGP_VALUE_TYPE_NULL; } - bool SatisfiesType(const query::TypedValue &value) const override { return !value.IsNull(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return !value.IsNull(); } }; class BoolType : public CypherType { @@ -72,7 +72,7 @@ class BoolType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_BOOL; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsBool(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsBool(); } }; class StringType : public CypherType { @@ -81,7 +81,7 @@ class StringType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_STRING; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsString(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsString(); } }; class IntType : public CypherType { @@ -90,7 +90,7 @@ class IntType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_INT; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsInt(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsInt(); } }; class FloatType : public CypherType { @@ -99,7 +99,7 @@ class FloatType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_DOUBLE; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsDouble(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsDouble(); } }; class NumberType : public CypherType { @@ -110,7 +110,9 @@ class NumberType : public CypherType { return value.type == MGP_VALUE_TYPE_INT || value.type == MGP_VALUE_TYPE_DOUBLE; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsInt() || value.IsDouble(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { + return value.IsInt() || value.IsDouble(); + } }; class NodeType : public CypherType { @@ -119,7 +121,7 @@ class NodeType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_VERTEX; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsVertex(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsVertex(); } }; class RelationshipType : public CypherType { @@ -128,7 +130,7 @@ class RelationshipType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_EDGE; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsEdge(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsEdge(); } }; class PathType : public CypherType { @@ -137,7 +139,7 @@ class PathType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_PATH; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsPath(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsPath(); } }; // You'd think that MapType would be a composite type like ListType, but nope. @@ -153,7 +155,7 @@ class MapType : public CypherType { return value.type == MGP_VALUE_TYPE_MAP || value.type == MGP_VALUE_TYPE_VERTEX || value.type == MGP_VALUE_TYPE_EDGE; } - bool SatisfiesType(const query::TypedValue &value) const override { + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsMap() || value.IsVertex() || value.IsEdge(); } }; @@ -166,7 +168,7 @@ class DateType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_DATE; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsDate(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsDate(); } }; class LocalTimeType : public CypherType { @@ -175,7 +177,7 @@ class LocalTimeType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_LOCAL_TIME; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsLocalTime(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsLocalTime(); } }; class LocalDateTimeType : public CypherType { @@ -184,7 +186,7 @@ class LocalDateTimeType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_LOCAL_DATE_TIME; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsLocalDateTime(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsLocalDateTime(); } }; class DurationType : public CypherType { @@ -193,7 +195,7 @@ class DurationType : public CypherType { bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_DURATION; } - bool SatisfiesType(const query::TypedValue &value) const override { return value.IsDuration(); } + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsDuration(); } }; // Composite Types @@ -226,7 +228,7 @@ class ListType : public CypherType { return true; } - bool SatisfiesType(const query::TypedValue &value) const override { + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { if (!value.IsList()) return false; for (const auto &elem : value.ValueList()) { if (!element_type_->SatisfiesType(elem)) return false; @@ -283,11 +285,11 @@ class NullableType : public CypherType { return value.type == MGP_VALUE_TYPE_NULL || type_->SatisfiesType(value); } - bool SatisfiesType(const query::TypedValue &value) const override { + bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsNull() || type_->SatisfiesType(value); } const NullableType *AsNullableType() const override { return this; } }; -} // namespace query::procedure +} // namespace memgraph::query::procedure diff --git a/src/query/procedure/mg_procedure_helpers.cpp b/src/query/procedure/mg_procedure_helpers.cpp index 550936347..25ddf192e 100644 --- a/src/query/procedure/mg_procedure_helpers.cpp +++ b/src/query/procedure/mg_procedure_helpers.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "query/procedure/mg_procedure_helpers.hpp" -namespace query::procedure { +namespace memgraph::query::procedure { MgpUniquePtr GetStringValueOrSetError(const char *string, mgp_memory *memory, mgp_result *result) { procedure::MgpUniquePtr value{nullptr, mgp_value_destroy}; const auto success = @@ -33,4 +33,4 @@ bool InsertResultOrSetError(mgp_result *result, mgp_result_record *record, const return true; } -} // namespace query::procedure +} // namespace memgraph::query::procedure diff --git a/src/query/procedure/mg_procedure_helpers.hpp b/src/query/procedure/mg_procedure_helpers.hpp index 60e1a15c5..8a8b2200c 100644 --- a/src/query/procedure/mg_procedure_helpers.hpp +++ b/src/query/procedure/mg_procedure_helpers.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "mg_procedure.h" -namespace query::procedure { +namespace memgraph::query::procedure { template TResult Call(TFunc func, TArgs... args) { static_assert(std::is_trivially_copyable_v); @@ -66,4 +66,4 @@ template [[nodiscard]] bool InsertResultOrSetError(mgp_result *result, mgp_result_record *record, const char *result_name, mgp_value *value); -} // namespace query::procedure +} // namespace memgraph::query::procedure diff --git a/src/query/procedure/mg_procedure_impl.cpp b/src/query/procedure/mg_procedure_impl.cpp index e28abdbea..238de1759 100644 --- a/src/query/procedure/mg_procedure_impl.cpp +++ b/src/query/procedure/mg_procedure_impl.cpp @@ -39,14 +39,14 @@ #include "utils/variant_helpers.hpp" // This file contains implementation of top level C API functions, but this is -// all actually part of query::procedure. So use that namespace for simplicity. +// all actually part of memgraph::query::procedure. So use that namespace for simplicity. // NOLINTNEXTLINE(google-build-using-namespace) -using namespace query::procedure; +using namespace memgraph::query::procedure; namespace { -void *MgpAlignedAllocImpl(utils::MemoryResource &memory, const size_t size_in_bytes, const size_t alignment) { - if (size_in_bytes == 0U || !utils::IsPow2(alignment)) return nullptr; +void *MgpAlignedAllocImpl(memgraph::utils::MemoryResource &memory, const size_t size_in_bytes, const size_t alignment) { + if (size_in_bytes == 0U || !memgraph::utils::IsPow2(alignment)) return nullptr; // Simplify alignment by always using values greater or equal to max_align. const size_t alloc_align = std::max(alignment, alignof(std::max_align_t)); // Allocate space for header containing size & alignment info. @@ -56,7 +56,7 @@ void *MgpAlignedAllocImpl(utils::MemoryResource &memory, const size_t size_in_by // just allocate an additional multiple of `alloc_align` of bytes such that // the header fits. `data` will then be aligned after this multiple of bytes. static_assert(std::is_same_v); - const auto maybe_bytes_for_header = utils::RoundUint64ToMultiple(header_size, alloc_align); + const auto maybe_bytes_for_header = memgraph::utils::RoundUint64ToMultiple(header_size, alloc_align); if (!maybe_bytes_for_header) return nullptr; const size_t bytes_for_header = *maybe_bytes_for_header; const size_t alloc_size = bytes_for_header + size_in_bytes; @@ -69,7 +69,7 @@ void *MgpAlignedAllocImpl(utils::MemoryResource &memory, const size_t size_in_by return data; } -void MgpFreeImpl(utils::MemoryResource &memory, void *const p) noexcept { +void MgpFreeImpl(memgraph::utils::MemoryResource &memory, void *const p) noexcept { try { if (!p) return; char *const data = reinterpret_cast(p); @@ -82,12 +82,12 @@ void MgpFreeImpl(utils::MemoryResource &memory, void *const p) noexcept { // We need not check allocation request overflow, since we did so already in // mgp_aligned_alloc. const size_t header_size = sizeof(size_in_bytes) + sizeof(alloc_align); - const size_t bytes_for_header = *utils::RoundUint64ToMultiple(header_size, alloc_align); + const size_t bytes_for_header = *memgraph::utils::RoundUint64ToMultiple(header_size, alloc_align); const size_t alloc_size = bytes_for_header + size_in_bytes; // Get the original ptr we allocated. void *const original_ptr = data - bytes_for_header; memory.Deallocate(original_ptr, alloc_size, alloc_align); - } catch (const utils::BasicException &be) { + } catch (const memgraph::utils::BasicException &be) { spdlog::error("BasicException during the release of memory for query modules: {}", be.what()); } catch (const std::exception &e) { spdlog::error("std::exception during the release of memory for query modules: {}", e.what()); @@ -95,28 +95,28 @@ void MgpFreeImpl(utils::MemoryResource &memory, void *const p) noexcept { spdlog::error("Unexpected throw during the release of memory for query modules"); } } -struct DeletedObjectException : public utils::BasicException { - using utils::BasicException::BasicException; +struct DeletedObjectException : public memgraph::utils::BasicException { + using memgraph::utils::BasicException::BasicException; }; -struct KeyAlreadyExistsException : public utils::BasicException { - using utils::BasicException::BasicException; +struct KeyAlreadyExistsException : public memgraph::utils::BasicException { + using memgraph::utils::BasicException::BasicException; }; -struct InsufficientBufferException : public utils::BasicException { - using utils::BasicException::BasicException; +struct InsufficientBufferException : public memgraph::utils::BasicException { + using memgraph::utils::BasicException::BasicException; }; -struct ImmutableObjectException : public utils::BasicException { - using utils::BasicException::BasicException; +struct ImmutableObjectException : public memgraph::utils::BasicException { + using memgraph::utils::BasicException::BasicException; }; -struct ValueConversionException : public utils::BasicException { - using utils::BasicException::BasicException; +struct ValueConversionException : public memgraph::utils::BasicException { + using memgraph::utils::BasicException::BasicException; }; -struct SerializationException : public utils::BasicException { - using utils::BasicException::BasicException; +struct SerializationException : public memgraph::utils::BasicException { + using memgraph::utils::BasicException::BasicException; }; template @@ -162,7 +162,7 @@ template } catch (const std::bad_alloc &bae) { spdlog::error("Memory allocation error during mg API call: {}", bae.what()); return MGP_ERROR_UNABLE_TO_ALLOCATE; - } catch (const utils::OutOfMemoryException &oome) { + } catch (const memgraph::utils::OutOfMemoryException &oome) { spdlog::error("Memory limit exceeded during mg API call: {}", oome.what()); return MGP_ERROR_UNABLE_TO_ALLOCATE; } catch (const std::out_of_range &oore) { @@ -177,7 +177,7 @@ template } catch (const std::exception &e) { spdlog::error("Unexpected error during mg API call: {}", e.what()); return MGP_ERROR_UNKNOWN_ERROR; - } catch (const utils::temporal::InvalidArgumentException &e) { + } catch (const memgraph::utils::temporal::InvalidArgumentException &e) { spdlog::error("Invalid argument was sent to an mg API call for temporal types: {}", e.what()); return MGP_ERROR_INVALID_ARGUMENT; } catch (...) { @@ -187,7 +187,7 @@ template return MGP_ERROR_NO_ERROR; } -bool MgpGraphIsMutable(const mgp_graph &graph) noexcept { return graph.view == storage::View::NEW; } +bool MgpGraphIsMutable(const mgp_graph &graph) noexcept { return graph.view == memgraph::storage::View::NEW; } bool MgpVertexIsMutable(const mgp_vertex &vertex) { return MgpGraphIsMutable(*vertex.graph); } @@ -229,8 +229,8 @@ void mgp_global_free(void *const p) { namespace { template -U *NewRawMgpObject(utils::MemoryResource *memory, TArgs &&...args) { - utils::Allocator allocator(memory); +U *NewRawMgpObject(memgraph::utils::MemoryResource *memory, TArgs &&...args) { + memgraph::utils::Allocator allocator(memory); return allocator.template new_object(std::forward(args)...); } @@ -245,7 +245,7 @@ template void DeleteRawMgpObject(T *ptr) noexcept { try { if (!ptr) return; - utils::Allocator allocator(ptr->GetMemoryResource()); + memgraph::utils::Allocator allocator(ptr->GetMemoryResource()); allocator.delete_object(ptr); } catch (...) { LOG_FATAL("Cannot deallocate mgp object"); @@ -257,155 +257,156 @@ MgpUniquePtr NewMgpObject(mgp_memory *memory, TArgs &&...args) { return MgpUniquePtr(NewRawMgpObject(memory->impl, std::forward(args)...), &DeleteRawMgpObject); } -mgp_value_type FromTypedValueType(query::TypedValue::Type type) { +mgp_value_type FromTypedValueType(memgraph::query::TypedValue::Type type) { switch (type) { - case query::TypedValue::Type::Null: + case memgraph::query::TypedValue::Type::Null: return MGP_VALUE_TYPE_NULL; - case query::TypedValue::Type::Bool: + case memgraph::query::TypedValue::Type::Bool: return MGP_VALUE_TYPE_BOOL; - case query::TypedValue::Type::Int: + case memgraph::query::TypedValue::Type::Int: return MGP_VALUE_TYPE_INT; - case query::TypedValue::Type::Double: + case memgraph::query::TypedValue::Type::Double: return MGP_VALUE_TYPE_DOUBLE; - case query::TypedValue::Type::String: + case memgraph::query::TypedValue::Type::String: return MGP_VALUE_TYPE_STRING; - case query::TypedValue::Type::List: + case memgraph::query::TypedValue::Type::List: return MGP_VALUE_TYPE_LIST; - case query::TypedValue::Type::Map: + case memgraph::query::TypedValue::Type::Map: return MGP_VALUE_TYPE_MAP; - case query::TypedValue::Type::Vertex: + case memgraph::query::TypedValue::Type::Vertex: return MGP_VALUE_TYPE_VERTEX; - case query::TypedValue::Type::Edge: + case memgraph::query::TypedValue::Type::Edge: return MGP_VALUE_TYPE_EDGE; - case query::TypedValue::Type::Path: + case memgraph::query::TypedValue::Type::Path: return MGP_VALUE_TYPE_PATH; - case query::TypedValue::Type::Date: + case memgraph::query::TypedValue::Type::Date: return MGP_VALUE_TYPE_DATE; - case query::TypedValue::Type::LocalTime: + case memgraph::query::TypedValue::Type::LocalTime: return MGP_VALUE_TYPE_LOCAL_TIME; - case query::TypedValue::Type::LocalDateTime: + case memgraph::query::TypedValue::Type::LocalDateTime: return MGP_VALUE_TYPE_LOCAL_DATE_TIME; - case query::TypedValue::Type::Duration: + case memgraph::query::TypedValue::Type::Duration: return MGP_VALUE_TYPE_DURATION; } } -query::TypedValue ToTypedValue(const mgp_value &val, utils::MemoryResource *memory) { +memgraph::query::TypedValue ToTypedValue(const mgp_value &val, memgraph::utils::MemoryResource *memory) { switch (val.type) { case MGP_VALUE_TYPE_NULL: - return query::TypedValue(memory); + return memgraph::query::TypedValue(memory); case MGP_VALUE_TYPE_BOOL: - return query::TypedValue(val.bool_v, memory); + return memgraph::query::TypedValue(val.bool_v, memory); case MGP_VALUE_TYPE_INT: - return query::TypedValue(val.int_v, memory); + return memgraph::query::TypedValue(val.int_v, memory); case MGP_VALUE_TYPE_DOUBLE: - return query::TypedValue(val.double_v, memory); + return memgraph::query::TypedValue(val.double_v, memory); case MGP_VALUE_TYPE_STRING: - return query::TypedValue(val.string_v, memory); + return memgraph::query::TypedValue(val.string_v, memory); case MGP_VALUE_TYPE_LIST: { const auto *list = val.list_v; - query::TypedValue::TVector tv_list(memory); + memgraph::query::TypedValue::TVector tv_list(memory); tv_list.reserve(list->elems.size()); for (const auto &elem : list->elems) { tv_list.emplace_back(ToTypedValue(elem, memory)); } - return query::TypedValue(std::move(tv_list)); + return memgraph::query::TypedValue(std::move(tv_list)); } case MGP_VALUE_TYPE_MAP: { const auto *map = val.map_v; - query::TypedValue::TMap tv_map(memory); + memgraph::query::TypedValue::TMap tv_map(memory); for (const auto &item : map->items) { tv_map.emplace(item.first, ToTypedValue(item.second, memory)); } - return query::TypedValue(std::move(tv_map)); + return memgraph::query::TypedValue(std::move(tv_map)); } case MGP_VALUE_TYPE_VERTEX: - return query::TypedValue(val.vertex_v->impl, memory); + return memgraph::query::TypedValue(val.vertex_v->impl, memory); case MGP_VALUE_TYPE_EDGE: - return query::TypedValue(val.edge_v->impl, memory); + return memgraph::query::TypedValue(val.edge_v->impl, memory); case MGP_VALUE_TYPE_PATH: { const auto *path = val.path_v; MG_ASSERT(!path->vertices.empty()); MG_ASSERT(path->vertices.size() == path->edges.size() + 1); - query::Path tv_path(path->vertices[0].impl, memory); + memgraph::query::Path tv_path(path->vertices[0].impl, memory); for (size_t i = 0; i < path->edges.size(); ++i) { tv_path.Expand(path->edges[i].impl); tv_path.Expand(path->vertices[i + 1].impl); } - return query::TypedValue(std::move(tv_path)); + return memgraph::query::TypedValue(std::move(tv_path)); } case MGP_VALUE_TYPE_DATE: - return query::TypedValue(val.date_v->date, memory); + return memgraph::query::TypedValue(val.date_v->date, memory); case MGP_VALUE_TYPE_LOCAL_TIME: - return query::TypedValue(val.local_time_v->local_time, memory); + return memgraph::query::TypedValue(val.local_time_v->local_time, memory); case MGP_VALUE_TYPE_LOCAL_DATE_TIME: - return query::TypedValue(val.local_date_time_v->local_date_time, memory); + return memgraph::query::TypedValue(val.local_date_time_v->local_date_time, memory); case MGP_VALUE_TYPE_DURATION: - return query::TypedValue(val.duration_v->duration, memory); + return memgraph::query::TypedValue(val.duration_v->duration, memory); } } } // namespace -mgp_value::mgp_value(utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_NULL), memory(m) {} +mgp_value::mgp_value(memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_NULL), memory(m) {} -mgp_value::mgp_value(bool val, utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_BOOL), memory(m), bool_v(val) {} +mgp_value::mgp_value(bool val, memgraph::utils::MemoryResource *m) noexcept + : type(MGP_VALUE_TYPE_BOOL), memory(m), bool_v(val) {} -mgp_value::mgp_value(int64_t val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(int64_t val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_INT), memory(m), int_v(val) {} -mgp_value::mgp_value(double val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(double val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_DOUBLE), memory(m), double_v(val) {} -mgp_value::mgp_value(const char *val, utils::MemoryResource *m) +mgp_value::mgp_value(const char *val, memgraph::utils::MemoryResource *m) : type(MGP_VALUE_TYPE_STRING), memory(m), string_v(val, m) {} -mgp_value::mgp_value(mgp_list *val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(mgp_list *val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_LIST), memory(m), list_v(val) { MG_ASSERT(val->GetMemoryResource() == m, "Unable to take ownership of a pointer with different allocator."); } -mgp_value::mgp_value(mgp_map *val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(mgp_map *val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_MAP), memory(m), map_v(val) { MG_ASSERT(val->GetMemoryResource() == m, "Unable to take ownership of a pointer with different allocator."); } -mgp_value::mgp_value(mgp_vertex *val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(mgp_vertex *val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_VERTEX), memory(m), vertex_v(val) { MG_ASSERT(val->GetMemoryResource() == m, "Unable to take ownership of a pointer with different allocator."); } -mgp_value::mgp_value(mgp_edge *val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(mgp_edge *val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_EDGE), memory(m), edge_v(val) { MG_ASSERT(val->GetMemoryResource() == m, "Unable to take ownership of a pointer with different allocator."); } -mgp_value::mgp_value(mgp_path *val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(mgp_path *val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_PATH), memory(m), path_v(val) { MG_ASSERT(val->GetMemoryResource() == m, "Unable to take ownership of a pointer with different allocator."); } -mgp_value::mgp_value(mgp_date *val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(mgp_date *val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_DATE), memory(m), date_v(val) { MG_ASSERT(val->GetMemoryResource() == m, "Unable to take ownership of a pointer with different allocator."); } -mgp_value::mgp_value(mgp_local_time *val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(mgp_local_time *val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_LOCAL_TIME), memory(m), local_time_v(val) { MG_ASSERT(val->GetMemoryResource() == m, "Unable to take ownership of a pointer with different allocator."); } -mgp_value::mgp_value(mgp_local_date_time *val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(mgp_local_date_time *val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_LOCAL_DATE_TIME), memory(m), local_date_time_v(val) { MG_ASSERT(val->GetMemoryResource() == m, "Unable to take ownership of a pointer with different allocator."); } -mgp_value::mgp_value(mgp_duration *val, utils::MemoryResource *m) noexcept +mgp_value::mgp_value(mgp_duration *val, memgraph::utils::MemoryResource *m) noexcept : type(MGP_VALUE_TYPE_DURATION), memory(m), duration_v(val) { MG_ASSERT(val->GetMemoryResource() == m, "Unable to take ownership of a pointer with different allocator."); } -mgp_value::mgp_value(const query::TypedValue &tv, mgp_graph *graph, utils::MemoryResource *m) +mgp_value::mgp_value(const memgraph::query::TypedValue &tv, mgp_graph *graph, memgraph::utils::MemoryResource *m) : type(FromTypedValueType(tv.type())), memory(m) { switch (type) { case MGP_VALUE_TYPE_NULL: @@ -420,19 +421,19 @@ mgp_value::mgp_value(const query::TypedValue &tv, mgp_graph *graph, utils::Memor double_v = tv.ValueDouble(); break; case MGP_VALUE_TYPE_STRING: - new (&string_v) utils::pmr::string(tv.ValueString(), m); + new (&string_v) memgraph::utils::pmr::string(tv.ValueString(), m); break; case MGP_VALUE_TYPE_LIST: { // Fill the stack allocated container and then construct the actual member // value. This handles the case when filling the container throws // something and our destructor doesn't get called so member value isn't // released. - utils::pmr::vector elems(m); + memgraph::utils::pmr::vector elems(m); elems.reserve(tv.ValueList().size()); for (const auto &elem : tv.ValueList()) { elems.emplace_back(elem, graph); } - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); list_v = allocator.new_object(std::move(elems)); break; } @@ -441,21 +442,21 @@ mgp_value::mgp_value(const query::TypedValue &tv, mgp_graph *graph, utils::Memor // value. This handles the case when filling the container throws // something and our destructor doesn't get called so member value isn't // released. - utils::pmr::map items(m); + memgraph::utils::pmr::map items(m); for (const auto &item : tv.ValueMap()) { items.emplace(item.first, mgp_value(item.second, graph, m)); } - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); map_v = allocator.new_object(std::move(items)); break; } case MGP_VALUE_TYPE_VERTEX: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); vertex_v = allocator.new_object(tv.ValueVertex(), graph); break; } case MGP_VALUE_TYPE_EDGE: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); edge_v = allocator.new_object(tv.ValueEdge(), graph); break; } @@ -473,102 +474,102 @@ mgp_value::mgp_value(const query::TypedValue &tv, mgp_graph *graph, utils::Memor for (const auto &e : tv.ValuePath().edges()) { tmp_path.edges.emplace_back(e, graph); } - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); path_v = allocator.new_object(std::move(tmp_path)); break; } case MGP_VALUE_TYPE_DATE: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); date_v = allocator.new_object(tv.ValueDate()); break; } case MGP_VALUE_TYPE_LOCAL_TIME: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); local_time_v = allocator.new_object(tv.ValueLocalTime()); break; } case MGP_VALUE_TYPE_LOCAL_DATE_TIME: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); local_date_time_v = allocator.new_object(tv.ValueLocalDateTime()); break; } case MGP_VALUE_TYPE_DURATION: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); duration_v = allocator.new_object(tv.ValueDuration()); break; } } } -mgp_value::mgp_value(const storage::PropertyValue &pv, utils::MemoryResource *m) : memory(m) { +mgp_value::mgp_value(const memgraph::storage::PropertyValue &pv, memgraph::utils::MemoryResource *m) : memory(m) { switch (pv.type()) { - case storage::PropertyValue::Type::Null: + case memgraph::storage::PropertyValue::Type::Null: type = MGP_VALUE_TYPE_NULL; break; - case storage::PropertyValue::Type::Bool: + case memgraph::storage::PropertyValue::Type::Bool: type = MGP_VALUE_TYPE_BOOL; bool_v = pv.ValueBool(); break; - case storage::PropertyValue::Type::Int: + case memgraph::storage::PropertyValue::Type::Int: type = MGP_VALUE_TYPE_INT; int_v = pv.ValueInt(); break; - case storage::PropertyValue::Type::Double: + case memgraph::storage::PropertyValue::Type::Double: type = MGP_VALUE_TYPE_DOUBLE; double_v = pv.ValueDouble(); break; - case storage::PropertyValue::Type::String: + case memgraph::storage::PropertyValue::Type::String: type = MGP_VALUE_TYPE_STRING; - new (&string_v) utils::pmr::string(pv.ValueString(), m); + new (&string_v) memgraph::utils::pmr::string(pv.ValueString(), m); break; - case storage::PropertyValue::Type::List: { + case memgraph::storage::PropertyValue::Type::List: { // Fill the stack allocated container and then construct the actual member // value. This handles the case when filling the container throws // something and our destructor doesn't get called so member value isn't // released. type = MGP_VALUE_TYPE_LIST; - utils::pmr::vector elems(m); + memgraph::utils::pmr::vector elems(m); elems.reserve(pv.ValueList().size()); for (const auto &elem : pv.ValueList()) { elems.emplace_back(elem); } - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); list_v = allocator.new_object(std::move(elems)); break; } - case storage::PropertyValue::Type::Map: { + case memgraph::storage::PropertyValue::Type::Map: { // Fill the stack allocated container and then construct the actual member // value. This handles the case when filling the container throws // something and our destructor doesn't get called so member value isn't // released. type = MGP_VALUE_TYPE_MAP; - utils::pmr::map items(m); + memgraph::utils::pmr::map items(m); for (const auto &item : pv.ValueMap()) { items.emplace(item.first, item.second); } - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); map_v = allocator.new_object(std::move(items)); break; } - case storage::PropertyValue::Type::TemporalData: { + case memgraph::storage::PropertyValue::Type::TemporalData: { const auto &temporal_data = pv.ValueTemporalData(); switch (temporal_data.type) { - case storage::TemporalType::Date: { + case memgraph::storage::TemporalType::Date: { type = MGP_VALUE_TYPE_DATE; date_v = NewRawMgpObject(m, temporal_data.microseconds); break; } - case storage::TemporalType::LocalTime: { + case memgraph::storage::TemporalType::LocalTime: { type = MGP_VALUE_TYPE_LOCAL_TIME; local_time_v = NewRawMgpObject(m, temporal_data.microseconds); break; } - case storage::TemporalType::LocalDateTime: { + case memgraph::storage::TemporalType::LocalDateTime: { type = MGP_VALUE_TYPE_LOCAL_DATE_TIME; local_date_time_v = NewRawMgpObject(m, temporal_data.microseconds); break; } - case storage::TemporalType::Duration: { + case memgraph::storage::TemporalType::Duration: { type = MGP_VALUE_TYPE_DURATION; duration_v = NewRawMgpObject(m, temporal_data.microseconds); break; @@ -578,7 +579,7 @@ mgp_value::mgp_value(const storage::PropertyValue &pv, utils::MemoryResource *m) } } -mgp_value::mgp_value(const mgp_value &other, utils::MemoryResource *m) : type(other.type), memory(m) { +mgp_value::mgp_value(const mgp_value &other, memgraph::utils::MemoryResource *m) : type(other.type), memory(m) { switch (other.type) { case MGP_VALUE_TYPE_NULL: break; @@ -592,30 +593,30 @@ mgp_value::mgp_value(const mgp_value &other, utils::MemoryResource *m) : type(ot double_v = other.double_v; break; case MGP_VALUE_TYPE_STRING: - new (&string_v) utils::pmr::string(other.string_v, m); + new (&string_v) memgraph::utils::pmr::string(other.string_v, m); break; case MGP_VALUE_TYPE_LIST: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); list_v = allocator.new_object(*other.list_v); break; } case MGP_VALUE_TYPE_MAP: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); map_v = allocator.new_object(*other.map_v); break; } case MGP_VALUE_TYPE_VERTEX: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); vertex_v = allocator.new_object(*other.vertex_v); break; } case MGP_VALUE_TYPE_EDGE: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); edge_v = allocator.new_object(*other.edge_v); break; } case MGP_VALUE_TYPE_PATH: { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); path_v = allocator.new_object(*other.path_v); break; } @@ -642,7 +643,7 @@ namespace { void DeleteValueMember(mgp_value *value) noexcept { MG_ASSERT(value); - utils::Allocator allocator(value->GetMemoryResource()); + memgraph::utils::Allocator allocator(value->GetMemoryResource()); switch (Call(mgp_value_get_type, value)) { case MGP_VALUE_TYPE_NULL: case MGP_VALUE_TYPE_BOOL: @@ -650,7 +651,7 @@ void DeleteValueMember(mgp_value *value) noexcept { case MGP_VALUE_TYPE_DOUBLE: return; case MGP_VALUE_TYPE_STRING: - using TString = utils::pmr::string; + using TString = memgraph::utils::pmr::string; value->string_v.~TString(); return; case MGP_VALUE_TYPE_LIST: @@ -685,7 +686,7 @@ void DeleteValueMember(mgp_value *value) noexcept { } // namespace -mgp_value::mgp_value(mgp_value &&other, utils::MemoryResource *m) : type(other.type), memory(m) { +mgp_value::mgp_value(mgp_value &&other, memgraph::utils::MemoryResource *m) : type(other.type), memory(m) { switch (other.type) { case MGP_VALUE_TYPE_NULL: break; @@ -699,7 +700,7 @@ mgp_value::mgp_value(mgp_value &&other, utils::MemoryResource *m) : type(other.t double_v = other.double_v; break; case MGP_VALUE_TYPE_STRING: - new (&string_v) utils::pmr::string(std::move(other.string_v), m); + new (&string_v) memgraph::utils::pmr::string(std::move(other.string_v), m); break; case MGP_VALUE_TYPE_LIST: static_assert(std::is_pointer_v, "Expected to move list_v by copying pointers."); @@ -707,7 +708,7 @@ mgp_value::mgp_value(mgp_value &&other, utils::MemoryResource *m) : type(other.t list_v = other.list_v; other.type = MGP_VALUE_TYPE_NULL; } else { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); list_v = allocator.new_object(std::move(*other.list_v)); } break; @@ -717,7 +718,7 @@ mgp_value::mgp_value(mgp_value &&other, utils::MemoryResource *m) : type(other.t map_v = other.map_v; other.type = MGP_VALUE_TYPE_NULL; } else { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); map_v = allocator.new_object(std::move(*other.map_v)); } break; @@ -727,7 +728,7 @@ mgp_value::mgp_value(mgp_value &&other, utils::MemoryResource *m) : type(other.t vertex_v = other.vertex_v; other.type = MGP_VALUE_TYPE_NULL; } else { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); vertex_v = allocator.new_object(std::move(*other.vertex_v)); } break; @@ -737,7 +738,7 @@ mgp_value::mgp_value(mgp_value &&other, utils::MemoryResource *m) : type(other.t edge_v = other.edge_v; other.type = MGP_VALUE_TYPE_NULL; } else { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); edge_v = allocator.new_object(std::move(*other.edge_v)); } break; @@ -747,7 +748,7 @@ mgp_value::mgp_value(mgp_value &&other, utils::MemoryResource *m) : type(other.t path_v = other.path_v; other.type = MGP_VALUE_TYPE_NULL; } else { - utils::Allocator allocator(m); + memgraph::utils::Allocator allocator(m); path_v = allocator.new_object(std::move(*other.path_v)); } break; @@ -1072,7 +1073,7 @@ mgp_error mgp_path_expand(mgp_path *path, mgp_edge *edge) { } // Try appending edge and dst_vertex to path, preserving the original mgp_path // instance if anything fails. - utils::OnScopeExit scope_guard( + memgraph::utils::OnScopeExit scope_guard( [path] { MG_ASSERT(Call(mgp_path_size, path) == path->vertices.size() - 1); }); path->edges.push_back(*edge); @@ -1178,7 +1179,7 @@ mgp_error mgp_date_timestamp(mgp_date *date, int64_t *timestamp) { } mgp_error mgp_date_now(mgp_memory *memory, mgp_date **date) { - return WrapExceptions([memory] { return NewRawMgpObject(memory, utils::CurrentDate()); }, date); + return WrapExceptions([memory] { return NewRawMgpObject(memory, memgraph::utils::CurrentDate()); }, date); } mgp_error mgp_date_add_duration(mgp_date *date, mgp_duration *dur, mgp_memory *memory, mgp_date **result) { @@ -1241,8 +1242,8 @@ mgp_error mgp_local_time_timestamp(mgp_local_time *local_time, int64_t *timestam } mgp_error mgp_local_time_now(mgp_memory *memory, mgp_local_time **local_time) { - return WrapExceptions([memory] { return NewRawMgpObject(memory, utils::CurrentLocalTime()); }, - local_time); + return WrapExceptions( + [memory] { return NewRawMgpObject(memory, memgraph::utils::CurrentLocalTime()); }, local_time); } mgp_error mgp_local_time_add_duration(mgp_local_time *local_time, mgp_duration *dur, mgp_memory *memory, @@ -1335,7 +1336,7 @@ mgp_error mgp_local_date_time_timestamp(mgp_local_date_time *local_date_time, in mgp_error mgp_local_date_time_now(mgp_memory *memory, mgp_local_date_time **local_date_time) { return WrapExceptions( - [memory] { return NewRawMgpObject(memory, utils::CurrentLocalDateTime()); }, + [memory] { return NewRawMgpObject(memory, memgraph::utils::CurrentLocalDateTime()); }, local_date_time); } @@ -1424,8 +1425,9 @@ mgp_error mgp_result_new_record(mgp_result *res, mgp_result_record **result) { [res] { auto *memory = res->rows.get_allocator().GetMemoryResource(); MG_ASSERT(res->signature, "Expected to have a valid signature"); - res->rows.push_back( - mgp_result_record{res->signature, utils::pmr::map(memory)}); + res->rows.push_back(mgp_result_record{ + res->signature, + memgraph::utils::pmr::map(memory)}); return &res->rows.back(); }, result); @@ -1484,10 +1486,10 @@ mgp_error mgp_properties_iterator_next(mgp_properties_iterator *it, mgp_property it->current = std::nullopt; return nullptr; } - utils::OnScopeExit clean_up([it] { it->current = std::nullopt; }); - it->current.emplace( - utils::pmr::string(it->graph->impl->PropertyToName(it->current_it->first), it->GetMemoryResource()), - mgp_value(it->current_it->second, it->GetMemoryResource())); + memgraph::utils::OnScopeExit clean_up([it] { it->current = std::nullopt; }); + it->current.emplace(memgraph::utils::pmr::string(it->graph->impl->PropertyToName(it->current_it->first), + it->GetMemoryResource()), + mgp_value(it->current_it->second, it->GetMemoryResource())); it->property.name = it->current->first.c_str(); it->property.value = &it->current->second; clean_up.Disable(); @@ -1505,10 +1507,10 @@ mgp_error mgp_vertex_underlying_graph_is_mutable(mgp_vertex *v, int *result) { } namespace { -storage::PropertyValue ToPropertyValue(const mgp_value &value); +memgraph::storage::PropertyValue ToPropertyValue(const mgp_value &value); -storage::PropertyValue ToPropertyValue(const mgp_list &list) { - storage::PropertyValue result{std::vector{}}; +memgraph::storage::PropertyValue ToPropertyValue(const mgp_list &list) { + memgraph::storage::PropertyValue result{std::vector{}}; auto &result_list = result.ValueList(); for (const auto &value : list.elems) { result_list.push_back(ToPropertyValue(value)); @@ -1516,8 +1518,8 @@ storage::PropertyValue ToPropertyValue(const mgp_list &list) { return result; } -storage::PropertyValue ToPropertyValue(const mgp_map &map) { - storage::PropertyValue result{std::map{}}; +memgraph::storage::PropertyValue ToPropertyValue(const mgp_map &map) { + memgraph::storage::PropertyValue result{std::map{}}; auto &result_map = result.ValueMap(); for (const auto &[key, value] : map.items) { result_map.insert_or_assign(std::string{key}, ToPropertyValue(value)); @@ -1525,34 +1527,35 @@ storage::PropertyValue ToPropertyValue(const mgp_map &map) { return result; } -storage::PropertyValue ToPropertyValue(const mgp_value &value) { +memgraph::storage::PropertyValue ToPropertyValue(const mgp_value &value) { switch (value.type) { case MGP_VALUE_TYPE_NULL: - return storage::PropertyValue{}; + return memgraph::storage::PropertyValue{}; case MGP_VALUE_TYPE_BOOL: - return storage::PropertyValue{value.bool_v}; + return memgraph::storage::PropertyValue{value.bool_v}; case MGP_VALUE_TYPE_INT: - return storage::PropertyValue{value.int_v}; + return memgraph::storage::PropertyValue{value.int_v}; case MGP_VALUE_TYPE_DOUBLE: - return storage::PropertyValue{value.double_v}; + return memgraph::storage::PropertyValue{value.double_v}; case MGP_VALUE_TYPE_STRING: - return storage::PropertyValue{std::string{value.string_v}}; + return memgraph::storage::PropertyValue{std::string{value.string_v}}; case MGP_VALUE_TYPE_LIST: return ToPropertyValue(*value.list_v); case MGP_VALUE_TYPE_MAP: return ToPropertyValue(*value.map_v); case MGP_VALUE_TYPE_DATE: - return storage::PropertyValue{ - storage::TemporalData{storage::TemporalType::Date, value.date_v->date.MicrosecondsSinceEpoch()}}; + return memgraph::storage::PropertyValue{memgraph::storage::TemporalData{ + memgraph::storage::TemporalType::Date, value.date_v->date.MicrosecondsSinceEpoch()}}; case MGP_VALUE_TYPE_LOCAL_TIME: - return storage::PropertyValue{storage::TemporalData{storage::TemporalType::LocalTime, - value.local_time_v->local_time.MicrosecondsSinceEpoch()}}; + return memgraph::storage::PropertyValue{memgraph::storage::TemporalData{ + memgraph::storage::TemporalType::LocalTime, value.local_time_v->local_time.MicrosecondsSinceEpoch()}}; case MGP_VALUE_TYPE_LOCAL_DATE_TIME: - return storage::PropertyValue{storage::TemporalData{ - storage::TemporalType::LocalDateTime, value.local_date_time_v->local_date_time.MicrosecondsSinceEpoch()}}; + return memgraph::storage::PropertyValue{ + memgraph::storage::TemporalData{memgraph::storage::TemporalType::LocalDateTime, + value.local_date_time_v->local_date_time.MicrosecondsSinceEpoch()}}; case MGP_VALUE_TYPE_DURATION: - return storage::PropertyValue{ - storage::TemporalData{storage::TemporalType::Duration, value.duration_v->duration.microseconds}}; + return memgraph::storage::PropertyValue{memgraph::storage::TemporalData{memgraph::storage::TemporalType::Duration, + value.duration_v->duration.microseconds}}; case MGP_VALUE_TYPE_VERTEX: throw ValueConversionException{"A vertex is not a valid property value! "}; case MGP_VALUE_TYPE_EDGE: @@ -1572,27 +1575,28 @@ mgp_error mgp_vertex_set_property(struct mgp_vertex *v, const char *property_nam const auto result = v->impl.SetProperty(prop_key, ToPropertyValue(*property_value)); if (result.HasError()) { switch (result.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot set the properties of a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when setting a property of a vertex!"); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: LOG_FATAL("Unexpected error when setting a property of a vertex."); - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::SERIALIZATION_ERROR: throw SerializationException{"Cannot serialize setting a property of a vertex."}; } } auto &ctx = v->graph->ctx; - ctx->execution_stats[query::ExecutionStats::Key::UPDATED_PROPERTIES] += 1; + ctx->execution_stats[memgraph::query::ExecutionStats::Key::UPDATED_PROPERTIES] += 1; auto *trigger_ctx_collector = ctx->trigger_context_collector; - if (!trigger_ctx_collector || !trigger_ctx_collector->ShouldRegisterObjectPropertyChange()) { + if (!trigger_ctx_collector || + !trigger_ctx_collector->ShouldRegisterObjectPropertyChange()) { return; } - const auto old_value = query::TypedValue(*result); + const auto old_value = memgraph::query::TypedValue(*result); if (property_value->type == mgp_value_type::MGP_VALUE_TYPE_NULL) { trigger_ctx_collector->RegisterRemovedObjectProperty(v->impl, prop_key, old_value); return; @@ -1612,21 +1616,21 @@ mgp_error mgp_vertex_add_label(struct mgp_vertex *v, mgp_label label) { if (result.HasError()) { switch (result.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot add a label to a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when adding a label to a vertex!"); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: LOG_FATAL("Unexpected error when adding a label to a vertex."); - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::SERIALIZATION_ERROR: throw SerializationException{"Cannot serialize adding a label to a vertex."}; } } auto &ctx = v->graph->ctx; - ctx->execution_stats[query::ExecutionStats::Key::CREATED_LABELS] += 1; + ctx->execution_stats[memgraph::query::ExecutionStats::Key::CREATED_LABELS] += 1; if (ctx->trigger_context_collector) { ctx->trigger_context_collector->RegisterSetVertexLabel(v->impl, label_id); @@ -1644,21 +1648,21 @@ mgp_error mgp_vertex_remove_label(struct mgp_vertex *v, mgp_label label) { if (result.HasError()) { switch (result.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot remove a label from a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when removing a label from a vertex!"); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: LOG_FATAL("Unexpected error when removing a label from a vertex."); - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::SERIALIZATION_ERROR: throw SerializationException{"Cannot serialize removing a label from a vertex."}; } } auto &ctx = v->graph->ctx; - ctx->execution_stats[query::ExecutionStats::Key::DELETED_LABELS] += 1; + ctx->execution_stats[memgraph::query::ExecutionStats::Key::DELETED_LABELS] += 1; if (ctx->trigger_context_collector) { ctx->trigger_context_collector->RegisterRemovedVertexLabel(v->impl, label_id); @@ -1685,13 +1689,13 @@ mgp_error mgp_vertex_labels_count(mgp_vertex *v, size_t *result) { auto maybe_labels = v->impl.Labels(v->graph->view); if (maybe_labels.HasError()) { switch (maybe_labels.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot get the labels of a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when getting vertex labels!"); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: LOG_FATAL("Unexpected error when getting vertex labels."); } } @@ -1707,13 +1711,13 @@ mgp_error mgp_vertex_label_at(mgp_vertex *v, size_t i, mgp_label *result) { auto maybe_labels = v->impl.Labels(v->graph->view); if (maybe_labels.HasError()) { switch (maybe_labels.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot get a label of a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when getting a label of a vertex!"); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: LOG_FATAL("Unexpected error when getting a label of a vertex."); } } @@ -1733,22 +1737,22 @@ mgp_error mgp_vertex_label_at(mgp_vertex *v, size_t i, mgp_label *result) { mgp_error mgp_vertex_has_label_named(mgp_vertex *v, const char *name, int *result) { return WrapExceptions( [v, name] { - storage::LabelId label; + memgraph::storage::LabelId label; label = v->graph->impl->NameToLabel(name); auto maybe_has_label = v->impl.HasLabel(v->graph->view, label); if (maybe_has_label.HasError()) { switch (maybe_has_label.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot check the existence of a label on a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL( "Query modules shouldn't have access to nonexistent objects when checking the existence of a label " "on " "a vertex!"); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: LOG_FATAL("Unexpected error when checking the existence of a label on a vertex."); } } @@ -1768,14 +1772,14 @@ mgp_error mgp_vertex_get_property(mgp_vertex *v, const char *name, mgp_memory *m auto maybe_prop = v->impl.GetProperty(v->graph->view, key); if (maybe_prop.HasError()) { switch (maybe_prop.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot get a property of a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL( "Query modules shouldn't have access to nonexistent objects when getting a property of a vertex."); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: LOG_FATAL("Unexpected error when getting a property of a vertex."); } } @@ -1794,15 +1798,15 @@ mgp_error mgp_vertex_iter_properties(mgp_vertex *v, mgp_memory *memory, mgp_prop auto maybe_props = v->impl.Properties(v->graph->view); if (maybe_props.HasError()) { switch (maybe_props.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot get the properties of a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL( "Query modules shouldn't have access to nonexistent objects when getting the properties of a " "vertex."); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: LOG_FATAL("Unexpected error when getting the properties of a vertex."); } } @@ -1822,15 +1826,15 @@ mgp_error mgp_vertex_iter_in_edges(mgp_vertex *v, mgp_memory *memory, mgp_edges_ auto maybe_edges = v->impl.InEdges(v->graph->view); if (maybe_edges.HasError()) { switch (maybe_edges.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot get the inbound edges of a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL( "Query modules shouldn't have access to nonexistent objects when getting the inbound edges of a " "vertex."); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: LOG_FATAL("Unexpected error when getting the inbound edges of a vertex."); } } @@ -1854,15 +1858,15 @@ mgp_error mgp_vertex_iter_out_edges(mgp_vertex *v, mgp_memory *memory, mgp_edges auto maybe_edges = v->impl.OutEdges(v->graph->view); if (maybe_edges.HasError()) { switch (maybe_edges.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot get the outbound edges of a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL( "Query modules shouldn't have access to nonexistent objects when getting the outbound edges of a " "vertex."); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: LOG_FATAL("Unexpected error when getting the outbound edges of a vertex."); } } @@ -1969,14 +1973,14 @@ mgp_error mgp_edge_get_property(mgp_edge *e, const char *name, mgp_memory *memor auto maybe_prop = e->impl.GetProperty(view, key); if (maybe_prop.HasError()) { switch (maybe_prop.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot get a property of a deleted edge!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL( "Query modules shouldn't have access to nonexistent objects when getting a property of an edge."); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: LOG_FATAL("Unexpected error when getting a property of an edge."); } } @@ -1995,28 +1999,29 @@ mgp_error mgp_edge_set_property(struct mgp_edge *e, const char *property_name, m if (result.HasError()) { switch (result.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot set the properties of a deleted edge!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when setting a property of an edge!"); - case storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::PROPERTIES_DISABLED: throw std::logic_error{"Cannot set the properties of edges, because properties on edges are disabled!"}; - case storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::VERTEX_HAS_EDGES: LOG_FATAL("Unexpected error when setting a property of an edge."); - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::SERIALIZATION_ERROR: throw SerializationException{"Cannot serialize setting a property of an edge."}; } } auto &ctx = e->from.graph->ctx; - ctx->execution_stats[query::ExecutionStats::Key::UPDATED_PROPERTIES] += 1; + ctx->execution_stats[memgraph::query::ExecutionStats::Key::UPDATED_PROPERTIES] += 1; auto *trigger_ctx_collector = e->from.graph->ctx->trigger_context_collector; - if (!trigger_ctx_collector || !trigger_ctx_collector->ShouldRegisterObjectPropertyChange()) { + if (!trigger_ctx_collector || + !trigger_ctx_collector->ShouldRegisterObjectPropertyChange()) { return; } - const auto old_value = query::TypedValue(*result); + const auto old_value = memgraph::query::TypedValue(*result); if (property_value->type == mgp_value_type::MGP_VALUE_TYPE_NULL) { e->from.graph->ctx->trigger_context_collector->RegisterRemovedObjectProperty(e->impl, prop_key, old_value); return; @@ -2037,14 +2042,14 @@ mgp_error mgp_edge_iter_properties(mgp_edge *e, mgp_memory *memory, mgp_properti auto maybe_props = e->impl.Properties(view); if (maybe_props.HasError()) { switch (maybe_props.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot get the properties of a deleted edge!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL( "Query modules shouldn't have access to nonexistent objects when getting the properties of an edge."); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::SERIALIZATION_ERROR: LOG_FATAL("Unexpected error when getting the properties of an edge."); } } @@ -2056,7 +2061,7 @@ mgp_error mgp_edge_iter_properties(mgp_edge *e, mgp_memory *memory, mgp_properti mgp_error mgp_graph_get_vertex_by_id(mgp_graph *graph, mgp_vertex_id id, mgp_memory *memory, mgp_vertex **result) { return WrapExceptions( [graph, id, memory]() -> mgp_vertex * { - auto maybe_vertex = graph->impl->FindVertex(storage::Gid::FromInt(id.as_int), graph->view); + auto maybe_vertex = graph->impl->FindVertex(memgraph::storage::Gid::FromInt(id.as_int), graph->view); if (maybe_vertex) { return NewRawMgpObject(memory, *maybe_vertex, graph); } @@ -2079,7 +2084,7 @@ mgp_error mgp_graph_create_vertex(struct mgp_graph *graph, mgp_memory *memory, m auto vertex = graph->impl->InsertVertex(); auto &ctx = graph->ctx; - ctx->execution_stats[query::ExecutionStats::Key::CREATED_NODES] += 1; + ctx->execution_stats[memgraph::query::ExecutionStats::Key::CREATED_NODES] += 1; if (ctx->trigger_context_collector) { ctx->trigger_context_collector->RegisterCreatedObject(vertex); @@ -2098,14 +2103,14 @@ mgp_error mgp_graph_delete_vertex(struct mgp_graph *graph, mgp_vertex *vertex) { if (result.HasError()) { switch (result.GetError()) { - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when removing a vertex!"); - case storage::Error::DELETED_OBJECT: - case storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::PROPERTIES_DISABLED: LOG_FATAL("Unexpected error when removing a vertex."); - case storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::VERTEX_HAS_EDGES: throw std::logic_error{"Cannot remove a vertex that has edges!"}; - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::SERIALIZATION_ERROR: throw SerializationException{"Cannot serialize removing a vertex."}; } } @@ -2116,7 +2121,7 @@ mgp_error mgp_graph_delete_vertex(struct mgp_graph *graph, mgp_vertex *vertex) { auto &ctx = graph->ctx; - ctx->execution_stats[query::ExecutionStats::Key::DELETED_NODES] += 1; + ctx->execution_stats[memgraph::query::ExecutionStats::Key::DELETED_NODES] += 1; if (ctx->trigger_context_collector) { ctx->trigger_context_collector->RegisterDeletedObject(**result); @@ -2133,13 +2138,13 @@ mgp_error mgp_graph_detach_delete_vertex(struct mgp_graph *graph, mgp_vertex *ve if (result.HasError()) { switch (result.GetError()) { - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when removing a vertex!"); - case storage::Error::DELETED_OBJECT: - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: LOG_FATAL("Unexpected error when removing a vertex."); - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::SERIALIZATION_ERROR: throw SerializationException{"Cannot serialize removing a vertex."}; } } @@ -2150,8 +2155,9 @@ mgp_error mgp_graph_detach_delete_vertex(struct mgp_graph *graph, mgp_vertex *ve auto &ctx = graph->ctx; - ctx->execution_stats[query::ExecutionStats::Key::DELETED_NODES] += 1; - ctx->execution_stats[query::ExecutionStats::Key::DELETED_EDGES] += static_cast((*result)->second.size()); + ctx->execution_stats[memgraph::query::ExecutionStats::Key::DELETED_NODES] += 1; + ctx->execution_stats[memgraph::query::ExecutionStats::Key::DELETED_EDGES] += + static_cast((*result)->second.size()); auto *trigger_ctx_collector = ctx->trigger_context_collector; if (!trigger_ctx_collector) { @@ -2159,7 +2165,7 @@ mgp_error mgp_graph_detach_delete_vertex(struct mgp_graph *graph, mgp_vertex *ve } trigger_ctx_collector->RegisterDeletedObject((*result)->first); - if (!trigger_ctx_collector->ShouldRegisterDeletedObject()) { + if (!trigger_ctx_collector->ShouldRegisterDeletedObject()) { return; } for (const auto &edge : (*result)->second) { @@ -2179,20 +2185,20 @@ mgp_error mgp_graph_create_edge(mgp_graph *graph, mgp_vertex *from, mgp_vertex * auto edge = graph->impl->InsertEdge(&from->impl, &to->impl, from->graph->impl->NameToEdgeType(type.name)); if (edge.HasError()) { switch (edge.GetError()) { - case storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::DELETED_OBJECT: throw DeletedObjectException{"Cannot add an edge to a deleted vertex!"}; - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when creating an edge!"); - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: LOG_FATAL("Unexpected error when creating an edge."); - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::SERIALIZATION_ERROR: throw SerializationException{"Cannot serialize creating an edge."}; } } auto &ctx = graph->ctx; - ctx->execution_stats[query::ExecutionStats::Key::CREATED_EDGES] += 1; + ctx->execution_stats[memgraph::query::ExecutionStats::Key::CREATED_EDGES] += 1; if (ctx->trigger_context_collector) { ctx->trigger_context_collector->RegisterCreatedObject(*edge); @@ -2211,13 +2217,13 @@ mgp_error mgp_graph_delete_edge(struct mgp_graph *graph, mgp_edge *edge) { if (result.HasError()) { switch (result.GetError()) { - case storage::Error::NONEXISTENT_OBJECT: + case memgraph::storage::Error::NONEXISTENT_OBJECT: LOG_FATAL("Query modules shouldn't have access to nonexistent objects when removing an edge!"); - case storage::Error::DELETED_OBJECT: - case storage::Error::PROPERTIES_DISABLED: - case storage::Error::VERTEX_HAS_EDGES: + case memgraph::storage::Error::DELETED_OBJECT: + case memgraph::storage::Error::PROPERTIES_DISABLED: + case memgraph::storage::Error::VERTEX_HAS_EDGES: LOG_FATAL("Unexpected error when removing an edge."); - case storage::Error::SERIALIZATION_ERROR: + case memgraph::storage::Error::SERIALIZATION_ERROR: throw SerializationException{"Cannot serialize removing an edge."}; } } @@ -2227,7 +2233,7 @@ mgp_error mgp_graph_delete_edge(struct mgp_graph *graph, mgp_edge *edge) { } auto &ctx = graph->ctx; - ctx->execution_stats[query::ExecutionStats::Key::DELETED_EDGES] += 1; + ctx->execution_stats[memgraph::query::ExecutionStats::Key::DELETED_EDGES] += 1; if (ctx->trigger_context_collector) { ctx->trigger_context_collector->RegisterDeletedObject(**result); } @@ -2268,7 +2274,7 @@ mgp_error mgp_vertices_iterator_next(mgp_vertices_iterator *it, mgp_vertex **res it->current_v = std::nullopt; return nullptr; } - utils::OnScopeExit clean_up([it] { it->current_v = std::nullopt; }); + memgraph::utils::OnScopeExit clean_up([it] { it->current_v = std::nullopt; }); it->current_v.emplace(*it->current_it, it->graph, it->GetMemoryResource()); clean_up.Disable(); return &*it->current_v; @@ -2316,9 +2322,9 @@ mgp_error mgp_type_list(mgp_type *type, mgp_type **result) { return WrapExceptions( [type] { // Maps `type` to corresponding instance of ListType. - static utils::pmr::map gListTypes(utils::NewDeleteResource()); - static utils::SpinLock lock; - std::lock_guard guard(lock); + static memgraph::utils::pmr::map gListTypes(memgraph::utils::NewDeleteResource()); + static memgraph::utils::SpinLock lock; + std::lock_guard guard(lock); auto found_it = gListTypes.find(type); if (found_it != gListTypes.end()) { return &found_it->second; @@ -2338,9 +2344,9 @@ mgp_error mgp_type_nullable(mgp_type *type, mgp_type **result) { return WrapExceptions( [type] { // Maps `type` to corresponding instance of NullableType. - static utils::pmr::map gNullableTypes(utils::NewDeleteResource()); - static utils::SpinLock lock; - std::lock_guard guard(lock); + static memgraph::utils::pmr::map gNullableTypes(memgraph::utils::NewDeleteResource()); + static memgraph::utils::SpinLock lock; + std::lock_guard guard(lock); auto found_it = gNullableTypes.find(type); if (found_it != gNullableTypes.end()) return &found_it->second; @@ -2421,7 +2427,7 @@ mgp_error mgp_proc_add_opt_arg(mgp_proc *proc, const char *name, mgp_type *type, proc->name, type->impl->GetPresentableName())}; } auto *memory = proc->opt_args.get_allocator().GetMemoryResource(); - proc->opt_args.emplace_back(utils::pmr::string(name, memory), type->impl.get(), + proc->opt_args.emplace_back(memgraph::utils::pmr::string(name, memory), type->impl.get(), ToTypedValue(*default_value, memory)); }); } @@ -2429,7 +2435,7 @@ mgp_error mgp_proc_add_opt_arg(mgp_proc *proc, const char *name, mgp_type *type, namespace { template -concept ModuleProperties = utils::SameAsAnyOf; +concept ModuleProperties = memgraph::utils::SameAsAnyOf; template mgp_error AddResultToProp(T *prop, const char *name, mgp_type *type, bool is_deprecated) noexcept { @@ -2441,7 +2447,7 @@ mgp_error AddResultToProp(T *prop, const char *name, mgp_type *type, bool is_dep throw std::logic_error{fmt::format("Result already exists with name '{}' for procedure '{}'", name, prop->name)}; }; auto *memory = prop->results.get_allocator().GetMemoryResource(); - prop->results.emplace(utils::pmr::string(name, memory), std::make_pair(type->impl.get(), is_deprecated)); + prop->results.emplace(memgraph::utils::pmr::string(name, memory), std::make_pair(type->impl.get(), is_deprecated)); }); } @@ -2466,11 +2472,11 @@ mgp_error mgp_proc_add_deprecated_result(mgp_proc *proc, const char *name, mgp_t int mgp_must_abort(mgp_graph *graph) { MG_ASSERT(graph->ctx); - static_assert(noexcept(query::MustAbort(*graph->ctx))); - return query::MustAbort(*graph->ctx) ? 1 : 0; + static_assert(noexcept(memgraph::query::MustAbort(*graph->ctx))); + return memgraph::query::MustAbort(*graph->ctx) ? 1 : 0; } -namespace query::procedure { +namespace memgraph::query::procedure { namespace { @@ -2489,15 +2495,15 @@ std::ostream &PrintValue(const TypedValue &value, std::ostream *stream) { return (*stream) << value.ValueDouble(); case TypedValue::Type::String: // String value should be escaped, this allocates a new string. - return (*stream) << utils::Escape(value.ValueString()); + return (*stream) << memgraph::utils::Escape(value.ValueString()); case TypedValue::Type::List: (*stream) << "["; - utils::PrintIterable(*stream, value.ValueList(), ", ", - [](auto &stream, const auto &elem) { PrintValue(elem, &stream); }); + memgraph::utils::PrintIterable(*stream, value.ValueList(), ", ", + [](auto &stream, const auto &elem) { PrintValue(elem, &stream); }); return (*stream) << "]"; case TypedValue::Type::Map: (*stream) << "{"; - utils::PrintIterable(*stream, value.ValueMap(), ", ", [](auto &stream, const auto &item) { + memgraph::utils::PrintIterable(*stream, value.ValueMap(), ", ", [](auto &stream, const auto &item) { // Map keys are not escaped strings. stream << item.first << ": "; PrintValue(item.second, &stream); @@ -2522,16 +2528,16 @@ std::ostream &PrintValue(const TypedValue &value, std::ostream *stream) { void PrintProcSignature(const mgp_proc &proc, std::ostream *stream) { (*stream) << proc.name << "("; - utils::PrintIterable(*stream, proc.args, ", ", [](auto &stream, const auto &arg) { + memgraph::utils::PrintIterable(*stream, proc.args, ", ", [](auto &stream, const auto &arg) { stream << arg.first << " :: " << arg.second->GetPresentableName(); }); if (!proc.args.empty() && !proc.opt_args.empty()) (*stream) << ", "; - utils::PrintIterable(*stream, proc.opt_args, ", ", [](auto &stream, const auto &arg) { + memgraph::utils::PrintIterable(*stream, proc.opt_args, ", ", [](auto &stream, const auto &arg) { stream << std::get<0>(arg) << " = "; PrintValue(std::get<2>(arg), &stream) << " :: " << std::get<1>(arg)->GetPresentableName(); }); (*stream) << ") :: ("; - utils::PrintIterable(*stream, proc.results, ", ", [](auto &stream, const auto &name_result) { + memgraph::utils::PrintIterable(*stream, proc.results, ", ", [](auto &stream, const auto &name_result) { const auto &[type, is_deprecated] = name_result.second; if (is_deprecated) stream << "DEPRECATED "; stream << name_result.first << " :: " << type->GetPresentableName(); @@ -2545,10 +2551,10 @@ bool IsValidIdentifierName(const char *name) { return std::regex_match(name, regex); } -} // namespace query::procedure +} // namespace memgraph::query::procedure namespace { -using StreamSourceType = query::stream::StreamSourceType; +using StreamSourceType = memgraph::query::stream::StreamSourceType; class InvalidMessageFunction : public std::invalid_argument { public: @@ -2579,7 +2585,7 @@ mgp_source_type StreamSourceTypeToMgpSourceType(const StreamSourceType type) { mgp_error mgp_message_source_type(mgp_message *message, mgp_source_type *result) { return WrapExceptions( [message] { - return std::visit(utils::Overloaded{[](const auto &message) { + return std::visit(memgraph::utils::Overloaded{[](const auto &message) { return StreamSourceTypeToMgpSourceType(MessageToStreamSourceType(message)); }}, message->msg); @@ -2590,12 +2596,13 @@ mgp_error mgp_message_source_type(mgp_message *message, mgp_source_type *result) mgp_error mgp_message_payload(mgp_message *message, const char **result) { return WrapExceptions( [message] { - return std::visit(utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Payload().data(); }, - [](const mgp_message::PulsarMessage &msg) { return msg.Payload().data(); }, - [](const auto &msg) -> const char * { - throw InvalidMessageFunction(MessageToStreamSourceType(msg), "payload"); - }}, - message->msg); + return std::visit( + memgraph::utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Payload().data(); }, + [](const mgp_message::PulsarMessage &msg) { return msg.Payload().data(); }, + [](const auto &msg) -> const char * { + throw InvalidMessageFunction(MessageToStreamSourceType(msg), "payload"); + }}, + message->msg); }, result); } @@ -2603,13 +2610,13 @@ mgp_error mgp_message_payload(mgp_message *message, const char **result) { mgp_error mgp_message_payload_size(mgp_message *message, size_t *result) { return WrapExceptions( [message] { - return std::visit(utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Payload().size(); }, - [](const mgp_message::PulsarMessage &msg) { return msg.Payload().size(); }, - [](const auto &msg) -> size_t { - throw InvalidMessageFunction(MessageToStreamSourceType(msg), - "payload_size"); - }}, - message->msg); + return std::visit( + memgraph::utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Payload().size(); }, + [](const mgp_message::PulsarMessage &msg) { return msg.Payload().size(); }, + [](const auto &msg) -> size_t { + throw InvalidMessageFunction(MessageToStreamSourceType(msg), "payload_size"); + }}, + message->msg); }, result); } @@ -2618,11 +2625,11 @@ mgp_error mgp_message_topic_name(mgp_message *message, const char **result) { return WrapExceptions( [message] { return std::visit( - utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->TopicName().data(); }, - [](const mgp_message::PulsarMessage &msg) { return msg.TopicName().data(); }, - [](const auto &msg) -> const char * { - throw InvalidMessageFunction(MessageToStreamSourceType(msg), "topic_name"); - }}, + memgraph::utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->TopicName().data(); }, + [](const mgp_message::PulsarMessage &msg) { return msg.TopicName().data(); }, + [](const auto &msg) -> const char * { + throw InvalidMessageFunction(MessageToStreamSourceType(msg), "topic_name"); + }}, message->msg); }, result); @@ -2631,11 +2638,12 @@ mgp_error mgp_message_topic_name(mgp_message *message, const char **result) { mgp_error mgp_message_key(mgp_message *message, const char **result) { return WrapExceptions( [message] { - return std::visit(utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Key().data(); }, - [](const auto &msg) -> const char * { - throw InvalidMessageFunction(MessageToStreamSourceType(msg), "key"); - }}, - message->msg); + return std::visit( + memgraph::utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Key().data(); }, + [](const auto &msg) -> const char * { + throw InvalidMessageFunction(MessageToStreamSourceType(msg), "key"); + }}, + message->msg); }, result); } @@ -2643,11 +2651,12 @@ mgp_error mgp_message_key(mgp_message *message, const char **result) { mgp_error mgp_message_key_size(mgp_message *message, size_t *result) { return WrapExceptions( [message] { - return std::visit(utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Key().size(); }, - [](const auto &msg) -> size_t { - throw InvalidMessageFunction(MessageToStreamSourceType(msg), "key_size"); - }}, - message->msg); + return std::visit( + memgraph::utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Key().size(); }, + [](const auto &msg) -> size_t { + throw InvalidMessageFunction(MessageToStreamSourceType(msg), "key_size"); + }}, + message->msg); }, result); } @@ -2655,11 +2664,12 @@ mgp_error mgp_message_key_size(mgp_message *message, size_t *result) { mgp_error mgp_message_timestamp(mgp_message *message, int64_t *result) { return WrapExceptions( [message] { - return std::visit(utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Timestamp(); }, - [](const auto &msg) -> int64_t { - throw InvalidMessageFunction(MessageToStreamSourceType(msg), "timestamp"); - }}, - message->msg); + return std::visit( + memgraph::utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Timestamp(); }, + [](const auto &msg) -> int64_t { + throw InvalidMessageFunction(MessageToStreamSourceType(msg), "timestamp"); + }}, + message->msg); }, result); } @@ -2667,11 +2677,12 @@ mgp_error mgp_message_timestamp(mgp_message *message, int64_t *result) { mgp_error mgp_message_offset(struct mgp_message *message, int64_t *result) { return WrapExceptions( [message] { - return std::visit(utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Offset(); }, - [](const auto &msg) -> int64_t { - throw InvalidMessageFunction(MessageToStreamSourceType(msg), "offset"); - }}, - message->msg); + return std::visit( + memgraph::utils::Overloaded{[](const mgp_message::KafkaMessage &msg) { return msg->Offset(); }, + [](const auto &msg) -> int64_t { + throw InvalidMessageFunction(MessageToStreamSourceType(msg), "offset"); + }}, + message->msg); }, result); } diff --git a/src/query/procedure/mg_procedure_impl.hpp b/src/query/procedure/mg_procedure_impl.hpp index 697708537..d28ca699d 100644 --- a/src/query/procedure/mg_procedure_impl.hpp +++ b/src/query/procedure/mg_procedure_impl.hpp @@ -34,65 +34,65 @@ #include "utils/temporal.hpp" /// Wraps memory resource used in custom procedures. /// -/// This should have been `using mgp_memory = utils::MemoryResource`, but that's +/// This should have been `using mgp_memory = memgraph::utils::MemoryResource`, but that's /// not valid C++ because we have a forward declare `struct mgp_memory` in /// mg_procedure.h /// TODO: Make this extendable in C API, so that custom procedure writer can add /// their own memory management wrappers. struct mgp_memory { - utils::MemoryResource *impl; + memgraph::utils::MemoryResource *impl; }; /// Immutable container of various values that appear in openCypher. struct mgp_value { /// Allocator type so that STL containers are aware that we need one. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; // Construct MGP_VALUE_TYPE_NULL. - explicit mgp_value(utils::MemoryResource *) noexcept; + explicit mgp_value(memgraph::utils::MemoryResource *) noexcept; - mgp_value(bool, utils::MemoryResource *) noexcept; - mgp_value(int64_t, utils::MemoryResource *) noexcept; - mgp_value(double, utils::MemoryResource *) noexcept; + mgp_value(bool, memgraph::utils::MemoryResource *) noexcept; + mgp_value(int64_t, memgraph::utils::MemoryResource *) noexcept; + mgp_value(double, memgraph::utils::MemoryResource *) noexcept; /// @throw std::bad_alloc - mgp_value(const char *, utils::MemoryResource *); + mgp_value(const char *, memgraph::utils::MemoryResource *); /// Take ownership of the mgp_list, MemoryResource must match. - mgp_value(mgp_list *, utils::MemoryResource *) noexcept; + mgp_value(mgp_list *, memgraph::utils::MemoryResource *) noexcept; /// Take ownership of the mgp_map, MemoryResource must match. - mgp_value(mgp_map *, utils::MemoryResource *) noexcept; + mgp_value(mgp_map *, memgraph::utils::MemoryResource *) noexcept; /// Take ownership of the mgp_vertex, MemoryResource must match. - mgp_value(mgp_vertex *, utils::MemoryResource *) noexcept; + mgp_value(mgp_vertex *, memgraph::utils::MemoryResource *) noexcept; /// Take ownership of the mgp_edge, MemoryResource must match. - mgp_value(mgp_edge *, utils::MemoryResource *) noexcept; + mgp_value(mgp_edge *, memgraph::utils::MemoryResource *) noexcept; /// Take ownership of the mgp_path, MemoryResource must match. - mgp_value(mgp_path *, utils::MemoryResource *) noexcept; + mgp_value(mgp_path *, memgraph::utils::MemoryResource *) noexcept; - mgp_value(mgp_date *, utils::MemoryResource *) noexcept; - mgp_value(mgp_local_time *, utils::MemoryResource *) noexcept; - mgp_value(mgp_local_date_time *, utils::MemoryResource *) noexcept; - mgp_value(mgp_duration *, utils::MemoryResource *) noexcept; + mgp_value(mgp_date *, memgraph::utils::MemoryResource *) noexcept; + mgp_value(mgp_local_time *, memgraph::utils::MemoryResource *) noexcept; + mgp_value(mgp_local_date_time *, memgraph::utils::MemoryResource *) noexcept; + mgp_value(mgp_duration *, memgraph::utils::MemoryResource *) noexcept; - /// Construct by copying query::TypedValue using utils::MemoryResource. + /// Construct by copying memgraph::query::TypedValue using memgraph::utils::MemoryResource. /// mgp_graph is needed to construct mgp_vertex and mgp_edge. /// @throw std::bad_alloc - mgp_value(const query::TypedValue &, mgp_graph *, utils::MemoryResource *); + mgp_value(const memgraph::query::TypedValue &, mgp_graph *, memgraph::utils::MemoryResource *); - /// Construct by copying storage::PropertyValue using utils::MemoryResource. + /// Construct by copying memgraph::storage::PropertyValue using memgraph::utils::MemoryResource. /// @throw std::bad_alloc - mgp_value(const storage::PropertyValue &, utils::MemoryResource *); + mgp_value(const memgraph::storage::PropertyValue &, memgraph::utils::MemoryResource *); - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_value(const mgp_value &) = delete; - /// Copy construct using given utils::MemoryResource. + /// Copy construct using given memgraph::utils::MemoryResource. /// @throw std::bad_alloc - mgp_value(const mgp_value &, utils::MemoryResource *); + mgp_value(const mgp_value &, memgraph::utils::MemoryResource *); - /// Move construct using given utils::MemoryResource. + /// Move construct using given memgraph::utils::MemoryResource. /// @throw std::bad_alloc if MemoryResource is different, so we cannot move. - mgp_value(mgp_value &&, utils::MemoryResource *); + mgp_value(mgp_value &&, memgraph::utils::MemoryResource *); - /// Move construct, utils::MemoryResource is inherited. + /// Move construct, memgraph::utils::MemoryResource is inherited. mgp_value(mgp_value &&other) noexcept : mgp_value(other, other.memory) {} /// Copy-assignment is not allowed to preserve immutability. @@ -103,16 +103,16 @@ struct mgp_value { ~mgp_value() noexcept; - utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } mgp_value_type type; - utils::MemoryResource *memory; + memgraph::utils::MemoryResource *memory; union { bool bool_v; int64_t int_v; double double_v; - utils::pmr::string string_v; + memgraph::utils::pmr::string string_v; // We use pointers so that taking ownership via C API is easier. Besides, // mgp_map cannot use incomplete mgp_value type, because that would be // undefined behaviour. @@ -128,7 +128,7 @@ struct mgp_value { }; }; -inline utils::DateParameters MapDateParameters(const mgp_date_parameters *parameters) { +inline memgraph::utils::DateParameters MapDateParameters(const mgp_date_parameters *parameters) { return {.year = parameters->year, .month = parameters->month, .day = parameters->day}; } @@ -136,29 +136,32 @@ struct mgp_date { /// Allocator type so that STL containers are aware that we need one. /// We don't actually need this, but it simplifies the C API, because we store /// the allocator which was used to allocate `this`. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; - // Hopefully utils::Date copy constructor remains noexcept, so that we can + // Hopefully memgraph::utils::Date copy constructor remains noexcept, so that we can // have everything noexcept here. - static_assert(std::is_nothrow_copy_constructible_v); + static_assert(std::is_nothrow_copy_constructible_v); - mgp_date(const utils::Date &date, utils::MemoryResource *memory) noexcept : memory(memory), date(date) {} + mgp_date(const memgraph::utils::Date &date, memgraph::utils::MemoryResource *memory) noexcept + : memory(memory), date(date) {} - mgp_date(const std::string_view string, utils::MemoryResource *memory) noexcept - : memory(memory), date(utils::ParseDateParameters(string).first) {} + mgp_date(const std::string_view string, memgraph::utils::MemoryResource *memory) noexcept + : memory(memory), date(memgraph::utils::ParseDateParameters(string).first) {} - mgp_date(const mgp_date_parameters *parameters, utils::MemoryResource *memory) noexcept + mgp_date(const mgp_date_parameters *parameters, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), date(MapDateParameters(parameters)) {} - mgp_date(const int64_t microseconds, utils::MemoryResource *memory) noexcept : memory(memory), date(microseconds) {} + mgp_date(const int64_t microseconds, memgraph::utils::MemoryResource *memory) noexcept + : memory(memory), date(microseconds) {} - mgp_date(const mgp_date &other, utils::MemoryResource *memory) noexcept : memory(memory), date(other.date) {} + mgp_date(const mgp_date &other, memgraph::utils::MemoryResource *memory) noexcept + : memory(memory), date(other.date) {} - mgp_date(mgp_date &&other, utils::MemoryResource *memory) noexcept : memory(memory), date(other.date) {} + mgp_date(mgp_date &&other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), date(other.date) {} mgp_date(mgp_date &&other) noexcept : memory(other.memory), date(other.date) {} - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_date(const mgp_date &) = delete; mgp_date &operator=(const mgp_date &) = delete; @@ -166,13 +169,13 @@ struct mgp_date { ~mgp_date() = default; - utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } - utils::MemoryResource *memory; - utils::Date date; + memgraph::utils::MemoryResource *memory; + memgraph::utils::Date date; }; -inline utils::LocalTimeParameters MapLocalTimeParameters(const mgp_local_time_parameters *parameters) { +inline memgraph::utils::LocalTimeParameters MapLocalTimeParameters(const mgp_local_time_parameters *parameters) { return {.hour = parameters->hour, .minute = parameters->minute, .second = parameters->second, @@ -184,33 +187,33 @@ struct mgp_local_time { /// Allocator type so that STL containers are aware that we need one. /// We don't actually need this, but it simplifies the C API, because we store /// the allocator which was used to allocate `this`. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; - // Hopefully utils::LocalTime copy constructor remains noexcept, so that we can + // Hopefully memgraph::utils::LocalTime copy constructor remains noexcept, so that we can // have everything noexcept here. - static_assert(std::is_nothrow_copy_constructible_v); + static_assert(std::is_nothrow_copy_constructible_v); - mgp_local_time(const std::string_view string, utils::MemoryResource *memory) noexcept - : memory(memory), local_time(utils::ParseLocalTimeParameters(string).first) {} + mgp_local_time(const std::string_view string, memgraph::utils::MemoryResource *memory) noexcept + : memory(memory), local_time(memgraph::utils::ParseLocalTimeParameters(string).first) {} - mgp_local_time(const mgp_local_time_parameters *parameters, utils::MemoryResource *memory) noexcept + mgp_local_time(const mgp_local_time_parameters *parameters, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_time(MapLocalTimeParameters(parameters)) {} - mgp_local_time(const utils::LocalTime &local_time, utils::MemoryResource *memory) noexcept + mgp_local_time(const memgraph::utils::LocalTime &local_time, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_time(local_time) {} - mgp_local_time(const int64_t microseconds, utils::MemoryResource *memory) noexcept + mgp_local_time(const int64_t microseconds, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_time(microseconds) {} - mgp_local_time(const mgp_local_time &other, utils::MemoryResource *memory) noexcept + mgp_local_time(const mgp_local_time &other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_time(other.local_time) {} - mgp_local_time(mgp_local_time &&other, utils::MemoryResource *memory) noexcept + mgp_local_time(mgp_local_time &&other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_time(other.local_time) {} mgp_local_time(mgp_local_time &&other) noexcept : memory(other.memory), local_time(other.local_time) {} - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_local_time(const mgp_local_time &) = delete; mgp_local_time &operator=(const mgp_local_time &) = delete; @@ -218,51 +221,53 @@ struct mgp_local_time { ~mgp_local_time() = default; - utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } - utils::MemoryResource *memory; - utils::LocalTime local_time; + memgraph::utils::MemoryResource *memory; + memgraph::utils::LocalTime local_time; }; -inline utils::LocalDateTime CreateLocalDateTimeFromString(const std::string_view string) { - const auto &[date_parameters, local_time_parameters] = utils::ParseLocalDateTimeParameters(string); - return utils::LocalDateTime{date_parameters, local_time_parameters}; +inline memgraph::utils::LocalDateTime CreateLocalDateTimeFromString(const std::string_view string) { + const auto &[date_parameters, local_time_parameters] = memgraph::utils::ParseLocalDateTimeParameters(string); + return memgraph::utils::LocalDateTime{date_parameters, local_time_parameters}; } struct mgp_local_date_time { /// Allocator type so that STL containers are aware that we need one. /// We don't actually need this, but it simplifies the C API, because we store /// the allocator which was used to allocate `this`. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; - // Hopefully utils::LocalDateTime copy constructor remains noexcept, so that we can + // Hopefully memgraph::utils::LocalDateTime copy constructor remains noexcept, so that we can // have everything noexcept here. - static_assert(std::is_nothrow_copy_constructible_v); + static_assert(std::is_nothrow_copy_constructible_v); - mgp_local_date_time(const utils::LocalDateTime &local_date_time, utils::MemoryResource *memory) noexcept + mgp_local_date_time(const memgraph::utils::LocalDateTime &local_date_time, + memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_date_time(local_date_time) {} - mgp_local_date_time(const std::string_view string, utils::MemoryResource *memory) noexcept + mgp_local_date_time(const std::string_view string, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_date_time(CreateLocalDateTimeFromString(string)) {} - mgp_local_date_time(const mgp_local_date_time_parameters *parameters, utils::MemoryResource *memory) noexcept + mgp_local_date_time(const mgp_local_date_time_parameters *parameters, + memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_date_time(MapDateParameters(parameters->date_parameters), MapLocalTimeParameters(parameters->local_time_parameters)) {} - mgp_local_date_time(const int64_t microseconds, utils::MemoryResource *memory) noexcept + mgp_local_date_time(const int64_t microseconds, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_date_time(microseconds) {} - mgp_local_date_time(const mgp_local_date_time &other, utils::MemoryResource *memory) noexcept + mgp_local_date_time(const mgp_local_date_time &other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_date_time(other.local_date_time) {} - mgp_local_date_time(mgp_local_date_time &&other, utils::MemoryResource *memory) noexcept + mgp_local_date_time(mgp_local_date_time &&other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), local_date_time(other.local_date_time) {} mgp_local_date_time(mgp_local_date_time &&other) noexcept : memory(other.memory), local_date_time(other.local_date_time) {} - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_local_date_time(const mgp_local_date_time &) = delete; mgp_local_date_time &operator=(const mgp_local_date_time &) = delete; @@ -270,13 +275,13 @@ struct mgp_local_date_time { ~mgp_local_date_time() = default; - utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } - utils::MemoryResource *memory; - utils::LocalDateTime local_date_time; + memgraph::utils::MemoryResource *memory; + memgraph::utils::LocalDateTime local_date_time; }; -inline utils::DurationParameters MapDurationParameters(const mgp_duration_parameters *parameters) { +inline memgraph::utils::DurationParameters MapDurationParameters(const mgp_duration_parameters *parameters) { return {.day = parameters->day, .hour = parameters->hour, .minute = parameters->minute, @@ -289,33 +294,33 @@ struct mgp_duration { /// Allocator type so that STL containers are aware that we need one. /// We don't actually need this, but it simplifies the C API, because we store /// the allocator which was used to allocate `this`. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; - // Hopefully utils::Duration copy constructor remains noexcept, so that we can + // Hopefully memgraph::utils::Duration copy constructor remains noexcept, so that we can // have everything noexcept here. - static_assert(std::is_nothrow_copy_constructible_v); + static_assert(std::is_nothrow_copy_constructible_v); - mgp_duration(const std::string_view string, utils::MemoryResource *memory) noexcept - : memory(memory), duration(utils::ParseDurationParameters(string)) {} + mgp_duration(const std::string_view string, memgraph::utils::MemoryResource *memory) noexcept + : memory(memory), duration(memgraph::utils::ParseDurationParameters(string)) {} - mgp_duration(const mgp_duration_parameters *parameters, utils::MemoryResource *memory) noexcept + mgp_duration(const mgp_duration_parameters *parameters, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), duration(MapDurationParameters(parameters)) {} - mgp_duration(const utils::Duration &duration, utils::MemoryResource *memory) noexcept + mgp_duration(const memgraph::utils::Duration &duration, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), duration(duration) {} - mgp_duration(const int64_t microseconds, utils::MemoryResource *memory) noexcept + mgp_duration(const int64_t microseconds, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), duration(microseconds) {} - mgp_duration(const mgp_duration &other, utils::MemoryResource *memory) noexcept + mgp_duration(const mgp_duration &other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), duration(other.duration) {} - mgp_duration(mgp_duration &&other, utils::MemoryResource *memory) noexcept + mgp_duration(mgp_duration &&other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), duration(other.duration) {} mgp_duration(mgp_duration &&other) noexcept : memory(other.memory), duration(other.duration) {} - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_duration(const mgp_duration &) = delete; mgp_duration &operator=(const mgp_duration &) = delete; @@ -323,27 +328,28 @@ struct mgp_duration { ~mgp_duration() = default; - utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } - utils::MemoryResource *memory; - utils::Duration duration; + memgraph::utils::MemoryResource *memory; + memgraph::utils::Duration duration; }; struct mgp_list { /// Allocator type so that STL containers are aware that we need one. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; - explicit mgp_list(utils::MemoryResource *memory) : elems(memory) {} + explicit mgp_list(memgraph::utils::MemoryResource *memory) : elems(memory) {} - mgp_list(utils::pmr::vector &&elems, utils::MemoryResource *memory) : elems(std::move(elems), memory) {} + mgp_list(memgraph::utils::pmr::vector &&elems, memgraph::utils::MemoryResource *memory) + : elems(std::move(elems), memory) {} - mgp_list(const mgp_list &other, utils::MemoryResource *memory) : elems(other.elems, memory) {} + mgp_list(const mgp_list &other, memgraph::utils::MemoryResource *memory) : elems(other.elems, memory) {} - mgp_list(mgp_list &&other, utils::MemoryResource *memory) : elems(std::move(other.elems), memory) {} + mgp_list(mgp_list &&other, memgraph::utils::MemoryResource *memory) : elems(std::move(other.elems), memory) {} mgp_list(mgp_list &&other) noexcept : elems(std::move(other.elems)) {} - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_list(const mgp_list &) = delete; mgp_list &operator=(const mgp_list &) = delete; @@ -351,28 +357,31 @@ struct mgp_list { ~mgp_list() = default; - utils::MemoryResource *GetMemoryResource() const noexcept { return elems.get_allocator().GetMemoryResource(); } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { + return elems.get_allocator().GetMemoryResource(); + } // C++17 vector can work with incomplete type. - utils::pmr::vector elems; + memgraph::utils::pmr::vector elems; }; struct mgp_map { /// Allocator type so that STL containers are aware that we need one. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; - explicit mgp_map(utils::MemoryResource *memory) : items(memory) {} + explicit mgp_map(memgraph::utils::MemoryResource *memory) : items(memory) {} - mgp_map(utils::pmr::map &&items, utils::MemoryResource *memory) + mgp_map(memgraph::utils::pmr::map &&items, + memgraph::utils::MemoryResource *memory) : items(std::move(items), memory) {} - mgp_map(const mgp_map &other, utils::MemoryResource *memory) : items(other.items, memory) {} + mgp_map(const mgp_map &other, memgraph::utils::MemoryResource *memory) : items(other.items, memory) {} - mgp_map(mgp_map &&other, utils::MemoryResource *memory) : items(std::move(other.items), memory) {} + mgp_map(mgp_map &&other, memgraph::utils::MemoryResource *memory) : items(std::move(other.items), memory) {} mgp_map(mgp_map &&other) noexcept : items(std::move(other.items)) {} - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_map(const mgp_map &) = delete; mgp_map &operator=(const mgp_map &) = delete; @@ -380,11 +389,13 @@ struct mgp_map { ~mgp_map() = default; - utils::MemoryResource *GetMemoryResource() const noexcept { return items.get_allocator().GetMemoryResource(); } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { + return items.get_allocator().GetMemoryResource(); + } // Unfortunately using incomplete type with map is undefined, so mgp_map // needs to be defined after mgp_value. - utils::pmr::map items; + memgraph::utils::pmr::map items; }; struct mgp_map_item { @@ -393,9 +404,9 @@ struct mgp_map_item { }; struct mgp_map_items_iterator { - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; - mgp_map_items_iterator(mgp_map *map, utils::MemoryResource *memory) + mgp_map_items_iterator(mgp_map *map, memgraph::utils::MemoryResource *memory) : memory(memory), map(map), current_it(map->items.begin()) { if (current_it != map->items.end()) { current.key = current_it->first.c_str(); @@ -410,9 +421,9 @@ struct mgp_map_items_iterator { ~mgp_map_items_iterator() = default; - utils::MemoryResource *GetMemoryResource() const { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const { return memory; } - utils::MemoryResource *memory; + memgraph::utils::MemoryResource *memory; mgp_map *map; decltype(map->items.begin()) current_it; mgp_map_item current; @@ -422,24 +433,24 @@ struct mgp_vertex { /// Allocator type so that STL containers are aware that we need one. /// We don't actually need this, but it simplifies the C API, because we store /// the allocator which was used to allocate `this`. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; // Hopefully VertexAccessor copy constructor remains noexcept, so that we can // have everything noexcept here. - static_assert(std::is_nothrow_copy_constructible_v); + static_assert(std::is_nothrow_copy_constructible_v); - mgp_vertex(query::VertexAccessor v, mgp_graph *graph, utils::MemoryResource *memory) noexcept + mgp_vertex(memgraph::query::VertexAccessor v, mgp_graph *graph, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), impl(v), graph(graph) {} - mgp_vertex(const mgp_vertex &other, utils::MemoryResource *memory) noexcept + mgp_vertex(const mgp_vertex &other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), impl(other.impl), graph(other.graph) {} - mgp_vertex(mgp_vertex &&other, utils::MemoryResource *memory) noexcept + mgp_vertex(mgp_vertex &&other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), impl(other.impl), graph(other.graph) {} mgp_vertex(mgp_vertex &&other) noexcept : memory(other.memory), impl(other.impl), graph(other.graph) {} - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_vertex(const mgp_vertex &) = delete; mgp_vertex &operator=(const mgp_vertex &) = delete; @@ -450,10 +461,10 @@ struct mgp_vertex { ~mgp_vertex() = default; - utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } - utils::MemoryResource *memory; - query::VertexAccessor impl; + memgraph::utils::MemoryResource *memory; + memgraph::query::VertexAccessor impl; mgp_graph *graph; }; @@ -461,27 +472,28 @@ struct mgp_edge { /// Allocator type so that STL containers are aware that we need one. /// We don't actually need this, but it simplifies the C API, because we store /// the allocator which was used to allocate `this`. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; // Hopefully EdgeAccessor copy constructor remains noexcept, so that we can // have everything noexcept here. - static_assert(std::is_nothrow_copy_constructible_v); + static_assert(std::is_nothrow_copy_constructible_v); static mgp_edge *Copy(const mgp_edge &edge, mgp_memory &memory); - mgp_edge(const query::EdgeAccessor &impl, mgp_graph *graph, utils::MemoryResource *memory) noexcept + mgp_edge(const memgraph::query::EdgeAccessor &impl, mgp_graph *graph, + memgraph::utils::MemoryResource *memory) noexcept : memory(memory), impl(impl), from(impl.From(), graph, memory), to(impl.To(), graph, memory) {} - mgp_edge(const mgp_edge &other, utils::MemoryResource *memory) noexcept + mgp_edge(const mgp_edge &other, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), impl(other.impl), from(other.from, memory), to(other.to, memory) {} - mgp_edge(mgp_edge &&other, utils::MemoryResource *memory) noexcept + mgp_edge(mgp_edge &&other, memgraph::utils::MemoryResource *memory) noexcept : memory(other.memory), impl(other.impl), from(std::move(other.from), memory), to(std::move(other.to), memory) {} mgp_edge(mgp_edge &&other) noexcept : memory(other.memory), impl(other.impl), from(std::move(other.from)), to(std::move(other.to)) {} - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_edge(const mgp_edge &) = delete; mgp_edge &operator=(const mgp_edge &) = delete; @@ -491,29 +503,29 @@ struct mgp_edge { bool operator==(const mgp_edge &other) const noexcept { return this->impl == other.impl; } bool operator!=(const mgp_edge &other) const noexcept { return !(*this == other); }; - utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { return memory; } - utils::MemoryResource *memory; - query::EdgeAccessor impl; + memgraph::utils::MemoryResource *memory; + memgraph::query::EdgeAccessor impl; mgp_vertex from; mgp_vertex to; }; struct mgp_path { /// Allocator type so that STL containers are aware that we need one. - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; - explicit mgp_path(utils::MemoryResource *memory) : vertices(memory), edges(memory) {} + explicit mgp_path(memgraph::utils::MemoryResource *memory) : vertices(memory), edges(memory) {} - mgp_path(const mgp_path &other, utils::MemoryResource *memory) + mgp_path(const mgp_path &other, memgraph::utils::MemoryResource *memory) : vertices(other.vertices, memory), edges(other.edges, memory) {} - mgp_path(mgp_path &&other, utils::MemoryResource *memory) + mgp_path(mgp_path &&other, memgraph::utils::MemoryResource *memory) : vertices(std::move(other.vertices), memory), edges(std::move(other.edges), memory) {} mgp_path(mgp_path &&other) noexcept : vertices(std::move(other.vertices)), edges(std::move(other.edges)) {} - /// Copy construction without utils::MemoryResource is not allowed. + /// Copy construction without memgraph::utils::MemoryResource is not allowed. mgp_path(const mgp_path &) = delete; mgp_path &operator=(const mgp_path &) = delete; @@ -521,62 +533,67 @@ struct mgp_path { ~mgp_path() = default; - utils::MemoryResource *GetMemoryResource() const noexcept { return vertices.get_allocator().GetMemoryResource(); } + memgraph::utils::MemoryResource *GetMemoryResource() const noexcept { + return vertices.get_allocator().GetMemoryResource(); + } - utils::pmr::vector vertices; - utils::pmr::vector edges; + memgraph::utils::pmr::vector vertices; + memgraph::utils::pmr::vector edges; }; struct mgp_result_record { /// Result record signature as defined for mgp_proc. - const utils::pmr::map> *signature; - utils::pmr::map values; + const memgraph::utils::pmr::map> *signature; + memgraph::utils::pmr::map values; }; struct mgp_result { explicit mgp_result( - const utils::pmr::map> *signature, - utils::MemoryResource *mem) + const memgraph::utils::pmr::map> *signature, + memgraph::utils::MemoryResource *mem) : signature(signature), rows(mem) {} /// Result record signature as defined for mgp_proc. - const utils::pmr::map> *signature; - utils::pmr::vector rows; - std::optional error_msg; + const memgraph::utils::pmr::map> *signature; + memgraph::utils::pmr::vector rows; + std::optional error_msg; }; struct mgp_graph { - query::DbAccessor *impl; - storage::View view; + memgraph::query::DbAccessor *impl; + memgraph::storage::View view; // TODO: Merge `mgp_graph` and `mgp_memory` into a single `mgp_context`. The // `ctx` field is out of place here. - query::ExecutionContext *ctx; + memgraph::query::ExecutionContext *ctx; }; struct mgp_properties_iterator { - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; // Define members at the start because we use decltype a lot here, so members // need to be visible in method definitions. - utils::MemoryResource *memory; + memgraph::utils::MemoryResource *memory; mgp_graph *graph; - std::remove_reference_t().Properties(graph->view))> pvs; + std::remove_reference_t().Properties(graph->view))> pvs; decltype(pvs.begin()) current_it; - std::optional> current; + std::optional> current; mgp_property property{nullptr, nullptr}; // Construct with no properties. - explicit mgp_properties_iterator(mgp_graph *graph, utils::MemoryResource *memory) + explicit mgp_properties_iterator(mgp_graph *graph, memgraph::utils::MemoryResource *memory) : memory(memory), graph(graph), current_it(pvs.begin()) {} // May throw who the #$@! knows what because PropertyValueStore doesn't // document what it throws, and it may surely throw some piece of !@#$ // exception because it's built on top of STL and other libraries. - mgp_properties_iterator(mgp_graph *graph, decltype(pvs) pvs, utils::MemoryResource *memory) + mgp_properties_iterator(mgp_graph *graph, decltype(pvs) pvs, memgraph::utils::MemoryResource *memory) : memory(memory), graph(graph), pvs(std::move(pvs)), current_it(this->pvs.begin()) { if (current_it != this->pvs.end()) { - current.emplace(utils::pmr::string(graph->impl->PropertyToName(current_it->first), memory), + current.emplace(memgraph::utils::pmr::string(graph->impl->PropertyToName(current_it->first), memory), mgp_value(current_it->second, memory)); property.name = current->first.c_str(); property.value = ¤t->second; @@ -591,17 +608,17 @@ struct mgp_properties_iterator { ~mgp_properties_iterator() = default; - utils::MemoryResource *GetMemoryResource() const { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const { return memory; } }; struct mgp_edges_iterator { - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; // Hopefully mgp_vertex copy constructor remains noexcept, so that we can // have everything noexcept here. - static_assert(std::is_nothrow_constructible_v); + static_assert(std::is_nothrow_constructible_v); - mgp_edges_iterator(const mgp_vertex &v, utils::MemoryResource *memory) noexcept + mgp_edges_iterator(const mgp_vertex &v, memgraph::utils::MemoryResource *memory) noexcept : memory(memory), source_vertex(v, memory) {} mgp_edges_iterator(mgp_edges_iterator &&other) noexcept @@ -619,9 +636,9 @@ struct mgp_edges_iterator { ~mgp_edges_iterator() = default; - utils::MemoryResource *GetMemoryResource() const { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const { return memory; } - utils::MemoryResource *memory; + memgraph::utils::MemoryResource *memory; mgp_vertex source_vertex; std::optionalview))>> in; std::optionalbegin())> in_it; @@ -631,19 +648,19 @@ struct mgp_edges_iterator { }; struct mgp_vertices_iterator { - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; /// @throw anything VerticesIterable may throw - mgp_vertices_iterator(mgp_graph *graph, utils::MemoryResource *memory) + mgp_vertices_iterator(mgp_graph *graph, memgraph::utils::MemoryResource *memory) : memory(memory), graph(graph), vertices(graph->impl->Vertices(graph->view)), current_it(vertices.begin()) { if (current_it != vertices.end()) { current_v.emplace(*current_it, graph, memory); } } - utils::MemoryResource *GetMemoryResource() const { return memory; } + memgraph::utils::MemoryResource *GetMemoryResource() const { return memory; } - utils::MemoryResource *memory; + memgraph::utils::MemoryResource *memory; mgp_graph *graph; decltype(graph->impl->Vertices(graph->view)) vertices; decltype(vertices.begin()) current_it; @@ -651,36 +668,36 @@ struct mgp_vertices_iterator { }; struct mgp_type { - query::procedure::CypherTypePtr impl; + memgraph::query::procedure::CypherTypePtr impl; }; struct ProcedureInfo { bool is_write = false; - std::optional required_privilege = std::nullopt; + std::optional required_privilege = std::nullopt; }; struct mgp_proc { - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; /// @throw std::bad_alloc /// @throw std::length_error - mgp_proc(const char *name, mgp_proc_cb cb, utils::MemoryResource *memory, const ProcedureInfo &info = {}) + mgp_proc(const char *name, mgp_proc_cb cb, memgraph::utils::MemoryResource *memory, const ProcedureInfo &info = {}) : name(name, memory), cb(cb), args(memory), opt_args(memory), results(memory), info(info) {} /// @throw std::bad_alloc /// @throw std::length_error mgp_proc(const char *name, std::function cb, - utils::MemoryResource *memory, const ProcedureInfo &info = {}) + memgraph::utils::MemoryResource *memory, const ProcedureInfo &info = {}) : name(name, memory), cb(cb), args(memory), opt_args(memory), results(memory), info(info) {} /// @throw std::bad_alloc /// @throw std::length_error mgp_proc(const std::string_view name, std::function cb, - utils::MemoryResource *memory, const ProcedureInfo &info = {}) + memgraph::utils::MemoryResource *memory, const ProcedureInfo &info = {}) : name(name, memory), cb(cb), args(memory), opt_args(memory), results(memory), info(info) {} /// @throw std::bad_alloc /// @throw std::length_error - mgp_proc(const mgp_proc &other, utils::MemoryResource *memory) + mgp_proc(const mgp_proc &other, memgraph::utils::MemoryResource *memory) : name(other.name, memory), cb(other.cb), args(other.args, memory), @@ -688,7 +705,7 @@ struct mgp_proc { results(other.results, memory), info(other.info) {} - mgp_proc(mgp_proc &&other, utils::MemoryResource *memory) + mgp_proc(mgp_proc &&other, memgraph::utils::MemoryResource *memory) : name(std::move(other.name), memory), cb(std::move(other.cb)), args(std::move(other.args), memory), @@ -705,38 +722,43 @@ struct mgp_proc { ~mgp_proc() = default; /// Name of the procedure. - utils::pmr::string name; + memgraph::utils::pmr::string name; /// Entry-point for the procedure. std::function cb; /// Required, positional arguments as a (name, type) pair. - utils::pmr::vector> args; + memgraph::utils::pmr::vector> + args; /// Optional positional arguments as a (name, type, default_value) tuple. - utils::pmr::vector> opt_args; + memgraph::utils::pmr::vector> + opt_args; /// Fields this procedure returns, as a (name -> (type, is_deprecated)) map. - utils::pmr::map> results; + memgraph::utils::pmr::map> + results; ProcedureInfo info; }; struct mgp_trans { - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; /// @throw std::bad_alloc /// @throw std::length_error - mgp_trans(const char *name, mgp_trans_cb cb, utils::MemoryResource *memory) + mgp_trans(const char *name, mgp_trans_cb cb, memgraph::utils::MemoryResource *memory) : name(name, memory), cb(cb), results(memory) {} /// @throw std::bad_alloc /// @throw std::length_error mgp_trans(const char *name, std::function cb, - utils::MemoryResource *memory) + memgraph::utils::MemoryResource *memory) : name(name, memory), cb(cb), results(memory) {} /// @throw std::bad_alloc /// @throw std::length_error - mgp_trans(const mgp_trans &other, utils::MemoryResource *memory) + mgp_trans(const mgp_trans &other, memgraph::utils::MemoryResource *memory) : name(other.name, memory), cb(other.cb), results(other.results) {} - mgp_trans(mgp_trans &&other, utils::MemoryResource *memory) + mgp_trans(mgp_trans &&other, memgraph::utils::MemoryResource *memory) : name(std::move(other.name), memory), cb(std::move(other.cb)), results(std::move(other.results)) {} mgp_trans(const mgp_trans &other) = default; @@ -748,24 +770,26 @@ struct mgp_trans { ~mgp_trans() = default; /// Name of the transformation. - utils::pmr::string name; + memgraph::utils::pmr::string name; /// Entry-point for the transformation. std::function cb; /// Fields this transformation returns. - utils::pmr::map> results; + memgraph::utils::pmr::map> + results; }; mgp_error MgpTransAddFixedResult(mgp_trans *trans) noexcept; struct mgp_module { - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; - explicit mgp_module(utils::MemoryResource *memory) : procedures(memory), transformations(memory) {} + explicit mgp_module(memgraph::utils::MemoryResource *memory) : procedures(memory), transformations(memory) {} - mgp_module(const mgp_module &other, utils::MemoryResource *memory) + mgp_module(const mgp_module &other, memgraph::utils::MemoryResource *memory) : procedures(other.procedures, memory), transformations(other.transformations, memory) {} - mgp_module(mgp_module &&other, utils::MemoryResource *memory) + mgp_module(mgp_module &&other, memgraph::utils::MemoryResource *memory) : procedures(std::move(other.procedures), memory), transformations(std::move(other.transformations), memory) {} mgp_module(const mgp_module &) = default; @@ -776,11 +800,11 @@ struct mgp_module { ~mgp_module() = default; - utils::pmr::map procedures; - utils::pmr::map transformations; + memgraph::utils::pmr::map procedures; + memgraph::utils::pmr::map transformations; }; -namespace query::procedure { +namespace memgraph::query::procedure { /// @throw std::bad_alloc /// @throw std::length_error @@ -789,20 +813,20 @@ void PrintProcSignature(const mgp_proc &, std::ostream *); bool IsValidIdentifierName(const char *name); -} // namespace query::procedure +} // namespace memgraph::query::procedure struct mgp_message { - explicit mgp_message(const integrations::kafka::Message &message) : msg{&message} {} - explicit mgp_message(const integrations::pulsar::Message &message) : msg{message} {} + explicit mgp_message(const memgraph::integrations::kafka::Message &message) : msg{&message} {} + explicit mgp_message(const memgraph::integrations::pulsar::Message &message) : msg{message} {} - using KafkaMessage = const integrations::kafka::Message *; - using PulsarMessage = integrations::pulsar::Message; + using KafkaMessage = const memgraph::integrations::kafka::Message *; + using PulsarMessage = memgraph::integrations::pulsar::Message; std::variant msg; }; struct mgp_messages { - using allocator_type = utils::Allocator; - using storage_type = utils::pmr::vector; + using allocator_type = memgraph::utils::Allocator; + using storage_type = memgraph::utils::pmr::vector; explicit mgp_messages(storage_type &&storage) : messages(std::move(storage)) {} mgp_messages(const mgp_messages &) = delete; diff --git a/src/query/procedure/module.cpp b/src/query/procedure/module.cpp index 4bbc67b43..3373bb886 100644 --- a/src/query/procedure/module.cpp +++ b/src/query/procedure/module.cpp @@ -31,7 +31,7 @@ extern "C" { #include "utils/pmr/vector.hpp" #include "utils/string.hpp" -namespace query::procedure { +namespace memgraph::query::procedure { ModuleRegistry gModuleRegistry; @@ -1121,4 +1121,4 @@ std::optional> FindTransformation( return MakePairIfPropFound(module_registry, fully_qualified_transformation_name, memory); } -} // namespace query::procedure +} // namespace memgraph::query::procedure diff --git a/src/query/procedure/module.hpp b/src/query/procedure/module.hpp index 9e269687d..4d52f915d 100644 --- a/src/query/procedure/module.hpp +++ b/src/query/procedure/module.hpp @@ -27,7 +27,7 @@ class CypherMainVisitorTest; -namespace query::procedure { +namespace memgraph::query::procedure { class Module { public: @@ -147,4 +147,4 @@ std::optional> FindProcedure( std::optional> FindTransformation( const ModuleRegistry &module_registry, const std::string_view fully_qualified_transformation_name, utils::MemoryResource *memory); -} // namespace query::procedure +} // namespace memgraph::query::procedure diff --git a/src/query/procedure/py_module.cpp b/src/query/procedure/py_module.cpp index b73a0204f..b4aed17d1 100644 --- a/src/query/procedure/py_module.cpp +++ b/src/query/procedure/py_module.cpp @@ -26,7 +26,7 @@ #include "utils/on_scope_exit.hpp" #include "utils/pmr/vector.hpp" -namespace query::procedure { +namespace memgraph::query::procedure { namespace { // Set this as a __reduce__ special method on our types to prevent `pickle` and @@ -2525,4 +2525,4 @@ PyObject *PyGraphDeleteEdge(PyGraph *self, PyObject *args) { Py_RETURN_NONE; } -} // namespace query::procedure +} // namespace memgraph::query::procedure diff --git a/src/query/procedure/py_module.hpp b/src/query/procedure/py_module.hpp index 3b64ef33c..5bf4a5611 100644 --- a/src/query/procedure/py_module.hpp +++ b/src/query/procedure/py_module.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ struct mgp_memory; struct mgp_module; struct mgp_value; -namespace query::procedure { +namespace memgraph::query::procedure { struct PyGraph; @@ -57,7 +57,7 @@ mgp_value *PyObjectToMgpValue(PyObject *, mgp_memory *); /// /// The function is to be used before Py_Initialize via the following code. /// -/// PyImport_AppendInittab("_mgp", &query::procedure::PyInitMgpModule); +/// PyImport_AppendInittab("_mgp", &memgraph::query::procedure::PyInitMgpModule); PyObject *PyInitMgpModule(); /// Create an instance of _mgp.Graph class. @@ -79,4 +79,4 @@ py::Object ImportPyModule(const char *, mgp_module *); /// Return nullptr and set appropriate Python exception on failure. py::Object ReloadPyModule(PyObject *, mgp_module *); -} // namespace query::procedure +} // namespace memgraph::query::procedure diff --git a/src/query/serialization/property_value.cpp b/src/query/serialization/property_value.cpp index d37002ad0..b14620a1a 100644 --- a/src/query/serialization/property_value.cpp +++ b/src/query/serialization/property_value.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include "storage/v2/property_value.hpp" #include "utils/logging.hpp" -namespace query::serialization { +namespace memgraph::query::serialization { namespace { enum class ObjectType : uint8_t { MAP, TEMPORAL_DATA }; @@ -124,4 +124,4 @@ std::map DeserializePropertyValueMap(const return property_values; } -} // namespace query::serialization +} // namespace memgraph::query::serialization diff --git a/src/query/serialization/property_value.hpp b/src/query/serialization/property_value.hpp index 92ed4448b..c5ea084be 100644 --- a/src/query/serialization/property_value.hpp +++ b/src/query/serialization/property_value.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "storage/v2/property_value.hpp" -namespace query::serialization { +namespace memgraph::query::serialization { nlohmann::json SerializePropertyValue(const storage::PropertyValue &property_value); @@ -29,4 +29,4 @@ std::vector DeserializePropertyValueList(const nlohmann: std::map DeserializePropertyValueMap(const nlohmann::json::object_t &data); -} // namespace query::serialization +} // namespace memgraph::query::serialization diff --git a/src/query/stream.hpp b/src/query/stream.hpp index cbdf36152..ee7e854a2 100644 --- a/src/query/stream.hpp +++ b/src/query/stream.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "query/typed_value.hpp" #include "utils/memory.hpp" -namespace query { +namespace memgraph::query { /** * `AnyStream` can wrap *any* type implementing the `Stream` concept into a @@ -60,4 +60,4 @@ class AnyStream final { std::unique_ptr> content_; }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/stream/common.cpp b/src/query/stream/common.cpp index cf6cdc59c..50b554f4d 100644 --- a/src/query/stream/common.cpp +++ b/src/query/stream/common.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace query::stream { +namespace memgraph::query::stream { namespace { const std::string kBatchIntervalKey{"batch_interval"}; const std::string kBatchSizeKey{"batch_size"}; @@ -42,4 +42,4 @@ void from_json(const nlohmann::json &data, CommonStreamInfo &common_info) { data.at(kTransformationName).get_to(common_info.transformation_name); } -} // namespace query::stream +} // namespace memgraph::query::stream diff --git a/src/query/stream/common.hpp b/src/query/stream/common.hpp index 47f6cb318..0c2a2abc7 100644 --- a/src/query/stream/common.hpp +++ b/src/query/stream/common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "query/procedure/mg_procedure_impl.hpp" -namespace query::stream { +namespace memgraph::query::stream { constexpr std::chrono::milliseconds kDefaultBatchInterval{100}; constexpr int64_t kDefaultBatchSize{1000}; @@ -83,4 +83,4 @@ const std::string kCommonInfoKey = "common_info"; void to_json(nlohmann::json &data, CommonStreamInfo &&info); void from_json(const nlohmann::json &data, CommonStreamInfo &common_info); -} // namespace query::stream +} // namespace memgraph::query::stream diff --git a/src/query/stream/sources.cpp b/src/query/stream/sources.cpp index 5f350a694..e799a5fbb 100644 --- a/src/query/stream/sources.cpp +++ b/src/query/stream/sources.cpp @@ -15,7 +15,7 @@ #include "integrations/constants.hpp" -namespace query::stream { +namespace memgraph::query::stream { KafkaStream::KafkaStream(std::string stream_name, StreamInfo stream_info, ConsumerFunction consumer_function) { integrations::kafka::ConsumerInfo consumer_info{ @@ -129,4 +129,4 @@ void from_json(const nlohmann::json &data, PulsarStream::StreamInfo &info) { data.at(kTopicsKey).get_to(info.topics); data.at(kServiceUrl).get_to(info.service_url); } -} // namespace query::stream +} // namespace memgraph::query::stream diff --git a/src/query/stream/sources.hpp b/src/query/stream/sources.hpp index 1b5b62f58..29548a074 100644 --- a/src/query/stream/sources.hpp +++ b/src/query/stream/sources.hpp @@ -16,7 +16,7 @@ #include "integrations/kafka/consumer.hpp" #include "integrations/pulsar/consumer.hpp" -namespace query::stream { +namespace memgraph::query::stream { struct KafkaStream { struct StreamInfo { @@ -90,4 +90,4 @@ inline StreamSourceType StreamType(const PulsarStream & /*stream*/) { return StreamSourceType::PULSAR; } -} // namespace query::stream +} // namespace memgraph::query::stream diff --git a/src/query/stream/streams.cpp b/src/query/stream/streams.cpp index 3e3689a3c..4d323b057 100644 --- a/src/query/stream/streams.cpp +++ b/src/query/stream/streams.cpp @@ -40,7 +40,7 @@ namespace EventCounter { extern const Event MessagesConsumed; } // namespace EventCounter -namespace query::stream { +namespace memgraph::query::stream { namespace { constexpr auto kExpectedTransformationResultSize = 2; const utils::pmr::string query_param_name{"query", utils::NewDeleteResource()}; @@ -528,7 +528,7 @@ Streams::StreamsMap::iterator Streams::CreateConsumer(StreamsMap &map, const std interpreter->CommitTransaction(); result.rows.clear(); break; - } catch (const query::TransactionSerializationException &e) { + } catch (const memgraph::query::TransactionSerializationException &e) { interpreter->Abort(); if (i == total_retries) { throw; @@ -742,4 +742,4 @@ TransformationResult Streams::Check(const std::string &stream_name, std::optiona it->second); } -} // namespace query::stream +} // namespace memgraph::query::stream diff --git a/src/query/stream/streams.hpp b/src/query/stream/streams.hpp index 75c5ff313..fa556517b 100644 --- a/src/query/stream/streams.hpp +++ b/src/query/stream/streams.hpp @@ -32,7 +32,7 @@ #include "utils/synchronized.hpp" class StreamsTest; -namespace query { +namespace memgraph::query { struct InterpreterContext; @@ -191,4 +191,4 @@ class Streams final { }; } // namespace stream -} // namespace query +} // namespace memgraph::query diff --git a/src/query/trigger.cpp b/src/query/trigger.cpp index 285cd0860..fde357a07 100644 --- a/src/query/trigger.cpp +++ b/src/query/trigger.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -29,7 +29,7 @@ namespace EventCounter { extern const Event TriggersExecuted; } // namespace EventCounter -namespace query { +namespace memgraph::query { namespace { auto IdentifierString(const TriggerIdentifierTag tag) noexcept { switch (tag) { @@ -154,7 +154,7 @@ Trigger::Trigger(std::string name, const std::string &query, const std::map &user_parameters, const TriggerEventType event_type, utils::SkipList *query_cache, DbAccessor *db_accessor, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, - std::optional owner, const query::AuthChecker *auth_checker) + std::optional owner, const memgraph::query::AuthChecker *auth_checker) : name_{std::move(name)}, parsed_statements_{ParseQuery(query, user_parameters, query_cache, antlr_lock, query_config)}, event_type_{event_type}, @@ -167,7 +167,7 @@ Trigger::TriggerPlan::TriggerPlan(std::unique_ptr logical_plan, std : cached_plan(std::move(logical_plan)), identifiers(std::move(identifiers)) {} std::shared_ptr Trigger::GetPlan(DbAccessor *db_accessor, - const query::AuthChecker *auth_checker) const { + const memgraph::query::AuthChecker *auth_checker) const { std::lock_guard plan_guard{plan_lock_}; if (!parsed_statements_.is_cacheable || !trigger_plan_ || trigger_plan_->cached_plan.IsExpired()) { auto identifiers = GetPredefinedIdentifiers(event_type_); @@ -258,7 +258,7 @@ TriggerStore::TriggerStore(std::filesystem::path directory) : storage_{std::move void TriggerStore::RestoreTriggers(utils::SkipList *query_cache, DbAccessor *db_accessor, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, - const query::AuthChecker *auth_checker) { + const memgraph::query::AuthChecker *auth_checker) { MG_ASSERT(before_commit_triggers_.size() == 0 && after_commit_triggers_.size() == 0, "Cannot restore trigger when some triggers already exist!"); spdlog::info("Loading triggers..."); @@ -337,7 +337,7 @@ void TriggerStore::AddTrigger(std::string name, const std::string &query, TriggerEventType event_type, TriggerPhase phase, utils::SkipList *query_cache, DbAccessor *db_accessor, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, - std::optional owner, const query::AuthChecker *auth_checker) { + std::optional owner, const memgraph::query::AuthChecker *auth_checker) { std::unique_lock store_guard{store_lock_}; if (storage_.Get(name)) { throw utils::BasicException("Trigger with the same name already exists."); @@ -438,4 +438,4 @@ std::unordered_set TriggerStore::GetEventTypes() const { add_event_types(after_commit_triggers_); return event_types; } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/trigger.hpp b/src/query/trigger.hpp index 078d1279c..aca97d5f9 100644 --- a/src/query/trigger.hpp +++ b/src/query/trigger.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -30,13 +30,13 @@ #include "utils/skip_list.hpp" #include "utils/spin_lock.hpp" -namespace query { +namespace memgraph::query { struct Trigger { explicit Trigger(std::string name, const std::string &query, const std::map &user_parameters, TriggerEventType event_type, utils::SkipList *query_cache, DbAccessor *db_accessor, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, std::optional owner, - const query::AuthChecker *auth_checker); + const memgraph::query::AuthChecker *auth_checker); void Execute(DbAccessor *dba, utils::MonotonicBufferResource *execution_memory, double max_execution_time_sec, std::atomic *is_shutting_down, const TriggerContext &context, @@ -63,7 +63,7 @@ struct Trigger { CachedPlan cached_plan; std::vector identifiers; }; - std::shared_ptr GetPlan(DbAccessor *db_accessor, const query::AuthChecker *auth_checker) const; + std::shared_ptr GetPlan(DbAccessor *db_accessor, const memgraph::query::AuthChecker *auth_checker) const; std::string name_; ParsedQuery parsed_statements_; @@ -82,13 +82,13 @@ struct TriggerStore { void RestoreTriggers(utils::SkipList *query_cache, DbAccessor *db_accessor, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, - const query::AuthChecker *auth_checker); + const memgraph::query::AuthChecker *auth_checker); void AddTrigger(std::string name, const std::string &query, const std::map &user_parameters, TriggerEventType event_type, TriggerPhase phase, utils::SkipList *query_cache, DbAccessor *db_accessor, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, - std::optional owner, const query::AuthChecker *auth_checker); + std::optional owner, const memgraph::query::AuthChecker *auth_checker); void DropTrigger(const std::string &name); @@ -116,4 +116,4 @@ struct TriggerStore { utils::SkipList after_commit_triggers_; }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/trigger_context.cpp b/src/query/trigger_context.cpp index deb5137be..d65d5b166 100644 --- a/src/query/trigger_context.cpp +++ b/src/query/trigger_context.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ #include "storage/v2/property_value.hpp" #include "utils/memory.hpp" -namespace query { +namespace memgraph::query { namespace { template concept WithToMap = requires(const T value, DbAccessor *dba) { @@ -168,7 +168,7 @@ using PropertyChangesLists = template [[nodiscard]] PropertyChangesLists PropertyMapToList( - query::TriggerContextCollector::PropertyChangesMap &&map) { + memgraph::query::TriggerContextCollector::PropertyChangesMap &&map) { std::vector> set_object_properties; std::vector> removed_object_properties; @@ -198,7 +198,8 @@ template } template -[[nodiscard]] ChangesSummary Summarize(query::TriggerContextCollector::Registry &®istry) { +[[nodiscard]] ChangesSummary Summarize( + memgraph::query::TriggerContextCollector::Registry &®istry) { auto [set_object_properties, removed_object_properties] = PropertyMapToList(std::move(registry.property_changes)); std::vector> created_objects_vec; created_objects_vec.reserve(registry.created_objects.size()); @@ -553,4 +554,4 @@ TriggerContextCollector::LabelChangesLists TriggerContextCollector::LabelMapToLi return {std::move(set_vertex_labels), std::move(removed_vertex_labels)}; } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/trigger_context.hpp b/src/query/trigger_context.hpp index 12c04d296..39f4a89dd 100644 --- a/src/query/trigger_context.hpp +++ b/src/query/trigger_context.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,7 +27,7 @@ #include "utils/concepts.hpp" #include "utils/fnv.hpp" -namespace query { +namespace memgraph::query { namespace detail { template concept ObjectAccessor = utils::SameAsAnyOf; @@ -361,4 +361,4 @@ class TriggerContextCollector { // the state of the label before the transaction start, and the latest state assigned throughout the transaction. LabelChangesMap label_changes_; }; -} // namespace query +} // namespace memgraph::query diff --git a/src/query/typed_value.cpp b/src/query/typed_value.cpp index 95b910ce0..0e3e3c8a0 100644 --- a/src/query/typed_value.cpp +++ b/src/query/typed_value.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ #include "utils/exceptions.hpp" #include "utils/fnv.hpp" -namespace query { +namespace memgraph::query { TypedValue::TypedValue(const storage::PropertyValue &value) // TODO: MemoryResource in storage::PropertyValue @@ -1104,4 +1104,4 @@ size_t TypedValue::Hash::operator()(const TypedValue &value) const { LOG_FATAL("Unhandled TypedValue.type() in hash function"); } -} // namespace query +} // namespace memgraph::query diff --git a/src/query/typed_value.hpp b/src/query/typed_value.hpp index c44c07f57..8737eb1dc 100644 --- a/src/query/typed_value.hpp +++ b/src/query/typed_value.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -29,7 +29,7 @@ #include "utils/pmr/vector.hpp" #include "utils/temporal.hpp" -namespace query { +namespace memgraph::query { // TODO: Neo4j does overflow checking. Should we also implement it? /** @@ -736,4 +736,4 @@ TypedValue operator%(const TypedValue &a, const TypedValue &b); /** Output the TypedValue::Type value as a string */ std::ostream &operator<<(std::ostream &os, const TypedValue::Type &type); -} // namespace query +} // namespace memgraph::query diff --git a/src/requests/requests.cpp b/src/requests/requests.cpp index 823620d94..da36c0c6a 100644 --- a/src/requests/requests.cpp +++ b/src/requests/requests.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "utils/logging.hpp" -namespace requests { +namespace memgraph::requests { namespace { @@ -113,4 +113,4 @@ bool CreateAndDownloadFile(const std::string &url, const std::string &path, int return true; } -} // namespace requests +} // namespace memgraph::requests diff --git a/src/requests/requests.hpp b/src/requests/requests.hpp index 58a0a289b..4ded90464 100644 --- a/src/requests/requests.hpp +++ b/src/requests/requests.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include -namespace requests { +namespace memgraph::requests { /** * Call this function in each `main` file that uses the Requests stack. It is @@ -47,4 +47,4 @@ bool RequestPostJson(const std::string &url, const nlohmann::json &data, int tim */ bool CreateAndDownloadFile(const std::string &url, const std::string &path, int timeout_in_seconds = 10); -} // namespace requests +} // namespace memgraph::requests diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 26f4de8b2..a7351d03f 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "rpc/client.hpp" -namespace rpc { +namespace memgraph::rpc { Client::Client(const io::network::Endpoint &endpoint, communication::ClientContext *context) : endpoint_(endpoint), context_(context) {} @@ -24,4 +24,4 @@ void Client::Abort() { client_ = std::nullopt; } -} // namespace rpc +} // namespace memgraph::rpc diff --git a/src/rpc/client.hpp b/src/rpc/client.hpp index d40b3d8ea..082dfa753 100644 --- a/src/rpc/client.hpp +++ b/src/rpc/client.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,7 +24,7 @@ #include "utils/logging.hpp" #include "utils/on_scope_exit.hpp" -namespace rpc { +namespace memgraph::rpc { /// Client is thread safe, but it is recommended to use thread_local clients. class Client { @@ -38,7 +38,7 @@ class Client { friend class Client; StreamHandler(Client *self, std::unique_lock &&guard, - std::function res_load) + std::function res_load) : self_(self), guard_(std::move(guard)), req_builder_([self](const uint8_t *data, size_t size, bool have_more) { @@ -55,7 +55,7 @@ class Client { ~StreamHandler() {} - slk::Builder *GetBuilder() { return &req_builder_; } + memgraph::slk::Builder *GetBuilder() { return &req_builder_; } typename TRequestResponse::Response AwaitResponse() { auto res_type = TRequestResponse::Response::kType; @@ -66,10 +66,10 @@ class Client { // Receive the response. uint64_t response_data_size = 0; while (true) { - auto ret = slk::CheckStreamComplete(self_->client_->GetData(), self_->client_->GetDataSize()); - if (ret.status == slk::StreamStatus::INVALID) { + auto ret = memgraph::slk::CheckStreamComplete(self_->client_->GetData(), self_->client_->GetDataSize()); + if (ret.status == memgraph::slk::StreamStatus::INVALID) { throw RpcFailedException(self_->endpoint_); - } else if (ret.status == slk::StreamStatus::PARTIAL) { + } else if (ret.status == memgraph::slk::StreamStatus::PARTIAL) { if (!self_->client_->Read(ret.stream_size - self_->client_->GetDataSize(), /* exactly_len = */ false)) { throw RpcFailedException(self_->endpoint_); @@ -81,11 +81,11 @@ class Client { } // Load the response. - slk::Reader res_reader(self_->client_->GetData(), response_data_size); + memgraph::slk::Reader res_reader(self_->client_->GetData(), response_data_size); utils::OnScopeExit res_cleanup([&, response_data_size] { self_->client_->ShiftData(response_data_size); }); uint64_t res_id = 0; - slk::Load(&res_id, &res_reader); + memgraph::slk::Load(&res_id, &res_reader); // Check the response ID. if (res_id != res_type.id) { @@ -102,8 +102,8 @@ class Client { private: Client *self_; std::unique_lock guard_; - slk::Builder req_builder_; - std::function res_load_; + memgraph::slk::Builder req_builder_; + std::function res_load_; }; /// Stream a previously defined and registered RPC call. This function can @@ -132,8 +132,8 @@ class Client { /// Same as `Stream` but the first argument is a response loading function. template - StreamHandler StreamWithLoad(std::function load, - Args &&...args) { + StreamHandler StreamWithLoad( + std::function load, Args &&...args) { typename TRequestResponse::Request request(std::forward(args)...); auto req_type = TRequestResponse::Request::kType; SPDLOG_TRACE("[RpcClient] sent {}", req_type.name); @@ -160,7 +160,7 @@ class Client { StreamHandler handler(this, std::move(guard), load); // Build and send the request. - slk::Save(req_type.id, handler.GetBuilder()); + memgraph::slk::Save(req_type.id, handler.GetBuilder()); TRequestResponse::Request::Save(request, handler.GetBuilder()); // Return the handler to the user. @@ -185,7 +185,7 @@ class Client { /// Same as `Call` but the first argument is a response loading function. template typename TRequestResponse::Response CallWithLoad( - std::function load, Args &&...args) { + std::function load, Args &&...args) { auto stream = StreamWithLoad(load, std::forward(args)...); return stream.AwaitResponse(); } @@ -203,4 +203,4 @@ class Client { std::mutex mutex_; }; -} // namespace rpc +} // namespace memgraph::rpc diff --git a/src/rpc/client_pool.hpp b/src/rpc/client_pool.hpp index 71281fda3..408b006a2 100644 --- a/src/rpc/client_pool.hpp +++ b/src/rpc/client_pool.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "rpc/client.hpp" -namespace rpc { +namespace memgraph::rpc { /** * A simple client pool that creates new RPC clients on demand. Useful when you @@ -69,4 +69,4 @@ class ClientPool { std::stack> unused_clients_; }; -} // namespace rpc +} // namespace memgraph::rpc diff --git a/src/rpc/exceptions.hpp b/src/rpc/exceptions.hpp index 122e679ff..d731288ac 100644 --- a/src/rpc/exceptions.hpp +++ b/src/rpc/exceptions.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -12,7 +12,7 @@ #include "io/network/endpoint.hpp" #include "utils/exceptions.hpp" -namespace rpc { +namespace memgraph::rpc { /// Exception that is thrown whenever a RPC call fails. /// This exception inherits `std::exception` directly because @@ -33,4 +33,4 @@ class RpcFailedException final : public utils::BasicException { private: io::network::Endpoint endpoint_; }; -} // namespace rpc +} // namespace memgraph::rpc diff --git a/src/rpc/messages.hpp b/src/rpc/messages.hpp index c43e3d746..875217d31 100644 --- a/src/rpc/messages.hpp +++ b/src/rpc/messages.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "utils/typeinfo.hpp" -namespace rpc { +namespace memgraph::rpc { using MessageSize = uint32_t; @@ -34,4 +34,4 @@ struct RequestResponse { using Response = TResponse; }; -} // namespace rpc +} // namespace memgraph::rpc diff --git a/src/rpc/protocol.cpp b/src/rpc/protocol.cpp index af461fb26..63ac58760 100644 --- a/src/rpc/protocol.cpp +++ b/src/rpc/protocol.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "slk/streams.hpp" #include "utils/on_scope_exit.hpp" -namespace rpc { +namespace memgraph::rpc { Session::Session(Server *server, const io::network::Endpoint &endpoint, communication::InputStream *input_stream, communication::OutputStream *output_stream) @@ -76,4 +76,4 @@ void Session::Execute() { (it != server_->callbacks_.end() ? it->second.res_type.name : extended_it->second.res_type.name)); } -} // namespace rpc +} // namespace memgraph::rpc diff --git a/src/rpc/protocol.hpp b/src/rpc/protocol.hpp index 92ce4e8a5..38e58950b 100644 --- a/src/rpc/protocol.hpp +++ b/src/rpc/protocol.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,7 +27,7 @@ * Message layout: MessageSize message_size, * message_size bytes serialized_message */ -namespace rpc { +namespace memgraph::rpc { // Forward declaration of class Server class Server; @@ -64,4 +64,4 @@ class Session { communication::OutputStream *output_stream_; }; -} // namespace rpc +} // namespace memgraph::rpc diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 6dbdc2066..aa3caca2e 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "rpc/server.hpp" -namespace rpc { +namespace memgraph::rpc { Server::Server(const io::network::Endpoint &endpoint, communication::ServerContext *context, size_t workers_count) : server_(endpoint, this, context, -1, context->use_ssl() ? "RPCS" : "RPC", workers_count) {} @@ -23,4 +23,4 @@ void Server::Shutdown() { server_.Shutdown(); } void Server::AwaitShutdown() { server_.AwaitShutdown(); } const io::network::Endpoint &Server::endpoint() const { return server_.endpoint(); } -} // namespace rpc +} // namespace memgraph::rpc diff --git a/src/rpc/server.hpp b/src/rpc/server.hpp index 29ecec169..9755bc8c2 100644 --- a/src/rpc/server.hpp +++ b/src/rpc/server.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "rpc/protocol.hpp" #include "slk/streams.hpp" -namespace rpc { +namespace memgraph::rpc { class Server { public: @@ -39,7 +39,7 @@ class Server { const io::network::Endpoint &endpoint() const; template - void Register(std::function callback) { + void Register(std::function callback) { std::lock_guard guard(lock_); MG_ASSERT(!server_.IsRunning(), "You can't register RPCs when the server is running!"); RpcCallback rpc; @@ -57,7 +57,8 @@ class Server { } template - void Register(std::function callback) { + void Register( + std::function callback) { std::lock_guard guard(lock_); MG_ASSERT(!server_.IsRunning(), "You can't register RPCs when the server is running!"); RpcExtendedCallback rpc; @@ -75,13 +76,13 @@ class Server { struct RpcCallback { utils::TypeInfo req_type; - std::function callback; + std::function callback; utils::TypeInfo res_type; }; struct RpcExtendedCallback { utils::TypeInfo req_type; - std::function callback; + std::function callback; utils::TypeInfo res_type; }; @@ -92,4 +93,4 @@ class Server { communication::Server server_; }; -} // namespace rpc +} // namespace memgraph::rpc diff --git a/src/slk/serialization.hpp b/src/slk/serialization.hpp index 1cba9018b..5c5cbf68d 100644 --- a/src/slk/serialization.hpp +++ b/src/slk/serialization.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -34,7 +34,7 @@ // The namespace name stands for SaveLoadKit. It should be not mistaken for the // Mercedes car model line. -namespace slk { +namespace memgraph::slk { // Static assert for the assumption made in this library. static_assert(std::is_same_v || std::is_same_v, @@ -136,19 +136,19 @@ MAKE_PRIMITIVE_LOAD(uint64_t) #undef MAKE_PRIMITIVE_LOAD -inline void Save(float obj, Builder *builder) { slk::Save(utils::MemcpyCast(obj), builder); } +inline void Save(float obj, Builder *builder) { memgraph::slk::Save(utils::MemcpyCast(obj), builder); } -inline void Save(double obj, Builder *builder) { slk::Save(utils::MemcpyCast(obj), builder); } +inline void Save(double obj, Builder *builder) { memgraph::slk::Save(utils::MemcpyCast(obj), builder); } inline void Load(float *obj, Reader *reader) { uint32_t obj_encoded; - slk::Load(&obj_encoded, reader); + memgraph::slk::Load(&obj_encoded, reader); *obj = utils::MemcpyCast(obj_encoded); } inline void Load(double *obj, Reader *reader) { uint64_t obj_encoded; - slk::Load(&obj_encoded, reader); + memgraph::slk::Load(&obj_encoded, reader); *obj = utils::MemcpyCast(obj_encoded); } @@ -471,4 +471,4 @@ inline void Load(std::optional *obj, Reader *reader, std::function write_func) : write_func_(write_func) {} @@ -142,4 +142,4 @@ StreamInfo CheckStreamComplete(const uint8_t *data, size_t size) { return {StreamStatus::COMPLETE, pos, data_size}; } -} // namespace slk +} // namespace memgraph::slk diff --git a/src/slk/streams.hpp b/src/slk/streams.hpp index 5d39a29c3..962ff5431 100644 --- a/src/slk/streams.hpp +++ b/src/slk/streams.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "utils/exceptions.hpp" -namespace slk { +namespace memgraph::slk { using SegmentSize = uint32_t; @@ -118,4 +118,4 @@ struct StreamInfo { /// segment data. StreamInfo CheckStreamComplete(const uint8_t *data, size_t size); -} // namespace slk +} // namespace memgraph::slk diff --git a/src/storage/v2/commit_log.cpp b/src/storage/v2/commit_log.cpp index e7f0a8a22..59b6e88f4 100644 --- a/src/storage/v2/commit_log.cpp +++ b/src/storage/v2/commit_log.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -12,7 +12,7 @@ #include "storage/v2/commit_log.hpp" #include "utils/memory.hpp" -namespace storage { +namespace memgraph::storage { CommitLog::CommitLog() : allocator_(utils::NewDeleteResource()) {} CommitLog::CommitLog(uint64_t oldest_active) : allocator_(utils::NewDeleteResource()) { @@ -108,4 +108,4 @@ CommitLog::Block *CommitLog::FindOrCreateBlock(const uint64_t id) { return current; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/commit_log.hpp b/src/storage/v2/commit_log.hpp index b6bcee000..8c5050a4e 100644 --- a/src/storage/v2/commit_log.hpp +++ b/src/storage/v2/commit_log.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/memory.hpp" #include "utils/spin_lock.hpp" -namespace storage { +namespace memgraph::storage { /// This class keeps track of finalized transactions to provide info on the /// oldest active transaction (minimal transaction ID which could still be @@ -76,4 +76,4 @@ class CommitLog final { utils::Allocator allocator_; }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/config.hpp b/src/storage/v2/config.hpp index 755d21a3b..0db24615d 100644 --- a/src/storage/v2/config.hpp +++ b/src/storage/v2/config.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "storage/v2/isolation_level.hpp" #include "storage/v2/transaction.hpp" -namespace storage { +namespace memgraph::storage { /// Pass this class to the \ref Storage constructor to change the behavior of /// the storage. This class also defines the default behavior. @@ -57,4 +57,4 @@ struct Config { } transaction; }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/constraints.cpp b/src/storage/v2/constraints.cpp index d56c502bd..fab6ee4c4 100644 --- a/src/storage/v2/constraints.cpp +++ b/src/storage/v2/constraints.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "storage/v2/mvcc.hpp" #include "utils/logging.hpp" -namespace storage { +namespace memgraph::storage { namespace { /// Helper function that determines position of the given `property` in the @@ -411,4 +411,4 @@ void UniqueConstraints::RemoveObsoleteEntries(uint64_t oldest_active_start_times } } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/constraints.hpp b/src/storage/v2/constraints.hpp index 2daf270bd..b209437f8 100644 --- a/src/storage/v2/constraints.hpp +++ b/src/storage/v2/constraints.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ #include "utils/result.hpp" #include "utils/skip_list.hpp" -namespace storage { +namespace memgraph::storage { // NOLINTNEXTLINE(misc-definitions-in-headers) const size_t kUniqueConstraintsMaxProperties = 32; @@ -196,4 +196,4 @@ inline std::vector> ListExistenceConstraints(cons return constraints.existence_constraints; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/delta.hpp b/src/storage/v2/delta.hpp index 16f343fc7..5aad1ab2f 100644 --- a/src/storage/v2/delta.hpp +++ b/src/storage/v2/delta.hpp @@ -18,7 +18,7 @@ #include "storage/v2/property_value.hpp" #include "utils/logging.hpp" -namespace storage { +namespace memgraph::storage { // Forward declarations because we only store pointers here. struct Vertex; @@ -239,4 +239,4 @@ struct Delta { static_assert(alignof(Delta) >= 8, "The Delta should be aligned to at least 8!"); -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/durability/durability.cpp b/src/storage/v2/durability/durability.cpp index e5f115a5c..8aaf115b6 100644 --- a/src/storage/v2/durability/durability.cpp +++ b/src/storage/v2/durability/durability.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -31,7 +31,7 @@ #include "utils/memory_tracker.hpp" #include "utils/message.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { void VerifyStorageDirectoryOwnerAndProcessUserOrDie(const std::filesystem::path &storage_directory) { // Get the process user ID. @@ -256,7 +256,8 @@ std::optional RecoverData(const std::filesystem::path &snapshot_di auto maybe_wal_files = GetWalFiles(wal_directory, *uuid); if (!maybe_wal_files) { - spdlog::warn(utils::MessageWithLink("Couldn't get WAL file info from the WAL directory.", "https://memgr.ph/durability")); + spdlog::warn( + utils::MessageWithLink("Couldn't get WAL file info from the WAL directory.", "https://memgr.ph/durability")); return std::nullopt; } @@ -343,4 +344,4 @@ std::optional RecoverData(const std::filesystem::path &snapshot_di return recovery_info; } -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/durability.hpp b/src/storage/v2/durability/durability.hpp index 6b68f992c..0e26c4e95 100644 --- a/src/storage/v2/durability/durability.hpp +++ b/src/storage/v2/durability/durability.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -28,7 +28,7 @@ #include "storage/v2/vertex.hpp" #include "utils/skip_list.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { /// Verifies that the owner of the storage directory is the same user that /// started the current process. If the verification fails, the process is @@ -111,4 +111,4 @@ std::optional RecoverData(const std::filesystem::path &snapshot_di Indices *indices, Constraints *constraints, Config::Items items, uint64_t *wal_seq_num); -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/exceptions.hpp b/src/storage/v2/durability/exceptions.hpp index 91bbd8a0b..ce0b10252 100644 --- a/src/storage/v2/durability/exceptions.hpp +++ b/src/storage/v2/durability/exceptions.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,11 +13,11 @@ #include "utils/exceptions.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { /// Exception used to handle errors during recovery. class RecoveryFailure : public utils::BasicException { using utils::BasicException::BasicException; }; -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/marker.hpp b/src/storage/v2/durability/marker.hpp index 86283b99e..5bc3b5359 100644 --- a/src/storage/v2/durability/marker.hpp +++ b/src/storage/v2/durability/marker.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace storage::durability { +namespace memgraph::storage::durability { /// Markers that are used to indicate crucial parts of the snapshot/WAL. /// IMPORTANT: Don't forget to update the list of all markers `kMarkersAll` when @@ -103,4 +103,4 @@ static const Marker kMarkersAll[] = { Marker::VALUE_TRUE, }; -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/metadata.hpp b/src/storage/v2/durability/metadata.hpp index bb2a3fc6b..2986212be 100644 --- a/src/storage/v2/durability/metadata.hpp +++ b/src/storage/v2/durability/metadata.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "storage/v2/durability/exceptions.hpp" #include "storage/v2/id_types.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { /// Structure used to hold metadata about the recovered snapshot/WAL. struct RecoveryInfo { @@ -71,4 +71,4 @@ void RemoveRecoveredIndexConstraint(std::vector *list, TObj obj, const cha } } -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/paths.hpp b/src/storage/v2/durability/paths.hpp index 0d81b5da6..a8e210d5a 100644 --- a/src/storage/v2/durability/paths.hpp +++ b/src/storage/v2/durability/paths.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "utils/timestamp.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { static const std::string kSnapshotDirectory{"snapshots"}; static const std::string kWalDirectory{"wal"}; @@ -47,4 +47,4 @@ inline std::string RemakeWalName(const std::string ¤t_name, uint64_t from_ std::to_string(to_timestamp); } -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/serialization.cpp b/src/storage/v2/durability/serialization.cpp index 6f940f813..e2862d970 100644 --- a/src/storage/v2/durability/serialization.cpp +++ b/src/storage/v2/durability/serialization.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include "storage/v2/temporal.hpp" #include "utils/endian.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { ////////////////////////// // Encoder implementation. @@ -461,4 +461,4 @@ std::optional Decoder::GetPosition() { return file_.GetPosition(); } bool Decoder::SetPosition(uint64_t position) { return !!file_.SetPosition(utils::InputFile::Position::SET, position); } -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/serialization.hpp b/src/storage/v2/durability/serialization.hpp index 3abb6898a..b53f94d40 100644 --- a/src/storage/v2/durability/serialization.hpp +++ b/src/storage/v2/durability/serialization.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "storage/v2/property_value.hpp" #include "utils/file.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { /// Encoder interface class. Used to implement streams to different targets /// (e.g. file and network). @@ -128,4 +128,4 @@ class Decoder final : public BaseDecoder { utils::InputFile file_; }; -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/snapshot.cpp b/src/storage/v2/durability/snapshot.cpp index 4ff9ae514..16c7d017c 100644 --- a/src/storage/v2/durability/snapshot.cpp +++ b/src/storage/v2/durability/snapshot.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,7 +24,7 @@ #include "utils/logging.hpp" #include "utils/message.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { // Snapshot format: // @@ -977,4 +977,4 @@ void CreateSnapshot(Transaction *transaction, const std::filesystem::path &snaps } } -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/snapshot.hpp b/src/storage/v2/durability/snapshot.hpp index d6da3fc43..b1cfad63c 100644 --- a/src/storage/v2/durability/snapshot.hpp +++ b/src/storage/v2/durability/snapshot.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,7 +26,7 @@ #include "utils/file_locker.hpp" #include "utils/skip_list.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { /// Structure used to hold information about a snapshot. struct SnapshotInfo { @@ -72,4 +72,4 @@ void CreateSnapshot(Transaction *transaction, const std::filesystem::path &snaps std::string_view epoch_id, const std::deque> &epoch_history, utils::FileRetainer *file_retainer); -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/version.hpp b/src/storage/v2/durability/version.hpp index 9a95404b0..712bf322a 100644 --- a/src/storage/v2/durability/version.hpp +++ b/src/storage/v2/durability/version.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include #include -namespace storage::durability { +namespace memgraph::storage::durability { // The current version of snapshot and WAL encoding / decoding. // IMPORTANT: Please bump this version for every snapshot and/or WAL format @@ -34,4 +34,4 @@ static_assert(std::is_same_v); // Checks whether the loaded snapshot/WAL version is supported. inline bool IsVersionSupported(uint64_t version) { return version >= kOldestSupportedVersion && version <= kVersion; } -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/wal.cpp b/src/storage/v2/durability/wal.cpp index 6a7b6b9ea..a8faf064a 100644 --- a/src/storage/v2/durability/wal.cpp +++ b/src/storage/v2/durability/wal.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/file_locker.hpp" #include "utils/logging.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { // WAL format: // @@ -987,4 +987,4 @@ void WalFile::TryFlushing() { wal_.TryFlushing(); } std::pair WalFile::CurrentFileBuffer() const { return wal_.CurrentFileBuffer(); } -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/durability/wal.hpp b/src/storage/v2/durability/wal.hpp index 9cca8ed79..ffd12fdb3 100644 --- a/src/storage/v2/durability/wal.hpp +++ b/src/storage/v2/durability/wal.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -28,7 +28,7 @@ #include "utils/file_locker.hpp" #include "utils/skip_list.hpp" -namespace storage::durability { +namespace memgraph::storage::durability { /// Structure used to hold information about a WAL. struct WalInfo { @@ -260,4 +260,4 @@ class WalFile { utils::FileRetainer *file_retainer_; }; -} // namespace storage::durability +} // namespace memgraph::storage::durability diff --git a/src/storage/v2/edge.hpp b/src/storage/v2/edge.hpp index 52c7fdf4d..fcf8ff8e7 100644 --- a/src/storage/v2/edge.hpp +++ b/src/storage/v2/edge.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "utils/logging.hpp" #include "utils/spin_lock.hpp" -namespace storage { +namespace memgraph::storage { struct Vertex; @@ -48,4 +48,4 @@ inline bool operator<(const Edge &first, const Edge &second) { return first.gid inline bool operator==(const Edge &first, const Gid &second) { return first.gid == second; } inline bool operator<(const Edge &first, const Gid &second) { return first.gid < second; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/edge_accessor.cpp b/src/storage/v2/edge_accessor.cpp index 4e004b786..ef0444422 100644 --- a/src/storage/v2/edge_accessor.cpp +++ b/src/storage/v2/edge_accessor.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "storage/v2/vertex_accessor.hpp" #include "utils/memory_tracker.hpp" -namespace storage { +namespace memgraph::storage { bool EdgeAccessor::IsVisible(const View view) const { bool deleted = true; @@ -196,4 +196,4 @@ Result> EdgeAccessor::Properties(View view) return std::move(properties); } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/edge_accessor.hpp b/src/storage/v2/edge_accessor.hpp index f848edf66..b0a1e1151 100644 --- a/src/storage/v2/edge_accessor.hpp +++ b/src/storage/v2/edge_accessor.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "storage/v2/transaction.hpp" #include "storage/v2/view.hpp" -namespace storage { +namespace memgraph::storage { struct Vertex; class VertexAccessor; @@ -102,11 +102,11 @@ class EdgeAccessor final { bool for_deleted_{false}; }; -} // namespace storage +} // namespace memgraph::storage namespace std { template <> -struct hash { - size_t operator()(const storage::EdgeAccessor &e) const { return e.Gid().AsUint(); } +struct hash { + size_t operator()(const memgraph::storage::EdgeAccessor &e) const { return e.Gid().AsUint(); } }; } // namespace std diff --git a/src/storage/v2/edge_ref.hpp b/src/storage/v2/edge_ref.hpp index 0da43864d..967dd9439 100644 --- a/src/storage/v2/edge_ref.hpp +++ b/src/storage/v2/edge_ref.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "storage/v2/id_types.hpp" -namespace storage { +namespace memgraph::storage { // Forward declaration because we only store a pointer here. struct Edge; @@ -39,4 +39,4 @@ inline bool operator==(const EdgeRef &a, const EdgeRef &b) noexcept { return a.g inline bool operator!=(const EdgeRef &a, const EdgeRef &b) noexcept { return a.gid != b.gid; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/id_types.hpp b/src/storage/v2/id_types.hpp index f7cf194f9..0a954985e 100644 --- a/src/storage/v2/id_types.hpp +++ b/src/storage/v2/id_types.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "utils/cast.hpp" -namespace storage { +namespace memgraph::storage { #define STORAGE_DEFINE_ID_TYPE(name) \ class name final { \ @@ -50,28 +50,28 @@ STORAGE_DEFINE_ID_TYPE(EdgeTypeId); #undef STORAGE_DEFINE_ID_TYPE -} // namespace storage +} // namespace memgraph::storage namespace std { template <> -struct hash { - size_t operator()(const storage::Gid &id) const noexcept { return id.AsUint(); } +struct hash { + size_t operator()(const memgraph::storage::Gid &id) const noexcept { return id.AsUint(); } }; template <> -struct hash { - size_t operator()(const storage::LabelId &id) const noexcept { return id.AsUint(); } +struct hash { + size_t operator()(const memgraph::storage::LabelId &id) const noexcept { return id.AsUint(); } }; template <> -struct hash { - size_t operator()(const storage::PropertyId &id) const noexcept { return id.AsUint(); } +struct hash { + size_t operator()(const memgraph::storage::PropertyId &id) const noexcept { return id.AsUint(); } }; template <> -struct hash { - size_t operator()(const storage::EdgeTypeId &id) const noexcept { return id.AsUint(); } +struct hash { + size_t operator()(const memgraph::storage::EdgeTypeId &id) const noexcept { return id.AsUint(); } }; } // namespace std diff --git a/src/storage/v2/indices.cpp b/src/storage/v2/indices.cpp index 64c8beb73..fb83ff166 100644 --- a/src/storage/v2/indices.cpp +++ b/src/storage/v2/indices.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/logging.hpp" #include "utils/memory_tracker.hpp" -namespace storage { +namespace memgraph::storage { namespace { @@ -709,4 +709,4 @@ void UpdateOnSetProperty(Indices *indices, PropertyId property, const PropertyVa indices->label_property_index.UpdateOnSetProperty(property, value, vertex, tx); } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/indices.hpp b/src/storage/v2/indices.hpp index 58dd89dcb..eed22e8b5 100644 --- a/src/storage/v2/indices.hpp +++ b/src/storage/v2/indices.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ #include "utils/logging.hpp" #include "utils/skip_list.hpp" -namespace storage { +namespace memgraph::storage { struct Indices; struct Constraints; @@ -279,4 +279,4 @@ void UpdateOnAddLabel(Indices *indices, LabelId label, Vertex *vertex, const Tra /// @throw std::bad_alloc void UpdateOnSetProperty(Indices *indices, PropertyId property, const PropertyValue &value, Vertex *vertex, const Transaction &tx); -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/isolation_level.hpp b/src/storage/v2/isolation_level.hpp index 9a8ff012f..b655e5e51 100644 --- a/src/storage/v2/isolation_level.hpp +++ b/src/storage/v2/isolation_level.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,8 +13,8 @@ #include -namespace storage { +namespace memgraph::storage { enum class IsolationLevel : std::uint8_t { SNAPSHOT_ISOLATION, READ_COMMITTED, READ_UNCOMMITTED }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/mvcc.hpp b/src/storage/v2/mvcc.hpp index 926c0c683..52154fe4a 100644 --- a/src/storage/v2/mvcc.hpp +++ b/src/storage/v2/mvcc.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "storage/v2/transaction.hpp" #include "storage/v2/view.hpp" -namespace storage { +namespace memgraph::storage { /// This function iterates through the undo buffers from an object (starting /// from the supplied delta) and determines what deltas should be applied to get @@ -131,4 +131,4 @@ inline void CreateAndLinkDelta(Transaction *transaction, TObj *object, Args &&.. object->delta = delta; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/name_id_mapper.hpp b/src/storage/v2/name_id_mapper.hpp index 291e6efc2..946f4dd3f 100644 --- a/src/storage/v2/name_id_mapper.hpp +++ b/src/storage/v2/name_id_mapper.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/logging.hpp" #include "utils/skip_list.hpp" -namespace storage { +namespace memgraph::storage { class NameIdMapper final { private: @@ -95,4 +95,4 @@ class NameIdMapper final { utils::SkipList name_to_id_; utils::SkipList id_to_name_; }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/property_store.cpp b/src/storage/v2/property_store.cpp index ba59ee083..db8982b6f 100644 --- a/src/storage/v2/property_store.cpp +++ b/src/storage/v2/property_store.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ #include "utils/cast.hpp" #include "utils/logging.hpp" -namespace storage { +namespace memgraph::storage { namespace { @@ -1161,4 +1161,4 @@ bool PropertyStore::ClearProperties() { return true; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/property_store.hpp b/src/storage/v2/property_store.hpp index 1db2397c9..bd397285f 100644 --- a/src/storage/v2/property_store.hpp +++ b/src/storage/v2/property_store.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,10 +16,12 @@ #include "storage/v2/id_types.hpp" #include "storage/v2/property_value.hpp" -namespace storage { +namespace memgraph::storage { class PropertyStore { - static_assert(std::endian::native == std::endian::little, "PropertyStore supports only architectures using little-endian."); + static_assert(std::endian::native == std::endian::little, + "PropertyStore supports only architectures using little-endian."); + public: PropertyStore(); @@ -67,4 +69,4 @@ class PropertyStore { uint8_t buffer_[sizeof(uint64_t) + sizeof(uint8_t *)]; }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/property_value.hpp b/src/storage/v2/property_value.hpp index 6b3120ffc..43481ac21 100644 --- a/src/storage/v2/property_value.hpp +++ b/src/storage/v2/property_value.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/algorithm.hpp" #include "utils/exceptions.hpp" -namespace storage { +namespace memgraph::storage { /// An exception raised by the PropertyValue. Typically when trying to perform /// operations (such as addition) on PropertyValues of incompatible Types. @@ -487,4 +487,4 @@ inline void PropertyValue::DestroyValue() noexcept { } } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/replication/config.hpp b/src/storage/v2/replication/config.hpp index 7ac3bd38b..93700bc66 100644 --- a/src/storage/v2/replication/config.hpp +++ b/src/storage/v2/replication/config.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include #include -namespace storage::replication { +namespace memgraph::storage::replication { struct ReplicationClientConfig { std::optional timeout; @@ -35,4 +35,4 @@ struct ReplicationServerConfig { std::optional ssl; }; -} // namespace storage::replication +} // namespace memgraph::storage::replication diff --git a/src/storage/v2/replication/enums.hpp b/src/storage/v2/replication/enums.hpp index a7680f2dd..132fb14da 100644 --- a/src/storage/v2/replication/enums.hpp +++ b/src/storage/v2/replication/enums.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -12,8 +12,8 @@ #pragma once #include -namespace storage::replication { +namespace memgraph::storage::replication { enum class ReplicationMode : std::uint8_t { SYNC, ASYNC }; enum class ReplicaState : std::uint8_t { READY, REPLICATING, RECOVERY, INVALID }; -} // namespace storage::replication +} // namespace memgraph::storage::replication diff --git a/src/storage/v2/replication/replication_client.cpp b/src/storage/v2/replication/replication_client.cpp index 707668280..1789d3936 100644 --- a/src/storage/v2/replication/replication_client.cpp +++ b/src/storage/v2/replication/replication_client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ #include "utils/logging.hpp" #include "utils/message.hpp" -namespace storage { +namespace memgraph::storage { namespace { template @@ -60,7 +60,7 @@ void Storage::ReplicationClient::InitializeClient() { epoch_id.emplace(storage_->epoch_id_); } - auto stream{rpc_client_->Stream(storage_->last_commit_timestamp_, std::move(*epoch_id))}; + auto stream{rpc_client_->Stream(storage_->last_commit_timestamp_, std::move(*epoch_id))}; const auto response = stream.AwaitResponse(); std::optional branching_point; @@ -119,16 +119,17 @@ void Storage::ReplicationClient::HandleRpcFailure() { }); } -SnapshotRes Storage::ReplicationClient::TransferSnapshot(const std::filesystem::path &path) { - auto stream{rpc_client_->Stream()}; +replication::SnapshotRes Storage::ReplicationClient::TransferSnapshot(const std::filesystem::path &path) { + auto stream{rpc_client_->Stream()}; replication::Encoder encoder(stream.GetBuilder()); encoder.WriteFile(path); return stream.AwaitResponse(); } -WalFilesRes Storage::ReplicationClient::TransferWalFiles(const std::vector &wal_files) { +replication::WalFilesRes Storage::ReplicationClient::TransferWalFiles( + const std::vector &wal_files) { MG_ASSERT(!wal_files.empty(), "Wal files list is empty!"); - auto stream{rpc_client_->Stream(wal_files.size())}; + auto stream{rpc_client_->Stream(wal_files.size())}; replication::Encoder encoder(stream.GetBuilder()); for (const auto &wal : wal_files) { spdlog::debug("Sending wal file: {}", wal); @@ -313,7 +314,7 @@ void Storage::ReplicationClient::RecoverReplica(uint64_t replica_commit) { // transaction and THEN we set the state to READY in the first thread, // we set this lock before checking the timestamp. // We will detect that the state is invalid during the next commit, - // because AppendDeltasRpc sends the last commit timestamp which + // because replication::AppendDeltasRpc sends the last commit timestamp which // replica checks if it's the same last commit timestamp it received // and we will go to recovery. // By adding this lock, we can avoid that, and go to RECOVERY immediately. @@ -530,7 +531,8 @@ void Storage::ReplicationClient::TimeoutDispatcher::StartTimeoutTask(const doubl Storage::ReplicationClient::ReplicaStream::ReplicaStream(ReplicationClient *self, const uint64_t previous_commit_timestamp, const uint64_t current_seq_num) - : self_(self), stream_(self_->rpc_client_->Stream(previous_commit_timestamp, current_seq_num)) { + : self_(self), + stream_(self_->rpc_client_->Stream(previous_commit_timestamp, current_seq_num)) { replication::Encoder encoder{stream_.GetBuilder()}; encoder.WriteString(self_->storage_->epoch_id_); } @@ -560,11 +562,11 @@ void Storage::ReplicationClient::ReplicaStream::AppendOperation(durability::Stor EncodeOperation(&encoder, &self_->storage_->name_id_mapper_, operation, label, properties, timestamp); } -AppendDeltasRes Storage::ReplicationClient::ReplicaStream::Finalize() { return stream_.AwaitResponse(); } +replication::AppendDeltasRes Storage::ReplicationClient::ReplicaStream::Finalize() { return stream_.AwaitResponse(); } ////// CurrentWalHandler ////// Storage::ReplicationClient::CurrentWalHandler::CurrentWalHandler(ReplicationClient *self) - : self_(self), stream_(self_->rpc_client_->Stream()) {} + : self_(self), stream_(self_->rpc_client_->Stream()) {} void Storage::ReplicationClient::CurrentWalHandler::AppendFilename(const std::string &filename) { replication::Encoder encoder(stream_.GetBuilder()); @@ -586,5 +588,5 @@ void Storage::ReplicationClient::CurrentWalHandler::AppendBufferData(const uint8 encoder.WriteBuffer(buffer, buffer_size); } -CurrentWalRes Storage::ReplicationClient::CurrentWalHandler::Finalize() { return stream_.AwaitResponse(); } -} // namespace storage +replication::CurrentWalRes Storage::ReplicationClient::CurrentWalHandler::Finalize() { return stream_.AwaitResponse(); } +} // namespace memgraph::storage diff --git a/src/storage/v2/replication/replication_client.hpp b/src/storage/v2/replication/replication_client.hpp index 08b5142ac..6078e1f4e 100644 --- a/src/storage/v2/replication/replication_client.hpp +++ b/src/storage/v2/replication/replication_client.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -35,7 +35,7 @@ #include "utils/synchronized.hpp" #include "utils/thread_pool.hpp" -namespace storage { +namespace memgraph::storage { class Storage::ReplicationClient { public: @@ -64,10 +64,10 @@ class Storage::ReplicationClient { private: /// @throw rpc::RpcFailedException - AppendDeltasRes Finalize(); + replication::AppendDeltasRes Finalize(); ReplicationClient *self_; - rpc::Client::StreamHandler stream_; + rpc::Client::StreamHandler stream_; }; // Handler for transfering the current WAL file whose data is @@ -87,11 +87,11 @@ class Storage::ReplicationClient { void AppendBufferData(const uint8_t *buffer, size_t buffer_size); /// @throw rpc::RpcFailedException - CurrentWalRes Finalize(); + replication::CurrentWalRes Finalize(); private: ReplicationClient *self_; - rpc::Client::StreamHandler stream_; + rpc::Client::StreamHandler stream_; }; void StartTransactionReplication(uint64_t current_wal_seq_num); @@ -107,12 +107,12 @@ class Storage::ReplicationClient { // Transfer the snapshot file. // @param path Path of the snapshot file. - SnapshotRes TransferSnapshot(const std::filesystem::path &path); + replication::SnapshotRes TransferSnapshot(const std::filesystem::path &path); CurrentWalHandler TransferCurrentWalFile() { return CurrentWalHandler{this}; } // Transfer the WAL files - WalFilesRes TransferWalFiles(const std::vector &wal_files); + replication::WalFilesRes TransferWalFiles(const std::vector &wal_files); const auto &Name() const { return name_; } @@ -200,4 +200,4 @@ class Storage::ReplicationClient { std::atomic replica_state_{replication::ReplicaState::INVALID}; }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/replication/replication_server.cpp b/src/storage/v2/replication/replication_server.cpp index 26bded4d5..2193c6667 100644 --- a/src/storage/v2/replication/replication_server.cpp +++ b/src/storage/v2/replication/replication_server.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ #include "storage/v2/transaction.hpp" #include "utils/exceptions.hpp" -namespace storage { +namespace memgraph::storage { namespace { std::pair ReadDelta(durability::BaseDecoder *decoder) { try { @@ -31,7 +31,7 @@ std::pair ReadDelta(durability::BaseDecoder SPDLOG_INFO(" Timestamp {}", timestamp); auto delta = ReadWalDeltaData(decoder); return {timestamp, delta}; - } catch (const slk::SlkReaderException &) { + } catch (const memgraph::slk::SlkReaderException &) { throw utils::BasicException("Missing data!"); } catch (const durability::RecoveryFailure &) { throw utils::BasicException("Invalid data!"); @@ -56,39 +56,41 @@ Storage::ReplicationServer::ReplicationServer(Storage *storage, io::network::End rpc_server_.emplace(std::move(endpoint), &*rpc_server_context_, /* workers_count = */ 1); - rpc_server_->Register([this](auto *req_reader, auto *res_builder) { + rpc_server_->Register([this](auto *req_reader, auto *res_builder) { spdlog::debug("Received HeartbeatRpc"); this->HeartbeatHandler(req_reader, res_builder); }); - rpc_server_->Register([this](auto *req_reader, auto *res_builder) { + rpc_server_->Register([this](auto *req_reader, auto *res_builder) { spdlog::debug("Received AppendDeltasRpc"); this->AppendDeltasHandler(req_reader, res_builder); }); - rpc_server_->Register([this](auto *req_reader, auto *res_builder) { + rpc_server_->Register([this](auto *req_reader, auto *res_builder) { spdlog::debug("Received SnapshotRpc"); this->SnapshotHandler(req_reader, res_builder); }); - rpc_server_->Register([this](auto *req_reader, auto *res_builder) { + rpc_server_->Register([this](auto *req_reader, auto *res_builder) { spdlog::debug("Received WalFilesRpc"); this->WalFilesHandler(req_reader, res_builder); }); - rpc_server_->Register([this](auto *req_reader, auto *res_builder) { + rpc_server_->Register([this](auto *req_reader, auto *res_builder) { spdlog::debug("Received CurrentWalRpc"); this->CurrentWalHandler(req_reader, res_builder); }); rpc_server_->Start(); } -void Storage::ReplicationServer::HeartbeatHandler(slk::Reader *req_reader, slk::Builder *res_builder) { - HeartbeatReq req; - slk::Load(&req, req_reader); - HeartbeatRes res{true, storage_->last_commit_timestamp_.load(), storage_->epoch_id_}; - slk::Save(res, res_builder); +void Storage::ReplicationServer::HeartbeatHandler(memgraph::slk::Reader *req_reader, + memgraph::slk::Builder *res_builder) { + replication::HeartbeatReq req; + memgraph::slk::Load(&req, req_reader); + replication::HeartbeatRes res{true, storage_->last_commit_timestamp_.load(), storage_->epoch_id_}; + memgraph::slk::Save(res, res_builder); } -void Storage::ReplicationServer::AppendDeltasHandler(slk::Reader *req_reader, slk::Builder *res_builder) { - AppendDeltasReq req; - slk::Load(&req, req_reader); +void Storage::ReplicationServer::AppendDeltasHandler(memgraph::slk::Reader *req_reader, + memgraph::slk::Builder *res_builder) { + replication::AppendDeltasReq req; + memgraph::slk::Load(&req, req_reader); replication::Decoder decoder(req_reader); @@ -122,20 +124,21 @@ void Storage::ReplicationServer::AppendDeltasHandler(slk::Reader *req_reader, sl transaction_complete = durability::IsWalDeltaDataTypeTransactionEnd(delta.type); } - AppendDeltasRes res{false, storage_->last_commit_timestamp_.load()}; - slk::Save(res, res_builder); + replication::AppendDeltasRes res{false, storage_->last_commit_timestamp_.load()}; + memgraph::slk::Save(res, res_builder); return; } ReadAndApplyDelta(&decoder); - AppendDeltasRes res{true, storage_->last_commit_timestamp_.load()}; - slk::Save(res, res_builder); + replication::AppendDeltasRes res{true, storage_->last_commit_timestamp_.load()}; + memgraph::slk::Save(res, res_builder); } -void Storage::ReplicationServer::SnapshotHandler(slk::Reader *req_reader, slk::Builder *res_builder) { - SnapshotReq req; - slk::Load(&req, req_reader); +void Storage::ReplicationServer::SnapshotHandler(memgraph::slk::Reader *req_reader, + memgraph::slk::Builder *res_builder) { + replication::SnapshotReq req; + memgraph::slk::Load(&req, req_reader); replication::Decoder decoder(req_reader); @@ -176,8 +179,8 @@ void Storage::ReplicationServer::SnapshotHandler(slk::Reader *req_reader, slk::B } storage_guard.unlock(); - SnapshotRes res{true, storage_->last_commit_timestamp_.load()}; - slk::Save(res, res_builder); + replication::SnapshotRes res{true, storage_->last_commit_timestamp_.load()}; + memgraph::slk::Save(res, res_builder); // Delete other durability files auto snapshot_files = durability::GetSnapshotFiles(storage_->snapshot_directory_, storage_->uuid_); @@ -197,9 +200,10 @@ void Storage::ReplicationServer::SnapshotHandler(slk::Reader *req_reader, slk::B } } -void Storage::ReplicationServer::WalFilesHandler(slk::Reader *req_reader, slk::Builder *res_builder) { - WalFilesReq req; - slk::Load(&req, req_reader); +void Storage::ReplicationServer::WalFilesHandler(memgraph::slk::Reader *req_reader, + memgraph::slk::Builder *res_builder) { + replication::WalFilesReq req; + memgraph::slk::Load(&req, req_reader); const auto wal_file_number = req.file_number; spdlog::debug("Received WAL files: {}", wal_file_number); @@ -212,13 +216,14 @@ void Storage::ReplicationServer::WalFilesHandler(slk::Reader *req_reader, slk::B LoadWal(&decoder); } - WalFilesRes res{true, storage_->last_commit_timestamp_.load()}; - slk::Save(res, res_builder); + replication::WalFilesRes res{true, storage_->last_commit_timestamp_.load()}; + memgraph::slk::Save(res, res_builder); } -void Storage::ReplicationServer::CurrentWalHandler(slk::Reader *req_reader, slk::Builder *res_builder) { - CurrentWalReq req; - slk::Load(&req, req_reader); +void Storage::ReplicationServer::CurrentWalHandler(memgraph::slk::Reader *req_reader, + memgraph::slk::Builder *res_builder) { + replication::CurrentWalReq req; + memgraph::slk::Load(&req, req_reader); replication::Decoder decoder(req_reader); @@ -226,8 +231,8 @@ void Storage::ReplicationServer::CurrentWalHandler(slk::Reader *req_reader, slk: LoadWal(&decoder); - CurrentWalRes res{true, storage_->last_commit_timestamp_.load()}; - slk::Save(res, res_builder); + replication::CurrentWalRes res{true, storage_->last_commit_timestamp_.load()}; + memgraph::slk::Save(res, res_builder); } void Storage::ReplicationServer::LoadWal(replication::Decoder *decoder) { @@ -559,4 +564,4 @@ uint64_t Storage::ReplicationServer::ReadAndApplyDelta(durability::BaseDecoder * return applied_deltas; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/replication/replication_server.hpp b/src/storage/v2/replication/replication_server.hpp index bab58da28..113b56d62 100644 --- a/src/storage/v2/replication/replication_server.hpp +++ b/src/storage/v2/replication/replication_server.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include "storage/v2/storage.hpp" -namespace storage { +namespace memgraph::storage { class Storage::ReplicationServer { public: @@ -28,11 +28,11 @@ class Storage::ReplicationServer { private: // RPC handlers - void HeartbeatHandler(slk::Reader *req_reader, slk::Builder *res_builder); - void AppendDeltasHandler(slk::Reader *req_reader, slk::Builder *res_builder); - void SnapshotHandler(slk::Reader *req_reader, slk::Builder *res_builder); - void WalFilesHandler(slk::Reader *req_reader, slk::Builder *res_builder); - void CurrentWalHandler(slk::Reader *req_reader, slk::Builder *res_builder); + void HeartbeatHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); + void AppendDeltasHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); + void SnapshotHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); + void WalFilesHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); + void CurrentWalHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); void LoadWal(replication::Decoder *decoder); uint64_t ReadAndApplyDelta(durability::BaseDecoder *decoder); @@ -43,4 +43,4 @@ class Storage::ReplicationServer { Storage *storage_; }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/replication/rpc.lcp b/src/storage/v2/replication/rpc.lcp index bfd6f53b4..dd9e155b9 100644 --- a/src/storage/v2/replication/rpc.lcp +++ b/src/storage/v2/replication/rpc.lcp @@ -1,4 +1,4 @@ -;; Copyright 2021 Memgraph Ltd. +;; Copyright 2022 Memgraph Ltd. ;; ;; Use of this software is governed by the Business Source License ;; included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,9 +20,9 @@ #include "slk/serialization.hpp" #include "slk/streams.hpp" cpp<# -;; TODO(antonio2368): Change namespace to `storage::replication` once LCP is -;; updated to support such namespaces. +(lcp:namespace memgraph) (lcp:namespace storage) +(lcp:namespace replication) (lcp:define-rpc append-deltas ;; The actual deltas are sent as additional data using the RPC client's @@ -61,4 +61,6 @@ cpp<# ((success :bool) (current-commit-timestamp :uint64_t)))) +(lcp:pop-namespace) ;; replication (lcp:pop-namespace) ;; storage +(lcp:pop-namespace) ;; memgraph diff --git a/src/storage/v2/replication/serialization.cpp b/src/storage/v2/replication/serialization.cpp index 52f5eb6fd..a91ea90f5 100644 --- a/src/storage/v2/replication/serialization.cpp +++ b/src/storage/v2/replication/serialization.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,33 +11,33 @@ #include "storage/v2/replication/serialization.hpp" -namespace storage::replication { +namespace memgraph::storage::replication { ////// Encoder ////// -void Encoder::WriteMarker(durability::Marker marker) { slk::Save(marker, builder_); } +void Encoder::WriteMarker(durability::Marker marker) { memgraph::slk::Save(marker, builder_); } void Encoder::WriteBool(bool value) { WriteMarker(durability::Marker::TYPE_BOOL); - slk::Save(value, builder_); + memgraph::slk::Save(value, builder_); } void Encoder::WriteUint(uint64_t value) { WriteMarker(durability::Marker::TYPE_INT); - slk::Save(value, builder_); + memgraph::slk::Save(value, builder_); } void Encoder::WriteDouble(double value) { WriteMarker(durability::Marker::TYPE_DOUBLE); - slk::Save(value, builder_); + memgraph::slk::Save(value, builder_); } void Encoder::WriteString(const std::string_view &value) { WriteMarker(durability::Marker::TYPE_STRING); - slk::Save(value, builder_); + memgraph::slk::Save(value, builder_); } void Encoder::WritePropertyValue(const PropertyValue &value) { WriteMarker(durability::Marker::TYPE_PROPERTY_VALUE); - slk::Save(value, builder_); + memgraph::slk::Save(value, builder_); } void Encoder::WriteBuffer(const uint8_t *buffer, const size_t buffer_size) { builder_->Save(buffer, buffer_size); } @@ -68,35 +68,35 @@ void Encoder::WriteFile(const std::filesystem::path &path) { ////// Decoder ////// std::optional Decoder::ReadMarker() { durability::Marker marker; - slk::Load(&marker, reader_); + memgraph::slk::Load(&marker, reader_); return marker; } std::optional Decoder::ReadBool() { if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_BOOL) return std::nullopt; bool value; - slk::Load(&value, reader_); + memgraph::slk::Load(&value, reader_); return value; } std::optional Decoder::ReadUint() { if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_INT) return std::nullopt; uint64_t value; - slk::Load(&value, reader_); + memgraph::slk::Load(&value, reader_); return value; } std::optional Decoder::ReadDouble() { if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_DOUBLE) return std::nullopt; double value; - slk::Load(&value, reader_); + memgraph::slk::Load(&value, reader_); return value; } std::optional Decoder::ReadString() { if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_STRING) return std::nullopt; std::string value; - slk::Load(&value, reader_); + memgraph::slk::Load(&value, reader_); return std::move(value); } @@ -104,21 +104,21 @@ std::optional Decoder::ReadPropertyValue() { if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_PROPERTY_VALUE) return std::nullopt; PropertyValue value; - slk::Load(&value, reader_); + memgraph::slk::Load(&value, reader_); return std::move(value); } bool Decoder::SkipString() { if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_STRING) return false; std::string value; - slk::Load(&value, reader_); + memgraph::slk::Load(&value, reader_); return true; } bool Decoder::SkipPropertyValue() { if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_PROPERTY_VALUE) return false; PropertyValue value; - slk::Load(&value, reader_); + memgraph::slk::Load(&value, reader_); return true; } @@ -146,4 +146,4 @@ std::optional Decoder::ReadFile(const std::filesystem::pa file.Close(); return std::move(path); } -} // namespace storage::replication +} // namespace memgraph::storage::replication diff --git a/src/storage/v2/replication/serialization.hpp b/src/storage/v2/replication/serialization.hpp index 21c7fda29..020cacef8 100644 --- a/src/storage/v2/replication/serialization.hpp +++ b/src/storage/v2/replication/serialization.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,11 +19,11 @@ #include "utils/cast.hpp" #include "utils/file.hpp" -namespace storage::replication { +namespace memgraph::storage::replication { class Encoder final : public durability::BaseEncoder { public: - explicit Encoder(slk::Builder *builder) : builder_(builder) {} + explicit Encoder(memgraph::slk::Builder *builder) : builder_(builder) {} void WriteMarker(durability::Marker marker) override; @@ -44,12 +44,12 @@ class Encoder final : public durability::BaseEncoder { void WriteFile(const std::filesystem::path &path); private: - slk::Builder *builder_; + memgraph::slk::Builder *builder_; }; class Decoder final : public durability::BaseDecoder { public: - explicit Decoder(slk::Reader *reader) : reader_(reader) {} + explicit Decoder(memgraph::slk::Reader *reader) : reader_(reader) {} std::optional ReadMarker() override; @@ -74,7 +74,7 @@ class Decoder final : public durability::BaseDecoder { std::optional ReadFile(const std::filesystem::path &directory, const std::string &suffix = ""); private: - slk::Reader *reader_; + memgraph::slk::Reader *reader_; }; -} // namespace storage::replication +} // namespace memgraph::storage::replication diff --git a/src/storage/v2/replication/slk.cpp b/src/storage/v2/replication/slk.cpp index 376060828..eded10cbe 100644 --- a/src/storage/v2/replication/slk.cpp +++ b/src/storage/v2/replication/slk.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,153 +17,155 @@ #include "storage/v2/temporal.hpp" #include "utils/cast.hpp" -namespace slk { +namespace memgraph::slk { -void Save(const storage::Gid &gid, slk::Builder *builder) { slk::Save(gid.AsUint(), builder); } - -void Load(storage::Gid *gid, slk::Reader *reader) { - uint64_t value; - slk::Load(&value, reader); - *gid = storage::Gid::FromUint(value); +void Save(const memgraph::storage::Gid &gid, memgraph::slk::Builder *builder) { + memgraph::slk::Save(gid.AsUint(), builder); } -void Load(storage::PropertyValue::Type *type, slk::Reader *reader) { - using PVTypeUnderlyingType = std::underlying_type_t; +void Load(memgraph::storage::Gid *gid, memgraph::slk::Reader *reader) { + uint64_t value; + memgraph::slk::Load(&value, reader); + *gid = memgraph::storage::Gid::FromUint(value); +} + +void Load(memgraph::storage::PropertyValue::Type *type, memgraph::slk::Reader *reader) { + using PVTypeUnderlyingType = std::underlying_type_t; PVTypeUnderlyingType value; - slk::Load(&value, reader); + memgraph::slk::Load(&value, reader); bool valid; switch (value) { - case utils::UnderlyingCast(storage::PropertyValue::Type::Null): - case utils::UnderlyingCast(storage::PropertyValue::Type::Bool): - case utils::UnderlyingCast(storage::PropertyValue::Type::Int): - case utils::UnderlyingCast(storage::PropertyValue::Type::Double): - case utils::UnderlyingCast(storage::PropertyValue::Type::String): - case utils::UnderlyingCast(storage::PropertyValue::Type::List): - case utils::UnderlyingCast(storage::PropertyValue::Type::Map): - case utils::UnderlyingCast(storage::PropertyValue::Type::TemporalData): + case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Null): + case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Bool): + case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Int): + case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Double): + case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::String): + case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::List): + case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Map): + case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::TemporalData): valid = true; break; default: valid = false; break; } - if (!valid) throw slk::SlkDecodeException("Trying to load unknown storage::PropertyValue!"); - *type = static_cast(value); + if (!valid) throw slk::SlkDecodeException("Trying to load unknown memgraph::storage::PropertyValue!"); + *type = static_cast(value); } -void Save(const storage::PropertyValue &value, slk::Builder *builder) { +void Save(const memgraph::storage::PropertyValue &value, memgraph::slk::Builder *builder) { switch (value.type()) { - case storage::PropertyValue::Type::Null: - slk::Save(storage::PropertyValue::Type::Null, builder); + case memgraph::storage::PropertyValue::Type::Null: + memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Null, builder); return; - case storage::PropertyValue::Type::Bool: - slk::Save(storage::PropertyValue::Type::Bool, builder); - slk::Save(value.ValueBool(), builder); + case memgraph::storage::PropertyValue::Type::Bool: + memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Bool, builder); + memgraph::slk::Save(value.ValueBool(), builder); return; - case storage::PropertyValue::Type::Int: - slk::Save(storage::PropertyValue::Type::Int, builder); - slk::Save(value.ValueInt(), builder); + case memgraph::storage::PropertyValue::Type::Int: + memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Int, builder); + memgraph::slk::Save(value.ValueInt(), builder); return; - case storage::PropertyValue::Type::Double: - slk::Save(storage::PropertyValue::Type::Double, builder); - slk::Save(value.ValueDouble(), builder); + case memgraph::storage::PropertyValue::Type::Double: + memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Double, builder); + memgraph::slk::Save(value.ValueDouble(), builder); return; - case storage::PropertyValue::Type::String: - slk::Save(storage::PropertyValue::Type::String, builder); - slk::Save(value.ValueString(), builder); + case memgraph::storage::PropertyValue::Type::String: + memgraph::slk::Save(memgraph::storage::PropertyValue::Type::String, builder); + memgraph::slk::Save(value.ValueString(), builder); return; - case storage::PropertyValue::Type::List: { - slk::Save(storage::PropertyValue::Type::List, builder); + case memgraph::storage::PropertyValue::Type::List: { + memgraph::slk::Save(memgraph::storage::PropertyValue::Type::List, builder); const auto &values = value.ValueList(); size_t size = values.size(); - slk::Save(size, builder); + memgraph::slk::Save(size, builder); for (const auto &v : values) { - slk::Save(v, builder); + memgraph::slk::Save(v, builder); } return; } - case storage::PropertyValue::Type::Map: { - slk::Save(storage::PropertyValue::Type::Map, builder); + case memgraph::storage::PropertyValue::Type::Map: { + memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Map, builder); const auto &map = value.ValueMap(); size_t size = map.size(); - slk::Save(size, builder); + memgraph::slk::Save(size, builder); for (const auto &kv : map) { - slk::Save(kv, builder); + memgraph::slk::Save(kv, builder); } return; } - case storage::PropertyValue::Type::TemporalData: { - slk::Save(storage::PropertyValue::Type::TemporalData, builder); + case memgraph::storage::PropertyValue::Type::TemporalData: { + memgraph::slk::Save(memgraph::storage::PropertyValue::Type::TemporalData, builder); const auto temporal_data = value.ValueTemporalData(); - slk::Save(temporal_data.type, builder); - slk::Save(temporal_data.microseconds, builder); + memgraph::slk::Save(temporal_data.type, builder); + memgraph::slk::Save(temporal_data.microseconds, builder); return; } } } -void Load(storage::PropertyValue *value, slk::Reader *reader) { - storage::PropertyValue::Type type; - slk::Load(&type, reader); +void Load(memgraph::storage::PropertyValue *value, memgraph::slk::Reader *reader) { + memgraph::storage::PropertyValue::Type type; + memgraph::slk::Load(&type, reader); switch (type) { - case storage::PropertyValue::Type::Null: - *value = storage::PropertyValue(); + case memgraph::storage::PropertyValue::Type::Null: + *value = memgraph::storage::PropertyValue(); return; - case storage::PropertyValue::Type::Bool: { + case memgraph::storage::PropertyValue::Type::Bool: { bool v; - slk::Load(&v, reader); - *value = storage::PropertyValue(v); + memgraph::slk::Load(&v, reader); + *value = memgraph::storage::PropertyValue(v); return; } - case storage::PropertyValue::Type::Int: { + case memgraph::storage::PropertyValue::Type::Int: { int64_t v; - slk::Load(&v, reader); - *value = storage::PropertyValue(v); + memgraph::slk::Load(&v, reader); + *value = memgraph::storage::PropertyValue(v); return; } - case storage::PropertyValue::Type::Double: { + case memgraph::storage::PropertyValue::Type::Double: { double v; - slk::Load(&v, reader); - *value = storage::PropertyValue(v); + memgraph::slk::Load(&v, reader); + *value = memgraph::storage::PropertyValue(v); return; } - case storage::PropertyValue::Type::String: { + case memgraph::storage::PropertyValue::Type::String: { std::string v; - slk::Load(&v, reader); - *value = storage::PropertyValue(std::move(v)); + memgraph::slk::Load(&v, reader); + *value = memgraph::storage::PropertyValue(std::move(v)); return; } - case storage::PropertyValue::Type::List: { + case memgraph::storage::PropertyValue::Type::List: { size_t size; - slk::Load(&size, reader); - std::vector list(size); + memgraph::slk::Load(&size, reader); + std::vector list(size); for (size_t i = 0; i < size; ++i) { - slk::Load(&list[i], reader); + memgraph::slk::Load(&list[i], reader); } - *value = storage::PropertyValue(std::move(list)); + *value = memgraph::storage::PropertyValue(std::move(list)); return; } - case storage::PropertyValue::Type::Map: { + case memgraph::storage::PropertyValue::Type::Map: { size_t size; - slk::Load(&size, reader); - std::map map; + memgraph::slk::Load(&size, reader); + std::map map; for (size_t i = 0; i < size; ++i) { - std::pair kv; - slk::Load(&kv, reader); + std::pair kv; + memgraph::slk::Load(&kv, reader); map.insert(kv); } - *value = storage::PropertyValue(std::move(map)); + *value = memgraph::storage::PropertyValue(std::move(map)); return; } - case storage::PropertyValue::Type::TemporalData: { - storage::TemporalType temporal_type; - slk::Load(&temporal_type, reader); + case memgraph::storage::PropertyValue::Type::TemporalData: { + memgraph::storage::TemporalType temporal_type; + memgraph::slk::Load(&temporal_type, reader); int64_t microseconds{0}; - slk::Load(µseconds, reader); - *value = storage::PropertyValue(storage::TemporalData{temporal_type, microseconds}); + memgraph::slk::Load(µseconds, reader); + *value = memgraph::storage::PropertyValue(memgraph::storage::TemporalData{temporal_type, microseconds}); return; } } } -} // namespace slk +} // namespace memgraph::slk diff --git a/src/storage/v2/replication/slk.hpp b/src/storage/v2/replication/slk.hpp index db69826e1..f3b020a2f 100644 --- a/src/storage/v2/replication/slk.hpp +++ b/src/storage/v2/replication/slk.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,25 +17,25 @@ #include "storage/v2/property_value.hpp" #include "utils/concepts.hpp" -namespace slk { +namespace memgraph::slk { -void Save(const storage::Gid &gid, slk::Builder *builder); -void Load(storage::Gid *gid, slk::Reader *reader); +void Save(const memgraph::storage::Gid &gid, memgraph::slk::Builder *builder); +void Load(memgraph::storage::Gid *gid, memgraph::slk::Reader *reader); -void Save(const storage::PropertyValue &value, slk::Builder *builder); -void Load(storage::PropertyValue *value, slk::Reader *reader); +void Save(const memgraph::storage::PropertyValue &value, memgraph::slk::Builder *builder); +void Load(memgraph::storage::PropertyValue *value, memgraph::slk::Reader *reader); template -void Save(const T &enum_value, slk::Builder *builder) { - slk::Save(utils::UnderlyingCast(enum_value), builder); +void Save(const T &enum_value, memgraph::slk::Builder *builder) { + memgraph::slk::Save(utils::UnderlyingCast(enum_value), builder); } template -void Load(T *enum_value, slk::Reader *reader) { +void Load(T *enum_value, memgraph::slk::Reader *reader) { using UnderlyingType = std::underlying_type_t; UnderlyingType value; - slk::Load(&value, reader); + memgraph::slk::Load(&value, reader); *enum_value = static_cast(value); } -} // namespace slk +} // namespace memgraph::slk diff --git a/src/storage/v2/result.hpp b/src/storage/v2/result.hpp index 933540205..e50f32cf3 100644 --- a/src/storage/v2/result.hpp +++ b/src/storage/v2/result.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "utils/result.hpp" -namespace storage { +namespace memgraph::storage { static_assert(std::is_same_v); @@ -30,4 +30,4 @@ enum class Error : uint8_t { template using Result = utils::BasicResult; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/storage.cpp b/src/storage/v2/storage.cpp index 10655afd6..5d00b5e75 100644 --- a/src/storage/v2/storage.cpp +++ b/src/storage/v2/storage.cpp @@ -44,7 +44,7 @@ #include "storage/v2/replication/replication_server.hpp" #include "storage/v2/replication/rpc.hpp" -namespace storage { +namespace memgraph::storage { using OOMExceptionEnabler = utils::MemoryTracker::OutOfMemoryExceptionEnabler; @@ -1174,7 +1174,7 @@ IndicesInfo Storage::ListAllIndices() const { utils::BasicResult Storage::CreateExistenceConstraint( LabelId label, PropertyId property, const std::optional desired_commit_timestamp) { std::unique_lock storage_guard(main_lock_); - auto ret = ::storage::CreateExistenceConstraint(&constraints_, label, property, vertices_.access()); + auto ret = storage::CreateExistenceConstraint(&constraints_, label, property, vertices_.access()); if (ret.HasError() || !ret.GetValue()) return ret; const auto commit_timestamp = CommitTimestamp(desired_commit_timestamp); AppendToWal(durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_CREATE, label, {property}, commit_timestamp); @@ -1186,7 +1186,7 @@ utils::BasicResult Storage::CreateExistenceConstraint bool Storage::DropExistenceConstraint(LabelId label, PropertyId property, const std::optional desired_commit_timestamp) { std::unique_lock storage_guard(main_lock_); - if (!::storage::DropExistenceConstraint(&constraints_, label, property)) return false; + if (!storage::DropExistenceConstraint(&constraints_, label, property)) return false; const auto commit_timestamp = CommitTimestamp(desired_commit_timestamp); AppendToWal(durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_DROP, label, {property}, commit_timestamp); commit_log_->MarkFinished(commit_timestamp); @@ -1944,4 +1944,4 @@ void Storage::SetIsolationLevel(IsolationLevel isolation_level) { isolation_level_ = isolation_level; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/storage.hpp b/src/storage/v2/storage.hpp index e511dc2ac..7b20dc20b 100644 --- a/src/storage/v2/storage.hpp +++ b/src/storage/v2/storage.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -48,7 +48,7 @@ #include "storage/v2/replication/rpc.hpp" #include "storage/v2/replication/serialization.hpp" -namespace storage { +namespace memgraph::storage { // The storage is based on this paper: // https://db.in.tum.de/~muehlbau/papers/mvcc.pdf @@ -589,4 +589,4 @@ class Storage final { std::atomic replication_role_{ReplicationRole::MAIN}; }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/temporal.cpp b/src/storage/v2/temporal.cpp index 03e21c43c..6bbd59b8a 100644 --- a/src/storage/v2/temporal.cpp +++ b/src/storage/v2/temporal.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "storage/v2/temporal.hpp" -namespace storage { +namespace memgraph::storage { TemporalData::TemporalData(TemporalType type, int64_t microseconds) : type{type}, microseconds{microseconds} {} -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/temporal.hpp b/src/storage/v2/temporal.hpp index 969a52685..1c10a2769 100644 --- a/src/storage/v2/temporal.hpp +++ b/src/storage/v2/temporal.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "utils/temporal.hpp" -namespace storage { +namespace memgraph::storage { enum class TemporalType : uint8_t { Date = 0, LocalTime, LocalDateTime, Duration }; @@ -53,4 +53,4 @@ struct TemporalData { int64_t microseconds; }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/transaction.hpp b/src/storage/v2/transaction.hpp index 5e2a81b22..d7a770598 100644 --- a/src/storage/v2/transaction.hpp +++ b/src/storage/v2/transaction.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -25,7 +25,7 @@ #include "storage/v2/vertex.hpp" #include "storage/v2/view.hpp" -namespace storage { +namespace memgraph::storage { const uint64_t kTimestampInitialId = 0; const uint64_t kTransactionInitialId = 1ULL << 63U; @@ -81,4 +81,4 @@ inline bool operator<(const Transaction &first, const Transaction &second) { inline bool operator==(const Transaction &first, const uint64_t &second) { return first.transaction_id == second; } inline bool operator<(const Transaction &first, const uint64_t &second) { return first.transaction_id < second; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/vertex.hpp b/src/storage/v2/vertex.hpp index 1a0d6ad2c..83f517c46 100644 --- a/src/storage/v2/vertex.hpp +++ b/src/storage/v2/vertex.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "storage/v2/property_store.hpp" #include "utils/spin_lock.hpp" -namespace storage { +namespace memgraph::storage { struct Vertex { Vertex(Gid gid, Delta *delta) : gid(gid), deleted(false), delta(delta) { @@ -52,4 +52,4 @@ inline bool operator<(const Vertex &first, const Vertex &second) { return first. inline bool operator==(const Vertex &first, const Gid &second) { return first.gid == second; } inline bool operator<(const Vertex &first, const Gid &second) { return first.gid < second; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/vertex_accessor.cpp b/src/storage/v2/vertex_accessor.cpp index 01a16dbde..05ba1ebcc 100644 --- a/src/storage/v2/vertex_accessor.cpp +++ b/src/storage/v2/vertex_accessor.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "utils/logging.hpp" #include "utils/memory_tracker.hpp" -namespace storage { +namespace memgraph::storage { namespace detail { namespace { @@ -575,4 +575,4 @@ Result VertexAccessor::OutDegree(View view) const { return degree; } -} // namespace storage +} // namespace memgraph::storage diff --git a/src/storage/v2/vertex_accessor.hpp b/src/storage/v2/vertex_accessor.hpp index 69cb7fe52..840eec910 100644 --- a/src/storage/v2/vertex_accessor.hpp +++ b/src/storage/v2/vertex_accessor.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "storage/v2/transaction.hpp" #include "storage/v2/view.hpp" -namespace storage { +namespace memgraph::storage { class EdgeAccessor; class Storage; @@ -118,11 +118,11 @@ class VertexAccessor final { bool for_deleted_{false}; }; -} // namespace storage +} // namespace memgraph::storage namespace std { template <> -struct hash { - size_t operator()(const storage::VertexAccessor &v) const noexcept { return v.Gid().AsUint(); } +struct hash { + size_t operator()(const memgraph::storage::VertexAccessor &v) const noexcept { return v.Gid().AsUint(); } }; } // namespace std diff --git a/src/storage/v2/view.hpp b/src/storage/v2/view.hpp index 3d69df715..7d34beb24 100644 --- a/src/storage/v2/view.hpp +++ b/src/storage/v2/view.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #pragma once -namespace storage { +namespace memgraph::storage { /// Indicator for obtaining the state before or after a transaction & command. enum class View { @@ -19,4 +19,4 @@ enum class View { NEW, }; -} // namespace storage +} // namespace memgraph::storage diff --git a/src/telemetry/collectors.cpp b/src/telemetry/collectors.cpp index 4ef9d6ff2..5cd8be1f8 100644 --- a/src/telemetry/collectors.cpp +++ b/src/telemetry/collectors.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ #include "utils/stat.hpp" #include "utils/string.hpp" -namespace telemetry { +namespace memgraph::telemetry { const std::pair GetCpuUsage(pid_t pid, pid_t tid = 0) { std::string name; @@ -82,4 +82,4 @@ const nlohmann::json GetResourceUsage() { return {{"cpu", cpu}, {"memory", utils::GetMemoryUsage()}}; } -} // namespace telemetry +} // namespace memgraph::telemetry diff --git a/src/telemetry/collectors.hpp b/src/telemetry/collectors.hpp index 4862645a6..2d68c8ab2 100644 --- a/src/telemetry/collectors.hpp +++ b/src/telemetry/collectors.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace telemetry { +namespace memgraph::telemetry { /** * This function returs a dictionary containing resource usage information @@ -21,4 +21,4 @@ namespace telemetry { */ const nlohmann::json GetResourceUsage(); -} // namespace telemetry +} // namespace memgraph::telemetry diff --git a/src/telemetry/system_info.cpp b/src/telemetry/system_info.cpp index 00ab659b5..735dda3eb 100644 --- a/src/telemetry/system_info.cpp +++ b/src/telemetry/system_info.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/file.hpp" #include "utils/string.hpp" -namespace telemetry { +namespace memgraph::telemetry { const nlohmann::json GetSystemInfo() { // Get `uname`. @@ -85,4 +85,4 @@ const nlohmann::json GetSystemInfo() { {"version", gflags::VersionString()}}; } -} // namespace telemetry +} // namespace memgraph::telemetry diff --git a/src/telemetry/system_info.hpp b/src/telemetry/system_info.hpp index 60768ffd7..efaa81bf4 100644 --- a/src/telemetry/system_info.hpp +++ b/src/telemetry/system_info.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace telemetry { +namespace memgraph::telemetry { // TODO (mferencevic): merge with `utils/sysinfo` @@ -23,4 +23,4 @@ namespace telemetry { */ const nlohmann::json GetSystemInfo(); -} // namespace telemetry +} // namespace memgraph::telemetry diff --git a/src/telemetry/telemetry.cpp b/src/telemetry/telemetry.cpp index bcb662774..028cd9384 100644 --- a/src/telemetry/telemetry.cpp +++ b/src/telemetry/telemetry.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ #include "utils/timestamp.hpp" #include "utils/uuid.hpp" -namespace telemetry { +namespace memgraph::telemetry { namespace { std::string GetMachineId() { #ifdef MG_TELEMETRY_ID_OVERRIDE @@ -120,4 +120,4 @@ void Telemetry::CollectData(const std::string &event) { const nlohmann::json Telemetry::GetUptime() { return timer_.Elapsed().count(); } -} // namespace telemetry +} // namespace memgraph::telemetry diff --git a/src/telemetry/telemetry.hpp b/src/telemetry/telemetry.hpp index e4ddb4eda..5ff53bba7 100644 --- a/src/telemetry/telemetry.hpp +++ b/src/telemetry/telemetry.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/scheduler.hpp" #include "utils/timer.hpp" -namespace telemetry { +namespace memgraph::telemetry { /** * This class implements the telemetry collector service. It periodically scapes @@ -68,4 +68,4 @@ class Telemetry final { kvstore::KVStore storage_; }; -} // namespace telemetry +} // namespace memgraph::telemetry diff --git a/src/utils/algorithm.hpp b/src/utils/algorithm.hpp index 9537d4098..b1b7dbc51 100644 --- a/src/utils/algorithm.hpp +++ b/src/utils/algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/exceptions.hpp" -namespace utils { +namespace memgraph::utils { /** * Outputs a collection of items to the given stream, separating them with the @@ -178,4 +178,4 @@ class Iterable { TIterator end_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/async_timer.cpp b/src/utils/async_timer.cpp index 3528173a2..5da937acc 100644 --- a/src/utils/async_timer.cpp +++ b/src/utils/async_timer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -44,7 +44,7 @@ bool operator==(const ExpirationFlagInfo &flag_info, const uint64_t id) { return bool operator<(const ExpirationFlagInfo &flag_info, const uint64_t id) { return flag_info.id < id; } // NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables) -utils::SkipList expiration_flags{}; +memgraph::utils::SkipList expiration_flags{}; uint64_t AddFlag(std::weak_ptr> flag) { const auto id = expiration_flag_counter.fetch_add(1, std::memory_order_relaxed); @@ -76,7 +76,7 @@ void MarkDone(const uint64_t flag_id) { } } // namespace -namespace utils { +namespace memgraph::utils { namespace { struct ThreadInfo { @@ -195,4 +195,4 @@ void AsyncTimer::ReleaseResources() { } } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/async_timer.hpp b/src/utils/async_timer.hpp index f04725e8f..5d6e60821 100644 --- a/src/utils/async_timer.hpp +++ b/src/utils/async_timer.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "utils/logging.hpp" -namespace utils { +namespace memgraph::utils { #define SIGTIMER (SIGRTMAX - 2) @@ -45,4 +45,4 @@ class AsyncTimer { uint64_t flag_id_; timer_t timer_id_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index 8de7717dc..ba302fcc0 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -38,7 +38,7 @@ #include #include -namespace utils { +namespace memgraph::utils { namespace { // // Depending on the url parameter in base64_chars, one of @@ -268,4 +268,4 @@ std::string base64_encode_mime(std::string_view s) { return encode_mime(s); } std::string base64_decode(std::string_view s, bool remove_linebreaks) { return decode(s, remove_linebreaks); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/base64.hpp b/src/utils/base64.hpp index 4fdc01d23..5f231c606 100644 --- a/src/utils/base64.hpp +++ b/src/utils/base64.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include #include -namespace utils { +namespace memgraph::utils { std::string base64_encode(std::string const &s, bool url = false); std::string base64_encode_pem(std::string const &s); std::string base64_encode_mime(std::string const &s); @@ -41,6 +41,6 @@ std::string base64_encode_mime(std::string_view s); std::string base64_decode(std::string_view s, bool remove_linebreaks = false); #endif // __cplusplus >= 201703L -} // namespace utils +} // namespace memgraph::utils #endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */ diff --git a/src/utils/bound.hpp b/src/utils/bound.hpp index 24b2abcd0..17a804324 100644 --- a/src/utils/bound.hpp +++ b/src/utils/bound.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #pragma once -namespace utils { +namespace memgraph::utils { /** * Determines whether the value of bound expression should be included or @@ -67,4 +67,4 @@ Bound MakeBoundExclusive(TValue value) { return Bound(value, BoundType::EXCLUSIVE); }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/cache.hpp b/src/utils/cache.hpp index 588c2d48c..d81e079c6 100644 --- a/src/utils/cache.hpp +++ b/src/utils/cache.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/logging.hpp" -namespace utils { +namespace memgraph::utils { namespace impl { template struct Node { @@ -196,4 +196,4 @@ class Cache { std::unordered_map cache_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/cast.hpp b/src/utils/cast.hpp index 0f5065e6e..bdb8facc6 100644 --- a/src/utils/cast.hpp +++ b/src/utils/cast.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include #include -namespace utils { +namespace memgraph::utils { template constexpr typename std::underlying_type::type UnderlyingCast(T e) { @@ -42,4 +42,4 @@ TDest MemcpyCast(TSrc src) { return dest; } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/concepts.hpp b/src/utils/concepts.hpp index 1c5f99eae..3a5442d4a 100644 --- a/src/utils/concepts.hpp +++ b/src/utils/concepts.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -12,10 +12,10 @@ #pragma once #include -namespace utils { +namespace memgraph::utils { template concept SameAsAnyOf = (std::same_as || ...); template concept Enum = std::is_enum_v; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/csv_parsing.cpp b/src/utils/csv_parsing.cpp index bc3f3ca37..fc63bf9a4 100644 --- a/src/utils/csv_parsing.cpp +++ b/src/utils/csv_parsing.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "utils/file.hpp" #include "utils/string.hpp" -namespace csv { +namespace memgraph::csv { using ParseError = Reader::ParseError; @@ -245,4 +245,4 @@ std::optional Reader::GetNextRow(utils::MemoryResource *mem) { return std::move(*row); } -} // namespace csv +} // namespace memgraph::csv diff --git a/src/utils/csv_parsing.hpp b/src/utils/csv_parsing.hpp index e9844a357..37d438b41 100644 --- a/src/utils/csv_parsing.hpp +++ b/src/utils/csv_parsing.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -30,7 +30,7 @@ #include "utils/pmr/vector.hpp" #include "utils/result.hpp" -namespace csv { +namespace memgraph::csv { class CsvReadException : public utils::BasicException { using utils::BasicException::BasicException; @@ -105,4 +105,4 @@ class Reader { ParsingResult ParseRow(utils::MemoryResource *mem); }; -} // namespace csv +} // namespace memgraph::csv diff --git a/src/utils/endian.hpp b/src/utils/endian.hpp index 83e16635a..e0fa4ea74 100644 --- a/src/utils/endian.hpp +++ b/src/utils/endian.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "utils/cast.hpp" -namespace utils { +namespace memgraph::utils { inline uint8_t HostToLittleEndian(uint8_t value) { return value; } inline uint16_t HostToLittleEndian(uint16_t value) { return htole16(value); } @@ -53,4 +53,4 @@ inline int16_t BigEndianToHost(int16_t value) { return MemcpyCast(be16t inline int32_t BigEndianToHost(int32_t value) { return MemcpyCast(be32toh(MemcpyCast(value))); } inline int64_t BigEndianToHost(int64_t value) { return MemcpyCast(be64toh(MemcpyCast(value))); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/exceptions.hpp b/src/utils/exceptions.hpp index 1276e170f..0e8379adb 100644 --- a/src/utils/exceptions.hpp +++ b/src/utils/exceptions.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ #include "utils/stacktrace.hpp" -namespace utils { +namespace memgraph::utils { /** * @brief Base class for all regular exceptions. @@ -148,4 +148,4 @@ class NotYetImplemented final : public BasicException { : NotYetImplemented(fmt::format(fmt, std::forward(args)...)) {} }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/file.cpp b/src/utils/file.cpp index c160aa4d2..d7fe100c5 100644 --- a/src/utils/file.cpp +++ b/src/utils/file.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,7 +24,7 @@ #include "utils/logging.hpp" -namespace utils { +namespace memgraph::utils { std::filesystem::path GetExecutablePath() { return std::filesystem::read_symlink("/proc/self/exe"); } @@ -561,4 +561,4 @@ void OutputFile::TryFlushing() { } } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/file.hpp b/src/utils/file.hpp index ba5d5d917..d02af0cfd 100644 --- a/src/utils/file.hpp +++ b/src/utils/file.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,7 +26,7 @@ #include "utils/rw_lock.hpp" -namespace utils { +namespace memgraph::utils { /// Get the path of the current executable. /// @@ -269,4 +269,4 @@ class OutputFile { utils::RWLock flush_lock_{RWLock::Priority::WRITE}; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/file_locker.cpp b/src/utils/file_locker.cpp index f4ac7fb06..7e8b6f6f8 100644 --- a/src/utils/file_locker.cpp +++ b/src/utils/file_locker.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -12,7 +12,7 @@ #include "utils/file_locker.hpp" #include -namespace utils { +namespace memgraph::utils { namespace { void DeleteFromSystem(const std::filesystem::path &path) { @@ -152,4 +152,4 @@ bool FileRetainer::FileLockerAccessor::RemovePath(const std::filesystem::path &p FileRetainer::FileLockerAccessor::~FileLockerAccessor() { file_retainer_->active_accessors_.fetch_sub(1); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/file_locker.hpp b/src/utils/file_locker.hpp index 90a18d1d4..1134bd73e 100644 --- a/src/utils/file_locker.hpp +++ b/src/utils/file_locker.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ #include "utils/spin_lock.hpp" #include "utils/synchronized.hpp" -namespace utils { +namespace memgraph::utils { /** * Helper class used for safer modifying and reading of files @@ -195,4 +195,4 @@ class FileRetainer { utils::Synchronized, utils::SpinLock> files_for_deletion_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/fnv.hpp b/src/utils/fnv.hpp index 13f2a889c..debec9a7b 100644 --- a/src/utils/fnv.hpp +++ b/src/utils/fnv.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include #include -namespace utils { +namespace memgraph::utils { inline uint64_t Fnv(const std::string_view &s) { // fnv1a is recommended so use it as the default implementation. @@ -77,4 +77,4 @@ struct HashCombine { } }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/license.cpp b/src/utils/license.cpp index 7ee02d9b2..a4fa5a23f 100644 --- a/src/utils/license.cpp +++ b/src/utils/license.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,7 +27,7 @@ #include "utils/spin_lock.hpp" #include "utils/synchronized.hpp" -namespace utils::license { +namespace memgraph::utils::license { namespace { constexpr std::string_view license_key_prefix = "mglk-"; @@ -243,15 +243,15 @@ bool LicenseChecker::IsValidLicenseFast() const { return is_valid_.load(std::mem std::string Encode(const License &license) { std::vector buffer; - slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool /*have_more*/) { + memgraph::slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool /*have_more*/) { for (size_t i = 0; i < size; ++i) { buffer.push_back(data[i]); } }); - slk::Save(license.organization_name, &builder); - slk::Save(license.valid_until, &builder); - slk::Save(license.memory_limit, &builder); + memgraph::slk::Save(license.organization_name, &builder); + memgraph::slk::Save(license.valid_until, &builder); + memgraph::slk::Save(license.memory_limit, &builder); builder.Finalize(); return std::string{license_key_prefix} + base64_encode(buffer.data(), buffer.size()); @@ -277,17 +277,17 @@ std::optional Decode(std::string_view license_key) { } try { - slk::Reader reader(std::bit_cast(decoded->c_str()), decoded->size()); + memgraph::slk::Reader reader(std::bit_cast(decoded->c_str()), decoded->size()); std::string organization_name; - slk::Load(&organization_name, &reader); + memgraph::slk::Load(&organization_name, &reader); int64_t valid_until{0}; - slk::Load(&valid_until, &reader); + memgraph::slk::Load(&valid_until, &reader); int64_t memory_limit{0}; - slk::Load(&memory_limit, &reader); + memgraph::slk::Load(&memory_limit, &reader); return License{.organization_name = organization_name, .valid_until = valid_until, .memory_limit = memory_limit}; - } catch (const slk::SlkReaderException &e) { + } catch (const memgraph::slk::SlkReaderException &e) { return std::nullopt; } } -} // namespace utils::license +} // namespace memgraph::utils::license diff --git a/src/utils/license.hpp b/src/utils/license.hpp index 3bbce7e00..d4859d8dc 100644 --- a/src/utils/license.hpp +++ b/src/utils/license.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/scheduler.hpp" #include "utils/settings.hpp" -namespace utils::license { +namespace memgraph::utils::license { struct License { std::string organization_name; @@ -74,4 +74,4 @@ std::string Encode(const License &license); // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) extern LicenseChecker global_license_checker; -} // namespace utils::license +} // namespace memgraph::utils::license diff --git a/src/utils/linux.hpp b/src/utils/linux.hpp index 6b21b3e8e..aa3a7fc64 100644 --- a/src/utils/linux.hpp +++ b/src/utils/linux.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,11 +11,11 @@ #pragma once -namespace utils { +namespace memgraph::utils { // This is the default Linux page size found on all architectures. The proper // way to check for this constant is to call `sysconf(_SC_PAGESIZE)`, but we // can't use that as a `constexpr`. const uint64_t kLinuxPageSize = 4096; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/logging.hpp b/src/utils/logging.hpp index 815fd7fc8..87517b05a 100644 --- a/src/utils/logging.hpp +++ b/src/utils/logging.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -31,7 +31,7 @@ #include #include -namespace logging { +namespace memgraph::logging { // TODO (antonio2368): Replace with std::source_location when it's supported by // compilers @@ -48,7 +48,7 @@ inline void AssertFailed(const char *file_name, int line_num, const char *expr, BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 0), "", fmt::format(__VA_ARGS__)) #define MG_ASSERT(expr, ...) \ - [[likely]] !!(expr) ? (void)0 : ::logging::AssertFailed(__FILE__, __LINE__, #expr, GET_MESSAGE(__VA_ARGS__)) + [[likely]] !!(expr) ? (void)0 : ::memgraph::logging::AssertFailed(__FILE__, __LINE__, #expr, GET_MESSAGE(__VA_ARGS__)) #ifndef NDEBUG #define DMG_ASSERT(expr, ...) MG_ASSERT(expr, __VA_ARGS__) @@ -75,4 +75,4 @@ void Fatal(const char *msg, const Args &...msg_args) { #endif inline void RedirectToStderr() { spdlog::set_default_logger(spdlog::stderr_color_mt("stderr")); } -} // namespace logging +} // namespace memgraph::logging diff --git a/src/utils/math.hpp b/src/utils/math.hpp index 83c89f1ea..14f29a64e 100644 --- a/src/utils/math.hpp +++ b/src/utils/math.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include #include -namespace utils { +namespace memgraph::utils { static_assert(std::is_same_v, "utils::Log requires uint64_t to be implemented as unsigned long."); @@ -64,4 +64,4 @@ constexpr inline std::optional RoundUint64ToMultiple(uint64_t val, uin return (numerator / multiple) * multiple; } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/memory.cpp b/src/utils/memory.cpp index 74a64f8c4..6f15183c0 100644 --- a/src/utils/memory.cpp +++ b/src/utils/memory.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "utils/logging.hpp" -namespace utils { +namespace memgraph::utils { // MonotonicBufferResource @@ -347,4 +347,4 @@ void PoolResource::Release() { // PoolResource END -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/memory.hpp b/src/utils/memory.hpp index 858edc63f..92f766ac1 100644 --- a/src/utils/memory.hpp +++ b/src/utils/memory.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -37,7 +37,7 @@ #include "utils/memory_tracker.hpp" #include "utils/spin_lock.hpp" -namespace utils { +namespace memgraph::utils { /// std::bad_alloc has no constructor accepting a message, so we wrap our /// exceptions in this class. @@ -585,4 +585,4 @@ class ResourceWithOutOfMemoryException : public MemoryResource { MemoryResource *upstream_{utils::NewDeleteResource()}; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/memory_tracker.cpp b/src/utils/memory_tracker.cpp index 3c43917cd..0989aed62 100644 --- a/src/utils/memory_tracker.cpp +++ b/src/utils/memory_tracker.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/on_scope_exit.hpp" #include "utils/readable_size.hpp" -namespace utils { +namespace memgraph::utils { namespace { @@ -120,4 +120,4 @@ void MemoryTracker::Alloc(const int64_t size) { void MemoryTracker::Free(const int64_t size) { amount_.fetch_sub(size, std::memory_order_relaxed); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/memory_tracker.hpp b/src/utils/memory_tracker.hpp index 7c0f9daac..2a9b0d93a 100644 --- a/src/utils/memory_tracker.hpp +++ b/src/utils/memory_tracker.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "utils/exceptions.hpp" -namespace utils { +namespace memgraph::utils { class OutOfMemoryException : public utils::BasicException { public: @@ -98,4 +98,4 @@ class MemoryTracker final { // Global memory tracker which tracks every allocation in the application. extern MemoryTracker total_memory_tracker; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/message.hpp b/src/utils/message.hpp index 127c89e07..c301b3878 100644 --- a/src/utils/message.hpp +++ b/src/utils/message.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace utils { +namespace memgraph::utils { template std::string MessageWithLink(fmt::format_string fmt, Args &&...args) { @@ -21,4 +21,4 @@ std::string MessageWithLink(fmt::format_string fmt, Args &&...args) { std::forward(args)...); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/on_scope_exit.hpp b/src/utils/on_scope_exit.hpp index 6b4ad6236..225c0d870 100644 --- a/src/utils/on_scope_exit.hpp +++ b/src/utils/on_scope_exit.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace utils { +namespace memgraph::utils { /** * Calls a function in it's destructor (on scope exit). @@ -47,4 +47,4 @@ class OnScopeExit { std::function function_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/pmr/list.hpp b/src/utils/pmr/list.hpp index b317a82e4..e234725b2 100644 --- a/src/utils/pmr/list.hpp +++ b/src/utils/pmr/list.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,9 +15,9 @@ #include "utils/memory.hpp" -namespace utils::pmr { +namespace memgraph::utils::pmr { template using list = std::list>; -} // namespace utils::pmr +} // namespace memgraph::utils::pmr diff --git a/src/utils/pmr/map.hpp b/src/utils/pmr/map.hpp index bf3bf63dc..b06243e68 100644 --- a/src/utils/pmr/map.hpp +++ b/src/utils/pmr/map.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "utils/memory.hpp" -namespace utils::pmr { +namespace memgraph::utils::pmr { // Use transparent std::less which forwards to `operator<`, so that, for // example, it's possible to use `find` with C-style (null terminated) strings @@ -23,4 +23,4 @@ namespace utils::pmr { template > using map = std::map>>; -} // namespace utils::pmr +} // namespace memgraph::utils::pmr diff --git a/src/utils/pmr/string.hpp b/src/utils/pmr/string.hpp index 8722ee0d6..653483ac8 100644 --- a/src/utils/pmr/string.hpp +++ b/src/utils/pmr/string.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,8 +15,8 @@ #include "utils/memory.hpp" -namespace utils::pmr { +namespace memgraph::utils::pmr { using string = std::basic_string, utils::Allocator>; -} // namespace utils::pmr +} // namespace memgraph::utils::pmr diff --git a/src/utils/pmr/unordered_map.hpp b/src/utils/pmr/unordered_map.hpp index b663a93f5..df6a153be 100644 --- a/src/utils/pmr/unordered_map.hpp +++ b/src/utils/pmr/unordered_map.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "utils/memory.hpp" -namespace utils::pmr { +namespace memgraph::utils::pmr { // Use transparent std::equal_to which forwards to `operator==`, so that, // for example, it's possible to use `find` with C-style (null terminated) @@ -23,4 +23,4 @@ namespace utils::pmr { template , class Pred = std::equal_to> using unordered_map = std::unordered_map>>; -} // namespace utils::pmr +} // namespace memgraph::utils::pmr diff --git a/src/utils/pmr/unordered_set.hpp b/src/utils/pmr/unordered_set.hpp index aa453c10c..b5fbce43c 100644 --- a/src/utils/pmr/unordered_set.hpp +++ b/src/utils/pmr/unordered_set.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "utils/memory.hpp" -namespace utils::pmr { +namespace memgraph::utils::pmr { // Use transparent std::equal_to which forwards to `operator==`, so that, // for example, it's possible to use `find` with C-style (null terminated) @@ -23,4 +23,4 @@ namespace utils::pmr { template , class Pred = std::equal_to> using unordered_set = std::unordered_set>; -} // namespace utils::pmr +} // namespace memgraph::utils::pmr diff --git a/src/utils/pmr/vector.hpp b/src/utils/pmr/vector.hpp index c89787992..a3de5d639 100644 --- a/src/utils/pmr/vector.hpp +++ b/src/utils/pmr/vector.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,9 +15,9 @@ #include "utils/memory.hpp" -namespace utils::pmr { +namespace memgraph::utils::pmr { template using vector = std::vector>; -} // namespace utils::pmr +} // namespace memgraph::utils::pmr diff --git a/src/utils/readable_size.cpp b/src/utils/readable_size.cpp index 0f1283e3b..fb8cc081a 100644 --- a/src/utils/readable_size.cpp +++ b/src/utils/readable_size.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include -namespace utils { +namespace memgraph::utils { std::string GetReadableSize(double size) { // TODO (antonio2368): Add support for base 1000 (KB, GB, TB...) @@ -35,4 +35,4 @@ std::string GetReadableSize(double size) { return fmt::format("{:.2f}{}", size, units[i]); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/readable_size.hpp b/src/utils/readable_size.hpp index b5e4da17f..e34e1e5ca 100644 --- a/src/utils/readable_size.hpp +++ b/src/utils/readable_size.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -12,6 +12,6 @@ #pragma once #include -namespace utils { +namespace memgraph::utils { std::string GetReadableSize(double size); -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/result.hpp b/src/utils/result.hpp index 672b17f7a..3c36e4729 100644 --- a/src/utils/result.hpp +++ b/src/utils/result.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include "utils/logging.hpp" -namespace utils { +namespace memgraph::utils { template class [[nodiscard]] BasicResult final { @@ -141,4 +141,4 @@ class [[nodiscard]] BasicResult final { std::optional error_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/rw_lock.hpp b/src/utils/rw_lock.hpp index 0c21a9950..beae536bf 100644 --- a/src/utils/rw_lock.hpp +++ b/src/utils/rw_lock.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "utils/logging.hpp" -namespace utils { +namespace memgraph::utils { /// A wrapper around `pthread_rwlock_t`, useful because it is not possible to /// choose read or write priority for `std::shared_mutex`. @@ -126,4 +126,4 @@ class WritePrioritizedRWLock final : public RWLock { WritePrioritizedRWLock() : RWLock{Priority::WRITE} {}; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/scheduler.hpp b/src/utils/scheduler.hpp index a6c92aa6b..5bebfabae 100644 --- a/src/utils/scheduler.hpp +++ b/src/utils/scheduler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "utils/logging.hpp" #include "utils/thread.hpp" -namespace utils { +namespace memgraph::utils { /** * Class used to run scheduled function execution. @@ -117,4 +117,4 @@ class Scheduler { std::thread thread_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/settings.cpp b/src/utils/settings.cpp index 6a2f94ec9..8d1ed9d69 100644 --- a/src/utils/settings.cpp +++ b/src/utils/settings.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include "utils/logging.hpp" #include "utils/settings.hpp" -namespace utils { +namespace memgraph::utils { // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) Settings global_settings; @@ -87,4 +87,4 @@ std::vector> Settings::AllSettings() const { return settings; } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/settings.hpp b/src/utils/settings.hpp index 7d03c907e..ed8889b01 100644 --- a/src/utils/settings.hpp +++ b/src/utils/settings.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "utils/rw_lock.hpp" #include "utils/synchronized.hpp" -namespace utils { +namespace memgraph::utils { struct Settings { using OnChangeCallback = std::function; @@ -40,4 +40,4 @@ struct Settings { // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) extern Settings global_settings; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/signals.cpp b/src/utils/signals.cpp index 2f6866496..d7b75226c 100644 --- a/src/utils/signals.cpp +++ b/src/utils/signals.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "utils/signals.hpp" -namespace utils { +namespace memgraph::utils { bool SignalIgnore(const Signal signal) { int signal_number = static_cast(signal); @@ -49,4 +49,4 @@ bool SignalHandler::RegisterHandler(Signal signal, std::function func, s } std::map> SignalHandler::handlers_ = {}; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/signals.hpp b/src/utils/signals.hpp index 755f9a29b..6d4314f93 100644 --- a/src/utils/signals.hpp +++ b/src/utils/signals.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include #include -namespace utils { +namespace memgraph::utils { // TODO: align bits so signals can be combined // Signal::Terminate | Signal::Interupt @@ -56,4 +56,4 @@ class SignalHandler { /// using `sigemptyset` and `sigaddset` functions from ``. static bool RegisterHandler(Signal signal, std::function func, sigset_t signal_mask); }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/skip_list.hpp b/src/utils/skip_list.hpp index 6cbb2dc16..486aade57 100644 --- a/src/utils/skip_list.hpp +++ b/src/utils/skip_list.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -35,7 +35,7 @@ // How the specified memory fences influence the generated assembler // instructions, see: https://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html -namespace utils { +namespace memgraph::utils { /// This is the maximum height of the list. This value shouldn't be changed from /// this value because it isn't practical to have skip lists that have larger @@ -1283,4 +1283,4 @@ class SkipList final { SpinLock lock_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/small_vector.hpp b/src/utils/small_vector.hpp index 25c057cf7..051db9a6b 100644 --- a/src/utils/small_vector.hpp +++ b/src/utils/small_vector.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -51,7 +51,7 @@ #define LLVM_NODISCARD // LLVM External Functions -namespace utils { +namespace memgraph::utils { namespace detail { /// NextPowerOf2 - Returns the next power of two (in 64-bits) /// that is strictly greater than a. Returns zero on overflow. @@ -65,9 +65,9 @@ inline uint64_t NextPowerOf2(uint64_t a) { return a + 1; } } // namespace detail -} // namespace utils +} // namespace memgraph::utils -namespace utils { +namespace memgraph::utils { /// This is all the non-templated stuff common to all SmallVectors. class SmallVectorBase { @@ -884,23 +884,23 @@ static inline size_t capacity_in_bytes(const SmallVector &x) { return x.capacity_in_bytes(); } -} // namespace utils +} // namespace memgraph::utils namespace std { /// Implement std::swap in terms of SmallVector swap. template -inline void swap(utils::SmallVectorImpl &lhs, utils::SmallVectorImpl &rhs) { +inline void swap(memgraph::utils::SmallVectorImpl &lhs, memgraph::utils::SmallVectorImpl &rhs) { lhs.swap(rhs); } /// Implement std::swap in terms of SmallVector swap. template -inline void swap(utils::SmallVector &lhs, utils::SmallVector &rhs) { +inline void swap(memgraph::utils::SmallVector &lhs, memgraph::utils::SmallVector &rhs) { lhs.swap(rhs); } } // namespace std -namespace utils { +namespace memgraph::utils { /// GrowPod - This is an implementation of the Grow() method which only works /// on POD-like datatypes and is out of line to reduce code duplication. inline void SmallVectorBase::GrowPod(void *first_el, size_t min_size_in_bytes, size_t t_size) { @@ -924,4 +924,4 @@ inline void SmallVectorBase::GrowPod(void *first_el, size_t min_size_in_bytes, s this->begin_x_ = new_elts; this->capacity_x_ = (char *)this->begin_x_ + new_capacity_in_bytes; } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/spin_lock.hpp b/src/utils/spin_lock.hpp index 705b7a486..d68cb87b5 100644 --- a/src/utils/spin_lock.hpp +++ b/src/utils/spin_lock.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "utils/logging.hpp" -namespace utils { +namespace memgraph::utils { /// This class is a wrapper around the `pthread_spinlock_t`. It provides a /// generic spin lock. The lock should be used in cases where you know that the @@ -75,4 +75,4 @@ class SpinLock { private: pthread_spinlock_t lock_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/stack.hpp b/src/utils/stack.hpp index 1145a8e00..fc5f0e6f7 100644 --- a/src/utils/stack.hpp +++ b/src/utils/stack.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/logging.hpp" #include "utils/spin_lock.hpp" -namespace utils { +namespace memgraph::utils { /// This class implements a stack. It is primarily intended for storing /// primitive types. This stack is thread-safe. It uses a spin lock to lock all @@ -123,4 +123,4 @@ class Stack { Block *head_{nullptr}; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/stacktrace.hpp b/src/utils/stacktrace.hpp index 5964271f2..a2aa5a6c3 100644 --- a/src/utils/stacktrace.hpp +++ b/src/utils/stacktrace.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/on_scope_exit.hpp" -namespace utils { +namespace memgraph::utils { class Stacktrace { public: @@ -100,4 +100,4 @@ class Stacktrace { } }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/stat.hpp b/src/utils/stat.hpp index 4f49f7dbe..c8a683a53 100644 --- a/src/utils/stat.hpp +++ b/src/utils/stat.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/file.hpp" #include "utils/string.hpp" -namespace utils { +namespace memgraph::utils { /// Returns the number of bytes a directory is using on disk. If the given path /// isn't a directory, zero will be returned. @@ -52,4 +52,4 @@ inline uint64_t GetMemoryUsage() { return memory; } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/string.hpp b/src/utils/string.hpp index c5aa55bde..9f6eddf6b 100644 --- a/src/utils/string.hpp +++ b/src/utils/string.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,7 +26,7 @@ #include "utils/exceptions.hpp" -namespace utils { +namespace memgraph::utils { /** Remove whitespace characters from the start of a string. */ inline std::string_view LTrim(const std::string_view &s) { @@ -451,4 +451,4 @@ inline std::string_view Substr(const std::string_view &string, size_t pos = 0, s return string.substr(pos, len); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/synchronized.hpp b/src/utils/synchronized.hpp index 975a732e7..56083d91a 100644 --- a/src/utils/synchronized.hpp +++ b/src/utils/synchronized.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ #include #include -namespace utils { +namespace memgraph::utils { template concept SharedMutex = requires(TMutex mutex) { @@ -135,4 +135,4 @@ class Synchronized { mutable TMutex mutex_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/sysinfo/memory.cpp b/src/utils/sysinfo/memory.cpp index 25ceb0216..c763041cb 100644 --- a/src/utils/sysinfo/memory.cpp +++ b/src/utils/sysinfo/memory.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "utils/sysinfo/memory.hpp" -namespace utils::sysinfo { +namespace memgraph::utils::sysinfo { namespace { std::optional ExtractAmountFromMemInfo(const std::string_view header_name) { @@ -41,4 +41,4 @@ std::optional TotalMemory() { return ExtractAmountFromMemInfo("MemTota std::optional SwapTotalMemory() { return ExtractAmountFromMemInfo("SwapTotal"); } -} // namespace utils::sysinfo +} // namespace memgraph::utils::sysinfo diff --git a/src/utils/sysinfo/memory.hpp b/src/utils/sysinfo/memory.hpp index 91a4d49d0..5ea106947 100644 --- a/src/utils/sysinfo/memory.hpp +++ b/src/utils/sysinfo/memory.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "utils/logging.hpp" -namespace utils::sysinfo { +namespace memgraph::utils::sysinfo { /** * Gets the amount of available RAM in KiB. If the information is @@ -38,4 +38,4 @@ std::optional TotalMemory(); */ std::optional SwapTotalMemory(); -} // namespace utils::sysinfo +} // namespace memgraph::utils::sysinfo diff --git a/src/utils/temporal.cpp b/src/utils/temporal.cpp index ddd64c697..f91d183e2 100644 --- a/src/utils/temporal.cpp +++ b/src/utils/temporal.cpp @@ -20,7 +20,7 @@ #include "utils/exceptions.hpp" #include "utils/fnv.hpp" -namespace utils { +namespace memgraph::utils { namespace { constexpr bool IsInBounds(const auto low, const auto high, const auto value) { return low <= value && value <= high; } @@ -620,7 +620,7 @@ Symbol table: 'n' represents a number that can be an integer of ANY value, or a fraction IF it's the last value in the string. All the fields are optional. )help", kSupportedLocalDateTimeFormatsHelpMessage); -// clang-format on +// clang-format on DurationParameters ParseDurationParameters(std::string_view string) { // The string needs to start with P followed by one of the two options: @@ -640,8 +640,8 @@ namespace { template constexpr To CastChronoDouble(const double value) { return std::chrono::duration_cast(std::chrono::duration(value)); -}; -} // namespace +}; +} // namespace Duration::Duration(int64_t microseconds) { this->microseconds = microseconds; } @@ -687,21 +687,21 @@ int64_t Duration::SubDaysAsNanoseconds() const { int64_t Duration::SubDaysAsMicroseconds() const { namespace chrono = std::chrono; - const auto days = chrono::days(Days()); + const auto days = chrono::days(Days()); const auto micros = chrono::microseconds(microseconds); return (micros - days).count(); } -int64_t Duration::SubSecondsAsNanoseconds() const { +int64_t Duration::SubSecondsAsNanoseconds() const { namespace chrono = std::chrono; - const auto micros = chrono::microseconds(SubDaysAsMicroseconds()); + const auto micros = chrono::microseconds(SubDaysAsMicroseconds()); const auto secs = chrono::seconds(SubDaysAsSeconds()); return chrono::duration_cast(micros - secs).count(); } Duration Duration::operator-() const { if (microseconds == std::numeric_limits::min()) [[unlikely]] { - throw temporal::InvalidArgumentException("Duration arithmetic overflows"); + throw temporal::InvalidArgumentException("Duration arithmetic overflows"); } Duration result{-microseconds}; return result; @@ -709,4 +709,4 @@ Duration Duration::operator-() const { size_t DurationHash::operator()(const Duration &duration) const { return std::hash{}(duration.microseconds); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/temporal.hpp b/src/utils/temporal.hpp index d2f3b6eac..29cd04985 100644 --- a/src/utils/temporal.hpp +++ b/src/utils/temporal.hpp @@ -20,7 +20,7 @@ #include "utils/exceptions.hpp" #include "utils/logging.hpp" -namespace utils { +namespace memgraph::utils { template concept Chrono = requires(T) { @@ -316,4 +316,4 @@ struct LocalDateTimeHash { Date CurrentDate(); LocalTime CurrentLocalTime(); LocalDateTime CurrentLocalDateTime(); -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/terminate_handler.hpp b/src/utils/terminate_handler.hpp index a27aae5dd..574ae664c 100644 --- a/src/utils/terminate_handler.hpp +++ b/src/utils/terminate_handler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "utils/stacktrace.hpp" -namespace utils { +namespace memgraph::utils { /** * Dump stacktrace to the stream and abort the probram. For more details @@ -42,4 +42,4 @@ void TerminateHandler(std::ostream &stream) noexcept { void TerminateHandler() noexcept { TerminateHandler(std::cout); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/thread.cpp b/src/utils/thread.cpp index 52da4c63b..7a1344984 100644 --- a/src/utils/thread.cpp +++ b/src/utils/thread.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "utils/logging.hpp" -namespace utils { +namespace memgraph::utils { void ThreadSetName(const std::string &name) { constexpr auto max_name_length = GetMaxThreadNameSize(); @@ -26,4 +26,4 @@ void ThreadSetName(const std::string &name) { } } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/thread.hpp b/src/utils/thread.hpp index 9bffb24af..ed8725d19 100644 --- a/src/utils/thread.hpp +++ b/src/utils/thread.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include -namespace utils { +namespace memgraph::utils { constexpr size_t GetMaxThreadNameSize() { return 16; } @@ -22,4 +22,4 @@ constexpr size_t GetMaxThreadNameSize() { return 16; } /// Beware, the name length limit is 16 characters! void ThreadSetName(const std::string &name); -}; // namespace utils +}; // namespace memgraph::utils diff --git a/src/utils/thread_pool.cpp b/src/utils/thread_pool.cpp index 697396d3b..8d16e6c0b 100644 --- a/src/utils/thread_pool.cpp +++ b/src/utils/thread_pool.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "utils/thread_pool.hpp" -namespace utils { +namespace memgraph::utils { ThreadPool::ThreadPool(const size_t pool_size) { for (size_t i = 0; i < pool_size; ++i) { @@ -87,4 +87,4 @@ void ThreadPool::ThreadLoop() { size_t ThreadPool::UnfinishedTasksNum() const { return unfinished_tasks_num_.load(); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/thread_pool.hpp b/src/utils/thread_pool.hpp index 6863f8132..8597a78a1 100644 --- a/src/utils/thread_pool.hpp +++ b/src/utils/thread_pool.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "utils/synchronized.hpp" #include "utils/thread.hpp" -namespace utils { +namespace memgraph::utils { class ThreadPool { using TaskSignature = std::function; @@ -57,4 +57,4 @@ class ThreadPool { std::condition_variable queue_cv_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/timer.hpp b/src/utils/timer.hpp index 85cc71c37..96a9fa1fd 100644 --- a/src/utils/timer.hpp +++ b/src/utils/timer.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace utils { +namespace memgraph::utils { // This class is threadsafe. class Timer { @@ -29,4 +29,4 @@ class Timer { std::chrono::steady_clock::time_point start_time_; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/timestamp.hpp b/src/utils/timestamp.hpp index ad15ae667..1f3df1d41 100644 --- a/src/utils/timestamp.hpp +++ b/src/utils/timestamp.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ #include "utils/exceptions.hpp" -namespace utils { +namespace memgraph::utils { class TimestampError : public StacktraceException { public: @@ -102,4 +102,4 @@ class Timestamp final { static constexpr auto fiso8601 = "{:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}.{:06d}Z"; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/tsc.cpp b/src/utils/tsc.cpp index f87494fde..fa87f9754 100644 --- a/src/utils/tsc.cpp +++ b/src/utils/tsc.cpp @@ -17,7 +17,7 @@ extern "C" { #include "utils/tsc.hpp" -namespace utils { +namespace memgraph::utils { uint64_t ReadTSC() { return rdtsc(); } std::optional GetTSCFrequency() { @@ -38,4 +38,4 @@ double TSCTimer::Elapsed() const { return static_cast(delta) / *frequency_; } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/tsc.hpp b/src/utils/tsc.hpp index c30cb2099..40344ddaf 100644 --- a/src/utils/tsc.hpp +++ b/src/utils/tsc.hpp @@ -14,7 +14,7 @@ #include #include -namespace utils { +namespace memgraph::utils { // TSC stands for Time-Stamp Counter @@ -36,4 +36,4 @@ class TSCTimer { uint64_t start_value_{0}; }; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/typeinfo.hpp b/src/utils/typeinfo.hpp index 148a80359..7d8085bce 100644 --- a/src/utils/typeinfo.hpp +++ b/src/utils/typeinfo.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include -namespace utils { +namespace memgraph::utils { /// Type information on a C++ type. /// @@ -69,4 +69,4 @@ TDerived *Downcast(TBase *a) { return nullptr; } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/uuid.cpp b/src/utils/uuid.cpp index 8de25f15f..9b13b8965 100644 --- a/src/utils/uuid.cpp +++ b/src/utils/uuid.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,7 +13,7 @@ #include -namespace utils { +namespace memgraph::utils { std::string GenerateUUID() { uuid_t uuid; @@ -23,4 +23,4 @@ std::string GenerateUUID() { return std::string(decoded); } -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/uuid.hpp b/src/utils/uuid.hpp index 0d8775774..8bbb1a1a1 100644 --- a/src/utils/uuid.hpp +++ b/src/utils/uuid.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,11 +13,11 @@ #include -namespace utils { +namespace memgraph::utils { /** * This function generates an UUID and returns it. */ std::string GenerateUUID(); -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/variant_helpers.hpp b/src/utils/variant_helpers.hpp index c7321fc64..2ba44860a 100644 --- a/src/utils/variant_helpers.hpp +++ b/src/utils/variant_helpers.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #pragma once -namespace utils { +namespace memgraph::utils { template struct Overloaded : Ts... { using Ts::operator()...; @@ -19,4 +19,4 @@ struct Overloaded : Ts... { template Overloaded(Ts...) -> Overloaded; -} // namespace utils +} // namespace memgraph::utils diff --git a/src/utils/visitor.hpp b/src/utils/visitor.hpp index 0190b4940..c5c932aaa 100644 --- a/src/utils/visitor.hpp +++ b/src/utils/visitor.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -51,7 +51,7 @@ #pragma once -namespace utils { +namespace memgraph::utils { // Don't use anonymous namespace, because each translation unit will then get a // unique type. This may cause errors if one wants to check the type. @@ -277,4 +277,4 @@ class Visitable { TVisitor::ReturnType Accept(TVisitor &visitor) override { return visitor.Visit(*this); } }; -} // namespace utils +} // namespace memgraph::utils diff --git a/tests/benchmark/expansion.cpp b/tests/benchmark/expansion.cpp index 8a0871d83..e6052efb5 100644 --- a/tests/benchmark/expansion.cpp +++ b/tests/benchmark/expansion.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,9 +20,9 @@ class ExpansionBenchFixture : public benchmark::Fixture { protected: - std::optional db; - std::optional interpreter_context; - std::optional interpreter; + std::optional db; + std::optional interpreter_context; + std::optional interpreter; std::filesystem::path data_directory{std::filesystem::temp_directory_path() / "expansion-benchmark"}; void SetUp(const benchmark::State &state) override { @@ -47,7 +47,7 @@ class ExpansionBenchFixture : public benchmark::Fixture { MG_ASSERT(db->CreateIndex(label)); - interpreter_context.emplace(&*db, query::InterpreterConfig{}, data_directory); + interpreter_context.emplace(&*db, memgraph::query::InterpreterConfig{}, data_directory); interpreter.emplace(&*interpreter_context); } diff --git a/tests/benchmark/query/eval.cpp b/tests/benchmark/query/eval.cpp index fe09ac689..7320c0cc7 100644 --- a/tests/benchmark/query/eval.cpp +++ b/tests/benchmark/query/eval.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,39 +16,40 @@ #include "query/interpreter.hpp" #include "storage/v2/storage.hpp" -// The following classes are wrappers for utils::MemoryResource, so that we can +// The following classes are wrappers for memgraph::utils::MemoryResource, so that we can // use BENCHMARK_TEMPLATE class MonotonicBufferResource final { - utils::MonotonicBufferResource memory_{query::kExecutionMemoryBlockSize}; + memgraph::utils::MonotonicBufferResource memory_{memgraph::query::kExecutionMemoryBlockSize}; public: - utils::MemoryResource *get() { return &memory_; } + memgraph::utils::MemoryResource *get() { return &memory_; } }; class NewDeleteResource final { public: - utils::MemoryResource *get() { return utils::NewDeleteResource(); } + memgraph::utils::MemoryResource *get() { return memgraph::utils::NewDeleteResource(); } }; template // NOLINTNEXTLINE(google-runtime-references) static void MapLiteral(benchmark::State &state) { - query::AstStorage ast; - query::SymbolTable symbol_table; + memgraph::query::AstStorage ast; + memgraph::query::SymbolTable symbol_table; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); - storage::Storage db; + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - std::unordered_map elements; + memgraph::query::DbAccessor dba(&storage_dba); + std::unordered_map elements; for (int64_t i = 0; i < state.range(0); ++i) { - elements.emplace(ast.GetPropertyIx("prop" + std::to_string(i)), ast.Create(i)); + elements.emplace(ast.GetPropertyIx("prop" + std::to_string(i)), ast.Create(i)); } - auto *expr = ast.Create(elements); - query::EvaluationContext evaluation_context{memory.get()}; - evaluation_context.properties = query::NamesToProperties(ast.properties_, &dba); - query::ExpressionEvaluator evaluator(&frame, symbol_table, evaluation_context, &dba, storage::View::NEW); + auto *expr = ast.Create(elements); + memgraph::query::EvaluationContext evaluation_context{memory.get()}; + evaluation_context.properties = memgraph::query::NamesToProperties(ast.properties_, &dba); + memgraph::query::ExpressionEvaluator evaluator(&frame, symbol_table, evaluation_context, &dba, + memgraph::storage::View::NEW); while (state.KeepRunning()) { benchmark::DoNotOptimize(expr->Accept(evaluator)); } @@ -62,19 +63,20 @@ BENCHMARK_TEMPLATE(MapLiteral, MonotonicBufferResource)->Range(512, 1U << 15U)-> template // NOLINTNEXTLINE(google-runtime-references) static void AdditionOperator(benchmark::State &state) { - query::AstStorage ast; - query::SymbolTable symbol_table; + memgraph::query::AstStorage ast; + memgraph::query::SymbolTable symbol_table; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); - storage::Storage db; + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - query::Expression *expr = ast.Create(0); + memgraph::query::DbAccessor dba(&storage_dba); + memgraph::query::Expression *expr = ast.Create(0); for (int64_t i = 0; i < state.range(0); ++i) { - expr = ast.Create(expr, ast.Create(i)); + expr = ast.Create(expr, ast.Create(i)); } - query::EvaluationContext evaluation_context{memory.get()}; - query::ExpressionEvaluator evaluator(&frame, symbol_table, evaluation_context, &dba, storage::View::NEW); + memgraph::query::EvaluationContext evaluation_context{memory.get()}; + memgraph::query::ExpressionEvaluator evaluator(&frame, symbol_table, evaluation_context, &dba, + memgraph::storage::View::NEW); while (state.KeepRunning()) { benchmark::DoNotOptimize(expr->Accept(evaluator)); } diff --git a/tests/benchmark/query/execution.cpp b/tests/benchmark/query/execution.cpp index 7eadb19f4..6bc4b9b01 100644 --- a/tests/benchmark/query/execution.cpp +++ b/tests/benchmark/query/execution.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -32,35 +32,35 @@ #include "query/interpreter.hpp" #include "storage/v2/storage.hpp" -// The following classes are wrappers for utils::MemoryResource, so that we can +// The following classes are wrappers for memgraph::utils::MemoryResource, so that we can // use BENCHMARK_TEMPLATE class MonotonicBufferResource final { - utils::MonotonicBufferResource memory_{query::kExecutionMemoryBlockSize}; + memgraph::utils::MonotonicBufferResource memory_{memgraph::query::kExecutionMemoryBlockSize}; public: - utils::MemoryResource *get() { return &memory_; } + memgraph::utils::MemoryResource *get() { return &memory_; } void Reset() { memory_.Release(); } }; class NewDeleteResource final { public: - utils::MemoryResource *get() { return utils::NewDeleteResource(); } + memgraph::utils::MemoryResource *get() { return memgraph::utils::NewDeleteResource(); } void Reset() {} }; class PoolResource final { - utils::PoolResource memory_{128, 4 * 1024}; + memgraph::utils::PoolResource memory_{128, 4 * 1024}; public: - utils::MemoryResource *get() { return &memory_; } + memgraph::utils::MemoryResource *get() { return &memory_; } void Reset() { memory_.Release(); } }; -static void AddVertices(storage::Storage *db, int vertex_count) { +static void AddVertices(memgraph::storage::Storage *db, int vertex_count) { auto dba = db->Access(); for (int i = 0; i < vertex_count; i++) dba.CreateVertex(); MG_ASSERT(!dba.Commit().HasError()); @@ -68,7 +68,7 @@ static void AddVertices(storage::Storage *db, int vertex_count) { static const char *kStartLabel = "start"; -static void AddStarGraph(storage::Storage *db, int spoke_count, int depth) { +static void AddStarGraph(memgraph::storage::Storage *db, int spoke_count, int depth) { { auto dba = db->Access(); auto center_vertex = dba.CreateVertex(); @@ -86,10 +86,10 @@ static void AddStarGraph(storage::Storage *db, int spoke_count, int depth) { MG_ASSERT(db->CreateIndex(db->NameToLabel(kStartLabel))); } -static void AddTree(storage::Storage *db, int vertex_count) { +static void AddTree(memgraph::storage::Storage *db, int vertex_count) { { auto dba = db->Access(); - std::vector vertices; + std::vector vertices; vertices.reserve(vertex_count); auto root = dba.CreateVertex(); MG_ASSERT(root.AddLabel(dba.NameToLabel(kStartLabel)).HasValue()); @@ -108,38 +108,39 @@ static void AddTree(storage::Storage *db, int vertex_count) { MG_ASSERT(db->CreateIndex(db->NameToLabel(kStartLabel))); } -static query::CypherQuery *ParseCypherQuery(const std::string &query_string, query::AstStorage *ast) { - query::frontend::ParsingContext parsing_context; +static memgraph::query::CypherQuery *ParseCypherQuery(const std::string &query_string, + memgraph::query::AstStorage *ast) { + memgraph::query::frontend::ParsingContext parsing_context; parsing_context.is_query_cached = false; - query::frontend::opencypher::Parser parser(query_string); + memgraph::query::frontend::opencypher::Parser parser(query_string); // Convert antlr4 AST into Memgraph AST. - query::frontend::CypherMainVisitor cypher_visitor(parsing_context, ast); + memgraph::query::frontend::CypherMainVisitor cypher_visitor(parsing_context, ast); cypher_visitor.visit(parser.tree()); - return utils::Downcast(cypher_visitor.query()); + return memgraph::utils::Downcast(cypher_visitor.query()); }; template // NOLINTNEXTLINE(google-runtime-references) static void Distinct(benchmark::State &state) { - query::AstStorage ast; - query::Parameters parameters; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::Parameters parameters; + memgraph::storage::Storage db; AddVertices(&db, state.range(0)); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto query_string = "MATCH (s) RETURN DISTINCT s"; auto *cypher_query = ParseCypherQuery(query_string, &ast); - auto symbol_table = query::MakeSymbolTable(cypher_query); - auto context = query::plan::MakePlanningContext(&ast, &symbol_table, cypher_query, &dba); - auto plan_and_cost = query::plan::MakeLogicalPlan(&context, parameters, false); + auto symbol_table = memgraph::query::MakeSymbolTable(cypher_query); + auto context = memgraph::query::plan::MakePlanningContext(&ast, &symbol_table, cypher_query, &dba); + auto plan_and_cost = memgraph::query::plan::MakeLogicalPlan(&context, parameters, false); ResultStreamFaker results(&db); // We need to only set the memory for temporary (per pull) evaluations TMemory per_pull_memory; - query::EvaluationContext evaluation_context{per_pull_memory.get()}; + memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()}; while (state.KeepRunning()) { - query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; + memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); auto cursor = plan_and_cost.first->MakeCursor(memory.get()); while (cursor->Pull(frame, execution_context)) per_pull_memory.Reset(); } @@ -152,43 +153,43 @@ BENCHMARK_TEMPLATE(Distinct, MonotonicBufferResource)->Range(1024, 1U << 21U)->U BENCHMARK_TEMPLATE(Distinct, PoolResource)->Range(1024, 1U << 21U)->Unit(benchmark::kMicrosecond); -static query::plan::ExpandVariable MakeExpandVariable(query::EdgeAtom::Type expand_type, - query::SymbolTable *symbol_table) { +static memgraph::query::plan::ExpandVariable MakeExpandVariable(memgraph::query::EdgeAtom::Type expand_type, + memgraph::query::SymbolTable *symbol_table) { auto input_symbol = symbol_table->CreateSymbol("input", false); auto dest_symbol = symbol_table->CreateSymbol("dest", false); auto edge_symbol = symbol_table->CreateSymbol("edge", false); auto lambda_node_symbol = symbol_table->CreateSymbol("n", false); auto lambda_edge_symbol = symbol_table->CreateSymbol("e", false); - query::plan::ExpansionLambda filter_lambda; + memgraph::query::plan::ExpansionLambda filter_lambda; filter_lambda.inner_node_symbol = lambda_node_symbol; filter_lambda.inner_edge_symbol = lambda_edge_symbol; filter_lambda.expression = nullptr; - return query::plan::ExpandVariable(nullptr, input_symbol, dest_symbol, edge_symbol, expand_type, - query::EdgeAtom::Direction::OUT, {}, false, nullptr, nullptr, false, filter_lambda, - std::nullopt, std::nullopt); + return memgraph::query::plan::ExpandVariable(nullptr, input_symbol, dest_symbol, edge_symbol, expand_type, + memgraph::query::EdgeAtom::Direction::OUT, {}, false, nullptr, nullptr, + false, filter_lambda, std::nullopt, std::nullopt); } template // NOLINTNEXTLINE(google-runtime-references) static void ExpandVariable(benchmark::State &state) { - query::AstStorage ast; - query::Parameters parameters; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::Parameters parameters; + memgraph::storage::Storage db; AddStarGraph(&db, state.range(0), state.range(1)); - query::SymbolTable symbol_table; - auto expand_variable = MakeExpandVariable(query::EdgeAtom::Type::DEPTH_FIRST, &symbol_table); + memgraph::query::SymbolTable symbol_table; + auto expand_variable = MakeExpandVariable(memgraph::query::EdgeAtom::Type::DEPTH_FIRST, &symbol_table); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // We need to only set the memory for temporary (per pull) evaluations TMemory per_pull_memory; - query::EvaluationContext evaluation_context{per_pull_memory.get()}; + memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()}; while (state.KeepRunning()) { - query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; + memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); auto cursor = expand_variable.MakeCursor(memory.get()); - for (const auto &v : dba.Vertices(storage::View::OLD, dba.NameToLabel(kStartLabel))) { - frame[expand_variable.input_symbol_] = query::TypedValue(query::VertexAccessor(v)); + for (const auto &v : dba.Vertices(memgraph::storage::View::OLD, dba.NameToLabel(kStartLabel))) { + frame[expand_variable.input_symbol_] = memgraph::query::TypedValue(memgraph::query::VertexAccessor(v)); while (cursor->Pull(frame, execution_context)) per_pull_memory.Reset(); } } @@ -210,24 +211,24 @@ BENCHMARK_TEMPLATE(ExpandVariable, PoolResource) template // NOLINTNEXTLINE(google-runtime-references) static void ExpandBfs(benchmark::State &state) { - query::AstStorage ast; - query::Parameters parameters; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::Parameters parameters; + memgraph::storage::Storage db; AddTree(&db, state.range(0)); - query::SymbolTable symbol_table; - auto expand_variable = MakeExpandVariable(query::EdgeAtom::Type::BREADTH_FIRST, &symbol_table); + memgraph::query::SymbolTable symbol_table; + auto expand_variable = MakeExpandVariable(memgraph::query::EdgeAtom::Type::BREADTH_FIRST, &symbol_table); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // We need to only set the memory for temporary (per pull) evaluations TMemory per_pull_memory; - query::EvaluationContext evaluation_context{per_pull_memory.get()}; + memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()}; while (state.KeepRunning()) { - query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; + memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); auto cursor = expand_variable.MakeCursor(memory.get()); - for (const auto &v : dba.Vertices(storage::View::OLD, dba.NameToLabel(kStartLabel))) { - frame[expand_variable.input_symbol_] = query::TypedValue(query::VertexAccessor(v)); + for (const auto &v : dba.Vertices(memgraph::storage::View::OLD, dba.NameToLabel(kStartLabel))) { + frame[expand_variable.input_symbol_] = memgraph::query::TypedValue(memgraph::query::VertexAccessor(v)); while (cursor->Pull(frame, execution_context)) per_pull_memory.Reset(); } } @@ -243,28 +244,28 @@ BENCHMARK_TEMPLATE(ExpandBfs, PoolResource)->Range(512, 1U << 19U)->Unit(benchma template // NOLINTNEXTLINE(google-runtime-references) static void ExpandShortest(benchmark::State &state) { - query::AstStorage ast; - query::Parameters parameters; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::Parameters parameters; + memgraph::storage::Storage db; AddTree(&db, state.range(0)); - query::SymbolTable symbol_table; - auto expand_variable = MakeExpandVariable(query::EdgeAtom::Type::BREADTH_FIRST, &symbol_table); + memgraph::query::SymbolTable symbol_table; + auto expand_variable = MakeExpandVariable(memgraph::query::EdgeAtom::Type::BREADTH_FIRST, &symbol_table); expand_variable.common_.existing_node = true; auto dest_symbol = expand_variable.common_.node_symbol; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // We need to only set the memory for temporary (per pull) evaluations TMemory per_pull_memory; - query::EvaluationContext evaluation_context{per_pull_memory.get()}; + memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()}; while (state.KeepRunning()) { - query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; + memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); auto cursor = expand_variable.MakeCursor(memory.get()); - for (const auto &v : dba.Vertices(storage::View::OLD, dba.NameToLabel(kStartLabel))) { - frame[expand_variable.input_symbol_] = query::TypedValue(query::VertexAccessor(v)); - for (const auto &dest : dba.Vertices(storage::View::OLD, dba.NameToLabel(kStartLabel))) { - frame[dest_symbol] = query::TypedValue(query::VertexAccessor(dest)); + for (const auto &v : dba.Vertices(memgraph::storage::View::OLD, dba.NameToLabel(kStartLabel))) { + frame[expand_variable.input_symbol_] = memgraph::query::TypedValue(memgraph::query::VertexAccessor(v)); + for (const auto &dest : dba.Vertices(memgraph::storage::View::OLD, dba.NameToLabel(kStartLabel))) { + frame[dest_symbol] = memgraph::query::TypedValue(memgraph::query::VertexAccessor(dest)); while (cursor->Pull(frame, execution_context)) per_pull_memory.Reset(); } } @@ -281,31 +282,31 @@ BENCHMARK_TEMPLATE(ExpandShortest, PoolResource)->Range(512, 1U << 20U)->Unit(be template // NOLINTNEXTLINE(google-runtime-references) static void ExpandWeightedShortest(benchmark::State &state) { - query::AstStorage ast; - query::Parameters parameters; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::Parameters parameters; + memgraph::storage::Storage db; AddTree(&db, state.range(0)); - query::SymbolTable symbol_table; - auto expand_variable = MakeExpandVariable(query::EdgeAtom::Type::WEIGHTED_SHORTEST_PATH, &symbol_table); + memgraph::query::SymbolTable symbol_table; + auto expand_variable = MakeExpandVariable(memgraph::query::EdgeAtom::Type::WEIGHTED_SHORTEST_PATH, &symbol_table); expand_variable.common_.existing_node = true; - expand_variable.weight_lambda_ = - query::plan::ExpansionLambda{symbol_table.CreateSymbol("edge", false), symbol_table.CreateSymbol("vertex", false), - ast.Create(1)}; + expand_variable.weight_lambda_ = memgraph::query::plan::ExpansionLambda{ + symbol_table.CreateSymbol("edge", false), symbol_table.CreateSymbol("vertex", false), + ast.Create(1)}; auto dest_symbol = expand_variable.common_.node_symbol; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // We need to only set the memory for temporary (per pull) evaluations TMemory per_pull_memory; - query::EvaluationContext evaluation_context{per_pull_memory.get()}; + memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()}; while (state.KeepRunning()) { - query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; + memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); auto cursor = expand_variable.MakeCursor(memory.get()); - for (const auto &v : dba.Vertices(storage::View::OLD, dba.NameToLabel(kStartLabel))) { - frame[expand_variable.input_symbol_] = query::TypedValue(query::VertexAccessor(v)); - for (const auto &dest : dba.Vertices(storage::View::OLD, dba.NameToLabel(kStartLabel))) { - frame[dest_symbol] = query::TypedValue(query::VertexAccessor(dest)); + for (const auto &v : dba.Vertices(memgraph::storage::View::OLD, dba.NameToLabel(kStartLabel))) { + frame[expand_variable.input_symbol_] = memgraph::query::TypedValue(memgraph::query::VertexAccessor(v)); + for (const auto &dest : dba.Vertices(memgraph::storage::View::OLD, dba.NameToLabel(kStartLabel))) { + frame[dest_symbol] = memgraph::query::TypedValue(memgraph::query::VertexAccessor(dest)); while (cursor->Pull(frame, execution_context)) per_pull_memory.Reset(); } } @@ -324,28 +325,28 @@ BENCHMARK_TEMPLATE(ExpandWeightedShortest, PoolResource)->Range(512, 1U << 20U)- template // NOLINTNEXTLINE(google-runtime-references) static void Accumulate(benchmark::State &state) { - query::AstStorage ast; - query::Parameters parameters; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::Parameters parameters; + memgraph::storage::Storage db; AddVertices(&db, state.range(1)); - query::SymbolTable symbol_table; - auto scan_all = std::make_shared(nullptr, symbol_table.CreateSymbol("v", false)); - std::vector symbols; + memgraph::query::SymbolTable symbol_table; + auto scan_all = std::make_shared(nullptr, symbol_table.CreateSymbol("v", false)); + std::vector symbols; symbols.reserve(state.range(0)); for (int i = 0; i < state.range(0); ++i) { symbols.push_back(symbol_table.CreateSymbol(std::to_string(i), false)); } - query::plan::Accumulate accumulate(scan_all, symbols, - /* advance_command= */ false); + memgraph::query::plan::Accumulate accumulate(scan_all, symbols, + /* advance_command= */ false); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // We need to only set the memory for temporary (per pull) evaluations TMemory per_pull_memory; - query::EvaluationContext evaluation_context{per_pull_memory.get()}; + memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()}; while (state.KeepRunning()) { - query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; + memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); auto cursor = accumulate.MakeCursor(memory.get()); while (cursor->Pull(frame, execution_context)) per_pull_memory.Reset(); } @@ -365,37 +366,38 @@ BENCHMARK_TEMPLATE(Accumulate, PoolResource)->Ranges({{4, 1U << 7U}, {512, 1U << template // NOLINTNEXTLINE(google-runtime-references) static void Aggregate(benchmark::State &state) { - query::AstStorage ast; - query::Parameters parameters; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::Parameters parameters; + memgraph::storage::Storage db; AddVertices(&db, state.range(1)); - query::SymbolTable symbol_table; - auto scan_all = std::make_shared(nullptr, symbol_table.CreateSymbol("v", false)); - std::vector symbols; + memgraph::query::SymbolTable symbol_table; + auto scan_all = std::make_shared(nullptr, symbol_table.CreateSymbol("v", false)); + std::vector symbols; symbols.reserve(state.range(0)); - std::vector group_by; + std::vector group_by; group_by.reserve(state.range(0)); - std::vector aggregations; + std::vector aggregations; aggregations.reserve(state.range(0)); for (int i = 0; i < state.range(0); ++i) { auto sym = symbol_table.CreateSymbol(std::to_string(i), false); symbols.push_back(sym); - group_by.push_back(ast.Create(sym.name())->MapTo(sym)); - aggregations.push_back({ast.Create(i), nullptr, query::Aggregation::Op::SUM, + group_by.push_back(ast.Create(sym.name())->MapTo(sym)); + aggregations.push_back({ast.Create(i), nullptr, + memgraph::query::Aggregation::Op::SUM, symbol_table.CreateSymbol("out" + std::to_string(i), false)}); } - query::plan::Aggregate aggregate(scan_all, aggregations, group_by, symbols); + memgraph::query::plan::Aggregate aggregate(scan_all, aggregations, group_by, symbols); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // We need to only set the memory for temporary (per pull) evaluations TMemory per_pull_memory; - query::EvaluationContext evaluation_context{per_pull_memory.get()}; + memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()}; while (state.KeepRunning()) { - query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; + memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); auto cursor = aggregate.MakeCursor(memory.get()); - frame[symbols.front()] = query::TypedValue(0); // initial group_by value + frame[symbols.front()] = memgraph::query::TypedValue(0); // initial group_by value while (cursor->Pull(frame, execution_context)) { frame[symbols.front()].ValueInt()++; // new group_by value per_pull_memory.Reset(); @@ -417,33 +419,33 @@ BENCHMARK_TEMPLATE(Aggregate, PoolResource)->Ranges({{4, 1U << 7U}, {512, 1U << template // NOLINTNEXTLINE(google-runtime-references) static void OrderBy(benchmark::State &state) { - query::AstStorage ast; - query::Parameters parameters; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::Parameters parameters; + memgraph::storage::Storage db; AddVertices(&db, state.range(1)); - query::SymbolTable symbol_table; - auto scan_all = std::make_shared(nullptr, symbol_table.CreateSymbol("v", false)); - std::vector symbols; + memgraph::query::SymbolTable symbol_table; + auto scan_all = std::make_shared(nullptr, symbol_table.CreateSymbol("v", false)); + std::vector symbols; symbols.reserve(state.range(0)); // NOLINTNEXTLINE(cert-msc32-c,cert-msc51-cpp) std::mt19937_64 rg(42); - std::vector sort_items; + std::vector sort_items; sort_items.reserve(state.range(0)); for (int i = 0; i < state.range(0); ++i) { symbols.push_back(symbol_table.CreateSymbol(std::to_string(i), false)); - auto rand_value = utils::MemcpyCast(rg()); - sort_items.push_back({query::Ordering::ASC, ast.Create(rand_value)}); + auto rand_value = memgraph::utils::MemcpyCast(rg()); + sort_items.push_back({memgraph::query::Ordering::ASC, ast.Create(rand_value)}); } - query::plan::OrderBy order_by(scan_all, sort_items, symbols); + memgraph::query::plan::OrderBy order_by(scan_all, sort_items, symbols); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // We need to only set the memory for temporary (per pull) evaluations TMemory per_pull_memory; - query::EvaluationContext evaluation_context{per_pull_memory.get()}; + memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()}; while (state.KeepRunning()) { - query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; + memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); auto cursor = order_by.MakeCursor(memory.get()); while (cursor->Pull(frame, execution_context)) per_pull_memory.Reset(); } @@ -463,26 +465,26 @@ BENCHMARK_TEMPLATE(OrderBy, PoolResource)->Ranges({{4, 1U << 7U}, {512, 1U << 13 template // NOLINTNEXTLINE(google-runtime-references) static void Unwind(benchmark::State &state) { - query::AstStorage ast; - query::Parameters parameters; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::Parameters parameters; + memgraph::storage::Storage db; AddVertices(&db, state.range(0)); - query::SymbolTable symbol_table; - auto scan_all = std::make_shared(nullptr, symbol_table.CreateSymbol("v", false)); + memgraph::query::SymbolTable symbol_table; + auto scan_all = std::make_shared(nullptr, symbol_table.CreateSymbol("v", false)); auto list_sym = symbol_table.CreateSymbol("list", false); - auto *list_expr = ast.Create("list")->MapTo(list_sym); + auto *list_expr = ast.Create("list")->MapTo(list_sym); auto out_sym = symbol_table.CreateSymbol("out", false); - query::plan::Unwind unwind(scan_all, list_expr, out_sym); + memgraph::query::plan::Unwind unwind(scan_all, list_expr, out_sym); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // We need to only set the memory for temporary (per pull) evaluations TMemory per_pull_memory; - query::EvaluationContext evaluation_context{per_pull_memory.get()}; + memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()}; while (state.KeepRunning()) { - query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; + memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context}; TMemory memory; - query::Frame frame(symbol_table.max_position(), memory.get()); - frame[list_sym] = query::TypedValue(std::vector(state.range(1))); + memgraph::query::Frame frame(symbol_table.max_position(), memory.get()); + frame[list_sym] = memgraph::query::TypedValue(std::vector(state.range(1))); auto cursor = unwind.MakeCursor(memory.get()); while (cursor->Pull(frame, execution_context)) per_pull_memory.Reset(); } diff --git a/tests/benchmark/query/planner.cpp b/tests/benchmark/query/planner.cpp index cecb72c13..d7157fb31 100644 --- a/tests/benchmark/query/planner.cpp +++ b/tests/benchmark/query/planner.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,21 +20,22 @@ #include "storage/v2/storage.hpp" // Add chained MATCH (node1) -- (node2), MATCH (node2) -- (node3) ... clauses. -static query::CypherQuery *AddChainedMatches(int num_matches, query::AstStorage &storage) { - auto *query = storage.Create(); +static memgraph::query::CypherQuery *AddChainedMatches(int num_matches, memgraph::query::AstStorage &storage) { + auto *query = storage.Create(); for (int i = 0; i < num_matches; ++i) { - auto *match = storage.Create(); - auto *pattern = storage.Create(); - auto *single_query = storage.Create(); - pattern->identifier_ = storage.Create("path"); + auto *match = storage.Create(); + auto *pattern = storage.Create(); + auto *single_query = storage.Create(); + pattern->identifier_ = storage.Create("path"); match->patterns_.emplace_back(pattern); std::string node1_name = "node" + std::to_string(i - 1); - pattern->atoms_.emplace_back(storage.Create(storage.Create(node1_name))); pattern->atoms_.emplace_back( - storage.Create(storage.Create("edge" + std::to_string(i)), - query::EdgeAtom::Type::SINGLE, query::EdgeAtom::Direction::BOTH)); - pattern->atoms_.emplace_back( - storage.Create(storage.Create("node" + std::to_string(i)))); + storage.Create(storage.Create(node1_name))); + pattern->atoms_.emplace_back(storage.Create( + storage.Create("edge" + std::to_string(i)), + memgraph::query::EdgeAtom::Type::SINGLE, memgraph::query::EdgeAtom::Direction::BOTH)); + pattern->atoms_.emplace_back(storage.Create( + storage.Create("node" + std::to_string(i)))); single_query->clauses_.emplace_back(match); query->single_query_ = single_query; } @@ -42,24 +43,24 @@ static query::CypherQuery *AddChainedMatches(int num_matches, query::AstStorage } static void BM_PlanChainedMatches(benchmark::State &state) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); while (state.KeepRunning()) { state.PauseTiming(); - query::AstStorage storage; + memgraph::query::AstStorage storage; int num_matches = state.range(0); auto *query = AddChainedMatches(num_matches, storage); - auto symbol_table = query::MakeSymbolTable(query); - auto ctx = query::plan::MakePlanningContext(&storage, &symbol_table, query, &dba); + auto symbol_table = memgraph::query::MakeSymbolTable(query); + auto ctx = memgraph::query::plan::MakePlanningContext(&storage, &symbol_table, query, &dba); state.ResumeTiming(); - auto query_parts = query::plan::CollectQueryParts(symbol_table, storage, query); + auto query_parts = memgraph::query::plan::CollectQueryParts(symbol_table, storage, query); if (query_parts.query_parts.size() == 0) { std::exit(EXIT_FAILURE); } auto single_query_parts = query_parts.query_parts.at(0).single_query_parts; - auto plans = - query::plan::MakeLogicalPlanForSingleQuery(single_query_parts, &ctx); + auto plans = memgraph::query::plan::MakeLogicalPlanForSingleQuery( + single_query_parts, &ctx); for (const auto &plan : plans) { // Exhaust through all generated plans, since they are lazily generated. benchmark::DoNotOptimize(plan.get()); @@ -69,19 +70,21 @@ static void BM_PlanChainedMatches(benchmark::State &state) { BENCHMARK(BM_PlanChainedMatches)->RangeMultiplier(2)->Range(50, 400)->Unit(benchmark::kMillisecond); -static query::CypherQuery *AddIndexedMatches(int num_matches, const std::string &label, const std::string &property, - query::AstStorage &storage) { - auto *query = storage.Create(); +static memgraph::query::CypherQuery *AddIndexedMatches(int num_matches, const std::string &label, + const std::string &property, + memgraph::query::AstStorage &storage) { + auto *query = storage.Create(); for (int i = 0; i < num_matches; ++i) { - auto *match = storage.Create(); - auto *pattern = storage.Create(); - auto *single_query = storage.Create(); - pattern->identifier_ = storage.Create("path"); + auto *match = storage.Create(); + auto *pattern = storage.Create(); + auto *single_query = storage.Create(); + pattern->identifier_ = storage.Create("path"); match->patterns_.emplace_back(pattern); std::string node1_name = "node" + std::to_string(i - 1); - auto *node = storage.Create(storage.Create(node1_name)); + auto *node = storage.Create(storage.Create(node1_name)); node->labels_.emplace_back(storage.GetLabelIx(label)); - std::get<0>(node->properties_)[storage.GetPropertyIx(property)] = storage.Create(i); + std::get<0>(node->properties_)[storage.GetPropertyIx(property)] = + storage.Create(i); pattern->atoms_.emplace_back(node); single_query->clauses_.emplace_back(match); query->single_query_ = single_query; @@ -89,7 +92,7 @@ static query::CypherQuery *AddIndexedMatches(int num_matches, const std::string return query; } -static auto CreateIndexedVertices(int index_count, int vertex_count, storage::Storage *db) { +static auto CreateIndexedVertices(int index_count, int vertex_count, memgraph::storage::Storage *db) { auto label = db->NameToLabel("label"); auto prop = db->NameToProperty("prop"); db->CreateIndex(label, prop); @@ -98,7 +101,7 @@ static auto CreateIndexedVertices(int index_count, int vertex_count, storage::St for (int index = 0; index < index_count; ++index) { auto vertex = dba.CreateVertex(); MG_ASSERT(vertex.AddLabel(label).HasValue()); - MG_ASSERT(vertex.SetProperty(prop, storage::PropertyValue(index)).HasValue()); + MG_ASSERT(vertex.SetProperty(prop, memgraph::storage::PropertyValue(index)).HasValue()); } } MG_ASSERT(!dba.Commit().HasError()); @@ -106,62 +109,62 @@ static auto CreateIndexedVertices(int index_count, int vertex_count, storage::St } static void BM_PlanAndEstimateIndexedMatching(benchmark::State &state) { - storage::Storage db; + memgraph::storage::Storage db; std::string label; std::string prop; int index_count = state.range(0); int vertex_count = state.range(1); std::tie(label, prop) = CreateIndexedVertices(index_count, vertex_count, &db); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - query::Parameters parameters; + memgraph::query::DbAccessor dba(&storage_dba); + memgraph::query::Parameters parameters; while (state.KeepRunning()) { state.PauseTiming(); - query::AstStorage storage; + memgraph::query::AstStorage storage; auto *query = AddIndexedMatches(index_count, label, prop, storage); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); state.ResumeTiming(); - auto ctx = query::plan::MakePlanningContext(&storage, &symbol_table, query, &dba); - auto query_parts = query::plan::CollectQueryParts(symbol_table, storage, query); + auto ctx = memgraph::query::plan::MakePlanningContext(&storage, &symbol_table, query, &dba); + auto query_parts = memgraph::query::plan::CollectQueryParts(symbol_table, storage, query); if (query_parts.query_parts.size() == 0) { std::exit(EXIT_FAILURE); } auto single_query_parts = query_parts.query_parts.at(0).single_query_parts; - auto plans = - query::plan::MakeLogicalPlanForSingleQuery(single_query_parts, &ctx); + auto plans = memgraph::query::plan::MakeLogicalPlanForSingleQuery( + single_query_parts, &ctx); for (auto plan : plans) { - query::plan::EstimatePlanCost(&dba, parameters, *plan); + memgraph::query::plan::EstimatePlanCost(&dba, parameters, *plan); } } } static void BM_PlanAndEstimateIndexedMatchingWithCachedCounts(benchmark::State &state) { - storage::Storage db; + memgraph::storage::Storage db; std::string label; std::string prop; int index_count = state.range(0); int vertex_count = state.range(1); std::tie(label, prop) = CreateIndexedVertices(index_count, vertex_count, &db); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - auto vertex_counts = query::plan::MakeVertexCountCache(&dba); - query::Parameters parameters; + memgraph::query::DbAccessor dba(&storage_dba); + auto vertex_counts = memgraph::query::plan::MakeVertexCountCache(&dba); + memgraph::query::Parameters parameters; while (state.KeepRunning()) { state.PauseTiming(); - query::AstStorage storage; + memgraph::query::AstStorage storage; auto *query = AddIndexedMatches(index_count, label, prop, storage); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); state.ResumeTiming(); - auto ctx = query::plan::MakePlanningContext(&storage, &symbol_table, query, &vertex_counts); - auto query_parts = query::plan::CollectQueryParts(symbol_table, storage, query); + auto ctx = memgraph::query::plan::MakePlanningContext(&storage, &symbol_table, query, &vertex_counts); + auto query_parts = memgraph::query::plan::CollectQueryParts(symbol_table, storage, query); if (query_parts.query_parts.size() == 0) { std::exit(EXIT_FAILURE); } auto single_query_parts = query_parts.query_parts.at(0).single_query_parts; - auto plans = - query::plan::MakeLogicalPlanForSingleQuery(single_query_parts, &ctx); + auto plans = memgraph::query::plan::MakeLogicalPlanForSingleQuery( + single_query_parts, &ctx); for (auto plan : plans) { - query::plan::EstimatePlanCost(&vertex_counts, parameters, *plan); + memgraph::query::plan::EstimatePlanCost(&vertex_counts, parameters, *plan); } } } diff --git a/tests/benchmark/query/profile.cpp b/tests/benchmark/query/profile.cpp index 49e912a95..056274176 100644 --- a/tests/benchmark/query/profile.cpp +++ b/tests/benchmark/query/profile.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -130,14 +130,14 @@ struct ScopedProfile { ScopedProfile(std::uintptr_t key, Context *context) : context(context) { if (context->evaluation_context_.is_profile_query) { stats = &context->evaluation_context_.operator_stats[key]; - start_time = utils::ReadTSC(); + start_time = memgraph::utils::ReadTSC(); stats->actual_hits++; } } ~ScopedProfile() { if (context->evaluation_context_.is_profile_query) { - stats->elapsed_time += utils::ReadTSC() - start_time; + stats->elapsed_time += memgraph::utils::ReadTSC() - start_time; } } @@ -249,13 +249,13 @@ struct ScopedProfile { context->evaluation_context_.stats_root = stats; stats->actual_hits++; stats->key = key; - start_time = utils::ReadTSC(); + start_time = memgraph::utils::ReadTSC(); } } ~ScopedProfile() { if (context->evaluation_context_.is_profile_query) { - stats->elapsed_time += utils::ReadTSC() - start_time; + stats->elapsed_time += memgraph::utils::ReadTSC() - start_time; // Restore the old root ("pop") context->evaluation_context_.stats_root = root; @@ -361,13 +361,13 @@ struct ScopedProfile { context->evaluation_context_.stats_root = stats; stats->actual_hits++; stats->key = key; - start_time = utils::ReadTSC(); + start_time = memgraph::utils::ReadTSC(); } } ~ScopedProfile() { if (context->evaluation_context_.is_profile_query) { - stats->elapsed_time += utils::ReadTSC() - start_time; + stats->elapsed_time += memgraph::utils::ReadTSC() - start_time; // Restore the old root ("pop") context->evaluation_context_.stats_root = root; @@ -546,7 +546,7 @@ struct ScopedProfile { MG_ASSERT(stats); stats->actual_hits++; - start_time = utils::ReadTSC(); + start_time = memgraph::utils::ReadTSC(); stats->key = key; // Set the new root ("push") @@ -587,7 +587,7 @@ struct ScopedProfile { MG_ASSERT(stats); if (context->evaluation_context_.is_profile_query) { - stats->elapsed_time += utils::ReadTSC() - start_time; + stats->elapsed_time += memgraph::utils::ReadTSC() - start_time; // Restore the old root ("pop") context->evaluation_context_.stats_root = old_root_id; diff --git a/tests/benchmark/query/stripped.cpp b/tests/benchmark/query/stripped.cpp index 3a6698ebc..129936408 100644 --- a/tests/benchmark/query/stripped.cpp +++ b/tests/benchmark/query/stripped.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -57,7 +57,7 @@ auto BM_Strip = [](benchmark::State &state, auto &function, std::string query) { }; int main(int argc, char *argv[]) { - auto preprocess = [](const std::string &query) { return query::frontend::StrippedQuery(query); }; + auto preprocess = [](const std::string &query) { return memgraph::query::frontend::StrippedQuery(query); }; for (auto test : kQueries) { benchmark::RegisterBenchmark(test, BM_Strip, preprocess, test)->Range(1, 1)->Complexity(benchmark::oN); diff --git a/tests/benchmark/rpc.cpp b/tests/benchmark/rpc.cpp index 95e0709c1..fc60b76b1 100644 --- a/tests/benchmark/rpc.cpp +++ b/tests/benchmark/rpc.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,28 +22,28 @@ #include "utils/timer.hpp" struct EchoMessage { - static const utils::TypeInfo kType; + static const memgraph::utils::TypeInfo kType; EchoMessage() {} // Needed for serialization. EchoMessage(const std::string &data) : data(data) {} - static void Load(EchoMessage *obj, slk::Reader *reader); - static void Save(const EchoMessage &obj, slk::Builder *builder); + static void Load(EchoMessage *obj, memgraph::slk::Reader *reader); + static void Save(const EchoMessage &obj, memgraph::slk::Builder *builder); std::string data; }; -namespace slk { +namespace memgraph::slk { void Save(const EchoMessage &echo, Builder *builder) { Save(echo.data, builder); } void Load(EchoMessage *echo, Reader *reader) { Load(&echo->data, reader); } -} // namespace slk +} // namespace memgraph::slk -void EchoMessage::Load(EchoMessage *obj, slk::Reader *reader) { slk::Load(obj, reader); } -void EchoMessage::Save(const EchoMessage &obj, slk::Builder *builder) { slk::Save(obj, builder); } +void EchoMessage::Load(EchoMessage *obj, memgraph::slk::Reader *reader) { memgraph::slk::Load(obj, reader); } +void EchoMessage::Save(const EchoMessage &obj, memgraph::slk::Builder *builder) { memgraph::slk::Save(obj, builder); } -const utils::TypeInfo EchoMessage::kType{2, "EchoMessage"}; +const memgraph::utils::TypeInfo EchoMessage::kType{2, "EchoMessage"}; -using Echo = rpc::RequestResponse; +using Echo = memgraph::rpc::RequestResponse; const int kThreadsNum = 16; @@ -55,11 +55,11 @@ DEFINE_bool(benchmark_use_ssl, false, "Set to true to benchmark using SSL"); DEFINE_bool(run_server, true, "Set to false to use external server"); DEFINE_bool(run_benchmark, true, "Set to false to only run server"); -std::optional server_context; -std::optional server; -std::optional client_context; -std::optional clients[kThreadsNum]; -std::optional client_pool; +std::optional server_context; +std::optional server; +std::optional client_context; +std::optional clients[kThreadsNum]; +std::optional client_pool; static void BenchmarkRpc(benchmark::State &state) { std::string data(state.range(0), 'a'); @@ -103,7 +103,7 @@ int main(int argc, char **argv) { } else { server_context.emplace(); } - server.emplace(io::network::Endpoint(FLAGS_server_address, FLAGS_server_port), &server_context.value(), + server.emplace(memgraph::io::network::Endpoint(FLAGS_server_address, FLAGS_server_port), &server_context.value(), kThreadsNum); server->Register([](const auto &req_reader, auto *res_builder) { @@ -117,11 +117,11 @@ int main(int argc, char **argv) { if (FLAGS_run_benchmark) { std::this_thread::sleep_for(std::chrono::milliseconds(200)); - io::network ::Endpoint endpoint; + memgraph::io::network ::Endpoint endpoint; if (FLAGS_run_server) { endpoint = server->endpoint(); } else { - endpoint = io::network::Endpoint(FLAGS_server_address, FLAGS_server_port); + endpoint = memgraph::io::network::Endpoint(FLAGS_server_address, FLAGS_server_port); } client_context.emplace(FLAGS_benchmark_use_ssl); diff --git a/tests/benchmark/skip_list_random.cpp b/tests/benchmark/skip_list_random.cpp index f71408426..33b08ca50 100644 --- a/tests/benchmark/skip_list_random.cpp +++ b/tests/benchmark/skip_list_random.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ DEFINE_int32(max_range, 2000000, "Maximum range used for the test"); int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - utils::SkipList list; + memgraph::utils::SkipList list; { auto acc = list.access(); diff --git a/tests/benchmark/skip_list_real_world.cpp b/tests/benchmark/skip_list_real_world.cpp index 01c9952bc..84debfd9a 100644 --- a/tests/benchmark/skip_list_real_world.cpp +++ b/tests/benchmark/skip_list_real_world.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ DEFINE_int32(max_range, 2000000, "Maximum range used for the test"); int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - utils::SkipList list; + memgraph::utils::SkipList list; { auto acc = list.access(); diff --git a/tests/benchmark/skip_list_same_item.cpp b/tests/benchmark/skip_list_same_item.cpp index b91e26e0a..8e20a6287 100644 --- a/tests/benchmark/skip_list_same_item.cpp +++ b/tests/benchmark/skip_list_same_item.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,7 +16,7 @@ int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - utils::SkipList list; + memgraph::utils::SkipList list; RunConcurrentTest([&list](auto *run, auto *stats) { std::mt19937 generator(std::random_device{}()); diff --git a/tests/benchmark/skip_list_vs_stl.cpp b/tests/benchmark/skip_list_vs_stl.cpp index 67674f685..1a17e56e1 100644 --- a/tests/benchmark/skip_list_vs_stl.cpp +++ b/tests/benchmark/skip_list_vs_stl.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,19 +24,19 @@ const int kThreadsNum = 8; const uint64_t kMaxNum = 10000000; /////////////////////////////////////////////////////////////////////////////// -// utils::SkipList set Insert +// memgraph::utils::SkipList set Insert /////////////////////////////////////////////////////////////////////////////// class SkipListSetInsertFixture : public benchmark::Fixture { protected: void SetUp(const benchmark::State &state) override { if (state.thread_index() == 0) { - list = utils::SkipList(); + list = memgraph::utils::SkipList(); } } protected: - utils::SkipList list; + memgraph::utils::SkipList list; }; BENCHMARK_DEFINE_F(SkipListSetInsertFixture, Insert)(benchmark::State &state) { @@ -71,7 +71,7 @@ class StdSetInsertFixture : public benchmark::Fixture { protected: std::set container; - utils::SpinLock lock; + memgraph::utils::SpinLock lock; }; BENCHMARK_DEFINE_F(StdSetInsertFixture, Insert)(benchmark::State &state) { @@ -79,7 +79,7 @@ BENCHMARK_DEFINE_F(StdSetInsertFixture, Insert)(benchmark::State &state) { std::uniform_int_distribution dist(0, kMaxNum); uint64_t counter = 0; while (state.KeepRunning()) { - std::lock_guard guard(lock); + std::lock_guard guard(lock); if (container.insert(dist(gen)).second) { ++counter; } @@ -101,9 +101,10 @@ class StdSetWithPoolAllocatorInsertFixture : public benchmark::Fixture { } protected: - utils::PoolResource memory_{256U /* max_blocks_per_chunk */, 1024U /* max_block_size */, utils::NewDeleteResource()}; - std::set, utils::Allocator> container{&memory_}; - utils::SpinLock lock; + memgraph::utils::PoolResource memory_{256U /* max_blocks_per_chunk */, 1024U /* max_block_size */, + memgraph::utils::NewDeleteResource()}; + std::set, memgraph::utils::Allocator> container{&memory_}; + memgraph::utils::SpinLock lock; }; BENCHMARK_DEFINE_F(StdSetWithPoolAllocatorInsertFixture, Insert) @@ -112,7 +113,7 @@ BENCHMARK_DEFINE_F(StdSetWithPoolAllocatorInsertFixture, Insert) std::uniform_int_distribution dist(0, kMaxNum); uint64_t counter = 0; while (state.KeepRunning()) { - std::lock_guard guard(lock); + std::lock_guard guard(lock); if (container.insert(dist(gen)).second) { ++counter; } @@ -126,7 +127,7 @@ BENCHMARK_REGISTER_F(StdSetWithPoolAllocatorInsertFixture, Insert) ->UseRealTime(); /////////////////////////////////////////////////////////////////////////////// -// utils::SkipList set Find +// memgraph::utils::SkipList set Find /////////////////////////////////////////////////////////////////////////////// class SkipListSetFindFixture : public benchmark::Fixture { @@ -141,7 +142,7 @@ class SkipListSetFindFixture : public benchmark::Fixture { } protected: - utils::SkipList list; + memgraph::utils::SkipList list; }; BENCHMARK_DEFINE_F(SkipListSetFindFixture, Find)(benchmark::State &state) { @@ -178,7 +179,7 @@ class StdSetFindFixture : public benchmark::Fixture { protected: std::set container; - utils::SpinLock lock; + memgraph::utils::SpinLock lock; }; BENCHMARK_DEFINE_F(StdSetFindFixture, Find)(benchmark::State &state) { @@ -186,7 +187,7 @@ BENCHMARK_DEFINE_F(StdSetFindFixture, Find)(benchmark::State &state) { std::uniform_int_distribution dist(0, kMaxNum); uint64_t counter = 0; while (state.KeepRunning()) { - std::lock_guard guard(lock); + std::lock_guard guard(lock); if (container.find(dist(gen)) != container.end()) { ++counter; } @@ -207,9 +208,10 @@ class StdSetWithPoolAllocatorFindFixture : public benchmark::Fixture { } protected: - utils::PoolResource memory_{256U /* max_blocks_per_chunk */, 1024U /* max_block_size */, utils::NewDeleteResource()}; - std::set, utils::Allocator> container{&memory_}; - utils::SpinLock lock; + memgraph::utils::PoolResource memory_{256U /* max_blocks_per_chunk */, 1024U /* max_block_size */, + memgraph::utils::NewDeleteResource()}; + std::set, memgraph::utils::Allocator> container{&memory_}; + memgraph::utils::SpinLock lock; }; BENCHMARK_DEFINE_F(StdSetWithPoolAllocatorFindFixture, Find) @@ -218,7 +220,7 @@ BENCHMARK_DEFINE_F(StdSetWithPoolAllocatorFindFixture, Find) std::uniform_int_distribution dist(0, kMaxNum); uint64_t counter = 0; while (state.KeepRunning()) { - std::lock_guard guard(lock); + std::lock_guard guard(lock); if (container.find(dist(gen)) != container.end()) { ++counter; } @@ -246,19 +248,19 @@ bool operator==(const MapObject &a, uint64_t b) { return a.key == b; } bool operator<(const MapObject &a, uint64_t b) { return a.key < b; } /////////////////////////////////////////////////////////////////////////////// -// utils::SkipList map Insert +// memgraph::utils::SkipList map Insert /////////////////////////////////////////////////////////////////////////////// class SkipListMapInsertFixture : public benchmark::Fixture { protected: void SetUp(const benchmark::State &state) override { if (state.thread_index() == 0) { - list = utils::SkipList(); + list = memgraph::utils::SkipList(); } } protected: - utils::SkipList list; + memgraph::utils::SkipList list; }; BENCHMARK_DEFINE_F(SkipListMapInsertFixture, Insert)(benchmark::State &state) { @@ -293,7 +295,7 @@ class StdMapInsertFixture : public benchmark::Fixture { protected: std::map container; - utils::SpinLock lock; + memgraph::utils::SpinLock lock; }; BENCHMARK_DEFINE_F(StdMapInsertFixture, Insert)(benchmark::State &state) { @@ -301,7 +303,7 @@ BENCHMARK_DEFINE_F(StdMapInsertFixture, Insert)(benchmark::State &state) { std::uniform_int_distribution dist(0, kMaxNum); uint64_t counter = 0; while (state.KeepRunning()) { - std::lock_guard guard(lock); + std::lock_guard guard(lock); if (container.insert({dist(gen), 0}).second) { ++counter; } @@ -323,9 +325,11 @@ class StdMapWithPoolAllocatorInsertFixture : public benchmark::Fixture { } protected: - utils::PoolResource memory_{256U /* max_blocks_per_chunk */, 1024U /* max_block_size */, utils::NewDeleteResource()}; - std::map, utils::Allocator>> container{&memory_}; - utils::SpinLock lock; + memgraph::utils::PoolResource memory_{256U /* max_blocks_per_chunk */, 1024U /* max_block_size */, + memgraph::utils::NewDeleteResource()}; + std::map, memgraph::utils::Allocator>> container{ + &memory_}; + memgraph::utils::SpinLock lock; }; BENCHMARK_DEFINE_F(StdMapWithPoolAllocatorInsertFixture, Insert) @@ -334,7 +338,7 @@ BENCHMARK_DEFINE_F(StdMapWithPoolAllocatorInsertFixture, Insert) std::uniform_int_distribution dist(0, kMaxNum); uint64_t counter = 0; while (state.KeepRunning()) { - std::lock_guard guard(lock); + std::lock_guard guard(lock); if (container.insert({dist(gen), 0}).second) { ++counter; } @@ -348,7 +352,7 @@ BENCHMARK_REGISTER_F(StdMapWithPoolAllocatorInsertFixture, Insert) ->UseRealTime(); /////////////////////////////////////////////////////////////////////////////// -// utils::SkipList map Find +// memgraph::utils::SkipList map Find /////////////////////////////////////////////////////////////////////////////// class SkipListMapFindFixture : public benchmark::Fixture { @@ -363,7 +367,7 @@ class SkipListMapFindFixture : public benchmark::Fixture { } protected: - utils::SkipList list; + memgraph::utils::SkipList list; }; BENCHMARK_DEFINE_F(SkipListMapFindFixture, Find)(benchmark::State &state) { @@ -400,7 +404,7 @@ class StdMapFindFixture : public benchmark::Fixture { protected: std::map container; - utils::SpinLock lock; + memgraph::utils::SpinLock lock; }; BENCHMARK_DEFINE_F(StdMapFindFixture, Find)(benchmark::State &state) { @@ -408,7 +412,7 @@ BENCHMARK_DEFINE_F(StdMapFindFixture, Find)(benchmark::State &state) { std::uniform_int_distribution dist(0, kMaxNum); uint64_t counter = 0; while (state.KeepRunning()) { - std::lock_guard guard(lock); + std::lock_guard guard(lock); if (container.find(dist(gen)) != container.end()) { ++counter; } @@ -429,9 +433,11 @@ class StdMapWithPoolAllocatorFindFixture : public benchmark::Fixture { } protected: - utils::PoolResource memory_{256U /* max_blocks_per_chunk */, 1024U /* max_block_size */, utils::NewDeleteResource()}; - std::map, utils::Allocator>> container{&memory_}; - utils::SpinLock lock; + memgraph::utils::PoolResource memory_{256U /* max_blocks_per_chunk */, 1024U /* max_block_size */, + memgraph::utils::NewDeleteResource()}; + std::map, memgraph::utils::Allocator>> container{ + &memory_}; + memgraph::utils::SpinLock lock; }; BENCHMARK_DEFINE_F(StdMapWithPoolAllocatorFindFixture, Find) @@ -440,7 +446,7 @@ BENCHMARK_DEFINE_F(StdMapWithPoolAllocatorFindFixture, Find) std::uniform_int_distribution dist(0, kMaxNum); uint64_t counter = 0; while (state.KeepRunning()) { - std::lock_guard guard(lock); + std::lock_guard guard(lock); if (container.find(dist(gen)) != container.end()) { ++counter; } diff --git a/tests/benchmark/storage_v2_gc.cpp b/tests/benchmark/storage_v2_gc.cpp index 15d37c9ab..a8f023ced 100644 --- a/tests/benchmark/storage_v2_gc.cpp +++ b/tests/benchmark/storage_v2_gc.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,26 +26,26 @@ DEFINE_int32(num_threads, 4, "number of threads"); DEFINE_int32(num_vertices, kNumVertices, "number of vertices"); DEFINE_int32(num_iterations, kNumIterations, "number of iterations"); -std::pair TestConfigurations[] = { - {"NoGc", storage::Config{.gc = {.type = storage::Config::Gc::Type::NONE}}}, - {"100msPeriodicGc", - storage::Config{.gc = {.type = storage::Config::Gc::Type::PERIODIC, .interval = std::chrono::milliseconds(100)}}}, - {"1000msPeriodicGc", storage::Config{.gc = {.type = storage::Config::Gc::Type::PERIODIC, - .interval = std::chrono::milliseconds(1000)}}}}; +std::pair TestConfigurations[] = { + {"NoGc", memgraph::storage::Config{.gc = {.type = memgraph::storage::Config::Gc::Type::NONE}}}, + {"100msPeriodicGc", memgraph::storage::Config{.gc = {.type = memgraph::storage::Config::Gc::Type::PERIODIC, + .interval = std::chrono::milliseconds(100)}}}, + {"1000msPeriodicGc", memgraph::storage::Config{.gc = {.type = memgraph::storage::Config::Gc::Type::PERIODIC, + .interval = std::chrono::milliseconds(1000)}}}}; -void UpdateLabelFunc(int thread_id, storage::Storage *storage, const std::vector &vertices, - int num_iterations) { +void UpdateLabelFunc(int thread_id, memgraph::storage::Storage *storage, + const std::vector &vertices, int num_iterations) { std::mt19937 gen(thread_id); std::uniform_int_distribution vertex_dist(0, vertices.size() - 1); std::uniform_int_distribution label_dist(0, 100); - utils::Timer timer; + memgraph::utils::Timer timer; for (int iter = 0; iter < num_iterations; ++iter) { auto acc = storage->Access(); - storage::Gid gid = vertices.at(vertex_dist(gen)); - std::optional vertex = acc.FindVertex(gid, storage::View::OLD); + memgraph::storage::Gid gid = vertices.at(vertex_dist(gen)); + std::optional vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); MG_ASSERT(vertex.has_value(), "Vertex with GID {} doesn't exist", gid.AsUint()); - if (vertex->AddLabel(storage::LabelId::FromUint(label_dist(gen))).HasValue()) { + if (vertex->AddLabel(memgraph::storage::LabelId::FromUint(label_dist(gen))).HasValue()) { MG_ASSERT(!acc.Commit().HasError()); } else { acc.Abort(); @@ -57,8 +57,8 @@ int main(int argc, char *argv[]) { gflags::ParseCommandLineFlags(&argc, &argv, true); for (const auto &config : TestConfigurations) { - storage::Storage storage(config.second); - std::vector vertices; + memgraph::storage::Storage storage(config.second); + std::vector vertices; { auto acc = storage.Access(); for (int i = 0; i < FLAGS_num_vertices; ++i) { @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) { MG_ASSERT(!acc.Commit().HasError()); } - utils::Timer timer; + memgraph::utils::Timer timer; std::vector threads; threads.reserve(FLAGS_num_threads); for (int i = 0; i < FLAGS_num_threads; ++i) { diff --git a/tests/benchmark/storage_v2_property_store.cpp b/tests/benchmark/storage_v2_property_store.cpp index cced3b97b..fa006683a 100644 --- a/tests/benchmark/storage_v2_property_store.cpp +++ b/tests/benchmark/storage_v2_property_store.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,13 +24,13 @@ // NOLINTNEXTLINE(google-runtime-references) static void PropertyStoreSet(benchmark::State &state) { - storage::PropertyStore store; + memgraph::storage::PropertyStore store; std::mt19937 gen(state.thread_index()); std::uniform_int_distribution dist(0, state.range(0) - 1); uint64_t counter = 0; while (state.KeepRunning()) { - auto prop = storage::PropertyId::FromUint(dist(gen)); - store.SetProperty(prop, storage::PropertyValue(42)); + auto prop = memgraph::storage::PropertyId::FromUint(dist(gen)); + store.SetProperty(prop, memgraph::storage::PropertyValue(42)); ++counter; } state.SetItemsProcessed(counter); @@ -44,13 +44,13 @@ BENCHMARK(PropertyStoreSet)->RangeMultiplier(2)->Range(1, 1024)->Unit(benchmark: // NOLINTNEXTLINE(google-runtime-references) static void StdMapSet(benchmark::State &state) { - std::map store; + std::map store; std::mt19937 gen(state.thread_index()); std::uniform_int_distribution dist(0, state.range(0) - 1); uint64_t counter = 0; while (state.KeepRunning()) { - auto prop = storage::PropertyId::FromUint(dist(gen)); - store.emplace(prop, storage::PropertyValue(42)); + auto prop = memgraph::storage::PropertyId::FromUint(dist(gen)); + store.emplace(prop, memgraph::storage::PropertyValue(42)); ++counter; } state.SetItemsProcessed(counter); @@ -64,16 +64,16 @@ BENCHMARK(StdMapSet)->RangeMultiplier(2)->Range(1, 1024)->Unit(benchmark::kNanos // NOLINTNEXTLINE(google-runtime-references) static void PropertyStoreGet(benchmark::State &state) { - storage::PropertyStore store; + memgraph::storage::PropertyStore store; for (uint64_t i = 0; i < state.range(0); ++i) { - auto prop = storage::PropertyId::FromUint(i); - store.SetProperty(prop, storage::PropertyValue(0)); + auto prop = memgraph::storage::PropertyId::FromUint(i); + store.SetProperty(prop, memgraph::storage::PropertyValue(0)); } std::mt19937 gen(state.thread_index()); std::uniform_int_distribution dist(0, state.range(0) - 1); uint64_t counter = 0; while (state.KeepRunning()) { - auto prop = storage::PropertyId::FromUint(dist(gen)); + auto prop = memgraph::storage::PropertyId::FromUint(dist(gen)); store.GetProperty(prop); ++counter; } @@ -88,16 +88,16 @@ BENCHMARK(PropertyStoreGet)->RangeMultiplier(2)->Range(1, 1024)->Unit(benchmark: // NOLINTNEXTLINE(google-runtime-references) static void StdMapGet(benchmark::State &state) { - std::map store; + std::map store; for (uint64_t i = 0; i < state.range(0); ++i) { - auto prop = storage::PropertyId::FromUint(i); - store.emplace(prop, storage::PropertyValue(0)); + auto prop = memgraph::storage::PropertyId::FromUint(i); + store.emplace(prop, memgraph::storage::PropertyValue(0)); } std::mt19937 gen(state.thread_index()); std::uniform_int_distribution dist(0, state.range(0) - 1); uint64_t counter = 0; while (state.KeepRunning()) { - auto prop = storage::PropertyId::FromUint(dist(gen)); + auto prop = memgraph::storage::PropertyId::FromUint(dist(gen)); store.find(prop); ++counter; } diff --git a/tests/concurrent/network_common.hpp b/tests/concurrent/network_common.hpp index a1da07781..bf81adb75 100644 --- a/tests/concurrent/network_common.hpp +++ b/tests/concurrent/network_common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -25,15 +25,15 @@ static constexpr const int SIZE = 60000; static constexpr const int REPLY = 10; -using io::network::Endpoint; -using io::network::Socket; +using memgraph::io::network::Endpoint; +using memgraph::io::network::Socket; class TestData {}; class TestSession { public: - TestSession(TestData *, const io::network::Endpoint &, communication::InputStream *input_stream, - communication::OutputStream *output_stream) + TestSession(TestData *, const memgraph::io::network::Endpoint &, memgraph::communication::InputStream *input_stream, + memgraph::communication::OutputStream *output_stream) : input_stream_(input_stream), output_stream_(output_stream) {} void Execute() { @@ -50,12 +50,12 @@ class TestSession { input_stream_->Shift(size + 2); } - communication::InputStream *input_stream_; - communication::OutputStream *output_stream_; + memgraph::communication::InputStream *input_stream_; + memgraph::communication::OutputStream *output_stream_; }; -using ContextT = communication::ServerContext; -using ServerT = communication::Server; +using ContextT = memgraph::communication::ServerContext; +using ServerT = memgraph::communication::Server; void client_run(int num, const char *interface, uint16_t port, const unsigned char *data, int lo, int hi) { std::stringstream name; diff --git a/tests/concurrent/network_read_hang.cpp b/tests/concurrent/network_read_hang.cpp index bc8b33f31..73389983d 100644 --- a/tests/concurrent/network_read_hang.cpp +++ b/tests/concurrent/network_read_hang.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,21 +26,21 @@ static constexpr const char interface[] = "127.0.0.1"; -using io::network::Endpoint; -using io::network::Socket; +using memgraph::io::network::Endpoint; +using memgraph::io::network::Socket; class TestData {}; class TestSession { public: - TestSession(TestData *, const io::network::Endpoint &, communication::InputStream *input_stream, - communication::OutputStream *output_stream) + TestSession(TestData *, const memgraph::io::network::Endpoint &, memgraph::communication::InputStream *input_stream, + memgraph::communication::OutputStream *output_stream) : input_stream_(input_stream), output_stream_(output_stream) {} void Execute() { output_stream_->Write(input_stream_->data(), input_stream_->size()); } - communication::InputStream *input_stream_; - communication::OutputStream *output_stream_; + memgraph::communication::InputStream *input_stream_; + memgraph::communication::OutputStream *output_stream_; }; std::atomic run{true}; @@ -70,8 +70,8 @@ TEST(Network, SocketReadHangOnConcurrentConnections) { TestData data; int N = (std::thread::hardware_concurrency() + 1) / 2; int Nc = N * 3; - communication::ServerContext context; - communication::Server server(endpoint, &data, &context, -1, "Test", N); + memgraph::communication::ServerContext context; + memgraph::communication::Server server(endpoint, &data, &context, -1, "Test", N); ASSERT_TRUE(server.Start()); const auto &ep = server.endpoint(); diff --git a/tests/concurrent/skip_list_insert.cpp b/tests/concurrent/skip_list_insert.cpp index 229e85962..0c61240ff 100644 --- a/tests/concurrent/skip_list_insert.cpp +++ b/tests/concurrent/skip_list_insert.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ const int kNumThreads = 8; const uint64_t kMaxNum = 10000000; int main() { - utils::SkipList list; + memgraph::utils::SkipList list; std::vector threads; for (int i = 0; i < kNumThreads; ++i) { diff --git a/tests/concurrent/skip_list_insert_competitive.cpp b/tests/concurrent/skip_list_insert_competitive.cpp index c11d1f7ae..7bfc1d8d4 100644 --- a/tests/concurrent/skip_list_insert_competitive.cpp +++ b/tests/concurrent/skip_list_insert_competitive.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ const int kNumThreads = 8; const uint64_t kMaxNum = 10000000; int main() { - utils::SkipList list; + memgraph::utils::SkipList list; std::atomic success{0}; diff --git a/tests/concurrent/skip_list_mixed.cpp b/tests/concurrent/skip_list_mixed.cpp index b796e8b44..004d42c93 100644 --- a/tests/concurrent/skip_list_mixed.cpp +++ b/tests/concurrent/skip_list_mixed.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,7 +26,7 @@ const int kNumThreadsFind = 3; const uint64_t kMaxNum = 10000000; int main() { - utils::SkipList list; + memgraph::utils::SkipList list; std::atomic run{true}, modify_done{false}; diff --git a/tests/concurrent/skip_list_remove.cpp b/tests/concurrent/skip_list_remove.cpp index 9ca8b139c..c5d37aaa8 100644 --- a/tests/concurrent/skip_list_remove.cpp +++ b/tests/concurrent/skip_list_remove.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ const int kNumThreads = 8; const uint64_t kMaxNum = 10000000; int main() { - utils::SkipList list; + memgraph::utils::SkipList list; for (int i = 0; i < kMaxNum * kNumThreads; ++i) { auto acc = list.access(); diff --git a/tests/concurrent/skip_list_remove_competitive.cpp b/tests/concurrent/skip_list_remove_competitive.cpp index e52508673..3be5e57ed 100644 --- a/tests/concurrent/skip_list_remove_competitive.cpp +++ b/tests/concurrent/skip_list_remove_competitive.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ const int kNumThreads = 8; const uint64_t kMaxNum = 10000000; int main() { - utils::SkipList list; + memgraph::utils::SkipList list; for (int i = 0; i < kMaxNum; ++i) { auto acc = list.access(); diff --git a/tests/concurrent/spin_lock.cpp b/tests/concurrent/spin_lock.cpp index 135c5d378..6e9cb319a 100644 --- a/tests/concurrent/spin_lock.cpp +++ b/tests/concurrent/spin_lock.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,13 +18,13 @@ #include "utils/spin_lock.hpp" int x = 0; -utils::SpinLock lock; +memgraph::utils::SpinLock lock; void test_lock() { using namespace std::literals; { - std::unique_lock guard(lock); + std::unique_lock guard(lock); x++; std::this_thread::sleep_for(25ms); diff --git a/tests/concurrent/stack.cpp b/tests/concurrent/stack.cpp index c0ec63f86..e74ec870b 100644 --- a/tests/concurrent/stack.cpp +++ b/tests/concurrent/stack.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -29,10 +29,10 @@ DEFINE_int32(max_value, 100000000, "Maximum value that should be inserted"); int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - utils::Stack stack; + memgraph::utils::Stack stack; std::vector threads; - utils::Timer timer; + memgraph::utils::Timer timer; for (int i = 0; i < kNumThreads; ++i) { threads.push_back(std::thread([&stack, i] { for (uint64_t item = i; item < FLAGS_max_value; item += kNumThreads) { diff --git a/tests/concurrent/storage_indices.cpp b/tests/concurrent/storage_indices.cpp index 08cb21ddd..017442fdc 100644 --- a/tests/concurrent/storage_indices.cpp +++ b/tests/concurrent/storage_indices.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,7 +26,7 @@ const uint64_t kVerifierBatchSize = 10; const uint64_t kMutatorBatchSize = 1000; TEST(Storage, LabelIndex) { - auto store = storage::Storage(); + auto store = memgraph::storage::Storage(); auto label = store.NameToLabel("label"); ASSERT_TRUE(store.CreateIndex(label)); @@ -35,8 +35,8 @@ TEST(Storage, LabelIndex) { verifiers.reserve(kNumVerifiers); for (uint64_t i = 0; i < kNumVerifiers; ++i) { verifiers.emplace_back([&store, label, num = i] { - utils::ThreadSetName(fmt::format("verifier{}", num)); - std::unordered_map gids; + memgraph::utils::ThreadSetName(fmt::format("verifier{}", num)); + std::unordered_map gids; gids.reserve(kNumIterations * kVerifierBatchSize); for (uint64_t i = 0; i < kNumIterations; ++i) { for (uint64_t j = 0; j < kVerifierBatchSize; ++j) { @@ -50,7 +50,7 @@ TEST(Storage, LabelIndex) { } { auto acc = store.Access(); - auto vertices = acc.Vertices(label, storage::View::OLD); + auto vertices = acc.Vertices(label, memgraph::storage::View::OLD); for (auto vertex : vertices) { auto it = gids.find(vertex.Gid()); if (it != gids.end()) { @@ -72,8 +72,8 @@ TEST(Storage, LabelIndex) { mutators.reserve(kNumMutators); for (uint64_t i = 0; i < kNumMutators; ++i) { mutators.emplace_back([&store, &mutators_run, label, num = i] { - utils::ThreadSetName(fmt::format("mutator{}", num)); - std::vector gids; + memgraph::utils::ThreadSetName(fmt::format("mutator{}", num)); + std::vector gids; gids.resize(kMutatorBatchSize); while (mutators_run.load(std::memory_order_acquire)) { for (uint64_t i = 0; i < kMutatorBatchSize; ++i) { @@ -87,7 +87,7 @@ TEST(Storage, LabelIndex) { } for (uint64_t i = 0; i < kMutatorBatchSize; ++i) { auto acc = store.Access(); - auto vertex = acc.FindVertex(gids[i], storage::View::OLD); + auto vertex = acc.FindVertex(gids[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); ASSERT_TRUE(acc.DeleteVertex(&*vertex).HasValue()); ASSERT_FALSE(acc.Commit().HasError()); @@ -107,7 +107,7 @@ TEST(Storage, LabelIndex) { } TEST(Storage, LabelPropertyIndex) { - auto store = storage::Storage(); + auto store = memgraph::storage::Storage(); auto label = store.NameToLabel("label"); auto prop = store.NameToProperty("prop"); @@ -117,8 +117,8 @@ TEST(Storage, LabelPropertyIndex) { verifiers.reserve(kNumVerifiers); for (uint64_t i = 0; i < kNumVerifiers; ++i) { verifiers.emplace_back([&store, label, prop, num = i] { - utils::ThreadSetName(fmt::format("verifier{}", num)); - std::unordered_map gids; + memgraph::utils::ThreadSetName(fmt::format("verifier{}", num)); + std::unordered_map gids; gids.reserve(kNumIterations * kVerifierBatchSize); for (uint64_t i = 0; i < kNumIterations; ++i) { for (uint64_t j = 0; j < kVerifierBatchSize; ++j) { @@ -131,7 +131,7 @@ TEST(Storage, LabelPropertyIndex) { ASSERT_TRUE(*ret); } { - auto old_value = vertex.SetProperty(prop, storage::PropertyValue(vertex.Gid().AsInt())); + auto old_value = vertex.SetProperty(prop, memgraph::storage::PropertyValue(vertex.Gid().AsInt())); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } @@ -139,7 +139,7 @@ TEST(Storage, LabelPropertyIndex) { } { auto acc = store.Access(); - auto vertices = acc.Vertices(label, prop, storage::View::OLD); + auto vertices = acc.Vertices(label, prop, memgraph::storage::View::OLD); for (auto vertex : vertices) { auto it = gids.find(vertex.Gid()); if (it != gids.end()) { @@ -161,8 +161,8 @@ TEST(Storage, LabelPropertyIndex) { mutators.reserve(kNumMutators); for (uint64_t i = 0; i < kNumMutators; ++i) { mutators.emplace_back([&store, &mutators_run, label, prop, num = i] { - utils::ThreadSetName(fmt::format("mutator{}", num)); - std::vector gids; + memgraph::utils::ThreadSetName(fmt::format("mutator{}", num)); + std::vector gids; gids.resize(kMutatorBatchSize); while (mutators_run.load(std::memory_order_acquire)) { for (uint64_t i = 0; i < kMutatorBatchSize; ++i) { @@ -175,7 +175,7 @@ TEST(Storage, LabelPropertyIndex) { ASSERT_TRUE(*ret); } { - auto old_value = vertex.SetProperty(prop, storage::PropertyValue(vertex.Gid().AsInt())); + auto old_value = vertex.SetProperty(prop, memgraph::storage::PropertyValue(vertex.Gid().AsInt())); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } @@ -183,7 +183,7 @@ TEST(Storage, LabelPropertyIndex) { } for (uint64_t i = 0; i < kMutatorBatchSize; ++i) { auto acc = store.Access(); - auto vertex = acc.FindVertex(gids[i], storage::View::OLD); + auto vertex = acc.FindVertex(gids[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); ASSERT_TRUE(acc.DeleteVertex(&*vertex).HasValue()); ASSERT_FALSE(acc.Commit().HasError()); diff --git a/tests/concurrent/storage_unique_constraints.cpp b/tests/concurrent/storage_unique_constraints.cpp index 3e50b01a4..63ad00abb 100644 --- a/tests/concurrent/storage_unique_constraints.cpp +++ b/tests/concurrent/storage_unique_constraints.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,9 +20,9 @@ const int kNumThreads = 8; #define ASSERT_OK(x) ASSERT_FALSE((x).HasError()) -using storage::LabelId; -using storage::PropertyId; -using storage::PropertyValue; +using memgraph::storage::LabelId; +using memgraph::storage::PropertyId; +using memgraph::storage::PropertyValue; class StorageUniqueConstraints : public ::testing::Test { protected: @@ -43,19 +43,20 @@ class StorageUniqueConstraints : public ::testing::Test { ASSERT_OK(acc.Commit()); } - storage::Storage storage; + memgraph::storage::Storage storage; LabelId label; PropertyId prop1; PropertyId prop2; PropertyId prop3; - storage::Gid gids[kNumThreads]; + memgraph::storage::Gid gids[kNumThreads]; }; -void SetProperties(storage::Storage *storage, storage::Gid gid, const std::vector &properties, - const std::vector &values, bool *commit_status) { +void SetProperties(memgraph::storage::Storage *storage, memgraph::storage::Gid gid, + const std::vector &properties, const std::vector &values, + bool *commit_status) { ASSERT_EQ(properties.size(), values.size()); auto acc = storage->Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); int value = 0; for (int iter = 0; iter < 40000; ++iter) { @@ -69,9 +70,9 @@ void SetProperties(storage::Storage *storage, storage::Gid gid, const std::vecto *commit_status = !acc.Commit().HasError(); } -void AddLabel(storage::Storage *storage, storage::Gid gid, LabelId label, bool *commit_status) { +void AddLabel(memgraph::storage::Storage *storage, memgraph::storage::Gid gid, LabelId label, bool *commit_status) { auto acc = storage->Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); for (int iter = 0; iter < 40000; ++iter) { ASSERT_OK(vertex->AddLabel(label)); @@ -85,14 +86,14 @@ TEST_F(StorageUniqueConstraints, ChangeProperties) { { auto res = storage.CreateUniqueConstraint(label, {prop1, prop2, prop3}); ASSERT_TRUE(res.HasValue()); - ASSERT_EQ(res.GetValue(), storage::UniqueConstraints::CreationStatus::SUCCESS); + ASSERT_EQ(res.GetValue(), memgraph::storage::UniqueConstraints::CreationStatus::SUCCESS); } { auto acc = storage.Access(); // NOLINTNEXTLINE(modernize-loop-convert) for (int i = 0; i < kNumThreads; ++i) { - auto vertex = acc.FindVertex(gids[i], storage::View::OLD); + auto vertex = acc.FindVertex(gids[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); ASSERT_OK(vertex->AddLabel(label)); } @@ -167,7 +168,7 @@ TEST_F(StorageUniqueConstraints, ChangeLabels) { { auto res = storage.CreateUniqueConstraint(label, {prop1, prop2, prop3}); ASSERT_TRUE(res.HasValue()); - ASSERT_EQ(res.GetValue(), storage::UniqueConstraints::CreationStatus::SUCCESS); + ASSERT_EQ(res.GetValue(), memgraph::storage::UniqueConstraints::CreationStatus::SUCCESS); } // In the first part of the test, each transaction tries to add the same label @@ -179,7 +180,7 @@ TEST_F(StorageUniqueConstraints, ChangeLabels) { auto acc = storage.Access(); // NOLINTNEXTLINE(modernize-loop-convert) for (int i = 0; i < kNumThreads; ++i) { - auto vertex = acc.FindVertex(gids[i], storage::View::OLD); + auto vertex = acc.FindVertex(gids[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); ASSERT_OK(vertex->SetProperty(prop1, PropertyValue(1))); ASSERT_OK(vertex->SetProperty(prop2, PropertyValue(2))); @@ -194,7 +195,7 @@ TEST_F(StorageUniqueConstraints, ChangeLabels) { auto acc = storage.Access(); // NOLINTNEXTLINE(modernize-loop-convert) for (int i = 0; i < kNumThreads; ++i) { - auto vertex = acc.FindVertex(gids[i], storage::View::OLD); + auto vertex = acc.FindVertex(gids[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); ASSERT_OK(vertex->RemoveLabel(label)); } @@ -225,7 +226,7 @@ TEST_F(StorageUniqueConstraints, ChangeLabels) { auto acc = storage.Access(); // NOLINTNEXTLINE(modernize-loop-convert) for (int i = 0; i < kNumThreads; ++i) { - auto vertex = acc.FindVertex(gids[i], storage::View::OLD); + auto vertex = acc.FindVertex(gids[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); ASSERT_OK(vertex->SetProperty(prop1, PropertyValue(3 * i))); ASSERT_OK(vertex->SetProperty(prop2, PropertyValue(3 * i + 1))); @@ -240,7 +241,7 @@ TEST_F(StorageUniqueConstraints, ChangeLabels) { auto acc = storage.Access(); // NOLINTNEXTLINE(modernize-loop-convert) for (int i = 0; i < kNumThreads; ++i) { - auto vertex = acc.FindVertex(gids[i], storage::View::OLD); + auto vertex = acc.FindVertex(gids[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); ASSERT_OK(vertex->RemoveLabel(label)); } diff --git a/tests/e2e/isolation_levels/isolation_levels.cpp b/tests/e2e/isolation_levels/isolation_levels.cpp index a8f75b77e..2f685be99 100644 --- a/tests/e2e/isolation_levels/isolation_levels.cpp +++ b/tests/e2e/isolation_levels/isolation_levels.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -240,7 +240,7 @@ void TestNextIsolationLevel() { int main(int argc, char **argv) { google::SetUsageMessage("Memgraph E2E Isolation Levels"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); diff --git a/tests/e2e/memory/memory_control.cpp b/tests/e2e/memory/memory_control.cpp index 9cab68b09..fc154684b 100644 --- a/tests/e2e/memory/memory_control.cpp +++ b/tests/e2e/memory/memory_control.cpp @@ -21,7 +21,7 @@ DEFINE_uint64(timeout, 120, "Timeout seconds"); int main(int argc, char **argv) { google::SetUsageMessage("Memgraph E2E Memory Control"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); @@ -36,7 +36,7 @@ int main(int argc, char **argv) { const auto *create_query = "UNWIND range(1, 50) as u CREATE (n {string: \"Some longer string\"}) RETURN n;"; - utils::Timer timer; + memgraph::utils::Timer timer; while (true) { if (timer.Elapsed>().count() > FLAGS_timeout) { LOG_FATAL("The test timed out"); diff --git a/tests/e2e/memory/memory_limit_global_alloc.cpp b/tests/e2e/memory/memory_limit_global_alloc.cpp index 916fa0619..611e2554a 100644 --- a/tests/e2e/memory/memory_limit_global_alloc.cpp +++ b/tests/e2e/memory/memory_limit_global_alloc.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ DEFINE_uint64(timeout, 120, "Timeout seconds"); int main(int argc, char **argv) { google::SetUsageMessage("Memgraph E2E Memory Limit For Global Allocators"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); diff --git a/tests/e2e/memory/memory_limit_global_alloc_proc.cpp b/tests/e2e/memory/memory_limit_global_alloc_proc.cpp index 5f8cb7864..7efb435c3 100644 --- a/tests/e2e/memory/memory_limit_global_alloc_proc.cpp +++ b/tests/e2e/memory/memory_limit_global_alloc_proc.cpp @@ -22,7 +22,7 @@ DEFINE_uint64(timeout, 120, "Timeout seconds"); int main(int argc, char **argv) { google::SetUsageMessage("Memgraph E2E Memory Limit For Global Allocators"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); diff --git a/tests/e2e/module_file_manager/module_file_manager.cpp b/tests/e2e/module_file_manager/module_file_manager.cpp index 68cc0413e..a6daa8bc1 100644 --- a/tests/e2e/module_file_manager/module_file_manager.cpp +++ b/tests/e2e/module_file_manager/module_file_manager.cpp @@ -176,7 +176,7 @@ def simple2(ctx: mgp.ProcCtx) -> mgp.Record(result=bool): int main(int argc, char **argv) { google::SetUsageMessage("Memgraph E2E Isolation Levels"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); auto client = GetClient(); @@ -241,7 +241,7 @@ int main(int argc, char **argv) { const auto non_module_directory = std::filesystem::temp_directory_path() / "module_file_manager_e2e_non_module_directory"; - utils::EnsureDirOrDie(non_module_directory); + memgraph::utils::EnsureDirOrDie(non_module_directory); const auto non_module_file_path{non_module_directory / "something.py"}; { diff --git a/tests/e2e/replication/common.hpp b/tests/e2e/replication/common.hpp index 5fcc8f39f..f3cff293e 100644 --- a/tests/e2e/replication/common.hpp +++ b/tests/e2e/replication/common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -34,17 +34,17 @@ DEFINE_double(reads_duration_limit, 10.0, "How long should the client perform re namespace mg::e2e::replication { auto ParseDatabaseEndpoints(const std::string &database_endpoints_str) { - const auto db_endpoints_strs = utils::Split(database_endpoints_str, ","); - std::vector database_endpoints; + const auto db_endpoints_strs = memgraph::utils::Split(database_endpoints_str, ","); + std::vector database_endpoints; for (const auto &db_endpoint_str : db_endpoints_strs) { - const auto maybe_host_port = io::network::Endpoint::ParseSocketOrIpAddress(db_endpoint_str, 7687); + const auto maybe_host_port = memgraph::io::network::Endpoint::ParseSocketOrIpAddress(db_endpoint_str, 7687); MG_ASSERT(maybe_host_port); - database_endpoints.emplace_back(io::network::Endpoint(maybe_host_port->first, maybe_host_port->second)); + database_endpoints.emplace_back(memgraph::io::network::Endpoint(maybe_host_port->first, maybe_host_port->second)); } return database_endpoints; } -auto Connect(const io::network::Endpoint &database_endpoint) { +auto Connect(const memgraph::io::network::Endpoint &database_endpoint) { mg::Client::Params params; params.host = database_endpoint.address; params.port = database_endpoint.port; diff --git a/tests/e2e/replication/constraints.cpp b/tests/e2e/replication/constraints.cpp index f98e8d9b8..f56e97946 100644 --- a/tests/e2e/replication/constraints.cpp +++ b/tests/e2e/replication/constraints.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -25,7 +25,7 @@ int main(int argc, char **argv) { google::SetUsageMessage("Memgraph E2E Replication Read-write Benchmark"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); auto database_endpoints = mg::e2e::replication::ParseDatabaseEndpoints(FLAGS_database_endpoints); @@ -83,7 +83,7 @@ int main(int argc, char **argv) { auto client = mg::e2e::replication::Connect(database_endpoint); mg::e2e::replication::IntGenerator node_update_generator(fmt::format("NodeUpdateGenerator {}", i), 0, FLAGS_nodes - 1); - utils::Timer t; + memgraph::utils::Timer t; while (true) { local_duration = t.Elapsed().count(); diff --git a/tests/e2e/replication/read_write_benchmark.cpp b/tests/e2e/replication/read_write_benchmark.cpp index 73ffc8b7b..df1c4fb90 100644 --- a/tests/e2e/replication/read_write_benchmark.cpp +++ b/tests/e2e/replication/read_write_benchmark.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -29,7 +29,7 @@ DEFINE_string(output_file, "memgraph__e2e__replication__read_write_benchmark.jso int main(int argc, char **argv) { google::SetUsageMessage("Memgraph E2E Replication Read-write Benchmark"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); const auto database_endpoints = mg::e2e::replication::ParseDatabaseEndpoints(FLAGS_database_endpoints); nlohmann::json output; @@ -62,7 +62,7 @@ int main(int argc, char **argv) { } spdlog::info("All indexes are in-place."); - utils::Timer node_write_timer; + memgraph::utils::Timer node_write_timer; for (int i = 0; i < FLAGS_nodes; ++i) { client->Execute("CREATE (:Node {id:" + std::to_string(i) + "});"); client->DiscardAll(); @@ -70,7 +70,7 @@ int main(int argc, char **argv) { output["node_write_time"] = node_write_timer.Elapsed().count(); mg::e2e::replication::IntGenerator edge_generator("EdgeCreateGenerator", 0, FLAGS_nodes - 1); - utils::Timer edge_write_timer; + memgraph::utils::Timer edge_write_timer; for (int i = 0; i < FLAGS_edges; ++i) { client->Execute("MATCH (n {id:" + std::to_string(edge_generator.Next()) + "}), (m {id:" + std::to_string(edge_generator.Next()) + "}) CREATE (n)-[:Edge]->(m);"); @@ -90,10 +90,10 @@ int main(int argc, char **argv) { for (int i = 0; i < num_threads; ++i) { const auto &database_endpoint = database_endpoints[i % database_endpoints.size()]; threads.emplace_back([i, &database_endpoint, &query_counter, &local_duration = thread_duration[i]] { - utils::ThreadSetName(fmt::format("BenchWriter{}", i)); + memgraph::utils::ThreadSetName(fmt::format("BenchWriter{}", i)); auto client = mg::e2e::replication::Connect(database_endpoint); mg::e2e::replication::IntGenerator node_generator(fmt::format("NodeReadGenerator {}", i), 0, FLAGS_nodes - 1); - utils::Timer t; + memgraph::utils::Timer t; while (true) { local_duration = t.Elapsed().count(); diff --git a/tests/e2e/temporal_types/roundtrip.cpp b/tests/e2e/temporal_types/roundtrip.cpp index 61e81aee4..72d664db0 100644 --- a/tests/e2e/temporal_types/roundtrip.cpp +++ b/tests/e2e/temporal_types/roundtrip.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -41,7 +41,7 @@ auto GetItFromNodeProperty(const mg::ConstMap &props, const std::string_view pro } void RoundtripDuration(mg::Client &client, const std::string_view group, const std::string_view property, - const std::string_view dur_str, const utils::Duration &expected) { + const std::string_view dur_str, const memgraph::utils::Duration &expected) { const auto query = fmt::format("CREATE (:{} {{{}: DURATION({})}})", group, property, dur_str); MaybeExecuteQuery(client, query, "Duration"); const auto result = MaybeExecuteMatch(client, group); @@ -56,7 +56,7 @@ void RoundtripDuration(mg::Client &client, const std::string_view group, const s } void RoundtripDate(mg::Client &client, const std::string_view group, const std::string_view property, - const std::string_view date_str, const utils::Date &expected) { + const std::string_view date_str, const memgraph::utils::Date &expected) { const auto query = fmt::format("CREATE (:{} {{{}: DATE({})}})", group, property, date_str); MaybeExecuteQuery(client, query, "Date"); const auto result = MaybeExecuteMatch(client, group); @@ -75,7 +75,7 @@ struct LocalTimeParams { }; void RoundtripLocalTime(mg::Client &client, const std::string_view group, const std::string_view property, - const std::string_view lt_str, const utils::LocalTime &expected) { + const std::string_view lt_str, const memgraph::utils::LocalTime &expected) { const auto query = fmt::format("CREATE (:{} {{{}: LOCALTIME({})}})", group, property, lt_str); MaybeExecuteQuery(client, query, "LocalTime"); const auto result = MaybeExecuteMatch(client, group); @@ -88,7 +88,7 @@ void RoundtripLocalTime(mg::Client &client, const std::string_view group, const } void RoundtripLocalDateTime(mg::Client &client, const std::string_view group, const std::string_view property, - const std::string_view ldt_str, const utils::LocalDateTime &expected) { + const std::string_view ldt_str, const memgraph::utils::LocalDateTime &expected) { const auto query = fmt::format("CREATE (:{} {{{}: LOCALDATETIME({})}})", group, property, ldt_str); MaybeExecuteQuery(client, query, "LocalDateTime"); const auto result = MaybeExecuteMatch(client, group); @@ -108,15 +108,15 @@ void TestDate(mg::Client &client) { auto date_query_map = [](auto year, auto month, auto day) { return fmt::format("{{year:{}, month:{}, day:{}}}", year, month, day); }; - RoundtripDate(client, "Person1", "dob", date_query(1960, 1, 12), utils::Date({1960, 1, 12})); - RoundtripDate(client, "Person2", "dob", date_query(1970, 1, 1), utils::Date({1970, 1, 1})); - RoundtripDate(client, "Person3", "dob", date_query(1971, 2, 2), utils::Date({1971, 2, 2})); - RoundtripDate(client, "Person4", "dob", date_query(2021, 12, 9), utils::Date({2021, 12, 9})); + RoundtripDate(client, "Person1", "dob", date_query(1960, 1, 12), memgraph::utils::Date({1960, 1, 12})); + RoundtripDate(client, "Person2", "dob", date_query(1970, 1, 1), memgraph::utils::Date({1970, 1, 1})); + RoundtripDate(client, "Person3", "dob", date_query(1971, 2, 2), memgraph::utils::Date({1971, 2, 2})); + RoundtripDate(client, "Person4", "dob", date_query(2021, 12, 9), memgraph::utils::Date({2021, 12, 9})); - RoundtripDate(client, "PersonMap1", "dob", date_query_map(1970, 1, 1), utils::Date({1970, 1, 1})); - RoundtripDate(client, "PersonMap2", "dob", date_query_map(1971, 6, 5), utils::Date({1971, 6, 5})); - RoundtripDate(client, "PersonMap3", "dob", date_query_map(2000, 8, 9), utils::Date({2000, 8, 9})); - RoundtripDate(client, "PersonMap4", "dob", date_query_map(2021, 12, 9), utils::Date({2021, 12, 9})); + RoundtripDate(client, "PersonMap1", "dob", date_query_map(1970, 1, 1), memgraph::utils::Date({1970, 1, 1})); + RoundtripDate(client, "PersonMap2", "dob", date_query_map(1971, 6, 5), memgraph::utils::Date({1971, 6, 5})); + RoundtripDate(client, "PersonMap3", "dob", date_query_map(2000, 8, 9), memgraph::utils::Date({2000, 8, 9})); + RoundtripDate(client, "PersonMap4", "dob", date_query_map(2021, 12, 9), memgraph::utils::Date({2021, 12, 9})); } void TestLocalTime(mg::Client &client) { @@ -127,7 +127,7 @@ void TestLocalTime(mg::Client &client) { }; const auto parse = [](const std::string_view query) { - return utils::LocalTime(utils::ParseLocalTimeParameters(fmt::format("{}", query)).first); + return memgraph::utils::LocalTime(memgraph::utils::ParseLocalTimeParameters(fmt::format("{}", query)).first); }; const auto str1 = lt(1, 3, 3, 33); @@ -140,13 +140,13 @@ void TestLocalTime(mg::Client &client) { RoundtripLocalTime(client, "LT4", "time", lt_query(str4), parse(str4)); const auto str5 = lt_query_map(10, 4, 22, 33, 99); - RoundtripLocalTime(client, "LT5", "time", str5, utils::LocalTime({10, 4, 22, 33, 99})); + RoundtripLocalTime(client, "LT5", "time", str5, memgraph::utils::LocalTime({10, 4, 22, 33, 99})); const auto str6 = lt_query_map(0, 0, 21, 12, 88); - RoundtripLocalTime(client, "LT6", "time", str6, utils::LocalTime({0, 0, 21, 12, 88})); + RoundtripLocalTime(client, "LT6", "time", str6, memgraph::utils::LocalTime({0, 0, 21, 12, 88})); const auto str7 = lt_query_map(8, 4, 22, 33, 99); - RoundtripLocalTime(client, "LT7", "time", str7, utils::LocalTime({8, 4, 22, 33, 99})); + RoundtripLocalTime(client, "LT7", "time", str7, memgraph::utils::LocalTime({8, 4, 22, 33, 99})); const auto str8 = lt_query_map(23, 1, 0, 0, 0); - RoundtripLocalTime(client, "LT8", "time", str8, utils::LocalTime({23, 1, 0, 0, 0})); + RoundtripLocalTime(client, "LT8", "time", str8, memgraph::utils::LocalTime({23, 1, 0, 0, 0})); } void TestLocalDateTime(mg::Client &client) { @@ -154,8 +154,8 @@ void TestLocalDateTime(mg::Client &client) { return fmt::format("{:0>2}-{:0>2}-{:0>2}T{:0>2}:{:0>2}:{:0>2}", y, mo, d, h, m, s); }; auto parse = [](const std::string_view str) { - const auto [dt, lt] = utils::ParseLocalDateTimeParameters(str); - return utils::LocalDateTime(dt, lt); + const auto [dt, lt] = memgraph::utils::ParseLocalDateTimeParameters(str); + return memgraph::utils::LocalDateTime(dt, lt); }; auto ldt_query = [](const std::string_view str) { return fmt::format("\"{}\"", str); }; const auto str = ldt(1200, 8, 9, 12, 33, 1); @@ -170,11 +170,11 @@ void TestLocalDateTime(mg::Client &client) { RoundtripLocalDateTime(client, "LDT5", "time", ldt_query(str4), parse(str4)); RoundtripLocalDateTime(client, "Map_LDT1", "time", "{year:1960, month:10, day:1}", - utils::LocalDateTime({1960, 10, 1}, {})); + memgraph::utils::LocalDateTime({1960, 10, 1}, {})); RoundtripLocalDateTime(client, "Map_LDT2", "time", "{year:1960, month:10, day:1, hour:1, minute:2, second:33}", - utils::LocalDateTime({1960, 10, 1}, {1, 2, 33})); - RoundtripLocalDateTime(client, "Map_LDT3", "time", "{hour:10}", utils::LocalDateTime({}, {.hour = 10})); - RoundtripLocalDateTime(client, "Map_LDT4", "time", "{day:2}", utils::LocalDateTime({.day = 2}, {})); + memgraph::utils::LocalDateTime({1960, 10, 1}, {1, 2, 33})); + RoundtripLocalDateTime(client, "Map_LDT3", "time", "{hour:10}", memgraph::utils::LocalDateTime({}, {.hour = 10})); + RoundtripLocalDateTime(client, "Map_LDT4", "time", "{day:2}", memgraph::utils::LocalDateTime({.day = 2}, {})); } void TestDuration(mg::Client &client) { @@ -182,40 +182,48 @@ void TestDuration(mg::Client &client) { return fmt::format("\"P{}DT{}H{}M{}.{}S\"", d, h, m, s, ss); }; - RoundtripDuration(client, "Runner1", "time", dur(3, 5, 6, 2, 1), utils::Duration({3, 5, 6, 2.1})); - RoundtripDuration(client, "Runner2", "time", dur(8, 9, 8, 4, 12), utils::Duration({8, 9, 8, 4.12})); - RoundtripDuration(client, "Runner3", "time", dur(10, 10, 12, 44, 44), utils::Duration({10, 10, 12, 44.44})); - RoundtripDuration(client, "Runner4", "time", dur(23, 11, 13, 59, 100000), utils::Duration({23, 11, 13, 59, 100})); - RoundtripDuration(client, "Runner5", "time", dur(0, 110, 14, 88, 400000), utils::Duration({0, 110, 14, 88, 400})); + RoundtripDuration(client, "Runner1", "time", dur(3, 5, 6, 2, 1), memgraph::utils::Duration({3, 5, 6, 2.1})); + RoundtripDuration(client, "Runner2", "time", dur(8, 9, 8, 4, 12), memgraph::utils::Duration({8, 9, 8, 4.12})); + RoundtripDuration(client, "Runner3", "time", dur(10, 10, 12, 44, 44), memgraph::utils::Duration({10, 10, 12, 44.44})); + RoundtripDuration(client, "Runner4", "time", dur(23, 11, 13, 59, 100000), + memgraph::utils::Duration({23, 11, 13, 59, 100})); + RoundtripDuration(client, "Runner5", "time", dur(0, 110, 14, 88, 400000), + memgraph::utils::Duration({0, 110, 14, 88, 400})); // fractions - RoundtripDuration(client, "Runner6", "time", "\"P4.5D\"", utils::Duration(utils::DurationParameters{.day = 4.5})); - RoundtripDuration(client, "Runner7", "time", "\"PT9.3H\"", utils::Duration(utils::DurationParameters{.hour = 9.3})); - RoundtripDuration(client, "Runner8", "time", "\"PT4.2M\"", utils::Duration(utils::DurationParameters{.minute = 4.2})); - RoundtripDuration(client, "Runner9", "time", "\"PT8.4S\"", utils::Duration(utils::DurationParameters{.second = 8.4})); + RoundtripDuration(client, "Runner6", "time", "\"P4.5D\"", + memgraph::utils::Duration(memgraph::utils::DurationParameters{.day = 4.5})); + RoundtripDuration(client, "Runner7", "time", "\"PT9.3H\"", + memgraph::utils::Duration(memgraph::utils::DurationParameters{.hour = 9.3})); + RoundtripDuration(client, "Runner8", "time", "\"PT4.2M\"", + memgraph::utils::Duration(memgraph::utils::DurationParameters{.minute = 4.2})); + RoundtripDuration(client, "Runner9", "time", "\"PT8.4S\"", + memgraph::utils::Duration(memgraph::utils::DurationParameters{.second = 8.4})); RoundtripDuration(client, "RunnerMap1", "time", "{day:0, hour:4, minute:1, second:44, millisecond:44, microsecond:22}", - utils::Duration(utils::DurationParameters{0, 4, 1, 44, 44, 22})); - RoundtripDuration(client, "RunnerMap2", "time", "{day:15}", utils::Duration(utils::DurationParameters{15})); + memgraph::utils::Duration(memgraph::utils::DurationParameters{0, 4, 1, 44, 44, 22})); + RoundtripDuration(client, "RunnerMap2", "time", "{day:15}", + memgraph::utils::Duration(memgraph::utils::DurationParameters{15})); RoundtripDuration(client, "RunnerMap3", "time", "{hour:2.5}", - utils::Duration(utils::DurationParameters{.hour = 2.5})); + memgraph::utils::Duration(memgraph::utils::DurationParameters{.hour = 2.5})); RoundtripDuration(client, "RunnerMap4", "time", "{minute:10.5, second:44}", - utils::Duration(utils::DurationParameters{.minute = 10.5, .second = 44})); + memgraph::utils::Duration(memgraph::utils::DurationParameters{.minute = 10.5, .second = 44})); RoundtripDuration(client, "NegRunnerMap1", "time", "{day:0, hour:-1, minute:-2, second:-20, millisecond:-4, microsecond:-15}", - utils::Duration(utils::DurationParameters{0, -1, -2, -20, -4, -15})); - RoundtripDuration(client, "NegRunnerMap2", "time", "{day:-15}", utils::Duration(utils::DurationParameters{-15})); + memgraph::utils::Duration(memgraph::utils::DurationParameters{0, -1, -2, -20, -4, -15})); + RoundtripDuration(client, "NegRunnerMap2", "time", "{day:-15}", + memgraph::utils::Duration(memgraph::utils::DurationParameters{-15})); RoundtripDuration(client, "NegRunnerMap3", "time", "{hour:-2.5}", - utils::Duration(utils::DurationParameters{.hour = -2.5})); + memgraph::utils::Duration(memgraph::utils::DurationParameters{.hour = -2.5})); } int main(int argc, char **argv) { gflags::SetUsageMessage("Memgraph E2E temporal types roundtrip"); gflags::ParseCommandLineFlags(&argc, &argv, true); MG_ASSERT(FLAGS_bolt_port != 0); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); auto client = mg::Client::Connect({.port = static_cast(FLAGS_bolt_port)}); diff --git a/tests/e2e/triggers/common.cpp b/tests/e2e/triggers/common.cpp index b15701730..ccc8d47a2 100644 --- a/tests/e2e/triggers/common.cpp +++ b/tests/e2e/triggers/common.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -67,7 +67,7 @@ int GetNumberOfAllVertices(mg::Client &client) { void WaitForNumberOfAllVertices(mg::Client &client, int number_of_vertices) { using namespace std::chrono_literals; - utils::Timer timer{}; + memgraph::utils::Timer timer{}; while ((timer.Elapsed().count() <= 0.5) && GetNumberOfAllVertices(client) != number_of_vertices) { } CheckNumberOfAllVertices(client, number_of_vertices); diff --git a/tests/e2e/triggers/on_create_triggers.cpp b/tests/e2e/triggers/on_create_triggers.cpp index 4696768aa..e754e500f 100644 --- a/tests/e2e/triggers/on_create_triggers.cpp +++ b/tests/e2e/triggers/on_create_triggers.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -63,7 +63,7 @@ void DropOnCreateTriggers(mg::Client &client) { int main(int argc, char **argv) { gflags::SetUsageMessage("Memgraph E2E ON CREATE Triggers"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); diff --git a/tests/e2e/triggers/on_delete_triggers.cpp b/tests/e2e/triggers/on_delete_triggers.cpp index bb3a2d4ef..71711cb5d 100644 --- a/tests/e2e/triggers/on_delete_triggers.cpp +++ b/tests/e2e/triggers/on_delete_triggers.cpp @@ -130,7 +130,7 @@ void ValidateVertexExistance(mg::Client &client, const bool should_exist, const int main(int argc, char **argv) { gflags::SetUsageMessage("Memgraph E2E ON DELETE Triggers"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); diff --git a/tests/e2e/triggers/on_update_triggers.cpp b/tests/e2e/triggers/on_update_triggers.cpp index 9e47a63ef..0dda2f721 100644 --- a/tests/e2e/triggers/on_update_triggers.cpp +++ b/tests/e2e/triggers/on_update_triggers.cpp @@ -197,7 +197,7 @@ int main(int argc, char **argv) { constexpr std::string_view kUpdatedProperty = "updateProperty"; gflags::SetUsageMessage("Memgraph E2E ON UPDATE Triggers"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); diff --git a/tests/e2e/triggers/privilige_check.cpp b/tests/e2e/triggers/privilige_check.cpp index eb32a68fa..0706594e7 100644 --- a/tests/e2e/triggers/privilige_check.cpp +++ b/tests/e2e/triggers/privilige_check.cpp @@ -33,7 +33,7 @@ bool FunctionThrows(const auto &function) { int main(int argc, char **argv) { gflags::SetUsageMessage("Memgraph E2E Triggers privilege check"); gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); constexpr int kVertexId{42}; constexpr std::string_view kUserlessLabel{"USERLESS"}; diff --git a/tests/e2e/websocket/websocket.cpp b/tests/e2e/websocket/websocket.cpp index 8fc25343e..2c9ad0633 100644 --- a/tests/e2e/websocket/websocket.cpp +++ b/tests/e2e/websocket/websocket.cpp @@ -60,7 +60,7 @@ int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); MG_ASSERT(FLAGS_bolt_port != 0); MG_ASSERT(FLAGS_monitoring_port != 0); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); mg::Client::Init(); auto mg_client = GetBoltClient(static_cast(FLAGS_bolt_port), false); diff --git a/tests/e2e/websocket/websocket_ssl.cpp b/tests/e2e/websocket/websocket_ssl.cpp index a9dafbfea..7f49ace51 100644 --- a/tests/e2e/websocket/websocket_ssl.cpp +++ b/tests/e2e/websocket/websocket_ssl.cpp @@ -67,7 +67,7 @@ int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); MG_ASSERT(FLAGS_bolt_port != 0); MG_ASSERT(FLAGS_monitoring_port != 0); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); auto mg_client = GetBoltClient(static_cast(FLAGS_bolt_port), true); mg::Client::Init(); diff --git a/tests/integration/audit/tester.cpp b/tests/integration/audit/tester.cpp index 25840f57d..7753bd59c 100644 --- a/tests/integration/audit/tester.cpp +++ b/tests/integration/audit/tester.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,8 +26,8 @@ DEFINE_bool(use_ssl, false, "Set to true to connect with SSL to the server."); DEFINE_string(query, "", "Query to execute"); DEFINE_string(params_json, "{}", "Params for the query"); -communication::bolt::Value JsonToValue(const nlohmann::json &jv) { - communication::bolt::Value ret; +memgraph::communication::bolt::Value JsonToValue(const nlohmann::json &jv) { + memgraph::communication::bolt::Value ret; switch (jv.type()) { case nlohmann::json::value_t::null: break; @@ -47,7 +47,7 @@ communication::bolt::Value JsonToValue(const nlohmann::json &jv) { ret = jv.get(); break; case nlohmann::json::value_t::array: { - std::vector vec; + std::vector vec; for (const auto &item : jv) { vec.push_back(JsonToValue(item)); } @@ -55,10 +55,11 @@ communication::bolt::Value JsonToValue(const nlohmann::json &jv) { break; } case nlohmann::json::value_t::object: { - std::map map; + std::map map; for (auto it = jv.begin(); it != jv.end(); ++it) { auto tmp = JsonToValue(it.key()); - MG_ASSERT(tmp.type() == communication::bolt::Value::Type::String, "Expected a string as the map key!"); + MG_ASSERT(tmp.type() == memgraph::communication::bolt::Value::Type::String, + "Expected a string as the map key!"); map.insert({tmp.ValueString(), JsonToValue(it.value())}); } ret = map; @@ -80,12 +81,12 @@ communication::bolt::Value JsonToValue(const nlohmann::json &jv) { int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; - io::network::Endpoint endpoint(io::network::ResolveHostname(FLAGS_address), FLAGS_port); + memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port); - communication::ClientContext context(FLAGS_use_ssl); - communication::bolt::Client client(&context); + memgraph::communication::ClientContext context(FLAGS_use_ssl); + memgraph::communication::bolt::Client client(&context); client.Connect(endpoint, FLAGS_username, FLAGS_password); client.Execute(FLAGS_query, JsonToValue(nlohmann::json::parse(FLAGS_params_json)).ValueMap()); diff --git a/tests/integration/auth/checker.cpp b/tests/integration/auth/checker.cpp index e1acea4bf..52cb33c07 100644 --- a/tests/integration/auth/checker.cpp +++ b/tests/integration/auth/checker.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -28,12 +28,12 @@ DEFINE_bool(use_ssl, false, "Set to true to connect with SSL to the server."); int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; - io::network::Endpoint endpoint(io::network::ResolveHostname(FLAGS_address), FLAGS_port); + memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port); - communication::ClientContext context(FLAGS_use_ssl); - communication::bolt::Client client(&context); + memgraph::communication::ClientContext context(FLAGS_use_ssl); + memgraph::communication::bolt::Client client(&context); client.Connect(endpoint, FLAGS_username, FLAGS_password); @@ -56,7 +56,7 @@ int main(int argc, char **argv) { } } } - } catch (const communication::bolt::ClientQueryException &e) { + } catch (const memgraph::communication::bolt::ClientQueryException &e) { LOG_FATAL( "The query shoudn't have failed but it failed with an " "error message '{}'", diff --git a/tests/integration/auth/tester.cpp b/tests/integration/auth/tester.cpp index bfe740b75..904ab14a5 100644 --- a/tests/integration/auth/tester.cpp +++ b/tests/integration/auth/tester.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -33,12 +33,12 @@ DEFINE_string(failure_message, "", "Set to the expected failure message."); int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; - io::network::Endpoint endpoint(io::network::ResolveHostname(FLAGS_address), FLAGS_port); + memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port); - communication::ClientContext context(FLAGS_use_ssl); - communication::bolt::Client client(&context); + memgraph::communication::ClientContext context(FLAGS_use_ssl); + memgraph::communication::bolt::Client client(&context); client.Connect(endpoint, FLAGS_username, FLAGS_password); @@ -46,7 +46,7 @@ int main(int argc, char **argv) { std::string query(argv[i]); try { client.Execute(query, {}); - } catch (const communication::bolt::ClientQueryException &e) { + } catch (const memgraph::communication::bolt::ClientQueryException &e) { if (!FLAGS_check_failure) { if (!FLAGS_failure_message.empty() && e.what() == FLAGS_failure_message) { LOG_FATAL( diff --git a/tests/integration/ldap/tester.cpp b/tests/integration/ldap/tester.cpp index 7d415370a..5fe5ae925 100644 --- a/tests/integration/ldap/tester.cpp +++ b/tests/integration/ldap/tester.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -32,18 +32,18 @@ DEFINE_bool(query_should_fail, false, "Set to true to expect query execution fai int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; - io::network::Endpoint endpoint(io::network::ResolveHostname(FLAGS_address), FLAGS_port); + memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port); - communication::ClientContext context(FLAGS_use_ssl); - communication::bolt::Client client(&context); + memgraph::communication::ClientContext context(FLAGS_use_ssl); + memgraph::communication::bolt::Client client(&context); { std::string what; try { client.Connect(endpoint, FLAGS_username, FLAGS_password); - } catch (const communication::bolt::ClientFatalException &e) { + } catch (const memgraph::communication::bolt::ClientFatalException &e) { what = e.what(); } if (FLAGS_auth_should_fail) { @@ -61,7 +61,7 @@ int main(int argc, char **argv) { std::string what; try { client.Execute(query, {}); - } catch (const communication::bolt::ClientQueryException &e) { + } catch (const memgraph::communication::bolt::ClientQueryException &e) { what = e.what(); } if (FLAGS_query_should_fail) { diff --git a/tests/integration/mg_import_csv/tester.cpp b/tests/integration/mg_import_csv/tester.cpp index 384c521a9..8197d5a71 100644 --- a/tests/integration/mg_import_csv/tester.cpp +++ b/tests/integration/mg_import_csv/tester.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -29,14 +29,14 @@ DEFINE_bool(use_ssl, false, "Set to true to connect with SSL to the server."); // NOLINTNEXTLINE(bugprone-exception-escape) int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; - io::network::Endpoint endpoint(io::network::ResolveHostname(FLAGS_address), FLAGS_port); + memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port); - communication::ClientContext context(FLAGS_use_ssl); - communication::bolt::Client client(&context); + memgraph::communication::ClientContext context(FLAGS_use_ssl); + memgraph::communication::bolt::Client client(&context); client.Connect(endpoint, FLAGS_username, FLAGS_password); auto ret = client.Execute("DUMP DATABASE", {}); diff --git a/tests/integration/ssl/tester.cpp b/tests/integration/ssl/tester.cpp index 611350879..784369740 100644 --- a/tests/integration/ssl/tester.cpp +++ b/tests/integration/ssl/tester.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -31,41 +31,42 @@ struct EchoData {}; class EchoSession { public: - EchoSession(EchoData *, const io::network::Endpoint &, communication::InputStream *input_stream, - communication::OutputStream *output_stream) + EchoSession(EchoData *, const memgraph::io::network::Endpoint &, memgraph::communication::InputStream *input_stream, + memgraph::communication::OutputStream *output_stream) : input_stream_(input_stream), output_stream_(output_stream) {} void Execute() { if (input_stream_->size() < message.size()) return; spdlog::info("Server received message."); if (!output_stream_->Write(input_stream_->data(), message.size())) { - throw utils::BasicException("Output stream write failed!"); + throw memgraph::utils::BasicException("Output stream write failed!"); } spdlog::info("Server sent message."); input_stream_->Shift(message.size()); } private: - communication::InputStream *input_stream_; - communication::OutputStream *output_stream_; + memgraph::communication::InputStream *input_stream_; + memgraph::communication::OutputStream *output_stream_; }; int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); // Initialize the communication stack. - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; // Initialize the server. EchoData echo_data; - communication::ServerContext server_context(FLAGS_server_key_file, FLAGS_server_cert_file, FLAGS_server_ca_file, - FLAGS_server_verify_peer); - communication::Server server({"127.0.0.1", 0}, &echo_data, &server_context, -1, "SSL", 1); + memgraph::communication::ServerContext server_context(FLAGS_server_key_file, FLAGS_server_cert_file, + FLAGS_server_ca_file, FLAGS_server_verify_peer); + memgraph::communication::Server server({"127.0.0.1", 0}, &echo_data, &server_context, -1, + "SSL", 1); server.Start(); // Initialize the client. - communication::ClientContext client_context(FLAGS_client_key_file, FLAGS_client_cert_file); - communication::Client client(&client_context); + memgraph::communication::ClientContext client_context(FLAGS_client_key_file, FLAGS_client_cert_file); + memgraph::communication::Client client(&client_context); // Connect to the server. MG_ASSERT(client.Connect(server.endpoint()), "Couldn't connect to server!"); diff --git a/tests/integration/telemetry/client.cpp b/tests/integration/telemetry/client.cpp index 00e896307..f9125aa5a 100644 --- a/tests/integration/telemetry/client.cpp +++ b/tests/integration/telemetry/client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,8 +23,9 @@ int main(int argc, char **argv) { gflags::SetVersionString("telemetry"); gflags::ParseCommandLineFlags(&argc, &argv, true); - requests::Init(); - telemetry::Telemetry telemetry(FLAGS_endpoint, FLAGS_storage_directory, std::chrono::seconds(FLAGS_interval), 1); + memgraph::requests::Init(); + memgraph::telemetry::Telemetry telemetry(FLAGS_endpoint, FLAGS_storage_directory, + std::chrono::seconds(FLAGS_interval), 1); uint64_t counter = 0; telemetry.AddCollector("db", [&counter]() -> nlohmann::json { diff --git a/tests/integration/transactions/tester.cpp b/tests/integration/transactions/tester.cpp index c19452e12..189b8c92b 100644 --- a/tests/integration/transactions/tester.cpp +++ b/tests/integration/transactions/tester.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -25,7 +25,7 @@ DEFINE_string(username, "", "Username for the database"); DEFINE_string(password, "", "Password for the database"); DEFINE_bool(use_ssl, false, "Set to true to connect with SSL to the server."); -using namespace communication::bolt; +using namespace memgraph::communication::bolt; class BoltClient : public ::testing::Test { protected: @@ -62,8 +62,9 @@ class BoltClient : public ::testing::Test { return false; } - io::network::Endpoint endpoint_{io::network::ResolveHostname(FLAGS_address), static_cast(FLAGS_port)}; - communication::ClientContext context_{FLAGS_use_ssl}; + memgraph::io::network::Endpoint endpoint_{memgraph::io::network::ResolveHostname(FLAGS_address), + static_cast(FLAGS_port)}; + memgraph::communication::ClientContext context_{FLAGS_use_ssl}; Client client_{&context_}; }; @@ -465,7 +466,7 @@ int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; return RUN_ALL_TESTS(); } diff --git a/tests/macro_benchmark/clients/bfs_pokec_client.cpp b/tests/macro_benchmark/clients/bfs_pokec_client.cpp index 9d43f8aaa..defe9a385 100644 --- a/tests/macro_benchmark/clients/bfs_pokec_client.cpp +++ b/tests/macro_benchmark/clients/bfs_pokec_client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -30,9 +30,9 @@ #include "long_running_common.hpp" -using communication::bolt::Edge; -using communication::bolt::Value; -using communication::bolt::Vertex; +using memgraph::communication::bolt::Edge; +using memgraph::communication::bolt::Value; +using memgraph::communication::bolt::Vertex; class BfsPokecClient : public TestClient { public: @@ -113,7 +113,7 @@ class BfsPokecClient : public TestClient { int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; Endpoint endpoint(FLAGS_address, FLAGS_port); ClientContext context(FLAGS_use_ssl); diff --git a/tests/macro_benchmark/clients/bolt_client.hpp b/tests/macro_benchmark/clients/bolt_client.hpp index 26665bf5d..493e64039 100644 --- a/tests/macro_benchmark/clients/bolt_client.hpp +++ b/tests/macro_benchmark/clients/bolt_client.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,11 +19,11 @@ #include "io/network/endpoint.hpp" #include "utils/logging.hpp" -using EndpointT = io::network::Endpoint; -using ContextT = communication::ClientContext; -using ClientT = communication::bolt::Client; -using QueryDataT = communication::bolt::QueryData; -using communication::bolt::Value; +using EndpointT = memgraph::io::network::Endpoint; +using ContextT = memgraph::communication::ClientContext; +using ClientT = memgraph::communication::bolt::Client; +using QueryDataT = memgraph::communication::bolt::QueryData; +using memgraph::communication::bolt::Value; class BoltClient { public: diff --git a/tests/macro_benchmark/clients/card_fraud_client.cpp b/tests/macro_benchmark/clients/card_fraud_client.cpp index 455b5c353..0cf990933 100644 --- a/tests/macro_benchmark/clients/card_fraud_client.cpp +++ b/tests/macro_benchmark/clients/card_fraud_client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -25,7 +25,7 @@ std::atomic num_cards; std::atomic num_transactions; std::atomic max_tx_id; -utils::RWLock world_lock(utils::RWLock::Priority::WRITE); +memgraph::utils::RWLock world_lock(memgraph::utils::RWLock::Priority::WRITE); DEFINE_string(config, "", "test config"); @@ -49,7 +49,7 @@ void CreateIndex(Client &client, const std::string &label, const std::string &pr try { spdlog::info("Trying to sync indexes..."); ExecuteNTimesTillSuccess(client, "CALL db.awaitIndexes(14400);", {}, MAX_RETRIES); - } catch (utils::BasicException &e) { + } catch (memgraph::utils::BasicException &e) { spdlog::warn("Index sync failed: {}", e.what()); } } @@ -182,12 +182,12 @@ class CardFraudClient : public TestClient { public: void AnalyticStep() { std::this_thread::sleep_for(std::chrono::milliseconds(config_["analytic"]["query_interval_ms"])); - std::shared_lock lock(world_lock); + std::shared_lock lock(world_lock); GetCompromisedPosInc(config_["analytic"]["pos_limit"]); } void WorkerStep() { - std::shared_lock lock(world_lock); + std::shared_lock lock(world_lock); bool is_fraud = UniformDouble(0, 1) < config_["fraud_probability"]; int64_t pos_id = UniformInt(0, num_pos - 1); @@ -221,13 +221,13 @@ class CardFraudClient : public TestClient { void CleanupStep() { if (num_transactions >= config_["cleanup"]["tx_hi"].get()) { spdlog::info("Trying to obtain world lock..."); - std::unique_lock lock(world_lock); + std::unique_lock lock(world_lock); int64_t id_limit = max_tx_id - config_["cleanup"]["tx_lo"].get() + 1; spdlog::info( "Transaction cleanup started, deleting transactions " "with ids less than {}", id_limit); - utils::Timer timer; + memgraph::utils::Timer timer; auto result = Execute( "MATCH (t:Transaction) WHERE t.id < $id_limit " "DETACH DELETE t RETURN count(1)", @@ -313,7 +313,7 @@ nlohmann::json LoadConfig() { int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; Endpoint endpoint(FLAGS_address, FLAGS_port); ClientContext context(FLAGS_use_ssl); diff --git a/tests/macro_benchmark/clients/common.hpp b/tests/macro_benchmark/clients/common.hpp index cba5a853f..a5037f813 100644 --- a/tests/macro_benchmark/clients/common.hpp +++ b/tests/macro_benchmark/clients/common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -25,10 +25,10 @@ #include "utils/spin_lock.hpp" #include "utils/timer.hpp" -using communication::ClientContext; -using communication::bolt::Client; -using communication::bolt::Value; -using io::network::Endpoint; +using memgraph::communication::ClientContext; +using memgraph::communication::bolt::Client; +using memgraph::communication::bolt::Value; +using memgraph::io::network::Endpoint; void PrintJsonValue(std::ostream &os, const Value &value) { switch (value.type()) { @@ -49,13 +49,13 @@ void PrintJsonValue(std::ostream &os, const Value &value) { break; case Value::Type::List: os << "["; - utils::PrintIterable(os, value.ValueList(), ", ", - [](auto &stream, const auto &item) { PrintJsonValue(stream, item); }); + memgraph::utils::PrintIterable(os, value.ValueList(), ", ", + [](auto &stream, const auto &item) { PrintJsonValue(stream, item); }); os << "]"; break; case Value::Type::Map: os << "{"; - utils::PrintIterable(os, value.ValueMap(), ", ", [](auto &stream, const auto &pair) { + memgraph::utils::PrintIterable(os, value.ValueMap(), ", ", [](auto &stream, const auto &pair) { PrintJsonValue(stream, {pair.first}); stream << ": "; PrintJsonValue(stream, pair.second); @@ -67,8 +67,8 @@ void PrintJsonValue(std::ostream &os, const Value &value) { } } -std::pair ExecuteNTimesTillSuccess( - Client &client, const std::string &query, const std::map ¶ms, +std::pair ExecuteNTimesTillSuccess( + Client &client, const std::string &query, const std::map ¶ms, int max_attempts) { static thread_local std::mt19937 pseudo_rand_gen_{std::random_device{}()}; static thread_local std::uniform_int_distribution<> rand_dist_{10, 50}; @@ -77,13 +77,13 @@ std::pair ExecuteNTimesTillSuccess( try { auto ret = client.Execute(query, params); return {ret, failed_attempts}; - } catch (const utils::BasicException &e) { + } catch (const memgraph::utils::BasicException &e) { spdlog::debug("Error: {}", e.what()); if (++failed_attempts == max_attempts) { spdlog::warn("{} failed {}", query, failed_attempts); throw; } - utils::Timer t; + memgraph::utils::Timer t; std::chrono::microseconds to_sleep(rand_dist_(pseudo_rand_gen_)); while (t.Elapsed() < to_sleep) ; diff --git a/tests/macro_benchmark/clients/long_running_common.hpp b/tests/macro_benchmark/clients/long_running_common.hpp index f14ca2c53..4509fa566 100644 --- a/tests/macro_benchmark/clients/long_running_common.hpp +++ b/tests/macro_benchmark/clients/long_running_common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -59,7 +59,7 @@ class TestClient { virtual ~TestClient() {} auto ConsumeStats() { - std::unique_lock guard(lock_); + std::unique_lock guard(lock_); auto stats = stats_; stats_.clear(); return stats; @@ -82,15 +82,15 @@ class TestClient { protected: virtual void Step() = 0; - std::optional Execute(const std::string &query, - const std::map ¶ms, - const std::string &query_name = "") { - communication::bolt::QueryData result; + std::optional Execute(const std::string &query, + const std::map ¶ms, + const std::string &query_name = "") { + memgraph::communication::bolt::QueryData result; int retries; - utils::Timer timer; + memgraph::utils::Timer timer; try { std::tie(result, retries) = ExecuteNTimesTillSuccess(client_, query, params, MAX_RETRIES); - } catch (const utils::BasicException &e) { + } catch (const memgraph::utils::BasicException &e) { serialization_errors += MAX_RETRIES; return std::nullopt; } @@ -98,7 +98,7 @@ class TestClient { auto metadata = result.metadata; metadata["wall_time"] = wall_time.count(); { - std::unique_lock guard(lock_); + std::unique_lock guard(lock_); if (query_name != "") { stats_[query_name].push_back(std::move(metadata)); } else { @@ -110,14 +110,14 @@ class TestClient { return result; } - utils::SpinLock lock_; + memgraph::utils::SpinLock lock_; std::unordered_map>> stats_; std::atomic keep_running_{true}; std::thread runner_thread_; private: - communication::ClientContext context_{FLAGS_use_ssl}; + memgraph::communication::ClientContext context_{FLAGS_use_ssl}; Client client_{&context_}; }; @@ -135,7 +135,7 @@ void RunMultithreadedTest(std::vector> &clients) { } std::ostream out(buf); - utils::Timer timer; + memgraph::utils::Timer timer; for (auto &client : clients) { client->Run(); } @@ -187,7 +187,7 @@ void RunMultithreadedTest(std::vector> &clients) { out << "{\"num_executed_queries\": " << executed_queries << ", " << "\"num_executed_steps\": " << executed_steps << ", " << "\"elapsed_time\": " << timer.Elapsed().count() << ", \"queries\": ["; - utils::PrintIterable(out, aggregated_stats, ", ", [](auto &stream, const auto &x) { + memgraph::utils::PrintIterable(out, aggregated_stats, ", ", [](auto &stream, const auto &x) { stream << "{\"query\": " << nlohmann::json(x.first) << ", \"stats\": "; PrintJsonValue(stream, Value(x.second)); stream << "}"; diff --git a/tests/macro_benchmark/clients/pokec_client.cpp b/tests/macro_benchmark/clients/pokec_client.cpp index ff44db3be..a6f7419a8 100644 --- a/tests/macro_benchmark/clients/pokec_client.cpp +++ b/tests/macro_benchmark/clients/pokec_client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -30,9 +30,9 @@ #include "long_running_common.hpp" -using communication::bolt::Edge; -using communication::bolt::Value; -using communication::bolt::Vertex; +using memgraph::communication::bolt::Edge; +using memgraph::communication::bolt::Value; +using memgraph::communication::bolt::Vertex; struct VertexAndEdges { Vertex vertex; @@ -68,9 +68,9 @@ class PokecClient : public TestClient { auto CreateVertex(const Vertex &vertex) { std::stringstream os; os << "CREATE (n :"; - utils::PrintIterable(os, vertex.labels, ":"); + memgraph::utils::PrintIterable(os, vertex.labels, ":"); os << " {"; - utils::PrintIterable(os, vertex.properties, ", ", [&](auto &stream, const auto &pair) { + memgraph::utils::PrintIterable(os, vertex.properties, ", ", [&](auto &stream, const auto &pair) { if (pair.second.type() == Value::Type::String) { stream << pair.first << ": \"" << pair.second << "\""; } else { @@ -107,7 +107,7 @@ class PokecClient : public TestClient { os << "-"; } os << "[:" << edge.type << " {"; - utils::PrintIterable(os, edge.properties, ", ", [&](auto &stream, const auto &pair) { + memgraph::utils::PrintIterable(os, edge.properties, ", ", [&](auto &stream, const auto &pair) { if (pair.second.type() == Value::Type::String) { stream << pair.first << ": \"" << pair.second << "\""; } else { @@ -253,13 +253,13 @@ std::vector IndependentSet(Client &client, const std::string &label) { int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; nlohmann::json config; std::cin >> config; auto independent_nodes_ids = [&] { - Endpoint endpoint(io::network::ResolveHostname(FLAGS_address), FLAGS_port); + Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port); ClientContext context(FLAGS_use_ssl); Client client(&context); client.Connect(endpoint, FLAGS_username, FLAGS_password); diff --git a/tests/macro_benchmark/clients/query_client.cpp b/tests/macro_benchmark/clients/query_client.cpp index f0b8808fd..51e32f9bb 100644 --- a/tests/macro_benchmark/clients/query_client.cpp +++ b/tests/macro_benchmark/clients/query_client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -34,13 +34,14 @@ DEFINE_string(username, "", "Username for the database"); DEFINE_string(password, "", "Password for the database"); DEFINE_bool(use_ssl, false, "Set to true to connect with SSL to the server."); -using communication::bolt::Value; +using memgraph::communication::bolt::Value; const int MAX_RETRIES = 50; void PrintJsonMetadata(std::ostream &os, const std::vector> &metadata) { os << "["; - utils::PrintIterable(os, metadata, ", ", [](auto &stream, const auto &item) { PrintJsonValue(stream, item); }); + memgraph::utils::PrintIterable(os, metadata, ", ", + [](auto &stream, const auto &item) { PrintJsonValue(stream, item); }); os << "]"; } @@ -54,13 +55,13 @@ void PrintSummary(std::ostream &os, double duration, const std::vector &queries, std::ostream &ostream) { std::vector threads; - utils::SpinLock spinlock; + memgraph::utils::SpinLock spinlock; uint64_t last = 0; std::vector> metadata; metadata.resize(queries.size()); - utils::Timer timer; + memgraph::utils::Timer timer; for (int i = 0; i < FLAGS_num_workers; ++i) { threads.push_back(std::thread([&]() { @@ -73,7 +74,7 @@ void ExecuteQueries(const std::vector &queries, std::ostream &ostre while (true) { uint64_t pos; { - std::lock_guard lock(spinlock); + std::lock_guard lock(spinlock); if (last == queries.size()) { break; } @@ -82,7 +83,7 @@ void ExecuteQueries(const std::vector &queries, std::ostream &ostre } try { metadata[pos] = ExecuteNTimesTillSuccess(client, str, {}, MAX_RETRIES).first.metadata; - } catch (const utils::BasicException &e) { + } catch (const memgraph::utils::BasicException &e) { LOG_FATAL("Could not execute query '{}' {} times! Error message: {}", str, MAX_RETRIES, e.what()); } } @@ -103,7 +104,7 @@ void ExecuteQueries(const std::vector &queries, std::ostream &ostre int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; std::ifstream ifile; std::istream *istream{&std::cin}; @@ -124,7 +125,7 @@ int main(int argc, char **argv) { while (!istream->eof()) { std::vector queries; std::string query; - while (std::getline(*istream, query) && utils::Trim(query) != "" && utils::Trim(query) != ";") { + while (std::getline(*istream, query) && memgraph::utils::Trim(query) != "" && memgraph::utils::Trim(query) != ";") { queries.push_back(query); } ExecuteQueries(queries, *ostream); diff --git a/tests/manual/antlr_sigsegv.cpp b/tests/manual/antlr_sigsegv.cpp index caafcd986..cd6bba3f5 100644 --- a/tests/manual/antlr_sigsegv.cpp +++ b/tests/manual/antlr_sigsegv.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -34,7 +34,7 @@ TEST(Antlr, Sigsegv) { while (!run) ; while (run) { - query::frontend::opencypher::Parser parser( + memgraph::query::frontend::opencypher::Parser parser( "CREATE (:Label_T7 {x: 903}) CREATE (:Label_T7 {x: 720}) CREATE " "(:Label_T7 {x: 13}) CREATE (:Label_T7 {x: 643}) CREATE (:Label_T7 " "{x: 245}) CREATE (:Label_T7 {x: 441}) CREATE (:Label_T7 {x: 47}) " @@ -99,15 +99,15 @@ int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); // Signal handling init. - utils::SignalHandler::RegisterHandler(utils::Signal::SegmentationFault, []() { + memgraph::utils::SignalHandler::RegisterHandler(memgraph::utils::Signal::SegmentationFault, []() { // Log that we got SIGSEGV and abort the program, because returning from // SIGSEGV handler is undefined behaviour. std::cerr << "SegmentationFault signal raised" << std::endl; std::abort(); // This will continue into our SIGABRT handler. }); - utils::SignalHandler::RegisterHandler(utils::Signal::Abort, []() { + memgraph::utils::SignalHandler::RegisterHandler(memgraph::utils::Signal::Abort, []() { // Log the stacktrace and let the abort continue. - utils::Stacktrace stacktrace; + memgraph::utils::Stacktrace stacktrace; std::cerr << "Abort signal raised" << std::endl << stacktrace.dump() << std::endl; }); diff --git a/tests/manual/bolt_client.cpp b/tests/manual/bolt_client.cpp index ef1ce3f1a..d978cfca5 100644 --- a/tests/manual/bolt_client.cpp +++ b/tests/manual/bolt_client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,13 +26,13 @@ DEFINE_bool(print_records, true, "Set to false to disable printing of records.") int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; // TODO: handle endpoint exception - io::network::Endpoint endpoint(io::network::ResolveHostname(FLAGS_address), FLAGS_port); + memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port); - communication::ClientContext context(FLAGS_use_ssl); - communication::bolt::Client client(&context); + memgraph::communication::ClientContext context(FLAGS_use_ssl); + memgraph::communication::bolt::Client client(&context); client.Connect(endpoint, FLAGS_username, FLAGS_password); @@ -45,7 +45,7 @@ int main(int argc, char **argv) { break; } try { - utils::Timer t; + memgraph::utils::Timer t; auto ret = client.Execute(s, {}); auto elapsed = t.Elapsed().count(); std::cout << "Wall time:\n " << elapsed << std::endl; @@ -69,7 +69,7 @@ int main(int argc, char **argv) { for (auto &data : ret.metadata) { std::cout << " " << data.first << " : " << data.second << std::endl; } - } catch (const communication::bolt::ClientQueryException &e) { + } catch (const memgraph::communication::bolt::ClientQueryException &e) { std::cout << "Client received exception: " << e.what() << std::endl; } } diff --git a/tests/manual/expression_pretty_printer.cpp b/tests/manual/expression_pretty_printer.cpp index d50d825cc..e2d58b350 100644 --- a/tests/manual/expression_pretty_printer.cpp +++ b/tests/manual/expression_pretty_printer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,25 +22,25 @@ std::string AssembleQueryString(const std::string &expression_string) { return "return " + expression_string + " as expr"; } -query::Query *ParseQuery(const std::string &query_string, query::AstStorage *ast_storage) { - query::frontend::ParsingContext context; - query::frontend::opencypher::Parser parser(query_string); - query::frontend::CypherMainVisitor visitor(context, ast_storage); +memgraph::query::Query *ParseQuery(const std::string &query_string, memgraph::query::AstStorage *ast_storage) { + memgraph::query::frontend::ParsingContext context; + memgraph::query::frontend::opencypher::Parser parser(query_string); + memgraph::query::frontend::CypherMainVisitor visitor(context, ast_storage); visitor.visit(parser.tree()); return visitor.query(); } -query::Expression *GetExpression(query::Query *query) { - auto cypher_query = dynamic_cast(query); - auto ret = dynamic_cast(cypher_query->single_query_->clauses_[0]); +memgraph::query::Expression *GetExpression(memgraph::query::Query *query) { + auto cypher_query = dynamic_cast(query); + auto ret = dynamic_cast(cypher_query->single_query_->clauses_[0]); auto expr = ret->body_.named_expressions[0]->expression_; return expr; } int main() { - query::AstStorage ast_storage; + memgraph::query::AstStorage ast_storage; std::ostringstream ss; ss << std::cin.rdbuf(); @@ -48,7 +48,7 @@ int main() { auto query = ParseQuery(query_string, &ast_storage); auto expr = GetExpression(query); - query::PrintExpression(expr, &std::cout); + memgraph::query::PrintExpression(expr, &std::cout); std::cout << std::endl; return 0; diff --git a/tests/manual/interactive_planning.cpp b/tests/manual/interactive_planning.cpp index 14e0421eb..09566e11b 100644 --- a/tests/manual/interactive_planning.cpp +++ b/tests/manual/interactive_planning.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -137,7 +137,7 @@ class Timer { // Dummy DbAccessor which forwards user input for various vertex counts. class InteractiveDbAccessor { public: - InteractiveDbAccessor(query::DbAccessor *dba, int64_t vertices_count, Timer &timer) + InteractiveDbAccessor(memgraph::query::DbAccessor *dba, int64_t vertices_count, Timer &timer) : dba_(dba), vertices_count_(vertices_count), timer_(timer) {} auto NameToLabel(const std::string &name) { return dba_->NameToLabel(name); } @@ -146,7 +146,7 @@ class InteractiveDbAccessor { int64_t VerticesCount() { return vertices_count_; } - int64_t VerticesCount(storage::LabelId label_id) { + int64_t VerticesCount(memgraph::storage::LabelId label_id) { auto label = dba_->LabelToName(label_id); if (label_vertex_count_.find(label) == label_vertex_count_.end()) { label_vertex_count_[label] = ReadVertexCount("label '" + label + "'"); @@ -154,7 +154,7 @@ class InteractiveDbAccessor { return label_vertex_count_.at(label); } - int64_t VerticesCount(storage::LabelId label_id, storage::PropertyId property_id) { + int64_t VerticesCount(memgraph::storage::LabelId label_id, memgraph::storage::PropertyId property_id) { auto label = dba_->LabelToName(label_id); auto property = dba_->PropertyToName(property_id); auto key = std::make_pair(label, property); @@ -164,8 +164,8 @@ class InteractiveDbAccessor { return label_property_vertex_count_.at(key); } - int64_t VerticesCount(storage::LabelId label_id, storage::PropertyId property_id, - const storage::PropertyValue &value) { + int64_t VerticesCount(memgraph::storage::LabelId label_id, memgraph::storage::PropertyId property_id, + const memgraph::storage::PropertyValue &value) { auto label = dba_->LabelToName(label_id); auto property = dba_->PropertyToName(property_id); auto label_prop = std::make_pair(label, property); @@ -182,9 +182,9 @@ class InteractiveDbAccessor { return value_vertex_count.at(value); } - int64_t VerticesCount(storage::LabelId label_id, storage::PropertyId property_id, - const std::optional> lower, - const std::optional> upper) { + int64_t VerticesCount(memgraph::storage::LabelId label_id, memgraph::storage::PropertyId property_id, + const std::optional> lower, + const std::optional> upper) { auto label = dba_->LabelToName(label_id); auto property = dba_->PropertyToName(property_id); std::stringstream range_string; @@ -199,9 +199,9 @@ class InteractiveDbAccessor { return ReadVertexCount("label '" + label + "' and property '" + property + "' in range " + range_string.str()); } - bool LabelIndexExists(storage::LabelId label) { return true; } + bool LabelIndexExists(memgraph::storage::LabelId label) { return true; } - bool LabelPropertyIndexExists(storage::LabelId label_id, storage::PropertyId property_id) { + bool LabelPropertyIndexExists(memgraph::storage::LabelId label_id, memgraph::storage::PropertyId property_id) { auto label = dba_->LabelToName(label_id); auto property = dba_->PropertyToName(property_id); auto key = std::make_pair(label, property); @@ -241,13 +241,13 @@ class InteractiveDbAccessor { } // Load the cached vertex counts from a stream. - // If loading fails, raises utils::BasicException. + // If loading fails, raises memgraph::utils::BasicException. void Load(std::istream &in) { auto load_named_size = [&](const auto &name) { int size; in.ignore(std::numeric_limits::max(), ' ') >> size; if (in.fail()) { - throw utils::BasicException("Unable to load {}", name); + throw memgraph::utils::BasicException("Unable to load {}", name); } SPDLOG_INFO("Load {} {}", name, size); return size; @@ -259,7 +259,7 @@ class InteractiveDbAccessor { int64_t count; in >> label >> count; if (in.fail()) { - throw utils::BasicException("Unable to load label count"); + throw memgraph::utils::BasicException("Unable to load label count"); } label_vertex_count_[label] = count; SPDLOG_INFO("Load {} {}", label, count); @@ -273,7 +273,7 @@ class InteractiveDbAccessor { auto &mapped = label_prop_map[std::make_pair(label, property)]; in >> mapped; if (in.fail()) { - throw utils::BasicException("Unable to load label property"); + throw memgraph::utils::BasicException("Unable to load label property"); } SPDLOG_INFO("Load {} {} {}", label, property, mapped); } @@ -287,7 +287,7 @@ class InteractiveDbAccessor { int64_t value_count; in >> label >> property >> value_count; if (in.fail()) { - throw utils::BasicException("Unable to load label property value"); + throw memgraph::utils::BasicException("Unable to load label property value"); } SPDLOG_INFO("Load {} {} {}", label, property, value_count); for (int v = 0; v < value_count; ++v) { @@ -295,7 +295,7 @@ class InteractiveDbAccessor { int64_t count; in >> count; if (in.fail()) { - throw utils::BasicException("Unable to load label property value"); + throw memgraph::utils::BasicException("Unable to load label property value"); } SPDLOG_INFO("Load {} {} {}", value.type(), value, count); property_value_vertex_count_[std::make_pair(label, property)][value] = count; @@ -306,20 +306,21 @@ class InteractiveDbAccessor { private: typedef std::pair LabelPropertyKey; - query::DbAccessor *dba_; + memgraph::query::DbAccessor *dba_; int64_t vertices_count_; Timer &timer_; std::map label_vertex_count_; std::map, int64_t> label_property_vertex_count_; std::map, bool> label_property_index_; - std::map, std::map> property_value_vertex_count_; + std::map, std::map> + property_value_vertex_count_; // TODO: Cache faked index counts by range. int64_t ReadVertexCount(const std::string &message) const { return timer_.WithPause([&message]() { return ReadInt("Vertices with " + message + ": "); }); } - storage::PropertyValue LoadPropertyValue(std::istream &in) { + memgraph::storage::PropertyValue LoadPropertyValue(std::istream &in) { std::string type; in >> type; if (type == "bool") { @@ -331,15 +332,15 @@ class InteractiveDbAccessor { } else if (type == "string") { return LoadPropertyValue(in); } else { - throw utils::BasicException("Unable to read type '{}'", type); + throw memgraph::utils::BasicException("Unable to read type '{}'", type); } } template - storage::PropertyValue LoadPropertyValue(std::istream &in) { + memgraph::storage::PropertyValue LoadPropertyValue(std::istream &in) { T val; in >> val; - return storage::PropertyValue(val); + return memgraph::storage::PropertyValue(val); } }; @@ -352,7 +353,7 @@ DEFCOMMAND(Top) { for (int64_t i = 0; i < n_plans; ++i) { std::cout << "---- Plan #" << i << " ---- " << std::endl; std::cout << "cost: " << plans[i].cost << std::endl; - query::plan::PrettyPrint(dba, plans[i].final_plan.get()); + memgraph::query::plan::PrettyPrint(dba, plans[i].final_plan.get()); std::cout << std::endl; } } @@ -365,7 +366,7 @@ DEFCOMMAND(Show) { const auto &plan = plans[plan_ix].final_plan; auto cost = plans[plan_ix].cost; std::cout << "Plan cost: " << cost << std::endl; - query::plan::PrettyPrint(dba, plan.get()); + memgraph::query::plan::PrettyPrint(dba, plan.get()); } DEFCOMMAND(ShowUnoptimized) { @@ -374,7 +375,7 @@ DEFCOMMAND(ShowUnoptimized) { ss >> plan_ix; if (ss.fail() || !ss.eof() || plan_ix >= plans.size()) return; const auto &plan = plans[plan_ix].unoptimized_plan; - query::plan::PrettyPrint(dba, plan.get()); + memgraph::query::plan::PrettyPrint(dba, plan.get()); } DEFCOMMAND(Help); @@ -399,12 +400,12 @@ DEFCOMMAND(Help) { } } -void ExaminePlans(query::DbAccessor *dba, const query::SymbolTable &symbol_table, std::vector &plans, - const query::AstStorage &ast) { +void ExaminePlans(memgraph::query::DbAccessor *dba, const memgraph::query::SymbolTable &symbol_table, + std::vector &plans, const memgraph::query::AstStorage &ast) { while (true) { auto line = ReadLine("plan? "); if (!line || *line == "quit") break; - auto words = utils::Split(utils::ToLowerCase(*line)); + auto words = memgraph::utils::Split(memgraph::utils::ToLowerCase(*line)); if (words.empty()) continue; auto command_name = words[0]; std::vector args(words.begin() + 1, words.end()); @@ -422,34 +423,34 @@ void ExaminePlans(query::DbAccessor *dba, const query::SymbolTable &symbol_table } } -query::Query *MakeAst(const std::string &query, query::AstStorage *storage) { - query::frontend::ParsingContext parsing_context; +memgraph::query::Query *MakeAst(const std::string &query, memgraph::query::AstStorage *storage) { + memgraph::query::frontend::ParsingContext parsing_context; parsing_context.is_query_cached = false; // query -> AST - auto parser = std::make_unique(query); + auto parser = std::make_unique(query); // AST -> high level tree - query::frontend::CypherMainVisitor visitor(parsing_context, storage); + memgraph::query::frontend::CypherMainVisitor visitor(parsing_context, storage); visitor.visit(parser->tree()); return visitor.query(); } // Returns a list of InteractivePlan instances, sorted in the ascending order by // cost. -auto MakeLogicalPlans(query::CypherQuery *query, query::AstStorage &ast, query::SymbolTable &symbol_table, - InteractiveDbAccessor *dba) { - auto query_parts = query::plan::CollectQueryParts(symbol_table, ast, query); +auto MakeLogicalPlans(memgraph::query::CypherQuery *query, memgraph::query::AstStorage &ast, + memgraph::query::SymbolTable &symbol_table, InteractiveDbAccessor *dba) { + auto query_parts = memgraph::query::plan::CollectQueryParts(symbol_table, ast, query); std::vector interactive_plans; - auto ctx = query::plan::MakePlanningContext(&ast, &symbol_table, query, dba); + auto ctx = memgraph::query::plan::MakePlanningContext(&ast, &symbol_table, query, dba); if (query_parts.query_parts.size() <= 0) { std::cerr << "Failed to extract query parts" << std::endl; std::exit(EXIT_FAILURE); } - query::Parameters parameters; - query::plan::PostProcessor post_process(parameters); - auto plans = query::plan::MakeLogicalPlanForSingleQuery( + memgraph::query::Parameters parameters; + memgraph::query::plan::PostProcessor post_process(parameters); + auto plans = memgraph::query::plan::MakeLogicalPlanForSingleQuery( query_parts.query_parts.at(0).single_query_parts, &ctx); for (auto plan : plans) { - query::AstStorage ast_copy; + memgraph::query::AstStorage ast_copy; auto unoptimized_plan = plan->Clone(&ast_copy); auto rewritten_plan = post_process.Rewrite(std::move(plan), &ctx); double cost = post_process.EstimatePlanCost(rewritten_plan, dba); @@ -461,8 +462,8 @@ auto MakeLogicalPlans(query::CypherQuery *query, query::AstStorage &ast, query:: return interactive_plans; } -void RunInteractivePlanning(query::DbAccessor *dba) { - std::string in_db_filename(utils::Trim(FLAGS_load_mock_db_file)); +void RunInteractivePlanning(memgraph::query::DbAccessor *dba) { + std::string in_db_filename(memgraph::utils::Trim(FLAGS_load_mock_db_file)); if (!in_db_filename.empty() && !std::filesystem::exists(in_db_filename)) { std::cerr << "File '" << in_db_filename << "' does not exist!" << std::endl; std::exit(EXIT_FAILURE); @@ -478,14 +479,14 @@ void RunInteractivePlanning(query::DbAccessor *dba) { if (!line || *line == "quit") break; if (line->empty()) continue; try { - query::AstStorage ast; - auto *query = dynamic_cast(MakeAst(*line, &ast)); + memgraph::query::AstStorage ast; + auto *query = dynamic_cast(MakeAst(*line, &ast)); if (!query) { - throw utils::BasicException( + throw memgraph::utils::BasicException( "Interactive planning is only avaialable for regular openCypher " "queries."); } - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); planning_timer.Start(); auto plans = MakeLogicalPlans(query, ast, symbol_table, &interactive_db); auto planning_time = planning_timer.Elapsed(); @@ -493,11 +494,11 @@ void RunInteractivePlanning(query::DbAccessor *dba) { << std::endl; std::cout << "Generated " << plans.size() << " plans" << std::endl; ExaminePlans(dba, symbol_table, plans, ast); - } catch (const utils::BasicException &e) { + } catch (const memgraph::utils::BasicException &e) { std::cout << "Error: " << e.what() << std::endl; } } - std::string db_filename(utils::Trim(FLAGS_save_mock_db_file)); + std::string db_filename(memgraph::utils::Trim(FLAGS_save_mock_db_file)); if (!db_filename.empty()) { std::ofstream db_file(db_filename); interactive_db.Save(db_file); diff --git a/tests/manual/interactive_planning.hpp b/tests/manual/interactive_planning.hpp index df2840941..f062849cd 100644 --- a/tests/manual/interactive_planning.hpp +++ b/tests/manual/interactive_planning.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,11 +27,11 @@ class GraphDbAccessor; struct InteractivePlan { // Original plan after going only through the RuleBasedPlanner. - std::unique_ptr unoptimized_plan; + std::unique_ptr unoptimized_plan; // Storage for the AST used in unoptimized_plan - query::AstStorage ast_storage; + memgraph::query::AstStorage ast_storage; // Final plan after being rewritten and optimized. - std::unique_ptr final_plan; + std::unique_ptr final_plan; // Cost of the final plan. double cost; }; @@ -42,8 +42,8 @@ typedef std::vector PlansWithCost; struct Command { typedef std::vector Args; // Function of this command - std::function + std::function function; // Number of arguments the function works with. int arg_count; @@ -51,10 +51,10 @@ struct Command { std::string documentation; }; -#define DEFCOMMAND(Name) \ - void Name##Command(query::DbAccessor &dba, const query::SymbolTable &symbol_table, PlansWithCost &plans, \ - const Command::Args &args, const query::AstStorage &ast_storage) +#define DEFCOMMAND(Name) \ + void Name##Command(memgraph::query::DbAccessor &dba, const memgraph::query::SymbolTable &symbol_table, \ + PlansWithCost &plans, const Command::Args &args, const memgraph::query::AstStorage &ast_storage) void AddCommand(const std::string &name, const Command &command); -void RunInteractivePlanning(query::DbAccessor *dba); +void RunInteractivePlanning(memgraph::query::DbAccessor *dba); diff --git a/tests/manual/kvstore_console.cpp b/tests/manual/kvstore_console.cpp index 785eb6f38..fb45f178e 100644 --- a/tests/manual/kvstore_console.cpp +++ b/tests/manual/kvstore_console.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ int main(int argc, char **argv) { MG_ASSERT(FLAGS_path != "", "Please specify a path to the KVStore!"); - kvstore::KVStore kvstore(std::filesystem::path{FLAGS_path}); + memgraph::kvstore::KVStore kvstore(std::filesystem::path{FLAGS_path}); while (true) { std::string s; @@ -32,7 +32,7 @@ int main(int argc, char **argv) { break; } - auto split = utils::Split(utils::Trim(s)); + auto split = memgraph::utils::Split(memgraph::utils::Trim(s)); if (split[0] == "list") { if (split.size() != 1) { std::cout << "`list' takes no arguments!" << std::endl; diff --git a/tests/manual/query_hash.cpp b/tests/manual/query_hash.cpp index 93a54ba41..8688da351 100644 --- a/tests/manual/query_hash.cpp +++ b/tests/manual/query_hash.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -31,7 +31,7 @@ int main(int argc, char **argv) { auto query = FLAGS_q; // run preprocessing - query::frontend::StrippedQuery preprocessed(query); + memgraph::query::frontend::StrippedQuery preprocessed(query); // print query, stripped query, hash and variable values (propertie values) std::cout << fmt::format("Query: {}\n", query); diff --git a/tests/manual/query_planner.cpp b/tests/manual/query_planner.cpp index 0964839d3..67875734b 100644 --- a/tests/manual/query_planner.cpp +++ b/tests/manual/query_planner.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,9 +20,9 @@ DECLARE_int32(min_log_level); int main(int argc, char *argv[]) { gflags::ParseCommandLineFlags(&argc, &argv, true); spdlog::set_level(spdlog::level::err); - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); RunInteractivePlanning(&dba); return 0; } diff --git a/tests/manual/single_query.cpp b/tests/manual/single_query.cpp index eab474d07..b48c8f74c 100644 --- a/tests/manual/single_query.cpp +++ b/tests/manual/single_query.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,13 +26,13 @@ int main(int argc, char *argv[]) { exit(1); } - storage::Storage db; + memgraph::storage::Storage db; auto data_directory = std::filesystem::temp_directory_path() / "single_query_test"; - utils::OnScopeExit([&data_directory] { std::filesystem::remove_all(data_directory); }); + memgraph::utils::OnScopeExit([&data_directory] { std::filesystem::remove_all(data_directory); }); - utils::license::global_license_checker.EnableTesting(); - query::InterpreterContext interpreter_context{&db, query::InterpreterConfig{}, data_directory}; - query::Interpreter interpreter{&interpreter_context}; + memgraph::utils::license::global_license_checker.EnableTesting(); + memgraph::query::InterpreterContext interpreter_context{&db, memgraph::query::InterpreterConfig{}, data_directory}; + memgraph::query::Interpreter interpreter{&interpreter_context}; ResultStreamFaker stream(&db); auto [header, _, qid] = interpreter.Prepare(argv[1], {}, nullptr); diff --git a/tests/manual/ssl_client.cpp b/tests/manual/ssl_client.cpp index 073125d75..e45fcb3d1 100644 --- a/tests/manual/ssl_client.cpp +++ b/tests/manual/ssl_client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ DEFINE_int32(port, 54321, "Server port"); DEFINE_string(cert_file, "", "Certificate file to use."); DEFINE_string(key_file, "", "Key file to use."); -bool EchoMessage(communication::Client &client, const std::string &data) { +bool EchoMessage(memgraph::communication::Client &client, const std::string &data) { uint16_t size = data.size(); if (!client.Write(reinterpret_cast(&size), sizeof(size))) { spdlog::warn("Couldn't send data size!"); @@ -47,12 +47,12 @@ bool EchoMessage(communication::Client &client, const std::string &data) { int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; - io::network::Endpoint endpoint(FLAGS_address, FLAGS_port); + memgraph::io::network::Endpoint endpoint(FLAGS_address, FLAGS_port); - communication::ClientContext context(FLAGS_key_file, FLAGS_cert_file); - communication::Client client(&context); + memgraph::communication::ClientContext context(FLAGS_key_file, FLAGS_cert_file); + memgraph::communication::Client client(&context); if (!client.Connect(endpoint)) return 1; diff --git a/tests/manual/ssl_server.cpp b/tests/manual/ssl_server.cpp index bf4549ade..b7dfb4aec 100644 --- a/tests/manual/ssl_server.cpp +++ b/tests/manual/ssl_server.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -30,8 +30,8 @@ struct EchoData { class EchoSession { public: - EchoSession(EchoData *data, const io::network::Endpoint &, communication::InputStream *input_stream, - communication::OutputStream *output_stream) + EchoSession(EchoData *data, const memgraph::io::network::Endpoint &, + memgraph::communication::InputStream *input_stream, memgraph::communication::OutputStream *output_stream) : data_(data), input_stream_(input_stream), output_stream_(output_stream) {} void Execute() { @@ -47,27 +47,27 @@ class EchoSession { } spdlog::info("Server received '{}'", std::string(reinterpret_cast(data + 2), size)); if (!output_stream_->Write(data + 2, size)) { - throw utils::BasicException("Output stream write failed!"); + throw memgraph::utils::BasicException("Output stream write failed!"); } input_stream_->Shift(size + 2); } private: EchoData *data_; - communication::InputStream *input_stream_; - communication::OutputStream *output_stream_; + memgraph::communication::InputStream *input_stream_; + memgraph::communication::OutputStream *output_stream_; }; int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; // Initialize the server. EchoData echo_data; - io::network::Endpoint endpoint(FLAGS_address, FLAGS_port); - communication::ServerContext context(FLAGS_key_file, FLAGS_cert_file, FLAGS_ca_file, FLAGS_verify_peer); - communication::Server server(endpoint, &echo_data, &context, -1, "SSL", 1); + memgraph::io::network::Endpoint endpoint(FLAGS_address, FLAGS_port); + memgraph::communication::ServerContext context(FLAGS_key_file, FLAGS_cert_file, FLAGS_ca_file, FLAGS_verify_peer); + memgraph::communication::Server server(endpoint, &echo_data, &context, -1, "SSL", 1); server.Start(); while (echo_data.alive) { diff --git a/tests/manual/stripped_timing.cpp b/tests/manual/stripped_timing.cpp index 52b7c0f4f..a60cb9cde 100644 --- a/tests/manual/stripped_timing.cpp +++ b/tests/manual/stripped_timing.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -30,7 +30,7 @@ int main(int argc, const char **a) { clock_t begin = clock(); for (int i = 0; i < REPEATS; ++i) { - query::frontend::StrippedQuery(std::string(query)); + memgraph::query::frontend::StrippedQuery(std::string(query)); } clock_t end = clock(); diff --git a/tests/mgbench/client.cpp b/tests/mgbench/client.cpp index 58cee24f3..e4b63d477 100644 --- a/tests/mgbench/client.cpp +++ b/tests/mgbench/client.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -49,14 +49,14 @@ DEFINE_bool(queries_json, false, DEFINE_string(input, "", "Input file. By default stdin is used."); DEFINE_string(output, "", "Output file. By default stdout is used."); -std::pair, uint64_t> ExecuteNTimesTillSuccess( - communication::bolt::Client *client, const std::string &query, - const std::map ¶ms, int max_attempts) { +std::pair, uint64_t> ExecuteNTimesTillSuccess( + memgraph::communication::bolt::Client *client, const std::string &query, + const std::map ¶ms, int max_attempts) { for (uint64_t i = 0; i < max_attempts; ++i) { try { auto ret = client->Execute(query, params); return {std::move(ret.metadata), i}; - } catch (const utils::BasicException &e) { + } catch (const memgraph::utils::BasicException &e) { if (i == max_attempts - 1) { LOG_FATAL("Could not execute query '{}' {} times! Error message: {}", query, max_attempts, e.what()); } else { @@ -67,7 +67,7 @@ std::pair, uint64_t> ExecuteNT LOG_FATAL("Could not execute query '{}' {} times!", query, max_attempts); } -communication::bolt::Value JsonToBoltValue(const nlohmann::json &data) { +memgraph::communication::bolt::Value JsonToBoltValue(const nlohmann::json &data) { switch (data.type()) { case nlohmann::json::value_t::null: return {}; @@ -82,7 +82,7 @@ communication::bolt::Value JsonToBoltValue(const nlohmann::json &data) { case nlohmann::json::value_t::number_float: return {data.get()}; case nlohmann::json::value_t::array: { - std::vector vec; + std::vector vec; vec.reserve(data.size()); for (const auto &item : data.get()) { vec.emplace_back(JsonToBoltValue(item)); @@ -90,7 +90,7 @@ communication::bolt::Value JsonToBoltValue(const nlohmann::json &data) { return {std::move(vec)}; } case nlohmann::json::value_t::object: { - std::map map; + std::map map; for (const auto &item : data.get()) { map.emplace(item.first, JsonToBoltValue(item.second)); } @@ -112,7 +112,7 @@ class Metadata final { }; public: - void Append(const std::map &values) { + void Append(const std::map &values) { for (const auto &item : values) { if (!item.second.IsInt() && !item.second.IsDouble()) continue; auto [it, emplaced] = storage_.emplace(item.first, Record()); @@ -158,8 +158,9 @@ class Metadata final { std::map storage_; }; -void Execute(const std::vector>> &queries, - std::ostream *stream) { +void Execute( + const std::vector>> &queries, + std::ostream *stream) { std::vector threads; threads.reserve(FLAGS_num_workers); @@ -174,9 +175,9 @@ void Execute(const std::vector position(0); for (int worker = 0; worker < FLAGS_num_workers; ++worker) { threads.push_back(std::thread([&, worker]() { - io::network::Endpoint endpoint(FLAGS_address, FLAGS_port); - communication::ClientContext context(FLAGS_use_ssl); - communication::bolt::Client client(&context); + memgraph::io::network::Endpoint endpoint(FLAGS_address, FLAGS_port); + memgraph::communication::ClientContext context(FLAGS_use_ssl); + memgraph::communication::bolt::Client client(&context); client.Connect(endpoint, FLAGS_username, FLAGS_password); ready.fetch_add(1, std::memory_order_acq_rel); @@ -186,7 +187,7 @@ void Execute(const std::vector= size) break; @@ -231,7 +232,7 @@ void Execute(const std::vector>> queries; + std::vector>> queries; if (!FLAGS_queries_json) { // Load simple queries. std::string query; while (std::getline(*istream, query)) { - auto trimmed = utils::Trim(query); + auto trimmed = memgraph::utils::Trim(query); if (trimmed == "" || trimmed == ";") { Execute(queries, ostream); queries.clear(); continue; } - queries.emplace_back(query, std::map{}); + queries.emplace_back(query, std::map{}); } } else { // Load advanced queries. diff --git a/tests/property_based/random_graph.cpp b/tests/property_based/random_graph.cpp index ec1468f56..909381b9c 100644 --- a/tests/property_based/random_graph.cpp +++ b/tests/property_based/random_graph.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -32,10 +32,10 @@ RC_GTEST_PROP(RandomGraph, RandomGraph, (std::vector vertex_labels, int vertices_num = vertex_labels.size(); int edges_num = edge_types.size(); - storage::Storage db; - std::vector vertices; - std::unordered_map vertex_label_map; - std::unordered_map edge_type_map; + memgraph::storage::Storage db; + std::vector vertices; + std::unordered_map vertex_label_map; + std::unordered_map edge_type_map; auto dba = db.Access(); @@ -58,15 +58,15 @@ RC_GTEST_PROP(RandomGraph, RandomGraph, (std::vector vertex_labels, int edges_num_check = 0; int vertices_num_check = 0; - for (auto vertex : dba.Vertices(storage::View::OLD)) { + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) { auto label = vertex_label_map.at(vertex); - auto maybe_labels = vertex.Labels(storage::View::OLD); + auto maybe_labels = vertex.Labels(memgraph::storage::View::OLD); RC_ASSERT(maybe_labels.HasValue()); const auto &labels = *maybe_labels; RC_ASSERT(labels.size() == 1); RC_ASSERT(dba.LabelToName(labels[0]) == label); vertices_num_check++; - auto maybe_edges = vertex.OutEdges(storage::View::OLD); + auto maybe_edges = vertex.OutEdges(memgraph::storage::View::OLD); RC_ASSERT(maybe_edges.HasValue()); for (auto &edge : *maybe_edges) { const auto &type = edge_type_map.at(edge); diff --git a/tests/stress/long_running.cpp b/tests/stress/long_running.cpp index d7973f317..11f5c5feb 100644 --- a/tests/stress/long_running.cpp +++ b/tests/stress/long_running.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,12 +23,12 @@ #include "utils/exceptions.hpp" #include "utils/timer.hpp" -using EndpointT = io::network::Endpoint; -using ClientContextT = communication::ClientContext; -using ClientT = communication::bolt::Client; -using ValueT = communication::bolt::Value; -using QueryDataT = communication::bolt::QueryData; -using ExceptionT = communication::bolt::ClientQueryException; +using EndpointT = memgraph::io::network::Endpoint; +using ClientContextT = memgraph::communication::ClientContext; +using ClientT = memgraph::communication::bolt::Client; +using ValueT = memgraph::communication::bolt::Value; +using QueryDataT = memgraph::communication::bolt::QueryData; +using ExceptionT = memgraph::communication::bolt::ClientQueryException; DEFINE_string(address, "127.0.0.1", "Server address"); DEFINE_int32(port, 7687, "Server port"); @@ -92,7 +92,7 @@ class GraphSession { std::mt19937 generator_; - utils::Timer timer_; + memgraph::utils::Timer timer_; private: double GetRandom() { return std::generate_canonical(generator_); } @@ -377,7 +377,7 @@ class GraphSession { int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); - communication::SSLInit sslInit; + memgraph::communication::SSLInit sslInit; MG_ASSERT(FLAGS_vertex_count > 0, "Vertex count must be greater than 0!"); MG_ASSERT(FLAGS_edge_count > 0, "Edge count must be greater than 0!"); diff --git a/tests/unit/auth.cpp b/tests/unit/auth.cpp index b8d74a2e1..3ef80a2b2 100644 --- a/tests/unit/auth.cpp +++ b/tests/unit/auth.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ #include "utils/file.hpp" #include "utils/license.hpp" -using namespace auth; +using namespace memgraph::auth; namespace fs = std::filesystem; DECLARE_bool(auth_password_permit_null); @@ -30,11 +30,11 @@ DECLARE_string(auth_password_strength_regex); class AuthWithStorage : public ::testing::Test { protected: virtual void SetUp() { - utils::EnsureDir(test_folder_); + memgraph::utils::EnsureDir(test_folder_); FLAGS_auth_password_permit_null = true; FLAGS_auth_password_strength_regex = ".+"; - utils::license::global_license_checker.EnableTesting(); + memgraph::utils::license::global_license_checker.EnableTesting(); } virtual void TearDown() { fs::remove_all(test_folder_); } @@ -346,7 +346,7 @@ TEST(AuthWithoutStorage, Permissions) { permissions.Grant(Permission::MATCH); ASSERT_EQ(permissions.Has(Permission::MATCH), PermissionLevel::GRANT); - ASSERT_EQ(permissions.grants(), utils::UnderlyingCast(Permission::MATCH)); + ASSERT_EQ(permissions.grants(), memgraph::utils::UnderlyingCast(Permission::MATCH)); ASSERT_EQ(permissions.denies(), 0); permissions.Revoke(Permission::MATCH); @@ -356,36 +356,37 @@ TEST(AuthWithoutStorage, Permissions) { permissions.Deny(Permission::MATCH); ASSERT_EQ(permissions.Has(Permission::MATCH), PermissionLevel::DENY); - ASSERT_EQ(permissions.denies(), utils::UnderlyingCast(Permission::MATCH)); + ASSERT_EQ(permissions.denies(), memgraph::utils::UnderlyingCast(Permission::MATCH)); ASSERT_EQ(permissions.grants(), 0); permissions.Grant(Permission::MATCH); ASSERT_EQ(permissions.Has(Permission::MATCH), PermissionLevel::GRANT); - ASSERT_EQ(permissions.grants(), utils::UnderlyingCast(Permission::MATCH)); + ASSERT_EQ(permissions.grants(), memgraph::utils::UnderlyingCast(Permission::MATCH)); ASSERT_EQ(permissions.denies(), 0); permissions.Deny(Permission::CREATE); ASSERT_EQ(permissions.Has(Permission::MATCH), PermissionLevel::GRANT); ASSERT_EQ(permissions.Has(Permission::CREATE), PermissionLevel::DENY); ASSERT_EQ(permissions.Has(Permission::MERGE), PermissionLevel::NEUTRAL); - ASSERT_EQ(permissions.grants(), utils::UnderlyingCast(Permission::MATCH)); - ASSERT_EQ(permissions.denies(), utils::UnderlyingCast(Permission::CREATE)); + ASSERT_EQ(permissions.grants(), memgraph::utils::UnderlyingCast(Permission::MATCH)); + ASSERT_EQ(permissions.denies(), memgraph::utils::UnderlyingCast(Permission::CREATE)); permissions.Grant(Permission::DELETE); ASSERT_EQ(permissions.Has(Permission::MATCH), PermissionLevel::GRANT); ASSERT_EQ(permissions.Has(Permission::CREATE), PermissionLevel::DENY); ASSERT_EQ(permissions.Has(Permission::MERGE), PermissionLevel::NEUTRAL); ASSERT_EQ(permissions.Has(Permission::DELETE), PermissionLevel::GRANT); - ASSERT_EQ(permissions.grants(), utils::UnderlyingCast(Permission::MATCH) | utils::UnderlyingCast(Permission::DELETE)); - ASSERT_EQ(permissions.denies(), utils::UnderlyingCast(Permission::CREATE)); + ASSERT_EQ(permissions.grants(), + memgraph::utils::UnderlyingCast(Permission::MATCH) | memgraph::utils::UnderlyingCast(Permission::DELETE)); + ASSERT_EQ(permissions.denies(), memgraph::utils::UnderlyingCast(Permission::CREATE)); permissions.Revoke(Permission::DELETE); ASSERT_EQ(permissions.Has(Permission::MATCH), PermissionLevel::GRANT); ASSERT_EQ(permissions.Has(Permission::CREATE), PermissionLevel::DENY); ASSERT_EQ(permissions.Has(Permission::MERGE), PermissionLevel::NEUTRAL); ASSERT_EQ(permissions.Has(Permission::DELETE), PermissionLevel::NEUTRAL); - ASSERT_EQ(permissions.grants(), utils::UnderlyingCast(Permission::MATCH)); - ASSERT_EQ(permissions.denies(), utils::UnderlyingCast(Permission::CREATE)); + ASSERT_EQ(permissions.grants(), memgraph::utils::UnderlyingCast(Permission::MATCH)); + ASSERT_EQ(permissions.denies(), memgraph::utils::UnderlyingCast(Permission::CREATE)); } TEST(AuthWithoutStorage, PermissionsMaskTest) { @@ -609,14 +610,14 @@ TEST_F(AuthWithStorage, CaseInsensitivity) { auto role = auth.GetRole("MODErator"); ASSERT_TRUE(role); ASSERT_EQ(role->rolename(), "moderator"); - role->permissions().Grant(auth::Permission::MATCH); + role->permissions().Grant(memgraph::auth::Permission::MATCH); auth.SaveRole(*role); } { auto role = auth.GetRole("modeRATOR"); ASSERT_TRUE(role); ASSERT_EQ(role->rolename(), "moderator"); - ASSERT_EQ(role->permissions().Has(auth::Permission::MATCH), auth::PermissionLevel::GRANT); + ASSERT_EQ(role->permissions().Has(memgraph::auth::Permission::MATCH), memgraph::auth::PermissionLevel::GRANT); } // SaveUser diff --git a/tests/unit/bfs_common.hpp b/tests/unit/bfs_common.hpp index 48aaa2236..a698580cc 100644 --- a/tests/unit/bfs_common.hpp +++ b/tests/unit/bfs_common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,21 +21,21 @@ #include "formatters.hpp" -namespace query { -void PrintTo(const query::EdgeAtom::Direction &dir, std::ostream *os) { +namespace memgraph::query { +void PrintTo(const memgraph::query::EdgeAtom::Direction &dir, std::ostream *os) { switch (dir) { - case query::EdgeAtom::Direction::IN: + case memgraph::query::EdgeAtom::Direction::IN: *os << "IN"; break; - case query::EdgeAtom::Direction::OUT: + case memgraph::query::EdgeAtom::Direction::OUT: *os << "OUT"; break; - case query::EdgeAtom::Direction::BOTH: + case memgraph::query::EdgeAtom::Direction::BOTH: *os << "BOTH"; break; } } -} // namespace query +} // namespace memgraph::query const auto kVertexCount = 6; // Maps vertices to workers @@ -48,20 +48,20 @@ const std::vector> kEdges = {{0, 1, "a"}, {1, // Filters input edge list by edge type and direction and returns a list of // pairs representing valid directed edges. std::vector> GetEdgeList(const std::vector> &edges, - query::EdgeAtom::Direction dir, + memgraph::query::EdgeAtom::Direction dir, const std::vector &edge_types) { std::vector> ret; for (const auto &e : edges) { - if (edge_types.empty() || utils::Contains(edge_types, std::get<2>(e))) + if (edge_types.empty() || memgraph::utils::Contains(edge_types, std::get<2>(e))) ret.emplace_back(std::get<0>(e), std::get<1>(e)); } switch (dir) { - case query::EdgeAtom::Direction::OUT: + case memgraph::query::EdgeAtom::Direction::OUT: break; - case query::EdgeAtom::Direction::IN: + case memgraph::query::EdgeAtom::Direction::IN: for (auto &e : ret) std::swap(e.first, e.second); break; - case query::EdgeAtom::Direction::BOTH: + case memgraph::query::EdgeAtom::Direction::BOTH: auto ret_copy = ret; for (const auto &e : ret_copy) { ret.emplace_back(e.second, e.first); @@ -97,36 +97,41 @@ std::vector> FloydWarshall(int num_vertices, const std::vector< return dist; } -class Yield : public query::plan::LogicalOperator { +class Yield : public memgraph::query::plan::LogicalOperator { public: - Yield(const std::shared_ptr &input, const std::vector &modified_symbols, - const std::vector> &values) - : input_(input ? input : std::make_shared()), + Yield(const std::shared_ptr &input, + const std::vector &modified_symbols, + const std::vector> &values) + : input_(input ? input : std::make_shared()), modified_symbols_(modified_symbols), values_(values) {} - query::plan::UniqueCursorPtr MakeCursor(utils::MemoryResource *mem) const override { - return query::plan::MakeUniqueCursorPtr(mem, this, input_->MakeCursor(mem)); + memgraph::query::plan::UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *mem) const override { + return memgraph::query::plan::MakeUniqueCursorPtr(mem, this, input_->MakeCursor(mem)); + } + std::vector ModifiedSymbols(const memgraph::query::SymbolTable &) const override { + return modified_symbols_; } - std::vector ModifiedSymbols(const query::SymbolTable &) const override { return modified_symbols_; } bool HasSingleInput() const override { return true; } - std::shared_ptr input() const override { return input_; } - void set_input(std::shared_ptr input) override { input_ = input; } - bool Accept(query::plan::HierarchicalLogicalOperatorVisitor &) override { LOG_FATAL("Please go away, visitor!"); } + std::shared_ptr input() const override { return input_; } + void set_input(std::shared_ptr input) override { input_ = input; } + bool Accept(memgraph::query::plan::HierarchicalLogicalOperatorVisitor &) override { + LOG_FATAL("Please go away, visitor!"); + } - std::unique_ptr Clone(query::AstStorage *storage) const override { + std::unique_ptr Clone(memgraph::query::AstStorage *storage) const override { LOG_FATAL("Don't clone Yield operator!"); } - std::shared_ptr input_; - std::vector modified_symbols_; - std::vector> values_; + std::shared_ptr input_; + std::vector modified_symbols_; + std::vector> values_; - class YieldCursor : public query::plan::Cursor { + class YieldCursor : public memgraph::query::plan::Cursor { public: - YieldCursor(const Yield *self, query::plan::UniqueCursorPtr input_cursor) + YieldCursor(const Yield *self, memgraph::query::plan::UniqueCursorPtr input_cursor) : self_(self), input_cursor_(std::move(input_cursor)), pull_index_(self_->values_.size()) {} - bool Pull(query::Frame &frame, query::ExecutionContext &context) override { + bool Pull(memgraph::query::Frame &frame, memgraph::query::ExecutionContext &context) override { if (pull_index_ == self_->values_.size()) { if (!input_cursor_->Pull(frame, context)) return false; pull_index_ = 0; @@ -146,18 +151,18 @@ class Yield : public query::plan::LogicalOperator { private: const Yield *self_; - query::plan::UniqueCursorPtr input_cursor_; + memgraph::query::plan::UniqueCursorPtr input_cursor_; size_t pull_index_; }; }; -std::vector> PullResults(query::plan::LogicalOperator *last_op, - query::ExecutionContext *context, - std::vector output_symbols) { - auto cursor = last_op->MakeCursor(utils::NewDeleteResource()); - std::vector> output; +std::vector> PullResults(memgraph::query::plan::LogicalOperator *last_op, + memgraph::query::ExecutionContext *context, + std::vector output_symbols) { + auto cursor = last_op->MakeCursor(memgraph::utils::NewDeleteResource()); + std::vector> output; { - query::Frame frame(context->symbol_table.max_position()); + memgraph::query::Frame frame(context->symbol_table.max_position()); while (cursor->Pull(frame, *context)) { output.emplace_back(); for (const auto &symbol : output_symbols) { @@ -187,59 +192,59 @@ enum class FilterLambdaType { NONE, USE_FRAME, USE_FRAME_NULL, USE_CTX, ERROR }; // Common interface for single-node and distributed Memgraph. class Database { public: - virtual storage::Storage::Accessor Access() = 0; - virtual std::unique_ptr MakeBfsOperator( - query::Symbol source_sym, query::Symbol sink_sym, query::Symbol edge_sym, query::EdgeAtom::Direction direction, - const std::vector &edge_types, const std::shared_ptr &input, - bool existing_node, query::Expression *lower_bound, query::Expression *upper_bound, - const query::plan::ExpansionLambda &filter_lambda) = 0; - virtual std::pair, std::vector> BuildGraph( - query::DbAccessor *dba, const std::vector &vertex_locations, - const std::vector> &edges) = 0; + virtual memgraph::storage::Storage::Accessor Access() = 0; + virtual std::unique_ptr MakeBfsOperator( + memgraph::query::Symbol source_sym, memgraph::query::Symbol sink_sym, memgraph::query::Symbol edge_sym, + memgraph::query::EdgeAtom::Direction direction, const std::vector &edge_types, + const std::shared_ptr &input, bool existing_node, + memgraph::query::Expression *lower_bound, memgraph::query::Expression *upper_bound, + const memgraph::query::plan::ExpansionLambda &filter_lambda) = 0; + virtual std::pair, std::vector> + BuildGraph(memgraph::query::DbAccessor *dba, const std::vector &vertex_locations, + const std::vector> &edges) = 0; virtual ~Database() {} }; // Returns an operator that yields vertices given by their address. We will also -// include query::TypedValue() to account for the optional match case. -std::unique_ptr YieldVertices(query::DbAccessor *dba, - std::vector vertices, - query::Symbol symbol, - std::shared_ptr input_op) { - std::vector> frames; - frames.push_back(std::vector{query::TypedValue()}); +// include memgraph::query::TypedValue() to account for the optional match case. +std::unique_ptr YieldVertices( + memgraph::query::DbAccessor *dba, std::vector vertices, + memgraph::query::Symbol symbol, std::shared_ptr input_op) { + std::vector> frames; + frames.push_back(std::vector{memgraph::query::TypedValue()}); for (const auto &vertex : vertices) { - frames.emplace_back(std::vector{query::TypedValue(vertex)}); + frames.emplace_back(std::vector{memgraph::query::TypedValue(vertex)}); } - return std::make_unique(input_op, std::vector{symbol}, frames); + return std::make_unique(input_op, std::vector{symbol}, frames); } // Returns an operator that yields edges and vertices given by their address. -std::unique_ptr YieldEntities(query::DbAccessor *dba, - std::vector vertices, - std::vector edges, - query::Symbol symbol, - std::shared_ptr input_op) { - std::vector> frames; +std::unique_ptr YieldEntities( + memgraph::query::DbAccessor *dba, std::vector vertices, + std::vector edges, memgraph::query::Symbol symbol, + std::shared_ptr input_op) { + std::vector> frames; for (const auto &vertex : vertices) { - frames.emplace_back(std::vector{query::TypedValue(vertex)}); + frames.emplace_back(std::vector{memgraph::query::TypedValue(vertex)}); } for (const auto &edge : edges) { - frames.emplace_back(std::vector{query::TypedValue(edge)}); + frames.emplace_back(std::vector{memgraph::query::TypedValue(edge)}); } - return std::make_unique(input_op, std::vector{symbol}, frames); + return std::make_unique(input_op, std::vector{symbol}, frames); } template -auto GetProp(const TRecord &rec, std::string prop, query::DbAccessor *dba) { - return *rec.GetProperty(storage::View::OLD, dba->NameToProperty(prop)); +auto GetProp(const TRecord &rec, std::string prop, memgraph::query::DbAccessor *dba) { + return *rec.GetProperty(memgraph::storage::View::OLD, dba->NameToProperty(prop)); } // Checks if the given path is actually a path from source to sink and if all // of its edges exist in the given edge list. template -void CheckPath(query::DbAccessor *dba, const query::VertexAccessor &source, const query::VertexAccessor &sink, - const std::vector &path, +void CheckPath(memgraph::query::DbAccessor *dba, const memgraph::query::VertexAccessor &source, + const memgraph::query::VertexAccessor &sink, + const std::vector &path, const std::vector> &edges) { auto curr = source; for (const auto &edge_tv : path) { @@ -251,7 +256,7 @@ void CheckPath(query::DbAccessor *dba, const query::VertexAccessor &source, cons int from = GetProp(curr, "id", dba).ValueInt(); int to = GetProp(next, "id", dba).ValueInt(); - ASSERT_TRUE(utils::Contains(edges, std::make_pair(from, to))); + ASSERT_TRUE(memgraph::utils::Contains(edges, std::make_pair(from, to))); curr = next; } @@ -261,8 +266,8 @@ void CheckPath(query::DbAccessor *dba, const query::VertexAccessor &source, cons // Given a list of BFS results of form (from, to, path, blocked entity), // checks if all paths are valid and returns the distance matrix. std::vector> CheckPathsAndExtractDistances( - query::DbAccessor *dba, const std::vector> edges, - const std::vector> &results) { + memgraph::query::DbAccessor *dba, const std::vector> edges, + const std::vector> &results) { std::vector> distances(kVertexCount, std::vector(kVertexCount, -1)); for (size_t i = 0; i < kVertexCount; ++i) distances[i][i] = 0; @@ -276,39 +281,40 @@ std::vector> CheckPathsAndExtractDistances( return distances; } -void BfsTest(Database *db, int lower_bound, int upper_bound, query::EdgeAtom::Direction direction, +void BfsTest(Database *db, int lower_bound, int upper_bound, memgraph::query::EdgeAtom::Direction direction, std::vector edge_types, bool known_sink, FilterLambdaType filter_lambda_type) { auto storage_dba = db->Access(); - query::DbAccessor dba(&storage_dba); - query::AstStorage storage; - query::ExecutionContext context{&dba}; - query::Symbol blocked_sym = context.symbol_table.CreateSymbol("blocked", true); - query::Symbol source_sym = context.symbol_table.CreateSymbol("source", true); - query::Symbol sink_sym = context.symbol_table.CreateSymbol("sink", true); - query::Symbol edges_sym = context.symbol_table.CreateSymbol("edges", true); - query::Symbol inner_node_sym = context.symbol_table.CreateSymbol("inner_node", true); - query::Symbol inner_edge_sym = context.symbol_table.CreateSymbol("inner_edge", true); - query::Identifier *blocked = IDENT("blocked")->MapTo(blocked_sym); - query::Identifier *inner_node = IDENT("inner_node")->MapTo(inner_node_sym); - query::Identifier *inner_edge = IDENT("inner_edge")->MapTo(inner_edge_sym); + memgraph::query::DbAccessor dba(&storage_dba); + memgraph::query::AstStorage storage; + memgraph::query::ExecutionContext context{&dba}; + memgraph::query::Symbol blocked_sym = context.symbol_table.CreateSymbol("blocked", true); + memgraph::query::Symbol source_sym = context.symbol_table.CreateSymbol("source", true); + memgraph::query::Symbol sink_sym = context.symbol_table.CreateSymbol("sink", true); + memgraph::query::Symbol edges_sym = context.symbol_table.CreateSymbol("edges", true); + memgraph::query::Symbol inner_node_sym = context.symbol_table.CreateSymbol("inner_node", true); + memgraph::query::Symbol inner_edge_sym = context.symbol_table.CreateSymbol("inner_edge", true); + memgraph::query::Identifier *blocked = IDENT("blocked")->MapTo(blocked_sym); + memgraph::query::Identifier *inner_node = IDENT("inner_node")->MapTo(inner_node_sym); + memgraph::query::Identifier *inner_edge = IDENT("inner_edge")->MapTo(inner_edge_sym); - std::vector vertices; - std::vector edges; + std::vector vertices; + std::vector edges; std::tie(vertices, edges) = db->BuildGraph(&dba, kVertexLocations, kEdges); dba.AdvanceCommand(); - std::shared_ptr input_op; + std::shared_ptr input_op; - query::Expression *filter_expr; + memgraph::query::Expression *filter_expr; // First build a filter lambda and an operator yielding blocked entities. switch (filter_lambda_type) { case FilterLambdaType::NONE: // No filter lambda, nothing is ever blocked. - input_op = std::make_shared(nullptr, std::vector{blocked_sym}, - std::vector>{{query::TypedValue()}}); + input_op = std::make_shared( + nullptr, std::vector{blocked_sym}, + std::vector>{{memgraph::query::TypedValue()}}); filter_expr = nullptr; break; case FilterLambdaType::USE_FRAME: @@ -319,15 +325,16 @@ void BfsTest(Database *db, int lower_bound, int upper_bound, query::EdgeAtom::Di case FilterLambdaType::USE_FRAME_NULL: // We block each entity in the graph and run BFS. input_op = YieldEntities(&dba, vertices, edges, blocked_sym, nullptr); - filter_expr = - IF(AND(NEQ(inner_node, blocked), NEQ(inner_edge, blocked)), LITERAL(true), LITERAL(storage::PropertyValue())); + filter_expr = IF(AND(NEQ(inner_node, blocked), NEQ(inner_edge, blocked)), LITERAL(true), + LITERAL(memgraph::storage::PropertyValue())); break; case FilterLambdaType::USE_CTX: // We only block vertex #5 and run BFS. - input_op = std::make_shared(nullptr, std::vector{blocked_sym}, - std::vector>{{query::TypedValue(vertices[5])}}); + input_op = std::make_shared( + nullptr, std::vector{blocked_sym}, + std::vector>{{memgraph::query::TypedValue(vertices[5])}}); filter_expr = NEQ(PROPERTY_LOOKUP(inner_node, PROPERTY_PAIR("id")), PARAMETER_LOOKUP(0)); - context.evaluation_context.parameters.Add(0, storage::PropertyValue(5)); + context.evaluation_context.parameters.Add(0, memgraph::storage::PropertyValue(5)); break; case FilterLambdaType::ERROR: // Evaluate to 42 for vertex #5 which is on worker 1. @@ -343,7 +350,7 @@ void BfsTest(Database *db, int lower_bound, int upper_bound, query::EdgeAtom::Di input_op = YieldVertices(&dba, vertices, sink_sym, input_op); } - std::vector storage_edge_types; + std::vector storage_edge_types; for (const auto &t : edge_types) { storage_edge_types.push_back(dba.NameToEdgeType(t)); } @@ -351,29 +358,29 @@ void BfsTest(Database *db, int lower_bound, int upper_bound, query::EdgeAtom::Di input_op = db->MakeBfsOperator(source_sym, sink_sym, edges_sym, direction, storage_edge_types, input_op, known_sink, lower_bound == -1 ? nullptr : LITERAL(lower_bound), upper_bound == -1 ? nullptr : LITERAL(upper_bound), - query::plan::ExpansionLambda{inner_edge_sym, inner_node_sym, filter_expr}); + memgraph::query::plan::ExpansionLambda{inner_edge_sym, inner_node_sym, filter_expr}); - context.evaluation_context.properties = query::NamesToProperties(storage.properties_, &dba); - context.evaluation_context.labels = query::NamesToLabels(storage.labels_, &dba); - std::vector> results; + context.evaluation_context.properties = memgraph::query::NamesToProperties(storage.properties_, &dba); + context.evaluation_context.labels = memgraph::query::NamesToLabels(storage.labels_, &dba); + std::vector> results; // An exception should be thrown on one of the pulls. if (filter_lambda_type == FilterLambdaType::ERROR) { - EXPECT_THROW( - PullResults(input_op.get(), &context, std::vector{source_sym, sink_sym, edges_sym, blocked_sym}), - query::QueryRuntimeException); + EXPECT_THROW(PullResults(input_op.get(), &context, + std::vector{source_sym, sink_sym, edges_sym, blocked_sym}), + memgraph::query::QueryRuntimeException); return; } - results = - PullResults(input_op.get(), &context, std::vector{source_sym, sink_sym, edges_sym, blocked_sym}); + results = PullResults(input_op.get(), &context, + std::vector{source_sym, sink_sym, edges_sym, blocked_sym}); // Group results based on blocked entity and compare them to results // obtained by running Floyd-Warshall. for (size_t i = 0; i < results.size();) { int j = i; auto blocked = results[j][3]; - while (j < results.size() && query::TypedValue::BoolEqual{}(results[j][3], blocked)) ++j; + while (j < results.size() && memgraph::query::TypedValue::BoolEqual{}(results[j][3], blocked)) ++j; SCOPED_TRACE(fmt::format("blocked entity = {}", ToString(blocked, dba))); @@ -422,7 +429,8 @@ void BfsTest(Database *db, int lower_bound, int upper_bound, query::EdgeAtom::Di EXPECT_EQ(j - i, num_results); auto distances = CheckPathsAndExtractDistances( - &dba, edges_blocked, std::vector>(results.begin() + i, results.begin() + j)); + &dba, edges_blocked, + std::vector>(results.begin() + i, results.begin() + j)); // The distances should also match. EXPECT_EQ(distances, correct_with_bounds); diff --git a/tests/unit/bfs_single_node.cpp b/tests/unit/bfs_single_node.cpp index e58f1ddf8..93002eef5 100644 --- a/tests/unit/bfs_single_node.cpp +++ b/tests/unit/bfs_single_node.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,18 +11,18 @@ #include "bfs_common.hpp" -using namespace query; -using namespace query::plan; +using namespace memgraph::query; +using namespace memgraph::query::plan; class SingleNodeDb : public Database { public: SingleNodeDb() : db_() {} - storage::Storage::Accessor Access() override { return db_.Access(); } + memgraph::storage::Storage::Accessor Access() override { return db_.Access(); } std::unique_ptr MakeBfsOperator(Symbol source_sym, Symbol sink_sym, Symbol edge_sym, EdgeAtom::Direction direction, - const std::vector &edge_types, + const std::vector &edge_types, const std::shared_ptr &input, bool existing_node, Expression *lower_bound, Expression *upper_bound, const ExpansionLambda &filter_lambda) override { @@ -31,16 +31,17 @@ class SingleNodeDb : public Database { filter_lambda, std::nullopt, std::nullopt); } - std::pair, std::vector> BuildGraph( - query::DbAccessor *dba, const std::vector &vertex_locations, + std::pair, std::vector> BuildGraph( + memgraph::query::DbAccessor *dba, const std::vector &vertex_locations, const std::vector> &edges) override { - std::vector vertex_addr; - std::vector edge_addr; + std::vector vertex_addr; + std::vector edge_addr; for (size_t id = 0; id < vertex_locations.size(); ++id) { auto vertex = dba->InsertVertex(); MG_ASSERT( - vertex.SetProperty(dba->NameToProperty("id"), storage::PropertyValue(static_cast(id))).HasValue()); + vertex.SetProperty(dba->NameToProperty("id"), memgraph::storage::PropertyValue(static_cast(id))) + .HasValue()); vertex_addr.push_back(vertex); } @@ -51,8 +52,8 @@ class SingleNodeDb : public Database { auto &from = vertex_addr[u]; auto &to = vertex_addr[v]; auto edge = dba->InsertEdge(&from, &to, dba->NameToEdgeType(type)); - MG_ASSERT(edge->SetProperty(dba->NameToProperty("from"), storage::PropertyValue(u)).HasValue()); - MG_ASSERT(edge->SetProperty(dba->NameToProperty("to"), storage::PropertyValue(v)).HasValue()); + MG_ASSERT(edge->SetProperty(dba->NameToProperty("from"), memgraph::storage::PropertyValue(u)).HasValue()); + MG_ASSERT(edge->SetProperty(dba->NameToProperty("to"), memgraph::storage::PropertyValue(v)).HasValue()); edge_addr.push_back(*edge); } @@ -60,7 +61,7 @@ class SingleNodeDb : public Database { } protected: - storage::Storage db_; + memgraph::storage::Storage db_; }; class SingleNodeBfsTest diff --git a/tests/unit/bolt_chunked_decoder_buffer.cpp b/tests/unit/bolt_chunked_decoder_buffer.cpp index 8400d20b8..a668d3c50 100644 --- a/tests/unit/bolt_chunked_decoder_buffer.cpp +++ b/tests/unit/bolt_chunked_decoder_buffer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,10 +16,10 @@ constexpr const int SIZE = 131072; uint8_t data[SIZE]; -using BufferT = communication::Buffer; -using StreamBufferT = io::network::StreamBuffer; -using DecoderBufferT = communication::bolt::ChunkedDecoderBuffer; -using ChunkStateT = communication::bolt::ChunkState; +using BufferT = memgraph::communication::Buffer; +using StreamBufferT = memgraph::io::network::StreamBuffer; +using DecoderBufferT = memgraph::communication::bolt::ChunkedDecoderBuffer; +using ChunkStateT = memgraph::communication::bolt::ChunkState; struct BoltBuffer : ::testing::Test { // In newer gtest library (1.8.1+) this is changed to SetUpTestSuite diff --git a/tests/unit/bolt_chunked_encoder_buffer.cpp b/tests/unit/bolt_chunked_encoder_buffer.cpp index d5a454201..a7d1451e6 100644 --- a/tests/unit/bolt_chunked_encoder_buffer.cpp +++ b/tests/unit/bolt_chunked_encoder_buffer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -13,12 +13,12 @@ #include "communication/bolt/v1/encoder/chunked_encoder_buffer.hpp" // aliases -using BufferT = communication::bolt::ChunkedEncoderBuffer; +using BufferT = memgraph::communication::bolt::ChunkedEncoderBuffer; // constants -using communication::bolt::kChunkHeaderSize; -using communication::bolt::kChunkMaxDataSize; -using communication::bolt::kChunkWholeSize; +using memgraph::communication::bolt::kChunkHeaderSize; +using memgraph::communication::bolt::kChunkMaxDataSize; +using memgraph::communication::bolt::kChunkWholeSize; // test data constexpr const int kTestDataSize = 100000; diff --git a/tests/unit/bolt_decoder.cpp b/tests/unit/bolt_decoder.cpp index 7b1b28b58..7f05f400f 100644 --- a/tests/unit/bolt_decoder.cpp +++ b/tests/unit/bolt_decoder.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "bolt_testdata.hpp" #include "communication/bolt/v1/decoder/decoder.hpp" -using communication::bolt::Value; +using memgraph::communication::bolt::Value; constexpr const int SIZE = 131072; uint8_t data[SIZE]; @@ -48,7 +48,7 @@ class TestDecoderBuffer { std::vector buffer_; }; -using DecoderT = communication::bolt::Decoder; +using DecoderT = memgraph::communication::bolt::Decoder; struct BoltDecoder : ::testing::Test { // In newer gtest library (1.8.1+) this is changed to SetUpTestSuite @@ -454,7 +454,7 @@ constexpr uint8_t Cast(T marker) { return static_cast(marker); } -void AssertThatDatesAreEqual(const utils::Date &d1, const utils::Date &d2) { +void AssertThatDatesAreEqual(const memgraph::utils::Date &d1, const memgraph::utils::Date &d2) { ASSERT_EQ(d1.day, d2.day); ASSERT_EQ(d1.month, d2.month); ASSERT_EQ(d1.year, d2.year); @@ -466,15 +466,15 @@ TEST_F(BoltDecoder, DateOld) { Value dv; - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; - const auto date = utils::Date({1970, 1, 1}); + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; + const auto date = memgraph::utils::Date({1970, 1, 1}); const auto days = date.DaysSinceEpoch(); ASSERT_EQ(days, 0); // clang-format off std::array data = { - Cast(Marker::TinyStruct1), - Cast(Sig::Date), + Cast(Marker::TinyStruct1), + Cast(Sig::Date), 0x0 }; // clang-format on buffer.Clear(); @@ -487,22 +487,22 @@ TEST_F(BoltDecoder, DateRecent) { TestDecoderBuffer buffer; DecoderT decoder(buffer); Value dv; - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; - const auto date = utils::Date({2021, 7, 20}); + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; + const auto date = memgraph::utils::Date({2021, 7, 20}); const auto days = date.DaysSinceEpoch(); ASSERT_EQ(days, 18828); const auto *d_bytes = std::bit_cast(&days); // clang-format off std::array data = { - Cast(Marker::TinyStruct1), - Cast(Sig::Date), - Cast(Marker::Int32), - d_bytes[3], - d_bytes[2], - d_bytes[1], + Cast(Marker::TinyStruct1), + Cast(Sig::Date), + Cast(Marker::Int32), + d_bytes[3], + d_bytes[2], + d_bytes[1], d_bytes[0] }; - // clang-format on + // clang-format on buffer.Clear(); buffer.Write(data.data(), data.size()); ASSERT_EQ(decoder.ReadValue(&dv, Value::Type::Date), true); @@ -513,15 +513,15 @@ TEST_F(BoltDecoder, DurationOneSec) { TestDecoderBuffer buffer; DecoderT decoder(buffer); Value dv; - const auto value = Value(utils::Duration(1)); + const auto value = Value(memgraph::utils::Duration(1)); const auto &dur = value.ValueDuration(); const auto nanos = dur.SubSecondsAsNanoseconds(); ASSERT_EQ(dur.Days(), 0); ASSERT_EQ(dur.SubDaysAsSeconds(), 0); - ASSERT_EQ(nanos, 1000); + ASSERT_EQ(nanos, 1000); const auto *n_bytes = std::bit_cast(&nanos); - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off std::array data = { Cast(Marker::TinyStruct4), @@ -542,15 +542,15 @@ TEST_F(BoltDecoder, DurationMinusOneSec) { TestDecoderBuffer buffer; DecoderT decoder(buffer); Value dv; - const auto value = Value(utils::Duration(-1)); + const auto value = Value(memgraph::utils::Duration(-1)); const auto &dur = value.ValueDuration(); const auto nanos = dur.SubSecondsAsNanoseconds(); ASSERT_EQ(dur.Days(), 0); ASSERT_EQ(dur.SubDaysAsSeconds(), 0); ASSERT_EQ(nanos, -1000); const auto *n_bytes = std::bit_cast(&nanos); - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off std::array data = { Cast(Marker::TinyStruct4), @@ -571,7 +571,7 @@ TEST_F(BoltDecoder, ArbitraryDuration) { TestDecoderBuffer buffer; DecoderT decoder(buffer); Value dv; - const auto value = Value(utils::Duration({15, 1, 2, 3, 5, 0})); + const auto value = Value(memgraph::utils::Duration({15, 1, 2, 3, 5, 0})); const auto &dur = value.ValueDuration(); ASSERT_EQ(dur.Days(), 15); const auto secs = dur.SubDaysAsSeconds(); @@ -580,8 +580,8 @@ TEST_F(BoltDecoder, ArbitraryDuration) { const auto nanos = dur.SubSecondsAsNanoseconds(); ASSERT_EQ(nanos, 5000000); const auto *nano_bytes = std::bit_cast(&nanos); - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off std::array data = { Cast(Marker::TinyStruct4), @@ -591,7 +591,7 @@ TEST_F(BoltDecoder, ArbitraryDuration) { Cast(Marker::Int16), sec_bytes[1], sec_bytes[0], - Cast(Marker::Int32), + Cast(Marker::Int32), nano_bytes[3], nano_bytes[2], nano_bytes[1], @@ -604,7 +604,7 @@ TEST_F(BoltDecoder, ArbitraryDuration) { ASSERT_EQ(dv.ValueDuration().microseconds, dur.microseconds); } -void AssertThatLocalTimeIsEqual(utils::LocalTime t1, utils::LocalTime t2) { +void AssertThatLocalTimeIsEqual(memgraph::utils::LocalTime t1, memgraph::utils::LocalTime t2) { ASSERT_EQ(t1.hour, t2.hour); ASSERT_EQ(t1.minute, t2.minute); ASSERT_EQ(t1.second, t2.second); @@ -616,18 +616,18 @@ TEST_F(BoltDecoder, LocalTimeOneMicro) { TestDecoderBuffer buffer; DecoderT decoder(buffer); Value dv; - const auto value = Value(utils::LocalTime(1)); + const auto value = Value(memgraph::utils::LocalTime(1)); const auto &local_time = value.ValueLocalTime(); const auto nanos = local_time.NanosecondsSinceEpoch(); ASSERT_EQ(nanos, 1000); const auto *n_bytes = std::bit_cast(&nanos); - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off std::array data = { - Cast(Marker::TinyStruct1), - Cast(Sig::LocalTime), - Cast(Marker::Int16), + Cast(Marker::TinyStruct1), + Cast(Sig::LocalTime), + Cast(Marker::Int16), n_bytes[1], n_bytes[0] }; // clang-format on @@ -641,18 +641,18 @@ TEST_F(BoltDecoder, LocalTimeOneThousandMicro) { TestDecoderBuffer buffer; DecoderT decoder(buffer); Value dv; - const auto value = Value(utils::LocalTime(1000)); + const auto value = Value(memgraph::utils::LocalTime(1000)); const auto &local_time = value.ValueLocalTime(); const auto nanos = local_time.NanosecondsSinceEpoch(); ASSERT_EQ(nanos, 1000000); const auto *n_bytes = std::bit_cast(&nanos); - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off std::array data = { - Cast(Marker::TinyStruct1), - Cast(Sig::LocalTime), - Cast(Marker::Int32), + Cast(Marker::TinyStruct1), + Cast(Sig::LocalTime), + Cast(Marker::Int32), n_bytes[3], n_bytes[2], n_bytes[1], n_bytes[0] }; // clang-format on @@ -668,9 +668,9 @@ TEST_F(BoltDecoder, LocalDateTime) { Value dv; - const auto local_time = utils::LocalTime(utils::LocalTimeParameters({0, 0, 30, 1, 0})); - const auto date = utils::Date(1); - const auto value = Value(utils::LocalDateTime(date, local_time)); + const auto local_time = memgraph::utils::LocalTime(memgraph::utils::LocalTimeParameters({0, 0, 30, 1, 0})); + const auto date = memgraph::utils::Date(1); + const auto value = Value(memgraph::utils::LocalDateTime(date, local_time)); const auto local_date_time = value.ValueLocalDateTime(); const auto secs = local_date_time.SecondsSinceEpoch(); ASSERT_EQ(secs, 30); @@ -678,15 +678,15 @@ TEST_F(BoltDecoder, LocalDateTime) { const auto nanos = local_date_time.SubSecondsAsNanoseconds(); ASSERT_EQ(nanos, 1000000); const auto *nano_bytes = std::bit_cast(&nanos); - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off std::array data = { Cast(Marker::TinyStruct2), Cast(Sig::LocalDateTime), // Seconds sec_bytes[0], - // Nanoseconds + // Nanoseconds Cast(Marker::Int32), nano_bytes[3], nano_bytes[2], nano_bytes[1], nano_bytes[0] }; diff --git a/tests/unit/bolt_encoder.cpp b/tests/unit/bolt_encoder.cpp index 6812c9e10..eefc43632 100644 --- a/tests/unit/bolt_encoder.cpp +++ b/tests/unit/bolt_encoder.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "glue/communication.hpp" #include "storage/v2/storage.hpp" #include "utils/temporal.hpp" -using communication::bolt::Value; +using memgraph::communication::bolt::Value; /** * TODO (mferencevic): document @@ -59,7 +59,7 @@ void CheckTypeSize(std::vector &v, int typ, uint64_t size) { void CheckInt(std::vector &output, int64_t value) { TestOutputStream output_stream; TestBuffer encoder_buffer(output_stream); - communication::bolt::BaseEncoder bolt_encoder(encoder_buffer); + memgraph::communication::bolt::BaseEncoder bolt_encoder(encoder_buffer); std::vector &encoded = output_stream.output; bolt_encoder.WriteInt(value); CheckOutput(output, encoded.data(), encoded.size(), false); @@ -72,7 +72,7 @@ void CheckRecordHeader(std::vector &v, uint64_t size) { TestOutputStream output_stream; TestBuffer encoder_buffer(output_stream); -communication::bolt::Encoder bolt_encoder(encoder_buffer); +memgraph::communication::bolt::Encoder bolt_encoder(encoder_buffer); std::vector &output = output_stream.output; struct BoltEncoder : ::testing::Test { @@ -178,7 +178,7 @@ TEST_F(BoltEncoder, VertexAndEdge) { output.clear(); // create vertex - storage::Storage db; + memgraph::storage::Storage db; auto dba = db.Access(); auto va1 = dba.CreateVertex(); auto va2 = dba.CreateVertex(); @@ -188,7 +188,7 @@ TEST_F(BoltEncoder, VertexAndEdge) { ASSERT_TRUE(va1.AddLabel(l2).HasValue()); auto p1 = dba.NameToProperty("prop1"); auto p2 = dba.NameToProperty("prop2"); - storage::PropertyValue pv1(12), pv2(200); + memgraph::storage::PropertyValue pv1(12), pv2(200); ASSERT_TRUE(va1.SetProperty(p1, pv1).HasValue()); ASSERT_TRUE(va1.SetProperty(p2, pv2).HasValue()); @@ -197,15 +197,18 @@ TEST_F(BoltEncoder, VertexAndEdge) { auto ea = dba.CreateEdge(&va1, &va2, et); auto p3 = dba.NameToProperty("prop3"); auto p4 = dba.NameToProperty("prop4"); - storage::PropertyValue pv3(42), pv4(1234); + memgraph::storage::PropertyValue pv3(42), pv4(1234); ASSERT_TRUE(ea->SetProperty(p3, pv3).HasValue()); ASSERT_TRUE(ea->SetProperty(p4, pv4).HasValue()); // check everything std::vector vals; - vals.push_back(*glue::ToBoltValue(query::TypedValue(query::VertexAccessor(va1)), db, storage::View::NEW)); - vals.push_back(*glue::ToBoltValue(query::TypedValue(query::VertexAccessor(va2)), db, storage::View::NEW)); - vals.push_back(*glue::ToBoltValue(query::TypedValue(query::EdgeAccessor(*ea)), db, storage::View::NEW)); + vals.push_back(*memgraph::glue::ToBoltValue(memgraph::query::TypedValue(memgraph::query::VertexAccessor(va1)), db, + memgraph::storage::View::NEW)); + vals.push_back(*memgraph::glue::ToBoltValue(memgraph::query::TypedValue(memgraph::query::VertexAccessor(va2)), db, + memgraph::storage::View::NEW)); + vals.push_back(*memgraph::glue::ToBoltValue(memgraph::query::TypedValue(memgraph::query::EdgeAccessor(*ea)), db, + memgraph::storage::View::NEW)); bolt_encoder.MessageRecord(vals); // The vertexedge_encoded testdata has hardcoded zeros for IDs, @@ -272,7 +275,7 @@ constexpr uint8_t Cast(T marker) { TEST_F(BoltEncoder, DateOld) { output.clear(); std::vector vals; - const auto value = Value(utils::Date({1970, 1, 1})); + const auto value = Value(memgraph::utils::Date({1970, 1, 1})); vals.push_back(value); ASSERT_EQ(bolt_encoder.MessageRecord(vals), true); const auto &date = value.ValueDate(); @@ -283,15 +286,15 @@ TEST_F(BoltEncoder, DateOld) { // WriteTypeSize() in base_encoder.hpp). // We reverse the order of d_bytes because after the encoding // it has BigEndian orderring. - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off const auto expected = std::array { - Cast(Marker::TinyStruct1), + Cast(Marker::TinyStruct1), Cast(Sig::Record), - 0x91, - Cast(Marker::TinyStruct1), - Cast(Sig::Date), + 0x91, + Cast(Marker::TinyStruct1), + Cast(Sig::Date), d_bytes[0] }; // clang-format on CheckOutput(output, expected.data(), expected.size()); @@ -300,7 +303,7 @@ TEST_F(BoltEncoder, DateOld) { TEST_F(BoltEncoder, DateRecent) { output.clear(); std::vector vals; - const auto value = Value(utils::Date({2021, 7, 20})); + const auto value = Value(memgraph::utils::Date({2021, 7, 20})); vals.push_back(value); ASSERT_EQ(bolt_encoder.MessageRecord(vals), true); const auto &date = value.ValueDate(); @@ -311,17 +314,17 @@ TEST_F(BoltEncoder, DateRecent) { // WriteTypeSize() in base_encoder.hpp). // We reverse the order of d_bytes because after the encoding // it has BigEndian orderring. - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off const auto expected = std::array { - Cast(Marker::TinyStruct1), + Cast(Marker::TinyStruct1), Cast(Sig::Record), - 0x91, - Cast(Marker::TinyStruct1), + 0x91, + Cast(Marker::TinyStruct1), Cast(Sig::Date), Cast(Marker::Int16), - d_bytes[1], + d_bytes[1], d_bytes[0] }; // clang-format on CheckOutput(output, expected.data(), expected.size()); @@ -330,7 +333,7 @@ TEST_F(BoltEncoder, DateRecent) { TEST_F(BoltEncoder, DurationOneSec) { output.clear(); std::vector vals; - const auto value = Value(utils::Duration(1)); + const auto value = Value(memgraph::utils::Duration(1)); vals.push_back(value); ASSERT_EQ(bolt_encoder.MessageRecord(vals), true); const auto &dur = value.ValueDuration(); @@ -341,11 +344,11 @@ TEST_F(BoltEncoder, DurationOneSec) { const auto *d_bytes = std::bit_cast(&nanos); // 0x91 denotes the size of vals (it's 0x91 because it's anded -- see // WriteTypeSize in base_encoder.hpp). - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off - const auto expected = std::array { - Cast(Marker::TinyStruct1), + const auto expected = std::array { + Cast(Marker::TinyStruct1), Cast(Sig::Record), 0x91, Cast(Marker::TinyStruct4), @@ -363,7 +366,7 @@ TEST_F(BoltEncoder, DurationOneSec) { TEST_F(BoltEncoder, DurationMinusOneSec) { output.clear(); std::vector vals; - const auto value = Value(utils::Duration(-1)); + const auto value = Value(memgraph::utils::Duration(-1)); vals.push_back(value); ASSERT_EQ(bolt_encoder.MessageRecord(vals), true); const auto &dur = value.ValueDuration(); @@ -374,11 +377,11 @@ TEST_F(BoltEncoder, DurationMinusOneSec) { ASSERT_EQ(nanos, -1000); // 0x91 denotes the size of vals (it's 0x91 because it's anded -- see // WriteTypeSize in base_encoder.hpp). - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off - const auto expected = std::array { - Cast(Marker::TinyStruct1), + const auto expected = std::array { + Cast(Marker::TinyStruct1), Cast(Sig::Record), 0x91, Cast(Marker::TinyStruct4), @@ -396,7 +399,7 @@ TEST_F(BoltEncoder, DurationMinusOneSec) { TEST_F(BoltEncoder, ArbitraryDuration) { output.clear(); std::vector vals; - const auto value = Value(utils::Duration({15, 1, 2, 3, 5, 0})); + const auto value = Value(memgraph::utils::Duration({15, 1, 2, 3, 5, 0})); vals.push_back(value); ASSERT_EQ(bolt_encoder.MessageRecord(vals), true); const auto &dur = value.ValueDuration(); @@ -410,11 +413,11 @@ TEST_F(BoltEncoder, ArbitraryDuration) { const auto *nano_bytes = std::bit_cast(&nanos); // 0x91 denotes the size of vals (it's 0x91 because it's anded -- see // WriteTypeSize in base_encoder.hpp). - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off - const auto expected = std::array { - Cast(Marker::TinyStruct1), + const auto expected = std::array { + Cast(Marker::TinyStruct1), Cast(Sig::Record), 0x91, Cast(Marker::TinyStruct4), @@ -424,7 +427,7 @@ TEST_F(BoltEncoder, ArbitraryDuration) { Cast(Marker::Int16), sec_bytes[1], sec_bytes[0], - Cast(Marker::Int32), + Cast(Marker::Int32), nano_bytes[3], nano_bytes[2], nano_bytes[1], @@ -436,15 +439,15 @@ TEST_F(BoltEncoder, ArbitraryDuration) { TEST_F(BoltEncoder, LocalTimeOneMicro) { output.clear(); std::vector vals; - const auto value = Value(utils::LocalTime(1)); + const auto value = Value(memgraph::utils::LocalTime(1)); vals.push_back(value); ASSERT_EQ(bolt_encoder.MessageRecord(vals), true); const auto &local_time = value.ValueLocalTime(); const auto nanos = local_time.NanosecondsSinceEpoch(); ASSERT_EQ(nanos, 1000); const auto *n_bytes = std::bit_cast(&nanos); - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off const auto expected = std::array { Cast(Marker::TinyStruct1), @@ -461,15 +464,15 @@ TEST_F(BoltEncoder, LocalTimeOneMicro) { TEST_F(BoltEncoder, LocalTimeOneThousandMicro) { output.clear(); std::vector vals; - const auto value = Value(utils::LocalTime(1000)); + const auto value = Value(memgraph::utils::LocalTime(1000)); vals.push_back(value); ASSERT_EQ(bolt_encoder.MessageRecord(vals), true); const auto &local_time = value.ValueLocalTime(); const auto nanos = local_time.NanosecondsSinceEpoch(); ASSERT_EQ(nanos, 1000000); const auto *n_bytes = std::bit_cast(&nanos); - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off const auto expected = std::array { Cast(Marker::TinyStruct1), @@ -487,7 +490,8 @@ TEST_F(BoltEncoder, LocalTimeOneThousandMicro) { TEST_F(BoltEncoder, LocalDateTime) { output.clear(); std::vector vals; - const auto value = Value(utils::LocalDateTime(utils::Date(1), utils::LocalTime({0, 0, 30, 1, 0}))); + const auto value = + Value(memgraph::utils::LocalDateTime(memgraph::utils::Date(1), memgraph::utils::LocalTime({0, 0, 30, 1, 0}))); const auto &local_date_time = value.ValueLocalDateTime(); vals.push_back(value); ASSERT_EQ(bolt_encoder.MessageRecord(vals), true); @@ -500,12 +504,12 @@ TEST_F(BoltEncoder, LocalDateTime) { // 0x91 denotes the size of vals (it's 0x91 because it's anded -- see // WriteTypeSize in base_encoder.hpp). // The rest of the expected results follow logically from LocalTime and Date test cases - using Marker = communication::bolt::Marker; - using Sig = communication::bolt::Signature; + using Marker = memgraph::communication::bolt::Marker; + using Sig = memgraph::communication::bolt::Signature; // clang-format off const auto expected = std::array { - Cast(Marker::TinyStruct1), - Cast(Sig::Record), + Cast(Marker::TinyStruct1), + Cast(Sig::Record), 0x91, Cast(Marker::TinyStruct2), Cast(Sig::LocalDateTime), diff --git a/tests/unit/bolt_session.cpp b/tests/unit/bolt_session.cpp index 396a81a72..f7fbc412c 100644 --- a/tests/unit/bolt_session.cpp +++ b/tests/unit/bolt_session.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,11 +16,11 @@ #include "communication/exceptions.hpp" #include "utils/logging.hpp" -using communication::bolt::ClientError; -using communication::bolt::Session; -using communication::bolt::SessionException; -using communication::bolt::State; -using communication::bolt::Value; +using memgraph::communication::bolt::ClientError; +using memgraph::communication::bolt::Session; +using memgraph::communication::bolt::SessionException; +using memgraph::communication::bolt::State; +using memgraph::communication::bolt::Value; static const char *kInvalidQuery = "invalid query"; static const char *kQueryReturn42 = "RETURN 42"; @@ -154,7 +154,7 @@ constexpr uint8_t route[]{0xb0, 0x60}; // Write bolt chunk header (length) void WriteChunkHeader(TestInputStream &input_stream, uint16_t len) { - len = utils::HostToBigEndian(len); + len = memgraph::utils::HostToBigEndian(len); input_stream.Write(reinterpret_cast(&len), sizeof(len)); } @@ -887,7 +887,7 @@ TEST(BoltSession, Goodbye) { ExecuteHandshake(input_stream, session, output, v4::handshake_req, v4::handshake_resp); ExecuteInit(input_stream, session, output, true); ASSERT_THROW(ExecuteCommand(input_stream, session, v4::goodbye, sizeof(v4::goodbye)), - communication::SessionClosedException); + memgraph::communication::SessionClosedException); } // v1 does not support goodbye message diff --git a/tests/unit/commit_log_v2.cpp b/tests/unit/commit_log_v2.cpp index a0a247d3a..6963f5a36 100644 --- a/tests/unit/commit_log_v2.cpp +++ b/tests/unit/commit_log_v2.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ constexpr size_t ids_per_block = 8192 * 64; } // namespace TEST(CommitLog, Simple) { - storage::CommitLog log; + memgraph::storage::CommitLog log; EXPECT_EQ(log.OldestActive(), 0); log.MarkFinished(1); @@ -29,7 +29,7 @@ TEST(CommitLog, Simple) { } TEST(CommitLog, Fields) { - storage::CommitLog log; + memgraph::storage::CommitLog log; for (uint64_t i = 0; i < 64; ++i) { log.MarkFinished(i); @@ -48,7 +48,7 @@ TEST(CommitLog, Fields) { } TEST(CommitLog, Blocks) { - storage::CommitLog log; + memgraph::storage::CommitLog log; for (uint64_t i = 0; i < ids_per_block; ++i) { log.MarkFinished(i); @@ -75,7 +75,7 @@ TEST(CommitLog, TrackAfterInitialId) { }; for (uint64_t i = 0; i < 2 * ids_per_block; ++i) { - storage::CommitLog log{i}; + memgraph::storage::CommitLog log{i}; check_marking_ids(&log, i); } } diff --git a/tests/unit/communication_buffer.cpp b/tests/unit/communication_buffer.cpp index 37023fd10..5bfeb7c0b 100644 --- a/tests/unit/communication_buffer.cpp +++ b/tests/unit/communication_buffer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ constexpr const int SIZE = 4096; uint8_t data[SIZE]; -using communication::Buffer; +using memgraph::communication::Buffer; struct CommunicationBuffer : ::testing::Test { // In newer gtest library (1.8.1+) this is changed to SetUpTestSuite diff --git a/tests/unit/cypher_main_visitor.cpp b/tests/unit/cypher_main_visitor.cpp index c8834a262..b3473fc2d 100644 --- a/tests/unit/cypher_main_visitor.cpp +++ b/tests/unit/cypher_main_visitor.cpp @@ -45,9 +45,9 @@ #include "utils/string.hpp" #include "utils/variant_helpers.hpp" -using namespace query; -using namespace query::frontend; -using query::TypedValue; +using namespace memgraph::query; +using namespace memgraph::query::frontend; +using memgraph::query::TypedValue; using testing::ElementsAre; using testing::Pair; using testing::UnorderedElementsAre; @@ -246,14 +246,14 @@ class CypherMainVisitorTest : public ::testing::TestWithParam &args, const std::vector &results, const ProcedureType type) { - utils::MemoryResource *memory = utils::NewDeleteResource(); + memgraph::utils::MemoryResource *memory = memgraph::utils::NewDeleteResource(); const bool is_write = type == ProcedureType::WRITE; mgp_proc proc(name, DummyProcCallback, memory, {.is_write = is_write}); for (const auto arg : args) { - proc.args.emplace_back(utils::pmr::string{arg, memory}, &any_type); + proc.args.emplace_back(memgraph::utils::pmr::string{arg, memory}, &any_type); } for (const auto result : results) { - proc.results.emplace(utils::pmr::string{result, memory}, std::make_pair(&any_type, false)); + proc.results.emplace(memgraph::utils::pmr::string{result, memory}, std::make_pair(&any_type, false)); } module.procedures.emplace(name, std::move(proc)); } @@ -3461,7 +3461,8 @@ TEST_P(CypherMainVisitorTest, ShowTriggers) { namespace { void ValidateCreateQuery(Base &ast_generator, const auto &query, const auto &trigger_name, - const query::TriggerQuery::EventType event_type, const auto &phase, const auto &statement) { + const memgraph::query::TriggerQuery::EventType event_type, const auto &phase, + const auto &statement) { auto *parsed_query = dynamic_cast(ast_generator.ParseQuery(query)); EXPECT_EQ(parsed_query->action_, TriggerQuery::Action::CREATE_TRIGGER); EXPECT_EQ(parsed_query->trigger_name_, trigger_name); @@ -3502,16 +3503,16 @@ TEST_P(CypherMainVisitorTest, CreateTriggers) { constexpr std::string_view query_template = "CREATE TRIGGER trigger {} {} COMMIT EXECUTE {}"; - constexpr std::array events{std::pair{"", query::TriggerQuery::EventType::ANY}, - std::pair{"ON CREATE", query::TriggerQuery::EventType::CREATE}, - std::pair{"ON () CREATE", query::TriggerQuery::EventType::VERTEX_CREATE}, - std::pair{"ON --> CREATE", query::TriggerQuery::EventType::EDGE_CREATE}, - std::pair{"ON DELETE", query::TriggerQuery::EventType::DELETE}, - std::pair{"ON () DELETE", query::TriggerQuery::EventType::VERTEX_DELETE}, - std::pair{"ON --> DELETE", query::TriggerQuery::EventType::EDGE_DELETE}, - std::pair{"ON UPDATE", query::TriggerQuery::EventType::UPDATE}, - std::pair{"ON () UPDATE", query::TriggerQuery::EventType::VERTEX_UPDATE}, - std::pair{"ON --> UPDATE", query::TriggerQuery::EventType::EDGE_UPDATE}}; + constexpr std::array events{std::pair{"", memgraph::query::TriggerQuery::EventType::ANY}, + std::pair{"ON CREATE", memgraph::query::TriggerQuery::EventType::CREATE}, + std::pair{"ON () CREATE", memgraph::query::TriggerQuery::EventType::VERTEX_CREATE}, + std::pair{"ON --> CREATE", memgraph::query::TriggerQuery::EventType::EDGE_CREATE}, + std::pair{"ON DELETE", memgraph::query::TriggerQuery::EventType::DELETE}, + std::pair{"ON () DELETE", memgraph::query::TriggerQuery::EventType::VERTEX_DELETE}, + std::pair{"ON --> DELETE", memgraph::query::TriggerQuery::EventType::EDGE_DELETE}, + std::pair{"ON UPDATE", memgraph::query::TriggerQuery::EventType::UPDATE}, + std::pair{"ON () UPDATE", memgraph::query::TriggerQuery::EventType::VERTEX_UPDATE}, + std::pair{"ON --> UPDATE", memgraph::query::TriggerQuery::EventType::EDGE_UPDATE}}; constexpr std::array phases{"BEFORE", "AFTER"}; @@ -3524,7 +3525,7 @@ TEST_P(CypherMainVisitorTest, CreateTriggers) { for (const auto &phase : phases) { for (const auto &statement : statements) { ValidateCreateQuery(ast_generator, fmt::format(query_template, event_string, phase, statement), "trigger", - event_type, phase, utils::Trim(statement)); + event_type, phase, memgraph::utils::Trim(statement)); } } } @@ -3552,13 +3553,13 @@ TEST_P(CypherMainVisitorTest, SetIsolationLevelQuery) { TestInvalidQuery("SET GLOBAL TRANSACTION ISOLATION LEVEL READ_COMITTED", ast_generator); TestInvalidQuery("SET SESSION TRANSACTION ISOLATION LEVEL READCOMITTED", ast_generator); - constexpr std::array scopes{std::pair{"GLOBAL", query::IsolationLevelQuery::IsolationLevelScope::GLOBAL}, - std::pair{"SESSION", query::IsolationLevelQuery::IsolationLevelScope::SESSION}, - std::pair{"NEXT", query::IsolationLevelQuery::IsolationLevelScope::NEXT}}; + constexpr std::array scopes{std::pair{"GLOBAL", memgraph::query::IsolationLevelQuery::IsolationLevelScope::GLOBAL}, + std::pair{"SESSION", memgraph::query::IsolationLevelQuery::IsolationLevelScope::SESSION}, + std::pair{"NEXT", memgraph::query::IsolationLevelQuery::IsolationLevelScope::NEXT}}; constexpr std::array isolation_levels{ - std::pair{"READ UNCOMMITTED", query::IsolationLevelQuery::IsolationLevel::READ_UNCOMMITTED}, - std::pair{"READ COMMITTED", query::IsolationLevelQuery::IsolationLevel::READ_COMMITTED}, - std::pair{"SNAPSHOT ISOLATION", query::IsolationLevelQuery::IsolationLevel::SNAPSHOT_ISOLATION}}; + std::pair{"READ UNCOMMITTED", memgraph::query::IsolationLevelQuery::IsolationLevel::READ_UNCOMMITTED}, + std::pair{"READ COMMITTED", memgraph::query::IsolationLevelQuery::IsolationLevel::READ_COMMITTED}, + std::pair{"SNAPSHOT ISOLATION", memgraph::query::IsolationLevelQuery::IsolationLevel::SNAPSHOT_ISOLATION}}; constexpr const auto *query_template = "SET {} TRANSACTION ISOLATION LEVEL {}"; @@ -3673,9 +3674,9 @@ TEST_P(CypherMainVisitorTest, StopAllStreams) { void ValidateTopicNames(const auto &topic_names, const std::vector &expected_topic_names, Base &ast_generator) { - std::visit(utils::Overloaded{ + std::visit(memgraph::utils::Overloaded{ [&](Expression *expression) { - ast_generator.CheckLiteral(expression, utils::Join(expected_topic_names, ",")); + ast_generator.CheckLiteral(expression, memgraph::utils::Join(expected_topic_names, ",")); }, [&](const std::vector &topic_names) { EXPECT_EQ(topic_names, expected_topic_names); }}, topic_names); @@ -3774,7 +3775,7 @@ TEST_P(CypherMainVisitorTest, CreateKafkaStream) { constexpr int kBatchSize = 1; const TypedValue batch_size_value{kBatchSize}; - const auto topic_names_as_str = utils::Join(topic_names, ","); + const auto topic_names_as_str = memgraph::utils::Join(topic_names, ","); ValidateCreateKafkaStreamQuery( ast_generator, @@ -3956,7 +3957,7 @@ TEST_P(CypherMainVisitorTest, CreatePulsarStream) { ast_generator); const std::vector topic_names{"topic1", "topic2"}; - const std::string topic_names_str = utils::Join(topic_names, ","); + const std::string topic_names_str = memgraph::utils::Join(topic_names, ","); constexpr std::string_view kStreamName{"PulsarStream"}; constexpr std::string_view kTransformName{"boringTransformation"}; constexpr std::string_view kServiceUrl{"localhost"}; diff --git a/tests/unit/formatters.hpp b/tests/unit/formatters.hpp index ffe53dee5..a2c9df807 100644 --- a/tests/unit/formatters.hpp +++ b/tests/unit/formatters.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,21 +21,22 @@ /// Functions that convert types to a `std::string` representation of it. The /// `TAccessor` supplied must have the functions `NameToLabel`, `LabelToName`, /// `NameToProperty`, `PropertyToName`, `NameToEdgeType` and `EdgeTypeToName`. -/// For example, both `storage::Storage` and `storage::Storage::Accessor` will +/// For example, both `memgraph::storage::Storage` and `Storage::Accessor` will /// be apropriate. template -inline std::string ToString(const query::VertexAccessor &vertex, const TAccessor &acc) { +inline std::string ToString(const memgraph::query::VertexAccessor &vertex, const TAccessor &acc) { std::ostringstream os; os << "V("; - auto maybe_labels = vertex.Labels(storage::View::NEW); + auto maybe_labels = vertex.Labels(memgraph::storage::View::NEW); MG_ASSERT(maybe_labels.HasValue()); - utils::PrintIterable(os, *maybe_labels, ":", [&](auto &stream, auto label) { stream << acc.LabelToName(label); }); + memgraph::utils::PrintIterable(os, *maybe_labels, ":", + [&](auto &stream, auto label) { stream << acc.LabelToName(label); }); if (maybe_labels->size() > 0) os << " "; os << "{"; - auto maybe_properties = vertex.Properties(storage::View::NEW); + auto maybe_properties = vertex.Properties(memgraph::storage::View::NEW); MG_ASSERT(maybe_properties.HasValue()); - utils::PrintIterable(os, *maybe_properties, ", ", [&](auto &stream, const auto &pair) { + memgraph::utils::PrintIterable(os, *maybe_properties, ", ", [&](auto &stream, const auto &pair) { stream << acc.PropertyToName(pair.first) << ": " << pair.second; }); os << "})"; @@ -43,13 +44,13 @@ inline std::string ToString(const query::VertexAccessor &vertex, const TAccessor } template -inline std::string ToString(const query::EdgeAccessor &edge, const TAccessor &acc) { +inline std::string ToString(const memgraph::query::EdgeAccessor &edge, const TAccessor &acc) { std::ostringstream os; os << "E[" << acc.EdgeTypeToName(edge.EdgeType()); os << " {"; - auto maybe_properties = edge.Properties(storage::View::NEW); + auto maybe_properties = edge.Properties(memgraph::storage::View::NEW); MG_ASSERT(maybe_properties.HasValue()); - utils::PrintIterable(os, *maybe_properties, ", ", [&](auto &stream, const auto &pair) { + memgraph::utils::PrintIterable(os, *maybe_properties, ", ", [&](auto &stream, const auto &pair) { stream << acc.PropertyToName(pair.first) << ": " << pair.second; }); os << "}]"; @@ -57,7 +58,7 @@ inline std::string ToString(const query::EdgeAccessor &edge, const TAccessor &ac } template -inline std::string ToString(const query::Path &path, const TAccessor &acc) { +inline std::string ToString(const memgraph::query::Path &path, const TAccessor &acc) { std::ostringstream os; const auto &vertices = path.vertices(); const auto &edges = path.edges(); @@ -74,65 +75,65 @@ inline std::string ToString(const query::Path &path, const TAccessor &acc) { } // TODO(antonio2368): Define printing of dates -inline std::string ToString(const utils::Date) { return ""; } +inline std::string ToString(const memgraph::utils::Date) { return ""; } -inline std::string ToString(const utils::LocalTime) { return ""; } +inline std::string ToString(const memgraph::utils::LocalTime) { return ""; } -inline std::string ToString(const utils::LocalDateTime) { return ""; } +inline std::string ToString(const memgraph::utils::LocalDateTime) { return ""; } -inline std::string ToString(const utils::Duration) { return ""; } +inline std::string ToString(const memgraph::utils::Duration) { return ""; } template -inline std::string ToString(const query::TypedValue &value, const TAccessor &acc) { +inline std::string ToString(const memgraph::query::TypedValue &value, const TAccessor &acc) { std::ostringstream os; switch (value.type()) { - case query::TypedValue::Type::Null: + case memgraph::query::TypedValue::Type::Null: os << "null"; break; - case query::TypedValue::Type::Bool: + case memgraph::query::TypedValue::Type::Bool: os << (value.ValueBool() ? "true" : "false"); break; - case query::TypedValue::Type::Int: + case memgraph::query::TypedValue::Type::Int: os << value.ValueInt(); break; - case query::TypedValue::Type::Double: + case memgraph::query::TypedValue::Type::Double: os << value.ValueDouble(); break; - case query::TypedValue::Type::String: + case memgraph::query::TypedValue::Type::String: os << value.ValueString(); break; - case query::TypedValue::Type::List: + case memgraph::query::TypedValue::Type::List: os << "["; - utils::PrintIterable(os, value.ValueList(), ", ", - [&](auto &stream, const auto &item) { stream << ToString(item, acc); }); + memgraph::utils::PrintIterable(os, value.ValueList(), ", ", + [&](auto &stream, const auto &item) { stream << ToString(item, acc); }); os << "]"; break; - case query::TypedValue::Type::Map: + case memgraph::query::TypedValue::Type::Map: os << "{"; - utils::PrintIterable(os, value.ValueMap(), ", ", [&](auto &stream, const auto &pair) { + memgraph::utils::PrintIterable(os, value.ValueMap(), ", ", [&](auto &stream, const auto &pair) { stream << pair.first << ": " << ToString(pair.second, acc); }); os << "}"; break; - case query::TypedValue::Type::Vertex: + case memgraph::query::TypedValue::Type::Vertex: os << ToString(value.ValueVertex(), acc); break; - case query::TypedValue::Type::Edge: + case memgraph::query::TypedValue::Type::Edge: os << ToString(value.ValueEdge(), acc); break; - case query::TypedValue::Type::Path: + case memgraph::query::TypedValue::Type::Path: os << ToString(value.ValuePath(), acc); break; - case query::TypedValue::Type::Date: + case memgraph::query::TypedValue::Type::Date: os << ToString(value.ValueDate()); break; - case query::TypedValue::Type::LocalTime: + case memgraph::query::TypedValue::Type::LocalTime: os << ToString(value.ValueLocalTime()); break; - case query::TypedValue::Type::LocalDateTime: + case memgraph::query::TypedValue::Type::LocalDateTime: os << ToString(value.ValueLocalDateTime()); break; - case query::TypedValue::Type::Duration: + case memgraph::query::TypedValue::Type::Duration: os << ToString(value.ValueDuration()); break; } diff --git a/tests/unit/integrations_kafka_consumer.cpp b/tests/unit/integrations_kafka_consumer.cpp index d598fefaa..203e50595 100644 --- a/tests/unit/integrations_kafka_consumer.cpp +++ b/tests/unit/integrations_kafka_consumer.cpp @@ -27,7 +27,7 @@ #include "kafka_mock.hpp" #include "utils/string.hpp" -using namespace integrations::kafka; +using namespace memgraph::integrations::kafka; namespace { const auto kDummyConsumerFunction = [](const auto & /*messages*/) {}; @@ -483,7 +483,7 @@ TEST_F(ConsumerTest, ConsumerStatus) { EXPECT_EQ(kConsumerGroupName, info.consumer_group); EXPECT_EQ(kBatchInterval, info.batch_interval); EXPECT_EQ(kBatchSize, info.batch_size); - EXPECT_EQ(2, info.topics.size()) << utils::Join(info.topics, ","); + EXPECT_EQ(2, info.topics.size()) << memgraph::utils::Join(info.topics, ","); ASSERT_LE(2, info.topics.size()); EXPECT_EQ(topics[0], info.topics[0]); EXPECT_EQ(topics[1], info.topics[1]); diff --git a/tests/unit/interpreter.cpp b/tests/unit/interpreter.cpp index 78ca82497..bbfdd61b1 100644 --- a/tests/unit/interpreter.cpp +++ b/tests/unit/interpreter.cpp @@ -32,8 +32,8 @@ namespace { -auto ToEdgeList(const communication::bolt::Value &v) { - std::vector list; +auto ToEdgeList(const memgraph::communication::bolt::Value &v) { + std::vector list; for (auto x : v.ValueList()) { list.push_back(x.ValueEdge()); } @@ -41,13 +41,13 @@ auto ToEdgeList(const communication::bolt::Value &v) { }; struct InterpreterFaker { - InterpreterFaker(storage::Storage *db, const query::InterpreterConfig config, + InterpreterFaker(memgraph::storage::Storage *db, const memgraph::query::InterpreterConfig config, const std::filesystem::path &data_directory) : interpreter_context(db, config, data_directory), interpreter(&interpreter_context) { interpreter_context.auth_checker = &auth_checker; } - auto Prepare(const std::string &query, const std::map ¶ms = {}) { + auto Prepare(const std::string &query, const std::map ¶ms = {}) { ResultStreamFaker stream(interpreter_context.db); const auto [header, _, qid] = interpreter.Prepare(query, params, nullptr); @@ -65,7 +65,7 @@ struct InterpreterFaker { * * Return the query stream. */ - auto Interpret(const std::string &query, const std::map ¶ms = {}) { + auto Interpret(const std::string &query, const std::map ¶ms = {}) { auto prepare_result = Prepare(query, params); auto &stream = prepare_result.first; @@ -75,9 +75,9 @@ struct InterpreterFaker { return std::move(stream); } - query::AllowEverythingAuthChecker auth_checker; - query::InterpreterContext interpreter_context; - query::Interpreter interpreter; + memgraph::query::AllowEverythingAuthChecker auth_checker; + memgraph::query::InterpreterContext interpreter_context; + memgraph::query::Interpreter interpreter; }; } // namespace @@ -87,12 +87,12 @@ struct InterpreterFaker { class InterpreterTest : public ::testing::Test { protected: - storage::Storage db_; + memgraph::storage::Storage db_; std::filesystem::path data_directory{std::filesystem::temp_directory_path() / "MG_tests_unit_interpreter"}; InterpreterFaker default_interpreter{&db_, {}, data_directory}; - auto Prepare(const std::string &query, const std::map ¶ms = {}) { + auto Prepare(const std::string &query, const std::map ¶ms = {}) { return default_interpreter.Prepare(query, params); } @@ -100,7 +100,7 @@ class InterpreterTest : public ::testing::Test { default_interpreter.Pull(stream, n, qid); } - auto Interpret(const std::string &query, const std::map ¶ms = {}) { + auto Interpret(const std::string &query, const std::map ¶ms = {}) { return default_interpreter.Interpret(query, params); } }; @@ -190,8 +190,8 @@ TEST_F(InterpreterTest, AstCache) { // Run query with same ast multiple times with different parameters. TEST_F(InterpreterTest, Parameters) { { - auto stream = - Interpret("RETURN $2 + $`a b`", {{"2", storage::PropertyValue(10)}, {"a b", storage::PropertyValue(15)}}); + auto stream = Interpret("RETURN $2 + $`a b`", {{"2", memgraph::storage::PropertyValue(10)}, + {"a b", memgraph::storage::PropertyValue(15)}}); ASSERT_EQ(stream.GetHeader().size(), 1U); EXPECT_EQ(stream.GetHeader()[0], "$2 + $`a b`"); ASSERT_EQ(stream.GetResults().size(), 1U); @@ -200,9 +200,9 @@ TEST_F(InterpreterTest, Parameters) { } { // Not needed parameter. - auto stream = Interpret( - "RETURN $2 + $`a b`", - {{"2", storage::PropertyValue(10)}, {"a b", storage::PropertyValue(15)}, {"c", storage::PropertyValue(10)}}); + auto stream = Interpret("RETURN $2 + $`a b`", {{"2", memgraph::storage::PropertyValue(10)}, + {"a b", memgraph::storage::PropertyValue(15)}, + {"c", memgraph::storage::PropertyValue(10)}}); ASSERT_EQ(stream.GetHeader().size(), 1U); EXPECT_EQ(stream.GetHeader()[0], "$2 + $`a b`"); ASSERT_EQ(stream.GetResults().size(), 1U); @@ -211,38 +211,39 @@ TEST_F(InterpreterTest, Parameters) { } { // Cached ast, different parameters. - auto stream = - Interpret("RETURN $2 + $`a b`", {{"2", storage::PropertyValue("da")}, {"a b", storage::PropertyValue("ne")}}); + auto stream = Interpret("RETURN $2 + $`a b`", {{"2", memgraph::storage::PropertyValue("da")}, + {"a b", memgraph::storage::PropertyValue("ne")}}); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); ASSERT_EQ(stream.GetResults()[0][0].ValueString(), "dane"); } { // Non-primitive literal. - auto stream = Interpret( - "RETURN $2", {{"2", storage::PropertyValue(std::vector{ - storage::PropertyValue(5), storage::PropertyValue(2), storage::PropertyValue(3)})}}); + auto stream = + Interpret("RETURN $2", {{"2", memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(5), memgraph::storage::PropertyValue(2), + memgraph::storage::PropertyValue(3)})}}); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - auto result = query::test_common::ToIntList(glue::ToTypedValue(stream.GetResults()[0][0])); + auto result = memgraph::query::test_common::ToIntList(memgraph::glue::ToTypedValue(stream.GetResults()[0][0])); ASSERT_THAT(result, testing::ElementsAre(5, 2, 3)); } { // Cached ast, unprovided parameter. - ASSERT_THROW( - Interpret("RETURN $2 + $`a b`", {{"2", storage::PropertyValue("da")}, {"ab", storage::PropertyValue("ne")}}), - query::UnprovidedParameterError); + ASSERT_THROW(Interpret("RETURN $2 + $`a b`", {{"2", memgraph::storage::PropertyValue("da")}, + {"ab", memgraph::storage::PropertyValue("ne")}}), + memgraph::query::UnprovidedParameterError); } } // Run CREATE/MATCH/MERGE queries with property map TEST_F(InterpreterTest, ParametersAsPropertyMap) { { - std::map property_map{}; - property_map["name"] = storage::PropertyValue("name1"); - property_map["age"] = storage::PropertyValue(25); + std::map property_map{}; + property_map["name"] = memgraph::storage::PropertyValue("name1"); + property_map["age"] = memgraph::storage::PropertyValue(25); auto stream = Interpret("CREATE (n $prop) RETURN n", { - {"prop", storage::PropertyValue(property_map)}, + {"prop", memgraph::storage::PropertyValue(property_map)}, }); ASSERT_EQ(stream.GetHeader().size(), 1U); ASSERT_EQ(stream.GetHeader()[0], "n"); @@ -253,14 +254,14 @@ TEST_F(InterpreterTest, ParametersAsPropertyMap) { EXPECT_EQ(result.properties["age"].ValueInt(), 25); } { - std::map property_map{}; - property_map["name"] = storage::PropertyValue("name1"); - property_map["age"] = storage::PropertyValue(25); + std::map property_map{}; + property_map["name"] = memgraph::storage::PropertyValue("name1"); + property_map["age"] = memgraph::storage::PropertyValue(25); Interpret("CREATE (:Person)"); - auto stream = - Interpret("MATCH (m: Person) CREATE (n $prop) RETURN n", { - {"prop", storage::PropertyValue(property_map)}, - }); + auto stream = Interpret("MATCH (m: Person) CREATE (n $prop) RETURN n", + { + {"prop", memgraph::storage::PropertyValue(property_map)}, + }); ASSERT_EQ(stream.GetHeader().size(), 1U); ASSERT_EQ(stream.GetHeader()[0], "n"); ASSERT_EQ(stream.GetResults().size(), 1U); @@ -270,12 +271,13 @@ TEST_F(InterpreterTest, ParametersAsPropertyMap) { EXPECT_EQ(result.properties["age"].ValueInt(), 25); } { - std::map property_map{}; - property_map["name"] = storage::PropertyValue("name1"); - property_map["weight"] = storage::PropertyValue(121); - auto stream = Interpret("CREATE ()-[r:TO $prop]->() RETURN r", { - {"prop", storage::PropertyValue(property_map)}, - }); + std::map property_map{}; + property_map["name"] = memgraph::storage::PropertyValue("name1"); + property_map["weight"] = memgraph::storage::PropertyValue(121); + auto stream = + Interpret("CREATE ()-[r:TO $prop]->() RETURN r", { + {"prop", memgraph::storage::PropertyValue(property_map)}, + }); ASSERT_EQ(stream.GetHeader().size(), 1U); ASSERT_EQ(stream.GetHeader()[0], "r"); ASSERT_EQ(stream.GetResults().size(), 1U); @@ -285,24 +287,24 @@ TEST_F(InterpreterTest, ParametersAsPropertyMap) { EXPECT_EQ(result.properties["weight"].ValueInt(), 121); } { - std::map property_map{}; - property_map["name"] = storage::PropertyValue("name1"); - property_map["age"] = storage::PropertyValue(15); + std::map property_map{}; + property_map["name"] = memgraph::storage::PropertyValue("name1"); + property_map["age"] = memgraph::storage::PropertyValue(15); ASSERT_THROW(Interpret("MATCH (n $prop) RETURN n", { - {"prop", storage::PropertyValue(property_map)}, + {"prop", memgraph::storage::PropertyValue(property_map)}, }), - query::SemanticException); + memgraph::query::SemanticException); } { - std::map property_map{}; - property_map["name"] = storage::PropertyValue("name1"); - property_map["age"] = storage::PropertyValue(15); + std::map property_map{}; + property_map["name"] = memgraph::storage::PropertyValue("name1"); + property_map["age"] = memgraph::storage::PropertyValue(15); ASSERT_THROW(Interpret("MERGE (n $prop) RETURN n", { - {"prop", storage::PropertyValue(property_map)}, + {"prop", memgraph::storage::PropertyValue(property_map)}, }), - query::SemanticException); + memgraph::query::SemanticException); } } @@ -317,24 +319,26 @@ TEST_F(InterpreterTest, Bfs) { const auto kReachable = "reachable"; const auto kId = "id"; - std::vector> levels(kNumLevels); + std::vector> levels(kNumLevels); int id = 0; // Set up. { auto storage_dba = db_.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto add_node = [&](int level, bool reachable) { auto node = dba.InsertVertex(); - MG_ASSERT(node.SetProperty(dba.NameToProperty(kId), storage::PropertyValue(id++)).HasValue()); - MG_ASSERT(node.SetProperty(dba.NameToProperty(kReachable), storage::PropertyValue(reachable)).HasValue()); + MG_ASSERT(node.SetProperty(dba.NameToProperty(kId), memgraph::storage::PropertyValue(id++)).HasValue()); + MG_ASSERT( + node.SetProperty(dba.NameToProperty(kReachable), memgraph::storage::PropertyValue(reachable)).HasValue()); levels[level].push_back(node); return node; }; auto add_edge = [&](auto &v1, auto &v2, bool reachable) { auto edge = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("edge")); - MG_ASSERT(edge->SetProperty(dba.NameToProperty(kReachable), storage::PropertyValue(reachable)).HasValue()); + MG_ASSERT( + edge->SetProperty(dba.NameToProperty(kReachable), memgraph::storage::PropertyValue(reachable)).HasValue()); }; // Add source node. @@ -478,44 +482,45 @@ TEST_F(InterpreterTest, ShortestPath) { TEST_F(InterpreterTest, CreateLabelIndexInMulticommandTransaction) { Interpret("BEGIN"); - ASSERT_THROW(Interpret("CREATE INDEX ON :X"), query::IndexInMulticommandTxException); + ASSERT_THROW(Interpret("CREATE INDEX ON :X"), memgraph::query::IndexInMulticommandTxException); Interpret("ROLLBACK"); } TEST_F(InterpreterTest, CreateLabelPropertyIndexInMulticommandTransaction) { Interpret("BEGIN"); - ASSERT_THROW(Interpret("CREATE INDEX ON :X(y)"), query::IndexInMulticommandTxException); + ASSERT_THROW(Interpret("CREATE INDEX ON :X(y)"), memgraph::query::IndexInMulticommandTxException); Interpret("ROLLBACK"); } TEST_F(InterpreterTest, CreateExistenceConstraintInMulticommandTransaction) { Interpret("BEGIN"); - ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT EXISTS (n.a)"), query::ConstraintInMulticommandTxException); + ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT EXISTS (n.a)"), + memgraph::query::ConstraintInMulticommandTxException); Interpret("ROLLBACK"); } TEST_F(InterpreterTest, CreateUniqueConstraintInMulticommandTransaction) { Interpret("BEGIN"); ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT n.a, n.b IS UNIQUE"), - query::ConstraintInMulticommandTxException); + memgraph::query::ConstraintInMulticommandTxException); Interpret("ROLLBACK"); } TEST_F(InterpreterTest, ShowIndexInfoInMulticommandTransaction) { Interpret("BEGIN"); - ASSERT_THROW(Interpret("SHOW INDEX INFO"), query::InfoInMulticommandTxException); + ASSERT_THROW(Interpret("SHOW INDEX INFO"), memgraph::query::InfoInMulticommandTxException); Interpret("ROLLBACK"); } TEST_F(InterpreterTest, ShowConstraintInfoInMulticommandTransaction) { Interpret("BEGIN"); - ASSERT_THROW(Interpret("SHOW CONSTRAINT INFO"), query::InfoInMulticommandTxException); + ASSERT_THROW(Interpret("SHOW CONSTRAINT INFO"), memgraph::query::InfoInMulticommandTxException); Interpret("ROLLBACK"); } TEST_F(InterpreterTest, ShowStorageInfoInMulticommandTransaction) { Interpret("BEGIN"); - ASSERT_THROW(Interpret("SHOW STORAGE INFO"), query::InfoInMulticommandTxException); + ASSERT_THROW(Interpret("SHOW STORAGE INFO"), memgraph::query::InfoInMulticommandTxException); Interpret("ROLLBACK"); } @@ -524,18 +529,18 @@ TEST_F(InterpreterTest, ExistenceConstraintTest) { Interpret("CREATE CONSTRAINT ON (n:A) ASSERT EXISTS (n.a);"); Interpret("CREATE (:A{a:1})"); Interpret("CREATE (:A{a:2})"); - ASSERT_THROW(Interpret("CREATE (:A)"), query::QueryException); + ASSERT_THROW(Interpret("CREATE (:A)"), memgraph::query::QueryException); Interpret("MATCH (n:A{a:2}) SET n.a=3"); Interpret("CREATE (:A{a:2})"); Interpret("MATCH (n:A{a:2}) DETACH DELETE n"); Interpret("CREATE (n:A{a:2})"); - ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT EXISTS (n.b);"), query::QueryRuntimeException); + ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT EXISTS (n.b);"), memgraph::query::QueryRuntimeException); } TEST_F(InterpreterTest, UniqueConstraintTest) { // Empty property list should result with syntax exception. - ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT IS UNIQUE;"), query::SyntaxException); - ASSERT_THROW(Interpret("DROP CONSTRAINT ON (n:A) ASSERT IS UNIQUE;"), query::SyntaxException); + ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT IS UNIQUE;"), memgraph::query::SyntaxException); + ASSERT_THROW(Interpret("DROP CONSTRAINT ON (n:A) ASSERT IS UNIQUE;"), memgraph::query::SyntaxException); // Too large list of properties should also result with syntax exception. { @@ -548,24 +553,26 @@ TEST_F(InterpreterTest, UniqueConstraintTest) { stream << " IS UNIQUE;"; std::string create_query = "CREATE CONSTRAINT" + stream.str(); std::string drop_query = "DROP CONSTRAINT" + stream.str(); - ASSERT_THROW(Interpret(create_query), query::SyntaxException); - ASSERT_THROW(Interpret(drop_query), query::SyntaxException); + ASSERT_THROW(Interpret(create_query), memgraph::query::SyntaxException); + ASSERT_THROW(Interpret(drop_query), memgraph::query::SyntaxException); } // Providing property list with duplicates results with syntax exception. - ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT n.a, n.b, n.a IS UNIQUE;"), query::SyntaxException); - ASSERT_THROW(Interpret("DROP CONSTRAINT ON (n:A) ASSERT n.a, n.b, n.a IS UNIQUE;"), query::SyntaxException); + ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT n.a, n.b, n.a IS UNIQUE;"), + memgraph::query::SyntaxException); + ASSERT_THROW(Interpret("DROP CONSTRAINT ON (n:A) ASSERT n.a, n.b, n.a IS UNIQUE;"), memgraph::query::SyntaxException); // Commit of vertex should fail if a constraint is violated. Interpret("CREATE CONSTRAINT ON (n:A) ASSERT n.a, n.b IS UNIQUE;"); Interpret("CREATE (:A{a:1, b:2})"); Interpret("CREATE (:A{a:1, b:3})"); - ASSERT_THROW(Interpret("CREATE (:A{a:1, b:2})"), query::QueryException); + ASSERT_THROW(Interpret("CREATE (:A{a:1, b:2})"), memgraph::query::QueryException); // Attempt to create a constraint should fail if it's violated. Interpret("CREATE (:A{a:1, c:2})"); Interpret("CREATE (:A{a:1, c:2})"); - ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT n.a, n.c IS UNIQUE;"), query::QueryRuntimeException); + ASSERT_THROW(Interpret("CREATE CONSTRAINT ON (n:A) ASSERT n.a, n.c IS UNIQUE;"), + memgraph::query::QueryRuntimeException); Interpret("MATCH (n:A{a:2, b:2}) SET n.a=1"); Interpret("CREATE (:A{a:2})"); @@ -689,7 +696,8 @@ TEST_F(InterpreterTest, ExplainQueryWithParams) { EXPECT_EQ(interpreter_context.plan_cache.size(), 0U); EXPECT_EQ(interpreter_context.ast_cache.size(), 0U); - auto stream = Interpret("EXPLAIN MATCH (n) WHERE n.id = $id RETURN *;", {{"id", storage::PropertyValue(42)}}); + auto stream = + Interpret("EXPLAIN MATCH (n) WHERE n.id = $id RETURN *;", {{"id", memgraph::storage::PropertyValue(42)}}); ASSERT_EQ(stream.GetHeader().size(), 1U); EXPECT_EQ(stream.GetHeader().front(), "QUERY PLAN"); std::vector expected_rows{" * Produce {n}", " * Filter", " * ScanAll (n)", " * Once"}; @@ -704,7 +712,7 @@ TEST_F(InterpreterTest, ExplainQueryWithParams) { EXPECT_EQ(interpreter_context.plan_cache.size(), 1U); // We should have AST cache for EXPLAIN ... and for inner MATCH ... EXPECT_EQ(interpreter_context.ast_cache.size(), 2U); - Interpret("MATCH (n) WHERE n.id = $id RETURN *;", {{"id", storage::PropertyValue("something else")}}); + Interpret("MATCH (n) WHERE n.id = $id RETURN *;", {{"id", memgraph::storage::PropertyValue("something else")}}); EXPECT_EQ(interpreter_context.plan_cache.size(), 1U); EXPECT_EQ(interpreter_context.ast_cache.size(), 2U); } @@ -774,7 +782,7 @@ TEST_F(InterpreterTest, ProfileQueryMultiplePulls) { TEST_F(InterpreterTest, ProfileQueryInMulticommandTransaction) { Interpret("BEGIN"); - ASSERT_THROW(Interpret("PROFILE MATCH (n) RETURN *;"), query::ProfileInMulticommandTxException); + ASSERT_THROW(Interpret("PROFILE MATCH (n) RETURN *;"), memgraph::query::ProfileInMulticommandTxException); Interpret("ROLLBACK"); } @@ -783,7 +791,8 @@ TEST_F(InterpreterTest, ProfileQueryWithParams) { EXPECT_EQ(interpreter_context.plan_cache.size(), 0U); EXPECT_EQ(interpreter_context.ast_cache.size(), 0U); - auto stream = Interpret("PROFILE MATCH (n) WHERE n.id = $id RETURN *;", {{"id", storage::PropertyValue(42)}}); + auto stream = + Interpret("PROFILE MATCH (n) WHERE n.id = $id RETURN *;", {{"id", memgraph::storage::PropertyValue(42)}}); std::vector expected_header{"OPERATOR", "ACTUAL HITS", "RELATIVE TIME", "ABSOLUTE TIME"}; EXPECT_EQ(stream.GetHeader(), expected_header); std::vector expected_rows{"* Produce", "* Filter", "* ScanAll", "* Once"}; @@ -798,7 +807,7 @@ TEST_F(InterpreterTest, ProfileQueryWithParams) { EXPECT_EQ(interpreter_context.plan_cache.size(), 1U); // We should have AST cache for PROFILE ... and for inner MATCH ... EXPECT_EQ(interpreter_context.ast_cache.size(), 2U); - Interpret("MATCH (n) WHERE n.id = $id RETURN *;", {{"id", storage::PropertyValue("something else")}}); + Interpret("MATCH (n) WHERE n.id = $id RETURN *;", {{"id", memgraph::storage::PropertyValue("something else")}}); EXPECT_EQ(interpreter_context.plan_cache.size(), 1U); EXPECT_EQ(interpreter_context.ast_cache.size(), 2U); } @@ -831,10 +840,10 @@ TEST_F(InterpreterTest, ProfileQueryWithLiterals) { TEST_F(InterpreterTest, Transactions) { auto &interpreter = default_interpreter.interpreter; { - ASSERT_THROW(interpreter.CommitTransaction(), query::ExplicitTransactionUsageException); - ASSERT_THROW(interpreter.RollbackTransaction(), query::ExplicitTransactionUsageException); + ASSERT_THROW(interpreter.CommitTransaction(), memgraph::query::ExplicitTransactionUsageException); + ASSERT_THROW(interpreter.RollbackTransaction(), memgraph::query::ExplicitTransactionUsageException); interpreter.BeginTransaction(); - ASSERT_THROW(interpreter.BeginTransaction(), query::ExplicitTransactionUsageException); + ASSERT_THROW(interpreter.BeginTransaction(), memgraph::query::ExplicitTransactionUsageException); auto [stream, qid] = Prepare("RETURN 2"); ASSERT_EQ(stream.GetHeader().size(), 1U); EXPECT_EQ(stream.GetHeader()[0], "2"); @@ -865,7 +874,7 @@ TEST_F(InterpreterTest, Qid) { interpreter.BeginTransaction(); auto [stream, qid] = Prepare("RETURN 2"); ASSERT_TRUE(qid); - ASSERT_THROW(Pull(&stream, {}, *qid + 1), query::InvalidArgumentsException); + ASSERT_THROW(Pull(&stream, {}, *qid + 1), memgraph::query::InvalidArgumentsException); interpreter.RollbackTransaction(); } { @@ -983,7 +992,7 @@ class FileWriter { }; std::string CreateRow(const std::vector &columns, const std::string_view delim) { - return utils::Join(columns, delim); + return memgraph::utils::Join(columns, delim); } } // namespace @@ -1085,7 +1094,7 @@ TEST_F(InterpreterTest, AllowLoadCsvConfig) { ASSERT_NO_THROW(interpreter_faker.Interpret(query)); } else { SCOPED_TRACE(fmt::format("'{}' should throw becuase LOAD CSV is not allowed", query)); - ASSERT_THROW(interpreter_faker.Interpret(query), utils::BasicException); + ASSERT_THROW(interpreter_faker.Interpret(query), memgraph::utils::BasicException); } SCOPED_TRACE(fmt::format("Normal query should not throw (allow_load_csv: {})", allow_load_csv)); ASSERT_NO_THROW(interpreter_faker.Interpret("RETURN 1")); @@ -1096,7 +1105,7 @@ TEST_F(InterpreterTest, AllowLoadCsvConfig) { check_load_csv_queries(false); } -void AssertAllValuesAreZero(const std::map &map, +void AssertAllValuesAreZero(const std::map &map, const std::vector &exceptions) { for (const auto &[key, value] : map) { if (const auto it = std::find(exceptions.begin(), exceptions.end(), key); it != exceptions.end()) continue; diff --git a/tests/unit/kvstore.cpp b/tests/unit/kvstore.cpp index f593ece2b..8af05e482 100644 --- a/tests/unit/kvstore.cpp +++ b/tests/unit/kvstore.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,7 +20,7 @@ namespace fs = std::filesystem; class KVStore : public ::testing::Test { protected: - virtual void SetUp() { utils::EnsureDir(test_folder_); } + virtual void SetUp() { memgraph::utils::EnsureDir(test_folder_); } virtual void TearDown() { fs::remove_all(test_folder_); } @@ -29,20 +29,20 @@ class KVStore : public ::testing::Test { }; TEST_F(KVStore, PutGet) { - kvstore::KVStore kvstore(test_folder_ / "PutGet"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "PutGet"); ASSERT_TRUE(kvstore.Put("key", "value")); ASSERT_EQ(kvstore.Get("key").value(), "value"); } TEST_F(KVStore, PutMultipleGet) { - kvstore::KVStore kvstore(test_folder_ / "PutMultipleGet"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "PutMultipleGet"); ASSERT_TRUE(kvstore.PutMultiple({{"key1", "value1"}, {"key2", "value2"}})); ASSERT_EQ(kvstore.Get("key1").value(), "value1"); ASSERT_EQ(kvstore.Get("key2").value(), "value2"); } TEST_F(KVStore, PutGetDeleteGet) { - kvstore::KVStore kvstore(test_folder_ / "PutGetDeleteGet"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "PutGetDeleteGet"); ASSERT_TRUE(kvstore.Put("key", "value")); ASSERT_EQ(kvstore.Get("key").value(), "value"); ASSERT_TRUE(kvstore.Delete("key")); @@ -50,7 +50,7 @@ TEST_F(KVStore, PutGetDeleteGet) { } TEST_F(KVStore, PutMultipleGetDeleteMultipleGet) { - kvstore::KVStore kvstore(test_folder_ / "PutMultipleGetDeleteMultipleGet"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "PutMultipleGetDeleteMultipleGet"); ASSERT_TRUE(kvstore.PutMultiple({{"key1", "value1"}, {"key2", "value2"}})); ASSERT_EQ(kvstore.Get("key1").value(), "value1"); ASSERT_EQ(kvstore.Get("key2").value(), "value2"); @@ -61,7 +61,7 @@ TEST_F(KVStore, PutMultipleGetDeleteMultipleGet) { } TEST_F(KVStore, PutMultipleGetPutAndDeleteMultipleGet) { - kvstore::KVStore kvstore(test_folder_ / "PutMultipleGetPutAndDeleteMultipleGet"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "PutMultipleGetPutAndDeleteMultipleGet"); ASSERT_TRUE(kvstore.PutMultiple({{"key1", "value1"}, {"key2", "value2"}})); ASSERT_EQ(kvstore.Get("key1").value(), "value1"); ASSERT_EQ(kvstore.Get("key2").value(), "value2"); @@ -73,17 +73,17 @@ TEST_F(KVStore, PutMultipleGetPutAndDeleteMultipleGet) { TEST_F(KVStore, Durability) { { - kvstore::KVStore kvstore(test_folder_ / "Durability"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "Durability"); ASSERT_TRUE(kvstore.Put("key", "value")); } { - kvstore::KVStore kvstore(test_folder_ / "Durability"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "Durability"); ASSERT_EQ(kvstore.Get("key").value(), "value"); } } TEST_F(KVStore, Size) { - kvstore::KVStore kvstore(test_folder_ / "Size"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "Size"); ASSERT_TRUE(kvstore.Put("prefix_1", "jedan")); ASSERT_TRUE(kvstore.Put("prefix_2", "dva")); @@ -113,7 +113,7 @@ TEST_F(KVStore, Size) { } TEST_F(KVStore, DeletePrefix) { - kvstore::KVStore kvstore(test_folder_ / "DeletePrefix"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "DeletePrefix"); ASSERT_TRUE(kvstore.Put("prefix_1", "jedan")); ASSERT_TRUE(kvstore.Put("prefix_2", "dva")); @@ -151,7 +151,7 @@ TEST_F(KVStore, DeletePrefix) { } TEST_F(KVStore, Iterator) { - kvstore::KVStore kvstore(test_folder_ / "Iterator"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "Iterator"); for (int i = 1; i <= 4; ++i) ASSERT_TRUE(kvstore.Put("key" + std::to_string(i), "value" + std::to_string(i))); @@ -180,7 +180,7 @@ TEST_F(KVStore, Iterator) { } TEST_F(KVStore, IteratorPrefix) { - kvstore::KVStore kvstore(test_folder_ / "Iterator"); + memgraph::kvstore::KVStore kvstore(test_folder_ / "Iterator"); ASSERT_TRUE(kvstore.Put("a_1", "value1")); ASSERT_TRUE(kvstore.Put("a_2", "value2")); diff --git a/tests/unit/main.cpp b/tests/unit/main.cpp index dcbf5f8aa..88d266b24 100644 --- a/tests/unit/main.cpp +++ b/tests/unit/main.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); - logging::RedirectToStderr(); + memgraph::logging::RedirectToStderr(); spdlog::set_level(spdlog::level::trace); return RUN_ALL_TESTS(); } diff --git a/tests/unit/mgp_kafka_c_api.cpp b/tests/unit/mgp_kafka_c_api.cpp index ee3a1a00b..91218dc75 100644 --- a/tests/unit/mgp_kafka_c_api.cpp +++ b/tests/unit/mgp_kafka_c_api.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -109,7 +109,7 @@ std::string MockedRdKafkaMessage::mocked_topic_name = "Topic1"; class MgpApiTest : public ::testing::Test { public: - using Message = integrations::kafka::Message; + using Message = memgraph::integrations::kafka::Message; using KafkaMessage = MockedRdKafkaMessage; MgpApiTest() { messages_.emplace(CreateMockedBatch()); } @@ -130,20 +130,20 @@ class MgpApiTest : public ::testing::Test { ExpectedResult{"payload2", '2', "Topic1", 8, 1}}; private: - utils::pmr::vector CreateMockedBatch() { + memgraph::utils::pmr::vector CreateMockedBatch() { std::transform( expected.begin(), expected.end(), std::back_inserter(msgs_storage_), [i = int64_t(0)](const auto expected) mutable { return Message(std::make_unique(std::string(1, expected.key), expected.payload, i++)); }); - auto v = utils::pmr::vector(utils::NewDeleteResource()); + auto v = memgraph::utils::pmr::vector(memgraph::utils::NewDeleteResource()); v.reserve(expected.size()); std::transform(msgs_storage_.begin(), msgs_storage_.end(), std::back_inserter(v), [](auto &msgs) { return mgp_message{msgs}; }); return v; } - utils::pmr::vector msgs_storage_{utils::NewDeleteResource()}; + memgraph::utils::pmr::vector msgs_storage_{memgraph::utils::NewDeleteResource()}; std::optional messages_; }; diff --git a/tests/unit/mgp_trans_c_api.cpp b/tests/unit/mgp_trans_c_api.cpp index cf97e09ce..b97bfc243 100644 --- a/tests/unit/mgp_trans_c_api.cpp +++ b/tests/unit/mgp_trans_c_api.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ TEST(MgpTransTest, TestMgpTransApi) { constexpr auto no_op_cb = [](mgp_messages *msg, mgp_graph *graph, mgp_result *result, mgp_memory *memory) {}; - mgp_module module(utils::NewDeleteResource()); + mgp_module module(memgraph::utils::NewDeleteResource()); // If this is false, then mgp_module_add_transformation() // correctly calls IsValidIdentifier(). We don't need to test // for different string cases as these are all handled by diff --git a/tests/unit/network_endpoint.cpp b/tests/unit/network_endpoint.cpp index 7e231cb4c..d9dcc67e8 100644 --- a/tests/unit/network_endpoint.cpp +++ b/tests/unit/network_endpoint.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "io/network/network_error.hpp" #include "utils/logging.hpp" -using endpoint_t = io::network::Endpoint; +using endpoint_t = memgraph::io::network::Endpoint; TEST(Endpoint, IPv4) { endpoint_t endpoint; @@ -27,7 +27,7 @@ TEST(Endpoint, IPv4) { EXPECT_EQ(endpoint.family, endpoint_t::IpFamily::IP4); // test address invalid - EXPECT_THROW(endpoint_t("invalid", 12345), io::network::NetworkError); + EXPECT_THROW(endpoint_t("invalid", 12345), memgraph::io::network::NetworkError); } TEST(Endpoint, IPv6) { @@ -40,5 +40,5 @@ TEST(Endpoint, IPv6) { EXPECT_EQ(endpoint.family, endpoint_t::IpFamily::IP6); // test address invalid - EXPECT_THROW(endpoint_t("::g", 12345), io::network::NetworkError); + EXPECT_THROW(endpoint_t("::g", 12345), memgraph::io::network::NetworkError); } diff --git a/tests/unit/network_timeouts.cpp b/tests/unit/network_timeouts.cpp index 620d0cffa..b7c4618df 100644 --- a/tests/unit/network_timeouts.cpp +++ b/tests/unit/network_timeouts.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -25,8 +25,8 @@ class TestData {}; class TestSession { public: - TestSession(TestData *, const io::network::Endpoint &, communication::InputStream *input_stream, - communication::OutputStream *output_stream) + TestSession(TestData *, const memgraph::io::network::Endpoint &, memgraph::communication::InputStream *input_stream, + memgraph::communication::OutputStream *output_stream) : input_stream_(input_stream), output_stream_(output_stream) {} void Execute() { @@ -40,14 +40,14 @@ class TestSession { } private: - communication::InputStream *input_stream_; - communication::OutputStream *output_stream_; + memgraph::communication::InputStream *input_stream_; + memgraph::communication::OutputStream *output_stream_; }; const std::string safe_query("tttt"); const std::string expensive_query("eeee"); -bool QueryServer(io::network::Socket &socket, const std::string &query) { +bool QueryServer(memgraph::io::network::Socket &socket, const std::string &query) { if (!socket.Write(query)) return false; char response[105]; int len = 0; @@ -64,12 +64,12 @@ bool QueryServer(io::network::Socket &socket, const std::string &query) { TEST(NetworkTimeouts, InactiveSession) { // Instantiate the server and set the session timeout to 2 seconds. TestData test_data; - communication::ServerContext context; - communication::Server server{{"127.0.0.1", 0}, &test_data, &context, 2, "Test", 1}; + memgraph::communication::ServerContext context; + memgraph::communication::Server server{{"127.0.0.1", 0}, &test_data, &context, 2, "Test", 1}; ASSERT_TRUE(server.Start()); // Create the client and connect to the server. - io::network::Socket client; + memgraph::io::network::Socket client; ASSERT_TRUE(client.Connect(server.endpoint())); // Send some data to the server. @@ -95,12 +95,12 @@ TEST(NetworkTimeouts, InactiveSession) { TEST(NetworkTimeouts, ActiveSession) { // Instantiate the server and set the session timeout to 2 seconds. TestData test_data; - communication::ServerContext context; - communication::Server server{{"127.0.0.1", 0}, &test_data, &context, 2, "Test", 1}; + memgraph::communication::ServerContext context; + memgraph::communication::Server server{{"127.0.0.1", 0}, &test_data, &context, 2, "Test", 1}; ASSERT_TRUE(server.Start()); // Create the client and connect to the server. - io::network::Socket client; + memgraph::io::network::Socket client; ASSERT_TRUE(client.Connect(server.endpoint())); // Send some data to the server. diff --git a/tests/unit/network_utils.cpp b/tests/unit/network_utils.cpp index 91a6945a4..7a32f2eb8 100644 --- a/tests/unit/network_utils.cpp +++ b/tests/unit/network_utils.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,7 +14,7 @@ #include "io/network/utils.hpp" -using namespace io::network; +using namespace memgraph::io::network; TEST(ResolveHostname, Simple) { auto result = ResolveHostname("localhost"); diff --git a/tests/unit/plan_pretty_print.cpp b/tests/unit/plan_pretty_print.cpp index 4c88a7cda..4444bd653 100644 --- a/tests/unit/plan_pretty_print.cpp +++ b/tests/unit/plan_pretty_print.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,8 +17,8 @@ #include "query_common.hpp" -using namespace query; -using namespace query::plan; +using namespace memgraph::query; +using namespace memgraph::query::plan; // The JSON formatted plan is consumed (or will be) by Memgraph Lab, and // therefore should not be changed before synchronizing with whoever is @@ -39,13 +39,13 @@ class PrintToJsonTest : public ::testing::Test { AstStorage storage; SymbolTable symbol_table; - storage::Storage db; - storage::Storage::Accessor dba; + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor dba; Symbol GetSymbol(std::string name) { return symbol_table.CreateSymbol(name, true); } void Check(LogicalOperator *root, std::string expected) { - query::DbAccessor query_dba(&dba); + memgraph::query::DbAccessor query_dba(&dba); EXPECT_EQ(PlanToJson(query_dba, root), json::parse(expected)); } }; @@ -90,7 +90,8 @@ TEST_F(PrintToJsonTest, ScanAllByLabelPropertyRange) { std::shared_ptr last_op; last_op = std::make_shared( nullptr, GetSymbol("node"), dba.NameToLabel("Label"), dba.NameToProperty("prop"), "prop", - utils::MakeBoundInclusive(LITERAL(1)), utils::MakeBoundExclusive(LITERAL(20))); + memgraph::utils::MakeBoundInclusive(LITERAL(1)), + memgraph::utils::MakeBoundExclusive(LITERAL(20))); Check(last_op.get(), R"( { @@ -111,9 +112,9 @@ TEST_F(PrintToJsonTest, ScanAllByLabelPropertyRange) { } { std::shared_ptr last_op; - last_op = std::make_shared(nullptr, GetSymbol("node"), dba.NameToLabel("Label"), - dba.NameToProperty("prop"), "prop", std::nullopt, - utils::MakeBoundExclusive(LITERAL(20))); + last_op = std::make_shared( + nullptr, GetSymbol("node"), dba.NameToLabel("Label"), dba.NameToProperty("prop"), "prop", std::nullopt, + memgraph::utils::MakeBoundExclusive(LITERAL(20))); Check(last_op.get(), R"( { @@ -133,7 +134,7 @@ TEST_F(PrintToJsonTest, ScanAllByLabelPropertyRange) { std::shared_ptr last_op; last_op = std::make_shared( nullptr, GetSymbol("node"), dba.NameToLabel("Label"), dba.NameToProperty("prop"), "prop", - utils::MakeBoundInclusive(LITERAL(1)), std::nullopt); + memgraph::utils::MakeBoundInclusive(LITERAL(1)), std::nullopt); Check(last_op.get(), R"( { @@ -239,8 +240,8 @@ TEST_F(PrintToJsonTest, Expand) { std::shared_ptr last_op = std::make_shared(nullptr, node1_sym); last_op = std::make_shared( last_op, node1_sym, GetSymbol("node2"), GetSymbol("edge"), EdgeAtom::Direction::BOTH, - std::vector{dba.NameToEdgeType("EdgeType1"), dba.NameToEdgeType("EdgeType2")}, false, - storage::View::OLD); + std::vector{dba.NameToEdgeType("EdgeType1"), dba.NameToEdgeType("EdgeType2")}, + false, memgraph::storage::View::OLD); Check(last_op.get(), R"( { @@ -265,8 +266,8 @@ TEST_F(PrintToJsonTest, ExpandVariable) { last_op = std::make_shared( last_op, node1_sym, GetSymbol("node2"), GetSymbol("edge"), EdgeAtom::Type::BREADTH_FIRST, EdgeAtom::Direction::OUT, - std::vector{dba.NameToEdgeType("EdgeType1"), dba.NameToEdgeType("EdgeType2")}, false, - LITERAL(2), LITERAL(5), false, + std::vector{dba.NameToEdgeType("EdgeType1"), dba.NameToEdgeType("EdgeType2")}, + false, LITERAL(2), LITERAL(5), false, ExpansionLambda{GetSymbol("inner_node"), GetSymbol("inner_edge"), PROPERTY_LOOKUP("inner_node", dba.NameToProperty("unblocked"))}, std::nullopt, std::nullopt); @@ -299,8 +300,8 @@ TEST_F(PrintToJsonTest, ExpandVariableWsp) { last_op = std::make_shared( last_op, node1_sym, GetSymbol("node2"), GetSymbol("edge"), EdgeAtom::Type::WEIGHTED_SHORTEST_PATH, EdgeAtom::Direction::OUT, - std::vector{dba.NameToEdgeType("EdgeType1"), dba.NameToEdgeType("EdgeType2")}, false, - LITERAL(2), LITERAL(5), false, ExpansionLambda{GetSymbol("inner_node"), GetSymbol("inner_edge"), nullptr}, + std::vector{dba.NameToEdgeType("EdgeType1"), dba.NameToEdgeType("EdgeType2")}, + false, LITERAL(2), LITERAL(5), false, ExpansionLambda{GetSymbol("inner_node"), GetSymbol("inner_edge"), nullptr}, ExpansionLambda{GetSymbol("inner_node"), GetSymbol("inner_edge"), PROPERTY_LOOKUP("inner_edge", dba.NameToProperty("weight"))}, GetSymbol("total")); @@ -338,9 +339,9 @@ TEST_F(PrintToJsonTest, ConstructNamedPath) { std::shared_ptr last_op = std::make_shared(nullptr, node1_sym); last_op = std::make_shared(last_op, node1_sym, node2_sym, edge1_sym, EdgeAtom::Direction::OUT, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared(last_op, node2_sym, node3_sym, edge2_sym, EdgeAtom::Direction::OUT, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared( last_op, GetSymbol("path"), std::vector{node1_sym, edge1_sym, node2_sym, edge2_sym, node3_sym}); @@ -417,7 +418,7 @@ TEST_F(PrintToJsonTest, Delete) { std::shared_ptr last_op = std::make_shared(nullptr, node_sym); last_op = std::make_shared(last_op, node_sym, GetSymbol("node2"), GetSymbol("edge"), EdgeAtom::Direction::BOTH, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared(last_op, std::vector{IDENT("node2")}, true); Check(last_op.get(), R"sep( @@ -443,7 +444,7 @@ TEST_F(PrintToJsonTest, Delete) { } TEST_F(PrintToJsonTest, SetProperty) { - storage::PropertyId prop = dba.NameToProperty("prop"); + memgraph::storage::PropertyId prop = dba.NameToProperty("prop"); std::shared_ptr last_op = std::make_shared(nullptr, GetSymbol("node")); last_op = std::make_shared(last_op, prop, PROPERTY_LOOKUP("node", prop), @@ -489,7 +490,7 @@ TEST_F(PrintToJsonTest, SetLabels) { auto node_sym = GetSymbol("node"); std::shared_ptr last_op = std::make_shared(nullptr, node_sym); last_op = std::make_shared( - last_op, node_sym, std::vector{dba.NameToLabel("label1"), dba.NameToLabel("label2")}); + last_op, node_sym, std::vector{dba.NameToLabel("label1"), dba.NameToLabel("label2")}); Check(last_op.get(), R"( { @@ -527,7 +528,7 @@ TEST_F(PrintToJsonTest, RemoveLabels) { auto node_sym = GetSymbol("node"); std::shared_ptr last_op = std::make_shared(nullptr, node_sym); last_op = std::make_shared( - last_op, node_sym, std::vector{dba.NameToLabel("label1"), dba.NameToLabel("label2")}); + last_op, node_sym, std::vector{dba.NameToLabel("label1"), dba.NameToLabel("label2")}); Check(last_op.get(), R"( { @@ -553,10 +554,10 @@ TEST_F(PrintToJsonTest, EdgeUniquenessFilter) { std::shared_ptr last_op = std::make_shared(nullptr, node1_sym); last_op = std::make_shared(last_op, node1_sym, node2_sym, edge1_sym, EdgeAtom::Direction::IN, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared(last_op, node3_sym); last_op = std::make_shared(last_op, node3_sym, node4_sym, edge2_sym, EdgeAtom::Direction::OUT, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared(last_op, edge2_sym, std::vector{edge1_sym}); Check(last_op.get(), R"( @@ -595,7 +596,7 @@ TEST_F(PrintToJsonTest, EdgeUniquenessFilter) { } TEST_F(PrintToJsonTest, Accumulate) { - storage::PropertyId prop = dba.NameToProperty("prop"); + memgraph::storage::PropertyId prop = dba.NameToProperty("prop"); auto node_sym = GetSymbol("node"); std::shared_ptr last_op = std::make_shared(nullptr, node_sym); last_op = std::make_shared(last_op, prop, PROPERTY_LOOKUP("node", prop), @@ -622,9 +623,9 @@ TEST_F(PrintToJsonTest, Accumulate) { } TEST_F(PrintToJsonTest, Aggregate) { - storage::PropertyId value = dba.NameToProperty("value"); - storage::PropertyId color = dba.NameToProperty("color"); - storage::PropertyId type = dba.NameToProperty("type"); + memgraph::storage::PropertyId value = dba.NameToProperty("value"); + memgraph::storage::PropertyId color = dba.NameToProperty("color"); + memgraph::storage::PropertyId type = dba.NameToProperty("type"); auto node_sym = GetSymbol("node"); std::shared_ptr last_op = std::make_shared(nullptr, node_sym); last_op = std::make_shared( @@ -701,8 +702,8 @@ TEST_F(PrintToJsonTest, Limit) { TEST_F(PrintToJsonTest, OrderBy) { Symbol node_sym = GetSymbol("node"); - storage::PropertyId value = dba.NameToProperty("value"); - storage::PropertyId color = dba.NameToProperty("color"); + memgraph::storage::PropertyId value = dba.NameToProperty("value"); + memgraph::storage::PropertyId color = dba.NameToProperty("color"); std::shared_ptr last_op = std::make_shared(nullptr, node_sym); last_op = std::make_shared(last_op, std::vector{{Ordering::ASC, PROPERTY_LOOKUP("node", value)}, @@ -733,7 +734,7 @@ TEST_F(PrintToJsonTest, OrderBy) { TEST_F(PrintToJsonTest, Merge) { Symbol node_sym = GetSymbol("node"); - storage::LabelId label = dba.NameToLabel("label"); + memgraph::storage::LabelId label = dba.NameToLabel("label"); std::shared_ptr match = std::make_shared(nullptr, node_sym, label); @@ -773,7 +774,7 @@ TEST_F(PrintToJsonTest, Optional) { std::shared_ptr expand = std::make_shared(nullptr, node1_sym, node2_sym, edge_sym, EdgeAtom::Direction::OUT, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); std::shared_ptr last_op = std::make_shared(input, expand, std::vector{node2_sym, edge_sym}); @@ -894,7 +895,7 @@ TEST_F(PrintToJsonTest, Cartesian) { } TEST_F(PrintToJsonTest, CallProcedure) { - query::plan::CallProcedure call_op; + memgraph::query::plan::CallProcedure call_op; call_op.input_ = std::make_shared(); call_op.procedure_name_ = "mg.reload"; call_op.arguments_ = {LITERAL("example")}; diff --git a/tests/unit/property_value_v2.cpp b/tests/unit/property_value_v2.cpp index 60eb7a801..aba322ce7 100644 --- a/tests/unit/property_value_v2.cpp +++ b/tests/unit/property_value_v2.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,9 +18,9 @@ // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, Null) { - storage::PropertyValue pv; + memgraph::storage::PropertyValue pv; - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::Null); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::Null); ASSERT_TRUE(pv.IsNull()); ASSERT_FALSE(pv.IsBool()); @@ -30,21 +30,21 @@ TEST(PropertyValue, Null) { ASSERT_FALSE(pv.IsList()); ASSERT_FALSE(pv.IsMap()); - ASSERT_THROW(pv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueMap(), memgraph::storage::PropertyValueException); const auto &cpv = pv; - ASSERT_THROW(cpv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueMap(), memgraph::storage::PropertyValueException); { std::stringstream ss; @@ -60,9 +60,9 @@ TEST(PropertyValue, Null) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, Bool) { - storage::PropertyValue pv(false); + memgraph::storage::PropertyValue pv(false); - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::Bool); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::Bool); ASSERT_FALSE(pv.IsNull()); ASSERT_TRUE(pv.IsBool()); @@ -73,20 +73,20 @@ TEST(PropertyValue, Bool) { ASSERT_FALSE(pv.IsMap()); ASSERT_EQ(pv.ValueBool(), false); - ASSERT_THROW(pv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueMap(), memgraph::storage::PropertyValueException); const auto &cpv = pv; ASSERT_EQ(cpv.ValueBool(), false); - ASSERT_THROW(cpv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueMap(), memgraph::storage::PropertyValueException); { std::stringstream ss; @@ -99,7 +99,7 @@ TEST(PropertyValue, Bool) { ASSERT_EQ(ss.str(), "false"); } { - storage::PropertyValue pvtrue(true); + memgraph::storage::PropertyValue pvtrue(true); std::stringstream ss; ss << pvtrue; ASSERT_EQ(ss.str(), "true"); @@ -108,9 +108,9 @@ TEST(PropertyValue, Bool) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, Int) { - storage::PropertyValue pv(123L); + memgraph::storage::PropertyValue pv(123L); - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::Int); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::Int); ASSERT_FALSE(pv.IsNull()); ASSERT_FALSE(pv.IsBool()); @@ -120,21 +120,21 @@ TEST(PropertyValue, Int) { ASSERT_FALSE(pv.IsList()); ASSERT_FALSE(pv.IsMap()); - ASSERT_THROW(pv.ValueBool(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueBool(), memgraph::storage::PropertyValueException); ASSERT_EQ(pv.ValueInt(), 123L); - ASSERT_THROW(pv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueMap(), memgraph::storage::PropertyValueException); const auto &cpv = pv; - ASSERT_THROW(cpv.ValueBool(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueBool(), memgraph::storage::PropertyValueException); ASSERT_EQ(cpv.ValueInt(), 123L); - ASSERT_THROW(cpv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueMap(), memgraph::storage::PropertyValueException); { std::stringstream ss; @@ -148,16 +148,16 @@ TEST(PropertyValue, Int) { } { - storage::PropertyValue pvint(123); - ASSERT_EQ(pvint.type(), storage::PropertyValue::Type::Int); + memgraph::storage::PropertyValue pvint(123); + ASSERT_EQ(pvint.type(), memgraph::storage::PropertyValue::Type::Int); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, Double) { - storage::PropertyValue pv(123.5); + memgraph::storage::PropertyValue pv(123.5); - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::Double); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::Double); ASSERT_FALSE(pv.IsNull()); ASSERT_FALSE(pv.IsBool()); @@ -167,21 +167,21 @@ TEST(PropertyValue, Double) { ASSERT_FALSE(pv.IsList()); ASSERT_FALSE(pv.IsMap()); - ASSERT_THROW(pv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueInt(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueInt(), memgraph::storage::PropertyValueException); ASSERT_EQ(pv.ValueDouble(), 123.5); - ASSERT_THROW(pv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueMap(), memgraph::storage::PropertyValueException); const auto &cpv = pv; - ASSERT_THROW(cpv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueInt(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueInt(), memgraph::storage::PropertyValueException); ASSERT_EQ(cpv.ValueDouble(), 123.5); - ASSERT_THROW(cpv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueMap(), memgraph::storage::PropertyValueException); { std::stringstream ss; @@ -198,11 +198,11 @@ TEST(PropertyValue, Double) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, StringCopy) { std::string str("nandare"); - storage::PropertyValue pv(str); + memgraph::storage::PropertyValue pv(str); ASSERT_EQ(str, "nandare"); - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::String); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::String); ASSERT_FALSE(pv.IsNull()); ASSERT_FALSE(pv.IsBool()); @@ -212,21 +212,21 @@ TEST(PropertyValue, StringCopy) { ASSERT_FALSE(pv.IsList()); ASSERT_FALSE(pv.IsMap()); - ASSERT_THROW(pv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueDouble(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueDouble(), memgraph::storage::PropertyValueException); ASSERT_EQ(pv.ValueString(), "nandare"); - ASSERT_THROW(pv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueMap(), memgraph::storage::PropertyValueException); const auto &cpv = pv; - ASSERT_THROW(cpv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueDouble(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueDouble(), memgraph::storage::PropertyValueException); ASSERT_EQ(cpv.ValueString(), "nandare"); - ASSERT_THROW(cpv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueMap(), memgraph::storage::PropertyValueException); { std::stringstream ss; @@ -243,11 +243,11 @@ TEST(PropertyValue, StringCopy) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, StringMove) { std::string str("nandare"); - storage::PropertyValue pv(std::move(str)); + memgraph::storage::PropertyValue pv(std::move(str)); ASSERT_EQ(str, ""); - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::String); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::String); ASSERT_FALSE(pv.IsNull()); ASSERT_FALSE(pv.IsBool()); @@ -257,21 +257,21 @@ TEST(PropertyValue, StringMove) { ASSERT_FALSE(pv.IsList()); ASSERT_FALSE(pv.IsMap()); - ASSERT_THROW(pv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueDouble(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueDouble(), memgraph::storage::PropertyValueException); ASSERT_EQ(pv.ValueString(), "nandare"); - ASSERT_THROW(pv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueMap(), memgraph::storage::PropertyValueException); const auto &cpv = pv; - ASSERT_THROW(cpv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueDouble(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueDouble(), memgraph::storage::PropertyValueException); ASSERT_EQ(cpv.ValueString(), "nandare"); - ASSERT_THROW(cpv.ValueList(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueList(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueMap(), memgraph::storage::PropertyValueException); { std::stringstream ss; @@ -287,14 +287,15 @@ TEST(PropertyValue, StringMove) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, ListCopy) { - std::vector vec{storage::PropertyValue("nandare"), storage::PropertyValue(123)}; - storage::PropertyValue pv(vec); + std::vector vec{memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue(123)}; + memgraph::storage::PropertyValue pv(vec); ASSERT_EQ(vec.size(), 2); ASSERT_EQ(vec[0].ValueString(), "nandare"); ASSERT_EQ(vec[1].ValueInt(), 123); - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::List); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::List); ASSERT_FALSE(pv.IsNull()); ASSERT_FALSE(pv.IsBool()); @@ -304,31 +305,31 @@ TEST(PropertyValue, ListCopy) { ASSERT_TRUE(pv.IsList()); ASSERT_FALSE(pv.IsMap()); - ASSERT_THROW(pv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueString(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueString(), memgraph::storage::PropertyValueException); { const auto &ret = pv.ValueList(); ASSERT_EQ(ret.size(), 2); ASSERT_EQ(ret[0].ValueString(), "nandare"); ASSERT_EQ(ret[1].ValueInt(), 123); } - ASSERT_THROW(pv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueMap(), memgraph::storage::PropertyValueException); const auto &cpv = pv; - ASSERT_THROW(cpv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueString(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueString(), memgraph::storage::PropertyValueException); { const auto &ret = cpv.ValueList(); ASSERT_EQ(ret.size(), 2); ASSERT_EQ(ret[0].ValueString(), "nandare"); ASSERT_EQ(ret[1].ValueInt(), 123); } - ASSERT_THROW(cpv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueMap(), memgraph::storage::PropertyValueException); { std::stringstream ss; @@ -344,12 +345,13 @@ TEST(PropertyValue, ListCopy) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, ListMove) { - std::vector vec{storage::PropertyValue("nandare"), storage::PropertyValue(123)}; - storage::PropertyValue pv(std::move(vec)); + std::vector vec{memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue(123)}; + memgraph::storage::PropertyValue pv(std::move(vec)); ASSERT_EQ(vec.size(), 0); - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::List); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::List); ASSERT_FALSE(pv.IsNull()); ASSERT_FALSE(pv.IsBool()); @@ -359,31 +361,31 @@ TEST(PropertyValue, ListMove) { ASSERT_TRUE(pv.IsList()); ASSERT_FALSE(pv.IsMap()); - ASSERT_THROW(pv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueString(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueString(), memgraph::storage::PropertyValueException); { const auto &ret = pv.ValueList(); ASSERT_EQ(ret.size(), 2); ASSERT_EQ(ret[0].ValueString(), "nandare"); ASSERT_EQ(ret[1].ValueInt(), 123); } - ASSERT_THROW(pv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueMap(), memgraph::storage::PropertyValueException); const auto &cpv = pv; - ASSERT_THROW(cpv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueString(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueString(), memgraph::storage::PropertyValueException); { const auto &ret = cpv.ValueList(); ASSERT_EQ(ret.size(), 2); ASSERT_EQ(ret[0].ValueString(), "nandare"); ASSERT_EQ(ret[1].ValueInt(), 123); } - ASSERT_THROW(cpv.ValueMap(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueMap(), memgraph::storage::PropertyValueException); { std::stringstream ss; @@ -399,13 +401,13 @@ TEST(PropertyValue, ListMove) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, MapCopy) { - std::map map{{"nandare", storage::PropertyValue(123)}}; - storage::PropertyValue pv(map); + std::map map{{"nandare", memgraph::storage::PropertyValue(123)}}; + memgraph::storage::PropertyValue pv(map); ASSERT_EQ(map.size(), 1); ASSERT_EQ(map.at("nandare").ValueInt(), 123); - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::Map); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::Map); ASSERT_FALSE(pv.IsNull()); ASSERT_FALSE(pv.IsBool()); @@ -415,11 +417,11 @@ TEST(PropertyValue, MapCopy) { ASSERT_FALSE(pv.IsList()); ASSERT_TRUE(pv.IsMap()); - ASSERT_THROW(pv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueList(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueList(), memgraph::storage::PropertyValueException); { const auto &ret = pv.ValueMap(); ASSERT_EQ(ret.size(), 1); @@ -428,11 +430,11 @@ TEST(PropertyValue, MapCopy) { const auto &cpv = pv; - ASSERT_THROW(cpv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueList(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueList(), memgraph::storage::PropertyValueException); { const auto &ret = cpv.ValueMap(); ASSERT_EQ(ret.size(), 1); @@ -453,12 +455,12 @@ TEST(PropertyValue, MapCopy) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, MapMove) { - std::map map{{"nandare", storage::PropertyValue(123)}}; - storage::PropertyValue pv(std::move(map)); + std::map map{{"nandare", memgraph::storage::PropertyValue(123)}}; + memgraph::storage::PropertyValue pv(std::move(map)); ASSERT_EQ(map.size(), 0); - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::Map); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::Map); ASSERT_FALSE(pv.IsNull()); ASSERT_FALSE(pv.IsBool()); @@ -468,11 +470,11 @@ TEST(PropertyValue, MapMove) { ASSERT_FALSE(pv.IsList()); ASSERT_TRUE(pv.IsMap()); - ASSERT_THROW(pv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(pv.ValueList(), storage::PropertyValueException); + ASSERT_THROW(pv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(pv.ValueList(), memgraph::storage::PropertyValueException); { const auto &ret = pv.ValueMap(); ASSERT_EQ(ret.size(), 1); @@ -481,11 +483,11 @@ TEST(PropertyValue, MapMove) { const auto &cpv = pv; - ASSERT_THROW(cpv.ValueBool(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueInt(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueDouble(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueString(), storage::PropertyValueException); - ASSERT_THROW(cpv.ValueList(), storage::PropertyValueException); + ASSERT_THROW(cpv.ValueBool(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueInt(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueDouble(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueString(), memgraph::storage::PropertyValueException); + ASSERT_THROW(cpv.ValueList(), memgraph::storage::PropertyValueException); { const auto &ret = cpv.ValueMap(); ASSERT_EQ(ret.size(), 1); @@ -506,44 +508,45 @@ TEST(PropertyValue, MapMove) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, CopyConstructor) { - std::vector vec{storage::PropertyValue(true), storage::PropertyValue(123)}; - std::map map{{"nandare", storage::PropertyValue(false)}}; - std::vector data{ - storage::PropertyValue(), - storage::PropertyValue(true), - storage::PropertyValue(123), - storage::PropertyValue(123.5), - storage::PropertyValue("nandare"), - storage::PropertyValue(vec), - storage::PropertyValue(map), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))}; + std::vector vec{memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123)}; + std::map map{{"nandare", memgraph::storage::PropertyValue(false)}}; + std::vector data{ + memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123), + memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue(vec), + memgraph::storage::PropertyValue(map), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))}; for (const auto &item : data) { - storage::PropertyValue pv(item); + memgraph::storage::PropertyValue pv(item); ASSERT_EQ(pv.type(), item.type()); switch (item.type()) { - case storage::PropertyValue::Type::Null: + case memgraph::storage::PropertyValue::Type::Null: ASSERT_TRUE(pv.IsNull()); break; - case storage::PropertyValue::Type::Bool: + case memgraph::storage::PropertyValue::Type::Bool: ASSERT_EQ(pv.ValueBool(), item.ValueBool()); break; - case storage::PropertyValue::Type::Int: + case memgraph::storage::PropertyValue::Type::Int: ASSERT_EQ(pv.ValueInt(), item.ValueInt()); break; - case storage::PropertyValue::Type::Double: + case memgraph::storage::PropertyValue::Type::Double: ASSERT_EQ(pv.ValueDouble(), item.ValueDouble()); break; - case storage::PropertyValue::Type::String: + case memgraph::storage::PropertyValue::Type::String: ASSERT_EQ(pv.ValueString(), item.ValueString()); break; - case storage::PropertyValue::Type::List: + case memgraph::storage::PropertyValue::Type::List: ASSERT_EQ(pv.ValueList(), item.ValueList()); break; - case storage::PropertyValue::Type::Map: + case memgraph::storage::PropertyValue::Type::Map: ASSERT_EQ(pv.ValueMap(), item.ValueMap()); break; - case storage::PropertyValue::Type::TemporalData: + case memgraph::storage::PropertyValue::Type::TemporalData: ASSERT_EQ(pv.ValueTemporalData(), item.ValueTemporalData()); } } @@ -551,46 +554,47 @@ TEST(PropertyValue, CopyConstructor) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, MoveConstructor) { - std::vector vec{storage::PropertyValue(true), storage::PropertyValue(123)}; - std::map map{{"nandare", storage::PropertyValue(false)}}; - std::vector data{ - storage::PropertyValue(), - storage::PropertyValue(true), - storage::PropertyValue(123), - storage::PropertyValue(123.5), - storage::PropertyValue("nandare"), - storage::PropertyValue(vec), - storage::PropertyValue(map), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))}; + std::vector vec{memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123)}; + std::map map{{"nandare", memgraph::storage::PropertyValue(false)}}; + std::vector data{ + memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123), + memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue(vec), + memgraph::storage::PropertyValue(map), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))}; for (auto &item : data) { - storage::PropertyValue copy(item); - storage::PropertyValue pv(std::move(item)); - ASSERT_EQ(item.type(), storage::PropertyValue::Type::Null); + memgraph::storage::PropertyValue copy(item); + memgraph::storage::PropertyValue pv(std::move(item)); + ASSERT_EQ(item.type(), memgraph::storage::PropertyValue::Type::Null); ASSERT_EQ(pv.type(), copy.type()); switch (copy.type()) { - case storage::PropertyValue::Type::Null: + case memgraph::storage::PropertyValue::Type::Null: ASSERT_TRUE(pv.IsNull()); break; - case storage::PropertyValue::Type::Bool: + case memgraph::storage::PropertyValue::Type::Bool: ASSERT_EQ(pv.ValueBool(), copy.ValueBool()); break; - case storage::PropertyValue::Type::Int: + case memgraph::storage::PropertyValue::Type::Int: ASSERT_EQ(pv.ValueInt(), copy.ValueInt()); break; - case storage::PropertyValue::Type::Double: + case memgraph::storage::PropertyValue::Type::Double: ASSERT_EQ(pv.ValueDouble(), copy.ValueDouble()); break; - case storage::PropertyValue::Type::String: + case memgraph::storage::PropertyValue::Type::String: ASSERT_EQ(pv.ValueString(), copy.ValueString()); break; - case storage::PropertyValue::Type::List: + case memgraph::storage::PropertyValue::Type::List: ASSERT_EQ(pv.ValueList(), copy.ValueList()); break; - case storage::PropertyValue::Type::Map: + case memgraph::storage::PropertyValue::Type::Map: ASSERT_EQ(pv.ValueMap(), copy.ValueMap()); break; - case storage::PropertyValue::Type::TemporalData: + case memgraph::storage::PropertyValue::Type::TemporalData: ASSERT_EQ(pv.ValueTemporalData(), copy.ValueTemporalData()); break; } @@ -599,45 +603,46 @@ TEST(PropertyValue, MoveConstructor) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, CopyAssignment) { - std::vector vec{storage::PropertyValue(true), storage::PropertyValue(123)}; - std::map map{{"nandare", storage::PropertyValue(false)}}; - std::vector data{ - storage::PropertyValue(), - storage::PropertyValue(true), - storage::PropertyValue(123), - storage::PropertyValue(123.5), - storage::PropertyValue("nandare"), - storage::PropertyValue(vec), - storage::PropertyValue(map), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))}; + std::vector vec{memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123)}; + std::map map{{"nandare", memgraph::storage::PropertyValue(false)}}; + std::vector data{ + memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123), + memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue(vec), + memgraph::storage::PropertyValue(map), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))}; for (const auto &item : data) { - storage::PropertyValue pv(123); + memgraph::storage::PropertyValue pv(123); pv = item; ASSERT_EQ(pv.type(), item.type()); switch (item.type()) { - case storage::PropertyValue::Type::Null: + case memgraph::storage::PropertyValue::Type::Null: ASSERT_TRUE(pv.IsNull()); break; - case storage::PropertyValue::Type::Bool: + case memgraph::storage::PropertyValue::Type::Bool: ASSERT_EQ(pv.ValueBool(), item.ValueBool()); break; - case storage::PropertyValue::Type::Int: + case memgraph::storage::PropertyValue::Type::Int: ASSERT_EQ(pv.ValueInt(), item.ValueInt()); break; - case storage::PropertyValue::Type::Double: + case memgraph::storage::PropertyValue::Type::Double: ASSERT_EQ(pv.ValueDouble(), item.ValueDouble()); break; - case storage::PropertyValue::Type::String: + case memgraph::storage::PropertyValue::Type::String: ASSERT_EQ(pv.ValueString(), item.ValueString()); break; - case storage::PropertyValue::Type::List: + case memgraph::storage::PropertyValue::Type::List: ASSERT_EQ(pv.ValueList(), item.ValueList()); break; - case storage::PropertyValue::Type::Map: + case memgraph::storage::PropertyValue::Type::Map: ASSERT_EQ(pv.ValueMap(), item.ValueMap()); break; - case storage::PropertyValue::Type::TemporalData: + case memgraph::storage::PropertyValue::Type::TemporalData: ASSERT_EQ(pv.ValueTemporalData(), item.ValueTemporalData()); break; } @@ -646,47 +651,48 @@ TEST(PropertyValue, CopyAssignment) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, MoveAssignment) { - std::vector vec{storage::PropertyValue(true), storage::PropertyValue(123)}; - std::map map{{"nandare", storage::PropertyValue(false)}}; - std::vector data{ - storage::PropertyValue(), - storage::PropertyValue(true), - storage::PropertyValue(123), - storage::PropertyValue(123.5), - storage::PropertyValue("nandare"), - storage::PropertyValue(vec), - storage::PropertyValue(map), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))}; + std::vector vec{memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123)}; + std::map map{{"nandare", memgraph::storage::PropertyValue(false)}}; + std::vector data{ + memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123), + memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue(vec), + memgraph::storage::PropertyValue(map), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))}; for (auto &item : data) { - storage::PropertyValue copy(item); - storage::PropertyValue pv(123); + memgraph::storage::PropertyValue copy(item); + memgraph::storage::PropertyValue pv(123); pv = std::move(item); - ASSERT_EQ(item.type(), storage::PropertyValue::Type::Null); + ASSERT_EQ(item.type(), memgraph::storage::PropertyValue::Type::Null); ASSERT_EQ(pv.type(), copy.type()); switch (copy.type()) { - case storage::PropertyValue::Type::Null: + case memgraph::storage::PropertyValue::Type::Null: ASSERT_TRUE(pv.IsNull()); break; - case storage::PropertyValue::Type::Bool: + case memgraph::storage::PropertyValue::Type::Bool: ASSERT_EQ(pv.ValueBool(), copy.ValueBool()); break; - case storage::PropertyValue::Type::Int: + case memgraph::storage::PropertyValue::Type::Int: ASSERT_EQ(pv.ValueInt(), copy.ValueInt()); break; - case storage::PropertyValue::Type::Double: + case memgraph::storage::PropertyValue::Type::Double: ASSERT_EQ(pv.ValueDouble(), copy.ValueDouble()); break; - case storage::PropertyValue::Type::String: + case memgraph::storage::PropertyValue::Type::String: ASSERT_EQ(pv.ValueString(), copy.ValueString()); break; - case storage::PropertyValue::Type::List: + case memgraph::storage::PropertyValue::Type::List: ASSERT_EQ(pv.ValueList(), copy.ValueList()); break; - case storage::PropertyValue::Type::Map: + case memgraph::storage::PropertyValue::Type::Map: ASSERT_EQ(pv.ValueMap(), copy.ValueMap()); break; - case storage::PropertyValue::Type::TemporalData: + case memgraph::storage::PropertyValue::Type::TemporalData: ASSERT_EQ(pv.ValueTemporalData(), copy.ValueTemporalData()); break; } @@ -695,34 +701,36 @@ TEST(PropertyValue, MoveAssignment) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, CopyAssignmentSelf) { - storage::PropertyValue pv("nandare"); + memgraph::storage::PropertyValue pv("nandare"); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wself-assign-overloaded" pv = pv; #pragma clang diagnostic pop - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::String); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::String); ASSERT_EQ(pv.ValueString(), "nandare"); } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, MoveAssignmentSelf) { - storage::PropertyValue pv("nandare"); + memgraph::storage::PropertyValue pv("nandare"); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wself-move" pv = std::move(pv); #pragma clang diagnostic pop - ASSERT_EQ(pv.type(), storage::PropertyValue::Type::String); + ASSERT_EQ(pv.type(), memgraph::storage::PropertyValue::Type::String); ASSERT_EQ(pv.ValueString(), "nandare"); } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, Equal) { - std::vector vec{storage::PropertyValue(true), storage::PropertyValue(123)}; - std::map map{{"nandare", storage::PropertyValue(false)}}; - std::vector data{storage::PropertyValue(), storage::PropertyValue(true), - storage::PropertyValue(123), storage::PropertyValue(123.5), - storage::PropertyValue("nandare"), storage::PropertyValue(vec), - storage::PropertyValue(map)}; + std::vector vec{memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123)}; + std::map map{{"nandare", memgraph::storage::PropertyValue(false)}}; + std::vector data{ + memgraph::storage::PropertyValue(), memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123), memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), memgraph::storage::PropertyValue(vec), + memgraph::storage::PropertyValue(map)}; for (const auto &item1 : data) { for (const auto &item2 : data) { if (item1.type() == item2.type()) { @@ -736,12 +744,14 @@ TEST(PropertyValue, Equal) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(PropertyValue, Less) { - std::vector vec{storage::PropertyValue(true), storage::PropertyValue(123)}; - std::map map{{"nandare", storage::PropertyValue(false)}}; - std::vector data{storage::PropertyValue(), storage::PropertyValue(true), - storage::PropertyValue(123), storage::PropertyValue(123.5), - storage::PropertyValue("nandare"), storage::PropertyValue(vec), - storage::PropertyValue(map)}; + std::vector vec{memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123)}; + std::map map{{"nandare", memgraph::storage::PropertyValue(false)}}; + std::vector data{ + memgraph::storage::PropertyValue(), memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123), memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), memgraph::storage::PropertyValue(vec), + memgraph::storage::PropertyValue(map)}; for (size_t i = 0; i < data.size(); ++i) { for (size_t j = 0; j < data.size(); ++j) { auto item1 = data[i]; @@ -756,8 +766,8 @@ TEST(PropertyValue, Less) { } TEST(PropertyValue, NumeralTypesComparison) { - auto v_int = storage::PropertyValue(2); - auto v_double = storage::PropertyValue(2.0); + auto v_int = memgraph::storage::PropertyValue(2); + auto v_double = memgraph::storage::PropertyValue(2.0); ASSERT_TRUE(v_int.IsInt()); ASSERT_TRUE(v_double.IsDouble()); ASSERT_TRUE(v_int == v_double); @@ -766,12 +776,17 @@ TEST(PropertyValue, NumeralTypesComparison) { } TEST(PropertyValue, NestedNumeralTypesComparison) { - auto v1 = storage::PropertyValue(std::vector{storage::PropertyValue(1)}); - auto v2 = storage::PropertyValue(std::vector{storage::PropertyValue(1.5)}); - auto v3 = storage::PropertyValue(std::vector{storage::PropertyValue(2)}); + auto v1 = memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(1)}); + auto v2 = memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(1.5)}); + auto v3 = memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(2)}); - auto v1alt = storage::PropertyValue(std::vector{storage::PropertyValue(1.0)}); - auto v3alt = storage::PropertyValue(std::vector{storage::PropertyValue(2.0)}); + auto v1alt = memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(1.0)}); + auto v3alt = memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(2.0)}); ASSERT_TRUE(v1 == v1alt); ASSERT_TRUE(v3 == v3alt); diff --git a/tests/unit/query_common.hpp b/tests/unit/query_common.hpp index 4ead307fd..60c1685d8 100644 --- a/tests/unit/query_common.hpp +++ b/tests/unit/query_common.hpp @@ -46,7 +46,7 @@ #include "storage/v2/id_types.hpp" #include "utils/string.hpp" -namespace query { +namespace memgraph::query { namespace test_common { @@ -124,13 +124,15 @@ auto GetOrderBy(T... exprs) { /// /// Name is used to create the Identifier which is used for property lookup. template -auto GetPropertyLookup(AstStorage &storage, TDbAccessor &dba, const std::string &name, storage::PropertyId property) { +auto GetPropertyLookup(AstStorage &storage, TDbAccessor &dba, const std::string &name, + memgraph::storage::PropertyId property) { return storage.Create(storage.Create(name), storage.GetPropertyIx(dba.PropertyToName(property))); } template -auto GetPropertyLookup(AstStorage &storage, TDbAccessor &dba, Expression *expr, storage::PropertyId property) { +auto GetPropertyLookup(AstStorage &storage, TDbAccessor &dba, Expression *expr, + memgraph::storage::PropertyId property) { return storage.Create(expr, storage.GetPropertyIx(dba.PropertyToName(property))); } @@ -141,13 +143,13 @@ auto GetPropertyLookup(AstStorage &storage, TDbAccessor &dba, Expression *expr, template auto GetPropertyLookup(AstStorage &storage, TDbAccessor &, const std::string &name, - const std::pair &prop_pair) { + const std::pair &prop_pair) { return storage.Create(storage.Create(name), storage.GetPropertyIx(prop_pair.first)); } template auto GetPropertyLookup(AstStorage &storage, TDbAccessor &, Expression *expr, - const std::pair &prop_pair) { + const std::pair &prop_pair) { return storage.Create(expr, storage.GetPropertyIx(prop_pair.first)); } @@ -182,17 +184,17 @@ auto GetEdgeVariable(AstStorage &storage, const std::string &name, EdgeAtom::Typ auto r_val = storage.Create(storage.Create(name), type, dir, types); r_val->filter_lambda_.inner_edge = - flambda_inner_edge ? flambda_inner_edge : storage.Create(utils::RandomString(20)); + flambda_inner_edge ? flambda_inner_edge : storage.Create(memgraph::utils::RandomString(20)); r_val->filter_lambda_.inner_node = - flambda_inner_node ? flambda_inner_node : storage.Create(utils::RandomString(20)); + flambda_inner_node ? flambda_inner_node : storage.Create(memgraph::utils::RandomString(20)); if (type == EdgeAtom::Type::WEIGHTED_SHORTEST_PATH) { r_val->weight_lambda_.inner_edge = - wlambda_inner_edge ? wlambda_inner_edge : storage.Create(utils::RandomString(20)); + wlambda_inner_edge ? wlambda_inner_edge : storage.Create(memgraph::utils::RandomString(20)); r_val->weight_lambda_.inner_node = - wlambda_inner_node ? wlambda_inner_node : storage.Create(utils::RandomString(20)); + wlambda_inner_node ? wlambda_inner_node : storage.Create(memgraph::utils::RandomString(20)); r_val->weight_lambda_.expression = - wlambda_expression ? wlambda_expression : storage.Create(1); + wlambda_expression ? wlambda_expression : storage.Create(1); r_val->total_weight_ = total_weight; } @@ -212,7 +214,7 @@ auto GetNode(AstStorage &storage, const std::string &name, std::optional atoms) { auto pattern = storage.Create(); - pattern->identifier_ = storage.Create(utils::RandomString(20), false); + pattern->identifier_ = storage.Create(memgraph::utils::RandomString(20), false); pattern->atoms_.insert(pattern->atoms_.begin(), atoms.begin(), atoms.end()); return pattern; } @@ -296,8 +298,8 @@ void FillReturnBody(AstStorage &storage, ReturnBody &body, const std::string &na if (name == "*") { body.all_identifiers = true; } else { - auto *ident = storage.Create(name); - auto *named_expr = storage.Create(name, ident); + auto *ident = storage.Create(name); + auto *named_expr = storage.Create(name, ident); body.named_expressions.emplace_back(named_expr); } } @@ -322,7 +324,7 @@ void FillReturnBody(AstStorage &, ReturnBody &body, Expression *expr, NamedExpre body.named_expressions.emplace_back(named_expr); } void FillReturnBody(AstStorage &storage, ReturnBody &body, const std::string &name, NamedExpression *named_expr) { - named_expr->expression_ = storage.Create(name); + named_expr->expression_ = storage.Create(name); body.named_expressions.emplace_back(named_expr); } template @@ -339,14 +341,14 @@ void FillReturnBody(AstStorage &storage, ReturnBody &body, NamedExpression *name template void FillReturnBody(AstStorage &storage, ReturnBody &body, const std::string &name, NamedExpression *named_expr, T... rest) { - named_expr->expression_ = storage.Create(name); + named_expr->expression_ = storage.Create(name); body.named_expressions.emplace_back(named_expr); FillReturnBody(storage, body, rest...); } template void FillReturnBody(AstStorage &storage, ReturnBody &body, const std::string &name, T... rest) { - auto *ident = storage.Create(name); - auto *named_expr = storage.Create(name, ident); + auto *ident = storage.Create(name); + auto *named_expr = storage.Create(name, ident); body.named_expressions.emplace_back(named_expr); FillReturnBody(storage, body, rest...); } @@ -386,7 +388,9 @@ auto GetWith(AstStorage &storage, bool distinct, T... exprs) { } /// Create the UNWIND clause with given named expression. -auto GetUnwind(AstStorage &storage, NamedExpression *named_expr) { return storage.Create(named_expr); } +auto GetUnwind(AstStorage &storage, NamedExpression *named_expr) { + return storage.Create(named_expr); +} auto GetUnwind(AstStorage &storage, Expression *expr, NamedExpression *as) { as->expression_ = expr; return GetUnwind(storage, as); @@ -438,13 +442,13 @@ auto GetRemove(AstStorage &storage, const std::string &name, std::vector(); + auto *merge = storage.Create(); merge->pattern_ = pattern; merge->on_create_ = on_create.set; return merge; } auto GetMerge(AstStorage &storage, Pattern *pattern, OnMatch on_match, OnCreate on_create = OnCreate{}) { - auto *merge = storage.Create(); + auto *merge = storage.Create(); merge->pattern_ = pattern; merge->on_match_ = on_match.set; merge->on_create_ = on_create.set; @@ -452,8 +456,8 @@ auto GetMerge(AstStorage &storage, Pattern *pattern, OnMatch on_match, OnCreate } auto GetCallProcedure(AstStorage &storage, std::string procedure_name, - std::vector arguments = {}) { - auto *call_procedure = storage.Create(); + std::vector arguments = {}) { + auto *call_procedure = storage.Create(); call_procedure->procedure_name_ = std::move(procedure_name); call_procedure->arguments_ = std::move(arguments); return call_procedure; @@ -461,7 +465,7 @@ auto GetCallProcedure(AstStorage &storage, std::string procedure_name, } // namespace test_common -} // namespace query +} // namespace memgraph::query /// All the following macros implicitly pass `storage` variable to functions. /// You need to have `AstStorage storage;` somewhere in scope to use them. @@ -473,97 +477,107 @@ auto GetCallProcedure(AstStorage &storage, std::string procedure_name, /// AstStorage storage; /// auto query = QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), /// RETURN(NEXPR("new_name"), IDENT("m"))); -#define NODE(...) query::test_common::GetNode(storage, __VA_ARGS__) -#define EDGE(...) query::test_common::GetEdge(storage, __VA_ARGS__) -#define EDGE_VARIABLE(...) query::test_common::GetEdgeVariable(storage, __VA_ARGS__) -#define PATTERN(...) query::test_common::GetPattern(storage, {__VA_ARGS__}) -#define NAMED_PATTERN(name, ...) query::test_common::GetPattern(storage, name, {__VA_ARGS__}) -#define OPTIONAL_MATCH(...) query::test_common::GetWithPatterns(storage.Create(true), {__VA_ARGS__}) -#define MATCH(...) query::test_common::GetWithPatterns(storage.Create(), {__VA_ARGS__}) -#define WHERE(expr) storage.Create((expr)) -#define CREATE(...) query::test_common::GetWithPatterns(storage.Create(), {__VA_ARGS__}) -#define IDENT(...) storage.Create(__VA_ARGS__) -#define LITERAL(val) storage.Create((val)) -#define LIST(...) storage.Create(std::vector{__VA_ARGS__}) -#define MAP(...) \ - storage.Create(std::unordered_map{__VA_ARGS__}) +#define NODE(...) memgraph::query::test_common::GetNode(storage, __VA_ARGS__) +#define EDGE(...) memgraph::query::test_common::GetEdge(storage, __VA_ARGS__) +#define EDGE_VARIABLE(...) memgraph::query::test_common::GetEdgeVariable(storage, __VA_ARGS__) +#define PATTERN(...) memgraph::query::test_common::GetPattern(storage, {__VA_ARGS__}) +#define NAMED_PATTERN(name, ...) memgraph::query::test_common::GetPattern(storage, name, {__VA_ARGS__}) +#define OPTIONAL_MATCH(...) \ + memgraph::query::test_common::GetWithPatterns(storage.Create(true), {__VA_ARGS__}) +#define MATCH(...) \ + memgraph::query::test_common::GetWithPatterns(storage.Create(), {__VA_ARGS__}) +#define WHERE(expr) storage.Create((expr)) +#define CREATE(...) \ + memgraph::query::test_common::GetWithPatterns(storage.Create(), {__VA_ARGS__}) +#define IDENT(...) storage.Create(__VA_ARGS__) +#define LITERAL(val) storage.Create((val)) +#define LIST(...) storage.Create(std::vector{__VA_ARGS__}) +#define MAP(...) \ + storage.Create( \ + std::unordered_map{__VA_ARGS__}) #define PROPERTY_PAIR(property_name) std::make_pair(property_name, dba.NameToProperty(property_name)) -#define PROPERTY_LOOKUP(...) query::test_common::GetPropertyLookup(storage, dba, __VA_ARGS__) -#define PARAMETER_LOOKUP(token_position) storage.Create((token_position)) -#define NEXPR(name, expr) storage.Create((name), (expr)) +#define PROPERTY_LOOKUP(...) memgraph::query::test_common::GetPropertyLookup(storage, dba, __VA_ARGS__) +#define PARAMETER_LOOKUP(token_position) storage.Create((token_position)) +#define NEXPR(name, expr) storage.Create((name), (expr)) // AS is alternative to NEXPR which does not initialize NamedExpression with // Expression. It should be used with RETURN or WITH. For example: // RETURN(IDENT("n"), AS("n")) vs. RETURN(NEXPR("n", IDENT("n"))). -#define AS(name) storage.Create((name)) -#define RETURN(...) query::test_common::GetReturn(storage, false, __VA_ARGS__) -#define WITH(...) query::test_common::GetWith(storage, false, __VA_ARGS__) -#define RETURN_DISTINCT(...) query::test_common::GetReturn(storage, true, __VA_ARGS__) -#define WITH_DISTINCT(...) query::test_common::GetWith(storage, true, __VA_ARGS__) -#define UNWIND(...) query::test_common::GetUnwind(storage, __VA_ARGS__) -#define ORDER_BY(...) query::test_common::GetOrderBy(__VA_ARGS__) +#define AS(name) storage.Create((name)) +#define RETURN(...) memgraph::query::test_common::GetReturn(storage, false, __VA_ARGS__) +#define WITH(...) memgraph::query::test_common::GetWith(storage, false, __VA_ARGS__) +#define RETURN_DISTINCT(...) memgraph::query::test_common::GetReturn(storage, true, __VA_ARGS__) +#define WITH_DISTINCT(...) memgraph::query::test_common::GetWith(storage, true, __VA_ARGS__) +#define UNWIND(...) memgraph::query::test_common::GetUnwind(storage, __VA_ARGS__) +#define ORDER_BY(...) memgraph::query::test_common::GetOrderBy(__VA_ARGS__) #define SKIP(expr) \ - query::test_common::Skip { (expr) } + memgraph::query::test_common::Skip { (expr) } #define LIMIT(expr) \ - query::test_common::Limit { (expr) } -#define DELETE(...) query::test_common::GetDelete(storage, {__VA_ARGS__}) -#define DETACH_DELETE(...) query::test_common::GetDelete(storage, {__VA_ARGS__}, true) -#define SET(...) query::test_common::GetSet(storage, __VA_ARGS__) -#define REMOVE(...) query::test_common::GetRemove(storage, __VA_ARGS__) -#define MERGE(...) query::test_common::GetMerge(storage, __VA_ARGS__) -#define ON_MATCH(...) \ - query::test_common::OnMatch { \ - std::vector { __VA_ARGS__ } \ + memgraph::query::test_common::Limit { (expr) } +#define DELETE(...) memgraph::query::test_common::GetDelete(storage, {__VA_ARGS__}) +#define DETACH_DELETE(...) memgraph::query::test_common::GetDelete(storage, {__VA_ARGS__}, true) +#define SET(...) memgraph::query::test_common::GetSet(storage, __VA_ARGS__) +#define REMOVE(...) memgraph::query::test_common::GetRemove(storage, __VA_ARGS__) +#define MERGE(...) memgraph::query::test_common::GetMerge(storage, __VA_ARGS__) +#define ON_MATCH(...) \ + memgraph::query::test_common::OnMatch { \ + std::vector { __VA_ARGS__ } \ } -#define ON_CREATE(...) \ - query::test_common::OnCreate { \ - std::vector { __VA_ARGS__ } \ +#define ON_CREATE(...) \ + memgraph::query::test_common::OnCreate { \ + std::vector { __VA_ARGS__ } \ } -#define CREATE_INDEX_ON(label, property) \ - storage.Create(query::IndexQuery::Action::CREATE, (label), \ - std::vector{(property)}) -#define QUERY(...) query::test_common::GetQuery(storage, __VA_ARGS__) -#define SINGLE_QUERY(...) query::test_common::GetSingleQuery(storage.Create(), __VA_ARGS__) -#define UNION(...) query::test_common::GetCypherUnion(storage.Create(true), __VA_ARGS__) -#define UNION_ALL(...) query::test_common::GetCypherUnion(storage.Create(false), __VA_ARGS__) +#define CREATE_INDEX_ON(label, property) \ + storage.Create(memgraph::query::IndexQuery::Action::CREATE, (label), \ + std::vector{(property)}) +#define QUERY(...) memgraph::query::test_common::GetQuery(storage, __VA_ARGS__) +#define SINGLE_QUERY(...) memgraph::query::test_common::GetSingleQuery(storage.Create(), __VA_ARGS__) +#define UNION(...) memgraph::query::test_common::GetCypherUnion(storage.Create(true), __VA_ARGS__) +#define UNION_ALL(...) memgraph::query::test_common::GetCypherUnion(storage.Create(false), __VA_ARGS__) // Various operators -#define NOT(expr) storage.Create((expr)) -#define UPLUS(expr) storage.Create((expr)) -#define UMINUS(expr) storage.Create((expr)) -#define IS_NULL(expr) storage.Create((expr)) -#define ADD(expr1, expr2) storage.Create((expr1), (expr2)) -#define LESS(expr1, expr2) storage.Create((expr1), (expr2)) -#define LESS_EQ(expr1, expr2) storage.Create((expr1), (expr2)) -#define GREATER(expr1, expr2) storage.Create((expr1), (expr2)) -#define GREATER_EQ(expr1, expr2) storage.Create((expr1), (expr2)) -#define SUM(expr) storage.Create((expr), nullptr, query::Aggregation::Op::SUM) -#define COUNT(expr) storage.Create((expr), nullptr, query::Aggregation::Op::COUNT) -#define AVG(expr) storage.Create((expr), nullptr, query::Aggregation::Op::AVG) -#define COLLECT_LIST(expr) storage.Create((expr), nullptr, query::Aggregation::Op::COLLECT_LIST) -#define EQ(expr1, expr2) storage.Create((expr1), (expr2)) -#define NEQ(expr1, expr2) storage.Create((expr1), (expr2)) -#define AND(expr1, expr2) storage.Create((expr1), (expr2)) -#define OR(expr1, expr2) storage.Create((expr1), (expr2)) -#define IN_LIST(expr1, expr2) storage.Create((expr1), (expr2)) -#define IF(cond, then, else) storage.Create((cond), (then), (else)) +#define NOT(expr) storage.Create((expr)) +#define UPLUS(expr) storage.Create((expr)) +#define UMINUS(expr) storage.Create((expr)) +#define IS_NULL(expr) storage.Create((expr)) +#define ADD(expr1, expr2) storage.Create((expr1), (expr2)) +#define LESS(expr1, expr2) storage.Create((expr1), (expr2)) +#define LESS_EQ(expr1, expr2) storage.Create((expr1), (expr2)) +#define GREATER(expr1, expr2) storage.Create((expr1), (expr2)) +#define GREATER_EQ(expr1, expr2) storage.Create((expr1), (expr2)) +#define SUM(expr) storage.Create((expr), nullptr, memgraph::query::Aggregation::Op::SUM) +#define COUNT(expr) \ + storage.Create((expr), nullptr, memgraph::query::Aggregation::Op::COUNT) +#define AVG(expr) storage.Create((expr), nullptr, memgraph::query::Aggregation::Op::AVG) +#define COLLECT_LIST(expr) \ + storage.Create((expr), nullptr, memgraph::query::Aggregation::Op::COLLECT_LIST) +#define EQ(expr1, expr2) storage.Create((expr1), (expr2)) +#define NEQ(expr1, expr2) storage.Create((expr1), (expr2)) +#define AND(expr1, expr2) storage.Create((expr1), (expr2)) +#define OR(expr1, expr2) storage.Create((expr1), (expr2)) +#define IN_LIST(expr1, expr2) storage.Create((expr1), (expr2)) +#define IF(cond, then, else) storage.Create((cond), (then), (else)) // Function call -#define FN(function_name, ...) \ - storage.Create(utils::ToUpperCase(function_name), std::vector{__VA_ARGS__}) +#define FN(function_name, ...) \ + storage.Create(memgraph::utils::ToUpperCase(function_name), \ + std::vector{__VA_ARGS__}) // List slicing -#define SLICE(list, lower_bound, upper_bound) storage.Create(list, lower_bound, upper_bound) +#define SLICE(list, lower_bound, upper_bound) \ + storage.Create(list, lower_bound, upper_bound) // all(variable IN list WHERE predicate) -#define ALL(variable, list, where) storage.Create(storage.Create(variable), list, where) +#define ALL(variable, list, where) \ + storage.Create(storage.Create(variable), list, where) #define SINGLE(variable, list, where) \ - storage.Create(storage.Create(variable), list, where) -#define ANY(variable, list, where) storage.Create(storage.Create(variable), list, where) + storage.Create(storage.Create(variable), list, where) +#define ANY(variable, list, where) \ + storage.Create(storage.Create(variable), list, where) #define NONE(variable, list, where) \ - storage.Create(storage.Create(variable), list, where) -#define REDUCE(accumulator, initializer, variable, list, expr) \ - storage.Create(storage.Create(accumulator), initializer, \ - storage.Create(variable), list, expr) -#define COALESCE(...) storage.Create(std::vector{__VA_ARGS__}) + storage.Create(storage.Create(variable), list, where) +#define REDUCE(accumulator, initializer, variable, list, expr) \ + storage.Create(storage.Create(accumulator), initializer, \ + storage.Create(variable), list, expr) +#define COALESCE(...) storage.Create(std::vector{__VA_ARGS__}) #define EXTRACT(variable, list, expr) \ - storage.Create(storage.Create(variable), list, expr) + storage.Create(storage.Create(variable), list, expr) #define AUTH_QUERY(action, user, role, user_or_role, password, privileges) \ - storage.Create((action), (user), (role), (user_or_role), password, (privileges)) -#define DROP_USER(usernames) storage.Create((usernames)) -#define CALL_PROCEDURE(...) query::test_common::GetCallProcedure(storage, __VA_ARGS__) + storage.Create((action), (user), (role), (user_or_role), password, (privileges)) +#define DROP_USER(usernames) storage.Create((usernames)) +#define CALL_PROCEDURE(...) memgraph::query::test_common::GetCallProcedure(storage, __VA_ARGS__) diff --git a/tests/unit/query_cost_estimator.cpp b/tests/unit/query_cost_estimator.cpp index ebd577c30..b73b24e6f 100644 --- a/tests/unit/query_cost_estimator.cpp +++ b/tests/unit/query_cost_estimator.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,12 +19,12 @@ #include "query/plan/operator.hpp" #include "storage/v2/storage.hpp" -using namespace query; -using namespace query::plan; +using namespace memgraph::query; +using namespace memgraph::query::plan; -using CardParam = CostEstimator::CardParam; -using CostParam = CostEstimator::CostParam; -using MiscParam = CostEstimator::MiscParam; +using CardParam = CostEstimator::CardParam; +using CostParam = CostEstimator::CostParam; +using MiscParam = CostEstimator::MiscParam; /** A fixture for cost estimation. Sets up the database * and accessor (adds some vertices). Provides convenience @@ -33,11 +33,11 @@ using MiscParam = CostEstimator::MiscParam; * estimation testing. */ class QueryCostEstimator : public ::testing::Test { protected: - storage::Storage db; - std::optional storage_dba; - std::optional dba; - storage::LabelId label = db.NameToLabel("label"); - storage::PropertyId property = db.NameToProperty("property"); + memgraph::storage::Storage db; + std::optional storage_dba; + std::optional dba; + memgraph::storage::LabelId label = db.NameToLabel("label"); + memgraph::storage::PropertyId property = db.NameToProperty("property"); // we incrementally build the logical operator plan // start it off with Once @@ -66,7 +66,7 @@ class QueryCostEstimator : public ::testing::Test { ASSERT_TRUE(vertex.AddLabel(label).HasValue()); } if (i < property_count) { - ASSERT_TRUE(vertex.SetProperty(property, storage::PropertyValue(i)).HasValue()); + ASSERT_TRUE(vertex.SetProperty(property, memgraph::storage::PropertyValue(i)).HasValue()); } } @@ -74,7 +74,7 @@ class QueryCostEstimator : public ::testing::Test { } auto Cost() { - CostEstimator cost_estimator(&*dba, parameters_); + CostEstimator cost_estimator(&*dba, parameters_); last_op_->Accept(cost_estimator); return cost_estimator.cost(); } @@ -92,11 +92,13 @@ class QueryCostEstimator : public ::testing::Test { template Expression *Parameter(TValue value) { int token_position = parameters_.size(); - parameters_.Add(token_position, storage::PropertyValue(value)); + parameters_.Add(token_position, memgraph::storage::PropertyValue(value)); return storage_.Create(token_position); } - auto InclusiveBound(Expression *expression) { return std::make_optional(utils::MakeBoundInclusive(expression)); }; + auto InclusiveBound(Expression *expression) { + return std::make_optional(memgraph::utils::MakeBoundInclusive(expression)); + }; const std::nullopt_t nullopt = std::nullopt; }; @@ -160,7 +162,7 @@ TEST_F(QueryCostEstimator, ScanAllByLabelPropertyRangeConstExpr) { AddVertices(100, 30, 20); for (auto const_val : {Literal(12), Parameter(12)}) { auto bound = std::make_optional( - utils::MakeBoundInclusive(static_cast(storage_.Create(const_val)))); + memgraph::utils::MakeBoundInclusive(static_cast(storage_.Create(const_val)))); MakeOp(nullptr, NextSymbol(), label, property, "property", bound, nullopt); EXPECT_COST(20 * CardParam::kFilter * CostParam::MakeScanAllByLabelPropertyRange); } @@ -168,14 +170,14 @@ TEST_F(QueryCostEstimator, ScanAllByLabelPropertyRangeConstExpr) { TEST_F(QueryCostEstimator, Expand) { MakeOp(last_op_, NextSymbol(), NextSymbol(), NextSymbol(), EdgeAtom::Direction::IN, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); EXPECT_COST(CardParam::kExpand * CostParam::kExpand); } TEST_F(QueryCostEstimator, ExpandVariable) { MakeOp(last_op_, NextSymbol(), NextSymbol(), NextSymbol(), EdgeAtom::Type::DEPTH_FIRST, - EdgeAtom::Direction::IN, std::vector{}, false, nullptr, nullptr, false, - ExpansionLambda{NextSymbol(), NextSymbol(), nullptr}, std::nullopt, std::nullopt); + EdgeAtom::Direction::IN, std::vector{}, false, nullptr, nullptr, + false, ExpansionLambda{NextSymbol(), NextSymbol(), nullptr}, std::nullopt, std::nullopt); EXPECT_COST(CardParam::kExpandVariable * CostParam::kExpandVariable); } @@ -198,13 +200,13 @@ TEST_F(QueryCostEstimator, EdgeUniquenessFilter) { } TEST_F(QueryCostEstimator, UnwindLiteral) { - TEST_OP(MakeOp(last_op_, storage_.Create(std::vector(7, nullptr)), - NextSymbol()), + TEST_OP(MakeOp( + last_op_, storage_.Create(std::vector(7, nullptr)), NextSymbol()), CostParam::kUnwind, 7); } TEST_F(QueryCostEstimator, UnwindNoLiteral) { - TEST_OP(MakeOp(last_op_, nullptr, NextSymbol()), CostParam::kUnwind, + TEST_OP(MakeOp(last_op_, nullptr, NextSymbol()), CostParam::kUnwind, MiscParam::kUnwindNoLiteral); } diff --git a/tests/unit/query_dump.cpp b/tests/unit/query_dump.cpp index 5040e51ee..d0397e612 100644 --- a/tests/unit/query_dump.cpp +++ b/tests/unit/query_dump.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -39,13 +39,13 @@ struct DatabaseState { struct Vertex { int64_t id; std::set labels; - std::map props; + std::map props; }; struct Edge { int64_t from, to; std::string edge_type; - std::map props; + std::map props; }; struct LabelItem { @@ -125,20 +125,20 @@ bool operator==(const DatabaseState &first, const DatabaseState &second) { first.unique_constraints == second.unique_constraints; } -DatabaseState GetState(storage::Storage *db) { +DatabaseState GetState(memgraph::storage::Storage *db) { // Capture all vertices - std::map gid_mapping; + std::map gid_mapping; std::set vertices; auto dba = db->Access(); - for (const auto &vertex : dba.Vertices(storage::View::NEW)) { + for (const auto &vertex : dba.Vertices(memgraph::storage::View::NEW)) { std::set labels; - auto maybe_labels = vertex.Labels(storage::View::NEW); + auto maybe_labels = vertex.Labels(memgraph::storage::View::NEW); MG_ASSERT(maybe_labels.HasValue()); for (const auto &label : *maybe_labels) { labels.insert(dba.LabelToName(label)); } - std::map props; - auto maybe_properties = vertex.Properties(storage::View::NEW); + std::map props; + auto maybe_properties = vertex.Properties(memgraph::storage::View::NEW); MG_ASSERT(maybe_properties.HasValue()); for (const auto &kv : *maybe_properties) { props.emplace(dba.PropertyToName(kv.first), kv.second); @@ -151,13 +151,13 @@ DatabaseState GetState(storage::Storage *db) { // Capture all edges std::set edges; - for (const auto &vertex : dba.Vertices(storage::View::NEW)) { - auto maybe_edges = vertex.OutEdges(storage::View::NEW); + for (const auto &vertex : dba.Vertices(memgraph::storage::View::NEW)) { + auto maybe_edges = vertex.OutEdges(memgraph::storage::View::NEW); MG_ASSERT(maybe_edges.HasValue()); for (const auto &edge : *maybe_edges) { const auto &edge_type_name = dba.EdgeTypeToName(edge.EdgeType()); - std::map props; - auto maybe_properties = edge.Properties(storage::View::NEW); + std::map props; + auto maybe_properties = edge.Properties(memgraph::storage::View::NEW); MG_ASSERT(maybe_properties.HasValue()); for (const auto &kv : *maybe_properties) { props.emplace(dba.PropertyToName(kv.first), kv.second); @@ -201,10 +201,10 @@ DatabaseState GetState(storage::Storage *db) { return {vertices, edges, label_indices, label_property_indices, existence_constraints, unique_constraints}; } -auto Execute(storage::Storage *db, const std::string &query) { +auto Execute(memgraph::storage::Storage *db, const std::string &query) { auto data_directory = std::filesystem::temp_directory_path() / "MG_tests_unit_query_dump"; - query::InterpreterContext context(db, query::InterpreterConfig{}, data_directory); - query::Interpreter interpreter(&context); + memgraph::query::InterpreterContext context(db, memgraph::query::InterpreterConfig{}, data_directory); + memgraph::query::Interpreter interpreter(&context); ResultStreamFaker stream(db); auto [header, _, qid] = interpreter.Prepare(query, {}, nullptr); @@ -215,9 +215,10 @@ auto Execute(storage::Storage *db, const std::string &query) { return stream; } -storage::VertexAccessor CreateVertex(storage::Storage::Accessor *dba, const std::vector &labels, - const std::map &props, - bool add_property_id = true) { +memgraph::storage::VertexAccessor CreateVertex(memgraph::storage::Storage::Accessor *dba, + const std::vector &labels, + const std::map &props, + bool add_property_id = true) { MG_ASSERT(dba); auto vertex = dba->CreateVertex(); for (const auto &label_name : labels) { @@ -228,15 +229,17 @@ storage::VertexAccessor CreateVertex(storage::Storage::Accessor *dba, const std: } if (add_property_id) { MG_ASSERT( - vertex.SetProperty(dba->NameToProperty(kPropertyId), storage::PropertyValue(vertex.Gid().AsInt())).HasValue()); + vertex.SetProperty(dba->NameToProperty(kPropertyId), memgraph::storage::PropertyValue(vertex.Gid().AsInt())) + .HasValue()); } return vertex; } -storage::EdgeAccessor CreateEdge(storage::Storage::Accessor *dba, storage::VertexAccessor *from, - storage::VertexAccessor *to, const std::string &edge_type_name, - const std::map &props, - bool add_property_id = true) { +memgraph::storage::EdgeAccessor CreateEdge(memgraph::storage::Storage::Accessor *dba, + memgraph::storage::VertexAccessor *from, + memgraph::storage::VertexAccessor *to, const std::string &edge_type_name, + const std::map &props, + bool add_property_id = true) { MG_ASSERT(dba); auto edge = dba->CreateEdge(from, to, dba->NameToEdgeType(edge_type_name)); MG_ASSERT(edge.HasValue()); @@ -244,14 +247,14 @@ storage::EdgeAccessor CreateEdge(storage::Storage::Accessor *dba, storage::Verte MG_ASSERT(edge->SetProperty(dba->NameToProperty(kv.first), kv.second).HasValue()); } if (add_property_id) { - MG_ASSERT( - edge->SetProperty(dba->NameToProperty(kPropertyId), storage::PropertyValue(edge->Gid().AsInt())).HasValue()); + MG_ASSERT(edge->SetProperty(dba->NameToProperty(kPropertyId), memgraph::storage::PropertyValue(edge->Gid().AsInt())) + .HasValue()); } return *edge; } template -void VerifyQueries(const std::vector> &results, TArgs &&...args) { +void VerifyQueries(const std::vector> &results, TArgs &&...args) { std::vector expected{std::forward(args)...}; std::vector got; got.reserve(results.size()); @@ -265,20 +268,20 @@ void VerifyQueries(const std::vector> &r // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, EmptyGraph) { - storage::Storage db; + memgraph::storage::Storage db; ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } ASSERT_EQ(stream.GetResults().size(), 0); } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, SingleVertex) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); CreateVertex(&dba, {}, {}, false); @@ -287,11 +290,11 @@ TEST(DumpTest, SingleVertex) { { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), kCreateInternalIndex, "CREATE (:__mg_vertex__ {__mg_id__: 0});", kDropInternalIndex, kRemoveInternalLabelProperty); @@ -300,7 +303,7 @@ TEST(DumpTest, SingleVertex) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, VertexWithSingleLabel) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); CreateVertex(&dba, {"Label1"}, {}, false); @@ -309,11 +312,11 @@ TEST(DumpTest, VertexWithSingleLabel) { { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), kCreateInternalIndex, "CREATE (:__mg_vertex__:`Label1` {__mg_id__: 0});", kDropInternalIndex, kRemoveInternalLabelProperty); @@ -322,7 +325,7 @@ TEST(DumpTest, VertexWithSingleLabel) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, VertexWithMultipleLabels) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); CreateVertex(&dba, {"Label1", "Label 2"}, {}, false); @@ -331,11 +334,11 @@ TEST(DumpTest, VertexWithMultipleLabels) { { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), kCreateInternalIndex, "CREATE (:__mg_vertex__:`Label1`:`Label 2` {__mg_id__: 0});", kDropInternalIndex, @@ -345,20 +348,20 @@ TEST(DumpTest, VertexWithMultipleLabels) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, VertexWithSingleProperty) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); - CreateVertex(&dba, {}, {{"prop", storage::PropertyValue(42)}}, false); + CreateVertex(&dba, {}, {{"prop", memgraph::storage::PropertyValue(42)}}, false); ASSERT_FALSE(dba.Commit().HasError()); } { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), kCreateInternalIndex, "CREATE (:__mg_vertex__ {__mg_id__: 0, `prop`: 42});", kDropInternalIndex, kRemoveInternalLabelProperty); @@ -367,7 +370,7 @@ TEST(DumpTest, VertexWithSingleProperty) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, MultipleVertices) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); CreateVertex(&dba, {}, {}, false); @@ -378,11 +381,11 @@ TEST(DumpTest, MultipleVertices) { { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), kCreateInternalIndex, "CREATE (:__mg_vertex__ {__mg_id__: 0});", "CREATE (:__mg_vertex__ {__mg_id__: 1});", "CREATE (:__mg_vertex__ {__mg_id__: 2});", @@ -391,36 +394,37 @@ TEST(DumpTest, MultipleVertices) { } TEST(DumpTest, PropertyValue) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); - auto null_value = storage::PropertyValue(); - auto int_value = storage::PropertyValue(13); - auto bool_value = storage::PropertyValue(true); - auto double_value = storage::PropertyValue(-1.2); - auto str_value = storage::PropertyValue("hello 'world'"); - auto map_value = storage::PropertyValue({{"prop 1", int_value}, {"prop`2`", bool_value}}); - auto dt = storage::PropertyValue( - storage::TemporalData(storage::TemporalType::Date, utils::Date({1994, 12, 7}).MicrosecondsSinceEpoch())); - auto lt = storage::PropertyValue(storage::TemporalData( - storage::TemporalType::LocalTime, utils::LocalTime({14, 10, 44, 99, 99}).MicrosecondsSinceEpoch())); - auto ldt = storage::PropertyValue( - storage::TemporalData(storage::TemporalType::LocalDateTime, - utils::LocalDateTime({1994, 12, 7}, {14, 10, 44, 99, 99}).MicrosecondsSinceEpoch())); - auto dur = storage::PropertyValue( - storage::TemporalData(storage::TemporalType::Duration, utils::Duration({3, 4, 5, 6, 10, 11}).microseconds)); - auto list_value = storage::PropertyValue({map_value, null_value, double_value, dt, lt, ldt, dur}); + auto null_value = memgraph::storage::PropertyValue(); + auto int_value = memgraph::storage::PropertyValue(13); + auto bool_value = memgraph::storage::PropertyValue(true); + auto double_value = memgraph::storage::PropertyValue(-1.2); + auto str_value = memgraph::storage::PropertyValue("hello 'world'"); + auto map_value = memgraph::storage::PropertyValue({{"prop 1", int_value}, {"prop`2`", bool_value}}); + auto dt = memgraph::storage::PropertyValue(memgraph::storage::TemporalData( + memgraph::storage::TemporalType::Date, memgraph::utils::Date({1994, 12, 7}).MicrosecondsSinceEpoch())); + auto lt = memgraph::storage::PropertyValue( + memgraph::storage::TemporalData(memgraph::storage::TemporalType::LocalTime, + memgraph::utils::LocalTime({14, 10, 44, 99, 99}).MicrosecondsSinceEpoch())); + auto ldt = memgraph::storage::PropertyValue(memgraph::storage::TemporalData( + memgraph::storage::TemporalType::LocalDateTime, + memgraph::utils::LocalDateTime({1994, 12, 7}, {14, 10, 44, 99, 99}).MicrosecondsSinceEpoch())); + auto dur = memgraph::storage::PropertyValue(memgraph::storage::TemporalData( + memgraph::storage::TemporalType::Duration, memgraph::utils::Duration({3, 4, 5, 6, 10, 11}).microseconds)); + auto list_value = memgraph::storage::PropertyValue({map_value, null_value, double_value, dt, lt, ldt, dur}); CreateVertex(&dba, {}, {{"p1", list_value}, {"p2", str_value}}, false); ASSERT_FALSE(dba.Commit().HasError()); } { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), kCreateInternalIndex, "CREATE (:__mg_vertex__ {__mg_id__: 0, `p1`: [{`prop 1`: 13, " @@ -433,7 +437,7 @@ TEST(DumpTest, PropertyValue) { } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, SingleEdge) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); auto u = CreateVertex(&dba, {}, {}, false); @@ -444,11 +448,11 @@ TEST(DumpTest, SingleEdge) { { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), kCreateInternalIndex, "CREATE (:__mg_vertex__ {__mg_id__: 0});", "CREATE (:__mg_vertex__ {__mg_id__: 1});", @@ -460,7 +464,7 @@ TEST(DumpTest, SingleEdge) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, MultipleEdges) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); auto u = CreateVertex(&dba, {}, {}, false); @@ -474,11 +478,11 @@ TEST(DumpTest, MultipleEdges) { { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), kCreateInternalIndex, "CREATE (:__mg_vertex__ {__mg_id__: 0});", "CREATE (:__mg_vertex__ {__mg_id__: 1});", "CREATE (:__mg_vertex__ {__mg_id__: 2});", @@ -494,22 +498,22 @@ TEST(DumpTest, MultipleEdges) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, EdgeWithProperties) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); auto u = CreateVertex(&dba, {}, {}, false); auto v = CreateVertex(&dba, {}, {}, false); - CreateEdge(&dba, &u, &v, "EdgeType", {{"prop", storage::PropertyValue(13)}}, false); + CreateEdge(&dba, &u, &v, "EdgeType", {{"prop", memgraph::storage::PropertyValue(13)}}, false); ASSERT_FALSE(dba.Commit().HasError()); } { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), kCreateInternalIndex, "CREATE (:__mg_vertex__ {__mg_id__: 0});", "CREATE (:__mg_vertex__ {__mg_id__: 1});", @@ -521,10 +525,10 @@ TEST(DumpTest, EdgeWithProperties) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, IndicesKeys) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); - CreateVertex(&dba, {"Label1", "Label 2"}, {{"p", storage::PropertyValue(1)}}, false); + CreateVertex(&dba, {"Label1", "Label 2"}, {{"p", memgraph::storage::PropertyValue(1)}}, false); ASSERT_FALSE(dba.Commit().HasError()); } ASSERT_TRUE(db.CreateIndex(db.NameToLabel("Label1"), db.NameToProperty("prop"))); @@ -532,11 +536,11 @@ TEST(DumpTest, IndicesKeys) { { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), "CREATE INDEX ON :`Label1`(`prop`);", "CREATE INDEX ON :`Label 2`(`prop ```);", kCreateInternalIndex, "CREATE (:__mg_vertex__:`Label1`:`Label 2` {__mg_id__: 0, `p`: 1});", @@ -546,10 +550,10 @@ TEST(DumpTest, IndicesKeys) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, ExistenceConstraints) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); - CreateVertex(&dba, {"L`abel 1"}, {{"prop", storage::PropertyValue(1)}}, false); + CreateVertex(&dba, {"L`abel 1"}, {{"prop", memgraph::storage::PropertyValue(1)}}, false); ASSERT_FALSE(dba.Commit().HasError()); } { @@ -560,11 +564,11 @@ TEST(DumpTest, ExistenceConstraints) { { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), "CREATE CONSTRAINT ON (u:`L``abel 1`) ASSERT EXISTS (u.`prop`);", kCreateInternalIndex, "CREATE (:__mg_vertex__:`L``abel 1` {__mg_id__: 0, `prop`: 1});", @@ -573,27 +577,31 @@ TEST(DumpTest, ExistenceConstraints) { } TEST(DumpTest, UniqueConstraints) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); - CreateVertex(&dba, {"Label"}, {{"prop", storage::PropertyValue(1)}, {"prop2", storage::PropertyValue(2)}}, false); - CreateVertex(&dba, {"Label"}, {{"prop", storage::PropertyValue(2)}, {"prop2", storage::PropertyValue(2)}}, false); + CreateVertex(&dba, {"Label"}, + {{"prop", memgraph::storage::PropertyValue(1)}, {"prop2", memgraph::storage::PropertyValue(2)}}, + false); + CreateVertex(&dba, {"Label"}, + {{"prop", memgraph::storage::PropertyValue(2)}, {"prop2", memgraph::storage::PropertyValue(2)}}, + false); ASSERT_FALSE(dba.Commit().HasError()); } { auto res = db.CreateUniqueConstraint(db.NameToLabel("Label"), {db.NameToProperty("prop"), db.NameToProperty("prop2")}); ASSERT_TRUE(res.HasValue()); - ASSERT_EQ(res.GetValue(), storage::UniqueConstraints::CreationStatus::SUCCESS); + ASSERT_EQ(res.GetValue(), memgraph::storage::UniqueConstraints::CreationStatus::SUCCESS); } { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } VerifyQueries(stream.GetResults(), "CREATE CONSTRAINT ON (u:`Label`) ASSERT u.`prop`, u.`prop2` " @@ -609,24 +617,25 @@ TEST(DumpTest, UniqueConstraints) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, CheckStateVertexWithMultipleProperties) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); - std::map prop1 = {{"nested1", storage::PropertyValue(1337)}, - {"nested2", storage::PropertyValue(3.14)}}; - CreateVertex(&dba, {"Label1", "Label2"}, - {{"prop1", storage::PropertyValue(prop1)}, {"prop2", storage::PropertyValue("$'\t'")}}); + std::map prop1 = { + {"nested1", memgraph::storage::PropertyValue(1337)}, {"nested2", memgraph::storage::PropertyValue(3.14)}}; + CreateVertex( + &dba, {"Label1", "Label2"}, + {{"prop1", memgraph::storage::PropertyValue(prop1)}, {"prop2", memgraph::storage::PropertyValue("$'\t'")}}); ASSERT_FALSE(dba.Commit().HasError()); } - storage::Storage db_dump; + memgraph::storage::Storage db_dump; { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } const auto &results = stream.GetResults(); ASSERT_GE(results.size(), 1); @@ -641,41 +650,46 @@ TEST(DumpTest, CheckStateVertexWithMultipleProperties) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, CheckStateSimpleGraph) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); - auto u = CreateVertex(&dba, {"Person"}, {{"name", storage::PropertyValue("Ivan")}}); - auto v = CreateVertex(&dba, {"Person"}, {{"name", storage::PropertyValue("Josko")}}); - auto w = - CreateVertex(&dba, {"Person"}, {{"name", storage::PropertyValue("Bosko")}, {"id", storage::PropertyValue(0)}}); + auto u = CreateVertex(&dba, {"Person"}, {{"name", memgraph::storage::PropertyValue("Ivan")}}); + auto v = CreateVertex(&dba, {"Person"}, {{"name", memgraph::storage::PropertyValue("Josko")}}); + auto w = CreateVertex( + &dba, {"Person"}, + {{"name", memgraph::storage::PropertyValue("Bosko")}, {"id", memgraph::storage::PropertyValue(0)}}); auto z = - CreateVertex(&dba, {"Person"}, {{"name", storage::PropertyValue("Buha")}, {"id", storage::PropertyValue(1)}}); + CreateVertex(&dba, {"Person"}, + {{"name", memgraph::storage::PropertyValue("Buha")}, {"id", memgraph::storage::PropertyValue(1)}}); CreateEdge(&dba, &u, &v, "Knows", {}); - CreateEdge(&dba, &v, &w, "Knows", {{"how_long", storage::PropertyValue(5)}}); - CreateEdge(&dba, &w, &u, "Knows", {{"how", storage::PropertyValue("distant past")}}); + CreateEdge(&dba, &v, &w, "Knows", {{"how_long", memgraph::storage::PropertyValue(5)}}); + CreateEdge(&dba, &w, &u, "Knows", {{"how", memgraph::storage::PropertyValue("distant past")}}); CreateEdge(&dba, &v, &u, "Knows", {}); CreateEdge(&dba, &v, &u, "Likes", {}); CreateEdge(&dba, &z, &u, "Knows", {}); - CreateEdge(&dba, &w, &z, "Knows", {{"how", storage::PropertyValue("school")}}); - CreateEdge(&dba, &w, &z, "Likes", {{"how", storage::PropertyValue("very much")}}); + CreateEdge(&dba, &w, &z, "Knows", {{"how", memgraph::storage::PropertyValue("school")}}); + CreateEdge(&dba, &w, &z, "Likes", {{"how", memgraph::storage::PropertyValue("very much")}}); CreateEdge(&dba, &w, &z, "Date", - {{"time", storage::PropertyValue(storage::TemporalData( - storage::TemporalType::Date, utils::Date({1994, 12, 7}).MicrosecondsSinceEpoch()))}}); + {{"time", memgraph::storage::PropertyValue(memgraph::storage::TemporalData( + memgraph::storage::TemporalType::Date, + memgraph::utils::Date({1994, 12, 7}).MicrosecondsSinceEpoch()))}}); CreateEdge(&dba, &w, &z, "LocalTime", - {{"time", storage::PropertyValue( - storage::TemporalData(storage::TemporalType::LocalTime, - utils::LocalTime({14, 10, 44, 99, 99}).MicrosecondsSinceEpoch()))}}); - CreateEdge(&dba, &w, &z, "LocalDateTime", - {{"time", storage::PropertyValue(storage::TemporalData( - storage::TemporalType::LocalDateTime, - utils::LocalDateTime({1994, 12, 7}, {14, 10, 44, 99, 99}).MicrosecondsSinceEpoch()))}}); - CreateEdge(&dba, &w, &z, "Duration", - {{"time", storage::PropertyValue(storage::TemporalData( - storage::TemporalType::Duration, utils::Duration({3, 4, 5, 6, 10, 11}).microseconds))}}); + {{"time", memgraph::storage::PropertyValue(memgraph::storage::TemporalData( + memgraph::storage::TemporalType::LocalTime, + memgraph::utils::LocalTime({14, 10, 44, 99, 99}).MicrosecondsSinceEpoch()))}}); CreateEdge( - &dba, &w, &z, "NegativeDuration", - {{"time", storage::PropertyValue(storage::TemporalData( - storage::TemporalType::Duration, utils::Duration({-3, -4, -5, -6, -10, -11}).microseconds))}}); + &dba, &w, &z, "LocalDateTime", + {{"time", memgraph::storage::PropertyValue(memgraph::storage::TemporalData( + memgraph::storage::TemporalType::LocalDateTime, + memgraph::utils::LocalDateTime({1994, 12, 7}, {14, 10, 44, 99, 99}).MicrosecondsSinceEpoch()))}}); + CreateEdge(&dba, &w, &z, "Duration", + {{"time", memgraph::storage::PropertyValue(memgraph::storage::TemporalData( + memgraph::storage::TemporalType::Duration, + memgraph::utils::Duration({3, 4, 5, 6, 10, 11}).microseconds))}}); + CreateEdge(&dba, &w, &z, "NegativeDuration", + {{"time", memgraph::storage::PropertyValue(memgraph::storage::TemporalData( + memgraph::storage::TemporalType::Duration, + memgraph::utils::Duration({-3, -4, -5, -6, -10, -11}).microseconds))}}); ASSERT_FALSE(dba.Commit().HasError()); } { @@ -686,20 +700,20 @@ TEST(DumpTest, CheckStateSimpleGraph) { { auto ret = db.CreateUniqueConstraint(db.NameToLabel("Person"), {db.NameToProperty("name")}); ASSERT_TRUE(ret.HasValue()); - ASSERT_EQ(ret.GetValue(), storage::UniqueConstraints::CreationStatus::SUCCESS); + ASSERT_EQ(ret.GetValue(), memgraph::storage::UniqueConstraints::CreationStatus::SUCCESS); } ASSERT_TRUE(db.CreateIndex(db.NameToLabel("Person"), db.NameToProperty("id"))); ASSERT_TRUE(db.CreateIndex(db.NameToLabel("Person"), db.NameToProperty("unexisting_property"))); const auto &db_initial_state = GetState(&db); - storage::Storage db_dump; + memgraph::storage::Storage db_dump; { ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); { auto acc = db.Access(); - query::DbAccessor dba(&acc); - query::DumpDatabaseToCypherQueries(&dba, &query_stream); + memgraph::query::DbAccessor dba(&acc); + memgraph::query::DumpDatabaseToCypherQueries(&dba, &query_stream); } const auto &results = stream.GetResults(); // Indices and constraints are 4 queries and there must be at least one more @@ -718,7 +732,7 @@ TEST(DumpTest, CheckStateSimpleGraph) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, ExecuteDumpDatabase) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); CreateVertex(&dba, {}, {}, false); @@ -745,8 +759,8 @@ TEST(DumpTest, ExecuteDumpDatabase) { class StatefulInterpreter { public: - explicit StatefulInterpreter(storage::Storage *db) - : db_(db), context_(db_, query::InterpreterConfig{}, data_directory_), interpreter_(&context_) {} + explicit StatefulInterpreter(memgraph::storage::Storage *db) + : db_(db), context_(db_, memgraph::query::InterpreterConfig{}, data_directory_), interpreter_(&context_) {} auto Execute(const std::string &query) { ResultStreamFaker stream(db_); @@ -762,9 +776,9 @@ class StatefulInterpreter { private: static const std::filesystem::path data_directory_; - storage::Storage *db_; - query::InterpreterContext context_; - query::Interpreter interpreter_; + memgraph::storage::Storage *db_; + memgraph::query::InterpreterContext context_; + memgraph::query::Interpreter interpreter_; }; const std::filesystem::path StatefulInterpreter::data_directory_{std::filesystem::temp_directory_path() / @@ -772,7 +786,7 @@ const std::filesystem::path StatefulInterpreter::data_directory_{std::filesystem // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, ExecuteDumpDatabaseInMulticommandTransaction) { - storage::Storage db; + memgraph::storage::Storage db; StatefulInterpreter interpreter(&db); // Begin the transaction before the vertex is created. @@ -835,7 +849,7 @@ TEST(DumpTest, ExecuteDumpDatabaseInMulticommandTransaction) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(DumpTest, MultiplePartialPulls) { - storage::Storage db; + memgraph::storage::Storage db; { // Create indices db.CreateIndex(db.NameToLabel("PERSON"), db.NameToProperty("name")); @@ -857,30 +871,35 @@ TEST(DumpTest, MultiplePartialPulls) { { auto res = db.CreateUniqueConstraint(db.NameToLabel("PERSON"), {db.NameToProperty("name")}); ASSERT_TRUE(res.HasValue()); - ASSERT_EQ(res.GetValue(), storage::UniqueConstraints::CreationStatus::SUCCESS); + ASSERT_EQ(res.GetValue(), memgraph::storage::UniqueConstraints::CreationStatus::SUCCESS); } { auto res = db.CreateUniqueConstraint(db.NameToLabel("PERSON"), {db.NameToProperty("surname")}); ASSERT_TRUE(res.HasValue()); - ASSERT_EQ(res.GetValue(), storage::UniqueConstraints::CreationStatus::SUCCESS); + ASSERT_EQ(res.GetValue(), memgraph::storage::UniqueConstraints::CreationStatus::SUCCESS); } auto dba = db.Access(); - auto p1 = CreateVertex( - &dba, {"PERSON"}, {{"name", storage::PropertyValue("Person1")}, {"surname", storage::PropertyValue("Unique1")}}, - false); - auto p2 = CreateVertex( - &dba, {"PERSON"}, {{"name", storage::PropertyValue("Person2")}, {"surname", storage::PropertyValue("Unique2")}}, - false); - auto p3 = CreateVertex( - &dba, {"PERSON"}, {{"name", storage::PropertyValue("Person3")}, {"surname", storage::PropertyValue("Unique3")}}, - false); - auto p4 = CreateVertex( - &dba, {"PERSON"}, {{"name", storage::PropertyValue("Person4")}, {"surname", storage::PropertyValue("Unique4")}}, - false); - auto p5 = CreateVertex( - &dba, {"PERSON"}, {{"name", storage::PropertyValue("Person5")}, {"surname", storage::PropertyValue("Unique5")}}, - false); + auto p1 = CreateVertex(&dba, {"PERSON"}, + {{"name", memgraph::storage::PropertyValue("Person1")}, + {"surname", memgraph::storage::PropertyValue("Unique1")}}, + false); + auto p2 = CreateVertex(&dba, {"PERSON"}, + {{"name", memgraph::storage::PropertyValue("Person2")}, + {"surname", memgraph::storage::PropertyValue("Unique2")}}, + false); + auto p3 = CreateVertex(&dba, {"PERSON"}, + {{"name", memgraph::storage::PropertyValue("Person3")}, + {"surname", memgraph::storage::PropertyValue("Unique3")}}, + false); + auto p4 = CreateVertex(&dba, {"PERSON"}, + {{"name", memgraph::storage::PropertyValue("Person4")}, + {"surname", memgraph::storage::PropertyValue("Unique4")}}, + false); + auto p5 = CreateVertex(&dba, {"PERSON"}, + {{"name", memgraph::storage::PropertyValue("Person5")}, + {"surname", memgraph::storage::PropertyValue("Unique5")}}, + false); CreateEdge(&dba, &p1, &p2, "REL", {}, false); CreateEdge(&dba, &p1, &p3, "REL", {}, false); CreateEdge(&dba, &p4, &p5, "REL", {}, false); @@ -889,11 +908,11 @@ TEST(DumpTest, MultiplePartialPulls) { } ResultStreamFaker stream(&db); - query::AnyStream query_stream(&stream, utils::NewDeleteResource()); + memgraph::query::AnyStream query_stream(&stream, memgraph::utils::NewDeleteResource()); auto acc = db.Access(); - query::DbAccessor dba(&acc); + memgraph::query::DbAccessor dba(&acc); - query::PullPlanDump pullPlan{&dba}; + memgraph::query::PullPlanDump pullPlan{&dba}; auto check_next = [&, offset_index = 0U](const std::string &expected_row) mutable { pullPlan.Pull(&query_stream, 1); diff --git a/tests/unit/query_expression_evaluator.cpp b/tests/unit/query_expression_evaluator.cpp index db69e868a..acf8828bb 100644 --- a/tests/unit/query_expression_evaluator.cpp +++ b/tests/unit/query_expression_evaluator.cpp @@ -33,8 +33,8 @@ #include "query_common.hpp" #include "utils/temporal.hpp" -using namespace query; -using query::test_common::ToIntList; +using namespace memgraph::query; +using memgraph::query::test_common::ToIntList; using testing::ElementsAre; using testing::UnorderedElementsAre; @@ -42,17 +42,17 @@ namespace { class ExpressionEvaluatorTest : public ::testing::Test { protected: - storage::Storage db; - storage::Storage::Accessor storage_dba{db.Access()}; - query::DbAccessor dba{&storage_dba}; + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor storage_dba{db.Access()}; + memgraph::query::DbAccessor dba{&storage_dba}; AstStorage storage; - utils::MonotonicBufferResource mem{1024}; - EvaluationContext ctx{.memory = &mem, .timestamp = query::QueryTimestamp()}; + memgraph::utils::MonotonicBufferResource mem{1024}; + EvaluationContext ctx{.memory = &mem, .timestamp = memgraph::query::QueryTimestamp()}; SymbolTable symbol_table; Frame frame{128}; - ExpressionEvaluator eval{&frame, symbol_table, ctx, &dba, storage::View::OLD}; + ExpressionEvaluator eval{&frame, symbol_table, ctx, &dba, memgraph::storage::View::OLD}; Identifier *CreateIdentifierWithValue(std::string name, const TypedValue &value) { auto id = storage.Create(name, true); @@ -124,18 +124,18 @@ TEST_F(ExpressionEvaluatorTest, AndOperatorShortCircuit) { TEST_F(ExpressionEvaluatorTest, AndOperatorNull) { { // Null doesn't short circuit - auto *op = storage.Create(storage.Create(storage::PropertyValue()), + auto *op = storage.Create(storage.Create(memgraph::storage::PropertyValue()), storage.Create(5)); EXPECT_THROW(Eval(op), QueryRuntimeException); } { - auto *op = storage.Create(storage.Create(storage::PropertyValue()), + auto *op = storage.Create(storage.Create(memgraph::storage::PropertyValue()), storage.Create(true)); auto value = Eval(op); EXPECT_TRUE(value.IsNull()); } { - auto *op = storage.Create(storage.Create(storage::PropertyValue()), + auto *op = storage.Create(storage.Create(memgraph::storage::PropertyValue()), storage.Create(false)); auto value = Eval(op); ASSERT_TRUE(value.IsBool()); @@ -269,7 +269,7 @@ TEST_F(ExpressionEvaluatorTest, InListOperator) { } { auto *list_literal = storage.Create( - std::vector{storage.Create(storage::PropertyValue()), + std::vector{storage.Create(memgraph::storage::PropertyValue()), storage.Create(2), storage.Create("a")}); // Element doesn't exist in list with null element. auto *op = storage.Create(storage.Create("x"), list_literal); @@ -279,19 +279,20 @@ TEST_F(ExpressionEvaluatorTest, InListOperator) { { // Null list. auto *op = storage.Create(storage.Create("x"), - storage.Create(storage::PropertyValue())); + storage.Create(memgraph::storage::PropertyValue())); auto value = Eval(op); EXPECT_TRUE(value.IsNull()); } { // Null literal. - auto *op = storage.Create(storage.Create(storage::PropertyValue()), list_literal); + auto *op = storage.Create(storage.Create(memgraph::storage::PropertyValue()), + list_literal); auto value = Eval(op); EXPECT_TRUE(value.IsNull()); } { // Null literal, empty list. - auto *op = storage.Create(storage.Create(storage::PropertyValue()), + auto *op = storage.Create(storage.Create(memgraph::storage::PropertyValue()), storage.Create(std::vector())); auto value = Eval(op); EXPECT_FALSE(value.ValueBool()); @@ -328,7 +329,7 @@ TEST_F(ExpressionEvaluatorTest, ListIndexing) { } { // Indexing with one operator being null. - auto *op = storage.Create(storage.Create(storage::PropertyValue()), + auto *op = storage.Create(storage.Create(memgraph::storage::PropertyValue()), storage.Create(-2)); auto value = Eval(op); EXPECT_TRUE(value.IsNull()); @@ -364,8 +365,8 @@ TEST_F(ExpressionEvaluatorTest, MapIndexing) { } { // Indexing with Null. - auto *op = - storage.Create(map_literal, storage.Create(storage::PropertyValue())); + auto *op = storage.Create(map_literal, + storage.Create(memgraph::storage::PropertyValue())); auto value = Eval(op); EXPECT_TRUE(value.IsNull()); } @@ -377,8 +378,8 @@ TEST_F(ExpressionEvaluatorTest, VertexAndEdgeIndexing) { auto v1 = dba.InsertVertex(); auto e11 = dba.InsertEdge(&v1, &v1, edge_type); ASSERT_TRUE(e11.HasValue()); - ASSERT_TRUE(v1.SetProperty(prop, storage::PropertyValue(42)).HasValue()); - ASSERT_TRUE(e11->SetProperty(prop, storage::PropertyValue(43)).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop, memgraph::storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(e11->SetProperty(prop, memgraph::storage::PropertyValue(43)).HasValue()); dba.AdvanceCommand(); auto *vertex_id = CreateIdentifierWithValue("v1", TypedValue(v1)); @@ -413,12 +414,13 @@ TEST_F(ExpressionEvaluatorTest, VertexAndEdgeIndexing) { } { // Indexing with Null. - auto *op1 = - storage.Create(vertex_id, storage.Create(storage::PropertyValue())); + auto *op1 = storage.Create(vertex_id, + storage.Create(memgraph::storage::PropertyValue())); auto value1 = Eval(op1); EXPECT_TRUE(value1.IsNull()); - auto *op2 = storage.Create(edge_id, storage.Create(storage::PropertyValue())); + auto *op2 = storage.Create(edge_id, + storage.Create(memgraph::storage::PropertyValue())); auto value2 = Eval(op2); EXPECT_TRUE(value2.IsNull()); } @@ -478,9 +480,9 @@ TEST_F(ExpressionEvaluatorTest, ListSlicingOperator) { } { // Bound of illegal type and null value bound. - auto *op = - storage.Create(list_literal, storage.Create(storage::PropertyValue()), - storage.Create("mirko")); + auto *op = storage.Create(list_literal, + storage.Create(memgraph::storage::PropertyValue()), + storage.Create("mirko")); EXPECT_THROW(Eval(op), QueryRuntimeException); } { @@ -491,7 +493,7 @@ TEST_F(ExpressionEvaluatorTest, ListSlicingOperator) { } { // Null value list with undefined upper bound. - auto *op = storage.Create(storage.Create(storage::PropertyValue()), + auto *op = storage.Create(storage.Create(memgraph::storage::PropertyValue()), storage.Create(-2), nullptr); auto value = Eval(op); EXPECT_TRUE(value.IsNull()); @@ -499,8 +501,9 @@ TEST_F(ExpressionEvaluatorTest, ListSlicingOperator) { } { // Null value index. - auto *op = storage.Create(list_literal, storage.Create(-2), - storage.Create(storage::PropertyValue())); + auto *op = + storage.Create(list_literal, storage.Create(-2), + storage.Create(memgraph::storage::PropertyValue())); auto value = Eval(op); EXPECT_TRUE(value.IsNull()); ; @@ -554,7 +557,7 @@ TEST_F(ExpressionEvaluatorTest, IsNullOperator) { auto *op = storage.Create(storage.Create(1)); auto val1 = Eval(op); ASSERT_EQ(val1.ValueBool(), false); - op = storage.Create(storage.Create(storage::PropertyValue())); + op = storage.Create(storage.Create(memgraph::storage::PropertyValue())); auto val2 = Eval(op); ASSERT_EQ(val2.ValueBool(), true); } @@ -618,7 +621,7 @@ TEST_F(ExpressionEvaluatorTest, ListLiteral) { } TEST_F(ExpressionEvaluatorTest, ParameterLookup) { - ctx.parameters.Add(0, storage::PropertyValue(42)); + ctx.parameters.Add(0, memgraph::storage::PropertyValue(42)); auto *param_lookup = storage.Create(0); auto value = Eval(param_lookup); ASSERT_TRUE(value.IsInt()); @@ -651,7 +654,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionAll2) { TEST_F(ExpressionEvaluatorTest, FunctionAllNullList) { AstStorage storage; - auto *all = ALL("x", LITERAL(storage::PropertyValue()), WHERE(LITERAL(true))); + auto *all = ALL("x", LITERAL(memgraph::storage::PropertyValue()), WHERE(LITERAL(true))); const auto x_sym = symbol_table.CreateSymbol("x", true); all->identifier_->MapTo(x_sym); auto value = Eval(all); @@ -661,7 +664,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionAllNullList) { TEST_F(ExpressionEvaluatorTest, FunctionAllNullElementInList1) { AstStorage storage; auto *ident_x = IDENT("x"); - auto *all = ALL("x", LIST(LITERAL(1), LITERAL(storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(1)))); + auto *all = ALL("x", LIST(LITERAL(1), LITERAL(memgraph::storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(1)))); const auto x_sym = symbol_table.CreateSymbol("x", true); all->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -673,7 +676,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionAllNullElementInList1) { TEST_F(ExpressionEvaluatorTest, FunctionAllNullElementInList2) { AstStorage storage; auto *ident_x = IDENT("x"); - auto *all = ALL("x", LIST(LITERAL(2), LITERAL(storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(1)))); + auto *all = ALL("x", LIST(LITERAL(2), LITERAL(memgraph::storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(1)))); const auto x_sym = symbol_table.CreateSymbol("x", true); all->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -716,7 +719,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionSingle2) { TEST_F(ExpressionEvaluatorTest, FunctionSingleNullList) { AstStorage storage; - auto *single = SINGLE("x", LITERAL(storage::PropertyValue()), WHERE(LITERAL(true))); + auto *single = SINGLE("x", LITERAL(memgraph::storage::PropertyValue()), WHERE(LITERAL(true))); const auto x_sym = symbol_table.CreateSymbol("x", true); single->identifier_->MapTo(x_sym); auto value = Eval(single); @@ -726,7 +729,8 @@ TEST_F(ExpressionEvaluatorTest, FunctionSingleNullList) { TEST_F(ExpressionEvaluatorTest, FunctionSingleNullElementInList1) { AstStorage storage; auto *ident_x = IDENT("x"); - auto *single = SINGLE("x", LIST(LITERAL(1), LITERAL(storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(1)))); + auto *single = + SINGLE("x", LIST(LITERAL(1), LITERAL(memgraph::storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(1)))); const auto x_sym = symbol_table.CreateSymbol("x", true); single->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -738,7 +742,8 @@ TEST_F(ExpressionEvaluatorTest, FunctionSingleNullElementInList1) { TEST_F(ExpressionEvaluatorTest, FunctionSingleNullElementInList2) { AstStorage storage; auto *ident_x = IDENT("x"); - auto *single = SINGLE("x", LIST(LITERAL(2), LITERAL(storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(1)))); + auto *single = + SINGLE("x", LIST(LITERAL(2), LITERAL(memgraph::storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(1)))); const auto x_sym = symbol_table.CreateSymbol("x", true); single->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -773,7 +778,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionAny2) { TEST_F(ExpressionEvaluatorTest, FunctionAnyNullList) { AstStorage storage; - auto *any = ANY("x", LITERAL(storage::PropertyValue()), WHERE(LITERAL(true))); + auto *any = ANY("x", LITERAL(memgraph::storage::PropertyValue()), WHERE(LITERAL(true))); const auto x_sym = symbol_table.CreateSymbol("x", true); any->identifier_->MapTo(x_sym); auto value = Eval(any); @@ -783,7 +788,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionAnyNullList) { TEST_F(ExpressionEvaluatorTest, FunctionAnyNullElementInList1) { AstStorage storage; auto *ident_x = IDENT("x"); - auto *any = ANY("x", LIST(LITERAL(0), LITERAL(storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(0)))); + auto *any = ANY("x", LIST(LITERAL(0), LITERAL(memgraph::storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(0)))); const auto x_sym = symbol_table.CreateSymbol("x", true); any->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -794,7 +799,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionAnyNullElementInList1) { TEST_F(ExpressionEvaluatorTest, FunctionAnyNullElementInList2) { AstStorage storage; auto *ident_x = IDENT("x"); - auto *any = ANY("x", LIST(LITERAL(1), LITERAL(storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(0)))); + auto *any = ANY("x", LIST(LITERAL(1), LITERAL(memgraph::storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(0)))); const auto x_sym = symbol_table.CreateSymbol("x", true); any->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -836,7 +841,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionNone2) { TEST_F(ExpressionEvaluatorTest, FunctionNoneNullList) { AstStorage storage; - auto *none = NONE("x", LITERAL(storage::PropertyValue()), WHERE(LITERAL(true))); + auto *none = NONE("x", LITERAL(memgraph::storage::PropertyValue()), WHERE(LITERAL(true))); const auto x_sym = symbol_table.CreateSymbol("x", true); none->identifier_->MapTo(x_sym); auto value = Eval(none); @@ -846,7 +851,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionNoneNullList) { TEST_F(ExpressionEvaluatorTest, FunctionNoneNullElementInList1) { AstStorage storage; auto *ident_x = IDENT("x"); - auto *any = NONE("x", LIST(LITERAL(1), LITERAL(storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(0)))); + auto *any = NONE("x", LIST(LITERAL(1), LITERAL(memgraph::storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(0)))); const auto x_sym = symbol_table.CreateSymbol("x", true); any->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -857,7 +862,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionNoneNullElementInList1) { TEST_F(ExpressionEvaluatorTest, FunctionNoneNullElementInList2) { AstStorage storage; auto *ident_x = IDENT("x"); - auto *none = NONE("x", LIST(LITERAL(0), LITERAL(storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(0)))); + auto *none = NONE("x", LIST(LITERAL(0), LITERAL(memgraph::storage::PropertyValue())), WHERE(EQ(ident_x, LITERAL(0)))); const auto x_sym = symbol_table.CreateSymbol("x", true); none->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -893,7 +898,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionExtract) { AstStorage storage; auto *ident_x = IDENT("x"); auto *extract = - EXTRACT("x", LIST(LITERAL(1), LITERAL(2), LITERAL(storage::PropertyValue())), ADD(ident_x, LITERAL(1))); + EXTRACT("x", LIST(LITERAL(1), LITERAL(2), LITERAL(memgraph::storage::PropertyValue())), ADD(ident_x, LITERAL(1))); const auto x_sym = symbol_table.CreateSymbol("x", true); extract->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -909,7 +914,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionExtract) { TEST_F(ExpressionEvaluatorTest, FunctionExtractNull) { AstStorage storage; auto *ident_x = IDENT("x"); - auto *extract = EXTRACT("x", LITERAL(storage::PropertyValue()), ADD(ident_x, LITERAL(1))); + auto *extract = EXTRACT("x", LITERAL(memgraph::storage::PropertyValue()), ADD(ident_x, LITERAL(1))); const auto x_sym = symbol_table.CreateSymbol("x", true); extract->identifier_->MapTo(x_sym); ident_x->MapTo(x_sym); @@ -970,14 +975,15 @@ TEST_F(ExpressionEvaluatorTest, RegexMatch) { class ExpressionEvaluatorPropertyLookup : public ExpressionEvaluatorTest { protected: - std::pair prop_age = std::make_pair("age", dba.NameToProperty("age")); - std::pair prop_height = std::make_pair("height", dba.NameToProperty("height")); + std::pair prop_age = std::make_pair("age", dba.NameToProperty("age")); + std::pair prop_height = + std::make_pair("height", dba.NameToProperty("height")); Identifier *identifier = storage.Create("element"); Symbol symbol = symbol_table.CreateSymbol("element", true); void SetUp() { identifier->MapTo(symbol); } - auto Value(std::pair property) { + auto Value(std::pair property) { auto *op = storage.Create(identifier, storage.GetPropertyIx(property.first)); return Eval(op); } @@ -985,7 +991,7 @@ class ExpressionEvaluatorPropertyLookup : public ExpressionEvaluatorTest { TEST_F(ExpressionEvaluatorPropertyLookup, Vertex) { auto v1 = dba.InsertVertex(); - ASSERT_TRUE(v1.SetProperty(prop_age.second, storage::PropertyValue(10)).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop_age.second, memgraph::storage::PropertyValue(10)).HasValue()); dba.AdvanceCommand(); frame[symbol] = TypedValue(v1); EXPECT_EQ(Value(prop_age).ValueInt(), 10); @@ -993,7 +999,7 @@ TEST_F(ExpressionEvaluatorPropertyLookup, Vertex) { } TEST_F(ExpressionEvaluatorPropertyLookup, Duration) { - const utils::Duration dur({10, 1, 30, 2, 22, 45}); + const memgraph::utils::Duration dur({10, 1, 30, 2, 22, 45}); frame[symbol] = TypedValue(dur); const std::pair day = std::make_pair("day", dba.NameToProperty("day")); @@ -1038,7 +1044,7 @@ TEST_F(ExpressionEvaluatorPropertyLookup, Duration) { } TEST_F(ExpressionEvaluatorPropertyLookup, Date) { - const utils::Date date({1996, 11, 22}); + const memgraph::utils::Date date({1996, 11, 22}); frame[symbol] = TypedValue(date); const std::pair year = std::make_pair("year", dba.NameToProperty("year")); @@ -1058,7 +1064,7 @@ TEST_F(ExpressionEvaluatorPropertyLookup, Date) { } TEST_F(ExpressionEvaluatorPropertyLookup, LocalTime) { - const utils::LocalTime lt({1, 2, 3, 11, 22}); + const memgraph::utils::LocalTime lt({1, 2, 3, 11, 22}); frame[symbol] = TypedValue(lt); const std::pair hour = std::make_pair("hour", dba.NameToProperty("hour")); @@ -1088,7 +1094,7 @@ TEST_F(ExpressionEvaluatorPropertyLookup, LocalTime) { } TEST_F(ExpressionEvaluatorPropertyLookup, LocalDateTime) { - const utils::LocalDateTime ldt({1993, 8, 6}, {2, 3, 4, 55, 40}); + const memgraph::utils::LocalDateTime ldt({1993, 8, 6}, {2, 3, 4, 55, 40}); frame[symbol] = TypedValue(ldt); const std::pair year = std::make_pair("year", dba.NameToProperty("year")); @@ -1137,7 +1143,7 @@ TEST_F(ExpressionEvaluatorPropertyLookup, Edge) { auto v2 = dba.InsertVertex(); auto e12 = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("edge_type")); ASSERT_TRUE(e12.HasValue()); - ASSERT_TRUE(e12->SetProperty(prop_age.second, storage::PropertyValue(10)).HasValue()); + ASSERT_TRUE(e12->SetProperty(prop_age.second, memgraph::storage::PropertyValue(10)).HasValue()); dba.AdvanceCommand(); frame[symbol] = TypedValue(*e12); EXPECT_EQ(Value(prop_age).ValueInt(), 10); @@ -1206,7 +1212,8 @@ TEST_F(FunctionTest, EndNode) { ASSERT_TRUE(v2.AddLabel(dba.NameToLabel("label2")).HasValue()); auto e = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("t")); ASSERT_TRUE(e.HasValue()); - ASSERT_TRUE(*EvaluateFunction("ENDNODE", *e).ValueVertex().HasLabel(storage::View::NEW, dba.NameToLabel("label2"))); + ASSERT_TRUE( + *EvaluateFunction("ENDNODE", *e).ValueVertex().HasLabel(memgraph::storage::View::NEW, dba.NameToLabel("label2"))); ASSERT_THROW(EvaluateFunction("ENDNODE", 2), QueryRuntimeException); } @@ -1224,13 +1231,13 @@ TEST_F(FunctionTest, Properties) { ASSERT_THROW(EvaluateFunction("PROPERTIES"), QueryRuntimeException); ASSERT_TRUE(EvaluateFunction("PROPERTIES", TypedValue()).IsNull()); auto v1 = dba.InsertVertex(); - ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("height"), storage::PropertyValue(5)).HasValue()); - ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("age"), storage::PropertyValue(10)).HasValue()); + ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("height"), memgraph::storage::PropertyValue(5)).HasValue()); + ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("age"), memgraph::storage::PropertyValue(10)).HasValue()); auto v2 = dba.InsertVertex(); auto e = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("type1")); ASSERT_TRUE(e.HasValue()); - ASSERT_TRUE(e->SetProperty(dba.NameToProperty("height"), storage::PropertyValue(3)).HasValue()); - ASSERT_TRUE(e->SetProperty(dba.NameToProperty("age"), storage::PropertyValue(15)).HasValue()); + ASSERT_TRUE(e->SetProperty(dba.NameToProperty("height"), memgraph::storage::PropertyValue(3)).HasValue()); + ASSERT_TRUE(e->SetProperty(dba.NameToProperty("age"), memgraph::storage::PropertyValue(15)).HasValue()); dba.AdvanceCommand(); auto prop_values_to_int = [](TypedValue t) { @@ -1272,7 +1279,7 @@ TEST_F(FunctionTest, Size) { ASSERT_THROW(EvaluateFunction("SIZE", 5), QueryRuntimeException); auto v0 = dba.InsertVertex(); - query::Path path(v0); + memgraph::query::Path path(v0); EXPECT_EQ(EvaluateFunction("SIZE", path).ValueInt(), 0); auto v1 = dba.InsertVertex(); auto edge = dba.InsertEdge(&v0, &v1, dba.NameToEdgeType("type")); @@ -1291,7 +1298,9 @@ TEST_F(FunctionTest, StartNode) { ASSERT_TRUE(v2.AddLabel(dba.NameToLabel("label2")).HasValue()); auto e = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("t")); ASSERT_TRUE(e.HasValue()); - ASSERT_TRUE(*EvaluateFunction("STARTNODE", *e).ValueVertex().HasLabel(storage::View::NEW, dba.NameToLabel("label1"))); + ASSERT_TRUE(*EvaluateFunction("STARTNODE", *e) + .ValueVertex() + .HasLabel(memgraph::storage::View::NEW, dba.NameToLabel("label1"))); ASSERT_THROW(EvaluateFunction("STARTNODE", 2), QueryRuntimeException); } @@ -1450,18 +1459,18 @@ TEST_F(FunctionTest, NodesRelationships) { ASSERT_TRUE(e1.HasValue()); auto e2 = dba.InsertEdge(&v2, &v3, dba.NameToEdgeType("Type")); ASSERT_TRUE(e2.HasValue()); - query::Path path{v1, *e1, v2, *e2, v3}; + memgraph::query::Path path{v1, *e1, v2, *e2, v3}; dba.AdvanceCommand(); auto _nodes = EvaluateFunction("NODES", path).ValueList(); - std::vector nodes; + std::vector nodes; for (const auto &node : _nodes) { nodes.push_back(node.ValueVertex()); } EXPECT_THAT(nodes, ElementsAre(v1, v2, v3)); auto _edges = EvaluateFunction("RELATIONSHIPS", path).ValueList(); - std::vector edges; + std::vector edges; for (const auto &edge : _edges) { edges.push_back(edge.ValueEdge()); } @@ -1492,13 +1501,13 @@ TEST_F(FunctionTest, Keys) { ASSERT_THROW(EvaluateFunction("KEYS"), QueryRuntimeException); ASSERT_TRUE(EvaluateFunction("KEYS", TypedValue()).IsNull()); auto v1 = dba.InsertVertex(); - ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("height"), storage::PropertyValue(5)).HasValue()); - ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("age"), storage::PropertyValue(10)).HasValue()); + ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("height"), memgraph::storage::PropertyValue(5)).HasValue()); + ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("age"), memgraph::storage::PropertyValue(10)).HasValue()); auto v2 = dba.InsertVertex(); auto e = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("type1")); ASSERT_TRUE(e.HasValue()); - ASSERT_TRUE(e->SetProperty(dba.NameToProperty("width"), storage::PropertyValue(3)).HasValue()); - ASSERT_TRUE(e->SetProperty(dba.NameToProperty("age"), storage::PropertyValue(15)).HasValue()); + ASSERT_TRUE(e->SetProperty(dba.NameToProperty("width"), memgraph::storage::PropertyValue(3)).HasValue()); + ASSERT_TRUE(e->SetProperty(dba.NameToProperty("age"), memgraph::storage::PropertyValue(15)).HasValue()); dba.AdvanceCommand(); auto prop_keys_to_string = [](TypedValue t) { @@ -1747,25 +1756,25 @@ TEST_F(FunctionTest, TimestampVoid) { TEST_F(FunctionTest, TimestampDate) { ctx.timestamp = 42; - EXPECT_EQ(EvaluateFunction("TIMESTAMP", utils::Date({1970, 1, 1})).ValueInt(), 0); - EXPECT_EQ(EvaluateFunction("TIMESTAMP", utils::Date({1971, 1, 1})).ValueInt(), 31536000000000); + EXPECT_EQ(EvaluateFunction("TIMESTAMP", memgraph::utils::Date({1970, 1, 1})).ValueInt(), 0); + EXPECT_EQ(EvaluateFunction("TIMESTAMP", memgraph::utils::Date({1971, 1, 1})).ValueInt(), 31536000000000); } TEST_F(FunctionTest, TimestampLocalTime) { ctx.timestamp = 42; - const utils::LocalTime time(10000); + const memgraph::utils::LocalTime time(10000); EXPECT_EQ(EvaluateFunction("TIMESTAMP", time).ValueInt(), 10000); } TEST_F(FunctionTest, TimestampLocalDateTime) { ctx.timestamp = 42; - const utils::LocalDateTime time(20000); + const memgraph::utils::LocalDateTime time(20000); EXPECT_EQ(EvaluateFunction("TIMESTAMP", time).ValueInt(), 20000); } TEST_F(FunctionTest, TimestampDuration) { ctx.timestamp = 42; - const utils::Duration time(20000); + const memgraph::utils::Duration time(20000); EXPECT_EQ(EvaluateFunction("TIMESTAMP", time).ValueInt(), 20000); } @@ -1897,7 +1906,7 @@ TEST_F(FunctionTest, ToByteString) { "\x01\x23\x45\x67\x89\xAA\xBB\xCC\xDD\xEE\xFF"); EXPECT_EQ(EvaluateFunction("TOBYTESTRING", "0x042").ValueString().size(), 2); EXPECT_EQ(EvaluateFunction("TOBYTESTRING", "0x042").ValueString(), - utils::pmr::string("\x00\x42", 2, utils::NewDeleteResource())); + memgraph::utils::pmr::string("\x00\x42", 2, memgraph::utils::NewDeleteResource())); } TEST_F(FunctionTest, FromByteString) { @@ -1911,15 +1920,15 @@ TEST_F(FunctionTest, FromByteString) { } TEST_F(FunctionTest, Date) { - const auto unix_epoch = utils::Date({1970, 1, 1}); + const auto unix_epoch = memgraph::utils::Date({1970, 1, 1}); EXPECT_EQ(EvaluateFunction("DATE", "1970-01-01").ValueDate(), unix_epoch); const auto map_param = TypedValue( std::map{{"year", TypedValue(1970)}, {"month", TypedValue(1)}, {"day", TypedValue(1)}}); EXPECT_EQ(EvaluateFunction("DATE", map_param).ValueDate(), unix_epoch); - const auto today = utils::CurrentDate(); + const auto today = memgraph::utils::CurrentDate(); EXPECT_EQ(EvaluateFunction("DATE").ValueDate(), today); - EXPECT_THROW(EvaluateFunction("DATE", "{}"), utils::BasicException); + EXPECT_THROW(EvaluateFunction("DATE", "{}"), memgraph::utils::BasicException); EXPECT_THROW(EvaluateFunction("DATE", std::map{{"years", TypedValue(1970)}}), QueryRuntimeException); EXPECT_THROW(EvaluateFunction("DATE", std::map{{"mnths", TypedValue(1970)}}), @@ -1929,7 +1938,7 @@ TEST_F(FunctionTest, Date) { } TEST_F(FunctionTest, LocalTime) { - const auto local_time = utils::LocalTime({13, 3, 2, 0, 0}); + const auto local_time = memgraph::utils::LocalTime({13, 3, 2, 0, 0}); EXPECT_EQ(EvaluateFunction("LOCALTIME", "130302").ValueLocalTime(), local_time); const auto one_sec_in_microseconds = 1000000; const auto map_param = TypedValue(std::map{{"hour", TypedValue(1)}, @@ -1937,12 +1946,12 @@ TEST_F(FunctionTest, LocalTime) { {"second", TypedValue(3)}, {"millisecond", TypedValue(4)}, {"microsecond", TypedValue(5)}}); - EXPECT_EQ(EvaluateFunction("LOCALTIME", map_param).ValueLocalTime(), utils::LocalTime({1, 2, 3, 4, 5})); - const auto today = utils::CurrentLocalTime(); + EXPECT_EQ(EvaluateFunction("LOCALTIME", map_param).ValueLocalTime(), memgraph::utils::LocalTime({1, 2, 3, 4, 5})); + const auto today = memgraph::utils::CurrentLocalTime(); EXPECT_NEAR(EvaluateFunction("LOCALTIME").ValueLocalTime().MicrosecondsSinceEpoch(), today.MicrosecondsSinceEpoch(), one_sec_in_microseconds); - EXPECT_THROW(EvaluateFunction("LOCALTIME", "{}"), utils::BasicException); + EXPECT_THROW(EvaluateFunction("LOCALTIME", "{}"), memgraph::utils::BasicException); EXPECT_THROW(EvaluateFunction("LOCALTIME", TypedValue(std::map{{"hous", TypedValue(1970)}})), QueryRuntimeException); EXPECT_THROW( @@ -1954,9 +1963,9 @@ TEST_F(FunctionTest, LocalTime) { } TEST_F(FunctionTest, LocalDateTime) { - const auto local_date_time = utils::LocalDateTime({1970, 1, 1}, {13, 3, 2, 0, 0}); + const auto local_date_time = memgraph::utils::LocalDateTime({1970, 1, 1}, {13, 3, 2, 0, 0}); EXPECT_EQ(EvaluateFunction("LOCALDATETIME", "1970-01-01T13:03:02").ValueLocalDateTime(), local_date_time); - const auto today = utils::CurrentLocalDateTime(); + const auto today = memgraph::utils::CurrentLocalDateTime(); const auto one_sec_in_microseconds = 1000000; const auto map_param = TypedValue(std::map{{"year", TypedValue(1972)}, {"month", TypedValue(2)}, @@ -1968,10 +1977,10 @@ TEST_F(FunctionTest, LocalDateTime) { {"microsecond", TypedValue(8)}}); EXPECT_EQ(EvaluateFunction("LOCALDATETIME", map_param).ValueLocalDateTime(), - utils::LocalDateTime({1972, 2, 3}, {4, 5, 6, 7, 8})); + memgraph::utils::LocalDateTime({1972, 2, 3}, {4, 5, 6, 7, 8})); EXPECT_NEAR(EvaluateFunction("LOCALDATETIME").ValueLocalDateTime().MicrosecondsSinceEpoch(), today.MicrosecondsSinceEpoch(), one_sec_in_microseconds); - EXPECT_THROW(EvaluateFunction("LOCALDATETIME", "{}"), utils::BasicException); + EXPECT_THROW(EvaluateFunction("LOCALDATETIME", "{}"), memgraph::utils::BasicException); EXPECT_THROW( EvaluateFunction("LOCALDATETIME", TypedValue(std::map{{"hours", TypedValue(1970)}})), QueryRuntimeException); @@ -1988,8 +1997,8 @@ TEST_F(FunctionTest, Duration) { {"millisecond", TypedValue(7)}, {"microsecond", TypedValue(8)}}); - EXPECT_EQ(EvaluateFunction("DURATION", map_param).ValueDuration(), utils::Duration({3, 4, 5, 6, 7, 8})); - EXPECT_THROW(EvaluateFunction("DURATION", "{}"), utils::BasicException); + EXPECT_EQ(EvaluateFunction("DURATION", map_param).ValueDuration(), memgraph::utils::Duration({3, 4, 5, 6, 7, 8})); + EXPECT_THROW(EvaluateFunction("DURATION", "{}"), memgraph::utils::BasicException); EXPECT_THROW(EvaluateFunction("DURATION", TypedValue(std::map{{"hours", TypedValue(1970)}})), QueryRuntimeException); EXPECT_THROW( @@ -2003,10 +2012,13 @@ TEST_F(FunctionTest, Duration) { {"millisecond", TypedValue(-7)}, {"microsecond", TypedValue(-8)}}); EXPECT_EQ(EvaluateFunction("DURATION", map_param_negative).ValueDuration(), - utils::Duration({-3, -4, -5, -6, -7, -8})); + memgraph::utils::Duration({-3, -4, -5, -6, -7, -8})); - EXPECT_EQ(EvaluateFunction("DURATION", "P4DT4H5M6.2S").ValueDuration(), utils::Duration({4, 4, 5, 6, 0, 200000})); - EXPECT_EQ(EvaluateFunction("DURATION", "P3DT4H5M6.100S").ValueDuration(), utils::Duration({3, 4, 5, 6, 0, 100000})); - EXPECT_EQ(EvaluateFunction("DURATION", "P3DT4H5M6.100110S").ValueDuration(), utils::Duration({3, 4, 5, 6, 100, 110})); + EXPECT_EQ(EvaluateFunction("DURATION", "P4DT4H5M6.2S").ValueDuration(), + memgraph::utils::Duration({4, 4, 5, 6, 0, 200000})); + EXPECT_EQ(EvaluateFunction("DURATION", "P3DT4H5M6.100S").ValueDuration(), + memgraph::utils::Duration({3, 4, 5, 6, 0, 100000})); + EXPECT_EQ(EvaluateFunction("DURATION", "P3DT4H5M6.100110S").ValueDuration(), + memgraph::utils::Duration({3, 4, 5, 6, 100, 110})); } } // namespace diff --git a/tests/unit/query_plan.cpp b/tests/unit/query_plan.cpp index 1fc190787..e5cc29296 100644 --- a/tests/unit/query_plan.cpp +++ b/tests/unit/query_plan.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -30,20 +30,20 @@ #include "query_common.hpp" -namespace query { +namespace memgraph::query { ::std::ostream &operator<<(::std::ostream &os, const Symbol &sym) { return os << "Symbol{\"" << sym.name() << "\" [" << sym.position() << "] " << Symbol::TypeToString(sym.type()) << "}"; } -} // namespace query +} // namespace memgraph::query -using namespace query::plan; -using query::AstStorage; -using query::SingleQuery; -using query::Symbol; -using query::SymbolGenerator; -using query::SymbolTable; -using Type = query::EdgeAtom::Type; -using Direction = query::EdgeAtom::Direction; +using namespace memgraph::query::plan; +using memgraph::query::AstStorage; +using memgraph::query::SingleQuery; +using memgraph::query::Symbol; +using memgraph::query::SymbolGenerator; +using memgraph::query::SymbolTable; +using Type = memgraph::query::EdgeAtom::Type; +using Direction = memgraph::query::EdgeAtom::Direction; using Bound = ScanAllByLabelPropertyRange::Bound; namespace { @@ -52,7 +52,7 @@ class Planner { public: template Planner(std::vector single_query_parts, PlanningContext context) { - query::Parameters parameters; + memgraph::query::Parameters parameters; PostProcessor post_processor(parameters); plan_ = MakeLogicalPlanForSingleQuery(single_query_parts, &context); plan_ = post_processor.Rewrite(std::move(plan_), &context); @@ -73,8 +73,8 @@ auto CheckPlan(LogicalOperator &plan, const SymbolTable &symbol_table, TChecker. } template -auto CheckPlan(query::CypherQuery *query, AstStorage &storage, TChecker... checker) { - auto symbol_table = query::MakeSymbolTable(query); +auto CheckPlan(memgraph::query::CypherQuery *query, AstStorage &storage, TChecker... checker) { + auto symbol_table = memgraph::query::MakeSymbolTable(query); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, checker...); @@ -98,7 +98,7 @@ TYPED_TEST(TestPlanner, MatchNodeReturn) { AstStorage storage; auto *as_n = NEXPR("n", IDENT("n")); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), RETURN(as_n))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectProduce()); @@ -109,7 +109,7 @@ TYPED_TEST(TestPlanner, CreateNodeReturn) { AstStorage storage; auto ident_n = IDENT("n"); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"))), RETURN(ident_n, AS("n")))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto acc = ExpectAccumulate({symbol_table.at(*ident_n)}); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); @@ -171,14 +171,14 @@ TYPED_TEST(TestPlanner, MatchLabeledNodes) { auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", label))), RETURN(as_n))); { // Without created label index - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectFilter(), ExpectProduce()); } { // With created label index dba.SetIndexCount(dba.Label(label), 0); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabel(), ExpectProduce()); } @@ -192,7 +192,7 @@ TYPED_TEST(TestPlanner, MatchPathReturn) { auto *as_n = NEXPR("n", IDENT("n")); auto *query = QUERY( SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r", Direction::BOTH, {relationship}), NODE("m"))), RETURN(as_n))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectExpand(), ExpectProduce()); } @@ -205,7 +205,7 @@ TYPED_TEST(TestPlanner, MatchNamedPatternReturn) { auto *as_p = NEXPR("p", IDENT("p")); auto *query = QUERY(SINGLE_QUERY( MATCH(NAMED_PATTERN("p", NODE("n"), EDGE("r", Direction::BOTH, {relationship}), NODE("m"))), RETURN(as_p))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectExpand(), ExpectConstructNamedPath(), ExpectProduce()); } @@ -219,7 +219,7 @@ TYPED_TEST(TestPlanner, MatchNamedPatternWithPredicateReturn) { auto *query = QUERY(SINGLE_QUERY(MATCH(NAMED_PATTERN("p", NODE("n"), EDGE("r", Direction::BOTH, {relationship}), NODE("m"))), WHERE(EQ(LITERAL(2), IDENT("p"))), RETURN(as_p))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectExpand(), ExpectConstructNamedPath(), ExpectFilter(), ExpectProduce()); @@ -234,7 +234,7 @@ TYPED_TEST(TestPlanner, OptionalMatchNamedPatternReturn) { auto pattern = NAMED_PATTERN("p", node_n, edge, node_m); auto as_p = AS("p"); auto *query = QUERY(SINGLE_QUERY(OPTIONAL_MATCH(pattern), RETURN("p", as_p))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto get_symbol = [&symbol_table](const auto *ast_node) { return symbol_table.at(*ast_node->identifier_); }; std::vector optional_symbols{get_symbol(pattern), get_symbol(node_n), get_symbol(edge), get_symbol(node_m)}; FakeDbAccessor dba; @@ -252,7 +252,7 @@ TYPED_TEST(TestPlanner, MatchWhereReturn) { auto *as_n = NEXPR("n", IDENT("n")); auto *query = QUERY( SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), WHERE(LESS(PROPERTY_LOOKUP("n", property), LITERAL(42))), RETURN(as_n))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectFilter(), ExpectProduce()); } @@ -331,7 +331,7 @@ TYPED_TEST(TestPlanner, MultiMatch) { auto *node_h = NODE("h"); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_n, edge_r, node_m)), MATCH(PATTERN(node_j, edge_e, node_i, edge_f, node_h)), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); // Multiple MATCH clauses form a Cartesian product, so the uniqueness should @@ -348,7 +348,7 @@ TYPED_TEST(TestPlanner, MultiMatchSameStart) { QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), RETURN(as_n))); // Similar to MatchMultiPatternSameStart, we expect only Expand from second // MATCH clause. - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectExpand(), ExpectProduce()); @@ -360,7 +360,7 @@ TYPED_TEST(TestPlanner, MatchWithReturn) { auto *as_new = NEXPR("new", IDENT("new")); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), WITH("old", AS("new")), RETURN(as_new))); // No accumulation since we only do reads. - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectProduce(), ExpectProduce()); @@ -375,7 +375,7 @@ TYPED_TEST(TestPlanner, MatchWithWhereReturn) { auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), WITH("old", AS("new")), WHERE(LESS(PROPERTY_LOOKUP("new", prop), LITERAL(42))), RETURN(as_new))); // No accumulation since we only do reads. - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectProduce(), ExpectFilter(), ExpectProduce()); } @@ -415,7 +415,7 @@ TYPED_TEST(TestPlanner, MatchReturnSum) { auto n_prop2 = PROPERTY_LOOKUP("n", prop2); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), RETURN(sum, AS("sum"), n_prop2, AS("group")))); auto aggr = ExpectAggregate({sum}, {n_prop2}); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), aggr, ExpectProduce()); } @@ -429,7 +429,7 @@ TYPED_TEST(TestPlanner, CreateWithSum) { auto n_prop = PROPERTY_LOOKUP(ident_n, prop); auto sum = SUM(n_prop); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"))), WITH(sum, AS("sum")))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto acc = ExpectAccumulate({symbol_table.at(*ident_n)}); auto aggr = ExpectAggregate({sum}, {}); auto planner = MakePlanner(&dba, storage, symbol_table, query); @@ -453,7 +453,7 @@ TYPED_TEST(TestPlanner, MatchReturnSkipLimit) { AstStorage storage; auto *as_n = NEXPR("n", IDENT("n")); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), RETURN(as_n, SKIP(LITERAL(2)), LIMIT(LITERAL(1))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectProduce(), ExpectSkip(), ExpectLimit()); @@ -465,7 +465,7 @@ TYPED_TEST(TestPlanner, CreateWithSkipReturnLimit) { auto ident_n = IDENT("n"); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"))), WITH(ident_n, AS("m"), SKIP(LITERAL(2))), RETURN("m", LIMIT(LITERAL(1))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto acc = ExpectAccumulate({symbol_table.at(*ident_n)}); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); @@ -488,7 +488,7 @@ TYPED_TEST(TestPlanner, CreateReturnSumSkipLimit) { auto sum = SUM(n_prop); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"))), RETURN(sum, AS("s"), SKIP(LITERAL(2)), LIMIT(LITERAL(1))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto acc = ExpectAccumulate({symbol_table.at(*ident_n)}); auto aggr = ExpectAggregate({sum}, {}); auto planner = MakePlanner(&dba, storage, symbol_table, query); @@ -504,7 +504,7 @@ TYPED_TEST(TestPlanner, MatchReturnOrderBy) { auto *node_n = NODE("n"); auto ret = RETURN(as_m, ORDER_BY(PROPERTY_LOOKUP("n", prop))); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_n)), ret)); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectProduce(), ExpectOrderBy()); } @@ -525,7 +525,7 @@ TYPED_TEST(TestPlanner, CreateWithOrderByWhere) { auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"), EDGE("r", Direction::OUT, {r_type}), NODE("m"))), WITH(ident_n, AS("new"), ORDER_BY(new_prop, r_prop)), WHERE(LESS(m_prop, LITERAL(42))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Since this is a write query, we expect to accumulate to old used symbols. auto acc = ExpectAccumulate({ symbol_table.at(*ident_n), // `n` in WITH @@ -563,7 +563,7 @@ TYPED_TEST(TestPlanner, MatchMerge) { RETURN(ident_n, AS("n")))); std::list on_match{new ExpectExpand(), new ExpectSetProperty()}; std::list on_create{new ExpectCreateExpand(), new ExpectSetProperties()}; - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // We expect Accumulate after Merge, because it is considered as a write. auto acc = ExpectAccumulate({symbol_table.at(*ident_n)}); auto planner = MakePlanner(&dba, storage, symbol_table, query); @@ -591,7 +591,7 @@ TYPED_TEST(TestPlanner, MatchUnwindReturn) { auto *as_x = NEXPR("x", IDENT("x")); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), UNWIND(LIST(LITERAL(1), LITERAL(2), LITERAL(3)), AS("x")), RETURN(as_n, as_x))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectUnwind(), ExpectProduce()); @@ -614,7 +614,7 @@ TYPED_TEST(TestPlanner, CreateWithDistinctSumWhereReturn) { auto sum = SUM(PROPERTY_LOOKUP("n", prop)); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(node_n)), WITH_DISTINCT(sum, AS("s")), WHERE(LESS(IDENT("s"), LITERAL(42))), RETURN("s"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto acc = ExpectAccumulate({symbol_table.at(*node_n->identifier_)}); auto aggr = ExpectAggregate({sum}, {}); auto planner = MakePlanner(&dba, storage, symbol_table, query); @@ -648,7 +648,7 @@ TYPED_TEST(TestPlanner, MatchWhereBeforeExpand) { auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), WHERE(LESS(PROPERTY_LOOKUP("n", prop), LITERAL(42))), RETURN(as_n))); // We expect Filter to come immediately after ScanAll, since it only uses `n`. - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectFilter(), ExpectExpand(), ExpectProduce()); } @@ -665,7 +665,7 @@ TYPED_TEST(TestPlanner, MatchFilterPropIsNotNull) { // Test MATCH (n :label) -[r]- (m) WHERE n.prop IS NOT NULL RETURN n auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"), EDGE("r"), NODE("m"))), WHERE(NOT(IS_NULL(PROPERTY_LOOKUP("n", prop)))), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); // We expect ScanAllByLabelProperty to come instead of ScanAll > Filter. CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelProperty(label, prop), ExpectExpand(), ExpectProduce()); @@ -675,7 +675,7 @@ TYPED_TEST(TestPlanner, MatchFilterPropIsNotNull) { // Test MATCH (n :label) -[r]- (m) WHERE n.prop IS NOT NULL OR true RETURN n auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"), EDGE("r"), NODE("m"))), WHERE(OR(NOT(IS_NULL(PROPERTY_LOOKUP("n", prop))), LITERAL(true))), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); // We expect ScanAllBy > Filter because of the "or true" condition. CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectFilter(), ExpectExpand(), ExpectProduce()); @@ -689,7 +689,7 @@ TYPED_TEST(TestPlanner, MatchFilterPropIsNotNull) { SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"), EDGE("r"), NODE("m"))), WHERE(AND(NOT(IS_NULL(PROPERTY_LOOKUP("n", prop))), EQ(PROPERTY_LOOKUP("n", prop_x), LITERAL(2)))), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); // We expect ScanAllByLabelProperty > Filter // to come instead of ScanAll > Filter. @@ -734,7 +734,7 @@ TYPED_TEST(TestPlanner, MatchReturnAsterisk) { auto ret = RETURN(PROPERTY_LOOKUP("m", prop), AS("m.prop")); ret->body_.all_identifiers = true; auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("e"), NODE("m"))), ret)); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectExpand(), ExpectProduce()); std::vector output_names; @@ -754,13 +754,13 @@ TYPED_TEST(TestPlanner, MatchReturnAsteriskSum) { auto ret = RETURN(sum, AS("s")); ret->body_.all_identifiers = true; auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), ret)); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); auto *produce = dynamic_cast(&planner.plan()); ASSERT_TRUE(produce); const auto &named_expressions = produce->named_expressions_; ASSERT_EQ(named_expressions.size(), 2); - auto *expanded_ident = dynamic_cast(named_expressions[0]->expression_); + auto *expanded_ident = dynamic_cast(named_expressions[0]->expression_); ASSERT_TRUE(expanded_ident); auto aggr = ExpectAggregate({sum}, {expanded_ident}); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), aggr, ExpectProduce()); @@ -799,7 +799,7 @@ TYPED_TEST(TestPlanner, UnwindMergeNodePropertyWithIndex) { auto *query = QUERY(SINGLE_QUERY(UNWIND(LIST(LITERAL(1)), AS("i")), MERGE(PATTERN(node_n)))); std::list on_match{new ExpectScanAllByLabelPropertyValue(label, property, IDENT("i"))}; std::list on_create{new ExpectCreateNode()}; - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectUnwind(), ExpectMerge(on_match, on_create)); DeleteListContent(&on_match); @@ -861,8 +861,8 @@ TYPED_TEST(TestPlanner, EmptyListIndexAggregation) { auto sum = SUM(LITERAL(2)); auto empty_list = LIST(); auto group_by_literal = LITERAL(42); - auto *query = QUERY(SINGLE_QUERY(RETURN(storage.Create(empty_list, sum), AS("result"), - group_by_literal, AS("group_by")))); + auto *query = QUERY(SINGLE_QUERY(RETURN(storage.Create(empty_list, sum), + AS("result"), group_by_literal, AS("group_by")))); // We expect to group by '42' and the empty list, because it is a // sub-expression of a binary operator which contains an aggregation. This is // similar to grouping by '1' in `RETURN 1 + SUM(2)`. @@ -931,7 +931,7 @@ TYPED_TEST(TestPlanner, AtomIndexedLabelProperty) { std::get<0>(node->properties_)[storage.GetPropertyIx(property.first)] = lit_42; std::get<0>(node->properties_)[storage.GetPropertyIx(not_indexed.first)] = LITERAL(0); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node)), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyValue(label, property, lit_42), ExpectFilter(), ExpectProduce()); @@ -948,13 +948,13 @@ TYPED_TEST(TestPlanner, AtomPropertyWhereLabelIndexing) { auto node = NODE("n"); auto lit_42 = LITERAL(42); std::get<0>(node->properties_)[storage.GetPropertyIx(property.first)] = lit_42; - auto *query = - QUERY(SINGLE_QUERY(MATCH(PATTERN(node)), - WHERE(AND(PROPERTY_LOOKUP("n", not_indexed), - storage.Create( - IDENT("n"), std::vector{storage.GetLabelIx("label")}))), - RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto *query = QUERY( + SINGLE_QUERY(MATCH(PATTERN(node)), + WHERE(AND(PROPERTY_LOOKUP("n", not_indexed), + storage.Create( + IDENT("n"), std::vector{storage.GetLabelIx("label")}))), + RETURN("n"))); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyValue(label, property, lit_42), ExpectFilter(), ExpectProduce()); @@ -970,7 +970,7 @@ TYPED_TEST(TestPlanner, WhereIndexedLabelProperty) { auto lit_42 = LITERAL(42); auto *query = QUERY( SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(EQ(PROPERTY_LOOKUP("n", property), lit_42)), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyValue(label, property, lit_42), ExpectProduce()); } @@ -991,7 +991,7 @@ TYPED_TEST(TestPlanner, BestPropertyIndexed) { SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(AND(EQ(PROPERTY_LOOKUP("n", property), LITERAL(1)), EQ(PROPERTY_LOOKUP("n", better), lit_42))), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyValue(label, better, lit_42), ExpectFilter(), ExpectProduce()); @@ -1013,7 +1013,7 @@ TYPED_TEST(TestPlanner, MultiPropertyIndexScan) { auto *query = QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n", "label1")), PATTERN(NODE("m", "label2"))), WHERE(AND(EQ(PROPERTY_LOOKUP("n", prop1), lit_1), EQ(PROPERTY_LOOKUP("m", prop2), lit_2))), RETURN("n", "m"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyValue(label1, prop1, lit_1), ExpectScanAllByLabelPropertyValue(label2, prop2, lit_2), ExpectProduce()); @@ -1035,14 +1035,14 @@ TYPED_TEST(TestPlanner, WhereIndexedLabelPropertyRange) { storage.GetLabelIx("label"); storage.GetPropertyIx("property"); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(rel_expr), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyRange(label, property, lower_bound, upper_bound), ExpectProduce()); }; { // Test relation operators which form an upper bound for range. - std::vector> upper_bound_rel_op{ + std::vector> upper_bound_rel_op{ std::make_pair(LESS(n_prop, lit_42), Bound::Type::EXCLUSIVE), std::make_pair(LESS_EQ(n_prop, lit_42), Bound::Type::INCLUSIVE), std::make_pair(GREATER(lit_42, n_prop), Bound::Type::EXCLUSIVE), @@ -1053,7 +1053,7 @@ TYPED_TEST(TestPlanner, WhereIndexedLabelPropertyRange) { } { // Test relation operators which form a lower bound for range. - std::vector> lower_bound_rel_op{ + std::vector> lower_bound_rel_op{ std::make_pair(LESS(lit_42, n_prop), Bound::Type::EXCLUSIVE), std::make_pair(LESS_EQ(lit_42, n_prop), Bound::Type::INCLUSIVE), std::make_pair(GREATER(n_prop, lit_42), Bound::Type::EXCLUSIVE), @@ -1076,7 +1076,7 @@ TYPED_TEST(TestPlanner, WherePreferEqualityIndexOverRange) { MATCH(PATTERN(NODE("n", "label"))), WHERE(AND(EQ(PROPERTY_LOOKUP("n", property), lit_42), GREATER(PROPERTY_LOOKUP("n", property), LITERAL(0)))), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyValue(label, property, lit_42), ExpectFilter(), ExpectProduce()); @@ -1093,7 +1093,7 @@ TYPED_TEST(TestPlanner, UnableToUsePropertyIndex) { auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(EQ(PROPERTY_LOOKUP("n", property), PROPERTY_LOOKUP("n", property))), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); // We can only get ScanAllByLabelIndex, because we are comparing properties // with those on the same node. @@ -1112,7 +1112,7 @@ TYPED_TEST(TestPlanner, SecondPropertyIndex) { auto m_prop = PROPERTY_LOOKUP("m", property); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label")), PATTERN(NODE("m", "label"))), WHERE(EQ(m_prop, n_prop)), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabel(), // Note: We are scanning for m, therefore property should equal n_prop. @@ -1181,7 +1181,7 @@ TYPED_TEST(TestPlanner, MatchExpandVariableTotalWeightSymbol) { auto edge = EDGE_VARIABLE("r", Type::WEIGHTED_SHORTEST_PATH, Direction::BOTH, {}, nullptr, nullptr, nullptr, nullptr, nullptr, IDENT("total_weight")); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), RETURN("*"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); auto *root = dynamic_cast(&planner.plan()); @@ -1194,10 +1194,10 @@ TYPED_TEST(TestPlanner, MatchExpandVariableTotalWeightSymbol) { std::transform(nes.begin(), nes.end(), names.begin(), [](const auto *ne) { return ne->name_; }); EXPECT_TRUE(root->named_expressions_.size() == 4); - EXPECT_TRUE(utils::Contains(names, "m")); - EXPECT_TRUE(utils::Contains(names, "n")); - EXPECT_TRUE(utils::Contains(names, "r")); - EXPECT_TRUE(utils::Contains(names, "total_weight")); + EXPECT_TRUE(memgraph::utils::Contains(names, "m")); + EXPECT_TRUE(memgraph::utils::Contains(names, "n")); + EXPECT_TRUE(memgraph::utils::Contains(names, "r")); + EXPECT_TRUE(memgraph::utils::Contains(names, "total_weight")); } TYPED_TEST(TestPlanner, UnwindMatchVariable) { @@ -1216,15 +1216,16 @@ TYPED_TEST(TestPlanner, MatchBfs) { FakeDbAccessor dba; AstStorage storage; auto edge_type = storage.GetEdgeTypeIx("type"); - auto *bfs = storage.Create(IDENT("r"), query::EdgeAtom::Type::BREADTH_FIRST, Direction::OUT, - std::vector{edge_type}); + auto *bfs = + storage.Create(IDENT("r"), memgraph::query::EdgeAtom::Type::BREADTH_FIRST, + Direction::OUT, std::vector{edge_type}); bfs->filter_lambda_.inner_edge = IDENT("r"); bfs->filter_lambda_.inner_node = IDENT("n"); bfs->filter_lambda_.expression = IDENT("n"); bfs->upper_bound_ = LITERAL(10); auto *as_r = NEXPR("r", IDENT("r")); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), bfs, NODE("m"))), RETURN(as_r))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectExpandBfs(), ExpectProduce()); } @@ -1236,7 +1237,7 @@ TYPED_TEST(TestPlanner, MatchDoubleScanToExpandExisting) { dba.SetIndexCount(dba.Label(label), 0); AstStorage storage; auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m", label))), RETURN("r"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); // We expect 2x ScanAll and then Expand, since we are guessing that is // faster (due to low label index vertex count). @@ -1255,7 +1256,7 @@ TYPED_TEST(TestPlanner, MatchScanToExpand) { auto node_m = NODE("m", "label"); std::get<0>(node_m->properties_)[storage.GetPropertyIx("property")] = LITERAL(1); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), node_m)), RETURN("r"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); // We expect 1x ScanAll and then Expand, since we are guessing that // is faster (due to high label index vertex count). @@ -1281,10 +1282,10 @@ TYPED_TEST(TestPlanner, ReturnAsteriskOmitsLambdaSymbols) { edge->filter_lambda_.inner_edge = IDENT("ie"); edge->filter_lambda_.inner_node = IDENT("in"); edge->filter_lambda_.expression = LITERAL(true); - auto ret = storage.Create(); + auto ret = storage.Create(); ret->body_.all_identifiers = true; auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), ret)); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); FakeDbAccessor dba; auto planner = MakePlanner(&dba, storage, symbol_table, query); auto *produce = dynamic_cast(&planner.plan()); @@ -1296,7 +1297,7 @@ TYPED_TEST(TestPlanner, ReturnAsteriskOmitsLambdaSymbols) { // We expect `*` expanded to `n`, `r` and `m`. EXPECT_EQ(outputs.size(), 3); for (const auto &name : {"n", "r", "m"}) { - EXPECT_TRUE(utils::Contains(outputs, name)); + EXPECT_TRUE(memgraph::utils::Contains(outputs, name)); } } @@ -1308,13 +1309,13 @@ TYPED_TEST(TestPlanner, FilterRegexMatchIndex) { auto label = dba.Label("label"); dba.SetIndexCount(label, 0); dba.SetIndexCount(label, prop, 0); - auto *regex_match = storage.Create(PROPERTY_LOOKUP("n", prop), LITERAL("regex")); + auto *regex_match = storage.Create(PROPERTY_LOOKUP("n", prop), LITERAL("regex")); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(regex_match), RETURN("n"))); // We expect that we use index by property range where lower bound is an empty // string. Filter must still remain in place, because we don't have regex // based index. Bound lower_bound(LITERAL(""), Bound::Type::INCLUSIVE); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyRange(label, prop, lower_bound, std::nullopt), ExpectFilter(), ExpectProduce()); @@ -1328,13 +1329,13 @@ TYPED_TEST(TestPlanner, FilterRegexMatchPreferEqualityIndex) { auto label = dba.Label("label"); dba.SetIndexCount(label, 0); dba.SetIndexCount(label, prop.second, 0); - auto *regex_match = storage.Create(PROPERTY_LOOKUP("n", prop), LITERAL("regex")); + auto *regex_match = storage.Create(PROPERTY_LOOKUP("n", prop), LITERAL("regex")); auto *lit_42 = LITERAL(42); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(AND(regex_match, EQ(PROPERTY_LOOKUP("n", prop), lit_42))), RETURN("n"))); // We expect that we use index by property value equal to 42, because that's // much better than property range for regex matching. - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyValue(label, prop, lit_42), ExpectFilter(), ExpectProduce()); @@ -1349,7 +1350,7 @@ TYPED_TEST(TestPlanner, FilterRegexMatchPreferEqualityIndex2) { auto label = dba.Label("label"); dba.SetIndexCount(label, 0); dba.SetIndexCount(label, prop.second, 0); - auto *regex_match = storage.Create(PROPERTY_LOOKUP("n", prop), LITERAL("regex")); + auto *regex_match = storage.Create(PROPERTY_LOOKUP("n", prop), LITERAL("regex")); auto *lit_42 = LITERAL(42); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(AND(AND(regex_match, EQ(PROPERTY_LOOKUP("n", prop), lit_42)), @@ -1357,7 +1358,7 @@ TYPED_TEST(TestPlanner, FilterRegexMatchPreferEqualityIndex2) { RETURN("n"))); // We expect that we use index by property value equal to 42, because that's // much better than property range. - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyValue(label, prop, lit_42), ExpectFilter(), ExpectProduce()); @@ -1371,14 +1372,14 @@ TYPED_TEST(TestPlanner, FilterRegexMatchPreferRangeIndex) { auto label = dba.Label("label"); dba.SetIndexCount(label, 0); dba.SetIndexCount(label, prop, 0); - auto *regex_match = storage.Create(PROPERTY_LOOKUP("n", prop), LITERAL("regex")); + auto *regex_match = storage.Create(PROPERTY_LOOKUP("n", prop), LITERAL("regex")); auto *lit_42 = LITERAL(42); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(AND(regex_match, GREATER(PROPERTY_LOOKUP("n", prop), lit_42))), RETURN("n"))); // We expect that we use index by property range on a concrete value (42), as // it is much better than using a range from empty string for regex matching. Bound lower_bound(lit_42, Bound::Type::EXCLUSIVE); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabelPropertyRange(label, prop, lower_bound, std::nullopt), ExpectFilter(), ExpectProduce()); @@ -1387,13 +1388,13 @@ TYPED_TEST(TestPlanner, FilterRegexMatchPreferRangeIndex) { TYPED_TEST(TestPlanner, CallProcedureStandalone) { // Test CALL proc(1,2,3) YIELD field AS result AstStorage storage; - auto *ast_call = storage.Create(); + auto *ast_call = storage.Create(); ast_call->procedure_name_ = "proc"; ast_call->arguments_ = {LITERAL(1), LITERAL(2), LITERAL(3)}; ast_call->result_fields_ = {"field"}; ast_call->result_identifiers_ = {IDENT("result")}; auto *query = QUERY(SINGLE_QUERY(ast_call)); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); std::vector result_syms; result_syms.reserve(ast_call->result_identifiers_.size()); for (const auto *ident : ast_call->result_identifiers_) { @@ -1409,13 +1410,13 @@ TYPED_TEST(TestPlanner, CallProcedureStandalone) { TYPED_TEST(TestPlanner, CallProcedureAfterScanAll) { // Test MATCH (n) CALL proc(n) YIELD field AS result RETURN result AstStorage storage; - auto *ast_call = storage.Create(); + auto *ast_call = storage.Create(); ast_call->procedure_name_ = "proc"; ast_call->arguments_ = {IDENT("n")}; ast_call->result_fields_ = {"field"}; ast_call->result_identifiers_ = {IDENT("result")}; auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), ast_call, RETURN("result"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); std::vector result_syms; result_syms.reserve(ast_call->result_identifiers_.size()); for (const auto *ident : ast_call->result_identifiers_) { @@ -1431,7 +1432,7 @@ TYPED_TEST(TestPlanner, CallProcedureAfterScanAll) { TYPED_TEST(TestPlanner, CallProcedureBeforeScanAll) { // Test CALL proc() YIELD field MATCH (n) WHERE n.prop = field RETURN n AstStorage storage; - auto *ast_call = storage.Create(); + auto *ast_call = storage.Create(); ast_call->procedure_name_ = "proc"; ast_call->result_fields_ = {"field"}; ast_call->result_identifiers_ = {IDENT("field")}; @@ -1439,7 +1440,7 @@ TYPED_TEST(TestPlanner, CallProcedureBeforeScanAll) { auto property = dba.Property("prop"); auto *query = QUERY(SINGLE_QUERY(ast_call, MATCH(PATTERN(NODE("n"))), WHERE(EQ(PROPERTY_LOOKUP("n", property), IDENT("field"))), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); std::vector result_syms; result_syms.reserve(ast_call->result_identifiers_.size()); for (const auto *ident : ast_call->result_identifiers_) { @@ -1470,7 +1471,8 @@ TYPED_TEST(TestPlanner, ScanAllByIdExpandToExisting) { TYPED_TEST(TestPlanner, BfsToExisting) { // Test MATCH (n)-[r *bfs]-(m) WHERE id(m) = 42 RETURN r AstStorage storage; - auto *bfs = storage.Create(IDENT("r"), query::EdgeAtom::Type::BREADTH_FIRST, Direction::BOTH); + auto *bfs = storage.Create(IDENT("r"), memgraph::query::EdgeAtom::Type::BREADTH_FIRST, + Direction::BOTH); bfs->filter_lambda_.inner_edge = IDENT("ie"); bfs->filter_lambda_.inner_node = IDENT("in"); bfs->filter_lambda_.expression = LITERAL(true); @@ -1489,19 +1491,19 @@ TYPED_TEST(TestPlanner, LabelPropertyInListValidOptimization) { auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(IN_LIST(PROPERTY_LOOKUP("n", property), lit_list_a)), RETURN("n"))); { - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectFilter(), ExpectProduce()); } { dba.SetIndexCount(label, 1); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabel(), ExpectFilter(), ExpectProduce()); } { dba.SetIndexCount(label, property.second, 1); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectUnwind(), ExpectScanAllByLabelPropertyValue(label, property, lit_list_a), ExpectProduce()); @@ -1519,7 +1521,7 @@ TYPED_TEST(TestPlanner, LabelPropertyInListWhereLabelPropertyOnLeftNotListOnRigh WHERE(IN_LIST(PROPERTY_LOOKUP("n", property), lit_a)), RETURN("n"))); { dba.SetIndexCount(label, property.second, 1); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectFilter(), ExpectProduce()); } @@ -1535,19 +1537,19 @@ TYPED_TEST(TestPlanner, LabelPropertyInListWhereLabelPropertyOnRight) { auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", "label"))), WHERE(IN_LIST(lit_list_a, PROPERTY_LOOKUP("n", property))), RETURN("n"))); { - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAll(), ExpectFilter(), ExpectProduce()); } { dba.SetIndexCount(label, 1); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabel(), ExpectFilter(), ExpectProduce()); } { dba.SetIndexCount(label, property.second, 1); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); CheckPlan(planner.plan(), symbol_table, ExpectScanAllByLabel(), ExpectFilter(), ExpectProduce()); } diff --git a/tests/unit/query_plan_accumulate_aggregate.cpp b/tests/unit/query_plan_accumulate_aggregate.cpp index 5f03688ea..04bd1cc44 100644 --- a/tests/unit/query_plan_accumulate_aggregate.cpp +++ b/tests/unit/query_plan_accumulate_aggregate.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,10 +22,10 @@ #include "query/plan/operator.hpp" #include "query_plan_common.hpp" -using namespace query; -using namespace query::plan; -using query::test_common::ToIntList; -using query::test_common::ToIntMap; +using namespace memgraph::query; +using namespace memgraph::query::plan; +using memgraph::query::test_common::ToIntList; +using memgraph::query::test_common::ToIntMap; using testing::UnorderedElementsAre; TEST(QueryPlan, Accumulate) { @@ -36,15 +36,15 @@ TEST(QueryPlan, Accumulate) { // with accumulation we expect them to be [[2, 2], [2, 2]] auto check = [&](bool accumulate) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto prop = dba.NameToProperty("x"); auto v1 = dba.InsertVertex(); - ASSERT_TRUE(v1.SetProperty(prop, storage::PropertyValue(0)).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop, memgraph::storage::PropertyValue(0)).HasValue()); auto v2 = dba.InsertVertex(); - ASSERT_TRUE(v2.SetProperty(prop, storage::PropertyValue(0)).HasValue()); + ASSERT_TRUE(v2.SetProperty(prop, memgraph::storage::PropertyValue(0)).HasValue()); ASSERT_TRUE(dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("T")).HasValue()); dba.AdvanceCommand(); @@ -53,7 +53,7 @@ TEST(QueryPlan, Accumulate) { auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::BOTH, {}, "m", false, - storage::View::OLD); + memgraph::storage::View::OLD); auto one = LITERAL(1); auto n_p = PROPERTY_LOOKUP(IDENT("n")->MapTo(n.sym_), prop); @@ -88,9 +88,9 @@ TEST(QueryPlan, AccumulateAdvance) { // we simulate 'CREATE (n) WITH n AS n MATCH (m) RETURN m' // to get correct results we need to advance the command auto check = [&](bool advance) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; NodeCreationInfo node; @@ -140,10 +140,10 @@ std::shared_ptr MakeAggregationProduce(std::shared_ptr /** Test fixture for all the aggregation ops in one return. */ class QueryPlanAggregateOps : public ::testing::Test { protected: - storage::Storage db; - storage::Storage::Accessor storage_dba{db.Access()}; - query::DbAccessor dba{&storage_dba}; - storage::PropertyId prop = db.NameToProperty("prop"); + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor storage_dba{db.Access()}; + memgraph::query::DbAccessor dba{&storage_dba}; + memgraph::storage::PropertyId prop = db.NameToProperty("prop"); AstStorage storage; SymbolTable symbol_table; @@ -152,9 +152,9 @@ class QueryPlanAggregateOps : public ::testing::Test { // setup is several nodes most of which have an int property set // we will take the sum, avg, min, max and count // we won't group by anything - ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, storage::PropertyValue(5)).HasValue()); - ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, storage::PropertyValue(7)).HasValue()); - ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, storage::PropertyValue(12)).HasValue()); + ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, memgraph::storage::PropertyValue(5)).HasValue()); + ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, memgraph::storage::PropertyValue(7)).HasValue()); + ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, memgraph::storage::PropertyValue(12)).HasValue()); // a missing property (null) gets ignored by all aggregations except // COUNT(*) dba.InsertVertex(); @@ -275,13 +275,13 @@ TEST(QueryPlan, AggregateGroupByValues) { // Tests that distinct groups are aggregated properly for values of all types. // Also test the "remember" part of the Aggregation API as final results are // obtained via a property lookup of a remembered node. - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); - // a vector of storage::PropertyValue to be set as property values on vertices + // a vector of memgraph::storage::PropertyValue to be set as property values on vertices // most of them should result in a distinct group (commented where not) - std::vector group_by_vals; + std::vector group_by_vals; group_by_vals.emplace_back(4); group_by_vals.emplace_back(7); group_by_vals.emplace_back(7.3); @@ -291,15 +291,17 @@ TEST(QueryPlan, AggregateGroupByValues) { group_by_vals.emplace_back("1"); group_by_vals.emplace_back(true); group_by_vals.emplace_back(false); - group_by_vals.emplace_back(std::vector{storage::PropertyValue(1)}); - group_by_vals.emplace_back(std::vector{storage::PropertyValue(1), storage::PropertyValue(2)}); - group_by_vals.emplace_back(std::vector{storage::PropertyValue(2), storage::PropertyValue(1)}); - group_by_vals.emplace_back(storage::PropertyValue()); + group_by_vals.emplace_back(std::vector{memgraph::storage::PropertyValue(1)}); + group_by_vals.emplace_back(std::vector{memgraph::storage::PropertyValue(1), + memgraph::storage::PropertyValue(2)}); + group_by_vals.emplace_back(std::vector{memgraph::storage::PropertyValue(2), + memgraph::storage::PropertyValue(1)}); + group_by_vals.emplace_back(memgraph::storage::PropertyValue()); // should NOT result in another group because 7.0 == 7 group_by_vals.emplace_back(7.0); // should NOT result in another group - group_by_vals.emplace_back( - std::vector{storage::PropertyValue(1), storage::PropertyValue(2.0)}); + group_by_vals.emplace_back(std::vector{memgraph::storage::PropertyValue(1), + memgraph::storage::PropertyValue(2.0)}); // generate a lot of vertices and set props on them auto prop = dba.NameToProperty("prop"); @@ -336,18 +338,18 @@ TEST(QueryPlan, AggregateMultipleGroupBy) { // in this test we have 3 different properties that have different values // for different records and assert that we get the correct combination // of values in our groups - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto prop1 = dba.NameToProperty("prop1"); auto prop2 = dba.NameToProperty("prop2"); auto prop3 = dba.NameToProperty("prop3"); for (int i = 0; i < 2 * 3 * 5; ++i) { auto v = dba.InsertVertex(); - ASSERT_TRUE(v.SetProperty(prop1, storage::PropertyValue(static_cast(i % 2))).HasValue()); - ASSERT_TRUE(v.SetProperty(prop2, storage::PropertyValue(i % 3)).HasValue()); - ASSERT_TRUE(v.SetProperty(prop3, storage::PropertyValue("value" + std::to_string(i % 5))).HasValue()); + ASSERT_TRUE(v.SetProperty(prop1, memgraph::storage::PropertyValue(static_cast(i % 2))).HasValue()); + ASSERT_TRUE(v.SetProperty(prop2, memgraph::storage::PropertyValue(i % 3)).HasValue()); + ASSERT_TRUE(v.SetProperty(prop3, memgraph::storage::PropertyValue("value" + std::to_string(i % 5))).HasValue()); } dba.AdvanceCommand(); @@ -369,9 +371,9 @@ TEST(QueryPlan, AggregateMultipleGroupBy) { } TEST(QueryPlan, AggregateNoInput) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -394,9 +396,9 @@ TEST(QueryPlan, AggregateCountEdgeCases) { // - 2 vertices in database, property set on one // - 2 vertices in database, property set on both - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto prop = dba.NameToProperty("prop"); AstStorage storage; @@ -427,8 +429,8 @@ TEST(QueryPlan, AggregateCountEdgeCases) { EXPECT_EQ(0, count()); // one vertex, property set - for (auto va : dba.Vertices(storage::View::OLD)) - ASSERT_TRUE(va.SetProperty(prop, storage::PropertyValue(42)).HasValue()); + for (auto va : dba.Vertices(memgraph::storage::View::OLD)) + ASSERT_TRUE(va.SetProperty(prop, memgraph::storage::PropertyValue(42)).HasValue()); dba.AdvanceCommand(); EXPECT_EQ(1, count()); @@ -438,8 +440,8 @@ TEST(QueryPlan, AggregateCountEdgeCases) { EXPECT_EQ(1, count()); // two vertices, both with property set - for (auto va : dba.Vertices(storage::View::OLD)) - ASSERT_TRUE(va.SetProperty(prop, storage::PropertyValue(42)).HasValue()); + for (auto va : dba.Vertices(memgraph::storage::View::OLD)) + ASSERT_TRUE(va.SetProperty(prop, memgraph::storage::PropertyValue(42)).HasValue()); dba.AdvanceCommand(); EXPECT_EQ(2, count()); } @@ -448,15 +450,15 @@ TEST(QueryPlan, AggregateFirstValueTypes) { // testing exceptions that get emitted by the first-value // type check - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v1 = dba.InsertVertex(); auto prop_string = dba.NameToProperty("string"); - ASSERT_TRUE(v1.SetProperty(prop_string, storage::PropertyValue("johhny")).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop_string, memgraph::storage::PropertyValue("johhny")).HasValue()); auto prop_int = dba.NameToProperty("int"); - ASSERT_TRUE(v1.SetProperty(prop_int, storage::PropertyValue(12)).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop_int, memgraph::storage::PropertyValue(12)).HasValue()); dba.AdvanceCommand(); AstStorage storage; @@ -502,16 +504,16 @@ TEST(QueryPlan, AggregateTypes) { // does not check all combinations that can result in an exception // (that logic is defined and tested by TypedValue) - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto p1 = dba.NameToProperty("p1"); // has only string props - ASSERT_TRUE(dba.InsertVertex().SetProperty(p1, storage::PropertyValue("string")).HasValue()); - ASSERT_TRUE(dba.InsertVertex().SetProperty(p1, storage::PropertyValue("str2")).HasValue()); + ASSERT_TRUE(dba.InsertVertex().SetProperty(p1, memgraph::storage::PropertyValue("string")).HasValue()); + ASSERT_TRUE(dba.InsertVertex().SetProperty(p1, memgraph::storage::PropertyValue("str2")).HasValue()); auto p2 = dba.NameToProperty("p2"); // combines int and bool - ASSERT_TRUE(dba.InsertVertex().SetProperty(p2, storage::PropertyValue(42)).HasValue()); - ASSERT_TRUE(dba.InsertVertex().SetProperty(p2, storage::PropertyValue(true)).HasValue()); + ASSERT_TRUE(dba.InsertVertex().SetProperty(p2, memgraph::storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(dba.InsertVertex().SetProperty(p2, memgraph::storage::PropertyValue(true)).HasValue()); dba.AdvanceCommand(); AstStorage storage; @@ -557,18 +559,20 @@ TEST(QueryPlan, AggregateTypes) { } TEST(QueryPlan, Unwind) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; // UNWIND [ [1, true, "x"], [], ["bla"] ] AS x UNWIND x as y RETURN x, y - auto input_expr = storage.Create(std::vector{ - storage::PropertyValue(std::vector{ - storage::PropertyValue(1), storage::PropertyValue(true), storage::PropertyValue("x")}), - storage::PropertyValue(std::vector{}), - storage::PropertyValue(std::vector{storage::PropertyValue("bla")})}); + auto input_expr = storage.Create(std::vector{ + memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(1), memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue("x")}), + memgraph::storage::PropertyValue(std::vector{}), + memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue("bla")})}); auto x = symbol_table.CreateSymbol("x", true); auto unwind_0 = std::make_shared(nullptr, input_expr, x); diff --git a/tests/unit/query_plan_bag_semantics.cpp b/tests/unit/query_plan_bag_semantics.cpp index 18672a190..f0b0916f4 100644 --- a/tests/unit/query_plan_bag_semantics.cpp +++ b/tests/unit/query_plan_bag_semantics.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -28,13 +28,13 @@ #include "query_plan_common.hpp" -using namespace query; -using namespace query::plan; +using namespace memgraph::query; +using namespace memgraph::query::plan; TEST(QueryPlan, Skip) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -63,9 +63,9 @@ TEST(QueryPlan, Skip) { } TEST(QueryPlan, Limit) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -97,9 +97,9 @@ TEST(QueryPlan, CreateLimit) { // CREATE (n), (m) // MATCH (n) CREATE (m) LIMIT 1 // in the end we need to have 3 vertices in the db - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); dba.InsertVertex(); dba.InsertVertex(); dba.AdvanceCommand(); @@ -116,46 +116,50 @@ TEST(QueryPlan, CreateLimit) { auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(1, PullAll(*skip, &context)); dba.AdvanceCommand(); - EXPECT_EQ(3, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(3, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); } TEST(QueryPlan, OrderBy) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; auto prop = dba.NameToProperty("prop"); // contains a series of tests // each test defines the ordering a vector of values in the desired order - auto Null = storage::PropertyValue(); - std::vector>> orderable{ + auto Null = memgraph::storage::PropertyValue(); + std::vector>> orderable{ {Ordering::ASC, - {storage::PropertyValue(0), storage::PropertyValue(0), storage::PropertyValue(0.5), storage::PropertyValue(1), - storage::PropertyValue(2), storage::PropertyValue(12.6), storage::PropertyValue(42), Null, Null}}, + {memgraph::storage::PropertyValue(0), memgraph::storage::PropertyValue(0), memgraph::storage::PropertyValue(0.5), + memgraph::storage::PropertyValue(1), memgraph::storage::PropertyValue(2), + memgraph::storage::PropertyValue(12.6), memgraph::storage::PropertyValue(42), Null, Null}}, {Ordering::ASC, - {storage::PropertyValue(false), storage::PropertyValue(false), storage::PropertyValue(true), - storage::PropertyValue(true), Null, Null}}, + {memgraph::storage::PropertyValue(false), memgraph::storage::PropertyValue(false), + memgraph::storage::PropertyValue(true), memgraph::storage::PropertyValue(true), Null, Null}}, {Ordering::ASC, - {storage::PropertyValue("A"), storage::PropertyValue("B"), storage::PropertyValue("a"), - storage::PropertyValue("a"), storage::PropertyValue("aa"), storage::PropertyValue("ab"), - storage::PropertyValue("aba"), Null, Null}}, + {memgraph::storage::PropertyValue("A"), memgraph::storage::PropertyValue("B"), + memgraph::storage::PropertyValue("a"), memgraph::storage::PropertyValue("a"), + memgraph::storage::PropertyValue("aa"), memgraph::storage::PropertyValue("ab"), + memgraph::storage::PropertyValue("aba"), Null, Null}}, {Ordering::DESC, - {Null, Null, storage::PropertyValue(33), storage::PropertyValue(33), storage::PropertyValue(32.5), - storage::PropertyValue(32), storage::PropertyValue(2.2), storage::PropertyValue(2.1), - storage::PropertyValue(0)}}, - {Ordering::DESC, {Null, storage::PropertyValue(true), storage::PropertyValue(false)}}, - {Ordering::DESC, {Null, storage::PropertyValue("zorro"), storage::PropertyValue("borro")}}}; + {Null, Null, memgraph::storage::PropertyValue(33), memgraph::storage::PropertyValue(33), + memgraph::storage::PropertyValue(32.5), memgraph::storage::PropertyValue(32), + memgraph::storage::PropertyValue(2.2), memgraph::storage::PropertyValue(2.1), + memgraph::storage::PropertyValue(0)}}, + {Ordering::DESC, {Null, memgraph::storage::PropertyValue(true), memgraph::storage::PropertyValue(false)}}, + {Ordering::DESC, {Null, memgraph::storage::PropertyValue("zorro"), memgraph::storage::PropertyValue("borro")}}}; for (const auto &order_value_pair : orderable) { std::vector values; values.reserve(order_value_pair.second.size()); for (const auto &v : order_value_pair.second) values.emplace_back(v); // empty database - for (auto vertex : dba.Vertices(storage::View::OLD)) ASSERT_TRUE(dba.DetachRemoveVertex(&vertex).HasValue()); + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) + ASSERT_TRUE(dba.DetachRemoveVertex(&vertex).HasValue()); dba.AdvanceCommand(); - ASSERT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD))); + ASSERT_EQ(0, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); // take some effort to shuffle the values // because we are testing that something not ordered gets ordered @@ -171,7 +175,7 @@ TEST(QueryPlan, OrderBy) { // create the vertices for (const auto &value : shuffled) - ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, storage::PropertyValue(value)).HasValue()); + ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, memgraph::storage::PropertyValue(value)).HasValue()); dba.AdvanceCommand(); // order by and collect results @@ -189,9 +193,9 @@ TEST(QueryPlan, OrderBy) { } TEST(QueryPlan, OrderByMultiple) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -208,8 +212,8 @@ TEST(QueryPlan, OrderByMultiple) { std::random_shuffle(prop_values.begin(), prop_values.end()); for (const auto &pair : prop_values) { auto v = dba.InsertVertex(); - ASSERT_TRUE(v.SetProperty(p1, storage::PropertyValue(pair.first)).HasValue()); - ASSERT_TRUE(v.SetProperty(p2, storage::PropertyValue(pair.second)).HasValue()); + ASSERT_TRUE(v.SetProperty(p1, memgraph::storage::PropertyValue(pair.first)).HasValue()); + ASSERT_TRUE(v.SetProperty(p2, memgraph::storage::PropertyValue(pair.second)).HasValue()); } dba.AdvanceCommand(); @@ -243,42 +247,49 @@ TEST(QueryPlan, OrderByMultiple) { } TEST(QueryPlan, OrderByExceptions) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; auto prop = dba.NameToProperty("prop"); // a vector of pairs of typed values that should result // in an exception when trying to order on them - std::vector> exception_pairs{ - {storage::PropertyValue(42), storage::PropertyValue(true)}, - {storage::PropertyValue(42), storage::PropertyValue("bla")}, - {storage::PropertyValue(42), - storage::PropertyValue(std::vector{storage::PropertyValue(42)})}, - {storage::PropertyValue(true), storage::PropertyValue("bla")}, - {storage::PropertyValue(true), - storage::PropertyValue(std::vector{storage::PropertyValue(true)})}, - {storage::PropertyValue("bla"), - storage::PropertyValue(std::vector{storage::PropertyValue("bla")})}, + std::vector> exception_pairs{ + {memgraph::storage::PropertyValue(42), memgraph::storage::PropertyValue(true)}, + {memgraph::storage::PropertyValue(42), memgraph::storage::PropertyValue("bla")}, + {memgraph::storage::PropertyValue(42), + memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(42)})}, + {memgraph::storage::PropertyValue(true), memgraph::storage::PropertyValue("bla")}, + {memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(true)})}, + {memgraph::storage::PropertyValue("bla"), + memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue("bla")})}, // illegal comparisons of same-type values - {storage::PropertyValue(std::vector{storage::PropertyValue(42)}), - storage::PropertyValue(std::vector{storage::PropertyValue(42)})}}; + {memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(42)}), + memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(42)})}}; for (const auto &pair : exception_pairs) { // empty database - for (auto vertex : dba.Vertices(storage::View::OLD)) ASSERT_TRUE(dba.DetachRemoveVertex(&vertex).HasValue()); + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) + ASSERT_TRUE(dba.DetachRemoveVertex(&vertex).HasValue()); dba.AdvanceCommand(); - ASSERT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD))); + ASSERT_EQ(0, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); // make two vertices, and set values ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, pair.first).HasValue()); ASSERT_TRUE(dba.InsertVertex().SetProperty(prop, pair.second).HasValue()); dba.AdvanceCommand(); - ASSERT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD))); - for (const auto &va : dba.Vertices(storage::View::OLD)) - ASSERT_NE(va.GetProperty(storage::View::OLD, prop).GetValue().type(), storage::PropertyValue::Type::Null); + ASSERT_EQ(2, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + for (const auto &va : dba.Vertices(memgraph::storage::View::OLD)) + ASSERT_NE(va.GetProperty(memgraph::storage::View::OLD, prop).GetValue().type(), + memgraph::storage::PropertyValue::Type::Null); // order by and expect an exception auto n = MakeScanAll(storage, symbol_table, "n"); diff --git a/tests/unit/query_plan_checker.hpp b/tests/unit/query_plan_checker.hpp index dd0b37ebe..a454370a0 100644 --- a/tests/unit/query_plan_checker.hpp +++ b/tests/unit/query_plan_checker.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "query/plan/planner.hpp" #include "query/plan/preprocess.hpp" -namespace query::plan { +namespace memgraph::query::plan { class BaseOpChecker { public: @@ -153,14 +153,14 @@ using ExpectDistinct = OpChecker; class ExpectExpandVariable : public OpChecker { public: void ExpectOp(ExpandVariable &op, const SymbolTable &) override { - EXPECT_EQ(op.type_, query::EdgeAtom::Type::DEPTH_FIRST); + EXPECT_EQ(op.type_, memgraph::query::EdgeAtom::Type::DEPTH_FIRST); } }; class ExpectExpandBfs : public OpChecker { public: void ExpectOp(ExpandVariable &op, const SymbolTable &) override { - EXPECT_EQ(op.type_, query::EdgeAtom::Type::BREADTH_FIRST); + EXPECT_EQ(op.type_, memgraph::query::EdgeAtom::Type::BREADTH_FIRST); } }; @@ -179,8 +179,8 @@ class ExpectAccumulate : public OpChecker { class ExpectAggregate : public OpChecker { public: - ExpectAggregate(const std::vector &aggregations, - const std::unordered_set &group_by) + ExpectAggregate(const std::vector &aggregations, + const std::unordered_set &group_by) : aggregations_(aggregations), group_by_(group_by) {} void ExpectOp(Aggregate &op, const SymbolTable &symbol_table) override { @@ -204,8 +204,8 @@ class ExpectAggregate : public OpChecker { } private: - std::vector aggregations_; - std::unordered_set group_by_; + std::vector aggregations_; + std::unordered_set group_by_; }; class ExpectMerge : public OpChecker { @@ -247,9 +247,9 @@ class ExpectOptional : public OpChecker { class ExpectScanAllByLabelPropertyValue : public OpChecker { public: - ExpectScanAllByLabelPropertyValue(storage::LabelId label, - const std::pair &prop_pair, - query::Expression *expression) + ExpectScanAllByLabelPropertyValue(memgraph::storage::LabelId label, + const std::pair &prop_pair, + memgraph::query::Expression *expression) : label_(label), property_(prop_pair.second), expression_(expression) {} void ExpectOp(ScanAllByLabelPropertyValue &scan_all, const SymbolTable &) override { @@ -260,14 +260,14 @@ class ExpectScanAllByLabelPropertyValue : public OpChecker { public: - ExpectScanAllByLabelPropertyRange(storage::LabelId label, storage::PropertyId property, + ExpectScanAllByLabelPropertyRange(memgraph::storage::LabelId label, memgraph::storage::PropertyId property, std::optional lower_bound, std::optional upper_bound) : label_(label), property_(property), lower_bound_(lower_bound), upper_bound_(upper_bound) {} @@ -290,15 +290,16 @@ class ExpectScanAllByLabelPropertyRange : public OpChecker lower_bound_; std::optional upper_bound_; }; class ExpectScanAllByLabelProperty : public OpChecker { public: - ExpectScanAllByLabelProperty(storage::LabelId label, const std::pair &prop_pair) + ExpectScanAllByLabelProperty(memgraph::storage::LabelId label, + const std::pair &prop_pair) : label_(label), property_(prop_pair.second) {} void ExpectOp(ScanAllByLabelProperty &scan_all, const SymbolTable &) override { @@ -307,8 +308,8 @@ class ExpectScanAllByLabelProperty : public OpChecker { } private: - storage::LabelId label_; - storage::PropertyId property_; + memgraph::storage::LabelId label_; + memgraph::storage::PropertyId property_; }; class ExpectCartesian : public OpChecker { @@ -333,7 +334,7 @@ class ExpectCartesian : public OpChecker { class ExpectCallProcedure : public OpChecker { public: - ExpectCallProcedure(const std::string &name, const std::vector &args, + ExpectCallProcedure(const std::string &name, const std::vector &args, const std::vector &fields, const std::vector &result_syms) : name_(name), args_(args), fields_(fields), result_syms_(result_syms) {} @@ -352,7 +353,7 @@ class ExpectCallProcedure : public OpChecker { private: std::string name_; - std::vector args_; + std::vector args_; std::vector fields_; std::vector result_syms_; }; @@ -381,13 +382,13 @@ TPlanner MakePlanner(TDbAccessor *dba, AstStorage &storage, SymbolTable &symbol_ class FakeDbAccessor { public: - int64_t VerticesCount(storage::LabelId label) const { + int64_t VerticesCount(memgraph::storage::LabelId label) const { auto found = label_index_.find(label); if (found != label_index_.end()) return found->second; return 0; } - int64_t VerticesCount(storage::LabelId label, storage::PropertyId property) const { + int64_t VerticesCount(memgraph::storage::LabelId label, memgraph::storage::PropertyId property) const { for (auto &index : label_property_index_) { if (std::get<0>(index) == label && std::get<1>(index) == property) { return std::get<2>(index); @@ -396,9 +397,11 @@ class FakeDbAccessor { return 0; } - bool LabelIndexExists(storage::LabelId label) const { return label_index_.find(label) != label_index_.end(); } + bool LabelIndexExists(memgraph::storage::LabelId label) const { + return label_index_.find(label) != label_index_.end(); + } - bool LabelPropertyIndexExists(storage::LabelId label, storage::PropertyId property) const { + bool LabelPropertyIndexExists(memgraph::storage::LabelId label, memgraph::storage::PropertyId property) const { for (auto &index : label_property_index_) { if (std::get<0>(index) == label && std::get<1>(index) == property) { return true; @@ -407,9 +410,9 @@ class FakeDbAccessor { return false; } - void SetIndexCount(storage::LabelId label, int64_t count) { label_index_[label] = count; } + void SetIndexCount(memgraph::storage::LabelId label, int64_t count) { label_index_[label] = count; } - void SetIndexCount(storage::LabelId label, storage::PropertyId property, int64_t count) { + void SetIndexCount(memgraph::storage::LabelId label, memgraph::storage::PropertyId property, int64_t count) { for (auto &index : label_property_index_) { if (std::get<0>(index) == label && std::get<1>(index) == property) { std::get<2>(index) = count; @@ -419,44 +422,44 @@ class FakeDbAccessor { label_property_index_.emplace_back(label, property, count); } - storage::LabelId NameToLabel(const std::string &name) { + memgraph::storage::LabelId NameToLabel(const std::string &name) { auto found = labels_.find(name); if (found != labels_.end()) return found->second; - return labels_.emplace(name, storage::LabelId::FromUint(labels_.size())).first->second; + return labels_.emplace(name, memgraph::storage::LabelId::FromUint(labels_.size())).first->second; } - storage::LabelId Label(const std::string &name) { return NameToLabel(name); } + memgraph::storage::LabelId Label(const std::string &name) { return NameToLabel(name); } - storage::EdgeTypeId NameToEdgeType(const std::string &name) { + memgraph::storage::EdgeTypeId NameToEdgeType(const std::string &name) { auto found = edge_types_.find(name); if (found != edge_types_.end()) return found->second; - return edge_types_.emplace(name, storage::EdgeTypeId::FromUint(edge_types_.size())).first->second; + return edge_types_.emplace(name, memgraph::storage::EdgeTypeId::FromUint(edge_types_.size())).first->second; } - storage::PropertyId NameToProperty(const std::string &name) { + memgraph::storage::PropertyId NameToProperty(const std::string &name) { auto found = properties_.find(name); if (found != properties_.end()) return found->second; - return properties_.emplace(name, storage::PropertyId::FromUint(properties_.size())).first->second; + return properties_.emplace(name, memgraph::storage::PropertyId::FromUint(properties_.size())).first->second; } - storage::PropertyId Property(const std::string &name) { return NameToProperty(name); } + memgraph::storage::PropertyId Property(const std::string &name) { return NameToProperty(name); } - std::string PropertyToName(storage::PropertyId property) const { + std::string PropertyToName(memgraph::storage::PropertyId property) const { for (const auto &kv : properties_) { if (kv.second == property) return kv.first; } LOG_FATAL("Unable to find property name"); } - std::string PropertyName(storage::PropertyId property) const { return PropertyToName(property); } + std::string PropertyName(memgraph::storage::PropertyId property) const { return PropertyToName(property); } private: - std::unordered_map labels_; - std::unordered_map edge_types_; - std::unordered_map properties_; + std::unordered_map labels_; + std::unordered_map edge_types_; + std::unordered_map properties_; - std::unordered_map label_index_; - std::vector> label_property_index_; + std::unordered_map label_index_; + std::vector> label_property_index_; }; -} // namespace query::plan +} // namespace memgraph::query::plan diff --git a/tests/unit/query_plan_common.hpp b/tests/unit/query_plan_common.hpp index 867c0fc8b..037875754 100644 --- a/tests/unit/query_plan_common.hpp +++ b/tests/unit/query_plan_common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,12 +26,13 @@ #include "query_common.hpp" -using namespace query; -using namespace query::plan; +using namespace memgraph::query; +using namespace memgraph::query::plan; using Bound = ScanAllByLabelPropertyRange::Bound; -ExecutionContext MakeContext(const AstStorage &storage, const SymbolTable &symbol_table, query::DbAccessor *dba) { +ExecutionContext MakeContext(const AstStorage &storage, const SymbolTable &symbol_table, + memgraph::query::DbAccessor *dba) { ExecutionContext context{dba}; context.symbol_table = symbol_table; context.evaluation_context.properties = NamesToProperties(storage.properties_, dba); @@ -52,7 +53,7 @@ std::vector> CollectProduce(const Produce &produce, Exec symbols.emplace_back(context->symbol_table.at(*named_expression)); // stream out results - auto cursor = produce.MakeCursor(utils::NewDeleteResource()); + auto cursor = produce.MakeCursor(memgraph::utils::NewDeleteResource()); std::vector> results; while (cursor->Pull(frame, *context)) { std::vector values; @@ -65,7 +66,7 @@ std::vector> CollectProduce(const Produce &produce, Exec int PullAll(const LogicalOperator &logical_op, ExecutionContext *context) { Frame frame(context->symbol_table.max_position()); - auto cursor = logical_op.MakeCursor(utils::NewDeleteResource()); + auto cursor = logical_op.MakeCursor(memgraph::utils::NewDeleteResource()); int count = 0; while (cursor->Pull(frame, *context)) count++; return count; @@ -89,7 +90,8 @@ struct ScanAllTuple { * Returns ScanAllTuple(node_atom, scan_all_logical_op, symbol). */ ScanAllTuple MakeScanAll(AstStorage &storage, SymbolTable &symbol_table, const std::string &identifier, - std::shared_ptr input = {nullptr}, storage::View view = storage::View::OLD) { + std::shared_ptr input = {nullptr}, + memgraph::storage::View view = memgraph::storage::View::OLD) { auto node = NODE(identifier); auto symbol = symbol_table.CreateSymbol(identifier, true); node->identifier_->MapTo(symbol); @@ -104,8 +106,8 @@ ScanAllTuple MakeScanAll(AstStorage &storage, SymbolTable &symbol_table, const s * Returns ScanAllTuple(node_atom, scan_all_logical_op, symbol). */ ScanAllTuple MakeScanAllByLabel(AstStorage &storage, SymbolTable &symbol_table, const std::string &identifier, - storage::LabelId label, std::shared_ptr input = {nullptr}, - storage::View view = storage::View::OLD) { + memgraph::storage::LabelId label, std::shared_ptr input = {nullptr}, + memgraph::storage::View view = memgraph::storage::View::OLD) { auto node = NODE(identifier); auto symbol = symbol_table.CreateSymbol(identifier, true); node->identifier_->MapTo(symbol); @@ -120,11 +122,11 @@ ScanAllTuple MakeScanAllByLabel(AstStorage &storage, SymbolTable &symbol_table, * Returns ScanAllTuple(node_atom, scan_all_logical_op, symbol). */ ScanAllTuple MakeScanAllByLabelPropertyRange(AstStorage &storage, SymbolTable &symbol_table, std::string identifier, - storage::LabelId label, storage::PropertyId property, + memgraph::storage::LabelId label, memgraph::storage::PropertyId property, const std::string &property_name, std::optional lower_bound, std::optional upper_bound, std::shared_ptr input = {nullptr}, - storage::View view = storage::View::OLD) { + memgraph::storage::View view = memgraph::storage::View::OLD) { auto node = NODE(identifier); auto symbol = symbol_table.CreateSymbol(identifier, true); node->identifier_->MapTo(symbol); @@ -140,10 +142,10 @@ ScanAllTuple MakeScanAllByLabelPropertyRange(AstStorage &storage, SymbolTable &s * Returns ScanAllTuple(node_atom, scan_all_logical_op, symbol). */ ScanAllTuple MakeScanAllByLabelPropertyValue(AstStorage &storage, SymbolTable &symbol_table, std::string identifier, - storage::LabelId label, storage::PropertyId property, + memgraph::storage::LabelId label, memgraph::storage::PropertyId property, const std::string &property_name, Expression *value, std::shared_ptr input = {nullptr}, - storage::View view = storage::View::OLD) { + memgraph::storage::View view = memgraph::storage::View::OLD) { auto node = NODE(identifier); auto symbol = symbol_table.CreateSymbol(identifier, true); node->identifier_->MapTo(symbol); @@ -162,8 +164,8 @@ struct ExpandTuple { ExpandTuple MakeExpand(AstStorage &storage, SymbolTable &symbol_table, std::shared_ptr input, Symbol input_symbol, const std::string &edge_identifier, EdgeAtom::Direction direction, - const std::vector &edge_types, const std::string &node_identifier, - bool existing_node, storage::View view) { + const std::vector &edge_types, const std::string &node_identifier, + bool existing_node, memgraph::storage::View view) { auto edge = EDGE(edge_identifier, direction); auto edge_sym = symbol_table.CreateSymbol(edge_identifier, true); edge->identifier_->MapTo(edge_sym); @@ -186,7 +188,7 @@ struct UnwindTuple { UnwindTuple MakeUnwind(SymbolTable &symbol_table, const std::string &symbol_name, std::shared_ptr input, Expression *input_expression) { auto sym = symbol_table.CreateSymbol(symbol_name, true); - auto op = std::make_shared(input, input_expression, sym); + auto op = std::make_shared(input, input_expression, sym); return UnwindTuple{sym, op}; } @@ -199,7 +201,7 @@ auto CountIterable(TIterable &&iterable) { return count; } -inline uint64_t CountEdges(query::DbAccessor *dba, storage::View view) { +inline uint64_t CountEdges(memgraph::query::DbAccessor *dba, memgraph::storage::View view) { uint64_t count = 0; for (auto vertex : dba->Vertices(view)) { auto maybe_edges = vertex.OutEdges(view); diff --git a/tests/unit/query_plan_create_set_remove_delete.cpp b/tests/unit/query_plan_create_set_remove_delete.cpp index d071e50bd..90a13eee3 100644 --- a/tests/unit/query_plan_create_set_remove_delete.cpp +++ b/tests/unit/query_plan_create_set_remove_delete.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,15 +24,15 @@ #include "query_plan_common.hpp" -using namespace query; -using namespace query::plan; +using namespace memgraph::query; +using namespace memgraph::query::plan; TEST(QueryPlan, CreateNodeWithAttributes) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); - storage::LabelId label = dba.NameToLabel("Person"); + memgraph::storage::LabelId label = dba.NameToLabel("Person"); auto property = PROPERTY_PAIR("prop"); AstStorage storage; @@ -41,7 +41,7 @@ TEST(QueryPlan, CreateNodeWithAttributes) { NodeCreationInfo node; node.symbol = symbol_table.CreateSymbol("n", true); node.labels.emplace_back(label); - std::get>>(node.properties) + std::get>>(node.properties) .emplace_back(property.second, LITERAL(42)); auto create = std::make_shared(nullptr, node); @@ -51,18 +51,18 @@ TEST(QueryPlan, CreateNodeWithAttributes) { // count the number of vertices int vertex_count = 0; - for (auto vertex : dba.Vertices(storage::View::OLD)) { + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) { vertex_count++; - auto maybe_labels = vertex.Labels(storage::View::OLD); + auto maybe_labels = vertex.Labels(memgraph::storage::View::OLD); ASSERT_TRUE(maybe_labels.HasValue()); const auto &labels = *maybe_labels; EXPECT_EQ(labels.size(), 1); EXPECT_EQ(*labels.begin(), label); - auto maybe_properties = vertex.Properties(storage::View::OLD); + auto maybe_properties = vertex.Properties(memgraph::storage::View::OLD); ASSERT_TRUE(maybe_properties.HasValue()); const auto &properties = *maybe_properties; EXPECT_EQ(properties.size(), 1); - auto maybe_prop = vertex.GetProperty(storage::View::OLD, property.second); + auto maybe_prop = vertex.GetProperty(memgraph::storage::View::OLD, property.second); ASSERT_TRUE(maybe_prop.HasValue()); auto prop_eq = TypedValue(*maybe_prop) == TypedValue(42); ASSERT_EQ(prop_eq.type(), TypedValue::Type::Bool); @@ -73,11 +73,11 @@ TEST(QueryPlan, CreateNodeWithAttributes) { TEST(QueryPlan, CreateReturn) { // test CREATE (n:Person {age: 42}) RETURN n, n.age - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); - storage::LabelId label = dba.NameToLabel("Person"); + memgraph::storage::LabelId label = dba.NameToLabel("Person"); auto property = PROPERTY_PAIR("property"); AstStorage storage; @@ -86,7 +86,7 @@ TEST(QueryPlan, CreateReturn) { NodeCreationInfo node; node.symbol = symbol_table.CreateSymbol("n", true); node.labels.emplace_back(label); - std::get>>(node.properties) + std::get>>(node.properties) .emplace_back(property.second, LITERAL(42)); auto create = std::make_shared(nullptr, node); @@ -101,45 +101,45 @@ TEST(QueryPlan, CreateReturn) { EXPECT_EQ(1, results.size()); EXPECT_EQ(2, results[0].size()); EXPECT_EQ(TypedValue::Type::Vertex, results[0][0].type()); - auto maybe_labels = results[0][0].ValueVertex().Labels(storage::View::NEW); + auto maybe_labels = results[0][0].ValueVertex().Labels(memgraph::storage::View::NEW); EXPECT_EQ(1, maybe_labels->size()); EXPECT_EQ(label, (*maybe_labels)[0]); EXPECT_EQ(TypedValue::Type::Int, results[0][1].type()); EXPECT_EQ(42, results[0][1].ValueInt()); dba.AdvanceCommand(); - EXPECT_EQ(1, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(1, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); } TEST(QueryPlan, CreateExpand) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); - storage::LabelId label_node_1 = dba.NameToLabel("Node1"); - storage::LabelId label_node_2 = dba.NameToLabel("Node2"); + memgraph::storage::LabelId label_node_1 = dba.NameToLabel("Node1"); + memgraph::storage::LabelId label_node_2 = dba.NameToLabel("Node2"); auto property = PROPERTY_PAIR("property"); - storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type"); + memgraph::storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type"); SymbolTable symbol_table; AstStorage storage; auto test_create_path = [&](bool cycle, int expected_nodes_created, int expected_edges_created) { - int before_v = CountIterable(dba.Vertices(storage::View::OLD)); - int before_e = CountEdges(&dba, storage::View::OLD); + int before_v = CountIterable(dba.Vertices(memgraph::storage::View::OLD)); + int before_e = CountEdges(&dba, memgraph::storage::View::OLD); // data for the first node NodeCreationInfo n; n.symbol = symbol_table.CreateSymbol("n", true); n.labels.emplace_back(label_node_1); - std::get>>(n.properties) + std::get>>(n.properties) .emplace_back(property.second, LITERAL(1)); // data for the second node NodeCreationInfo m; m.symbol = cycle ? n.symbol : symbol_table.CreateSymbol("m", true); m.labels.emplace_back(label_node_2); - std::get>>(m.properties) + std::get>>(m.properties) .emplace_back(property.second, LITERAL(2)); EdgeCreationInfo r; @@ -153,45 +153,45 @@ TEST(QueryPlan, CreateExpand) { PullAll(*create_expand, &context); dba.AdvanceCommand(); - EXPECT_EQ(CountIterable(dba.Vertices(storage::View::OLD)) - before_v, expected_nodes_created); - EXPECT_EQ(CountEdges(&dba, storage::View::OLD) - before_e, expected_edges_created); + EXPECT_EQ(CountIterable(dba.Vertices(memgraph::storage::View::OLD)) - before_v, expected_nodes_created); + EXPECT_EQ(CountEdges(&dba, memgraph::storage::View::OLD) - before_e, expected_edges_created); }; test_create_path(false, 2, 1); test_create_path(true, 1, 1); - for (auto vertex : dba.Vertices(storage::View::OLD)) { - auto maybe_labels = vertex.Labels(storage::View::OLD); + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) { + auto maybe_labels = vertex.Labels(memgraph::storage::View::OLD); MG_ASSERT(maybe_labels.HasValue()); const auto &labels = *maybe_labels; EXPECT_EQ(labels.size(), 1); - storage::LabelId label = labels[0]; + memgraph::storage::LabelId label = labels[0]; if (label == label_node_1) { // node created by first op - EXPECT_EQ(vertex.GetProperty(storage::View::OLD, property.second)->ValueInt(), 1); + EXPECT_EQ(vertex.GetProperty(memgraph::storage::View::OLD, property.second)->ValueInt(), 1); } else if (label == label_node_2) { // node create by expansion - EXPECT_EQ(vertex.GetProperty(storage::View::OLD, property.second)->ValueInt(), 2); + EXPECT_EQ(vertex.GetProperty(memgraph::storage::View::OLD, property.second)->ValueInt(), 2); } else { // should not happen FAIL(); } - for (auto vertex : dba.Vertices(storage::View::OLD)) { - auto maybe_edges = vertex.OutEdges(storage::View::OLD); + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) { + auto maybe_edges = vertex.OutEdges(memgraph::storage::View::OLD); MG_ASSERT(maybe_edges.HasValue()); for (auto edge : *maybe_edges) { EXPECT_EQ(edge.EdgeType(), edge_type); - EXPECT_EQ(edge.GetProperty(storage::View::OLD, property.second)->ValueInt(), 3); + EXPECT_EQ(edge.GetProperty(memgraph::storage::View::OLD, property.second)->ValueInt(), 3); } } } } TEST(QueryPlan, MatchCreateNode) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // add three nodes we'll match and expand-create from dba.InsertVertex(); @@ -210,17 +210,17 @@ TEST(QueryPlan, MatchCreateNode) { // creation op auto create_node = std::make_shared(n_scan_all.op_, m); - EXPECT_EQ(CountIterable(dba.Vertices(storage::View::OLD)), 3); + EXPECT_EQ(CountIterable(dba.Vertices(memgraph::storage::View::OLD)), 3); auto context = MakeContext(storage, symbol_table, &dba); PullAll(*create_node, &context); dba.AdvanceCommand(); - EXPECT_EQ(CountIterable(dba.Vertices(storage::View::OLD)), 6); + EXPECT_EQ(CountIterable(dba.Vertices(memgraph::storage::View::OLD)), 6); } TEST(QueryPlan, MatchCreateExpand) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // add three nodes we'll match and expand-create from dba.InsertVertex(); @@ -228,17 +228,17 @@ TEST(QueryPlan, MatchCreateExpand) { dba.InsertVertex(); dba.AdvanceCommand(); - // storage::LabelId label_node_1 = dba.NameToLabel("Node1"); - // storage::LabelId label_node_2 = dba.NameToLabel("Node2"); - // storage::PropertyId property = dba.NameToLabel("prop"); - storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type"); + // memgraph::storage::LabelId label_node_1 = dba.NameToLabel("Node1"); + // memgraph::storage::LabelId label_node_2 = dba.NameToLabel("Node2"); + // memgraph::storage::PropertyId property = dba.NameToLabel("prop"); + memgraph::storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type"); SymbolTable symbol_table; AstStorage storage; auto test_create_path = [&](bool cycle, int expected_nodes_created, int expected_edges_created) { - int before_v = CountIterable(dba.Vertices(storage::View::OLD)); - int before_e = CountEdges(&dba, storage::View::OLD); + int before_v = CountIterable(dba.Vertices(memgraph::storage::View::OLD)); + int before_e = CountEdges(&dba, memgraph::storage::View::OLD); // data for the first node auto n_scan_all = MakeScanAll(storage, symbol_table, "n"); @@ -257,8 +257,8 @@ TEST(QueryPlan, MatchCreateExpand) { PullAll(*create_expand, &context); dba.AdvanceCommand(); - EXPECT_EQ(CountIterable(dba.Vertices(storage::View::OLD)) - before_v, expected_nodes_created); - EXPECT_EQ(CountEdges(&dba, storage::View::OLD) - before_e, expected_edges_created); + EXPECT_EQ(CountIterable(dba.Vertices(memgraph::storage::View::OLD)) - before_v, expected_nodes_created); + EXPECT_EQ(CountEdges(&dba, memgraph::storage::View::OLD) - before_e, expected_edges_created); }; test_create_path(false, 3, 3); @@ -266,20 +266,20 @@ TEST(QueryPlan, MatchCreateExpand) { } TEST(QueryPlan, Delete) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // make a fully-connected (one-direction, no cycles) with 4 nodes - std::vector vertices; + std::vector vertices; for (int i = 0; i < 4; ++i) vertices.push_back(dba.InsertVertex()); auto type = dba.NameToEdgeType("type"); for (int j = 0; j < 4; ++j) for (int k = j + 1; k < 4; ++k) ASSERT_TRUE(dba.InsertEdge(&vertices[j], &vertices[k], type).HasValue()); dba.AdvanceCommand(); - EXPECT_EQ(4, CountIterable(dba.Vertices(storage::View::OLD))); - EXPECT_EQ(6, CountEdges(&dba, storage::View::OLD)); + EXPECT_EQ(4, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + EXPECT_EQ(6, CountEdges(&dba, memgraph::storage::View::OLD)); AstStorage storage; SymbolTable symbol_table; @@ -292,8 +292,8 @@ TEST(QueryPlan, Delete) { auto context = MakeContext(storage, symbol_table, &dba); EXPECT_THROW(PullAll(*delete_op, &context), QueryRuntimeException); dba.AdvanceCommand(); - EXPECT_EQ(4, CountIterable(dba.Vertices(storage::View::OLD))); - EXPECT_EQ(6, CountEdges(&dba, storage::View::OLD)); + EXPECT_EQ(4, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + EXPECT_EQ(6, CountEdges(&dba, memgraph::storage::View::OLD)); } // detach delete a single vertex @@ -303,24 +303,24 @@ TEST(QueryPlan, Delete) { auto delete_op = std::make_shared(n.op_, std::vector{n_get}, true); Frame frame(symbol_table.max_position()); auto context = MakeContext(storage, symbol_table, &dba); - delete_op->MakeCursor(utils::NewDeleteResource())->Pull(frame, context); + delete_op->MakeCursor(memgraph::utils::NewDeleteResource())->Pull(frame, context); dba.AdvanceCommand(); - EXPECT_EQ(3, CountIterable(dba.Vertices(storage::View::OLD))); - EXPECT_EQ(3, CountEdges(&dba, storage::View::OLD)); + EXPECT_EQ(3, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + EXPECT_EQ(3, CountEdges(&dba, memgraph::storage::View::OLD)); } // delete all remaining edges { auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::OUT, {}, "m", false, - storage::View::NEW); + memgraph::storage::View::NEW); auto r_get = storage.Create("r")->MapTo(r_m.edge_sym_); auto delete_op = std::make_shared(r_m.op_, std::vector{r_get}, false); auto context = MakeContext(storage, symbol_table, &dba); PullAll(*delete_op, &context); dba.AdvanceCommand(); - EXPECT_EQ(3, CountIterable(dba.Vertices(storage::View::OLD))); - EXPECT_EQ(0, CountEdges(&dba, storage::View::OLD)); + EXPECT_EQ(3, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + EXPECT_EQ(0, CountEdges(&dba, memgraph::storage::View::OLD)); } // delete all remaining vertices @@ -331,8 +331,8 @@ TEST(QueryPlan, Delete) { auto context = MakeContext(storage, symbol_table, &dba); PullAll(*delete_op, &context); dba.AdvanceCommand(); - EXPECT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD))); - EXPECT_EQ(0, CountEdges(&dba, storage::View::OLD)); + EXPECT_EQ(0, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + EXPECT_EQ(0, CountEdges(&dba, memgraph::storage::View::OLD)); } } @@ -349,23 +349,23 @@ TEST(QueryPlan, DeleteTwiceDeleteBlockingEdge) { // MATCH (n)-[r]-(m) [DETACH] DELETE n, r, m auto test_delete = [](bool detach) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); ASSERT_TRUE(dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("T")).HasValue()); dba.AdvanceCommand(); - EXPECT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD))); - EXPECT_EQ(1, CountEdges(&dba, storage::View::OLD)); + EXPECT_EQ(2, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + EXPECT_EQ(1, CountEdges(&dba, memgraph::storage::View::OLD)); AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::BOTH, {}, "m", false, - storage::View::OLD); + memgraph::storage::View::OLD); // getter expressions for deletion auto n_get = storage.Create("n")->MapTo(n.sym_); @@ -376,8 +376,8 @@ TEST(QueryPlan, DeleteTwiceDeleteBlockingEdge) { auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(2, PullAll(*delete_op, &context)); dba.AdvanceCommand(); - EXPECT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD))); - EXPECT_EQ(0, CountEdges(&dba, storage::View::OLD)); + EXPECT_EQ(0, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + EXPECT_EQ(0, CountEdges(&dba, memgraph::storage::View::OLD)); }; test_delete(true); @@ -385,20 +385,20 @@ TEST(QueryPlan, DeleteTwiceDeleteBlockingEdge) { } TEST(QueryPlan, DeleteReturn) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // make a fully-connected (one-direction, no cycles) with 4 nodes auto prop = PROPERTY_PAIR("property"); for (int i = 0; i < 4; ++i) { auto va = dba.InsertVertex(); - ASSERT_TRUE(va.SetProperty(prop.second, storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(va.SetProperty(prop.second, memgraph::storage::PropertyValue(42)).HasValue()); } dba.AdvanceCommand(); - EXPECT_EQ(4, CountIterable(dba.Vertices(storage::View::OLD))); - EXPECT_EQ(0, CountEdges(&dba, storage::View::OLD)); + EXPECT_EQ(4, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + EXPECT_EQ(0, CountEdges(&dba, memgraph::storage::View::OLD)); AstStorage storage; SymbolTable symbol_table; @@ -418,9 +418,9 @@ TEST(QueryPlan, DeleteReturn) { TEST(QueryPlan, DeleteNull) { // test (simplified) WITH Null as x delete x - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -436,7 +436,7 @@ TEST(QueryPlan, DeleteAdvance) { // MATCH (n) DELETE n WITH n ... // this fails only if the deleted record `n` is actually used in subsequent // clauses, which is compatible with Neo's behavior. - storage::Storage db; + memgraph::storage::Storage db; AstStorage storage; SymbolTable symbol_table; @@ -448,7 +448,7 @@ TEST(QueryPlan, DeleteAdvance) { auto res_sym = symbol_table.CreateSymbol("res", true); { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); dba.InsertVertex(); dba.AdvanceCommand(); auto produce = MakeProduce(advance, NEXPR("res", LITERAL(42))->MapTo(res_sym)); @@ -457,7 +457,7 @@ TEST(QueryPlan, DeleteAdvance) { } { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); dba.InsertVertex(); dba.AdvanceCommand(); auto n_prop = PROPERTY_LOOKUP(n_get, dba.NameToProperty("prop")); @@ -468,9 +468,9 @@ TEST(QueryPlan, DeleteAdvance) { } TEST(QueryPlan, SetProperty) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // graph with 4 vertices in connected pairs // the origin vertex in each par and both edges @@ -490,7 +490,7 @@ TEST(QueryPlan, SetProperty) { // scan (n)-[r]->(m) auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::OUT, {}, "m", false, - storage::View::OLD); + memgraph::storage::View::OLD); // set prop1 to 42 on n and r auto prop1 = dba.NameToProperty("prop1"); @@ -505,27 +505,30 @@ TEST(QueryPlan, SetProperty) { EXPECT_EQ(2, PullAll(*set_r_p, &context)); dba.AdvanceCommand(); - EXPECT_EQ(CountEdges(&dba, storage::View::OLD), 2); - for (auto vertex : dba.Vertices(storage::View::OLD)) { - auto maybe_edges = vertex.OutEdges(storage::View::OLD); + EXPECT_EQ(CountEdges(&dba, memgraph::storage::View::OLD), 2); + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) { + auto maybe_edges = vertex.OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(maybe_edges.HasValue()); for (auto edge : *maybe_edges) { - ASSERT_EQ(edge.GetProperty(storage::View::OLD, prop1)->type(), storage::PropertyValue::Type::Int); - EXPECT_EQ(edge.GetProperty(storage::View::OLD, prop1)->ValueInt(), 42); + ASSERT_EQ(edge.GetProperty(memgraph::storage::View::OLD, prop1)->type(), + memgraph::storage::PropertyValue::Type::Int); + EXPECT_EQ(edge.GetProperty(memgraph::storage::View::OLD, prop1)->ValueInt(), 42); auto from = edge.From(); auto to = edge.To(); - ASSERT_EQ(from.GetProperty(storage::View::OLD, prop1)->type(), storage::PropertyValue::Type::Int); - EXPECT_EQ(from.GetProperty(storage::View::OLD, prop1)->ValueInt(), 42); - ASSERT_EQ(to.GetProperty(storage::View::OLD, prop1)->type(), storage::PropertyValue::Type::Null); + ASSERT_EQ(from.GetProperty(memgraph::storage::View::OLD, prop1)->type(), + memgraph::storage::PropertyValue::Type::Int); + EXPECT_EQ(from.GetProperty(memgraph::storage::View::OLD, prop1)->ValueInt(), 42); + ASSERT_EQ(to.GetProperty(memgraph::storage::View::OLD, prop1)->type(), + memgraph::storage::PropertyValue::Type::Null); } } } TEST(QueryPlan, SetProperties) { auto test_set_properties = [](bool update) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // graph: ({a: 0})-[:R {b:1}]->({c:2}) auto prop_a = dba.NameToProperty("a"); @@ -534,9 +537,9 @@ TEST(QueryPlan, SetProperties) { auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); auto e = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("R")); - ASSERT_TRUE(v1.SetProperty(prop_a, storage::PropertyValue(0)).HasValue()); - ASSERT_TRUE(e->SetProperty(prop_b, storage::PropertyValue(1)).HasValue()); - ASSERT_TRUE(v2.SetProperty(prop_c, storage::PropertyValue(2)).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop_a, memgraph::storage::PropertyValue(0)).HasValue()); + ASSERT_TRUE(e->SetProperty(prop_b, memgraph::storage::PropertyValue(1)).HasValue()); + ASSERT_TRUE(v2.SetProperty(prop_c, memgraph::storage::PropertyValue(2)).HasValue()); dba.AdvanceCommand(); AstStorage storage; @@ -545,7 +548,7 @@ TEST(QueryPlan, SetProperties) { // scan (n)-[r]->(m) auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::OUT, {}, "m", false, - storage::View::OLD); + memgraph::storage::View::OLD); auto op = update ? plan::SetProperties::Op::UPDATE : plan::SetProperties::Op::REPLACE; @@ -558,32 +561,37 @@ TEST(QueryPlan, SetProperties) { EXPECT_EQ(1, PullAll(*set_m_to_r, &context)); dba.AdvanceCommand(); - EXPECT_EQ(CountEdges(&dba, storage::View::OLD), 1); - for (auto vertex : dba.Vertices(storage::View::OLD)) { - auto maybe_edges = vertex.OutEdges(storage::View::OLD); + EXPECT_EQ(CountEdges(&dba, memgraph::storage::View::OLD), 1); + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) { + auto maybe_edges = vertex.OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(maybe_edges.HasValue()); for (auto edge : *maybe_edges) { auto from = edge.From(); - EXPECT_EQ(from.Properties(storage::View::OLD)->size(), update ? 2 : 1); + EXPECT_EQ(from.Properties(memgraph::storage::View::OLD)->size(), update ? 2 : 1); if (update) { - ASSERT_EQ(from.GetProperty(storage::View::OLD, prop_a)->type(), storage::PropertyValue::Type::Int); - EXPECT_EQ(from.GetProperty(storage::View::OLD, prop_a)->ValueInt(), 0); + ASSERT_EQ(from.GetProperty(memgraph::storage::View::OLD, prop_a)->type(), + memgraph::storage::PropertyValue::Type::Int); + EXPECT_EQ(from.GetProperty(memgraph::storage::View::OLD, prop_a)->ValueInt(), 0); } - ASSERT_EQ(from.GetProperty(storage::View::OLD, prop_b)->type(), storage::PropertyValue::Type::Int); - EXPECT_EQ(from.GetProperty(storage::View::OLD, prop_b)->ValueInt(), 1); + ASSERT_EQ(from.GetProperty(memgraph::storage::View::OLD, prop_b)->type(), + memgraph::storage::PropertyValue::Type::Int); + EXPECT_EQ(from.GetProperty(memgraph::storage::View::OLD, prop_b)->ValueInt(), 1); - EXPECT_EQ(edge.Properties(storage::View::OLD)->size(), update ? 2 : 1); + EXPECT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), update ? 2 : 1); if (update) { - ASSERT_EQ(edge.GetProperty(storage::View::OLD, prop_b)->type(), storage::PropertyValue::Type::Int); - EXPECT_EQ(edge.GetProperty(storage::View::OLD, prop_b)->ValueInt(), 1); + ASSERT_EQ(edge.GetProperty(memgraph::storage::View::OLD, prop_b)->type(), + memgraph::storage::PropertyValue::Type::Int); + EXPECT_EQ(edge.GetProperty(memgraph::storage::View::OLD, prop_b)->ValueInt(), 1); } - ASSERT_EQ(edge.GetProperty(storage::View::OLD, prop_c)->type(), storage::PropertyValue::Type::Int); - EXPECT_EQ(edge.GetProperty(storage::View::OLD, prop_c)->ValueInt(), 2); + ASSERT_EQ(edge.GetProperty(memgraph::storage::View::OLD, prop_c)->type(), + memgraph::storage::PropertyValue::Type::Int); + EXPECT_EQ(edge.GetProperty(memgraph::storage::View::OLD, prop_c)->ValueInt(), 2); auto to = edge.To(); - EXPECT_EQ(to.Properties(storage::View::OLD)->size(), 1); - ASSERT_EQ(to.GetProperty(storage::View::OLD, prop_c)->type(), storage::PropertyValue::Type::Int); - EXPECT_EQ(to.GetProperty(storage::View::OLD, prop_c)->ValueInt(), 2); + EXPECT_EQ(to.Properties(memgraph::storage::View::OLD)->size(), 1); + ASSERT_EQ(to.GetProperty(memgraph::storage::View::OLD, prop_c)->type(), + memgraph::storage::PropertyValue::Type::Int); + EXPECT_EQ(to.GetProperty(memgraph::storage::View::OLD, prop_c)->ValueInt(), 2); } } }; @@ -593,9 +601,9 @@ TEST(QueryPlan, SetProperties) { } TEST(QueryPlan, SetLabels) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto label1 = dba.NameToLabel("label1"); auto label2 = dba.NameToLabel("label2"); @@ -608,21 +616,22 @@ TEST(QueryPlan, SetLabels) { SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); - auto label_set = std::make_shared(n.op_, n.sym_, std::vector{label2, label3}); + auto label_set = + std::make_shared(n.op_, n.sym_, std::vector{label2, label3}); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(2, PullAll(*label_set, &context)); - for (auto vertex : dba.Vertices(storage::View::OLD)) { - EXPECT_EQ(3, vertex.Labels(storage::View::NEW)->size()); - EXPECT_TRUE(*vertex.HasLabel(storage::View::NEW, label2)); - EXPECT_TRUE(*vertex.HasLabel(storage::View::NEW, label3)); + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) { + EXPECT_EQ(3, vertex.Labels(memgraph::storage::View::NEW)->size()); + EXPECT_TRUE(*vertex.HasLabel(memgraph::storage::View::NEW, label2)); + EXPECT_TRUE(*vertex.HasLabel(memgraph::storage::View::NEW, label3)); } } TEST(QueryPlan, RemoveProperty) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // graph with 4 vertices in connected pairs // the origin vertex in each par and both edges @@ -636,15 +645,15 @@ TEST(QueryPlan, RemoveProperty) { { auto e = dba.InsertEdge(&v1, &v3, edge_type); ASSERT_TRUE(e.HasValue()); - ASSERT_TRUE(e->SetProperty(prop1, storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(e->SetProperty(prop1, memgraph::storage::PropertyValue(42)).HasValue()); } ASSERT_TRUE(dba.InsertEdge(&v2, &v4, edge_type).HasValue()); - ASSERT_TRUE(v2.SetProperty(prop1, storage::PropertyValue(42)).HasValue()); - ASSERT_TRUE(v3.SetProperty(prop1, storage::PropertyValue(42)).HasValue()); - ASSERT_TRUE(v4.SetProperty(prop1, storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(v2.SetProperty(prop1, memgraph::storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(v3.SetProperty(prop1, memgraph::storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(v4.SetProperty(prop1, memgraph::storage::PropertyValue(42)).HasValue()); auto prop2 = dba.NameToProperty("prop2"); - ASSERT_TRUE(v1.SetProperty(prop2, storage::PropertyValue(0)).HasValue()); - ASSERT_TRUE(v2.SetProperty(prop2, storage::PropertyValue(0)).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop2, memgraph::storage::PropertyValue(0)).HasValue()); + ASSERT_TRUE(v2.SetProperty(prop2, memgraph::storage::PropertyValue(0)).HasValue()); dba.AdvanceCommand(); AstStorage storage; @@ -653,7 +662,7 @@ TEST(QueryPlan, RemoveProperty) { // scan (n)-[r]->(m) auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::OUT, {}, "m", false, - storage::View::OLD); + memgraph::storage::View::OLD); auto n_p = PROPERTY_LOOKUP(IDENT("n")->MapTo(n.sym_), prop1); auto set_n_p = std::make_shared(r_m.op_, prop1, n_p); @@ -664,25 +673,29 @@ TEST(QueryPlan, RemoveProperty) { EXPECT_EQ(2, PullAll(*set_r_p, &context)); dba.AdvanceCommand(); - EXPECT_EQ(CountEdges(&dba, storage::View::OLD), 2); - for (auto vertex : dba.Vertices(storage::View::OLD)) { - auto maybe_edges = vertex.OutEdges(storage::View::OLD); + EXPECT_EQ(CountEdges(&dba, memgraph::storage::View::OLD), 2); + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) { + auto maybe_edges = vertex.OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(maybe_edges.HasValue()); for (auto edge : *maybe_edges) { - EXPECT_EQ(edge.GetProperty(storage::View::OLD, prop1)->type(), storage::PropertyValue::Type::Null); + EXPECT_EQ(edge.GetProperty(memgraph::storage::View::OLD, prop1)->type(), + memgraph::storage::PropertyValue::Type::Null); auto from = edge.From(); auto to = edge.To(); - EXPECT_EQ(from.GetProperty(storage::View::OLD, prop1)->type(), storage::PropertyValue::Type::Null); - EXPECT_EQ(from.GetProperty(storage::View::OLD, prop2)->type(), storage::PropertyValue::Type::Int); - EXPECT_EQ(to.GetProperty(storage::View::OLD, prop1)->type(), storage::PropertyValue::Type::Int); + EXPECT_EQ(from.GetProperty(memgraph::storage::View::OLD, prop1)->type(), + memgraph::storage::PropertyValue::Type::Null); + EXPECT_EQ(from.GetProperty(memgraph::storage::View::OLD, prop2)->type(), + memgraph::storage::PropertyValue::Type::Int); + EXPECT_EQ(to.GetProperty(memgraph::storage::View::OLD, prop1)->type(), + memgraph::storage::PropertyValue::Type::Int); } } } TEST(QueryPlan, RemoveLabels) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto label1 = dba.NameToLabel("label1"); auto label2 = dba.NameToLabel("label2"); @@ -701,25 +714,25 @@ TEST(QueryPlan, RemoveLabels) { auto n = MakeScanAll(storage, symbol_table, "n"); auto label_remove = - std::make_shared(n.op_, n.sym_, std::vector{label1, label2}); + std::make_shared(n.op_, n.sym_, std::vector{label1, label2}); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(2, PullAll(*label_remove, &context)); - for (auto vertex : dba.Vertices(storage::View::OLD)) { - EXPECT_EQ(1, vertex.Labels(storage::View::NEW)->size()); - EXPECT_FALSE(*vertex.HasLabel(storage::View::NEW, label1)); - EXPECT_FALSE(*vertex.HasLabel(storage::View::NEW, label2)); + for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) { + EXPECT_EQ(1, vertex.Labels(memgraph::storage::View::NEW)->size()); + EXPECT_FALSE(*vertex.HasLabel(memgraph::storage::View::NEW, label1)); + EXPECT_FALSE(*vertex.HasLabel(memgraph::storage::View::NEW, label2)); } } TEST(QueryPlan, NodeFilterSet) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Create a graph such that (v1 {prop: 42}) is connected to v2 and v3. auto v1 = dba.InsertVertex(); auto prop = PROPERTY_PAIR("property"); - ASSERT_TRUE(v1.SetProperty(prop.second, storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop.second, memgraph::storage::PropertyValue(42)).HasValue()); auto v2 = dba.InsertVertex(); auto v3 = dba.InsertVertex(); auto edge_type = dba.NameToEdgeType("Edge"); @@ -735,7 +748,7 @@ TEST(QueryPlan, NodeFilterSet) { auto scan_all = MakeScanAll(storage, symbol_table, "n"); std::get<0>(scan_all.node_->properties_)[storage.GetPropertyIx(prop.first)] = LITERAL(42); auto expand = MakeExpand(storage, symbol_table, scan_all.op_, scan_all.sym_, "r", EdgeAtom::Direction::BOTH, {}, "m", - false, storage::View::OLD); + false, memgraph::storage::View::OLD); auto *filter_expr = EQ(storage.Create(scan_all.node_->identifier_, storage.GetPropertyIx(prop.first)), LITERAL(42)); auto node_filter = std::make_shared(expand.op_, filter_expr); @@ -746,19 +759,19 @@ TEST(QueryPlan, NodeFilterSet) { auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(2, PullAll(*set, &context)); dba.AdvanceCommand(); - auto prop_eq = TypedValue(*v1.GetProperty(storage::View::OLD, prop.second)) == TypedValue(42 + 2); + auto prop_eq = TypedValue(*v1.GetProperty(memgraph::storage::View::OLD, prop.second)) == TypedValue(42 + 2); ASSERT_EQ(prop_eq.type(), TypedValue::Type::Bool); EXPECT_TRUE(prop_eq.ValueBool()); } TEST(QueryPlan, FilterRemove) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Create a graph such that (v1 {prop: 42}) is connected to v2 and v3. auto v1 = dba.InsertVertex(); auto prop = PROPERTY_PAIR("property"); - ASSERT_TRUE(v1.SetProperty(prop.second, storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop.second, memgraph::storage::PropertyValue(42)).HasValue()); auto v2 = dba.InsertVertex(); auto v3 = dba.InsertVertex(); auto edge_type = dba.NameToEdgeType("Edge"); @@ -773,7 +786,7 @@ TEST(QueryPlan, FilterRemove) { auto scan_all = MakeScanAll(storage, symbol_table, "n"); std::get<0>(scan_all.node_->properties_)[storage.GetPropertyIx(prop.first)] = LITERAL(42); auto expand = MakeExpand(storage, symbol_table, scan_all.op_, scan_all.sym_, "r", EdgeAtom::Direction::BOTH, {}, "m", - false, storage::View::OLD); + false, memgraph::storage::View::OLD); auto filter_prop = PROPERTY_LOOKUP(IDENT("n")->MapTo(scan_all.sym_), prop); auto filter = std::make_shared(expand.op_, LESS(filter_prop, LITERAL(43))); // REMOVE n.prop @@ -782,13 +795,14 @@ TEST(QueryPlan, FilterRemove) { auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(2, PullAll(*rem, &context)); dba.AdvanceCommand(); - EXPECT_EQ(v1.GetProperty(storage::View::OLD, prop.second)->type(), storage::PropertyValue::Type::Null); + EXPECT_EQ(v1.GetProperty(memgraph::storage::View::OLD, prop.second)->type(), + memgraph::storage::PropertyValue::Type::Null); } TEST(QueryPlan, SetRemove) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v = dba.InsertVertex(); auto label1 = dba.NameToLabel("label1"); auto label2 = dba.NameToLabel("label2"); @@ -799,14 +813,15 @@ TEST(QueryPlan, SetRemove) { SymbolTable symbol_table; // MATCH (n) SET n :label1 :label2 REMOVE n :label1 :label2 auto scan_all = MakeScanAll(storage, symbol_table, "n"); - auto set = - std::make_shared(scan_all.op_, scan_all.sym_, std::vector{label1, label2}); - auto rem = std::make_shared(set, scan_all.sym_, std::vector{label1, label2}); + auto set = std::make_shared(scan_all.op_, scan_all.sym_, + std::vector{label1, label2}); + auto rem = + std::make_shared(set, scan_all.sym_, std::vector{label1, label2}); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(1, PullAll(*rem, &context)); dba.AdvanceCommand(); - EXPECT_FALSE(*v.HasLabel(storage::View::OLD, label1)); - EXPECT_FALSE(*v.HasLabel(storage::View::OLD, label2)); + EXPECT_FALSE(*v.HasLabel(memgraph::storage::View::OLD, label1)); + EXPECT_FALSE(*v.HasLabel(memgraph::storage::View::OLD, label2)); } TEST(QueryPlan, Merge) { @@ -816,9 +831,9 @@ TEST(QueryPlan, Merge) { // - merge_match branch looks for an expansion (any direction) // and sets some property (for result validation) // - merge_create branch just sets some other property - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); ASSERT_TRUE(dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("Type")).HasValue()); @@ -833,7 +848,7 @@ TEST(QueryPlan, Merge) { // merge_match branch auto r_m = MakeExpand(storage, symbol_table, std::make_shared(), n.sym_, "r", EdgeAtom::Direction::BOTH, {}, - "m", false, storage::View::OLD); + "m", false, memgraph::storage::View::OLD); auto m_p = PROPERTY_LOOKUP(IDENT("m")->MapTo(r_m.node_sym_), prop); auto m_set = std::make_shared(r_m.op_, prop.second, m_p, LITERAL(1)); @@ -846,20 +861,23 @@ TEST(QueryPlan, Merge) { ASSERT_EQ(3, PullAll(*merge, &context)); dba.AdvanceCommand(); - ASSERT_EQ(v1.GetProperty(storage::View::OLD, prop.second)->type(), storage::PropertyValue::Type::Int); - ASSERT_EQ(v1.GetProperty(storage::View::OLD, prop.second)->ValueInt(), 1); - ASSERT_EQ(v2.GetProperty(storage::View::OLD, prop.second)->type(), storage::PropertyValue::Type::Int); - ASSERT_EQ(v2.GetProperty(storage::View::OLD, prop.second)->ValueInt(), 1); - ASSERT_EQ(v3.GetProperty(storage::View::OLD, prop.second)->type(), storage::PropertyValue::Type::Int); - ASSERT_EQ(v3.GetProperty(storage::View::OLD, prop.second)->ValueInt(), 2); + ASSERT_EQ(v1.GetProperty(memgraph::storage::View::OLD, prop.second)->type(), + memgraph::storage::PropertyValue::Type::Int); + ASSERT_EQ(v1.GetProperty(memgraph::storage::View::OLD, prop.second)->ValueInt(), 1); + ASSERT_EQ(v2.GetProperty(memgraph::storage::View::OLD, prop.second)->type(), + memgraph::storage::PropertyValue::Type::Int); + ASSERT_EQ(v2.GetProperty(memgraph::storage::View::OLD, prop.second)->ValueInt(), 1); + ASSERT_EQ(v3.GetProperty(memgraph::storage::View::OLD, prop.second)->type(), + memgraph::storage::PropertyValue::Type::Int); + ASSERT_EQ(v3.GetProperty(memgraph::storage::View::OLD, prop.second)->ValueInt(), 2); } TEST(QueryPlan, MergeNoInput) { // merge with no input, creates a single node - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -868,18 +886,18 @@ TEST(QueryPlan, MergeNoInput) { auto create = std::make_shared(nullptr, node); auto merge = std::make_shared(nullptr, create, create); - EXPECT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(0, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(1, PullAll(*merge, &context)); dba.AdvanceCommand(); - EXPECT_EQ(1, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(1, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); } TEST(QueryPlan, SetPropertyOnNull) { // SET (Null).prop = 42 - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; auto prop = PROPERTY_PAIR("property"); @@ -894,41 +912,41 @@ TEST(QueryPlan, SetPropertyOnNull) { TEST(QueryPlan, SetPropertiesOnNull) { // OPTIONAL MATCH (n) SET n = n - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); auto n_ident = IDENT("n")->MapTo(n.sym_); auto optional = std::make_shared(nullptr, n.op_, std::vector{n.sym_}); auto set_op = std::make_shared(optional, n.sym_, n_ident, plan::SetProperties::Op::REPLACE); - EXPECT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(0, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(1, PullAll(*set_op, &context)); } TEST(QueryPlan, SetLabelsOnNull) { // OPTIONAL MATCH (n) SET n :label - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto label = dba.NameToLabel("label"); AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); auto optional = std::make_shared(nullptr, n.op_, std::vector{n.sym_}); - auto set_op = std::make_shared(optional, n.sym_, std::vector{label}); - EXPECT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD))); + auto set_op = std::make_shared(optional, n.sym_, std::vector{label}); + EXPECT_EQ(0, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(1, PullAll(*set_op, &context)); } TEST(QueryPlan, RemovePropertyOnNull) { // REMOVE (Null).prop - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; auto prop = PROPERTY_PAIR("property"); @@ -942,28 +960,29 @@ TEST(QueryPlan, RemovePropertyOnNull) { TEST(QueryPlan, RemoveLabelsOnNull) { // OPTIONAL MATCH (n) REMOVE n :label - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto label = dba.NameToLabel("label"); AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); auto optional = std::make_shared(nullptr, n.op_, std::vector{n.sym_}); - auto remove_op = std::make_shared(optional, n.sym_, std::vector{label}); - EXPECT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD))); + auto remove_op = + std::make_shared(optional, n.sym_, std::vector{label}); + EXPECT_EQ(0, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(1, PullAll(*remove_op, &context)); } TEST(QueryPlan, DeleteSetProperty) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Add a single vertex. dba.InsertVertex(); dba.AdvanceCommand(); - EXPECT_EQ(1, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(1, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n SET n.property = 42 @@ -978,13 +997,13 @@ TEST(QueryPlan, DeleteSetProperty) { } TEST(QueryPlan, DeleteSetPropertiesFromMap) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Add a single vertex. dba.InsertVertex(); dba.AdvanceCommand(); - EXPECT_EQ(1, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(1, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n SET n = {property: 42} @@ -1003,16 +1022,16 @@ TEST(QueryPlan, DeleteSetPropertiesFromMap) { } TEST(QueryPlan, DeleteSetPropertiesFrom) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Add a single vertex. { auto v = dba.InsertVertex(); - ASSERT_TRUE(v.SetProperty(dba.NameToProperty("property"), storage::PropertyValue(1)).HasValue()); + ASSERT_TRUE(v.SetProperty(dba.NameToProperty("property"), memgraph::storage::PropertyValue(1)).HasValue()); } dba.AdvanceCommand(); - EXPECT_EQ(1, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(1, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n SET n = n @@ -1028,33 +1047,33 @@ TEST(QueryPlan, DeleteSetPropertiesFrom) { } TEST(QueryPlan, DeleteRemoveLabels) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Add a single vertex. dba.InsertVertex(); dba.AdvanceCommand(); - EXPECT_EQ(1, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(1, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n REMOVE n :label auto n = MakeScanAll(storage, symbol_table, "n"); auto n_get = storage.Create("n")->MapTo(n.sym_); auto delete_op = std::make_shared(n.op_, std::vector{n_get}, false); - std::vector labels{dba.NameToLabel("label")}; + std::vector labels{dba.NameToLabel("label")}; auto rem_op = std::make_shared(delete_op, n.sym_, labels); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_THROW(PullAll(*rem_op, &context), QueryRuntimeException); } TEST(QueryPlan, DeleteRemoveProperty) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Add a single vertex. dba.InsertVertex(); dba.AdvanceCommand(); - EXPECT_EQ(1, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(1, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n REMOVE n.property diff --git a/tests/unit/query_plan_edge_cases.cpp b/tests/unit/query_plan_edge_cases.cpp index 0e3c8e348..fe9f0e5f5 100644 --- a/tests/unit/query_plan_edge_cases.cpp +++ b/tests/unit/query_plan_edge_cases.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,15 +27,15 @@ DECLARE_bool(query_cost_planner); class QueryExecution : public testing::Test { protected: - std::optional db_; - std::optional interpreter_context_; - std::optional interpreter_; + std::optional db_; + std::optional interpreter_context_; + std::optional interpreter_; std::filesystem::path data_directory{std::filesystem::temp_directory_path() / "MG_tests_unit_query_plan_edge_cases"}; void SetUp() { db_.emplace(); - interpreter_context_.emplace(&*db_, query::InterpreterConfig{}, data_directory); + interpreter_context_.emplace(&*db_, memgraph::query::InterpreterConfig{}, data_directory); interpreter_.emplace(&*interpreter_context_); } diff --git a/tests/unit/query_plan_match_filter_return.cpp b/tests/unit/query_plan_match_filter_return.cpp index 81337b854..5d885b1bb 100644 --- a/tests/unit/query_plan_match_filter_return.cpp +++ b/tests/unit/query_plan_match_filter_return.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -31,14 +31,14 @@ #include "query_plan_common.hpp" -using namespace query; -using namespace query::plan; +using namespace memgraph::query; +using namespace memgraph::query::plan; class MatchReturnFixture : public testing::Test { protected: - storage::Storage db; - storage::Storage::Accessor storage_dba{db.Access()}; - query::DbAccessor dba{&storage_dba}; + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor storage_dba{db.Access()}; + memgraph::query::DbAccessor dba{&storage_dba}; AstStorage storage; SymbolTable symbol_table; @@ -58,7 +58,7 @@ TEST_F(MatchReturnFixture, MatchReturn) { AddVertices(2); dba.AdvanceCommand(); - auto test_pull_count = [&](storage::View view) { + auto test_pull_count = [&](memgraph::storage::View view) { auto scan_all = MakeScanAll(storage, symbol_table, "n", nullptr, view); auto output = NEXPR("n", IDENT("n")->MapTo(scan_all.sym_))->MapTo(symbol_table.CreateSymbol("named_expression_1", true)); @@ -67,13 +67,13 @@ TEST_F(MatchReturnFixture, MatchReturn) { return PullAll(*produce, &context); }; - EXPECT_EQ(2, test_pull_count(storage::View::NEW)); - EXPECT_EQ(2, test_pull_count(storage::View::OLD)); + EXPECT_EQ(2, test_pull_count(memgraph::storage::View::NEW)); + EXPECT_EQ(2, test_pull_count(memgraph::storage::View::OLD)); dba.InsertVertex(); - EXPECT_EQ(3, test_pull_count(storage::View::NEW)); - EXPECT_EQ(2, test_pull_count(storage::View::OLD)); + EXPECT_EQ(3, test_pull_count(memgraph::storage::View::NEW)); + EXPECT_EQ(2, test_pull_count(memgraph::storage::View::OLD)); dba.AdvanceCommand(); - EXPECT_EQ(3, test_pull_count(storage::View::OLD)); + EXPECT_EQ(3, test_pull_count(memgraph::storage::View::OLD)); } TEST_F(MatchReturnFixture, MatchReturnPath) { @@ -88,16 +88,16 @@ TEST_F(MatchReturnFixture, MatchReturnPath) { auto produce = MakeProduce(make_path, output); auto results = PathResults(produce); ASSERT_EQ(results.size(), 2); - std::vector expected_paths; - for (const auto &v : dba.Vertices(storage::View::OLD)) expected_paths.emplace_back(v); + std::vector expected_paths; + for (const auto &v : dba.Vertices(memgraph::storage::View::OLD)) expected_paths.emplace_back(v); ASSERT_EQ(expected_paths.size(), 2); EXPECT_TRUE(std::is_permutation(expected_paths.begin(), expected_paths.end(), results.begin())); } TEST(QueryPlan, MatchReturnCartesian) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); ASSERT_TRUE(dba.InsertVertex().AddLabel(dba.NameToLabel("l1")).HasValue()); ASSERT_TRUE(dba.InsertVertex().AddLabel(dba.NameToLabel("l2")).HasValue()); @@ -121,9 +121,9 @@ TEST(QueryPlan, MatchReturnCartesian) { } TEST(QueryPlan, StandaloneReturn) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // add a few nodes to the database dba.InsertVertex(); @@ -145,12 +145,12 @@ TEST(QueryPlan, StandaloneReturn) { } TEST(QueryPlan, NodeFilterLabelsAndProperties) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // add a few nodes to the database - storage::LabelId label = dba.NameToLabel("Label"); + memgraph::storage::LabelId label = dba.NameToLabel("Label"); auto property = PROPERTY_PAIR("Property"); auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); @@ -165,10 +165,10 @@ TEST(QueryPlan, NodeFilterLabelsAndProperties) { ASSERT_TRUE(v2.AddLabel(label).HasValue()); ASSERT_TRUE(v3.AddLabel(label).HasValue()); // v1 and v4 will have the right properties - ASSERT_TRUE(v1.SetProperty(property.second, storage::PropertyValue(42)).HasValue()); - ASSERT_TRUE(v2.SetProperty(property.second, storage::PropertyValue(1)).HasValue()); - ASSERT_TRUE(v4.SetProperty(property.second, storage::PropertyValue(42)).HasValue()); - ASSERT_TRUE(v5.SetProperty(property.second, storage::PropertyValue(1)).HasValue()); + ASSERT_TRUE(v1.SetProperty(property.second, memgraph::storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(v2.SetProperty(property.second, memgraph::storage::PropertyValue(1)).HasValue()); + ASSERT_TRUE(v4.SetProperty(property.second, memgraph::storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(v5.SetProperty(property.second, memgraph::storage::PropertyValue(1)).HasValue()); dba.AdvanceCommand(); AstStorage storage; @@ -199,14 +199,14 @@ TEST(QueryPlan, NodeFilterLabelsAndProperties) { } TEST(QueryPlan, NodeFilterMultipleLabels) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // add a few nodes to the database - storage::LabelId label1 = dba.NameToLabel("label1"); - storage::LabelId label2 = dba.NameToLabel("label2"); - storage::LabelId label3 = dba.NameToLabel("label3"); + memgraph::storage::LabelId label1 = dba.NameToLabel("label1"); + memgraph::storage::LabelId label2 = dba.NameToLabel("label2"); + memgraph::storage::LabelId label3 = dba.NameToLabel("label3"); // the test will look for nodes that have label1 and label2 dba.InsertVertex(); // NOT accepted ASSERT_TRUE(dba.InsertVertex().AddLabel(label1).HasValue()); // NOT accepted @@ -246,9 +246,9 @@ TEST(QueryPlan, NodeFilterMultipleLabels) { } TEST(QueryPlan, Cartesian) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto add_vertex = [&dba](std::string label) { auto vertex = dba.InsertVertex(); @@ -256,7 +256,7 @@ TEST(QueryPlan, Cartesian) { return vertex; }; - std::vector vertices{add_vertex("v1"), add_vertex("v2"), add_vertex("v3")}; + std::vector vertices{add_vertex("v1"), add_vertex("v2"), add_vertex("v3")}; dba.AdvanceCommand(); AstStorage storage; @@ -285,9 +285,9 @@ TEST(QueryPlan, Cartesian) { } TEST(QueryPlan, CartesianEmptySet) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -308,16 +308,16 @@ TEST(QueryPlan, CartesianEmptySet) { } TEST(QueryPlan, CartesianThreeWay) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto add_vertex = [&dba](std::string label) { auto vertex = dba.InsertVertex(); MG_ASSERT(vertex.AddLabel(dba.NameToLabel(label)).HasValue()); return vertex; }; - std::vector vertices{add_vertex("v1"), add_vertex("v2"), add_vertex("v3")}; + std::vector vertices{add_vertex("v1"), add_vertex("v2"), add_vertex("v3")}; dba.AdvanceCommand(); AstStorage storage; @@ -357,19 +357,19 @@ TEST(QueryPlan, CartesianThreeWay) { class ExpandFixture : public testing::Test { protected: - storage::Storage db; - storage::Storage::Accessor storage_dba{db.Access()}; - query::DbAccessor dba{&storage_dba}; + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor storage_dba{db.Access()}; + memgraph::query::DbAccessor dba{&storage_dba}; AstStorage storage; SymbolTable symbol_table; // make a V-graph (v3)<-[r2]-(v1)-[r1]->(v2) - query::VertexAccessor v1{dba.InsertVertex()}; - query::VertexAccessor v2{dba.InsertVertex()}; - query::VertexAccessor v3{dba.InsertVertex()}; - storage::EdgeTypeId edge_type{db.NameToEdgeType("Edge")}; - query::EdgeAccessor r1{*dba.InsertEdge(&v1, &v2, edge_type)}; - query::EdgeAccessor r2{*dba.InsertEdge(&v1, &v3, edge_type)}; + memgraph::query::VertexAccessor v1{dba.InsertVertex()}; + memgraph::query::VertexAccessor v2{dba.InsertVertex()}; + memgraph::query::VertexAccessor v3{dba.InsertVertex()}; + memgraph::storage::EdgeTypeId edge_type{db.NameToEdgeType("Edge")}; + memgraph::query::EdgeAccessor r1{*dba.InsertEdge(&v1, &v2, edge_type)}; + memgraph::query::EdgeAccessor r2{*dba.InsertEdge(&v1, &v3, edge_type)}; void SetUp() override { ASSERT_TRUE(v1.AddLabel(dba.NameToLabel("l1")).HasValue()); @@ -380,7 +380,7 @@ class ExpandFixture : public testing::Test { }; TEST_F(ExpandFixture, Expand) { - auto test_expand = [&](EdgeAtom::Direction direction, storage::View view) { + auto test_expand = [&](EdgeAtom::Direction direction, memgraph::storage::View view) { auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", direction, {}, "m", false, view); @@ -395,22 +395,22 @@ TEST_F(ExpandFixture, Expand) { // test that expand works well for both old and new graph state ASSERT_TRUE(dba.InsertEdge(&v1, &v2, edge_type).HasValue()); ASSERT_TRUE(dba.InsertEdge(&v1, &v3, edge_type).HasValue()); - EXPECT_EQ(2, test_expand(EdgeAtom::Direction::OUT, storage::View::OLD)); - EXPECT_EQ(2, test_expand(EdgeAtom::Direction::IN, storage::View::OLD)); - EXPECT_EQ(4, test_expand(EdgeAtom::Direction::BOTH, storage::View::OLD)); - EXPECT_EQ(4, test_expand(EdgeAtom::Direction::OUT, storage::View::NEW)); - EXPECT_EQ(4, test_expand(EdgeAtom::Direction::IN, storage::View::NEW)); - EXPECT_EQ(8, test_expand(EdgeAtom::Direction::BOTH, storage::View::NEW)); + EXPECT_EQ(2, test_expand(EdgeAtom::Direction::OUT, memgraph::storage::View::OLD)); + EXPECT_EQ(2, test_expand(EdgeAtom::Direction::IN, memgraph::storage::View::OLD)); + EXPECT_EQ(4, test_expand(EdgeAtom::Direction::BOTH, memgraph::storage::View::OLD)); + EXPECT_EQ(4, test_expand(EdgeAtom::Direction::OUT, memgraph::storage::View::NEW)); + EXPECT_EQ(4, test_expand(EdgeAtom::Direction::IN, memgraph::storage::View::NEW)); + EXPECT_EQ(8, test_expand(EdgeAtom::Direction::BOTH, memgraph::storage::View::NEW)); dba.AdvanceCommand(); - EXPECT_EQ(4, test_expand(EdgeAtom::Direction::OUT, storage::View::OLD)); - EXPECT_EQ(4, test_expand(EdgeAtom::Direction::IN, storage::View::OLD)); - EXPECT_EQ(8, test_expand(EdgeAtom::Direction::BOTH, storage::View::OLD)); + EXPECT_EQ(4, test_expand(EdgeAtom::Direction::OUT, memgraph::storage::View::OLD)); + EXPECT_EQ(4, test_expand(EdgeAtom::Direction::IN, memgraph::storage::View::OLD)); + EXPECT_EQ(8, test_expand(EdgeAtom::Direction::BOTH, memgraph::storage::View::OLD)); } TEST_F(ExpandFixture, ExpandPath) { auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::OUT, {}, "m", false, - storage::View::OLD); + memgraph::storage::View::OLD); Symbol path_sym = symbol_table.CreateSymbol("path", true); auto path = std::make_shared(r_m.op_, path_sym, std::vector{n.sym_, r_m.edge_sym_, r_m.node_sym_}); @@ -418,11 +418,12 @@ TEST_F(ExpandFixture, ExpandPath) { NEXPR("path", IDENT("path")->MapTo(path_sym))->MapTo(symbol_table.CreateSymbol("named_expression_1", true)); auto produce = MakeProduce(path, output); - std::vector expected_paths{query::Path(v1, r2, v3), query::Path(v1, r1, v2)}; + std::vector expected_paths{memgraph::query::Path(v1, r2, v3), + memgraph::query::Path(v1, r1, v2)}; auto context = MakeContext(storage, symbol_table, &dba); auto results = CollectProduce(*produce, &context); ASSERT_EQ(results.size(), 2); - std::vector results_paths; + std::vector results_paths; for (const auto &result : results) results_paths.emplace_back(result[0].ValuePath()); EXPECT_TRUE(std::is_permutation(expected_paths.begin(), expected_paths.end(), results_paths.begin())); } @@ -445,13 +446,13 @@ class QueryPlanExpandVariable : public testing::Test { // a lot below in test declaration using map_int = std::unordered_map; - storage::Storage db; - storage::Storage::Accessor storage_dba{db.Access()}; - query::DbAccessor dba{&storage_dba}; + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor storage_dba{db.Access()}; + memgraph::query::DbAccessor dba{&storage_dba}; // labels for layers in the double chain - std::vector labels; + std::vector labels; // for all the edges - storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type"); + memgraph::storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type"); AstStorage storage; SymbolTable symbol_table; @@ -462,9 +463,9 @@ class QueryPlanExpandVariable : public testing::Test { void SetUp() { // create the graph int chain_length = 3; - std::vector layer; + std::vector layer; for (int from_layer_ind = -1; from_layer_ind < chain_length - 1; from_layer_ind++) { - std::vector new_layer{dba.InsertVertex(), dba.InsertVertex()}; + std::vector new_layer{dba.InsertVertex(), dba.InsertVertex()}; auto label = dba.NameToLabel(std::to_string(from_layer_ind + 1)); labels.push_back(label); for (size_t v_to_ind = 0; v_to_ind < new_layer.size(); v_to_ind++) { @@ -474,16 +475,16 @@ class QueryPlanExpandVariable : public testing::Test { auto &v_from = layer[v_from_ind]; auto edge = dba.InsertEdge(&v_from, &v_to, edge_type); ASSERT_TRUE(edge->SetProperty(dba.NameToProperty("p"), - storage::PropertyValue(fmt::format("V{}{}->V{}{}", from_layer_ind, v_from_ind, - from_layer_ind + 1, v_to_ind))) + memgraph::storage::PropertyValue(fmt::format( + "V{}{}->V{}{}", from_layer_ind, v_from_ind, from_layer_ind + 1, v_to_ind))) .HasValue()); } } layer = new_layer; } dba.AdvanceCommand(); - ASSERT_EQ(CountIterable(dba.Vertices(storage::View::OLD)), 2 * chain_length); - ASSERT_EQ(CountEdges(&dba, storage::View::OLD), 4 * (chain_length - 1)); + ASSERT_EQ(CountIterable(dba.Vertices(memgraph::storage::View::OLD)), 2 * chain_length); + ASSERT_EQ(CountEdges(&dba, memgraph::storage::View::OLD), 4 * (chain_length - 1)); } /** @@ -500,14 +501,15 @@ class QueryPlanExpandVariable : public testing::Test { template std::shared_ptr AddMatch(std::shared_ptr input_op, const std::string &node_from, int layer, EdgeAtom::Direction direction, - const std::vector &edge_types, + const std::vector &edge_types, std::optional lower, std::optional upper, Symbol edge_sym, - const std::string &node_to, storage::View view, bool is_reverse = false) { + const std::string &node_to, memgraph::storage::View view, + bool is_reverse = false) { auto n_from = MakeScanAll(storage, symbol_table, node_from, input_op); auto filter_op = std::make_shared( n_from.op_, - storage.Create(n_from.node_->identifier_, - std::vector{storage.GetLabelIx(dba.LabelToName(labels[layer]))})); + storage.Create( + n_from.node_->identifier_, std::vector{storage.GetLabelIx(dba.LabelToName(labels[layer]))})); auto n_to = NODE(node_to); auto n_to_sym = symbol_table.CreateSymbol(node_to, true); @@ -518,7 +520,8 @@ class QueryPlanExpandVariable : public testing::Test { auto convert = [this](std::optional bound) { return bound ? LITERAL(static_cast(bound.value())) : nullptr; }; - MG_ASSERT(view == storage::View::OLD, "ExpandVariable should only be planned with storage::View::OLD"); + MG_ASSERT(view == memgraph::storage::View::OLD, + "ExpandVariable should only be planned with memgraph::storage::View::OLD"); return std::make_shared(filter_op, n_from.sym_, n_to_sym, edge_sym, EdgeAtom::Type::DEPTH_FIRST, direction, edge_types, is_reverse, convert(lower), convert(upper), false, @@ -542,9 +545,9 @@ class QueryPlanExpandVariable : public testing::Test { */ auto GetListResults(std::shared_ptr input_op, Symbol symbol) { Frame frame(symbol_table.max_position()); - auto cursor = input_op->MakeCursor(utils::NewDeleteResource()); + auto cursor = input_op->MakeCursor(memgraph::utils::NewDeleteResource()); auto context = MakeContext(storage, symbol_table, &dba); - std::vector> results; + std::vector> results; while (cursor->Pull(frame, context)) results.emplace_back(frame[symbol].ValueList()); return results; } @@ -554,7 +557,7 @@ class QueryPlanExpandVariable : public testing::Test { */ auto GetPathResults(std::shared_ptr input_op, Symbol symbol) { Frame frame(symbol_table.max_position()); - auto cursor = input_op->MakeCursor(utils::NewDeleteResource()); + auto cursor = input_op->MakeCursor(memgraph::utils::NewDeleteResource()); auto context = MakeContext(storage, symbol_table, &dba); std::vector results; while (cursor->Pull(frame, context)) results.emplace_back(frame[symbol].ValuePath()); @@ -585,9 +588,9 @@ TEST_F(QueryPlanExpandVariable, OneVariableExpansion) { auto test_expand = [&](int layer, EdgeAtom::Direction direction, std::optional lower, std::optional upper, bool reverse) { auto e = Edge("r", direction); - return GetEdgeListSizes( - AddMatch(nullptr, "n", layer, direction, {}, lower, upper, e, "m", storage::View::OLD, reverse), - e); + return GetEdgeListSizes(AddMatch(nullptr, "n", layer, direction, {}, lower, upper, e, "m", + memgraph::storage::View::OLD, reverse), + e); }; for (int reverse = 0; reverse < 2; ++reverse) { @@ -625,19 +628,19 @@ TEST_F(QueryPlanExpandVariable, EdgeUniquenessSingleAndVariableExpansion) { if (single_expansion_before) { symbols.push_back(Edge("r0", direction)); - last_op = - AddMatch(last_op, "n0", layer, direction, {}, lower, upper, symbols.back(), "m0", storage::View::OLD); + last_op = AddMatch(last_op, "n0", layer, direction, {}, lower, upper, symbols.back(), "m0", + memgraph::storage::View::OLD); } auto var_length_sym = Edge("r1", direction); symbols.push_back(var_length_sym); last_op = AddMatch(last_op, "n1", layer, direction, {}, lower, upper, var_length_sym, "m1", - storage::View::OLD); + memgraph::storage::View::OLD); if (!single_expansion_before) { symbols.push_back(Edge("r2", direction)); - last_op = - AddMatch(last_op, "n2", layer, direction, {}, lower, upper, symbols.back(), "m2", storage::View::OLD); + last_op = AddMatch(last_op, "n2", layer, direction, {}, lower, upper, symbols.back(), "m2", + memgraph::storage::View::OLD); } if (add_uniqueness_check) { @@ -660,11 +663,11 @@ TEST_F(QueryPlanExpandVariable, EdgeUniquenessTwoVariableExpansions) { auto test_expand = [&](int layer, EdgeAtom::Direction direction, std::optional lower, std::optional upper, bool add_uniqueness_check) { auto e1 = Edge("r1", direction); - auto first = - AddMatch(nullptr, "n1", layer, direction, {}, lower, upper, e1, "m1", storage::View::OLD); + auto first = AddMatch(nullptr, "n1", layer, direction, {}, lower, upper, e1, "m1", + memgraph::storage::View::OLD); auto e2 = Edge("r2", direction); - auto last_op = - AddMatch(first, "n2", layer, direction, {}, lower, upper, e2, "m2", storage::View::OLD); + auto last_op = AddMatch(first, "n2", layer, direction, {}, lower, upper, e2, "m2", + memgraph::storage::View::OLD); if (add_uniqueness_check) { last_op = std::make_shared(last_op, e2, std::vector{e1}); } @@ -678,8 +681,8 @@ TEST_F(QueryPlanExpandVariable, EdgeUniquenessTwoVariableExpansions) { TEST_F(QueryPlanExpandVariable, NamedPath) { auto e = Edge("r", EdgeAtom::Direction::OUT); - auto expand = - AddMatch(nullptr, "n", 0, EdgeAtom::Direction::OUT, {}, 2, 2, e, "m", storage::View::OLD); + auto expand = AddMatch(nullptr, "n", 0, EdgeAtom::Direction::OUT, {}, 2, 2, e, "m", + memgraph::storage::View::OLD); auto find_symbol = [this](const std::string &name) { for (const auto &sym : symbol_table.table()) if (sym.second.name() == name) return sym.second; @@ -690,12 +693,12 @@ TEST_F(QueryPlanExpandVariable, NamedPath) { auto create_path = std::make_shared(expand, path_symbol, std::vector{find_symbol("n"), e, find_symbol("m")}); - std::vector expected_paths; - for (const auto &v : dba.Vertices(storage::View::OLD)) { - if (!*v.HasLabel(storage::View::OLD, labels[0])) continue; - auto maybe_edges1 = v.OutEdges(storage::View::OLD); + std::vector expected_paths; + for (const auto &v : dba.Vertices(memgraph::storage::View::OLD)) { + if (!*v.HasLabel(memgraph::storage::View::OLD, labels[0])) continue; + auto maybe_edges1 = v.OutEdges(memgraph::storage::View::OLD); for (const auto &e1 : *maybe_edges1) { - auto maybe_edges2 = e1.To().OutEdges(storage::View::OLD); + auto maybe_edges2 = e1.To().OutEdges(memgraph::storage::View::OLD); for (const auto &e2 : *maybe_edges2) { expected_paths.emplace_back(v, e1, e1.To(), e2, e2.To()); } @@ -716,27 +719,27 @@ TEST_F(QueryPlanExpandVariable, ExpandToSameSymbol) { auto node = NODE("n"); auto symbol = symbol_table.CreateSymbol("n", true); node->identifier_->MapTo(symbol); - auto logical_op = std::make_shared(nullptr, symbol, storage::View::OLD); + auto logical_op = std::make_shared(nullptr, symbol, memgraph::storage::View::OLD); auto n_from = ScanAllTuple{node, logical_op, symbol}; auto filter_op = std::make_shared( n_from.op_, - storage.Create(n_from.node_->identifier_, - std::vector{storage.GetLabelIx(dba.LabelToName(labels[layer]))})); + storage.Create( + n_from.node_->identifier_, std::vector{storage.GetLabelIx(dba.LabelToName(labels[layer]))})); // convert optional ints to optional expressions auto convert = [this](std::optional bound) { return bound ? LITERAL(static_cast(bound.value())) : nullptr; }; - return GetEdgeListSizes( - std::make_shared(filter_op, symbol, symbol, e, EdgeAtom::Type::DEPTH_FIRST, direction, - std::vector{}, reverse, convert(lower), convert(upper), - /* existing = */ true, - ExpansionLambda{symbol_table.CreateSymbol("inner_edge", false), - symbol_table.CreateSymbol("inner_node", false), nullptr}, - std::nullopt, std::nullopt), - e); + return GetEdgeListSizes(std::make_shared( + filter_op, symbol, symbol, e, EdgeAtom::Type::DEPTH_FIRST, direction, + std::vector{}, reverse, convert(lower), convert(upper), + /* existing = */ true, + ExpansionLambda{symbol_table.CreateSymbol("inner_edge", false), + symbol_table.CreateSymbol("inner_node", false), nullptr}, + std::nullopt, std::nullopt), + e); }; // The graph is a double chain: @@ -909,24 +912,24 @@ struct hash> { class QueryPlanExpandWeightedShortestPath : public testing::Test { public: struct ResultType { - std::vector path; - query::VertexAccessor vertex; + std::vector path; + memgraph::query::VertexAccessor vertex; double total_weight; }; protected: - storage::Storage db; - storage::Storage::Accessor storage_dba{db.Access()}; - query::DbAccessor dba{&storage_dba}; - std::pair prop = PROPERTY_PAIR("property"); - storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type"); + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor storage_dba{db.Access()}; + memgraph::query::DbAccessor dba{&storage_dba}; + std::pair prop = PROPERTY_PAIR("property"); + memgraph::storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type"); // make 5 vertices because we'll need to compare against them exactly // v[0] has `prop` with the value 0 - std::vector v; + std::vector v; // make some edges too, in a map (from, to) vertex indices - std::unordered_map, query::EdgeAccessor> e; + std::unordered_map, memgraph::query::EdgeAccessor> e; AstStorage storage; SymbolTable symbol_table; @@ -943,12 +946,12 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test { void SetUp() { for (int i = 0; i < 5; i++) { v.push_back(dba.InsertVertex()); - ASSERT_TRUE(v.back().SetProperty(prop.second, storage::PropertyValue(i)).HasValue()); + ASSERT_TRUE(v.back().SetProperty(prop.second, memgraph::storage::PropertyValue(i)).HasValue()); } auto add_edge = [&](int from, int to, double weight) { auto edge = dba.InsertEdge(&v[from], &v[to], edge_type); - ASSERT_TRUE(edge->SetProperty(prop.second, storage::PropertyValue(weight)).HasValue()); + ASSERT_TRUE(edge->SetProperty(prop.second, memgraph::storage::PropertyValue(weight)).HasValue()); e.emplace(std::make_pair(from, to), *edge); }; @@ -982,16 +985,16 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test { auto edge_list_sym = symbol_table.CreateSymbol("edgelist_", true); auto filter_lambda = last_op = std::make_shared( last_op, n.sym_, node_sym, edge_list_sym, EdgeAtom::Type::WEIGHTED_SHORTEST_PATH, direction, - std::vector{}, false, nullptr, max_depth ? LITERAL(max_depth.value()) : nullptr, + std::vector{}, false, nullptr, max_depth ? LITERAL(max_depth.value()) : nullptr, existing_node_input != nullptr, ExpansionLambda{filter_edge, filter_node, where}, ExpansionLambda{weight_edge, weight_node, PROPERTY_LOOKUP(ident_e, prop)}, total_weight); Frame frame(symbol_table.max_position()); - auto cursor = last_op->MakeCursor(utils::NewDeleteResource()); + auto cursor = last_op->MakeCursor(memgraph::utils::NewDeleteResource()); std::vector results; auto context = MakeContext(storage, symbol_table, &dba); while (cursor->Pull(frame, context)) { - results.push_back(ResultType{std::vector(), frame[node_sym].ValueVertex(), + results.push_back(ResultType{std::vector(), frame[node_sym].ValueVertex(), frame[total_weight].ValueDouble()}); for (const TypedValue &edge : frame[edge_list_sym].ValueList()) results.back().path.emplace_back(edge.ValueEdge()); @@ -1002,12 +1005,12 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test { template auto GetProp(const TAccessor &accessor) { - return accessor.GetProperty(storage::View::OLD, prop.second)->ValueInt(); + return accessor.GetProperty(memgraph::storage::View::OLD, prop.second)->ValueInt(); } template auto GetDoubleProp(const TAccessor &accessor) { - return accessor.GetProperty(storage::View::OLD, prop.second)->ValueDouble(); + return accessor.GetProperty(memgraph::storage::View::OLD, prop.second)->ValueDouble(); } Expression *PropNe(Symbol symbol, int value) { @@ -1172,10 +1175,10 @@ TEST_F(QueryPlanExpandWeightedShortestPath, UpperBound) { } { auto new_vertex = dba.InsertVertex(); - ASSERT_TRUE(new_vertex.SetProperty(prop.second, storage::PropertyValue(5)).HasValue()); + ASSERT_TRUE(new_vertex.SetProperty(prop.second, memgraph::storage::PropertyValue(5)).HasValue()); auto edge = dba.InsertEdge(&v[4], &new_vertex, edge_type); ASSERT_TRUE(edge.HasValue()); - ASSERT_TRUE(edge->SetProperty(prop.second, storage::PropertyValue(2)).HasValue()); + ASSERT_TRUE(edge->SetProperty(prop.second, memgraph::storage::PropertyValue(2)).HasValue()); dba.AdvanceCommand(); auto results = ExpandWShortest(EdgeAtom::Direction::BOTH, 3, LITERAL(true)); @@ -1196,20 +1199,20 @@ TEST_F(QueryPlanExpandWeightedShortestPath, UpperBound) { TEST_F(QueryPlanExpandWeightedShortestPath, NonNumericWeight) { auto new_vertex = dba.InsertVertex(); - ASSERT_TRUE(new_vertex.SetProperty(prop.second, storage::PropertyValue(5)).HasValue()); + ASSERT_TRUE(new_vertex.SetProperty(prop.second, memgraph::storage::PropertyValue(5)).HasValue()); auto edge = dba.InsertEdge(&v[4], &new_vertex, edge_type); ASSERT_TRUE(edge.HasValue()); - ASSERT_TRUE(edge->SetProperty(prop.second, storage::PropertyValue("not a number")).HasValue()); + ASSERT_TRUE(edge->SetProperty(prop.second, memgraph::storage::PropertyValue("not a number")).HasValue()); dba.AdvanceCommand(); EXPECT_THROW(ExpandWShortest(EdgeAtom::Direction::BOTH, 1000, LITERAL(true)), QueryRuntimeException); } TEST_F(QueryPlanExpandWeightedShortestPath, NegativeWeight) { auto new_vertex = dba.InsertVertex(); - ASSERT_TRUE(new_vertex.SetProperty(prop.second, storage::PropertyValue(5)).HasValue()); + ASSERT_TRUE(new_vertex.SetProperty(prop.second, memgraph::storage::PropertyValue(5)).HasValue()); auto edge = dba.InsertEdge(&v[4], &new_vertex, edge_type); ASSERT_TRUE(edge.HasValue()); - ASSERT_TRUE(edge->SetProperty(prop.second, storage::PropertyValue(-10)).HasValue()); // negative weight + ASSERT_TRUE(edge->SetProperty(prop.second, memgraph::storage::PropertyValue(-10)).HasValue()); // negative weight dba.AdvanceCommand(); EXPECT_THROW(ExpandWShortest(EdgeAtom::Direction::BOTH, 1000, LITERAL(true)), QueryRuntimeException); } @@ -1219,9 +1222,9 @@ TEST_F(QueryPlanExpandWeightedShortestPath, NegativeUpperBound) { } TEST(QueryPlan, ExpandOptional) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -1230,19 +1233,19 @@ TEST(QueryPlan, ExpandOptional) { auto prop = dba.NameToProperty("p"); auto edge_type = dba.NameToEdgeType("T"); auto v1 = dba.InsertVertex(); - ASSERT_TRUE(v1.SetProperty(prop, storage::PropertyValue(1)).HasValue()); + ASSERT_TRUE(v1.SetProperty(prop, memgraph::storage::PropertyValue(1)).HasValue()); auto v2 = dba.InsertVertex(); - ASSERT_TRUE(v2.SetProperty(prop, storage::PropertyValue(2)).HasValue()); + ASSERT_TRUE(v2.SetProperty(prop, memgraph::storage::PropertyValue(2)).HasValue()); ASSERT_TRUE(dba.InsertEdge(&v1, &v2, edge_type).HasValue()); auto v3 = dba.InsertVertex(); - ASSERT_TRUE(v3.SetProperty(prop, storage::PropertyValue(2)).HasValue()); + ASSERT_TRUE(v3.SetProperty(prop, memgraph::storage::PropertyValue(2)).HasValue()); ASSERT_TRUE(dba.InsertEdge(&v1, &v3, edge_type).HasValue()); dba.AdvanceCommand(); // MATCH (n) OPTIONAL MATCH (n)-[r]->(m) auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, nullptr, n.sym_, "r", EdgeAtom::Direction::OUT, {}, "m", false, - storage::View::OLD); + memgraph::storage::View::OLD); auto optional = std::make_shared(n.op_, r_m.op_, std::vector{r_m.edge_sym_, r_m.node_sym_}); // RETURN n, r, m @@ -1257,8 +1260,8 @@ TEST(QueryPlan, ExpandOptional) { for (auto &row : results) { ASSERT_EQ(row[0].type(), TypedValue::Type::Vertex); auto &va = row[0].ValueVertex(); - auto va_p = *va.GetProperty(storage::View::OLD, prop); - ASSERT_EQ(va_p.type(), storage::PropertyValue::Type::Int); + auto va_p = *va.GetProperty(memgraph::storage::View::OLD, prop); + ASSERT_EQ(va_p.type(), memgraph::storage::PropertyValue::Type::Int); if (va_p.ValueInt() == 1) { v1_is_n_count++; EXPECT_EQ(row[1].type(), TypedValue::Type::Edge); @@ -1272,9 +1275,9 @@ TEST(QueryPlan, ExpandOptional) { } TEST(QueryPlan, OptionalMatchEmptyDB) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -1292,9 +1295,9 @@ TEST(QueryPlan, OptionalMatchEmptyDB) { } TEST(QueryPlan, OptionalMatchEmptyDBExpandFromNode) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; // OPTIONAL MATCH (n) @@ -1307,7 +1310,7 @@ TEST(QueryPlan, OptionalMatchEmptyDBExpandFromNode) { auto with = MakeProduce(optional, n_ne); // MATCH (n) -[r]-> (m) auto r_m = MakeExpand(storage, symbol_table, with, with_n_sym, "r", EdgeAtom::Direction::OUT, {}, "m", false, - storage::View::OLD); + memgraph::storage::View::OLD); // RETURN m auto m_ne = NEXPR("m", IDENT("m")->MapTo(r_m.node_sym_))->MapTo(symbol_table.CreateSymbol("m", true)); auto produce = MakeProduce(r_m.op_, m_ne); @@ -1317,17 +1320,17 @@ TEST(QueryPlan, OptionalMatchEmptyDBExpandFromNode) { } TEST(QueryPlan, OptionalMatchThenExpandToMissingNode) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Make a graph with 2 connected, unlabeled nodes. auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); auto edge_type = dba.NameToEdgeType("edge_type"); ASSERT_TRUE(dba.InsertEdge(&v1, &v2, edge_type).HasValue()); dba.AdvanceCommand(); - EXPECT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD))); - EXPECT_EQ(1, CountEdges(&dba, storage::View::OLD)); + EXPECT_EQ(2, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); + EXPECT_EQ(1, CountEdges(&dba, memgraph::storage::View::OLD)); AstStorage storage; SymbolTable symbol_table; // OPTIONAL MATCH (n :missing) @@ -1351,8 +1354,9 @@ TEST(QueryPlan, OptionalMatchThenExpandToMissingNode) { edge->identifier_->MapTo(edge_sym); auto node = NODE("n"); node->identifier_->MapTo(with_n_sym); - auto expand = std::make_shared(m.op_, m.sym_, with_n_sym, edge_sym, edge_direction, - std::vector{}, true, storage::View::OLD); + auto expand = + std::make_shared(m.op_, m.sym_, with_n_sym, edge_sym, edge_direction, + std::vector{}, true, memgraph::storage::View::OLD); // RETURN m auto m_ne = NEXPR("m", IDENT("m")->MapTo(m.sym_))->MapTo(symbol_table.CreateSymbol("m", true)); auto produce = MakeProduce(expand, m_ne); @@ -1362,9 +1366,9 @@ TEST(QueryPlan, OptionalMatchThenExpandToMissingNode) { } TEST(QueryPlan, ExpandExistingNode) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // make a graph (v1)->(v2) that // has a recursive edge (v1)->(v1) @@ -1381,10 +1385,11 @@ TEST(QueryPlan, ExpandExistingNode) { auto test_existing = [&](bool with_existing, int expected_result_count) { auto n = MakeScanAll(storage, symbol_table, "n"); auto r_n = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::OUT, {}, "n", with_existing, - storage::View::OLD); + memgraph::storage::View::OLD); if (with_existing) r_n.op_ = std::make_shared(n.op_, n.sym_, n.sym_, r_n.edge_sym_, r_n.edge_->direction_, - std::vector{}, with_existing, storage::View::OLD); + std::vector{}, with_existing, + memgraph::storage::View::OLD); // make a named expression and a produce auto output = NEXPR("n", IDENT("n")->MapTo(n.sym_))->MapTo(symbol_table.CreateSymbol("named_expression_1", true)); @@ -1401,9 +1406,9 @@ TEST(QueryPlan, ExpandExistingNode) { TEST(QueryPlan, ExpandBothCycleEdgeCase) { // we're testing that expanding on BOTH // does only one expansion for a cycle - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v = dba.InsertVertex(); ASSERT_TRUE(dba.InsertEdge(&v, &v, dba.NameToEdgeType("et")).HasValue()); @@ -1414,34 +1419,34 @@ TEST(QueryPlan, ExpandBothCycleEdgeCase) { auto n = MakeScanAll(storage, symbol_table, "n"); auto r_ = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::BOTH, {}, "_", false, - storage::View::OLD); + memgraph::storage::View::OLD); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_EQ(1, PullAll(*r_.op_, &context)); } TEST(QueryPlan, EdgeFilter) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // make an N-star expanding from (v1) // where only one edge will qualify // and there are all combinations of // (edge_type yes|no) * (property yes|absent|no) - std::vector edge_types; + std::vector edge_types; for (int j = 0; j < 2; ++j) edge_types.push_back(dba.NameToEdgeType("et" + std::to_string(j))); - std::vector vertices; + std::vector vertices; for (int i = 0; i < 7; ++i) vertices.push_back(dba.InsertVertex()); auto prop = PROPERTY_PAIR("property"); - std::vector edges; + std::vector edges; for (int i = 0; i < 6; ++i) { edges.push_back(*dba.InsertEdge(&vertices[0], &vertices[i + 1], edge_types[i % 2])); switch (i % 3) { case 0: - ASSERT_TRUE(edges.back().SetProperty(prop.second, storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(edges.back().SetProperty(prop.second, memgraph::storage::PropertyValue(42)).HasValue()); break; case 1: - ASSERT_TRUE(edges.back().SetProperty(prop.second, storage::PropertyValue(100)).HasValue()); + ASSERT_TRUE(edges.back().SetProperty(prop.second, memgraph::storage::PropertyValue(100)).HasValue()); break; default: break; @@ -1459,7 +1464,7 @@ TEST(QueryPlan, EdgeFilter) { auto n = MakeScanAll(storage, symbol_table, "n"); const auto &edge_type = edge_types[0]; auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::OUT, {edge_type}, "m", false, - storage::View::OLD); + memgraph::storage::View::OLD); r_m.edge_->edge_types_.push_back(storage.GetEdgeTypeIx(dba.EdgeTypeToName(edge_type))); std::get<0>(r_m.edge_->properties_)[storage.GetPropertyIx(prop.first)] = LITERAL(42); auto *filter_expr = EQ(PROPERTY_LOOKUP(r_m.edge_->identifier_, prop), LITERAL(42)); @@ -1475,16 +1480,16 @@ TEST(QueryPlan, EdgeFilter) { EXPECT_EQ(1, test_filter()); // test that edge filtering always filters on old state - for (auto &edge : edges) ASSERT_TRUE(edge.SetProperty(prop.second, storage::PropertyValue(42)).HasValue()); + for (auto &edge : edges) ASSERT_TRUE(edge.SetProperty(prop.second, memgraph::storage::PropertyValue(42)).HasValue()); EXPECT_EQ(1, test_filter()); dba.AdvanceCommand(); EXPECT_EQ(3, test_filter()); } TEST(QueryPlan, EdgeFilterMultipleTypes) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); @@ -1502,7 +1507,7 @@ TEST(QueryPlan, EdgeFilterMultipleTypes) { // make a scan all auto n = MakeScanAll(storage, symbol_table, "n"); auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r", EdgeAtom::Direction::OUT, {type_1, type_2}, "m", - false, storage::View::OLD); + false, memgraph::storage::View::OLD); // make a named expression and a produce auto output = @@ -1514,14 +1519,15 @@ TEST(QueryPlan, EdgeFilterMultipleTypes) { } TEST(QueryPlan, Filter) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // add a 6 nodes with property 'prop', 2 have true as value auto property = PROPERTY_PAIR("property"); for (int i = 0; i < 6; ++i) - ASSERT_TRUE(dba.InsertVertex().SetProperty(property.second, storage::PropertyValue(i % 3 == 0)).HasValue()); + ASSERT_TRUE( + dba.InsertVertex().SetProperty(property.second, memgraph::storage::PropertyValue(i % 3 == 0)).HasValue()); dba.InsertVertex(); // prop not set, gives NULL dba.AdvanceCommand(); @@ -1539,9 +1545,9 @@ TEST(QueryPlan, Filter) { } TEST(QueryPlan, EdgeUniquenessFilter) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // make a graph that has (v1)->(v2) and a recursive edge (v1)->(v1) auto v1 = dba.InsertVertex(); @@ -1557,10 +1563,10 @@ TEST(QueryPlan, EdgeUniquenessFilter) { auto n1 = MakeScanAll(storage, symbol_table, "n1"); auto r1_n2 = MakeExpand(storage, symbol_table, n1.op_, n1.sym_, "r1", EdgeAtom::Direction::OUT, {}, "n2", false, - storage::View::OLD); + memgraph::storage::View::OLD); std::shared_ptr last_op = r1_n2.op_; auto r2_n3 = MakeExpand(storage, symbol_table, last_op, r1_n2.node_sym_, "r2", EdgeAtom::Direction::OUT, {}, "n3", - false, storage::View::OLD); + false, memgraph::storage::View::OLD); last_op = r2_n3.op_; if (edge_uniqueness) last_op = std::make_shared(last_op, r2_n3.edge_sym_, std::vector{r1_n2.edge_sym_}); @@ -1576,9 +1582,9 @@ TEST(QueryPlan, Distinct) { // test queries like // UNWIND [1, 2, 3, 3] AS x RETURN DISTINCT x - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); AstStorage storage; SymbolTable symbol_table; @@ -1620,17 +1626,17 @@ TEST(QueryPlan, Distinct) { } TEST(QueryPlan, ScanAllByLabel) { - storage::Storage db; + memgraph::storage::Storage db; auto label = db.NameToLabel("label"); db.CreateIndex(label); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Add a vertex with a label and one without. auto labeled_vertex = dba.InsertVertex(); ASSERT_TRUE(labeled_vertex.AddLabel(label).HasValue()); dba.InsertVertex(); dba.AdvanceCommand(); - EXPECT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD))); + EXPECT_EQ(2, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); // MATCH (n :label) AstStorage storage; SymbolTable symbol_table; @@ -1647,29 +1653,32 @@ TEST(QueryPlan, ScanAllByLabel) { } TEST(QueryPlan, ScanAllByLabelProperty) { - storage::Storage db; + memgraph::storage::Storage db; // Add 5 vertices with same label, but with different property values. auto label = db.NameToLabel("label"); auto prop = db.NameToProperty("prop"); // vertex property values that will be stored into the DB - std::vector values{ - storage::PropertyValue(true), - storage::PropertyValue(false), - storage::PropertyValue("a"), - storage::PropertyValue("b"), - storage::PropertyValue("c"), - storage::PropertyValue(0), - storage::PropertyValue(1), - storage::PropertyValue(2), - storage::PropertyValue(0.5), - storage::PropertyValue(1.5), - storage::PropertyValue(2.5), - storage::PropertyValue(std::vector{storage::PropertyValue(0)}), - storage::PropertyValue(std::vector{storage::PropertyValue(1)}), - storage::PropertyValue(std::vector{storage::PropertyValue(2)})}; + std::vector values{ + memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(false), + memgraph::storage::PropertyValue("a"), + memgraph::storage::PropertyValue("b"), + memgraph::storage::PropertyValue("c"), + memgraph::storage::PropertyValue(0), + memgraph::storage::PropertyValue(1), + memgraph::storage::PropertyValue(2), + memgraph::storage::PropertyValue(0.5), + memgraph::storage::PropertyValue(1.5), + memgraph::storage::PropertyValue(2.5), + memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(0)}), + memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(1)}), + memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(2)})}; { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); for (const auto &value : values) { auto vertex = dba.InsertVertex(); ASSERT_TRUE(vertex.AddLabel(label).HasValue()); @@ -1680,8 +1689,8 @@ TEST(QueryPlan, ScanAllByLabelProperty) { db.CreateIndex(label, prop); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - ASSERT_EQ(14, CountIterable(dba.Vertices(storage::View::OLD))); + memgraph::query::DbAccessor dba(&storage_dba); + ASSERT_EQ(14, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); auto run_scan_all = [&](const TypedValue &lower, Bound::Type lower_type, const TypedValue &upper, Bound::Type upper_type) { @@ -1702,7 +1711,8 @@ TEST(QueryPlan, ScanAllByLabelProperty) { auto results = run_scan_all(lower, lower_type, upper, upper_type); ASSERT_EQ(results.size(), expected.size()); for (size_t i = 0; i < expected.size(); i++) { - TypedValue equal = TypedValue(*results[i][0].ValueVertex().GetProperty(storage::View::OLD, prop)) == expected[i]; + TypedValue equal = + TypedValue(*results[i][0].ValueVertex().GetProperty(memgraph::storage::View::OLD, prop)) == expected[i]; ASSERT_EQ(equal.type(), TypedValue::Type::Bool); EXPECT_TRUE(equal.ValueBool()); } @@ -1715,23 +1725,23 @@ TEST(QueryPlan, ScanAllByLabelProperty) { check(TypedValue(1.5), Bound::Type::EXCLUSIVE, TypedValue(2.5), Bound::Type::INCLUSIVE, {TypedValue(2), TypedValue(2.5)}); - auto are_comparable = [](storage::PropertyValue::Type a, storage::PropertyValue::Type b) { - auto is_numeric = [](const storage::PropertyValue::Type t) { - return t == storage::PropertyValue::Type::Int || t == storage::PropertyValue::Type::Double; + auto are_comparable = [](memgraph::storage::PropertyValue::Type a, memgraph::storage::PropertyValue::Type b) { + auto is_numeric = [](const memgraph::storage::PropertyValue::Type t) { + return t == memgraph::storage::PropertyValue::Type::Int || t == memgraph::storage::PropertyValue::Type::Double; }; return a == b || (is_numeric(a) && is_numeric(b)); }; - auto is_orderable = [](const storage::PropertyValue &t) { + auto is_orderable = [](const memgraph::storage::PropertyValue &t) { return t.IsNull() || t.IsInt() || t.IsDouble() || t.IsString(); }; // when a range contains different types, nothing should get returned for (const auto &value_a : values) { for (const auto &value_b : values) { - if (are_comparable(static_cast(value_a).type(), - static_cast(value_b).type())) + if (are_comparable(static_cast(value_a).type(), + static_cast(value_b).type())) continue; if (is_orderable(value_a) && is_orderable(value_b)) { check(TypedValue(value_a), Bound::Type::INCLUSIVE, TypedValue(value_b), Bound::Type::INCLUSIVE, {}); @@ -1754,27 +1764,27 @@ TEST(QueryPlan, ScanAllByLabelProperty) { } TEST(QueryPlan, ScanAllByLabelPropertyEqualityNoError) { - storage::Storage db; + memgraph::storage::Storage db; // Add 2 vertices with same label, but with property values that cannot be // compared. On the other hand, equality works fine. auto label = db.NameToLabel("label"); auto prop = db.NameToProperty("prop"); { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto number_vertex = dba.InsertVertex(); ASSERT_TRUE(number_vertex.AddLabel(label).HasValue()); - ASSERT_TRUE(number_vertex.SetProperty(prop, storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(number_vertex.SetProperty(prop, memgraph::storage::PropertyValue(42)).HasValue()); auto string_vertex = dba.InsertVertex(); ASSERT_TRUE(string_vertex.AddLabel(label).HasValue()); - ASSERT_TRUE(string_vertex.SetProperty(prop, storage::PropertyValue("string")).HasValue()); + ASSERT_TRUE(string_vertex.SetProperty(prop, memgraph::storage::PropertyValue("string")).HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } db.CreateIndex(label, prop); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - EXPECT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD))); + memgraph::query::DbAccessor dba(&storage_dba); + EXPECT_EQ(2, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); // MATCH (n :label {prop: 42}) AstStorage storage; SymbolTable symbol_table; @@ -1788,30 +1798,30 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualityNoError) { const auto &row = results[0]; ASSERT_EQ(row.size(), 1); auto vertex = row[0].ValueVertex(); - TypedValue value(*vertex.GetProperty(storage::View::OLD, prop)); + TypedValue value(*vertex.GetProperty(memgraph::storage::View::OLD, prop)); TypedValue::BoolEqual eq; EXPECT_TRUE(eq(value, TypedValue(42))); } TEST(QueryPlan, ScanAllByLabelPropertyValueError) { - storage::Storage db; + memgraph::storage::Storage db; auto label = db.NameToLabel("label"); auto prop = db.NameToProperty("prop"); { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); for (int i = 0; i < 2; ++i) { auto vertex = dba.InsertVertex(); ASSERT_TRUE(vertex.AddLabel(label).HasValue()); - ASSERT_TRUE(vertex.SetProperty(prop, storage::PropertyValue(i)).HasValue()); + ASSERT_TRUE(vertex.SetProperty(prop, memgraph::storage::PropertyValue(i)).HasValue()); } ASSERT_FALSE(dba.Commit().HasError()); } db.CreateIndex(label, prop); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - EXPECT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD))); + memgraph::query::DbAccessor dba(&storage_dba); + EXPECT_EQ(2, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); // MATCH (m), (n :label {prop: m}) AstStorage storage; SymbolTable symbol_table; @@ -1825,24 +1835,24 @@ TEST(QueryPlan, ScanAllByLabelPropertyValueError) { } TEST(QueryPlan, ScanAllByLabelPropertyRangeError) { - storage::Storage db; + memgraph::storage::Storage db; auto label = db.NameToLabel("label"); auto prop = db.NameToProperty("prop"); { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); for (int i = 0; i < 2; ++i) { auto vertex = dba.InsertVertex(); ASSERT_TRUE(vertex.AddLabel(label).HasValue()); - ASSERT_TRUE(vertex.SetProperty(prop, storage::PropertyValue(i)).HasValue()); + ASSERT_TRUE(vertex.SetProperty(prop, memgraph::storage::PropertyValue(i)).HasValue()); } ASSERT_FALSE(dba.Commit().HasError()); } db.CreateIndex(label, prop); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - EXPECT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD))); + memgraph::query::DbAccessor dba(&storage_dba); + EXPECT_EQ(2, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); // MATCH (m), (n :label {prop: m}) AstStorage storage; SymbolTable symbol_table; @@ -1875,7 +1885,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeError) { } TEST(QueryPlan, ScanAllByLabelPropertyEqualNull) { - storage::Storage db; + memgraph::storage::Storage db; // Add 2 vertices with the same label, but one has a property value while // the other does not. Checking if the value is equal to null, should // yield no results. @@ -1883,19 +1893,19 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualNull) { auto prop = db.NameToProperty("prop"); { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto vertex = dba.InsertVertex(); ASSERT_TRUE(vertex.AddLabel(label).HasValue()); auto vertex_with_prop = dba.InsertVertex(); ASSERT_TRUE(vertex_with_prop.AddLabel(label).HasValue()); - ASSERT_TRUE(vertex_with_prop.SetProperty(prop, storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(vertex_with_prop.SetProperty(prop, memgraph::storage::PropertyValue(42)).HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } db.CreateIndex(label, prop); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - EXPECT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD))); + memgraph::query::DbAccessor dba(&storage_dba); + EXPECT_EQ(2, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); // MATCH (n :label {prop: 42}) AstStorage storage; SymbolTable symbol_table; @@ -1910,7 +1920,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualNull) { } TEST(QueryPlan, ScanAllByLabelPropertyRangeNull) { - storage::Storage db; + memgraph::storage::Storage db; // Add 2 vertices with the same label, but one has a property value while // the other does not. Checking if the value is between nulls, should // yield no results. @@ -1918,19 +1928,19 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeNull) { auto prop = db.NameToProperty("prop"); { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto vertex = dba.InsertVertex(); ASSERT_TRUE(vertex.AddLabel(label).HasValue()); auto vertex_with_prop = dba.InsertVertex(); ASSERT_TRUE(vertex_with_prop.AddLabel(label).HasValue()); - ASSERT_TRUE(vertex_with_prop.SetProperty(prop, storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(vertex_with_prop.SetProperty(prop, memgraph::storage::PropertyValue(42)).HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } db.CreateIndex(label, prop); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - EXPECT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD))); + memgraph::query::DbAccessor dba(&storage_dba); + EXPECT_EQ(2, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); // MATCH (n :label) WHERE null <= n.prop < null AstStorage storage; SymbolTable symbol_table; @@ -1946,22 +1956,22 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeNull) { } TEST(QueryPlan, ScanAllByLabelPropertyNoValueInIndexContinuation) { - storage::Storage db; + memgraph::storage::Storage db; auto label = db.NameToLabel("label"); auto prop = db.NameToProperty("prop"); { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v = dba.InsertVertex(); ASSERT_TRUE(v.AddLabel(label).HasValue()); - ASSERT_TRUE(v.SetProperty(prop, storage::PropertyValue(2)).HasValue()); + ASSERT_TRUE(v.SetProperty(prop, memgraph::storage::PropertyValue(2)).HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } db.CreateIndex(label, prop); auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - EXPECT_EQ(1, CountIterable(dba.Vertices(storage::View::OLD))); + memgraph::query::DbAccessor dba(&storage_dba); + EXPECT_EQ(1, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); AstStorage storage; SymbolTable symbol_table; @@ -1981,7 +1991,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyNoValueInIndexContinuation) { } TEST(QueryPlan, ScanAllEqualsScanAllByLabelProperty) { - storage::Storage db; + memgraph::storage::Storage db; auto label = db.NameToLabel("label"); auto prop = db.NameToProperty("prop"); @@ -1991,11 +2001,11 @@ TEST(QueryPlan, ScanAllEqualsScanAllByLabelProperty) { for (int i = 0; i < vertex_count; ++i) { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v = dba.InsertVertex(); ASSERT_TRUE(v.AddLabel(label).HasValue()); - ASSERT_TRUE( - v.SetProperty(prop, storage::PropertyValue(i < vertex_prop_count ? prop_value1 : prop_value2)).HasValue()); + ASSERT_TRUE(v.SetProperty(prop, memgraph::storage::PropertyValue(i < vertex_prop_count ? prop_value1 : prop_value2)) + .HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } @@ -2004,8 +2014,8 @@ TEST(QueryPlan, ScanAllEqualsScanAllByLabelProperty) { // Make sure there are `vertex_count` vertices { auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - EXPECT_EQ(vertex_count, CountIterable(dba.Vertices(storage::View::OLD))); + memgraph::query::DbAccessor dba(&storage_dba); + EXPECT_EQ(vertex_count, CountIterable(dba.Vertices(memgraph::storage::View::OLD))); } // Make sure there are `vertex_prop_count` results when using index @@ -2013,7 +2023,7 @@ TEST(QueryPlan, ScanAllEqualsScanAllByLabelProperty) { AstStorage storage; SymbolTable symbol_table; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto scan_all_by_label_property_value = MakeScanAllByLabelPropertyValue(storage, symbol_table, "n", label, prop, "prop", LITERAL(prop_value)); auto output = NEXPR("n", IDENT("n")->MapTo(scan_all_by_label_property_value.sym_)) @@ -2028,7 +2038,7 @@ TEST(QueryPlan, ScanAllEqualsScanAllByLabelProperty) { AstStorage storage; SymbolTable symbol_table; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto scan_all = MakeScanAll(storage, symbol_table, "n"); auto e = PROPERTY_LOOKUP(IDENT("n")->MapTo(scan_all.sym_), std::make_pair("prop", prop)); auto filter = std::make_shared(scan_all.op_, EQ(e, LITERAL(prop_value))); diff --git a/tests/unit/query_plan_read_write_typecheck.cpp b/tests/unit/query_plan_read_write_typecheck.cpp index d9f655bf2..b68202a86 100644 --- a/tests/unit/query_plan_read_write_typecheck.cpp +++ b/tests/unit/query_plan_read_write_typecheck.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,8 +17,8 @@ #include "query_common.hpp" -using namespace query; -using namespace query::plan; +using namespace memgraph::query; +using namespace memgraph::query::plan; using RWType = ReadWriteTypeChecker::RWType; class ReadWriteTypeCheckTest : public ::testing::Test { @@ -28,8 +28,8 @@ class ReadWriteTypeCheckTest : public ::testing::Test { AstStorage storage; SymbolTable symbol_table; - storage::Storage db; - storage::Storage::Accessor dba; + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor dba; const Symbol &GetSymbol(std::string name) { return symbol_table.CreateSymbol(name, true); } @@ -65,7 +65,8 @@ TEST_F(ReadWriteTypeCheckTest, Filter) { TEST_F(ReadWriteTypeCheckTest, ScanAllBy) { std::shared_ptr last_op = std::make_shared( nullptr, GetSymbol("node"), dba.NameToLabel("Label"), dba.NameToProperty("prop"), "prop", - utils::MakeBoundInclusive(LITERAL(1)), utils::MakeBoundExclusive(LITERAL(20))); + memgraph::utils::MakeBoundInclusive(LITERAL(1)), + memgraph::utils::MakeBoundExclusive(LITERAL(20))); last_op = std::make_shared(last_op, GetSymbol("node"), dba.NameToLabel("Label"), dba.NameToProperty("prop"), "prop", ADD(LITERAL(21), LITERAL(21))); @@ -81,8 +82,8 @@ TEST_F(ReadWriteTypeCheckTest, OrderByAndLimit) { // ORDER BY n.property // LIMIT 10 Symbol node_sym = GetSymbol("node"); - storage::LabelId label = dba.NameToLabel("label"); - storage::PropertyId prop = dba.NameToProperty("property"); + memgraph::storage::LabelId label = dba.NameToLabel("label"); + memgraph::storage::PropertyId prop = dba.NameToProperty("property"); std::shared_ptr last_op = std::make_shared(); last_op = std::make_shared(last_op, node_sym, label); @@ -101,7 +102,7 @@ TEST_F(ReadWriteTypeCheckTest, Delete) { last_op = std::make_shared(last_op, node_sym, GetSymbol("node2"), GetSymbol("edge"), EdgeAtom::Direction::BOTH, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared(last_op, std::vector{IDENT("node2")}, true); CheckPlanType(last_op.get(), RWType::RW); @@ -115,8 +116,8 @@ TEST_F(ReadWriteTypeCheckTest, ExpandVariable) { last_op = std::make_shared( last_op, node1_sym, GetSymbol("node2"), GetSymbol("edge"), EdgeAtom::Type::BREADTH_FIRST, EdgeAtom::Direction::OUT, - std::vector{dba.NameToEdgeType("EdgeType1"), dba.NameToEdgeType("EdgeType2")}, false, - LITERAL(2), LITERAL(5), false, + std::vector{dba.NameToEdgeType("EdgeType1"), dba.NameToEdgeType("EdgeType2")}, + false, LITERAL(2), LITERAL(5), false, ExpansionLambda{GetSymbol("inner_node"), GetSymbol("inner_edge"), PROPERTY_LOOKUP("inner_node", dba.NameToProperty("unblocked"))}, std::nullopt, std::nullopt); @@ -135,10 +136,10 @@ TEST_F(ReadWriteTypeCheckTest, EdgeUniquenessFilter) { std::shared_ptr last_op = std::make_shared(nullptr, node1_sym); last_op = std::make_shared(last_op, node1_sym, node2_sym, edge1_sym, EdgeAtom::Direction::IN, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared(last_op, node3_sym); last_op = std::make_shared(last_op, node3_sym, node4_sym, edge2_sym, EdgeAtom::Direction::OUT, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared(last_op, edge2_sym, std::vector{edge1_sym}); CheckPlanType(last_op.get(), RWType::R); @@ -146,7 +147,7 @@ TEST_F(ReadWriteTypeCheckTest, EdgeUniquenessFilter) { TEST_F(ReadWriteTypeCheckTest, SetRemovePropertiesLabels) { auto node_sym = GetSymbol("node"); - storage::PropertyId prop = dba.NameToProperty("prop"); + memgraph::storage::PropertyId prop = dba.NameToProperty("prop"); std::shared_ptr last_op = std::make_shared(nullptr, GetSymbol("node")); last_op = std::make_shared(last_op, prop, PROPERTY_LOOKUP("node", prop), @@ -159,9 +160,9 @@ TEST_F(ReadWriteTypeCheckTest, SetRemovePropertiesLabels) { {storage.GetPropertyIx("prop2"), LITERAL("this is a property")}}), plan::SetProperties::Op::REPLACE); last_op = std::make_shared( - last_op, node_sym, std::vector{dba.NameToLabel("label1"), dba.NameToLabel("label2")}); + last_op, node_sym, std::vector{dba.NameToLabel("label1"), dba.NameToLabel("label2")}); last_op = std::make_shared( - last_op, node_sym, std::vector{dba.NameToLabel("label1"), dba.NameToLabel("label2")}); + last_op, node_sym, std::vector{dba.NameToLabel("label1"), dba.NameToLabel("label2")}); CheckPlanType(last_op.get(), RWType::RW); } @@ -238,9 +239,9 @@ TEST_F(ReadWriteTypeCheckTest, ConstructNamedPath) { std::shared_ptr last_op = std::make_shared(nullptr, node1_sym); last_op = std::make_shared(last_op, node1_sym, node2_sym, edge1_sym, EdgeAtom::Direction::OUT, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared(last_op, node2_sym, node3_sym, edge2_sym, EdgeAtom::Direction::OUT, - std::vector{}, false, storage::View::OLD); + std::vector{}, false, memgraph::storage::View::OLD); last_op = std::make_shared( last_op, GetSymbol("path"), std::vector{node1_sym, edge1_sym, node2_sym, edge2_sym, node3_sym}); diff --git a/tests/unit/query_plan_v2_create_set_remove_delete.cpp b/tests/unit/query_plan_v2_create_set_remove_delete.cpp index 4139b310b..c1409daf8 100644 --- a/tests/unit/query_plan_v2_create_set_remove_delete.cpp +++ b/tests/unit/query_plan_v2_create_set_remove_delete.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,63 +18,63 @@ #include "storage/v2/storage.hpp" TEST(QueryPlan, CreateNodeWithAttributes) { - storage::Storage db; + memgraph::storage::Storage db; auto dba = db.Access(); - auto label = storage::LabelId::FromInt(42); - auto property = storage::PropertyId::FromInt(1); + auto label = memgraph::storage::LabelId::FromInt(42); + auto property = memgraph::storage::PropertyId::FromInt(1); - query::AstStorage ast; - query::SymbolTable symbol_table; + memgraph::query::AstStorage ast; + memgraph::query::SymbolTable symbol_table; - query::plan::NodeCreationInfo node; + memgraph::query::plan::NodeCreationInfo node; node.symbol = symbol_table.CreateSymbol("n", true); node.labels.emplace_back(label); - std::get>>(node.properties) + std::get>>(node.properties) .emplace_back(property, ast.Create(42)); - query::plan::CreateNode create_node(nullptr, node); + memgraph::query::plan::CreateNode create_node(nullptr, node); DbAccessor execution_dba(&dba); auto context = MakeContext(ast, symbol_table, &execution_dba); Frame frame(context.symbol_table.max_position()); - auto cursor = create_node.MakeCursor(utils::NewDeleteResource()); + auto cursor = create_node.MakeCursor(memgraph::utils::NewDeleteResource()); int count = 0; while (cursor->Pull(frame, context)) { ++count; const auto &node_value = frame[node.symbol]; EXPECT_EQ(node_value.type(), TypedValue::Type::Vertex); const auto &v = node_value.ValueVertex(); - EXPECT_TRUE(*v.HasLabel(storage::View::NEW, label)); - EXPECT_EQ(v.GetProperty(storage::View::NEW, property)->ValueInt(), 42); - EXPECT_EQ(CountIterable(*v.InEdges(storage::View::NEW)), 0); - EXPECT_EQ(CountIterable(*v.OutEdges(storage::View::NEW)), 0); + EXPECT_TRUE(*v.HasLabel(memgraph::storage::View::NEW, label)); + EXPECT_EQ(v.GetProperty(memgraph::storage::View::NEW, property)->ValueInt(), 42); + EXPECT_EQ(CountIterable(*v.InEdges(memgraph::storage::View::NEW)), 0); + EXPECT_EQ(CountIterable(*v.OutEdges(memgraph::storage::View::NEW)), 0); // Invokes LOG(FATAL) instead of erroring out. - // EXPECT_TRUE(v.HasLabel(label, storage::View::OLD).IsError()); + // EXPECT_TRUE(v.HasLabel(label, memgraph::storage::View::OLD).IsError()); } EXPECT_EQ(count, 1); } TEST(QueryPlan, ScanAllEmpty) { - query::AstStorage ast; - query::SymbolTable symbol_table; - storage::Storage db; + memgraph::query::AstStorage ast; + memgraph::query::SymbolTable symbol_table; + memgraph::storage::Storage db; auto dba = db.Access(); DbAccessor execution_dba(&dba); auto node_symbol = symbol_table.CreateSymbol("n", true); { - query::plan::ScanAll scan_all(nullptr, node_symbol, storage::View::OLD); + memgraph::query::plan::ScanAll scan_all(nullptr, node_symbol, memgraph::storage::View::OLD); auto context = MakeContext(ast, symbol_table, &execution_dba); Frame frame(context.symbol_table.max_position()); - auto cursor = scan_all.MakeCursor(utils::NewDeleteResource()); + auto cursor = scan_all.MakeCursor(memgraph::utils::NewDeleteResource()); int count = 0; while (cursor->Pull(frame, context)) ++count; EXPECT_EQ(count, 0); } { - query::plan::ScanAll scan_all(nullptr, node_symbol, storage::View::NEW); + memgraph::query::plan::ScanAll scan_all(nullptr, node_symbol, memgraph::storage::View::NEW); auto context = MakeContext(ast, symbol_table, &execution_dba); Frame frame(context.symbol_table.max_position()); - auto cursor = scan_all.MakeCursor(utils::NewDeleteResource()); + auto cursor = scan_all.MakeCursor(memgraph::utils::NewDeleteResource()); int count = 0; while (cursor->Pull(frame, context)) ++count; EXPECT_EQ(count, 0); @@ -82,28 +82,28 @@ TEST(QueryPlan, ScanAllEmpty) { } TEST(QueryPlan, ScanAll) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); for (int i = 0; i < 42; ++i) dba.CreateVertex(); EXPECT_FALSE(dba.Commit().HasError()); } - query::AstStorage ast; - query::SymbolTable symbol_table; + memgraph::query::AstStorage ast; + memgraph::query::SymbolTable symbol_table; auto dba = db.Access(); DbAccessor execution_dba(&dba); auto node_symbol = symbol_table.CreateSymbol("n", true); - query::plan::ScanAll scan_all(nullptr, node_symbol); + memgraph::query::plan::ScanAll scan_all(nullptr, node_symbol); auto context = MakeContext(ast, symbol_table, &execution_dba); Frame frame(context.symbol_table.max_position()); - auto cursor = scan_all.MakeCursor(utils::NewDeleteResource()); + auto cursor = scan_all.MakeCursor(memgraph::utils::NewDeleteResource()); int count = 0; while (cursor->Pull(frame, context)) ++count; EXPECT_EQ(count, 42); } TEST(QueryPlan, ScanAllByLabel) { - storage::Storage db; + memgraph::storage::Storage db; auto label = db.NameToLabel("label"); ASSERT_TRUE(db.CreateIndex(label)); { @@ -118,14 +118,14 @@ TEST(QueryPlan, ScanAllByLabel) { EXPECT_FALSE(dba.Commit().HasError()); } auto dba = db.Access(); - query::AstStorage ast; - query::SymbolTable symbol_table; + memgraph::query::AstStorage ast; + memgraph::query::SymbolTable symbol_table; auto node_symbol = symbol_table.CreateSymbol("n", true); DbAccessor execution_dba(&dba); - query::plan::ScanAllByLabel scan_all(nullptr, node_symbol, label); + memgraph::query::plan::ScanAllByLabel scan_all(nullptr, node_symbol, label); auto context = MakeContext(ast, symbol_table, &execution_dba); Frame frame(context.symbol_table.max_position()); - auto cursor = scan_all.MakeCursor(utils::NewDeleteResource()); + auto cursor = scan_all.MakeCursor(memgraph::utils::NewDeleteResource()); int count = 0; while (cursor->Pull(frame, context)) ++count; EXPECT_EQ(count, 42); diff --git a/tests/unit/query_pretty_print.cpp b/tests/unit/query_pretty_print.cpp index 1dc24a877..9bfcab6ec 100644 --- a/tests/unit/query_pretty_print.cpp +++ b/tests/unit/query_pretty_print.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,17 +19,17 @@ #include "query_common.hpp" #include "utils/string.hpp" -using namespace query; -using query::test_common::ToString; +using namespace memgraph::query; +using memgraph::query::test_common::ToString; using testing::ElementsAre; using testing::UnorderedElementsAre; namespace { struct ExpressionPrettyPrinterTest : public ::testing::Test { - storage::Storage db; - storage::Storage::Accessor storage_dba{db.Access()}; - query::DbAccessor dba{&storage_dba}; + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor storage_dba{db.Access()}; + memgraph::query::DbAccessor dba{&storage_dba}; AstStorage storage; }; @@ -50,22 +50,24 @@ TEST_F(ExpressionPrettyPrinterTest, Literals) { EXPECT_EQ(ToString(LITERAL(false)), "false"); // [1 null "hello"] - std::vector values{storage::PropertyValue(1), storage::PropertyValue(), - storage::PropertyValue("hello")}; - EXPECT_EQ(ToString(LITERAL(storage::PropertyValue(values))), "[1, null, \"hello\"]"); + std::vector values{memgraph::storage::PropertyValue(1), + memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue("hello")}; + EXPECT_EQ(ToString(LITERAL(memgraph::storage::PropertyValue(values))), "[1, null, \"hello\"]"); // {hello: 1, there: 2} - std::map map{{"hello", storage::PropertyValue(1)}, - {"there", storage::PropertyValue(2)}}; - EXPECT_EQ(ToString(LITERAL(storage::PropertyValue(map))), "{\"hello\": 1, \"there\": 2}"); + std::map map{{"hello", memgraph::storage::PropertyValue(1)}, + {"there", memgraph::storage::PropertyValue(2)}}; + EXPECT_EQ(ToString(LITERAL(memgraph::storage::PropertyValue(map))), "{\"hello\": 1, \"there\": 2}"); - std::vector tt_vec{ - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Duration, 1)), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Duration, -2)), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::LocalTime, 2)), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::LocalDateTime, 3)), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 4))}; - EXPECT_EQ(ToString(LITERAL(storage::PropertyValue(tt_vec))), + std::vector tt_vec{ + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Duration, 1)), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Duration, -2)), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::LocalTime, 2)), + memgraph::storage::PropertyValue( + memgraph::storage::TemporalData(memgraph::storage::TemporalType::LocalDateTime, 3)), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 4))}; + EXPECT_EQ(ToString(LITERAL(memgraph::storage::PropertyValue(tt_vec))), "[DURATION(\"P0DT0H0M0.000001S\"), DURATION(\"P0DT0H0M-0.000002S\"), LOCALTIME(\"00:00:00.000002\"), " "LOCALDATETIME(\"1970-01-01T00:00:00.000003\"), DATE(\"1970-01-01\")]"); } @@ -81,7 +83,7 @@ TEST_F(ExpressionPrettyPrinterTest, Identifiers) { TEST_F(ExpressionPrettyPrinterTest, Reducing) { // all(x in list where x.prop = 42) auto prop = dba.NameToProperty("prop"); - EXPECT_EQ(ToString(ALL("x", LITERAL(std::vector{}), + EXPECT_EQ(ToString(ALL("x", LITERAL(std::vector{}), WHERE(EQ(PROPERTY_LOOKUP("x", prop), LITERAL(42))))), "(All (Identifier \"x\") [] (== (PropertyLookup " "(Identifier \"x\") \"prop\") 42))"); diff --git a/tests/unit/query_procedure_mgp_module.cpp b/tests/unit/query_procedure_mgp_module.cpp index d7fb13f67..1cbfd1518 100644 --- a/tests/unit/query_procedure_mgp_module.cpp +++ b/tests/unit/query_procedure_mgp_module.cpp @@ -22,7 +22,7 @@ static void DummyCallback(mgp_list *, mgp_graph *, mgp_result *, mgp_memory *) {} TEST(Module, InvalidProcedureRegistration) { - mgp_module module(utils::NewDeleteResource()); + mgp_module module(memgraph::utils::NewDeleteResource()); mgp_proc *proc{nullptr}; EXPECT_EQ(mgp_module_add_read_procedure(&module, "dashes-not-supported", DummyCallback, &proc), MGP_ERROR_INVALID_ARGUMENT); @@ -42,7 +42,7 @@ TEST(Module, InvalidProcedureRegistration) { } TEST(Module, RegisteringTheSameProcedureMultipleTimes) { - mgp_module module(utils::NewDeleteResource()); + mgp_module module(memgraph::utils::NewDeleteResource()); mgp_proc *proc{nullptr}; EXPECT_EQ(module.procedures.find("same_name"), module.procedures.end()); EXPECT_EQ(mgp_module_add_read_procedure(&module, "same_name", DummyCallback, &proc), MGP_ERROR_NO_ERROR); @@ -53,7 +53,7 @@ TEST(Module, RegisteringTheSameProcedureMultipleTimes) { } TEST(Module, CaseSensitiveProcedureNames) { - mgp_module module(utils::NewDeleteResource()); + mgp_module module(memgraph::utils::NewDeleteResource()); EXPECT_TRUE(module.procedures.empty()); mgp_proc *proc{nullptr}; EXPECT_EQ(mgp_module_add_read_procedure(&module, "not_same", DummyCallback, &proc), MGP_ERROR_NO_ERROR); @@ -64,13 +64,13 @@ TEST(Module, CaseSensitiveProcedureNames) { static void CheckSignature(const mgp_proc *proc, const std::string &expected) { std::stringstream ss; - query::procedure::PrintProcSignature(*proc, &ss); + memgraph::query::procedure::PrintProcSignature(*proc, &ss); EXPECT_EQ(ss.str(), expected); } TEST(Module, ProcedureSignature) { - mgp_memory memory{utils::NewDeleteResource()}; - mgp_module module(utils::NewDeleteResource()); + mgp_memory memory{memgraph::utils::NewDeleteResource()}; + mgp_module module(memgraph::utils::NewDeleteResource()); auto *proc = EXPECT_MGP_NO_ERROR(mgp_proc *, mgp_module_add_read_procedure, &module, "proc", &DummyCallback); CheckSignature(proc, "proc() :: ()"); EXPECT_EQ(mgp_proc_add_arg(proc, "arg1", EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_number)), MGP_ERROR_NO_ERROR); @@ -111,8 +111,8 @@ TEST(Module, ProcedureSignature) { } TEST(Module, ProcedureSignatureOnlyOptArg) { - mgp_memory memory{utils::NewDeleteResource()}; - mgp_module module(utils::NewDeleteResource()); + mgp_memory memory{memgraph::utils::NewDeleteResource()}; + mgp_module module(memgraph::utils::NewDeleteResource()); auto *proc = EXPECT_MGP_NO_ERROR(mgp_proc *, mgp_module_add_read_procedure, &module, "proc", &DummyCallback); EXPECT_EQ(mgp_proc_add_opt_arg( proc, "opt1", @@ -123,7 +123,7 @@ TEST(Module, ProcedureSignatureOnlyOptArg) { } TEST(Module, ReadWriteProcedures) { - mgp_module module(utils::NewDeleteResource()); + mgp_module module(memgraph::utils::NewDeleteResource()); auto *read_proc = EXPECT_MGP_NO_ERROR(mgp_proc *, mgp_module_add_read_procedure, &module, "read", &DummyCallback); EXPECT_FALSE(read_proc->info.is_write); auto *write_proc = EXPECT_MGP_NO_ERROR(mgp_proc *, mgp_module_add_write_procedure, &module, "write", &DummyCallback); @@ -131,6 +131,6 @@ TEST(Module, ReadWriteProcedures) { mgp_proc read_proc_with_function{"dummy_name", std::function{ [](mgp_list *, mgp_graph *, mgp_result *, mgp_memory *) {}}, - utils::NewDeleteResource()}; + memgraph::utils::NewDeleteResource()}; EXPECT_FALSE(read_proc_with_function.info.is_write); } diff --git a/tests/unit/query_procedure_mgp_type.cpp b/tests/unit/query_procedure_mgp_type.cpp index 173ae71f0..447a5efd4 100644 --- a/tests/unit/query_procedure_mgp_type.cpp +++ b/tests/unit/query_procedure_mgp_type.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -83,10 +83,10 @@ TEST(CypherType, PresentableNameCompositeTypes) { } TEST(CypherType, NullSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; { auto *mgp_null = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_null, &memory); - const query::TypedValue tv_null; + const memgraph::query::TypedValue tv_null; std::vector primitive_types{ EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_bool), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_string), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_int), @@ -108,7 +108,7 @@ TEST(CypherType, NullSatisfiesType) { } } -static void CheckSatisfiesTypesAndNullable(const mgp_value *mgp_val, const query::TypedValue &tv, +static void CheckSatisfiesTypesAndNullable(const mgp_value *mgp_val, const memgraph::query::TypedValue &tv, const std::vector &types) { for (auto *type : types) { EXPECT_TRUE(type->impl->SatisfiesType(*mgp_val)) << type->impl->GetPresentableName(); @@ -119,7 +119,7 @@ static void CheckSatisfiesTypesAndNullable(const mgp_value *mgp_val, const query } } -static void CheckNotSatisfiesTypesAndListAndNullable(const mgp_value *mgp_val, const query::TypedValue &tv, +static void CheckNotSatisfiesTypesAndListAndNullable(const mgp_value *mgp_val, const memgraph::query::TypedValue &tv, const std::vector &elem_types) { for (auto *elem_type : elem_types) { for (auto *type : {elem_type, EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_list, elem_type), @@ -135,9 +135,9 @@ static void CheckNotSatisfiesTypesAndListAndNullable(const mgp_value *mgp_val, c } TEST(CypherType, BoolSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; auto *mgp_bool = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_bool, 1, &memory); - const query::TypedValue tv_bool(true); + const memgraph::query::TypedValue tv_bool(true); CheckSatisfiesTypesAndNullable( mgp_bool, tv_bool, {EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_bool)}); @@ -151,9 +151,9 @@ TEST(CypherType, BoolSatisfiesType) { } TEST(CypherType, IntSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; auto *mgp_int = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_int, 42, &memory); - const query::TypedValue tv_int(42); + const memgraph::query::TypedValue tv_int(42); CheckSatisfiesTypesAndNullable( mgp_int, tv_int, {EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_int), @@ -168,9 +168,9 @@ TEST(CypherType, IntSatisfiesType) { } TEST(CypherType, DoubleSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; auto *mgp_double = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_double, 42, &memory); - const query::TypedValue tv_double(42.0); + const memgraph::query::TypedValue tv_double(42.0); CheckSatisfiesTypesAndNullable( mgp_double, tv_double, {EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_float), @@ -185,9 +185,9 @@ TEST(CypherType, DoubleSatisfiesType) { } TEST(CypherType, StringSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; auto *mgp_string = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_string, "text", &memory); - const query::TypedValue tv_string("text"); + const memgraph::query::TypedValue tv_string("text"); CheckSatisfiesTypesAndNullable( mgp_string, tv_string, {EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_string)}); @@ -201,7 +201,7 @@ TEST(CypherType, StringSatisfiesType) { } TEST(CypherType, MapSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; auto *map = EXPECT_MGP_NO_ERROR(mgp_map *, mgp_map_make_empty, &memory); EXPECT_EQ( mgp_map_insert( @@ -209,7 +209,8 @@ TEST(CypherType, MapSatisfiesType) { test_utils::CreateValueOwningPtr(EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_int, 42, &memory)).get()), MGP_ERROR_NO_ERROR); auto *mgp_map_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_map, map); - const query::TypedValue tv_map(std::map{{"key", query::TypedValue(42)}}); + const memgraph::query::TypedValue tv_map( + std::map{{"key", memgraph::query::TypedValue(42)}}); CheckSatisfiesTypesAndNullable( mgp_map_v, tv_map, {EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_map)}); @@ -223,16 +224,16 @@ TEST(CypherType, MapSatisfiesType) { } TEST(CypherType, VertexSatisfiesType) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto vertex = dba.InsertVertex(); - mgp_memory memory{utils::NewDeleteResource()}; - utils::Allocator alloc(memory.impl); - mgp_graph graph{&dba, storage::View::NEW}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; + memgraph::utils::Allocator alloc(memory.impl); + mgp_graph graph{&dba, memgraph::storage::View::NEW}; auto *mgp_vertex_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_vertex, alloc.new_object(vertex, &graph)); - const query::TypedValue tv_vertex(vertex); + const memgraph::query::TypedValue tv_vertex(vertex); CheckSatisfiesTypesAndNullable( mgp_vertex_v, tv_vertex, {EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_node), @@ -247,17 +248,17 @@ TEST(CypherType, VertexSatisfiesType) { } TEST(CypherType, EdgeSatisfiesType) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); auto edge = *dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("edge_type")); - mgp_memory memory{utils::NewDeleteResource()}; - utils::Allocator alloc(memory.impl); - mgp_graph graph{&dba, storage::View::NEW}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; + memgraph::utils::Allocator alloc(memory.impl); + mgp_graph graph{&dba, memgraph::storage::View::NEW}; auto *mgp_edge_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_edge, alloc.new_object(edge, &graph)); - const query::TypedValue tv_edge(edge); + const memgraph::query::TypedValue tv_edge(edge); CheckSatisfiesTypesAndNullable( mgp_edge_v, tv_edge, {EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_relationship), @@ -272,15 +273,15 @@ TEST(CypherType, EdgeSatisfiesType) { } TEST(CypherType, PathSatisfiesType) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); auto edge = *dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("edge_type")); - mgp_memory memory{utils::NewDeleteResource()}; - utils::Allocator alloc(memory.impl); - mgp_graph graph{&dba, storage::View::NEW}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; + memgraph::utils::Allocator alloc(memory.impl); + mgp_graph graph{&dba, memgraph::storage::View::NEW}; auto *mgp_vertex_v = alloc.new_object(v1, &graph); auto path = EXPECT_MGP_NO_ERROR(mgp_path *, mgp_path_make_with_start, mgp_vertex_v, &memory); ASSERT_TRUE(path); @@ -289,7 +290,7 @@ TEST(CypherType, PathSatisfiesType) { ASSERT_EQ(mgp_path_expand(path, mgp_edge_v), MGP_ERROR_NO_ERROR); alloc.delete_object(mgp_edge_v); auto *mgp_path_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_path, path); - const query::TypedValue tv_path(query::Path(v1, edge, v2)); + const memgraph::query::TypedValue tv_path(memgraph::query::Path(v1, edge, v2)); CheckSatisfiesTypesAndNullable( mgp_path_v, tv_path, {EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_path)}); @@ -314,10 +315,10 @@ static std::vector MakeListTypes(const std::vector &elem } TEST(CypherType, EmptyListSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; auto *list = EXPECT_MGP_NO_ERROR(mgp_list *, mgp_list_make_empty, 0, &memory); auto *mgp_list_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_list, list); - query::TypedValue tv_list(std::vector{}); + memgraph::query::TypedValue tv_list(std::vector{}); // Empty List satisfies all list element types std::vector primitive_types{ EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_any), EXPECT_MGP_NO_ERROR(mgp_type *, mgp_type_bool), @@ -332,11 +333,11 @@ TEST(CypherType, EmptyListSatisfiesType) { } TEST(CypherType, ListOfIntSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; constexpr int64_t elem_count = 3; auto *list = EXPECT_MGP_NO_ERROR(mgp_list *, mgp_list_make_empty, elem_count, &memory); auto *mgp_list_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_list, list); - query::TypedValue tv_list(std::vector{}); + memgraph::query::TypedValue tv_list(std::vector{}); for (int64_t i = 0; i < elem_count; ++i) { ASSERT_EQ( mgp_list_append( @@ -360,11 +361,11 @@ TEST(CypherType, ListOfIntSatisfiesType) { } TEST(CypherType, ListOfIntAndBoolSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; constexpr int64_t elem_count = 2; auto *list = EXPECT_MGP_NO_ERROR(mgp_list *, mgp_list_make_empty, elem_count, &memory); auto *mgp_list_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_list, list); - query::TypedValue tv_list(std::vector{}); + memgraph::query::TypedValue tv_list(std::vector{}); // Add an int ASSERT_EQ( mgp_list_append( @@ -394,10 +395,10 @@ TEST(CypherType, ListOfIntAndBoolSatisfiesType) { } TEST(CypherType, ListOfNullSatisfiesType) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; auto *list = EXPECT_MGP_NO_ERROR(mgp_list *, mgp_list_make_empty, 1, &memory); auto *mgp_list_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_list, list); - query::TypedValue tv_list(std::vector{}); + memgraph::query::TypedValue tv_list(std::vector{}); ASSERT_EQ( mgp_list_append( list, test_utils::CreateValueOwningPtr(EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_null, &memory)).get()), diff --git a/tests/unit/query_procedure_py_module.cpp b/tests/unit/query_procedure_py_module.cpp index 8acdce2c8..68459e372 100644 --- a/tests/unit/query_procedure_py_module.cpp +++ b/tests/unit/query_procedure_py_module.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "test_utils.hpp" TEST(PyModule, MgpValueToPyObject) { - mgp_memory memory{utils::NewDeleteResource()}; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; auto *list = EXPECT_MGP_NO_ERROR(mgp_list *, mgp_list_make_empty, 42, &memory); { // Create a list: [null, false, true, 42, 0.1, "some text"] @@ -39,10 +39,10 @@ TEST(PyModule, MgpValueToPyObject) { EXPECT_EQ(mgp_map_insert(map, "list", list_val), MGP_ERROR_NO_ERROR); mgp_value_destroy(list_val); auto *map_val = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_map, map); - auto gil = py::EnsureGIL(); - py::Object py_graph(query::procedure::MakePyGraph(nullptr, &memory)); - auto py_dict = - query::procedure::MgpValueToPyObject(*map_val, reinterpret_cast(py_graph.Ptr())); + auto gil = memgraph::py::EnsureGIL(); + memgraph::py::Object py_graph(memgraph::query::procedure::MakePyGraph(nullptr, &memory)); + auto py_dict = memgraph::query::procedure::MgpValueToPyObject( + *map_val, reinterpret_cast(py_graph.Ptr())); mgp_value_destroy(map_val); // We should now have in Python: // {"list": (None, False, True, 42, 0.1, "some text")} @@ -74,35 +74,35 @@ TEST(PyModule, MgpValueToPyObject) { // Our _mgp types should not support (by default) pickling and copying. static void AssertPickleAndCopyAreNotSupported(PyObject *py_obj) { ASSERT_TRUE(py_obj); - py::Object pickle_mod(PyImport_ImportModule("pickle")); + memgraph::py::Object pickle_mod(PyImport_ImportModule("pickle")); ASSERT_TRUE(pickle_mod); - ASSERT_FALSE(py::FetchError()); - py::Object dumps_res(pickle_mod.CallMethod("dumps", py_obj)); + ASSERT_FALSE(memgraph::py::FetchError()); + memgraph::py::Object dumps_res(pickle_mod.CallMethod("dumps", py_obj)); ASSERT_FALSE(dumps_res); - ASSERT_TRUE(py::FetchError()); - py::Object copy_mod(PyImport_ImportModule("copy")); + ASSERT_TRUE(memgraph::py::FetchError()); + memgraph::py::Object copy_mod(PyImport_ImportModule("copy")); ASSERT_TRUE(copy_mod); - ASSERT_FALSE(py::FetchError()); - py::Object copy_res(copy_mod.CallMethod("copy", py_obj)); + ASSERT_FALSE(memgraph::py::FetchError()); + memgraph::py::Object copy_res(copy_mod.CallMethod("copy", py_obj)); ASSERT_FALSE(copy_res); - ASSERT_TRUE(py::FetchError()); + ASSERT_TRUE(memgraph::py::FetchError()); // We should have cleared the error state. - ASSERT_FALSE(py::FetchError()); - py::Object deepcopy_res(copy_mod.CallMethod("deepcopy", py_obj)); + ASSERT_FALSE(memgraph::py::FetchError()); + memgraph::py::Object deepcopy_res(copy_mod.CallMethod("deepcopy", py_obj)); ASSERT_FALSE(deepcopy_res); - ASSERT_TRUE(py::FetchError()); + ASSERT_TRUE(memgraph::py::FetchError()); } TEST(PyModule, PyVertex) { // Initialize the database with 2 vertices and 1 edge. - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); auto v1 = dba.CreateVertex(); auto v2 = dba.CreateVertex(); - ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("key1"), storage::PropertyValue("value1")).HasValue()); - ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("key2"), storage::PropertyValue(1337)).HasValue()); + ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("key1"), memgraph::storage::PropertyValue("value1")).HasValue()); + ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("key2"), memgraph::storage::PropertyValue(1337)).HasValue()); auto e = dba.CreateEdge(&v1, &v2, dba.NameToEdgeType("type")); ASSERT_TRUE(e.HasValue()); @@ -111,24 +111,24 @@ TEST(PyModule, PyVertex) { } // Get the first vertex as an mgp_value. auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - mgp_memory memory{utils::NewDeleteResource()}; - mgp_graph graph{&dba, storage::View::OLD}; + memgraph::query::DbAccessor dba(&storage_dba); + mgp_memory memory{memgraph::utils::NewDeleteResource()}; + mgp_graph graph{&dba, memgraph::storage::View::OLD}; auto *vertex = EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{0}, &memory); ASSERT_TRUE(vertex); auto *vertex_value = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_vertex, EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_vertex_copy, vertex, &memory)); mgp_vertex_destroy(vertex); // Initialize the Python graph object. - auto gil = py::EnsureGIL(); - py::Object py_graph(query::procedure::MakePyGraph(&graph, &memory)); + auto gil = memgraph::py::EnsureGIL(); + memgraph::py::Object py_graph(memgraph::query::procedure::MakePyGraph(&graph, &memory)); ASSERT_TRUE(py_graph); // Convert from mgp_value to mgp.Vertex. - py::Object py_vertex_value(query::procedure::MgpValueToPyObject(*vertex_value, py_graph.Ptr())); + memgraph::py::Object py_vertex_value(memgraph::query::procedure::MgpValueToPyObject(*vertex_value, py_graph.Ptr())); ASSERT_TRUE(py_vertex_value); AssertPickleAndCopyAreNotSupported(py_vertex_value.GetAttr("_vertex").Ptr()); // Convert from mgp.Vertex to mgp_value. - auto *new_vertex_value = query::procedure::PyObjectToMgpValue(py_vertex_value.Ptr(), &memory); + auto *new_vertex_value = memgraph::query::procedure::PyObjectToMgpValue(py_vertex_value.Ptr(), &memory); // Test for equality. ASSERT_TRUE(new_vertex_value); ASSERT_NE(new_vertex_value, vertex_value); // Pointer compare. @@ -145,7 +145,7 @@ TEST(PyModule, PyVertex) { TEST(PyModule, PyEdge) { // Initialize the database with 2 vertices and 1 edge. - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); auto v1 = dba.CreateVertex(); @@ -154,15 +154,15 @@ TEST(PyModule, PyEdge) { auto e = dba.CreateEdge(&v1, &v2, dba.NameToEdgeType("type")); ASSERT_TRUE(e.HasValue()); - ASSERT_TRUE(e->SetProperty(dba.NameToProperty("key1"), storage::PropertyValue("value1")).HasValue()); - ASSERT_TRUE(e->SetProperty(dba.NameToProperty("key2"), storage::PropertyValue(1337)).HasValue()); + ASSERT_TRUE(e->SetProperty(dba.NameToProperty("key1"), memgraph::storage::PropertyValue("value1")).HasValue()); + ASSERT_TRUE(e->SetProperty(dba.NameToProperty("key2"), memgraph::storage::PropertyValue(1337)).HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } // Get the edge as an mgp_value. auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - mgp_memory memory{utils::NewDeleteResource()}; - mgp_graph graph{&dba, storage::View::OLD}; + memgraph::query::DbAccessor dba(&storage_dba); + mgp_memory memory{memgraph::utils::NewDeleteResource()}; + mgp_graph graph{&dba, memgraph::storage::View::OLD}; auto *start_v = EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{0}, &memory); ASSERT_TRUE(start_v); auto *edges_it = EXPECT_MGP_NO_ERROR(mgp_edges_iterator *, mgp_vertex_iter_out_edges, start_v, &memory); @@ -175,15 +175,15 @@ TEST(PyModule, PyEdge) { mgp_edges_iterator_destroy(edges_it); mgp_vertex_destroy(start_v); // Initialize the Python graph object. - auto gil = py::EnsureGIL(); - py::Object py_graph(query::procedure::MakePyGraph(&graph, &memory)); + auto gil = memgraph::py::EnsureGIL(); + memgraph::py::Object py_graph(memgraph::query::procedure::MakePyGraph(&graph, &memory)); ASSERT_TRUE(py_graph); // Convert from mgp_value to mgp.Edge. - py::Object py_edge_value(query::procedure::MgpValueToPyObject(*edge_value, py_graph.Ptr())); + memgraph::py::Object py_edge_value(memgraph::query::procedure::MgpValueToPyObject(*edge_value, py_graph.Ptr())); ASSERT_TRUE(py_edge_value); AssertPickleAndCopyAreNotSupported(py_edge_value.GetAttr("_edge").Ptr()); // Convert from mgp.Edge to mgp_value. - auto *new_edge_value = query::procedure::PyObjectToMgpValue(py_edge_value.Ptr(), &memory); + auto *new_edge_value = memgraph::query::procedure::PyObjectToMgpValue(py_edge_value.Ptr(), &memory); // Test for equality. ASSERT_TRUE(new_edge_value); ASSERT_NE(new_edge_value, edge_value); // Pointer compare. @@ -198,7 +198,7 @@ TEST(PyModule, PyEdge) { } TEST(PyModule, PyPath) { - storage::Storage db; + memgraph::storage::Storage db; { auto dba = db.Access(); auto v1 = dba.CreateVertex(); @@ -207,9 +207,9 @@ TEST(PyModule, PyPath) { ASSERT_FALSE(dba.Commit().HasError()); } auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); - mgp_memory memory{utils::NewDeleteResource()}; - mgp_graph graph{&dba, storage::View::OLD}; + memgraph::query::DbAccessor dba(&storage_dba); + mgp_memory memory{memgraph::utils::NewDeleteResource()}; + mgp_graph graph{&dba, memgraph::storage::View::OLD}; auto *start_v = EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{0}, &memory); ASSERT_TRUE(start_v); auto *path = EXPECT_MGP_NO_ERROR(mgp_path *, mgp_path_make_with_start, start_v, &memory); @@ -225,15 +225,15 @@ TEST(PyModule, PyPath) { mgp_vertex_destroy(start_v); auto *path_value = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_path, path); ASSERT_TRUE(path_value); - auto gil = py::EnsureGIL(); - py::Object py_graph(query::procedure::MakePyGraph(&graph, &memory)); + auto gil = memgraph::py::EnsureGIL(); + memgraph::py::Object py_graph(memgraph::query::procedure::MakePyGraph(&graph, &memory)); ASSERT_TRUE(py_graph); // We have setup the C structs, so create convert to PyObject. - py::Object py_path_value(query::procedure::MgpValueToPyObject(*path_value, py_graph.Ptr())); + memgraph::py::Object py_path_value(memgraph::query::procedure::MgpValueToPyObject(*path_value, py_graph.Ptr())); ASSERT_TRUE(py_path_value); AssertPickleAndCopyAreNotSupported(py_path_value.GetAttr("_path").Ptr()); // Convert back to C struct and check equality. - auto *new_path_value = query::procedure::PyObjectToMgpValue(py_path_value.Ptr(), &memory); + auto *new_path_value = memgraph::query::procedure::PyObjectToMgpValue(py_path_value.Ptr(), &memory); ASSERT_TRUE(new_path_value); ASSERT_NE(new_path_value, path_value); // Pointer compare. ASSERT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_value_is_path, new_path_value), 1); @@ -246,11 +246,11 @@ TEST(PyModule, PyPath) { } TEST(PyModule, PyObjectToMgpValue) { - mgp_memory memory{utils::NewDeleteResource()}; - auto gil = py::EnsureGIL(); - py::Object py_value{ + mgp_memory memory{memgraph::utils::NewDeleteResource()}; + auto gil = memgraph::py::EnsureGIL(); + memgraph::py::Object py_value{ Py_BuildValue("[i f s (i f s) {s i s f}]", 1, 1.0, "one", 2, 2.0, "two", "three", 3, "four", 4.0)}; - auto *value = query::procedure::PyObjectToMgpValue(py_value.Ptr(), &memory); + auto *value = memgraph::query::procedure::PyObjectToMgpValue(py_value.Ptr(), &memory); ASSERT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_value_is_list, value), 1); auto *list1 = EXPECT_MGP_NO_ERROR(mgp_list *, mgp_value_get_list, value); @@ -300,7 +300,7 @@ int main(int argc, char **argv) { // Set program name, so Python can find its way to runtime libraries relative // to executable. Py_SetProgramName(program_name); - PyImport_AppendInittab("_mgp", &query::procedure::PyInitMgpModule); + PyImport_AppendInittab("_mgp", &memgraph::query::procedure::PyInitMgpModule); Py_InitializeEx(0 /* = initsigs */); PyEval_InitThreads(); int test_result; @@ -311,14 +311,14 @@ int main(int argc, char **argv) { MG_ASSERT(std::filesystem::exists(mgp_py_path)); auto *py_path = PySys_GetObject("path"); MG_ASSERT(py_path); - py::Object import_dir(PyUnicode_FromString(mgp_py_path.parent_path().c_str())); + memgraph::py::Object import_dir(PyUnicode_FromString(mgp_py_path.parent_path().c_str())); if (PyList_Append(py_path, import_dir.Ptr()) != 0) { - auto exc_info = py::FetchError().value(); + auto exc_info = memgraph::py::FetchError().value(); LOG_FATAL(exc_info); } - py::Object mgp(PyImport_ImportModule("mgp")); + memgraph::py::Object mgp(PyImport_ImportModule("mgp")); if (!mgp) { - auto exc_info = py::FetchError().value(); + auto exc_info = memgraph::py::FetchError().value(); LOG_FATAL(exc_info); } // Now run tests. diff --git a/tests/unit/query_procedures_mgp_graph.cpp b/tests/unit/query_procedures_mgp_graph.cpp index d9128a3ba..9638100b9 100644 --- a/tests/unit/query_procedures_mgp_graph.cpp +++ b/tests/unit/query_procedures_mgp_graph.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -91,27 +91,27 @@ size_t CountMaybeIterables(TMaybeIterable &&maybe_iterable) { } void CheckEdgeCountBetween(const MgpVertexPtr &from, const MgpVertexPtr &to, const size_t number_of_edges_between) { - EXPECT_EQ(CountMaybeIterables(from->impl.InEdges(storage::View::NEW)), 0); - EXPECT_EQ(CountMaybeIterables(from->impl.OutEdges(storage::View::NEW)), number_of_edges_between); - EXPECT_EQ(CountMaybeIterables(to->impl.InEdges(storage::View::NEW)), number_of_edges_between); - EXPECT_EQ(CountMaybeIterables(to->impl.OutEdges(storage::View::NEW)), 0); + EXPECT_EQ(CountMaybeIterables(from->impl.InEdges(memgraph::storage::View::NEW)), 0); + EXPECT_EQ(CountMaybeIterables(from->impl.OutEdges(memgraph::storage::View::NEW)), number_of_edges_between); + EXPECT_EQ(CountMaybeIterables(to->impl.InEdges(memgraph::storage::View::NEW)), number_of_edges_between); + EXPECT_EQ(CountMaybeIterables(to->impl.OutEdges(memgraph::storage::View::NEW)), 0); } } // namespace struct MgpGraphTest : public ::testing::Test { - mgp_graph CreateGraph(const storage::View view = storage::View::NEW) { + mgp_graph CreateGraph(const memgraph::storage::View view = memgraph::storage::View::NEW) { // the execution context can be null as it shouldn't be used in these tests - return mgp_graph{&CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION), view, ctx_.get()}; + return mgp_graph{&CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION), view, ctx_.get()}; } - std::array CreateEdge() { - std::array vertex_ids{}; - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + std::array CreateEdge() { + std::array vertex_ids{}; + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); for (auto i = 0; i < 2; ++i) { vertex_ids[i] = accessor.InsertVertex().Gid(); } - auto from = accessor.FindVertex(vertex_ids[0], storage::View::NEW); - auto to = accessor.FindVertex(vertex_ids[1], storage::View::NEW); + auto from = accessor.FindVertex(vertex_ids[0], memgraph::storage::View::NEW); + auto to = accessor.FindVertex(vertex_ids[1], memgraph::storage::View::NEW); EXPECT_TRUE(accessor.InsertEdge(&from.value(), &to.value(), accessor.NameToEdgeType("EDGE")).HasValue()); EXPECT_FALSE(accessor.Commit().HasError()); @@ -119,7 +119,7 @@ struct MgpGraphTest : public ::testing::Test { return vertex_ids; } - void GetFirstOutEdge(mgp_graph &graph, storage::Gid vertex_id, MgpEdgePtr &edge) { + void GetFirstOutEdge(mgp_graph &graph, memgraph::storage::Gid vertex_id, MgpEdgePtr &edge) { MgpVertexPtr from{EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{vertex_id.AsInt()}, &memory)}; ASSERT_NE(from, nullptr); @@ -133,108 +133,109 @@ struct MgpGraphTest : public ::testing::Test { ASSERT_NE(edge, nullptr); } - query::DbAccessor &CreateDbAccessor(const storage::IsolationLevel isolationLevel) { + memgraph::query::DbAccessor &CreateDbAccessor(const memgraph::storage::IsolationLevel isolationLevel) { accessors_.push_back(storage.Access(isolationLevel)); db_accessors_.emplace_back(&accessors_.back()); return db_accessors_.back(); } - storage::Storage storage; - mgp_memory memory{utils::NewDeleteResource()}; + memgraph::storage::Storage storage; + mgp_memory memory{memgraph::utils::NewDeleteResource()}; private: - std::list accessors_; - std::list db_accessors_; - std::unique_ptr ctx_ = std::make_unique(); + std::list accessors_; + std::list db_accessors_; + std::unique_ptr ctx_ = std::make_unique(); }; TEST_F(MgpGraphTest, IsMutable) { - mgp_graph immutable_graph = CreateGraph(storage::View::OLD); + mgp_graph immutable_graph = CreateGraph(memgraph::storage::View::OLD); EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_graph_is_mutable, &immutable_graph), 0); - mgp_graph mutable_graph = CreateGraph(storage::View::NEW); + mgp_graph mutable_graph = CreateGraph(memgraph::storage::View::NEW); EXPECT_NE(EXPECT_MGP_NO_ERROR(int, mgp_graph_is_mutable, &mutable_graph), 0); } TEST_F(MgpGraphTest, CreateVertex) { mgp_graph graph = CreateGraph(); - auto read_uncommited_accessor = storage.Access(storage::IsolationLevel::READ_UNCOMMITTED); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 0); + auto read_uncommited_accessor = storage.Access(memgraph::storage::IsolationLevel::READ_UNCOMMITTED); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 0); MgpVertexPtr vertex{EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_create_vertex, &graph, &memory)}; EXPECT_NE(vertex, nullptr); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 1); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 1); const auto vertex_id = EXPECT_MGP_NO_ERROR(mgp_vertex_id, mgp_vertex_get_id, vertex.get()); - EXPECT_TRUE( - read_uncommited_accessor.FindVertex(storage::Gid::FromInt(vertex_id.as_int), storage::View::NEW).has_value()); + EXPECT_TRUE(read_uncommited_accessor + .FindVertex(memgraph::storage::Gid::FromInt(vertex_id.as_int), memgraph::storage::View::NEW) + .has_value()); } TEST_F(MgpGraphTest, DeleteVertex) { - storage::Gid vertex_id{}; + memgraph::storage::Gid vertex_id{}; { - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); const auto vertex = accessor.InsertVertex(); vertex_id = vertex.Gid(); ASSERT_FALSE(accessor.Commit().HasError()); } mgp_graph graph = CreateGraph(); - auto read_uncommited_accessor = storage.Access(storage::IsolationLevel::READ_UNCOMMITTED); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 1); + auto read_uncommited_accessor = storage.Access(memgraph::storage::IsolationLevel::READ_UNCOMMITTED); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 1); MgpVertexPtr vertex{ EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{vertex_id.AsInt()}, &memory)}; EXPECT_NE(vertex, nullptr); EXPECT_SUCCESS(mgp_graph_delete_vertex(&graph, vertex.get())); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 0); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 0); } TEST_F(MgpGraphTest, DetachDeleteVertex) { const auto vertex_ids = CreateEdge(); auto graph = CreateGraph(); - auto read_uncommited_accessor = storage.Access(storage::IsolationLevel::READ_UNCOMMITTED); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 2); + auto read_uncommited_accessor = storage.Access(memgraph::storage::IsolationLevel::READ_UNCOMMITTED); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 2); MgpVertexPtr vertex{EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{vertex_ids.front().AsInt()}, &memory)}; EXPECT_EQ(mgp_graph_delete_vertex(&graph, vertex.get()), MGP_ERROR_LOGIC_ERROR); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 2); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 2); EXPECT_SUCCESS(mgp_graph_detach_delete_vertex(&graph, vertex.get())); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 1); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 1); } TEST_F(MgpGraphTest, CreateDeleteWithImmutableGraph) { - storage::Gid vertex_id{}; + memgraph::storage::Gid vertex_id{}; { - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); const auto vertex = accessor.InsertVertex(); vertex_id = vertex.Gid(); ASSERT_FALSE(accessor.Commit().HasError()); } - auto read_uncommited_accessor = storage.Access(storage::IsolationLevel::READ_UNCOMMITTED); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 1); + auto read_uncommited_accessor = storage.Access(memgraph::storage::IsolationLevel::READ_UNCOMMITTED); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 1); - mgp_graph immutable_graph = CreateGraph(storage::View::OLD); + mgp_graph immutable_graph = CreateGraph(memgraph::storage::View::OLD); mgp_vertex *raw_vertex{nullptr}; EXPECT_EQ(mgp_graph_create_vertex(&immutable_graph, &memory, &raw_vertex), MGP_ERROR_IMMUTABLE_OBJECT); MgpVertexPtr created_vertex{raw_vertex}; EXPECT_EQ(created_vertex, nullptr); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 1); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 1); MgpVertexPtr vertex_to_delete{EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &immutable_graph, mgp_vertex_id{vertex_id.AsInt()}, &memory)}; ASSERT_NE(vertex_to_delete, nullptr); EXPECT_EQ(mgp_graph_delete_vertex(&immutable_graph, vertex_to_delete.get()), MGP_ERROR_IMMUTABLE_OBJECT); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 1); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 1); } TEST_F(MgpGraphTest, VerticesIterator) { { - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); accessor.InsertVertex(); ASSERT_FALSE(accessor.Commit().HasError()); } - auto check_vertices_iterator = [this](const storage::View view) { + auto check_vertices_iterator = [this](const memgraph::storage::View view) { mgp_graph graph = CreateGraph(view); MgpVerticesIteratorPtr vertices_iter{ EXPECT_MGP_NO_ERROR(mgp_vertices_iterator *, mgp_graph_iter_vertices, &graph, &memory)}; ASSERT_NE(vertices_iter, nullptr); EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_vertices_iterator_get, vertices_iter.get()); - if (view == storage::View::NEW) { + if (view == memgraph::storage::View::NEW) { EXPECT_NE(EXPECT_MGP_NO_ERROR(int, mgp_vertices_iterator_underlying_graph_is_mutable, vertices_iter.get()), 0); } else { EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_vertices_iterator_underlying_graph_is_mutable, vertices_iter.get()), 0); @@ -242,44 +243,45 @@ TEST_F(MgpGraphTest, VerticesIterator) { }; { SCOPED_TRACE("View::OLD"); - check_vertices_iterator(storage::View::OLD); + check_vertices_iterator(memgraph::storage::View::OLD); } { SCOPED_TRACE("View::NEW"); - check_vertices_iterator(storage::View::NEW); + check_vertices_iterator(memgraph::storage::View::NEW); } } TEST_F(MgpGraphTest, VertexIsMutable) { - auto graph = CreateGraph(storage::View::NEW); + auto graph = CreateGraph(memgraph::storage::View::NEW); MgpVertexPtr vertex{EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_create_vertex, &graph, &memory)}; ASSERT_NE(vertex.get(), nullptr); EXPECT_NE(EXPECT_MGP_NO_ERROR(int, mgp_vertex_underlying_graph_is_mutable, vertex.get()), 0); - graph.view = storage::View::OLD; + graph.view = memgraph::storage::View::OLD; EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_vertex_underlying_graph_is_mutable, vertex.get()), 0); } TEST_F(MgpGraphTest, VertexSetProperty) { constexpr std::string_view property_to_update{"to_update"}; constexpr std::string_view property_to_set{"to_set"}; - storage::Gid vertex_id{}; + memgraph::storage::Gid vertex_id{}; { - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); auto vertex = accessor.InsertVertex(); vertex_id = vertex.Gid(); - const auto result = vertex.SetProperty(accessor.NameToProperty(property_to_update), storage::PropertyValue(42)); + const auto result = + vertex.SetProperty(accessor.NameToProperty(property_to_update), memgraph::storage::PropertyValue(42)); ASSERT_TRUE(result.HasValue()); ASSERT_FALSE(accessor.Commit().HasError()); } - auto read_uncommited_accessor = storage.Access(storage::IsolationLevel::READ_UNCOMMITTED); - EXPECT_EQ(CountVertices(read_uncommited_accessor, storage::View::NEW), 1); + auto read_uncommited_accessor = storage.Access(memgraph::storage::IsolationLevel::READ_UNCOMMITTED); + EXPECT_EQ(CountVertices(read_uncommited_accessor, memgraph::storage::View::NEW), 1); - mgp_graph graph = CreateGraph(storage::View::NEW); + mgp_graph graph = CreateGraph(memgraph::storage::View::NEW); MgpVertexPtr vertex{ EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{vertex_id.AsInt()}, &memory)}; ASSERT_NE(vertex, nullptr); - auto vertex_acc = read_uncommited_accessor.FindVertex(vertex_id, storage::View::NEW); + auto vertex_acc = read_uncommited_accessor.FindVertex(vertex_id, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_acc.has_value()); const auto property_id_to_update = read_uncommited_accessor.NameToProperty(property_to_update); @@ -291,9 +293,9 @@ TEST_F(MgpGraphTest, VertexSetProperty) { ASSERT_NE(value_to_update_to, nullptr); EXPECT_SUCCESS(mgp_vertex_set_property(vertex.get(), property_to_update.data(), value_to_update_to.get())); - const auto maybe_prop = vertex_acc->GetProperty(property_id_to_update, storage::View::NEW); + const auto maybe_prop = vertex_acc->GetProperty(property_id_to_update, memgraph::storage::View::NEW); ASSERT_TRUE(maybe_prop.HasValue()); - EXPECT_EQ(*maybe_prop, storage::PropertyValue{numerical_value_to_update_to}); + EXPECT_EQ(*maybe_prop, memgraph::storage::PropertyValue{numerical_value_to_update_to}); } { SCOPED_TRACE("Remove the property"); @@ -301,9 +303,9 @@ TEST_F(MgpGraphTest, VertexSetProperty) { ASSERT_NE(null_value, nullptr); EXPECT_SUCCESS(mgp_vertex_set_property(vertex.get(), property_to_update.data(), null_value.get())); - const auto maybe_prop = vertex_acc->GetProperty(property_id_to_update, storage::View::NEW); + const auto maybe_prop = vertex_acc->GetProperty(property_id_to_update, memgraph::storage::View::NEW); ASSERT_TRUE(maybe_prop.HasValue()); - EXPECT_EQ(*maybe_prop, storage::PropertyValue{}); + EXPECT_EQ(*maybe_prop, memgraph::storage::PropertyValue{}); } { SCOPED_TRACE("Add a property"); @@ -312,23 +314,23 @@ TEST_F(MgpGraphTest, VertexSetProperty) { ASSERT_NE(value_to_set, nullptr); EXPECT_SUCCESS(mgp_vertex_set_property(vertex.get(), property_to_set.data(), value_to_set.get())); const auto maybe_prop = - vertex_acc->GetProperty(read_uncommited_accessor.NameToProperty(property_to_set), storage::View::NEW); + vertex_acc->GetProperty(read_uncommited_accessor.NameToProperty(property_to_set), memgraph::storage::View::NEW); ASSERT_TRUE(maybe_prop.HasValue()); - EXPECT_EQ(*maybe_prop, storage::PropertyValue{numerical_value_to_set}); + EXPECT_EQ(*maybe_prop, memgraph::storage::PropertyValue{numerical_value_to_set}); } } TEST_F(MgpGraphTest, VertexAddLabel) { constexpr std::string_view label = "test_label"; - storage::Gid vertex_id{}; + memgraph::storage::Gid vertex_id{}; { - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); const auto vertex = accessor.InsertVertex(); vertex_id = vertex.Gid(); ASSERT_FALSE(accessor.Commit().HasError()); } - mgp_graph graph = CreateGraph(storage::View::NEW); + mgp_graph graph = CreateGraph(memgraph::storage::View::NEW); MgpVertexPtr vertex{ EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{vertex_id.AsInt()}, &memory)}; EXPECT_SUCCESS(mgp_vertex_add_label(vertex.get(), mgp_label{label.data()})); @@ -336,10 +338,10 @@ TEST_F(MgpGraphTest, VertexAddLabel) { auto check_label = [&]() { EXPECT_NE(EXPECT_MGP_NO_ERROR(int, mgp_vertex_has_label_named, vertex.get(), label.data()), 0); - auto read_uncommited_accessor = storage.Access(storage::IsolationLevel::READ_UNCOMMITTED); - const auto maybe_vertex = read_uncommited_accessor.FindVertex(vertex_id, storage::View::NEW); + auto read_uncommited_accessor = storage.Access(memgraph::storage::IsolationLevel::READ_UNCOMMITTED); + const auto maybe_vertex = read_uncommited_accessor.FindVertex(vertex_id, memgraph::storage::View::NEW); ASSERT_TRUE(maybe_vertex.has_value()); - const auto label_ids = maybe_vertex->Labels(storage::View::NEW); + const auto label_ids = maybe_vertex->Labels(memgraph::storage::View::NEW); ASSERT_TRUE(label_ids.HasValue()); EXPECT_THAT(*label_ids, ::testing::ContainerEq(std::vector{read_uncommited_accessor.NameToLabel(label)})); }; @@ -350,9 +352,9 @@ TEST_F(MgpGraphTest, VertexAddLabel) { TEST_F(MgpGraphTest, VertexRemoveLabel) { constexpr std::string_view label = "test_label"; - storage::Gid vertex_id{}; + memgraph::storage::Gid vertex_id{}; { - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); auto vertex = accessor.InsertVertex(); const auto result = vertex.AddLabel(accessor.NameToLabel(label)); ASSERT_TRUE(result.HasValue()); @@ -361,7 +363,7 @@ TEST_F(MgpGraphTest, VertexRemoveLabel) { ASSERT_FALSE(accessor.Commit().HasError()); } - mgp_graph graph = CreateGraph(storage::View::NEW); + mgp_graph graph = CreateGraph(memgraph::storage::View::NEW); MgpVertexPtr vertex{ EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{vertex_id.AsInt()}, &memory)}; EXPECT_SUCCESS(mgp_vertex_remove_label(vertex.get(), mgp_label{label.data()})); @@ -369,10 +371,10 @@ TEST_F(MgpGraphTest, VertexRemoveLabel) { auto check_label = [&]() { EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_vertex_has_label_named, vertex.get(), label.data()), 0); - auto read_uncommited_accessor = storage.Access(storage::IsolationLevel::READ_UNCOMMITTED); - const auto maybe_vertex = read_uncommited_accessor.FindVertex(vertex_id, storage::View::NEW); + auto read_uncommited_accessor = storage.Access(memgraph::storage::IsolationLevel::READ_UNCOMMITTED); + const auto maybe_vertex = read_uncommited_accessor.FindVertex(vertex_id, memgraph::storage::View::NEW); ASSERT_TRUE(maybe_vertex.has_value()); - const auto label_ids = maybe_vertex->Labels(storage::View::NEW); + const auto label_ids = maybe_vertex->Labels(memgraph::storage::View::NEW); ASSERT_TRUE(label_ids.HasValue()); EXPECT_EQ(label_ids->size(), 0); }; @@ -383,15 +385,15 @@ TEST_F(MgpGraphTest, VertexRemoveLabel) { TEST_F(MgpGraphTest, ModifyImmutableVertex) { constexpr std::string_view label_to_remove{"label_to_remove"}; - storage::Gid vertex_id{}; + memgraph::storage::Gid vertex_id{}; { - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); auto vertex = accessor.InsertVertex(); vertex_id = vertex.Gid(); ASSERT_TRUE(vertex.AddLabel(accessor.NameToLabel(label_to_remove)).HasValue()); ASSERT_FALSE(accessor.Commit().HasError()); } - auto graph = CreateGraph(storage::View::OLD); + auto graph = CreateGraph(memgraph::storage::View::OLD); MgpVertexPtr vertex{ EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{vertex_id.AsInt()}, &memory)}; EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_vertex_underlying_graph_is_mutable, vertex.get()), 0); @@ -403,9 +405,9 @@ TEST_F(MgpGraphTest, ModifyImmutableVertex) { } TEST_F(MgpGraphTest, CreateDeleteEdge) { - std::array vertex_ids{}; + std::array vertex_ids{}; { - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); for (auto i = 0; i < 2; ++i) { vertex_ids[i] = accessor.InsertVertex().Gid(); } @@ -428,10 +430,10 @@ TEST_F(MgpGraphTest, CreateDeleteEdge) { } TEST_F(MgpGraphTest, CreateDeleteEdgeWithImmutableGraph) { - storage::Gid from_id; - storage::Gid to_id; + memgraph::storage::Gid from_id; + memgraph::storage::Gid to_id; { - auto accessor = CreateDbAccessor(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); auto from = accessor.InsertVertex(); auto to = accessor.InsertVertex(); from_id = from.Gid(); @@ -439,7 +441,7 @@ TEST_F(MgpGraphTest, CreateDeleteEdgeWithImmutableGraph) { ASSERT_TRUE(accessor.InsertEdge(&from, &to, accessor.NameToEdgeType("EDGE_TYPE_TO_REMOVE")).HasValue()); ASSERT_FALSE(accessor.Commit().HasError()); } - auto graph = CreateGraph(storage::View::OLD); + auto graph = CreateGraph(memgraph::storage::View::OLD); MgpVertexPtr from{ EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, mgp_vertex_id{from_id.AsInt()}, &memory)}; MgpVertexPtr to{ @@ -469,17 +471,17 @@ TEST_F(MgpGraphTest, EdgeIsMutable) { MgpEdgePtr edge{}; ASSERT_NO_FATAL_FAILURE(GetFirstOutEdge(graph, vertex_ids[0], edge)); EXPECT_NE(EXPECT_MGP_NO_ERROR(int, mgp_edge_underlying_graph_is_mutable, edge.get()), 0); - graph.view = storage::View::OLD; + graph.view = memgraph::storage::View::OLD; EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_edge_underlying_graph_is_mutable, edge.get()), 0); } TEST_F(MgpGraphTest, MutableFromTo) { - storage::Gid from_vertex_id{}; + memgraph::storage::Gid from_vertex_id{}; { const auto vertex_ids = CreateEdge(); from_vertex_id = vertex_ids[0]; } - auto check_edges_iterator = [this, from_vertex_id](const storage::View view) { + auto check_edges_iterator = [this, from_vertex_id](const memgraph::storage::View view) { mgp_graph graph = CreateGraph(view); MgpEdgePtr edge{}; @@ -491,7 +493,7 @@ TEST_F(MgpGraphTest, MutableFromTo) { EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_vertex_underlying_graph_is_mutable, from) != 0, is_mutable); EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_vertex_underlying_graph_is_mutable, to) != 0, is_mutable); }; - if (view == storage::View::NEW) { + if (view == memgraph::storage::View::NEW) { check_is_mutable(true); } else { check_is_mutable(false); @@ -499,21 +501,21 @@ TEST_F(MgpGraphTest, MutableFromTo) { }; { SCOPED_TRACE("View::OLD"); - check_edges_iterator(storage::View::OLD); + check_edges_iterator(memgraph::storage::View::OLD); } { SCOPED_TRACE("View::NEW"); - check_edges_iterator(storage::View::NEW); + check_edges_iterator(memgraph::storage::View::NEW); } } TEST_F(MgpGraphTest, EdgesIterator) { - storage::Gid from_vertex_id{}; + memgraph::storage::Gid from_vertex_id{}; { const auto vertex_ids = CreateEdge(); from_vertex_id = vertex_ids[0]; } - auto check_edges_iterator = [this, from_vertex_id](const storage::View view) { + auto check_edges_iterator = [this, from_vertex_id](const memgraph::storage::View view) { mgp_graph graph = CreateGraph(view); MgpVertexPtr from{EXPECT_MGP_NO_ERROR(mgp_vertex *, mgp_graph_get_vertex_by_id, &graph, @@ -524,7 +526,7 @@ TEST_F(MgpGraphTest, EdgesIterator) { EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_edges_iterator_underlying_graph_is_mutable, iter.get()) != 0, is_mutable); EXPECT_EQ(EXPECT_MGP_NO_ERROR(int, mgp_edge_underlying_graph_is_mutable, edge) != 0, is_mutable); }; - if (view == storage::View::NEW) { + if (view == memgraph::storage::View::NEW) { check_is_mutable(true); } else { check_is_mutable(false); @@ -532,11 +534,11 @@ TEST_F(MgpGraphTest, EdgesIterator) { }; { SCOPED_TRACE("View::OLD"); - check_edges_iterator(storage::View::OLD); + check_edges_iterator(memgraph::storage::View::OLD); } { SCOPED_TRACE("View::NEW"); - check_edges_iterator(storage::View::NEW); + check_edges_iterator(memgraph::storage::View::NEW); } } @@ -544,23 +546,24 @@ TEST_F(MgpGraphTest, EdgeSetProperty) { constexpr std::string_view property_to_update{"to_update"}; constexpr std::string_view property_to_set{"to_set"}; - storage::Gid from_vertex_id{}; - auto get_edge = [&from_vertex_id](storage::Storage::Accessor &accessor) -> storage::EdgeAccessor { - auto from = accessor.FindVertex(from_vertex_id, storage::View::NEW); - return from->OutEdges(storage::View::NEW).GetValue().front(); + memgraph::storage::Gid from_vertex_id{}; + auto get_edge = [&from_vertex_id](memgraph::storage::Storage::Accessor &accessor) -> memgraph::storage::EdgeAccessor { + auto from = accessor.FindVertex(from_vertex_id, memgraph::storage::View::NEW); + return from->OutEdges(memgraph::storage::View::NEW).GetValue().front(); }; { const auto vertex_ids = CreateEdge(); from_vertex_id = vertex_ids[0]; - auto accessor = storage.Access(storage::IsolationLevel::SNAPSHOT_ISOLATION); + auto accessor = storage.Access(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); auto edge = get_edge(accessor); - const auto result = edge.SetProperty(accessor.NameToProperty(property_to_update), storage::PropertyValue(42)); + const auto result = + edge.SetProperty(accessor.NameToProperty(property_to_update), memgraph::storage::PropertyValue(42)); ASSERT_TRUE(result.HasValue()); ASSERT_FALSE(accessor.Commit().HasError()); } - auto read_uncommited_accessor = storage.Access(storage::IsolationLevel::READ_UNCOMMITTED); + auto read_uncommited_accessor = storage.Access(memgraph::storage::IsolationLevel::READ_UNCOMMITTED); - mgp_graph graph = CreateGraph(storage::View::NEW); + mgp_graph graph = CreateGraph(memgraph::storage::View::NEW); MgpEdgePtr edge; ASSERT_NO_FATAL_FAILURE(GetFirstOutEdge(graph, from_vertex_id, edge)); const auto edge_acc = get_edge(read_uncommited_accessor); @@ -575,9 +578,9 @@ TEST_F(MgpGraphTest, EdgeSetProperty) { ASSERT_NE(value_to_update_to, nullptr); EXPECT_SUCCESS(mgp_edge_set_property(edge.get(), property_to_update.data(), value_to_update_to.get())); - const auto maybe_prop = edge_acc.GetProperty(property_id_to_update, storage::View::NEW); + const auto maybe_prop = edge_acc.GetProperty(property_id_to_update, memgraph::storage::View::NEW); ASSERT_TRUE(maybe_prop.HasValue()); - EXPECT_EQ(*maybe_prop, storage::PropertyValue{numerical_value_to_update_to}); + EXPECT_EQ(*maybe_prop, memgraph::storage::PropertyValue{numerical_value_to_update_to}); } { SCOPED_TRACE("Remove the property"); @@ -585,9 +588,9 @@ TEST_F(MgpGraphTest, EdgeSetProperty) { ASSERT_NE(null_value, nullptr); EXPECT_SUCCESS(mgp_edge_set_property(edge.get(), property_to_update.data(), null_value.get())); - const auto maybe_prop = edge_acc.GetProperty(property_id_to_update, storage::View::NEW); + const auto maybe_prop = edge_acc.GetProperty(property_id_to_update, memgraph::storage::View::NEW); ASSERT_TRUE(maybe_prop.HasValue()); - EXPECT_EQ(*maybe_prop, storage::PropertyValue{}); + EXPECT_EQ(*maybe_prop, memgraph::storage::PropertyValue{}); } { SCOPED_TRACE("Add a property"); @@ -596,19 +599,19 @@ TEST_F(MgpGraphTest, EdgeSetProperty) { ASSERT_NE(value_to_set, nullptr); EXPECT_SUCCESS(mgp_edge_set_property(edge.get(), property_to_set.data(), value_to_set.get())); const auto maybe_prop = - edge_acc.GetProperty(read_uncommited_accessor.NameToProperty(property_to_set), storage::View::NEW); + edge_acc.GetProperty(read_uncommited_accessor.NameToProperty(property_to_set), memgraph::storage::View::NEW); ASSERT_TRUE(maybe_prop.HasValue()); - EXPECT_EQ(*maybe_prop, storage::PropertyValue{numerical_value_to_set}); + EXPECT_EQ(*maybe_prop, memgraph::storage::PropertyValue{numerical_value_to_set}); } } TEST_F(MgpGraphTest, EdgeSetPropertyWithImmutableGraph) { - storage::Gid from_vertex_id{}; + memgraph::storage::Gid from_vertex_id{}; { const auto vertex_ids = CreateEdge(); from_vertex_id = vertex_ids[0]; } - auto graph = CreateGraph(storage::View::OLD); + auto graph = CreateGraph(memgraph::storage::View::OLD); MgpEdgePtr edge; ASSERT_NO_FATAL_FAILURE(GetFirstOutEdge(graph, from_vertex_id, edge)); MgpValuePtr value{EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_int, 65, &memory)}; diff --git a/tests/unit/query_profile.cpp b/tests/unit/query_profile.cpp index 51b6b1817..74476fdc7 100644 --- a/tests/unit/query_profile.cpp +++ b/tests/unit/query_profile.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "query/plan/profile.hpp" -using namespace query::plan; +using namespace memgraph::query::plan; TEST(QueryProfileTest, SimpleQuery) { std::chrono::duration total_time{0.001}; diff --git a/tests/unit/query_required_privileges.cpp b/tests/unit/query_required_privileges.cpp index e6dc3c6ad..ad21b10c4 100644 --- a/tests/unit/query_required_privileges.cpp +++ b/tests/unit/query_required_privileges.cpp @@ -19,7 +19,7 @@ #include "query_common.hpp" -using namespace query; +using namespace memgraph::query; class FakeDbAccessor {}; diff --git a/tests/unit/query_semantic.cpp b/tests/unit/query_semantic.cpp index f057bca84..643d8175d 100644 --- a/tests/unit/query_semantic.cpp +++ b/tests/unit/query_semantic.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,20 +22,20 @@ #include "query_common.hpp" -using namespace query; +using namespace memgraph::query; class TestSymbolGenerator : public ::testing::Test { protected: - storage::Storage db; - storage::Storage::Accessor storage_dba{db.Access()}; - query::DbAccessor dba{&storage_dba}; + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor storage_dba{db.Access()}; + memgraph::query::DbAccessor dba{&storage_dba}; AstStorage storage; }; TEST_F(TestSymbolGenerator, MatchNodeReturn) { // MATCH (node_atom_1) RETURN node_atom_1 auto query_ast = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("node_atom_1"))), RETURN("node_atom_1"))); - auto symbol_table = query::MakeSymbolTable(query_ast); + auto symbol_table = memgraph::query::MakeSymbolTable(query_ast); // symbols for pattern, node_atom_1 and named_expr in return EXPECT_EQ(symbol_table.max_position(), 3); auto match = dynamic_cast(query_ast->single_query_->clauses_[0]); @@ -59,7 +59,7 @@ TEST_F(TestSymbolGenerator, MatchNodeReturn) { TEST_F(TestSymbolGenerator, MatchNamedPattern) { // MATCH p = (node_atom_1) RETURN node_atom_1 auto query_ast = QUERY(SINGLE_QUERY(MATCH(NAMED_PATTERN("p", NODE("node_atom_1"))), RETURN("p"))); - auto symbol_table = query::MakeSymbolTable(query_ast); + auto symbol_table = memgraph::query::MakeSymbolTable(query_ast); // symbols for p, node_atom_1 and named_expr in return EXPECT_EQ(symbol_table.max_position(), 3); auto match = dynamic_cast(query_ast->single_query_->clauses_[0]); @@ -75,13 +75,13 @@ TEST_F(TestSymbolGenerator, MatchUnboundMultiReturn) { // expression. This is treated as an unbound variable. // MATCH (node_atom_1) RETURN node_atom_1 AS n, n auto query_ast = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("node_atom_1"))), RETURN("node_atom_1", AS("n"), "n"))); - EXPECT_THROW(query::MakeSymbolTable(query_ast), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query_ast), UnboundVariableError); } TEST_F(TestSymbolGenerator, MatchNodeUnboundReturn) { // AST with unbound variable in return: MATCH (n) RETURN x auto query_ast = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), RETURN("x"))); - EXPECT_THROW(query::MakeSymbolTable(query_ast), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query_ast), UnboundVariableError); } TEST_F(TestSymbolGenerator, CreatePropertyUnbound) { @@ -89,13 +89,13 @@ TEST_F(TestSymbolGenerator, CreatePropertyUnbound) { auto node = NODE("anon"); std::get<0>(node->properties_)[storage.GetPropertyIx("prop")] = IDENT("x"); auto *query_ast = QUERY(SINGLE_QUERY(CREATE(PATTERN(node)))); - EXPECT_THROW(query::MakeSymbolTable(query_ast), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query_ast), UnboundVariableError); } TEST_F(TestSymbolGenerator, CreateNodeReturn) { // Simple AST returning a created node: CREATE (n) RETURN n auto query_ast = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"))), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query_ast); + auto symbol_table = memgraph::query::MakeSymbolTable(query_ast); // symbols for pattern, `n` and named_expr EXPECT_EQ(symbol_table.max_position(), 3); auto create = dynamic_cast(query_ast->single_query_->clauses_[0]); @@ -116,20 +116,20 @@ TEST_F(TestSymbolGenerator, CreateNodeReturn) { TEST_F(TestSymbolGenerator, CreateRedeclareNode) { // AST with redeclaring a variable when creating nodes: CREATE (n), (n) auto query_ast = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n")), PATTERN(NODE("n"))))); - EXPECT_THROW(query::MakeSymbolTable(query_ast), RedeclareVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query_ast), RedeclareVariableError); } TEST_F(TestSymbolGenerator, MultiCreateRedeclareNode) { // AST with redeclaring a variable when creating nodes with multiple creates: // CREATE (n) CREATE (n) auto query_ast = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"))), CREATE(PATTERN(NODE("n"))))); - EXPECT_THROW(query::MakeSymbolTable(query_ast), RedeclareVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query_ast), RedeclareVariableError); } TEST_F(TestSymbolGenerator, MatchCreateRedeclareNode) { // AST with redeclaring a match node variable in create: MATCH (n) CREATE (n) auto query_ast = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), CREATE(PATTERN(NODE("n"))))); - EXPECT_THROW(query::MakeSymbolTable(query_ast), RedeclareVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query_ast), RedeclareVariableError); } TEST_F(TestSymbolGenerator, MatchCreateRedeclareEdge) { @@ -139,14 +139,14 @@ TEST_F(TestSymbolGenerator, MatchCreateRedeclareEdge) { auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), CREATE(PATTERN(NODE("n"), EDGE("r", EdgeAtom::Direction::OUT, {relationship}), NODE("l"))))); - EXPECT_THROW(query::MakeSymbolTable(query), RedeclareVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), RedeclareVariableError); } TEST_F(TestSymbolGenerator, MatchTypeMismatch) { // Using an edge variable as a node causes a type mismatch. // MATCH (n) -[r]-> (r) auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("r"))))); - EXPECT_THROW(query::MakeSymbolTable(query), TypeMismatchError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), TypeMismatchError); } TEST_F(TestSymbolGenerator, MatchCreateTypeMismatch) { @@ -154,7 +154,7 @@ TEST_F(TestSymbolGenerator, MatchCreateTypeMismatch) { // MATCH (n1) -[r1]- (n2) CREATE (r1) -[r2]-> (n2) auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n1"), EDGE("r1"), NODE("n2"))), CREATE(PATTERN(NODE("r1"), EDGE("r2", EdgeAtom::Direction::OUT), NODE("n2"))))); - EXPECT_THROW(query::MakeSymbolTable(query), TypeMismatchError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), TypeMismatchError); } TEST_F(TestSymbolGenerator, CreateMultipleEdgeType) { @@ -165,7 +165,7 @@ TEST_F(TestSymbolGenerator, CreateMultipleEdgeType) { auto edge = EDGE("r", EdgeAtom::Direction::OUT, {rel1}); edge->edge_types_.emplace_back(storage.GetEdgeTypeIx(rel2)); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"), edge, NODE("m"))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, CreateBidirectionalEdge) { @@ -173,13 +173,13 @@ TEST_F(TestSymbolGenerator, CreateBidirectionalEdge) { // CREATE (n) -[r :rel1]- (m) auto rel1 = "rel1"; auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"), EDGE("r", EdgeAtom::Direction::BOTH, {rel1}), NODE("m"))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MatchWhereUnbound) { // Test MATCH (n) WHERE missing < 42 RETURN n auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), WHERE(LESS(IDENT("missing"), LITERAL(42))), RETURN("n"))); - EXPECT_THROW(query::MakeSymbolTable(query), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), UnboundVariableError); } TEST_F(TestSymbolGenerator, CreateDelete) { @@ -187,7 +187,7 @@ TEST_F(TestSymbolGenerator, CreateDelete) { auto node = NODE("n"); auto ident = IDENT("n"); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(node)), DELETE(ident))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // symbols for pattern and `n` EXPECT_EQ(symbol_table.max_position(), 2); auto node_symbol = symbol_table.at(*node->identifier_); @@ -199,7 +199,7 @@ TEST_F(TestSymbolGenerator, CreateDelete) { TEST_F(TestSymbolGenerator, CreateDeleteUnbound) { // Test CREATE (n) DELETE missing auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"))), DELETE(IDENT("missing")))); - EXPECT_THROW(query::MakeSymbolTable(query), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), UnboundVariableError); } TEST_F(TestSymbolGenerator, MatchWithReturn) { @@ -210,7 +210,7 @@ TEST_F(TestSymbolGenerator, MatchWithReturn) { auto n_ident = IDENT("n"); auto ret_as_n = AS("n"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node)), WITH(old_ident, with_as_n), RETURN(n_ident, ret_as_n))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // symbols for pattern, `old`, `n` and named_expr in return EXPECT_EQ(symbol_table.max_position(), 4); auto node_symbol = symbol_table.at(*node->identifier_); @@ -227,7 +227,7 @@ TEST_F(TestSymbolGenerator, MatchWithReturn) { TEST_F(TestSymbolGenerator, MatchWithReturnUnbound) { // Test MATCH (old) WITH old AS n RETURN old auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), WITH("old", AS("n")), RETURN("old"))); - EXPECT_THROW(query::MakeSymbolTable(query), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), UnboundVariableError); } TEST_F(TestSymbolGenerator, MatchWithWhere) { @@ -238,7 +238,7 @@ TEST_F(TestSymbolGenerator, MatchWithWhere) { auto with_as_n = AS("n"); auto n_prop = PROPERTY_LOOKUP("n", prop); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node)), WITH(old_ident, with_as_n), WHERE(LESS(n_prop, LITERAL(42))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // symbols for pattern, `old` and `n` EXPECT_EQ(symbol_table.max_position(), 3); auto node_symbol = symbol_table.at(*node->identifier_); @@ -255,7 +255,7 @@ TEST_F(TestSymbolGenerator, MatchWithWhereUnbound) { auto prop = dba.NameToProperty("prop"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), WITH(COUNT(IDENT("old")), AS("c")), WHERE(LESS(PROPERTY_LOOKUP("old", prop), LITERAL(42))))); - EXPECT_THROW(query::MakeSymbolTable(query), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), UnboundVariableError); } TEST_F(TestSymbolGenerator, CreateMultiExpand) { @@ -269,7 +269,7 @@ TEST_F(TestSymbolGenerator, CreateMultiExpand) { auto edge_p = EDGE("p", EdgeAtom::Direction::OUT, {p_type}); auto node_l = NODE("l"); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(node_n1, edge_r, node_m), PATTERN(node_n2, edge_p, node_l)))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // symbols for pattern * 2, `n`, `r`, `m`, `p`, `l` EXPECT_EQ(symbol_table.max_position(), 7); auto n1 = symbol_table.at(*node_n1->identifier_); @@ -297,7 +297,7 @@ TEST_F(TestSymbolGenerator, MatchCreateExpandLabel) { auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), CREATE(PATTERN(NODE("m"), EDGE("r", EdgeAtom::Direction::OUT, {r_type}), NODE("n", label))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, CreateExpandProperty) { @@ -306,7 +306,7 @@ TEST_F(TestSymbolGenerator, CreateExpandProperty) { auto n_prop = NODE("n"); std::get<0>(n_prop->properties_)[storage.GetPropertyIx("prop")] = LITERAL(42); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"), EDGE("r", EdgeAtom::Direction::OUT, {r_type}), n_prop)))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MatchReturnSum) { @@ -316,7 +316,7 @@ TEST_F(TestSymbolGenerator, MatchReturnSum) { auto sum = SUM(PROPERTY_LOOKUP("n", prop)); auto as_result = AS("result"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node)), RETURN(ADD(sum, LITERAL(42)), as_result))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // 3 symbols for: pattern, 'n', 'sum' and 'result'. EXPECT_EQ(symbol_table.max_position(), 4); auto node_symbol = symbol_table.at(*node->identifier_); @@ -332,7 +332,7 @@ TEST_F(TestSymbolGenerator, NestedAggregation) { auto prop = dba.NameToProperty("prop"); auto query = QUERY( SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), RETURN(SUM(ADD(LITERAL(42), SUM(PROPERTY_LOOKUP("n", prop)))), AS("s")))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, WrongAggregationContext) { @@ -340,7 +340,7 @@ TEST_F(TestSymbolGenerator, WrongAggregationContext) { auto prop = dba.NameToProperty("prop"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), WITH(PROPERTY_LOOKUP("n", prop), AS("prop")), WHERE(LESS(SUM(IDENT("prop")), LITERAL(42))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MatchPropCreateNodeProp) { @@ -351,7 +351,7 @@ TEST_F(TestSymbolGenerator, MatchPropCreateNodeProp) { auto n_prop = PROPERTY_LOOKUP("n", prop.second); std::get<0>(node_m->properties_)[storage.GetPropertyIx(prop.first)] = n_prop; auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_n)), CREATE(PATTERN(node_m)))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // symbols: pattern * 2, `node_n`, `node_m` EXPECT_EQ(symbol_table.max_position(), 4); auto n = symbol_table.at(*node_n->identifier_); @@ -368,7 +368,7 @@ TEST_F(TestSymbolGenerator, CreateNodeEdge) { auto edge = EDGE("r", EdgeAtom::Direction::OUT, {r_type}); auto node_3 = NODE("n"); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(node_1), PATTERN(node_2, edge, node_3)))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // symbols: pattern * 2, `n`, `r` EXPECT_EQ(symbol_table.max_position(), 4); auto n = symbol_table.at(*node_1->identifier_); @@ -385,7 +385,7 @@ TEST_F(TestSymbolGenerator, MatchWithCreate) { auto edge = EDGE("r", EdgeAtom::Direction::OUT, {r_type}); auto node_3 = NODE("m"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_1)), WITH("n", AS("m")), CREATE(PATTERN(node_2, edge, node_3)))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // symbols: pattern * 2, `n`, `m`, `r` EXPECT_EQ(symbol_table.max_position(), 5); auto n = symbol_table.at(*node_1->identifier_); @@ -400,44 +400,44 @@ TEST_F(TestSymbolGenerator, MatchWithCreate) { TEST_F(TestSymbolGenerator, SameResultsWith) { // Test MATCH (n) WITH n AS m, n AS m auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), WITH("n", AS("m"), "n", AS("m")))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, SameResults) { // Test MATCH (n) RETURN n, n auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), RETURN("n", "n"))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, SkipUsingIdentifier) { // Test MATCH (old) WITH old AS new SKIP old auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), WITH("old", AS("new"), SKIP(IDENT("old"))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, SkipUsingIdentifierAlias) { // Test MATCH (old) WITH old AS new SKIP new auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), WITH("old", AS("new"), SKIP(IDENT("new"))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, LimitUsingIdentifier) { // Test MATCH (n) RETURN n AS n LIMIT n auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), RETURN("n", LIMIT(IDENT("n"))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, OrderByAggregation) { // Test MATCH (old) RETURN old AS new ORDER BY COUNT(1) auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), RETURN("old", AS("new"), ORDER_BY(COUNT(LITERAL(1)))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, OrderByUnboundVariable) { // Test MATCH (old) RETURN COUNT(old) AS new ORDER BY old auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), RETURN(COUNT(IDENT("old")), AS("new"), ORDER_BY(IDENT("old"))))); - EXPECT_THROW(query::MakeSymbolTable(query), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), UnboundVariableError); } TEST_F(TestSymbolGenerator, AggregationOrderBy) { @@ -447,7 +447,7 @@ TEST_F(TestSymbolGenerator, AggregationOrderBy) { auto as_new = AS("new"); auto ident_new = IDENT("new"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node)), RETURN(COUNT(ident_old), as_new, ORDER_BY(ident_new)))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for pattern, `old`, `count(old)` and `new` EXPECT_EQ(symbol_table.max_position(), 4); auto old = symbol_table.at(*node->identifier_); @@ -464,7 +464,7 @@ TEST_F(TestSymbolGenerator, OrderByOldVariable) { auto as_new = AS("new"); auto by_old = IDENT("old"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node)), RETURN(ident_old, as_new, ORDER_BY(by_old)))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for pattern, `old` and `new` EXPECT_EQ(symbol_table.max_position(), 3); auto old = symbol_table.at(*node->identifier_); @@ -477,7 +477,7 @@ TEST_F(TestSymbolGenerator, OrderByOldVariable) { TEST_F(TestSymbolGenerator, MergeVariableError) { // Test MATCH (n) MERGE (n) auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), MERGE(PATTERN(NODE("n"))))); - EXPECT_THROW(query::MakeSymbolTable(query), RedeclareVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), RedeclareVariableError); } TEST_F(TestSymbolGenerator, MergeVariableErrorEdge) { @@ -485,14 +485,14 @@ TEST_F(TestSymbolGenerator, MergeVariableErrorEdge) { auto rel = "rel"; auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), MERGE(PATTERN(NODE("a"), EDGE("r", EdgeAtom::Direction::BOTH, {rel}), NODE("b"))))); - EXPECT_THROW(query::MakeSymbolTable(query), RedeclareVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), RedeclareVariableError); } TEST_F(TestSymbolGenerator, MergeEdgeWithoutType) { // Test MERGE (a) -[r]- (b) auto query = QUERY(SINGLE_QUERY(MERGE(PATTERN(NODE("a"), EDGE("r"), NODE("b"))))); // Edge must have a type, since it doesn't we raise. - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MergeOnMatchOnCreate) { @@ -512,7 +512,7 @@ TEST_F(TestSymbolGenerator, MergeOnMatchOnCreate) { MATCH(PATTERN(match_n)), MERGE(PATTERN(merge_n, edge_r, node_m), ON_MATCH(SET(n_prop, LITERAL(42))), ON_CREATE(SET(m_prop, LITERAL(42)))), RETURN(ident_r, as_r))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for: pattern * 2, `n`, `r`, `m` and `AS r`. EXPECT_EQ(symbol_table.max_position(), 6); auto n = symbol_table.at(*match_n->identifier_); @@ -533,7 +533,7 @@ TEST_F(TestSymbolGenerator, WithUnwindRedeclareReturn) { // Test WITH [1, 2] AS list UNWIND list AS list RETURN list auto query = QUERY( SINGLE_QUERY(WITH(LIST(LITERAL(1), LITERAL(2)), AS("list")), UNWIND(IDENT("list"), AS("list")), RETURN("list"))); - EXPECT_THROW(query::MakeSymbolTable(query), RedeclareVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), RedeclareVariableError); } TEST_F(TestSymbolGenerator, WithUnwindReturn) { @@ -546,7 +546,7 @@ TEST_F(TestSymbolGenerator, WithUnwindReturn) { auto ret_as_elem = AS("elem"); auto query = QUERY(SINGLE_QUERY(WITH(LIST(LITERAL(1), LITERAL(2)), with_as_list), unwind, RETURN(ret_list, ret_as_list, ret_elem, ret_as_elem))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for: `list`, `elem`, `AS list`, `AS elem` EXPECT_EQ(symbol_table.max_position(), 4); const auto &list = symbol_table.at(*with_as_list); @@ -571,7 +571,7 @@ TEST_F(TestSymbolGenerator, MatchCrossReferenceVariable) { auto ident_n = IDENT("n"); auto as_n = AS("n"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_n), PATTERN(node_m)), RETURN(ident_n, as_n))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for pattern * 2, `n`, `m` and `AS n` EXPECT_EQ(symbol_table.max_position(), 5); auto n = symbol_table.at(*node_n->identifier_); @@ -596,7 +596,7 @@ TEST_F(TestSymbolGenerator, MatchWithAsteriskReturnAsterisk) { auto with = storage.Create(); with->body_.all_identifiers = true; auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_n, edge, node_m)), with, ret)); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for pattern, `n`, `e`, `m`, `AS n.prop`. EXPECT_EQ(symbol_table.max_position(), 5); auto n = symbol_table.at(*node_n->identifier_); @@ -608,7 +608,7 @@ TEST_F(TestSymbolGenerator, MatchReturnAsteriskSameResult) { auto ret = RETURN("n"); ret->body_.all_identifiers = true; auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), ret)); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MatchReturnAsteriskNoUserVariables) { @@ -618,7 +618,7 @@ TEST_F(TestSymbolGenerator, MatchReturnAsteriskNoUserVariables) { auto ident_n = storage.Create("anon", false); auto node = storage.Create(ident_n); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node)), ret)); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MatchMergeExpandLabel) { @@ -628,7 +628,7 @@ TEST_F(TestSymbolGenerator, MatchMergeExpandLabel) { auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), MERGE(PATTERN(NODE("m"), EDGE("r", EdgeAtom::Direction::OUT, {r_type}), NODE("n", label))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MatchEdgeWithIdentifierInProperty) { @@ -639,7 +639,7 @@ TEST_F(TestSymbolGenerator, MatchEdgeWithIdentifierInProperty) { std::get<0>(edge->properties_)[storage.GetPropertyIx(prop.first)] = n_prop; auto node_n = NODE("n"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_n, edge, NODE("m"))), RETURN("r"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for pattern, `n`, `r`, `m` and implicit in RETURN `r AS r` EXPECT_EQ(symbol_table.max_position(), 5); auto n = symbol_table.at(*node_n->identifier_); @@ -654,7 +654,7 @@ TEST_F(TestSymbolGenerator, MatchVariablePathUsingIdentifier) { edge->upper_bound_ = l_prop; auto node_l = NODE("l"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m")), PATTERN(node_l)), RETURN("r"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for pattern * 2, `n`, `r`, inner_node, inner_edge, `m`, `l` and // implicit in RETURN `r AS r` EXPECT_EQ(symbol_table.max_position(), 9); @@ -672,7 +672,7 @@ TEST_F(TestSymbolGenerator, MatchVariablePathUsingUnboundIdentifier) { edge->upper_bound_ = l_prop; auto node_l = NODE("l"); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), MATCH(PATTERN(node_l)), RETURN("r"))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, CreateVariablePath) { @@ -680,7 +680,7 @@ TEST_F(TestSymbolGenerator, CreateVariablePath) { // paths cannot be created. auto edge = EDGE_VARIABLE("r", EdgeAtom::Type::DEPTH_FIRST, EdgeAtom::Direction::OUT); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"), edge, NODE("m"))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MergeVariablePath) { @@ -688,7 +688,7 @@ TEST_F(TestSymbolGenerator, MergeVariablePath) { // paths cannot be created. auto edge = EDGE_VARIABLE("r", EdgeAtom::Type::DEPTH_FIRST, EdgeAtom::Direction::OUT); auto query = QUERY(SINGLE_QUERY(MERGE(PATTERN(NODE("n"), edge, NODE("m"))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, RedeclareVariablePath) { @@ -698,7 +698,7 @@ TEST_F(TestSymbolGenerator, RedeclareVariablePath) { // should be changed to check for type errors. auto edge = EDGE_VARIABLE("n", EdgeAtom::Type::DEPTH_FIRST, EdgeAtom::Direction::OUT); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), RETURN("n"))); - EXPECT_THROW(query::MakeSymbolTable(query), RedeclareVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), RedeclareVariableError); } TEST_F(TestSymbolGenerator, VariablePathSameIdentifier) { @@ -709,7 +709,7 @@ TEST_F(TestSymbolGenerator, VariablePathSameIdentifier) { auto edge = EDGE_VARIABLE("r", EdgeAtom::Type::DEPTH_FIRST, EdgeAtom::Direction::OUT); edge->lower_bound_ = PROPERTY_LOOKUP("r", prop); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), RETURN("r"))); - EXPECT_THROW(query::MakeSymbolTable(query), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), UnboundVariableError); } TEST_F(TestSymbolGenerator, MatchPropertySameIdentifier) { @@ -721,7 +721,7 @@ TEST_F(TestSymbolGenerator, MatchPropertySameIdentifier) { auto n_prop = PROPERTY_LOOKUP("n", prop.second); std::get<0>(node_n->properties_)[storage.GetPropertyIx(prop.first)] = n_prop; auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_n)), RETURN("n"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto n = symbol_table.at(*node_n->identifier_); EXPECT_EQ(n, symbol_table.at(*dynamic_cast(n_prop->expression_))); } @@ -735,7 +735,7 @@ TEST_F(TestSymbolGenerator, WithReturnAll) { auto *ret_as_x = AS("x"); auto *ret_x = IDENT("x"); auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(42), with_as_x), RETURN(all, ret_as_x, ret_x, AS("y")))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for `WITH .. AS x`, `ALL(x ...)`, `ALL(...) AS x` and `AS y`. EXPECT_EQ(symbol_table.max_position(), 4); // Check `WITH .. AS x` is the same as `[x]` and `RETURN ... x AS y` @@ -757,7 +757,7 @@ TEST_F(TestSymbolGenerator, WithReturnSingle) { auto *ret_as_x = AS("x"); auto *ret_x = IDENT("x"); auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(42), with_as_x), RETURN(single, ret_as_x, ret_x, AS("y")))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for `WITH .. AS x`, `SINGLE(x ...)`, `SINGLE(...) AS x` and `AS y`. EXPECT_EQ(symbol_table.max_position(), 4); // Check `WITH .. AS x` is the same as `[x]` and `RETURN ... x AS y` @@ -781,7 +781,7 @@ TEST_F(TestSymbolGenerator, WithReturnReduce) { auto *ret_x = IDENT("x"); auto *ret_as_y = AS("y"); auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(42), with_as_x), RETURN(reduce, ret_as_x, ret_x, ret_as_y))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for `WITH .. AS x`, `REDUCE(y, x ...)`, `REDUCE(...) AS x` and `AS // y`. EXPECT_EQ(symbol_table.max_position(), 5); @@ -808,7 +808,7 @@ TEST_F(TestSymbolGenerator, WithReturnExtract) { auto *ret_as_y = AS("y"); auto query = QUERY(SINGLE_QUERY(WITH(LIST(LITERAL(1), LITERAL(2), LITERAL(3)), with_as_x), RETURN(extract, ret_as_x, ret_x, ret_as_y))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for `WITH .. AS x`, `EXTRACT(x ...)`, `EXTRACT(...) AS x` and // `AS y`. EXPECT_EQ(symbol_table.max_position(), 4); @@ -836,7 +836,7 @@ TEST_F(TestSymbolGenerator, MatchBfsReturn) { bfs->upper_bound_ = n_prop; auto *ret_r = IDENT("r"); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_n, bfs, NODE("m"))), RETURN(ret_r, AS("r")))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for pattern, `n`, `[r]`, `r|`, `n|`, `m` and `AS r`. EXPECT_EQ(symbol_table.max_position(), 7); EXPECT_EQ(symbol_table.at(*ret_r), symbol_table.at(*bfs->identifier_)); @@ -857,7 +857,7 @@ TEST_F(TestSymbolGenerator, MatchBfsUsesEdgeSymbolError) { bfs->filter_lambda_.expression = IDENT("r"); bfs->upper_bound_ = LITERAL(10); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), bfs, NODE("m"))), RETURN("r"))); - EXPECT_THROW(query::MakeSymbolTable(query), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), UnboundVariableError); } TEST_F(TestSymbolGenerator, MatchBfsUsesPreviousOuterSymbol) { @@ -869,7 +869,7 @@ TEST_F(TestSymbolGenerator, MatchBfsUsesPreviousOuterSymbol) { bfs->filter_lambda_.expression = IDENT("a"); bfs->upper_bound_ = LITERAL(10); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_a, bfs, NODE("m"))), RETURN("r"))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); EXPECT_EQ(symbol_table.at(*node_a->identifier_), symbol_table.at(*dynamic_cast(bfs->filter_lambda_.expression))); } @@ -882,7 +882,7 @@ TEST_F(TestSymbolGenerator, MatchBfsUsesLaterSymbolError) { bfs->filter_lambda_.expression = IDENT("m"); bfs->upper_bound_ = LITERAL(10); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), bfs, NODE("m"))), RETURN("r"))); - EXPECT_THROW(query::MakeSymbolTable(query), UnboundVariableError); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), UnboundVariableError); } TEST_F(TestSymbolGenerator, MatchVariableLambdaSymbols) { @@ -895,7 +895,7 @@ TEST_F(TestSymbolGenerator, MatchVariableLambdaSymbols) { edge->filter_lambda_.inner_node = storage.Create("anon_inner_n", false); auto end_node = storage.Create(storage.Create("anon_end", false)); auto query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node, edge, end_node)), RETURN(LITERAL(42), AS("res")))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for `anon_n`, `anon_r`, `anon_inner_e`, `anon_inner_n`, `anon_end` // `AS res` and the auto-generated path name symbol. EXPECT_EQ(symbol_table.max_position(), 7); @@ -932,7 +932,7 @@ TEST_F(TestSymbolGenerator, MatchWShortestReturn) { } auto *ret_r = IDENT("r"); auto *query = QUERY(SINGLE_QUERY(MATCH(PATTERN(node_n, shortest, NODE("m"))), RETURN(ret_r, AS("r")))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); // Symbols for pattern, `n`, `[r]`, `total_weight`, (`r|`, `n|`)x2, `m` and // `AS r`. EXPECT_EQ(symbol_table.max_position(), 10); @@ -954,7 +954,7 @@ TEST_F(TestSymbolGenerator, MatchWShortestReturn) { TEST_F(TestSymbolGenerator, MatchUnionSymbols) { // RETURN 5 as X UNION RETURN 6 AS x auto query = QUERY(SINGLE_QUERY(RETURN(LITERAL(5), AS("X"))), UNION(SINGLE_QUERY(RETURN(LITERAL(6), AS("X"))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); EXPECT_EQ(symbol_table.max_position(), 3); } @@ -962,14 +962,14 @@ TEST_F(TestSymbolGenerator, MatchUnionMultipleSymbols) { // RETURN 5 as X, 6 AS Y UNION RETURN 5 AS Y, 6 AS x auto query = QUERY(SINGLE_QUERY(RETURN(LITERAL(5), AS("X"), LITERAL(6), AS("Y"))), UNION(SINGLE_QUERY(RETURN(LITERAL(5), AS("Y"), LITERAL(6), AS("X"))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); EXPECT_EQ(symbol_table.max_position(), 6); } TEST_F(TestSymbolGenerator, MatchUnionAllSymbols) { // RETURN 5 as X UNION ALL RETURN 6 AS x auto query = QUERY(SINGLE_QUERY(RETURN(LITERAL(5), AS("X"))), UNION_ALL(SINGLE_QUERY(RETURN(LITERAL(6), AS("X"))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); EXPECT_EQ(symbol_table.max_position(), 3); } @@ -977,7 +977,7 @@ TEST_F(TestSymbolGenerator, MatchUnionAllMultipleSymbols) { // RETURN 5 as X, 6 AS Y UNION ALL RETURN 5 AS Y, 6 AS x auto query = QUERY(SINGLE_QUERY(RETURN(LITERAL(5), AS("X"), LITERAL(6), AS("Y"))), UNION_ALL(SINGLE_QUERY(RETURN(LITERAL(5), AS("Y"), LITERAL(6), AS("X"))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); EXPECT_EQ(symbol_table.max_position(), 6); } @@ -987,7 +987,7 @@ TEST_F(TestSymbolGenerator, MatchUnionReturnAllSymbols) { ret->body_.all_identifiers = true; auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(1), AS("X"), LITERAL(2), AS("Y")), ret), UNION(SINGLE_QUERY(RETURN(LITERAL(3), AS("X"), LITERAL(4), AS("Y"))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); EXPECT_EQ(symbol_table.max_position(), 6); } @@ -995,7 +995,7 @@ TEST_F(TestSymbolGenerator, MatchUnionReturnSymbols) { // WITH 1 as X, 2 AS Y RETURN Y, X UNION RETURN 3 AS X, 4 AS Y auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(1), AS("X"), LITERAL(2), AS("Y")), RETURN("Y", "X")), UNION(SINGLE_QUERY(RETURN(LITERAL(3), AS("X"), LITERAL(4), AS("Y"))))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); EXPECT_EQ(symbol_table.max_position(), 8); } @@ -1005,7 +1005,7 @@ TEST_F(TestSymbolGenerator, MatchUnionParameterNameThrowSemanticExpcetion) { ret->body_.all_identifiers = true; auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(1), AS("X"), LITERAL(2), AS("Y")), ret), UNION(SINGLE_QUERY(RETURN(LITERAL(3), AS("Z"), LITERAL(4), AS("Y"))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MatchUnionParameterNumberThrowSemanticExpcetion) { @@ -1014,7 +1014,7 @@ TEST_F(TestSymbolGenerator, MatchUnionParameterNumberThrowSemanticExpcetion) { ret->body_.all_identifiers = true; auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(1), AS("X"), LITERAL(2), AS("Y")), ret), UNION(SINGLE_QUERY(RETURN(LITERAL(4), AS("Y"))))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, MatchUnion) { @@ -1023,7 +1023,7 @@ TEST_F(TestSymbolGenerator, MatchUnion) { ret->body_.all_identifiers = true; auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(5), AS("X"), LITERAL(3), AS("Y")), ret), UNION(SINGLE_QUERY(WITH(LITERAL(9), AS("Y"), LITERAL(4), AS("X")), RETURN("Y", "X")))); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); EXPECT_EQ(symbol_table.max_position(), 8); } @@ -1038,7 +1038,7 @@ TEST_F(TestSymbolGenerator, CallProcedureYield) { auto *as_x = AS("x"); auto *ret = RETURN("x", "y"); auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(1), as_x), call, ret)); - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); EXPECT_EQ(symbol_table.max_position(), 4); const auto &sym_x = symbol_table.at(*as_x); const auto &sym_y = symbol_table.at(*call->result_identifiers_.back()); @@ -1060,7 +1060,7 @@ TEST_F(TestSymbolGenerator, CallProcedureShadowingYield) { call->result_fields_.emplace_back("x"); call->result_identifiers_.push_back(IDENT("x")); auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(1), AS("x")), call, RETURN(LITERAL(42), AS("res")))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, CallProcedureShadowingYieldAlias) { @@ -1070,7 +1070,7 @@ TEST_F(TestSymbolGenerator, CallProcedureShadowingYieldAlias) { call->result_fields_.emplace_back("y"); call->result_identifiers_.push_back(IDENT("x")); auto query = QUERY(SINGLE_QUERY(WITH(LITERAL(1), AS("x")), call, RETURN(LITERAL(42), AS("res")))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, CallProcedureUnboundArgument) { @@ -1079,7 +1079,7 @@ TEST_F(TestSymbolGenerator, CallProcedureUnboundArgument) { call->procedure_name_ = "proc"; call->arguments_.push_back(IDENT("unbound")); auto query = QUERY(SINGLE_QUERY(call)); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST_F(TestSymbolGenerator, CallWithoutFieldsReturnAsterisk) { @@ -1089,7 +1089,7 @@ TEST_F(TestSymbolGenerator, CallWithoutFieldsReturnAsterisk) { auto ret = storage.Create(); ret->body_.all_identifiers = true; auto query = QUERY(SINGLE_QUERY(call, ret)); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); } TEST(TestSymbolTable, CreateAnonymousSymbols) { @@ -1112,40 +1112,40 @@ TEST_F(TestSymbolGenerator, PredefinedIdentifiers) { auto *second_op = IDENT("second_op", false); // RETURN first_op + second_op AS result auto query = QUERY(SINGLE_QUERY(RETURN(ADD(first_op, second_op), AS("result")))); - EXPECT_THROW(query::MakeSymbolTable(query), SemanticException); - EXPECT_THROW(query::MakeSymbolTable(query, {first_op}), SemanticException); - EXPECT_THROW(query::MakeSymbolTable(query, {second_op}), SemanticException); - auto symbol_table = query::MakeSymbolTable(query, {first_op, second_op}); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query, {first_op}), SemanticException); + EXPECT_THROW(memgraph::query::MakeSymbolTable(query, {second_op}), SemanticException); + auto symbol_table = memgraph::query::MakeSymbolTable(query, {first_op, second_op}); ASSERT_EQ(symbol_table.max_position(), 3); // predefined identifier can only be used in one scope // RETURN first_op + second_op AS result UNION RETURN second_op + first_op AS result query = QUERY(SINGLE_QUERY(RETURN(ADD(first_op, second_op), AS("result"))), UNION(SINGLE_QUERY(RETURN(ADD(second_op, first_op), AS("result"))))); - ASSERT_THROW(query::MakeSymbolTable(query, {first_op, second_op}), SemanticException); + ASSERT_THROW(memgraph::query::MakeSymbolTable(query, {first_op, second_op}), SemanticException); // predefined identifier can be introduced in any of the scope // different predefined identifiers can be introduced in different scopes // RETURN first_op AS result UNION RETURN second_op AS result query = QUERY(SINGLE_QUERY(RETURN(first_op, AS("result"))), UNION(SINGLE_QUERY(RETURN(second_op, AS("result"))))); - ASSERT_THROW(query::MakeSymbolTable(query), SemanticException); - symbol_table = query::MakeSymbolTable(query, {first_op, second_op}); + ASSERT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); + symbol_table = memgraph::query::MakeSymbolTable(query, {first_op, second_op}); ASSERT_EQ(symbol_table.max_position(), 5); // WITH statement resets the scope, but the predefined identifier is okay // because it's the first introduction of it in the query // WITH 1 as one RETURN first_op AS first query = QUERY(SINGLE_QUERY(WITH(LITERAL(1), AS("one")), RETURN(first_op, AS("first")))); - ASSERT_THROW(query::MakeSymbolTable(query), SemanticException); - symbol_table = query::MakeSymbolTable(query, {first_op}); + ASSERT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); + symbol_table = memgraph::query::MakeSymbolTable(query, {first_op}); ASSERT_EQ(symbol_table.max_position(), 3); // In the first scope, first_op represents identifier created by match, // in the second it represent the predefined identifier // MATCH(first_op) WITH first_op as n RETURN first_op, n query = QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("first_op"))), WITH("first_op", AS("n")), RETURN("first_op", "n"))); - ASSERT_THROW(query::MakeSymbolTable(query), SemanticException); - symbol_table = query::MakeSymbolTable(query, {first_op}); + ASSERT_THROW(memgraph::query::MakeSymbolTable(query), SemanticException); + symbol_table = memgraph::query::MakeSymbolTable(query, {first_op}); ASSERT_EQ(symbol_table.max_position(), 6); // You cannot redaclare the predefined identifier in the same scope @@ -1155,5 +1155,5 @@ TEST_F(TestSymbolGenerator, PredefinedIdentifiers) { std::get<0>(node->properties_)[storage.GetPropertyIx("prop")] = dynamic_cast(unwind->named_expression_->expression_); query = QUERY(SINGLE_QUERY(unwind, CREATE(PATTERN(node)))); - ASSERT_THROW(query::MakeSymbolTable(query, {first_op}), SemanticException); + ASSERT_THROW(memgraph::query::MakeSymbolTable(query, {first_op}), SemanticException); } diff --git a/tests/unit/query_serialization_property_value.cpp b/tests/unit/query_serialization_property_value.cpp index 46d6f5a63..49fc0ee2b 100644 --- a/tests/unit/query_serialization_property_value.cpp +++ b/tests/unit/query_serialization_property_value.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,70 +16,71 @@ #include "utils/logging.hpp" namespace { -void ExpectPropEq(const storage::PropertyValue &a, const storage::PropertyValue &b) { +void ExpectPropEq(const memgraph::storage::PropertyValue &a, const memgraph::storage::PropertyValue &b) { ASSERT_EQ(a.type(), b.type()); ASSERT_EQ(a, b); } -void CheckJsonConversion(const storage::PropertyValue &property_value) { - const auto json_string = query::serialization::SerializePropertyValue(property_value).dump(); +void CheckJsonConversion(const memgraph::storage::PropertyValue &property_value) { + const auto json_string = memgraph::query::serialization::SerializePropertyValue(property_value).dump(); const auto json_object = nlohmann::json::parse(json_string); - ExpectPropEq(property_value, query::serialization::DeserializePropertyValue(json_object)); + ExpectPropEq(property_value, memgraph::query::serialization::DeserializePropertyValue(json_object)); } } // namespace -TEST(PropertyValueSerializationTest, Null) { CheckJsonConversion(storage::PropertyValue{}); } +TEST(PropertyValueSerializationTest, Null) { CheckJsonConversion(memgraph::storage::PropertyValue{}); } TEST(PropertyValueSerializationTest, Bool) { - CheckJsonConversion(storage::PropertyValue{true}); - CheckJsonConversion(storage::PropertyValue{false}); + CheckJsonConversion(memgraph::storage::PropertyValue{true}); + CheckJsonConversion(memgraph::storage::PropertyValue{false}); } TEST(PropertyValueSerializationTest, Int) { - CheckJsonConversion(storage::PropertyValue{1}); - CheckJsonConversion(storage::PropertyValue{100}); + CheckJsonConversion(memgraph::storage::PropertyValue{1}); + CheckJsonConversion(memgraph::storage::PropertyValue{100}); } TEST(PropertyValueSerializationTest, Double) { - CheckJsonConversion(storage::PropertyValue{1.0}); - CheckJsonConversion(storage::PropertyValue{2.321}); + CheckJsonConversion(memgraph::storage::PropertyValue{1.0}); + CheckJsonConversion(memgraph::storage::PropertyValue{2.321}); } TEST(PropertyValueSerializationTest, String) { - CheckJsonConversion(storage::PropertyValue{"TestString"}); - CheckJsonConversion(storage::PropertyValue{""}); + CheckJsonConversion(memgraph::storage::PropertyValue{"TestString"}); + CheckJsonConversion(memgraph::storage::PropertyValue{""}); } TEST(PropertyValueSerializationTest, TemporalData) { const auto test_temporal_data_conversion = [](const auto type, const auto microseconds) { - CheckJsonConversion(storage::PropertyValue{storage::TemporalData{type, microseconds}}); + CheckJsonConversion(memgraph::storage::PropertyValue{memgraph::storage::TemporalData{type, microseconds}}); }; - test_temporal_data_conversion(storage::TemporalType::Date, 20); - test_temporal_data_conversion(storage::TemporalType::LocalDateTime, -20); - test_temporal_data_conversion(storage::TemporalType::Duration, 10000); + test_temporal_data_conversion(memgraph::storage::TemporalType::Date, 20); + test_temporal_data_conversion(memgraph::storage::TemporalType::LocalDateTime, -20); + test_temporal_data_conversion(memgraph::storage::TemporalType::Duration, 10000); } namespace { -std::vector GetPropertyValueListWithBasicTypes() { - return {storage::PropertyValue{}, storage::PropertyValue{true}, storage::PropertyValue{"string"}, - storage::PropertyValue{1}, storage::PropertyValue{1.0}}; +std::vector GetPropertyValueListWithBasicTypes() { + return {memgraph::storage::PropertyValue{}, memgraph::storage::PropertyValue{true}, + memgraph::storage::PropertyValue{"string"}, memgraph::storage::PropertyValue{1}, + memgraph::storage::PropertyValue{1.0}}; } -std::map GetPropertyValueMapWithBasicTypes() { - return {{"null", storage::PropertyValue{}}, - {"bool", storage::PropertyValue{true}}, - {"int", storage::PropertyValue{1}}, - {"double", storage::PropertyValue{1.0}}, - {"string", storage::PropertyValue{"string"}}}; +std::map GetPropertyValueMapWithBasicTypes() { + return {{"null", memgraph::storage::PropertyValue{}}, + {"bool", memgraph::storage::PropertyValue{true}}, + {"int", memgraph::storage::PropertyValue{1}}, + {"double", memgraph::storage::PropertyValue{1.0}}, + {"string", memgraph::storage::PropertyValue{"string"}}}; } } // namespace TEST(PropertyValueSerializationTest, List) { - storage::PropertyValue list = storage::PropertyValue{GetPropertyValueListWithBasicTypes()}; + memgraph::storage::PropertyValue list = memgraph::storage::PropertyValue{GetPropertyValueListWithBasicTypes()}; { SCOPED_TRACE("Basic list"); @@ -88,7 +89,7 @@ TEST(PropertyValueSerializationTest, List) { { SCOPED_TRACE("Nested list"); - CheckJsonConversion(storage::PropertyValue{std::vector{list, list}}); + CheckJsonConversion(memgraph::storage::PropertyValue{std::vector{list, list}}); } { @@ -102,18 +103,18 @@ TEST(PropertyValueSerializationTest, Map) { auto map = GetPropertyValueMapWithBasicTypes(); { SCOPED_TRACE("Basic map"); - CheckJsonConversion(storage::PropertyValue{map}); + CheckJsonConversion(memgraph::storage::PropertyValue{map}); } { SCOPED_TRACE("Nested map"); - map.emplace("map", storage::PropertyValue{map}); - CheckJsonConversion(storage::PropertyValue{map}); + map.emplace("map", memgraph::storage::PropertyValue{map}); + CheckJsonConversion(memgraph::storage::PropertyValue{map}); } { SCOPED_TRACE("Map with list"); - map.emplace("list", storage::PropertyValue{GetPropertyValueListWithBasicTypes()}); - CheckJsonConversion(storage::PropertyValue{map}); + map.emplace("list", memgraph::storage::PropertyValue{GetPropertyValueListWithBasicTypes()}); + CheckJsonConversion(memgraph::storage::PropertyValue{map}); } } diff --git a/tests/unit/query_streams.cpp b/tests/unit/query_streams.cpp index 1f26fdcc2..1b21c2e7a 100644 --- a/tests/unit/query_streams.cpp +++ b/tests/unit/query_streams.cpp @@ -25,9 +25,9 @@ #include "storage/v2/storage.hpp" #include "test_utils.hpp" -using Streams = query::stream::Streams; -using StreamInfo = query::stream::KafkaStream::StreamInfo; -using StreamStatus = query::stream::StreamStatus; +using Streams = memgraph::query::stream::Streams; +using StreamInfo = memgraph::query::stream::KafkaStream::StreamInfo; +using StreamStatus = memgraph::query::stream::StreamStatus; namespace { const static std::string kTopicName{"TrialTopic"}; @@ -54,7 +54,7 @@ class StreamsTest : public ::testing::Test { StreamsTest() { ResetStreamsObject(); } protected: - storage::Storage db_; + memgraph::storage::Storage db_; std::filesystem::path data_directory_{GetCleanDataDirectory()}; KafkaClusterMock mock_cluster_{std::vector{kTopicName}}; // Though there is a Streams object in interpreter context, it makes more sense to use a separate object to test, @@ -62,7 +62,7 @@ class StreamsTest : public ::testing::Test { // Streams constructor. // InterpreterContext::auth_checker_ is used in the Streams object, but only in the message processing part. Because // these tests don't send any messages, the auth_checker_ pointer can be left as nullptr. - query::InterpreterContext interpreter_context_{&db_, query::InterpreterConfig{}, data_directory_}; + memgraph::query::InterpreterContext interpreter_context_{&db_, memgraph::query::InterpreterConfig{}, data_directory_}; std::filesystem::path streams_data_directory_{data_directory_ / "separate-dir-for-test"}; std::optional streams_; @@ -84,7 +84,8 @@ class StreamsTest : public ::testing::Test { void CheckConfigAndCredentials(const StreamCheckData &check_data) { const auto locked_streams = streams_->streams_.ReadLock(); const auto &stream = locked_streams->at(check_data.name); - const auto *stream_data = std::get_if>(&stream); + const auto *stream_data = + std::get_if>(&stream); ASSERT_NE(stream_data, nullptr); const auto stream_info = stream_data->stream_source->ReadLock()->Info(check_data.info.common_info.transformation_name); @@ -104,8 +105,8 @@ class StreamsTest : public ::testing::Test { StreamInfo CreateDefaultStreamInfo() { return StreamInfo{.common_info{ - .batch_interval = query::stream::kDefaultBatchInterval, - .batch_size = query::stream::kDefaultBatchSize, + .batch_interval = memgraph::query::stream::kDefaultBatchInterval, + .batch_size = memgraph::query::stream::kDefaultBatchSize, .transformation_name = "not used in the tests", }, .topics = {kTopicName}, @@ -125,7 +126,7 @@ class StreamsTest : public ::testing::Test { TEST_F(StreamsTest, SimpleStreamManagement) { auto check_data = CreateDefaultStreamCheckData(); - streams_->Create(check_data.name, check_data.info, check_data.owner); + streams_->Create(check_data.name, check_data.info, check_data.owner); EXPECT_NO_FATAL_FAILURE(CheckStreamStatus(check_data)); EXPECT_NO_THROW(streams_->Start(check_data.name)); @@ -151,12 +152,12 @@ TEST_F(StreamsTest, SimpleStreamManagement) { TEST_F(StreamsTest, CreateAlreadyExisting) { auto stream_info = CreateDefaultStreamInfo(); auto stream_name = GetDefaultStreamName(); - streams_->Create(stream_name, stream_info, std::nullopt); + streams_->Create(stream_name, stream_info, std::nullopt); try { - streams_->Create(stream_name, stream_info, std::nullopt); + streams_->Create(stream_name, stream_info, std::nullopt); FAIL() << "Creating already existing stream should throw\n"; - } catch (query::stream::StreamsException &exception) { + } catch (memgraph::query::stream::StreamsException &exception) { EXPECT_EQ(exception.what(), fmt::format("Stream already exists with name '{}'", stream_name)); } } @@ -165,12 +166,12 @@ TEST_F(StreamsTest, DropNotExistingStream) { const auto stream_info = CreateDefaultStreamInfo(); const auto stream_name = GetDefaultStreamName(); const std::string not_existing_stream_name{"ThisDoesn'tExists"}; - streams_->Create(stream_name, stream_info, std::nullopt); + streams_->Create(stream_name, stream_info, std::nullopt); try { streams_->Drop(not_existing_stream_name); FAIL() << "Dropping not existing stream should throw\n"; - } catch (query::stream::StreamsException &exception) { + } catch (memgraph::query::stream::StreamsException &exception) { EXPECT_EQ(exception.what(), fmt::format("Couldn't find stream '{}'", not_existing_stream_name)); } } @@ -232,7 +233,7 @@ TEST_F(StreamsTest, RestoreStreams) { EXPECT_TRUE(streams_->GetStreamInfo().empty()); for (auto &check_data : stream_check_datas) { - streams_->Create(check_data.name, check_data.info, check_data.owner); + streams_->Create(check_data.name, check_data.info, check_data.owner); } { SCOPED_TRACE("After streams are created"); @@ -268,12 +269,13 @@ TEST_F(StreamsTest, RestoreStreams) { TEST_F(StreamsTest, CheckWithTimeout) { const auto stream_info = CreateDefaultStreamInfo(); const auto stream_name = GetDefaultStreamName(); - streams_->Create(stream_name, stream_info, std::nullopt); + streams_->Create(stream_name, stream_info, std::nullopt); std::chrono::milliseconds timeout{3000}; const auto start = std::chrono::steady_clock::now(); - EXPECT_THROW(streams_->Check(stream_name, timeout, std::nullopt), integrations::kafka::ConsumerCheckFailedException); + EXPECT_THROW(streams_->Check(stream_name, timeout, std::nullopt), + memgraph::integrations::kafka::ConsumerCheckFailedException); const auto end = std::chrono::steady_clock::now(); const auto elapsed = (end - start); @@ -291,8 +293,8 @@ TEST_F(StreamsTest, CheckInvalidConfig) { EXPECT_TRUE(message.find(kInvalidConfigName) != std::string::npos) << message; EXPECT_TRUE(message.find(kConfigValue) != std::string::npos) << message; }; - EXPECT_THROW_WITH_MSG(streams_->Create(stream_name, stream_info, std::nullopt), - integrations::kafka::SettingCustomConfigFailed, checker); + EXPECT_THROW_WITH_MSG(streams_->Create(stream_name, stream_info, std::nullopt), + memgraph::integrations::kafka::SettingCustomConfigFailed, checker); } TEST_F(StreamsTest, CheckInvalidCredentials) { @@ -303,9 +305,9 @@ TEST_F(StreamsTest, CheckInvalidCredentials) { stream_info.credentials.emplace(kInvalidCredentialName, kCredentialValue); const auto checker = [](const std::string_view message) { EXPECT_TRUE(message.find(kInvalidCredentialName) != std::string::npos) << message; - EXPECT_TRUE(message.find(integrations::kReducted) != std::string::npos) << message; + EXPECT_TRUE(message.find(memgraph::integrations::kReducted) != std::string::npos) << message; EXPECT_TRUE(message.find(kCredentialValue) == std::string::npos) << message; }; - EXPECT_THROW_WITH_MSG(streams_->Create(stream_name, stream_info, std::nullopt), - integrations::kafka::SettingCustomConfigFailed, checker); + EXPECT_THROW_WITH_MSG(streams_->Create(stream_name, stream_info, std::nullopt), + memgraph::integrations::kafka::SettingCustomConfigFailed, checker); } diff --git a/tests/unit/query_trigger.cpp b/tests/unit/query_trigger.cpp index 547cae69c..57bc4f3bc 100644 --- a/tests/unit/query_trigger.cpp +++ b/tests/unit/query_trigger.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -25,17 +25,18 @@ #include "utils/memory.hpp" namespace { -const std::unordered_set kAllEventTypes{ - query::TriggerEventType::ANY, query::TriggerEventType::VERTEX_CREATE, query::TriggerEventType::EDGE_CREATE, - query::TriggerEventType::CREATE, query::TriggerEventType::VERTEX_DELETE, query::TriggerEventType::EDGE_DELETE, - query::TriggerEventType::DELETE, query::TriggerEventType::VERTEX_UPDATE, query::TriggerEventType::EDGE_UPDATE, - query::TriggerEventType::UPDATE, +const std::unordered_set kAllEventTypes{ + memgraph::query::TriggerEventType::ANY, memgraph::query::TriggerEventType::VERTEX_CREATE, + memgraph::query::TriggerEventType::EDGE_CREATE, memgraph::query::TriggerEventType::CREATE, + memgraph::query::TriggerEventType::VERTEX_DELETE, memgraph::query::TriggerEventType::EDGE_DELETE, + memgraph::query::TriggerEventType::DELETE, memgraph::query::TriggerEventType::VERTEX_UPDATE, + memgraph::query::TriggerEventType::EDGE_UPDATE, memgraph::query::TriggerEventType::UPDATE, }; -class MockAuthChecker : public query::AuthChecker { +class MockAuthChecker : public memgraph::query::AuthChecker { public: MOCK_CONST_METHOD2(IsUserAuthorized, bool(const std::optional &username, - const std::vector &privileges)); + const std::vector &privileges)); }; } // namespace @@ -48,26 +49,28 @@ class TriggerContextTest : public ::testing::Test { db.reset(); } - storage::Storage::Accessor &StartTransaction() { + memgraph::storage::Storage::Accessor &StartTransaction() { accessors.push_back(db->Access()); return accessors.back(); } protected: - std::optional db; - std::list accessors; + std::optional db; + std::list accessors; }; namespace { -void CheckTypedValueSize(const query::TriggerContext &trigger_context, const query::TriggerIdentifierTag tag, - const size_t expected_size, query::DbAccessor &dba) { +void CheckTypedValueSize(const memgraph::query::TriggerContext &trigger_context, + const memgraph::query::TriggerIdentifierTag tag, const size_t expected_size, + memgraph::query::DbAccessor &dba) { auto typed_values = trigger_context.GetTypedValue(tag, &dba); ASSERT_TRUE(typed_values.IsList()); ASSERT_EQ(expected_size, typed_values.ValueList().size()); }; -void CheckLabelList(const query::TriggerContext &trigger_context, const query::TriggerIdentifierTag tag, - const size_t expected, query::DbAccessor &dba) { +void CheckLabelList(const memgraph::query::TriggerContext &trigger_context, + const memgraph::query::TriggerIdentifierTag tag, const size_t expected, + memgraph::query::DbAccessor &dba) { auto typed_values = trigger_context.GetTypedValue(tag, &dba); ASSERT_TRUE(typed_values.IsList()); const auto &label_maps = typed_values.ValueList(); @@ -92,13 +95,13 @@ void CheckLabelList(const query::TriggerContext &trigger_context, const query::T // Returned TypedValue should always contain only objects // that exist (unless its explicitly created for the deleted object) TEST_F(TriggerContextTest, ValidObjectsTest) { - query::TriggerContext trigger_context; - query::TriggerContextCollector trigger_context_collector{kAllEventTypes}; + memgraph::query::TriggerContext trigger_context; + memgraph::query::TriggerContextCollector trigger_context_collector{kAllEventTypes}; size_t vertex_count = 0; size_t edge_count = 0; { - query::DbAccessor dba{&StartTransaction()}; + memgraph::query::DbAccessor dba{&StartTransaction()}; auto create_vertex = [&] { auto created_vertex = dba.InsertVertex(); @@ -108,7 +111,7 @@ TEST_F(TriggerContextTest, ValidObjectsTest) { }; // Create vertices and add them to the trigger context as created - std::vector vertices; + std::vector vertices; for (size_t i = 0; i < 4; ++i) { vertices.push_back(create_vertex()); } @@ -127,12 +130,13 @@ TEST_F(TriggerContextTest, ValidObjectsTest) { dba.AdvanceCommand(); trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - trigger_context_collector = query::TriggerContextCollector{kAllEventTypes}; + trigger_context_collector = memgraph::query::TriggerContextCollector{kAllEventTypes}; // Should have all the created objects - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_VERTICES, vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_EDGES, edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_OBJECTS, vertex_count + edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_VERTICES, vertex_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_EDGES, edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_OBJECTS, + vertex_count + edge_count, dba); // we delete one of the vertices and edges in the same transaction ASSERT_TRUE(dba.DetachRemoveVertex(&vertices[0]).HasValue()); @@ -142,54 +146,58 @@ TEST_F(TriggerContextTest, ValidObjectsTest) { dba.AdvanceCommand(); // Should have one less created object for vertex and edge - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_VERTICES, vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_EDGES, edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_OBJECTS, vertex_count + edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_VERTICES, vertex_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_EDGES, edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_OBJECTS, + vertex_count + edge_count, dba); ASSERT_FALSE(dba.Commit().HasError()); } { - query::DbAccessor dba{&StartTransaction()}; + memgraph::query::DbAccessor dba{&StartTransaction()}; trigger_context.AdaptForAccessor(&dba); // Should have one less created object for vertex and edge - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_VERTICES, vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_EDGES, edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_OBJECTS, vertex_count + edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_VERTICES, vertex_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_EDGES, edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_OBJECTS, + vertex_count + edge_count, dba); } size_t deleted_vertex_count = 0; size_t deleted_edge_count = 0; { - query::DbAccessor dba{&StartTransaction()}; + memgraph::query::DbAccessor dba{&StartTransaction()}; // register each type of change for each object { - auto vertices = dba.Vertices(storage::View::OLD); + auto vertices = dba.Vertices(memgraph::storage::View::OLD); for (auto vertex : vertices) { trigger_context_collector.RegisterSetObjectProperty(vertex, dba.NameToProperty("PROPERTY1"), - query::TypedValue("Value"), query::TypedValue("ValueNew")); + memgraph::query::TypedValue("Value"), + memgraph::query::TypedValue("ValueNew")); trigger_context_collector.RegisterRemovedObjectProperty(vertex, dba.NameToProperty("PROPERTY2"), - query::TypedValue("Value")); + memgraph::query::TypedValue("Value")); trigger_context_collector.RegisterSetVertexLabel(vertex, dba.NameToLabel("LABEL1")); trigger_context_collector.RegisterRemovedVertexLabel(vertex, dba.NameToLabel("LABEL2")); - auto out_edges = vertex.OutEdges(storage::View::OLD); + auto out_edges = vertex.OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(out_edges.HasValue()); for (auto edge : *out_edges) { - trigger_context_collector.RegisterSetObjectProperty( - edge, dba.NameToProperty("PROPERTY1"), query::TypedValue("Value"), query::TypedValue("ValueNew")); + trigger_context_collector.RegisterSetObjectProperty(edge, dba.NameToProperty("PROPERTY1"), + memgraph::query::TypedValue("Value"), + memgraph::query::TypedValue("ValueNew")); trigger_context_collector.RegisterRemovedObjectProperty(edge, dba.NameToProperty("PROPERTY2"), - query::TypedValue("Value")); + memgraph::query::TypedValue("Value")); } } } // Delete the first vertex with its edge and register the deleted object { - auto vertices = dba.Vertices(storage::View::OLD); + auto vertices = dba.Vertices(memgraph::storage::View::OLD); for (auto vertex : vertices) { const auto maybe_values = dba.DetachRemoveVertex(&vertex); ASSERT_TRUE(maybe_values.HasValue()); @@ -213,25 +221,30 @@ TEST_F(TriggerContextTest, ValidObjectsTest) { ASSERT_FALSE(dba.Commit().HasError()); trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - trigger_context_collector = query::TriggerContextCollector{kAllEventTypes}; + trigger_context_collector = memgraph::query::TriggerContextCollector{kAllEventTypes}; - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::SET_VERTEX_PROPERTIES, vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::SET_EDGE_PROPERTIES, edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::SET_VERTEX_PROPERTIES, vertex_count, + dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::SET_EDGE_PROPERTIES, edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::REMOVED_VERTEX_PROPERTIES, vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::REMOVED_EDGE_PROPERTIES, edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_VERTEX_PROPERTIES, vertex_count, + dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_EDGE_PROPERTIES, edge_count, + dba); - CheckLabelList(trigger_context, query::TriggerIdentifierTag::SET_VERTEX_LABELS, vertex_count, dba); - CheckLabelList(trigger_context, query::TriggerIdentifierTag::REMOVED_VERTEX_LABELS, vertex_count, dba); + CheckLabelList(trigger_context, memgraph::query::TriggerIdentifierTag::SET_VERTEX_LABELS, vertex_count, dba); + CheckLabelList(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_VERTEX_LABELS, vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_VERTICES, 4 * vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_EDGES, 2 * edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_OBJECTS, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, 4 * vertex_count, + dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_EDGES, 2 * edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_OBJECTS, 4 * vertex_count + 2 * edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::DELETED_VERTICES, deleted_vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::DELETED_EDGES, deleted_edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::DELETED_OBJECTS, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::DELETED_VERTICES, deleted_vertex_count, + dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::DELETED_EDGES, deleted_edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::DELETED_OBJECTS, deleted_vertex_count + deleted_edge_count, dba); } @@ -239,10 +252,10 @@ TEST_F(TriggerContextTest, ValidObjectsTest) { // for each update event. // TypedValue of the deleted objects stay the same as they're bound to the transaction which deleted them. { - query::DbAccessor dba{&StartTransaction()}; + memgraph::query::DbAccessor dba{&StartTransaction()}; trigger_context.AdaptForAccessor(&dba); - auto vertices = dba.Vertices(storage::View::OLD); + auto vertices = dba.Vertices(memgraph::storage::View::OLD); for (auto vertex : vertices) { ASSERT_TRUE(dba.DetachRemoveVertex(&vertex).HasValue()); break; @@ -254,26 +267,31 @@ TEST_F(TriggerContextTest, ValidObjectsTest) { } { - query::DbAccessor dba{&StartTransaction()}; + memgraph::query::DbAccessor dba{&StartTransaction()}; trigger_context.AdaptForAccessor(&dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::SET_VERTEX_PROPERTIES, vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::SET_EDGE_PROPERTIES, edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::SET_VERTEX_PROPERTIES, vertex_count, + dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::SET_EDGE_PROPERTIES, edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::REMOVED_VERTEX_PROPERTIES, vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::REMOVED_EDGE_PROPERTIES, edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_VERTEX_PROPERTIES, vertex_count, + dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_EDGE_PROPERTIES, edge_count, + dba); - CheckLabelList(trigger_context, query::TriggerIdentifierTag::SET_VERTEX_LABELS, vertex_count, dba); - CheckLabelList(trigger_context, query::TriggerIdentifierTag::REMOVED_VERTEX_LABELS, vertex_count, dba); + CheckLabelList(trigger_context, memgraph::query::TriggerIdentifierTag::SET_VERTEX_LABELS, vertex_count, dba); + CheckLabelList(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_VERTEX_LABELS, vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_VERTICES, 4 * vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_EDGES, 2 * edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_OBJECTS, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, 4 * vertex_count, + dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_EDGES, 2 * edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_OBJECTS, 4 * vertex_count + 2 * edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::DELETED_VERTICES, deleted_vertex_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::DELETED_EDGES, deleted_edge_count, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::DELETED_OBJECTS, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::DELETED_VERTICES, deleted_vertex_count, + dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::DELETED_EDGES, deleted_edge_count, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::DELETED_OBJECTS, deleted_vertex_count + deleted_edge_count, dba); } } @@ -282,17 +300,18 @@ TEST_F(TriggerContextTest, ValidObjectsTest) { // Binding the trigger context to transaction will mean that creating and updating an object in the same transaction // will return only the CREATE event. TEST_F(TriggerContextTest, ReturnCreateOnlyEvent) { - query::TriggerContextCollector trigger_context_collector{kAllEventTypes}; + memgraph::query::TriggerContextCollector trigger_context_collector{kAllEventTypes}; - query::DbAccessor dba{&StartTransaction()}; + memgraph::query::DbAccessor dba{&StartTransaction()}; auto create_vertex = [&] { auto vertex = dba.InsertVertex(); trigger_context_collector.RegisterCreatedObject(vertex); trigger_context_collector.RegisterSetObjectProperty(vertex, dba.NameToProperty("PROPERTY1"), - query::TypedValue("Value"), query::TypedValue("ValueNew")); + memgraph::query::TypedValue("Value"), + memgraph::query::TypedValue("ValueNew")); trigger_context_collector.RegisterRemovedObjectProperty(vertex, dba.NameToProperty("PROPERTY2"), - query::TypedValue("Value")); + memgraph::query::TypedValue("Value")); trigger_context_collector.RegisterSetVertexLabel(vertex, dba.NameToLabel("LABEL1")); trigger_context_collector.RegisterRemovedVertexLabel(vertex, dba.NameToLabel("LABEL2")); return vertex; @@ -304,144 +323,159 @@ TEST_F(TriggerContextTest, ReturnCreateOnlyEvent) { ASSERT_FALSE(maybe_edge.HasError()); trigger_context_collector.RegisterCreatedObject(*maybe_edge); trigger_context_collector.RegisterSetObjectProperty(*maybe_edge, dba.NameToProperty("PROPERTY1"), - query::TypedValue("Value"), query::TypedValue("ValueNew")); + memgraph::query::TypedValue("Value"), + memgraph::query::TypedValue("ValueNew")); trigger_context_collector.RegisterRemovedObjectProperty(*maybe_edge, dba.NameToProperty("PROPERTY2"), - query::TypedValue("Value")); + memgraph::query::TypedValue("Value")); dba.AdvanceCommand(); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_VERTICES, 2, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_EDGES, 1, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_OBJECTS, 3, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_VERTICES, 2, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_EDGES, 1, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_OBJECTS, 3, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::SET_VERTEX_PROPERTIES, 0, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::SET_EDGE_PROPERTIES, 0, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::SET_VERTEX_PROPERTIES, 0, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::SET_EDGE_PROPERTIES, 0, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::REMOVED_VERTEX_PROPERTIES, 0, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::REMOVED_EDGE_PROPERTIES, 0, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_VERTEX_PROPERTIES, 0, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_EDGE_PROPERTIES, 0, dba); - CheckLabelList(trigger_context, query::TriggerIdentifierTag::SET_VERTEX_LABELS, 0, dba); - CheckLabelList(trigger_context, query::TriggerIdentifierTag::REMOVED_VERTEX_LABELS, 0, dba); + CheckLabelList(trigger_context, memgraph::query::TriggerIdentifierTag::SET_VERTEX_LABELS, 0, dba); + CheckLabelList(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_VERTEX_LABELS, 0, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_VERTICES, 0, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_EDGES, 0, dba); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_OBJECTS, 0, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, 0, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_EDGES, 0, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_OBJECTS, 0, dba); } namespace { -void EXPECT_PROP_TRUE(const query::TypedValue &a) { - EXPECT_TRUE(a.type() == query::TypedValue::Type::Bool && a.ValueBool()); +void EXPECT_PROP_TRUE(const memgraph::query::TypedValue &a) { + EXPECT_TRUE(a.type() == memgraph::query::TypedValue::Type::Bool && a.ValueBool()); } -void EXPECT_PROP_EQ(const query::TypedValue &a, const query::TypedValue &b) { EXPECT_PROP_TRUE(a == b); } +void EXPECT_PROP_EQ(const memgraph::query::TypedValue &a, const memgraph::query::TypedValue &b) { + EXPECT_PROP_TRUE(a == b); +} } // namespace // During a transaction, same property for the same object can change multiple times. TriggerContext should ensure // that only the change on the global value is returned (value before the transaction + latest value after the // transaction) everything inbetween should be ignored. TEST_F(TriggerContextTest, GlobalPropertyChange) { - query::DbAccessor dba{&StartTransaction()}; - const std::unordered_set event_types{query::TriggerEventType::VERTEX_UPDATE}; + memgraph::query::DbAccessor dba{&StartTransaction()}; + const std::unordered_set event_types{ + memgraph::query::TriggerEventType::VERTEX_UPDATE}; auto v = dba.InsertVertex(); dba.AdvanceCommand(); { SPDLOG_DEBUG("SET -> SET"); - query::TriggerContextCollector trigger_context_collector{event_types}; - trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue("Value"), - query::TypedValue("ValueNew")); + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), - query::TypedValue("ValueNew"), query::TypedValue("ValueNewer")); + memgraph::query::TypedValue("Value"), + memgraph::query::TypedValue("ValueNew")); + trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), + memgraph::query::TypedValue("ValueNew"), + memgraph::query::TypedValue("ValueNewer")); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 1); auto &update = updated_vertices_list[0]; ASSERT_TRUE(update.IsMap()); - EXPECT_PROP_EQ(update, query::TypedValue{std::map{ - {"event_type", query::TypedValue{"set_vertex_property"}}, - {"vertex", query::TypedValue{v}}, - {"key", query::TypedValue{"PROPERTY"}}, - {"old", query::TypedValue{"Value"}}, - {"new", query::TypedValue{"ValueNewer"}}}}); + EXPECT_PROP_EQ(update, memgraph::query::TypedValue{std::map{ + {"event_type", memgraph::query::TypedValue{"set_vertex_property"}}, + {"vertex", memgraph::query::TypedValue{v}}, + {"key", memgraph::query::TypedValue{"PROPERTY"}}, + {"old", memgraph::query::TypedValue{"Value"}}, + {"new", memgraph::query::TypedValue{"ValueNewer"}}}}); } { SPDLOG_DEBUG("SET -> REMOVE"); - query::TriggerContextCollector trigger_context_collector{event_types}; - trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue("Value"), - query::TypedValue("ValueNew")); + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; + trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), + memgraph::query::TypedValue("Value"), + memgraph::query::TypedValue("ValueNew")); trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), - query::TypedValue("ValueNew")); + memgraph::query::TypedValue("ValueNew")); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 1); auto &update = updated_vertices_list[0]; ASSERT_TRUE(update.IsMap()); - EXPECT_PROP_EQ(update, query::TypedValue{std::map{ - {"event_type", query::TypedValue{"removed_vertex_property"}}, - {"vertex", query::TypedValue{v}}, - {"key", query::TypedValue{"PROPERTY"}}, - {"old", query::TypedValue{"Value"}}}}); + EXPECT_PROP_EQ(update, memgraph::query::TypedValue{std::map{ + {"event_type", memgraph::query::TypedValue{"removed_vertex_property"}}, + {"vertex", memgraph::query::TypedValue{v}}, + {"key", memgraph::query::TypedValue{"PROPERTY"}}, + {"old", memgraph::query::TypedValue{"Value"}}}}); } { SPDLOG_DEBUG("REMOVE -> SET"); - query::TriggerContextCollector trigger_context_collector{event_types}; + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), - query::TypedValue("Value")); - trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue(), - query::TypedValue("ValueNew")); + memgraph::query::TypedValue("Value")); + trigger_context_collector.RegisterSetObjectProperty( + v, dba.NameToProperty("PROPERTY"), memgraph::query::TypedValue(), memgraph::query::TypedValue("ValueNew")); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 1); auto &update = updated_vertices_list[0]; ASSERT_TRUE(update.IsMap()); - EXPECT_PROP_EQ(update, query::TypedValue{std::map{ - {"event_type", query::TypedValue{"set_vertex_property"}}, - {"vertex", query::TypedValue{v}}, - {"key", query::TypedValue{"PROPERTY"}}, - {"old", query::TypedValue{"Value"}}, - {"new", query::TypedValue{"ValueNew"}}}}); + EXPECT_PROP_EQ(update, memgraph::query::TypedValue{std::map{ + {"event_type", memgraph::query::TypedValue{"set_vertex_property"}}, + {"vertex", memgraph::query::TypedValue{v}}, + {"key", memgraph::query::TypedValue{"PROPERTY"}}, + {"old", memgraph::query::TypedValue{"Value"}}, + {"new", memgraph::query::TypedValue{"ValueNew"}}}}); } { SPDLOG_DEBUG("REMOVE -> REMOVE"); - query::TriggerContextCollector trigger_context_collector{event_types}; + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), - query::TypedValue("Value")); - trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue()); + memgraph::query::TypedValue("Value")); + trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), + memgraph::query::TypedValue()); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 1); auto &update = updated_vertices_list[0]; ASSERT_TRUE(update.IsMap()); - EXPECT_PROP_EQ(update, query::TypedValue{std::map{ - {"event_type", query::TypedValue{"removed_vertex_property"}}, - {"vertex", query::TypedValue{v}}, - {"key", query::TypedValue{"PROPERTY"}}, - {"old", query::TypedValue{"Value"}}}}); + EXPECT_PROP_EQ(update, memgraph::query::TypedValue{std::map{ + {"event_type", memgraph::query::TypedValue{"removed_vertex_property"}}, + {"vertex", memgraph::query::TypedValue{v}}, + {"key", memgraph::query::TypedValue{"PROPERTY"}}, + {"old", memgraph::query::TypedValue{"Value"}}}}); } { SPDLOG_DEBUG("SET -> SET (no change on transaction level)"); - query::TriggerContextCollector trigger_context_collector{event_types}; - trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue("Value"), - query::TypedValue("ValueNew")); + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), - query::TypedValue("ValueNew"), query::TypedValue("Value")); + memgraph::query::TypedValue("Value"), + memgraph::query::TypedValue("ValueNew")); + trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), + memgraph::query::TypedValue("ValueNew"), + memgraph::query::TypedValue("Value")); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 0); @@ -449,13 +483,14 @@ TEST_F(TriggerContextTest, GlobalPropertyChange) { { SPDLOG_DEBUG("SET -> REMOVE (no change on transaction level)"); - query::TriggerContextCollector trigger_context_collector{event_types}; - trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue(), - query::TypedValue("ValueNew")); + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; + trigger_context_collector.RegisterSetObjectProperty( + v, dba.NameToProperty("PROPERTY"), memgraph::query::TypedValue(), memgraph::query::TypedValue("ValueNew")); trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), - query::TypedValue("ValueNew")); + memgraph::query::TypedValue("ValueNew")); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 0); @@ -463,13 +498,14 @@ TEST_F(TriggerContextTest, GlobalPropertyChange) { { SPDLOG_DEBUG("REMOVE -> SET (no change on transaction level)"); - query::TriggerContextCollector trigger_context_collector{event_types}; + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), - query::TypedValue("Value")); - trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue(), - query::TypedValue("Value")); + memgraph::query::TypedValue("Value")); + trigger_context_collector.RegisterSetObjectProperty( + v, dba.NameToProperty("PROPERTY"), memgraph::query::TypedValue(), memgraph::query::TypedValue("Value")); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 0); @@ -477,11 +513,14 @@ TEST_F(TriggerContextTest, GlobalPropertyChange) { { SPDLOG_DEBUG("REMOVE -> REMOVE (no change on transaction level)"); - query::TriggerContextCollector trigger_context_collector{event_types}; - trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue()); - trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue()); + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; + trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), + memgraph::query::TypedValue()); + trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), + memgraph::query::TypedValue()); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 0); @@ -489,37 +528,40 @@ TEST_F(TriggerContextTest, GlobalPropertyChange) { { SPDLOG_DEBUG("SET -> REMOVE -> SET -> REMOVE -> SET"); - query::TriggerContextCollector trigger_context_collector{event_types}; - trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue("Value0"), - query::TypedValue("Value1")); + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; + trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), + memgraph::query::TypedValue("Value0"), + memgraph::query::TypedValue("Value1")); trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), - query::TypedValue("Value1")); - trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue(), - query::TypedValue("Value2")); + memgraph::query::TypedValue("Value1")); + trigger_context_collector.RegisterSetObjectProperty( + v, dba.NameToProperty("PROPERTY"), memgraph::query::TypedValue(), memgraph::query::TypedValue("Value2")); trigger_context_collector.RegisterRemovedObjectProperty(v, dba.NameToProperty("PROPERTY"), - query::TypedValue("Value2")); - trigger_context_collector.RegisterSetObjectProperty(v, dba.NameToProperty("PROPERTY"), query::TypedValue(), - query::TypedValue("Value3")); + memgraph::query::TypedValue("Value2")); + trigger_context_collector.RegisterSetObjectProperty( + v, dba.NameToProperty("PROPERTY"), memgraph::query::TypedValue(), memgraph::query::TypedValue("Value3")); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 1); auto &update = updated_vertices_list[0]; ASSERT_TRUE(update.IsMap()); - EXPECT_PROP_EQ(update, query::TypedValue{std::map{ - {"event_type", query::TypedValue{"set_vertex_property"}}, - {"vertex", query::TypedValue{v}}, - {"key", query::TypedValue{"PROPERTY"}}, - {"old", query::TypedValue{"Value0"}}, - {"new", query::TypedValue{"Value3"}}}}); + EXPECT_PROP_EQ(update, memgraph::query::TypedValue{std::map{ + {"event_type", memgraph::query::TypedValue{"set_vertex_property"}}, + {"vertex", memgraph::query::TypedValue{v}}, + {"key", memgraph::query::TypedValue{"PROPERTY"}}, + {"old", memgraph::query::TypedValue{"Value0"}}, + {"new", memgraph::query::TypedValue{"Value3"}}}}); } } // Same as above, but for label changes TEST_F(TriggerContextTest, GlobalLabelChange) { - query::DbAccessor dba{&StartTransaction()}; - const std::unordered_set event_types{query::TriggerEventType::VERTEX_UPDATE}; + memgraph::query::DbAccessor dba{&StartTransaction()}; + const std::unordered_set event_types{ + memgraph::query::TriggerEventType::VERTEX_UPDATE}; auto v = dba.InsertVertex(); dba.AdvanceCommand(); @@ -529,11 +571,12 @@ TEST_F(TriggerContextTest, GlobalLabelChange) { // so REMOVE -> REMOVE and SET -> SET doesn't make sense { SPDLOG_DEBUG("SET -> REMOVE"); - query::TriggerContextCollector trigger_context_collector{event_types}; + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; trigger_context_collector.RegisterSetVertexLabel(v, label_id); trigger_context_collector.RegisterRemovedVertexLabel(v, label_id); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 0); @@ -541,11 +584,12 @@ TEST_F(TriggerContextTest, GlobalLabelChange) { { SPDLOG_DEBUG("REMOVE -> SET"); - query::TriggerContextCollector trigger_context_collector{event_types}; + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; trigger_context_collector.RegisterRemovedVertexLabel(v, label_id); trigger_context_collector.RegisterSetVertexLabel(v, label_id); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 0); @@ -553,44 +597,46 @@ TEST_F(TriggerContextTest, GlobalLabelChange) { { SPDLOG_DEBUG("SET -> REMOVE -> SET -> REMOVE -> SET"); - query::TriggerContextCollector trigger_context_collector{event_types}; + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; trigger_context_collector.RegisterSetVertexLabel(v, label_id); trigger_context_collector.RegisterRemovedVertexLabel(v, label_id); trigger_context_collector.RegisterSetVertexLabel(v, label_id); trigger_context_collector.RegisterRemovedVertexLabel(v, label_id); trigger_context_collector.RegisterSetVertexLabel(v, label_id); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 1); auto &update = updated_vertices_list[0]; ASSERT_TRUE(update.IsMap()); - EXPECT_PROP_EQ(update, query::TypedValue{std::map{ - {"event_type", query::TypedValue{"set_vertex_label"}}, - {"vertex", query::TypedValue{v}}, - {"label", query::TypedValue{"LABEL"}}}}); + EXPECT_PROP_EQ(update, memgraph::query::TypedValue{std::map{ + {"event_type", memgraph::query::TypedValue{"set_vertex_label"}}, + {"vertex", memgraph::query::TypedValue{v}}, + {"label", memgraph::query::TypedValue{"LABEL"}}}}); } { SPDLOG_DEBUG("REMOVE -> SET -> REMOVE -> SET -> REMOVE"); - query::TriggerContextCollector trigger_context_collector{event_types}; + memgraph::query::TriggerContextCollector trigger_context_collector{event_types}; trigger_context_collector.RegisterRemovedVertexLabel(v, label_id); trigger_context_collector.RegisterSetVertexLabel(v, label_id); trigger_context_collector.RegisterRemovedVertexLabel(v, label_id); trigger_context_collector.RegisterSetVertexLabel(v, label_id); trigger_context_collector.RegisterRemovedVertexLabel(v, label_id); const auto trigger_context = std::move(trigger_context_collector).TransformToTriggerContext(); - auto updated_vertices = trigger_context.GetTypedValue(query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); + auto updated_vertices = + trigger_context.GetTypedValue(memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, &dba); ASSERT_TRUE(updated_vertices.IsList()); auto &updated_vertices_list = updated_vertices.ValueList(); ASSERT_EQ(updated_vertices_list.size(), 1); auto &update = updated_vertices_list[0]; ASSERT_TRUE(update.IsMap()); - EXPECT_PROP_EQ(update, query::TypedValue{std::map{ - {"event_type", query::TypedValue{"removed_vertex_label"}}, - {"vertex", query::TypedValue{v}}, - {"label", query::TypedValue{"LABEL"}}}}); + EXPECT_PROP_EQ(update, memgraph::query::TypedValue{std::map{ + {"event_type", memgraph::query::TypedValue{"removed_vertex_label"}}, + {"vertex", memgraph::query::TypedValue{v}}, + {"label", memgraph::query::TypedValue{"LABEL"}}}}); } } @@ -602,7 +648,8 @@ struct ShouldRegisterExpectation { }; template -void CheckRegisterInfo(const query::TriggerContextCollector &collector, const ShouldRegisterExpectation &expectation) { +void CheckRegisterInfo(const memgraph::query::TriggerContextCollector &collector, + const ShouldRegisterExpectation &expectation) { EXPECT_EQ(expectation.creation, collector.ShouldRegisterCreatedObject()); EXPECT_EQ(expectation.deletion, collector.ShouldRegisterDeletedObject()); EXPECT_EQ(expectation.update, collector.ShouldRegisterObjectPropertyChange()); @@ -610,21 +657,21 @@ void CheckRegisterInfo(const query::TriggerContextCollector &collector, const Sh size_t BoolToSize(const bool value) { return value ? 1 : 0; } -void CheckFilters(const std::unordered_set &event_types, +void CheckFilters(const std::unordered_set &event_types, const ShouldRegisterExpectation &vertex_expectation, - const ShouldRegisterExpectation &edge_expectation, storage::Storage::Accessor *accessor) { - query::TriggerContextCollector collector{event_types}; + const ShouldRegisterExpectation &edge_expectation, memgraph::storage::Storage::Accessor *accessor) { + memgraph::query::TriggerContextCollector collector{event_types}; { SCOPED_TRACE("Checking vertex"); - CheckRegisterInfo(collector, vertex_expectation); + CheckRegisterInfo(collector, vertex_expectation); } { SCOPED_TRACE("Checking edge"); - CheckRegisterInfo(collector, edge_expectation); + CheckRegisterInfo(collector, edge_expectation); } EXPECT_EQ(collector.ShouldRegisterVertexLabelChange(), vertex_expectation.update); - query::DbAccessor dba{accessor}; + memgraph::query::DbAccessor dba{accessor}; auto vertex_to_delete = dba.InsertVertex(); auto vertex_to_modify = dba.InsertVertex(); @@ -645,12 +692,13 @@ void CheckFilters(const std::unordered_set &event_types collector.RegisterCreatedObject(created_edge); collector.RegisterDeletedObject(dba.RemoveEdge(&edge_to_delete).GetValue().value()); collector.RegisterDeletedObject(dba.RemoveVertex(&vertex_to_delete).GetValue().value()); - collector.RegisterSetObjectProperty(vertex_to_modify, dba.NameToProperty("UPDATE"), query::TypedValue{1}, - query::TypedValue{2}); - collector.RegisterRemovedObjectProperty(vertex_to_modify, dba.NameToProperty("REMOVE"), query::TypedValue{1}); - collector.RegisterSetObjectProperty(edge_to_modify, dba.NameToProperty("UPDATE"), query::TypedValue{1}, - query::TypedValue{2}); - collector.RegisterRemovedObjectProperty(edge_to_modify, dba.NameToProperty("REMOVE"), query::TypedValue{1}); + collector.RegisterSetObjectProperty(vertex_to_modify, dba.NameToProperty("UPDATE"), memgraph::query::TypedValue{1}, + memgraph::query::TypedValue{2}); + collector.RegisterRemovedObjectProperty(vertex_to_modify, dba.NameToProperty("REMOVE"), + memgraph::query::TypedValue{1}); + collector.RegisterSetObjectProperty(edge_to_modify, dba.NameToProperty("UPDATE"), memgraph::query::TypedValue{1}, + memgraph::query::TypedValue{2}); + collector.RegisterRemovedObjectProperty(edge_to_modify, dba.NameToProperty("REMOVE"), memgraph::query::TypedValue{1}); collector.RegisterSetVertexLabel(vertex_to_modify, dba.NameToLabel("SET")); collector.RegisterRemovedVertexLabel(vertex_to_modify, dba.NameToLabel("REMOVE")); dba.AdvanceCommand(); @@ -659,78 +707,81 @@ void CheckFilters(const std::unordered_set &event_types const auto created_vertices = BoolToSize(vertex_expectation.creation); { SCOPED_TRACE("CREATED_VERTICES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_VERTICES, created_vertices, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_VERTICES, created_vertices, + dba); } const auto created_edges = BoolToSize(edge_expectation.creation); { SCOPED_TRACE("CREATED_EDGES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_EDGES, created_edges, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_EDGES, created_edges, dba); } { SCOPED_TRACE("CREATED_OBJECTS"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::CREATED_OBJECTS, created_vertices + created_edges, - dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::CREATED_OBJECTS, + created_vertices + created_edges, dba); } const auto deleted_vertices = BoolToSize(vertex_expectation.deletion); { SCOPED_TRACE("DELETED_VERTICES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::DELETED_VERTICES, deleted_vertices, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::DELETED_VERTICES, deleted_vertices, + dba); } const auto deleted_edges = BoolToSize(edge_expectation.deletion); { SCOPED_TRACE("DELETED_EDGES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::DELETED_EDGES, deleted_edges, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::DELETED_EDGES, deleted_edges, dba); } { SCOPED_TRACE("DELETED_OBJECTS"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::DELETED_OBJECTS, deleted_vertices + deleted_edges, - dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::DELETED_OBJECTS, + deleted_vertices + deleted_edges, dba); } { SCOPED_TRACE("SET_VERTEX_PROPERTIES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::SET_VERTEX_PROPERTIES, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::SET_VERTEX_PROPERTIES, BoolToSize(vertex_expectation.update), dba); } { SCOPED_TRACE("SET_EDGE_PROPERTIES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::SET_EDGE_PROPERTIES, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::SET_EDGE_PROPERTIES, BoolToSize(edge_expectation.update), dba); } { SCOPED_TRACE("REMOVED_VERTEX_PROPERTIES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::REMOVED_VERTEX_PROPERTIES, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_VERTEX_PROPERTIES, BoolToSize(vertex_expectation.update), dba); } { SCOPED_TRACE("REMOVED_EDGE_PROPERTIES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::REMOVED_EDGE_PROPERTIES, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_EDGE_PROPERTIES, BoolToSize(edge_expectation.update), dba); } const auto set_and_removed_vertex_props_and_labels = BoolToSize(vertex_expectation.update) * 4; { SCOPED_TRACE("UPDATED_VERTICES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_VERTICES, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_VERTICES, set_and_removed_vertex_props_and_labels, dba); } const auto set_and_removed_edge_props = BoolToSize(edge_expectation.update) * 2; { SCOPED_TRACE("UPDATED_EDGES"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_EDGES, set_and_removed_edge_props, dba); + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_EDGES, + set_and_removed_edge_props, dba); } // sum of the previous { SCOPED_TRACE("UPDATED_OBJECTS"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::UPDATED_OBJECTS, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::UPDATED_OBJECTS, set_and_removed_vertex_props_and_labels + set_and_removed_edge_props, dba); } { SCOPED_TRACE("SET_VERTEX_LABELS"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::SET_VERTEX_LABELS, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::SET_VERTEX_LABELS, BoolToSize(vertex_expectation.update), dba); } { SCOPED_TRACE("REMOVED_VERTEX_LABELS"); - CheckTypedValueSize(trigger_context, query::TriggerIdentifierTag::REMOVED_VERTEX_LABELS, + CheckTypedValueSize(trigger_context, memgraph::query::TriggerIdentifierTag::REMOVED_VERTEX_LABELS, BoolToSize(vertex_expectation.update), dba); } @@ -739,7 +790,7 @@ void CheckFilters(const std::unordered_set &event_types } // namespace TEST_F(TriggerContextTest, Filtering) { - using TET = query::TriggerEventType; + using TET = memgraph::query::TriggerEventType; // Check all event type individually { SCOPED_TRACE("TET::ANY"); @@ -837,11 +888,11 @@ class TriggerStoreTest : public ::testing::Test { storage_accessor.reset(); } - std::optional dba; + std::optional dba; - utils::SkipList ast_cache; - utils::SpinLock antlr_lock; - query::AllowEverythingAuthChecker auth_checker; + memgraph::utils::SkipList ast_cache; + memgraph::utils::SpinLock antlr_lock; + memgraph::query::AllowEverythingAuthChecker auth_checker; private: void Clear() { @@ -849,16 +900,16 @@ class TriggerStoreTest : public ::testing::Test { std::filesystem::remove_all(testing_directory); } - storage::Storage storage; - std::optional storage_accessor; + memgraph::storage::Storage storage; + std::optional storage_accessor; }; TEST_F(TriggerStoreTest, Restore) { - std::optional store; + std::optional store; const auto reset_store = [&] { store.emplace(testing_directory); - store->RestoreTriggers(&ast_cache, &*dba, &antlr_lock, query::InterpreterConfig::Query{}, &auth_checker); + store->RestoreTriggers(&ast_cache, &*dba, &antlr_lock, memgraph::query::InterpreterConfig::Query{}, &auth_checker); }; reset_store(); @@ -874,16 +925,18 @@ TEST_F(TriggerStoreTest, Restore) { const auto *trigger_name_before = "trigger"; const auto *trigger_name_after = "trigger_after"; const auto *trigger_statement = "RETURN $parameter"; - const auto event_type = query::TriggerEventType::VERTEX_CREATE; + const auto event_type = memgraph::query::TriggerEventType::VERTEX_CREATE; const std::string owner{"owner"}; - store->AddTrigger(trigger_name_before, trigger_statement, - std::map{{"parameter", storage::PropertyValue{1}}}, event_type, - query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, std::nullopt, &auth_checker); - store->AddTrigger(trigger_name_after, trigger_statement, - std::map{{"parameter", storage::PropertyValue{"value"}}}, - event_type, query::TriggerPhase::AFTER_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, {owner}, &auth_checker); + store->AddTrigger( + trigger_name_before, trigger_statement, + std::map{{"parameter", memgraph::storage::PropertyValue{1}}}, + event_type, memgraph::query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker); + store->AddTrigger( + trigger_name_after, trigger_statement, + std::map{{"parameter", memgraph::storage::PropertyValue{"value"}}}, + event_type, memgraph::query::TriggerPhase::AFTER_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, {owner}, &auth_checker); const auto check_triggers = [&] { ASSERT_EQ(store->GetTriggerInfo().size(), 2); @@ -929,38 +982,38 @@ TEST_F(TriggerStoreTest, Restore) { } TEST_F(TriggerStoreTest, AddTrigger) { - query::TriggerStore store{testing_directory}; + memgraph::query::TriggerStore store{testing_directory}; // Invalid query in statements - ASSERT_THROW(store.AddTrigger("trigger", "RETUR 1", {}, query::TriggerEventType::VERTEX_CREATE, - query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), - utils::BasicException); - ASSERT_THROW(store.AddTrigger("trigger", "RETURN createdEdges", {}, query::TriggerEventType::VERTEX_CREATE, - query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), - utils::BasicException); + ASSERT_THROW(store.AddTrigger("trigger", "RETUR 1", {}, memgraph::query::TriggerEventType::VERTEX_CREATE, + memgraph::query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), + memgraph::utils::BasicException); + ASSERT_THROW(store.AddTrigger("trigger", "RETURN createdEdges", {}, memgraph::query::TriggerEventType::VERTEX_CREATE, + memgraph::query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), + memgraph::utils::BasicException); - ASSERT_THROW(store.AddTrigger("trigger", "RETURN $parameter", {}, query::TriggerEventType::VERTEX_CREATE, - query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), - utils::BasicException); + ASSERT_THROW(store.AddTrigger("trigger", "RETURN $parameter", {}, memgraph::query::TriggerEventType::VERTEX_CREATE, + memgraph::query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), + memgraph::utils::BasicException); - ASSERT_NO_THROW( - store.AddTrigger("trigger", "RETURN $parameter", - std::map{{"parameter", storage::PropertyValue{1}}}, - query::TriggerEventType::VERTEX_CREATE, query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, - &antlr_lock, query::InterpreterConfig::Query{}, std::nullopt, &auth_checker)); + ASSERT_NO_THROW(store.AddTrigger( + "trigger", "RETURN $parameter", + std::map{{"parameter", memgraph::storage::PropertyValue{1}}}, + memgraph::query::TriggerEventType::VERTEX_CREATE, memgraph::query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, + &antlr_lock, memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker)); // Inserting with the same name - ASSERT_THROW(store.AddTrigger("trigger", "RETURN 1", {}, query::TriggerEventType::VERTEX_CREATE, - query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), - utils::BasicException); - ASSERT_THROW(store.AddTrigger("trigger", "RETURN 1", {}, query::TriggerEventType::VERTEX_CREATE, - query::TriggerPhase::AFTER_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), - utils::BasicException); + ASSERT_THROW(store.AddTrigger("trigger", "RETURN 1", {}, memgraph::query::TriggerEventType::VERTEX_CREATE, + memgraph::query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), + memgraph::utils::BasicException); + ASSERT_THROW(store.AddTrigger("trigger", "RETURN 1", {}, memgraph::query::TriggerEventType::VERTEX_CREATE, + memgraph::query::TriggerPhase::AFTER_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker), + memgraph::utils::BasicException); ASSERT_EQ(store.GetTriggerInfo().size(), 1); ASSERT_EQ(store.BeforeCommitTriggers().size(), 1); @@ -968,29 +1021,29 @@ TEST_F(TriggerStoreTest, AddTrigger) { } TEST_F(TriggerStoreTest, DropTrigger) { - query::TriggerStore store{testing_directory}; + memgraph::query::TriggerStore store{testing_directory}; - ASSERT_THROW(store.DropTrigger("Unknown"), utils::BasicException); + ASSERT_THROW(store.DropTrigger("Unknown"), memgraph::utils::BasicException); const auto *trigger_name = "trigger"; - store.AddTrigger(trigger_name, "RETURN 1", {}, query::TriggerEventType::VERTEX_CREATE, - query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, std::nullopt, &auth_checker); + store.AddTrigger(trigger_name, "RETURN 1", {}, memgraph::query::TriggerEventType::VERTEX_CREATE, + memgraph::query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker); - ASSERT_THROW(store.DropTrigger("Unknown"), utils::BasicException); + ASSERT_THROW(store.DropTrigger("Unknown"), memgraph::utils::BasicException); ASSERT_NO_THROW(store.DropTrigger(trigger_name)); ASSERT_EQ(store.GetTriggerInfo().size(), 0); } TEST_F(TriggerStoreTest, TriggerInfo) { - query::TriggerStore store{testing_directory}; + memgraph::query::TriggerStore store{testing_directory}; - std::vector expected_info; - store.AddTrigger("trigger", "RETURN 1", {}, query::TriggerEventType::VERTEX_CREATE, - query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, std::nullopt, &auth_checker); - expected_info.push_back( - {"trigger", "RETURN 1", query::TriggerEventType::VERTEX_CREATE, query::TriggerPhase::BEFORE_COMMIT}); + std::vector expected_info; + store.AddTrigger("trigger", "RETURN 1", {}, memgraph::query::TriggerEventType::VERTEX_CREATE, + memgraph::query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker); + expected_info.push_back({"trigger", "RETURN 1", memgraph::query::TriggerEventType::VERTEX_CREATE, + memgraph::query::TriggerPhase::BEFORE_COMMIT}); const auto check_trigger_info = [&] { const auto trigger_info = store.GetTriggerInfo(); @@ -1006,11 +1059,11 @@ TEST_F(TriggerStoreTest, TriggerInfo) { check_trigger_info(); - store.AddTrigger("edge_update_trigger", "RETURN 1", {}, query::TriggerEventType::EDGE_UPDATE, - query::TriggerPhase::AFTER_COMMIT, &ast_cache, &*dba, &antlr_lock, query::InterpreterConfig::Query{}, - std::nullopt, &auth_checker); - expected_info.push_back( - {"edge_update_trigger", "RETURN 1", query::TriggerEventType::EDGE_UPDATE, query::TriggerPhase::AFTER_COMMIT}); + store.AddTrigger("edge_update_trigger", "RETURN 1", {}, memgraph::query::TriggerEventType::EDGE_UPDATE, + memgraph::query::TriggerPhase::AFTER_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker); + expected_info.push_back({"edge_update_trigger", "RETURN 1", memgraph::query::TriggerEventType::EDGE_UPDATE, + memgraph::query::TriggerPhase::AFTER_COMMIT}); check_trigger_info(); @@ -1030,7 +1083,7 @@ TEST_F(TriggerStoreTest, TriggerInfo) { } TEST_F(TriggerStoreTest, AnyTriggerAllKeywords) { - query::TriggerStore store{testing_directory}; + memgraph::query::TriggerStore store{testing_directory}; using namespace std::literals; @@ -1051,10 +1104,11 @@ TEST_F(TriggerStoreTest, AnyTriggerAllKeywords) { const auto updates_objects = "updatedObjects"sv; std::array event_types_to_test = { - std::make_pair(query::TriggerEventType::CREATE, std::vector{created_vertices, created_edges, created_objects}), - std::make_pair(query::TriggerEventType::VERTEX_CREATE, std::vector{created_vertices}), - std::make_pair(query::TriggerEventType::EDGE_CREATE, std::vector{created_edges}), - std::make_pair(query::TriggerEventType::UPDATE, + std::make_pair(memgraph::query::TriggerEventType::CREATE, + std::vector{created_vertices, created_edges, created_objects}), + std::make_pair(memgraph::query::TriggerEventType::VERTEX_CREATE, std::vector{created_vertices}), + std::make_pair(memgraph::query::TriggerEventType::EDGE_CREATE, std::vector{created_edges}), + std::make_pair(memgraph::query::TriggerEventType::UPDATE, std::vector{ set_vertex_properties, set_edge_properties, @@ -1066,7 +1120,7 @@ TEST_F(TriggerStoreTest, AnyTriggerAllKeywords) { updated_edges, updates_objects, }), - std::make_pair(query::TriggerEventType::VERTEX_UPDATE, + std::make_pair(memgraph::query::TriggerEventType::VERTEX_UPDATE, std::vector{ set_vertex_properties, removed_vertex_properties, @@ -1074,27 +1128,27 @@ TEST_F(TriggerStoreTest, AnyTriggerAllKeywords) { removed_vertex_labels, updated_vertices, }), - std::make_pair(query::TriggerEventType::EDGE_UPDATE, + std::make_pair(memgraph::query::TriggerEventType::EDGE_UPDATE, std::vector{ set_edge_properties, removed_edge_properties, updated_edges, }), - std::make_pair(query::TriggerEventType::DELETE, + std::make_pair(memgraph::query::TriggerEventType::DELETE, std::vector{ deleted_vertices, deleted_edges, deleted_objects, }), - std::make_pair(query::TriggerEventType::VERTEX_DELETE, + std::make_pair(memgraph::query::TriggerEventType::VERTEX_DELETE, std::vector{ deleted_vertices, }), - std::make_pair(query::TriggerEventType::EDGE_DELETE, + std::make_pair(memgraph::query::TriggerEventType::EDGE_DELETE, std::vector{ deleted_edges, }), - std::make_pair(query::TriggerEventType::ANY, + std::make_pair(memgraph::query::TriggerEventType::ANY, std::vector{ created_vertices, created_edges, @@ -1116,23 +1170,23 @@ TEST_F(TriggerStoreTest, AnyTriggerAllKeywords) { const auto trigger_name = "trigger"s; for (const auto &[event_type, keywords] : event_types_to_test) { - SCOPED_TRACE(query::TriggerEventTypeToString(event_type)); + SCOPED_TRACE(memgraph::query::TriggerEventTypeToString(event_type)); for (const auto keyword : keywords) { SCOPED_TRACE(keyword); EXPECT_NO_THROW(store.AddTrigger(trigger_name, fmt::format("RETURN {}", keyword), {}, event_type, - query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, - query::InterpreterConfig::Query{}, std::nullopt, &auth_checker)); + memgraph::query::TriggerPhase::BEFORE_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &auth_checker)); store.DropTrigger(trigger_name); } } } TEST_F(TriggerStoreTest, AuthCheckerUsage) { - using Privilege = query::AuthQuery::Privilege; + using Privilege = memgraph::query::AuthQuery::Privilege; using ::testing::_; using ::testing::ElementsAre; using ::testing::Return; - std::optional store{testing_directory}; + std::optional store{testing_directory}; const std::optional owner{"testing_owner"}; MockAuthChecker mock_checker; @@ -1144,22 +1198,24 @@ TEST_F(TriggerStoreTest, AuthCheckerUsage) { EXPECT_CALL(mock_checker, IsUserAuthorized(owner, ElementsAre(Privilege::CREATE))).Times(1).WillOnce(Return(true)); ASSERT_NO_THROW(store->AddTrigger("successfull_trigger_1", "CREATE (n:VERTEX) RETURN n", {}, - query::TriggerEventType::EDGE_UPDATE, query::TriggerPhase::AFTER_COMMIT, &ast_cache, - &*dba, &antlr_lock, query::InterpreterConfig::Query{}, std::nullopt, - &mock_checker)); + memgraph::query::TriggerEventType::EDGE_UPDATE, + memgraph::query::TriggerPhase::AFTER_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &mock_checker)); ASSERT_NO_THROW(store->AddTrigger("successfull_trigger_2", "CREATE (n:VERTEX) RETURN n", {}, - query::TriggerEventType::EDGE_UPDATE, query::TriggerPhase::AFTER_COMMIT, &ast_cache, - &*dba, &antlr_lock, query::InterpreterConfig::Query{}, owner, &mock_checker)); + memgraph::query::TriggerEventType::EDGE_UPDATE, + memgraph::query::TriggerPhase::AFTER_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, owner, &mock_checker)); EXPECT_CALL(mock_checker, IsUserAuthorized(std::optional{}, ElementsAre(Privilege::MATCH))) .Times(1) .WillOnce(Return(false)); ASSERT_THROW(store->AddTrigger("unprivileged_trigger", "MATCH (n:VERTEX) RETURN n", {}, - query::TriggerEventType::EDGE_UPDATE, query::TriggerPhase::AFTER_COMMIT, &ast_cache, - &*dba, &antlr_lock, query::InterpreterConfig::Query{}, std::nullopt, &mock_checker); - , utils::BasicException); + memgraph::query::TriggerEventType::EDGE_UPDATE, + memgraph::query::TriggerPhase::AFTER_COMMIT, &ast_cache, &*dba, &antlr_lock, + memgraph::query::InterpreterConfig::Query{}, std::nullopt, &mock_checker); + , memgraph::utils::BasicException); store.emplace(testing_directory); EXPECT_CALL(mock_checker, IsUserAuthorized(std::optional{}, ElementsAre(Privilege::CREATE))) @@ -1167,8 +1223,8 @@ TEST_F(TriggerStoreTest, AuthCheckerUsage) { .WillOnce(Return(false)); EXPECT_CALL(mock_checker, IsUserAuthorized(owner, ElementsAre(Privilege::CREATE))).Times(1).WillOnce(Return(true)); - ASSERT_NO_THROW( - store->RestoreTriggers(&ast_cache, &*dba, &antlr_lock, query::InterpreterConfig::Query{}, &mock_checker)); + ASSERT_NO_THROW(store->RestoreTriggers(&ast_cache, &*dba, &antlr_lock, memgraph::query::InterpreterConfig::Query{}, + &mock_checker)); const auto triggers = store->GetTriggerInfo(); ASSERT_EQ(triggers.size(), 1); diff --git a/tests/unit/query_variable_start_planner.cpp b/tests/unit/query_variable_start_planner.cpp index 59877edb6..2de54c577 100644 --- a/tests/unit/query_variable_start_planner.cpp +++ b/tests/unit/query_variable_start_planner.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,22 +23,23 @@ #include "formatters.hpp" -using namespace query::plan; -using query::AstStorage; -using Type = query::EdgeAtom::Type; -using Direction = query::EdgeAtom::Direction; +using namespace memgraph::query::plan; +using memgraph::query::AstStorage; +using Type = memgraph::query::EdgeAtom::Type; +using Direction = memgraph::query::EdgeAtom::Direction; // Functions for printing resulting rows from a query. template std::string ToString(const std::vector &row, const TAccessor &acc) { std::ostringstream os; - utils::PrintIterable(os, row, ", ", [&](auto &stream, const auto &item) { stream << ToString(item, acc); }); + memgraph::utils::PrintIterable(os, row, ", ", [&](auto &stream, const auto &item) { stream << ToString(item, acc); }); return os.str(); } template std::string ToString(const std::vector> &rows, const TAccessor &acc) { std::ostringstream os; - utils::PrintIterable(os, rows, "\n", [&](auto &stream, const auto &item) { stream << ToString(item, acc); }); + memgraph::utils::PrintIterable(os, rows, "\n", + [&](auto &stream, const auto &item) { stream << ToString(item, acc); }); return os.str(); } @@ -67,10 +68,10 @@ void AssertRows(const std::vector> &datum, std::vector> &)> check) { - auto symbol_table = query::MakeSymbolTable(query); + auto symbol_table = memgraph::query::MakeSymbolTable(query); auto planning_context = MakePlanningContext(&storage, &symbol_table, query, dba); auto query_parts = CollectQueryParts(symbol_table, storage, query); EXPECT_TRUE(query_parts.query_parts.size() > 0); @@ -87,9 +88,9 @@ void CheckPlansProduce(size_t expected_plan_count, query::CypherQuery *query, As } TEST(TestVariableStartPlanner, MatchReturn) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Make a graph (v1) -[:r]-> (v2) auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); @@ -101,14 +102,14 @@ TEST(TestVariableStartPlanner, MatchReturn) { // We have 2 nodes `n` and `m` from which we could start, so expect 2 plans. CheckPlansProduce(2, query, storage, &dba, [&](const auto &results) { // We expect to produce only a single (v1) node. - AssertRows(results, {{TypedValue(query::VertexAccessor(v1))}}, dba); + AssertRows(results, {{TypedValue(memgraph::query::VertexAccessor(v1))}}, dba); }); } TEST(TestVariableStartPlanner, MatchTripletPatternReturn) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Make a graph (v1) -[:r]-> (v2) -[:r]-> (v3) auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); @@ -125,7 +126,7 @@ TEST(TestVariableStartPlanner, MatchTripletPatternReturn) { // We have 3 nodes: `n`, `m` and `l` from which we could start. CheckPlansProduce(3, query, storage, &dba, [&](const auto &results) { // We expect to produce only a single (v1) node. - AssertRows(results, {{TypedValue(query::VertexAccessor(v1))}}, dba); + AssertRows(results, {{TypedValue(memgraph::query::VertexAccessor(v1))}}, dba); }); } { @@ -135,15 +136,15 @@ TEST(TestVariableStartPlanner, MatchTripletPatternReturn) { PATTERN(NODE("m"), EDGE("e", Direction::OUT), NODE("l"))), RETURN("n"))); CheckPlansProduce(3, query, storage, &dba, [&](const auto &results) { - AssertRows(results, {{TypedValue(query::VertexAccessor(v1))}}, dba); + AssertRows(results, {{TypedValue(memgraph::query::VertexAccessor(v1))}}, dba); }); } } TEST(TestVariableStartPlanner, MatchOptionalMatchReturn) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Make a graph (v1) -[:r]-> (v2) -[:r]-> (v3) auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); @@ -163,19 +164,19 @@ TEST(TestVariableStartPlanner, MatchOptionalMatchReturn) { // * (v1), (v3) // * (v2), null AssertRows(results, - {{TypedValue(query::VertexAccessor(v1)), TypedValue(query::VertexAccessor(v3))}, - {TypedValue(query::VertexAccessor(v2)), TypedValue()}}, + {{TypedValue(memgraph::query::VertexAccessor(v1)), TypedValue(memgraph::query::VertexAccessor(v3))}, + {TypedValue(memgraph::query::VertexAccessor(v2)), TypedValue()}}, dba); }); } TEST(TestVariableStartPlanner, MatchOptionalMatchMergeReturn) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Graph (v1) -[:r]-> (v2) - query::VertexAccessor v1(dba.InsertVertex()); - query::VertexAccessor v2(dba.InsertVertex()); + memgraph::query::VertexAccessor v1(dba.InsertVertex()); + memgraph::query::VertexAccessor v2(dba.InsertVertex()); auto r_type_name = "r"; auto r_type = dba.NameToEdgeType(r_type_name); ASSERT_TRUE(dba.InsertEdge(&v1, &v2, r_type).HasValue()); @@ -196,12 +197,12 @@ TEST(TestVariableStartPlanner, MatchOptionalMatchMergeReturn) { } TEST(TestVariableStartPlanner, MatchWithMatchReturn) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Graph (v1) -[:r]-> (v2) - query::VertexAccessor v1(dba.InsertVertex()); - query::VertexAccessor v2(dba.InsertVertex()); + memgraph::query::VertexAccessor v1(dba.InsertVertex()); + memgraph::query::VertexAccessor v2(dba.InsertVertex()); ASSERT_TRUE(dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("r")).HasValue()); dba.AdvanceCommand(); // Test MATCH (n) -[r]-> (m) WITH n MATCH (m) -[r]-> (l) RETURN n, m, l @@ -218,9 +219,9 @@ TEST(TestVariableStartPlanner, MatchWithMatchReturn) { } TEST(TestVariableStartPlanner, MatchVariableExpand) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); // Graph (v1) -[:r1]-> (v2) -[:r2]-> (v3) auto v1 = dba.InsertVertex(); auto v2 = dba.InsertVertex(); @@ -243,17 +244,17 @@ TEST(TestVariableStartPlanner, MatchVariableExpand) { } TEST(TestVariableStartPlanner, MatchVariableExpandReferenceNode) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto id = dba.NameToProperty("id"); // Graph (v1 {id:1}) -[:r1]-> (v2 {id: 2}) -[:r2]-> (v3 {id: 3}) auto v1 = dba.InsertVertex(); - ASSERT_TRUE(v1.SetProperty(id, storage::PropertyValue(1)).HasValue()); + ASSERT_TRUE(v1.SetProperty(id, memgraph::storage::PropertyValue(1)).HasValue()); auto v2 = dba.InsertVertex(); - ASSERT_TRUE(v2.SetProperty(id, storage::PropertyValue(2)).HasValue()); + ASSERT_TRUE(v2.SetProperty(id, memgraph::storage::PropertyValue(2)).HasValue()); auto v3 = dba.InsertVertex(); - ASSERT_TRUE(v3.SetProperty(id, storage::PropertyValue(3)).HasValue()); + ASSERT_TRUE(v3.SetProperty(id, memgraph::storage::PropertyValue(3)).HasValue()); auto r1 = *dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("r1")); auto r2 = *dba.InsertEdge(&v2, &v3, dba.NameToEdgeType("r2")); dba.AdvanceCommand(); @@ -273,13 +274,13 @@ TEST(TestVariableStartPlanner, MatchVariableExpandReferenceNode) { } TEST(TestVariableStartPlanner, MatchVariableExpandBoth) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto id = dba.NameToProperty("id"); // Graph (v1 {id:1}) -[:r1]-> (v2) -[:r2]-> (v3) auto v1 = dba.InsertVertex(); - ASSERT_TRUE(v1.SetProperty(id, storage::PropertyValue(1)).HasValue()); + ASSERT_TRUE(v1.SetProperty(id, memgraph::storage::PropertyValue(1)).HasValue()); auto v2 = dba.InsertVertex(); auto v3 = dba.InsertVertex(); auto r1 = *dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("r1")); @@ -301,24 +302,24 @@ TEST(TestVariableStartPlanner, MatchVariableExpandBoth) { } TEST(TestVariableStartPlanner, MatchBfs) { - storage::Storage db; + memgraph::storage::Storage db; auto storage_dba = db.Access(); - query::DbAccessor dba(&storage_dba); + memgraph::query::DbAccessor dba(&storage_dba); auto id = dba.NameToProperty("id"); // Graph (v1 {id:1}) -[:r1]-> (v2 {id: 2}) -[:r2]-> (v3 {id: 3}) auto v1 = dba.InsertVertex(); - ASSERT_TRUE(v1.SetProperty(id, storage::PropertyValue(1)).HasValue()); + ASSERT_TRUE(v1.SetProperty(id, memgraph::storage::PropertyValue(1)).HasValue()); auto v2 = dba.InsertVertex(); - ASSERT_TRUE(v2.SetProperty(id, storage::PropertyValue(2)).HasValue()); + ASSERT_TRUE(v2.SetProperty(id, memgraph::storage::PropertyValue(2)).HasValue()); auto v3 = dba.InsertVertex(); - ASSERT_TRUE(v3.SetProperty(id, storage::PropertyValue(3)).HasValue()); + ASSERT_TRUE(v3.SetProperty(id, memgraph::storage::PropertyValue(3)).HasValue()); auto r1 = *dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("r1")); ASSERT_TRUE(dba.InsertEdge(&v2, &v3, dba.NameToEdgeType("r2")).HasValue()); dba.AdvanceCommand(); // Test MATCH (n) -[r *bfs..10](r, n | n.id <> 3)]-> (m) RETURN r AstStorage storage; - auto *bfs = storage.Create(IDENT("r"), EdgeAtom::Type::BREADTH_FIRST, Direction::OUT, - std::vector{}); + auto *bfs = storage.Create(IDENT("r"), EdgeAtom::Type::BREADTH_FIRST, Direction::OUT, + std::vector{}); bfs->filter_lambda_.inner_edge = IDENT("r"); bfs->filter_lambda_.inner_node = IDENT("n"); bfs->filter_lambda_.expression = NEQ(PROPERTY_LOOKUP("n", id), LITERAL(3)); diff --git a/tests/unit/ring_buffer.cpp b/tests/unit/ring_buffer.cpp index 7757c3d5c..6f0484384 100644 --- a/tests/unit/ring_buffer.cpp +++ b/tests/unit/ring_buffer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ TEST(RingBuffer, MultithreadedUsage) { auto test_f = [](int producer_count, int elems_per_producer, int producer_sleep_ms, int consumer_count, int consumer_sleep_ms) { std::unordered_set consumed; - utils::SpinLock consumed_lock; + memgraph::utils::SpinLock consumed_lock; RingBuffer buffer{20}; std::vector producers; @@ -40,7 +40,7 @@ TEST(RingBuffer, MultithreadedUsage) { consumers.emplace_back([elem_total_count, consumer_sleep_ms, &buffer, &consumed, &consumed_lock]() { while (true) { std::this_thread::sleep_for(std::chrono::milliseconds(consumer_sleep_ms)); - std::lock_guard guard(consumed_lock); + std::lock_guard guard(consumed_lock); if (consumed.size() == elem_total_count) break; auto value = buffer.pop(); if (value) consumed.emplace(*value); diff --git a/tests/unit/rpc.cpp b/tests/unit/rpc.cpp index c852f09d1..a1ece0f31 100644 --- a/tests/unit/rpc.cpp +++ b/tests/unit/rpc.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,10 +22,10 @@ #include "rpc_messages.hpp" -using namespace rpc; +using namespace memgraph::rpc; using namespace std::literals::chrono_literals; -namespace slk { +namespace memgraph::slk { void Save(const SumReq &sum, Builder *builder) { Save(sum.x, builder); Save(sum.y, builder); @@ -43,30 +43,30 @@ void Load(SumRes *res, Reader *reader) { Load(&res->sum, reader); } void Save(const EchoMessage &echo, Builder *builder) { Save(echo.data, builder); } void Load(EchoMessage *echo, Reader *reader) { Load(&echo->data, reader); } -} // namespace slk +} // namespace memgraph::slk -void SumReq::Load(SumReq *obj, slk::Reader *reader) { slk::Load(obj, reader); } -void SumReq::Save(const SumReq &obj, slk::Builder *builder) { slk::Save(obj, builder); } +void SumReq::Load(SumReq *obj, memgraph::slk::Reader *reader) { memgraph::slk::Load(obj, reader); } +void SumReq::Save(const SumReq &obj, memgraph::slk::Builder *builder) { memgraph::slk::Save(obj, builder); } -void SumRes::Load(SumRes *obj, slk::Reader *reader) { slk::Load(obj, reader); } -void SumRes::Save(const SumRes &obj, slk::Builder *builder) { slk::Save(obj, builder); } +void SumRes::Load(SumRes *obj, memgraph::slk::Reader *reader) { memgraph::slk::Load(obj, reader); } +void SumRes::Save(const SumRes &obj, memgraph::slk::Builder *builder) { memgraph::slk::Save(obj, builder); } -void EchoMessage::Load(EchoMessage *obj, slk::Reader *reader) { slk::Load(obj, reader); } -void EchoMessage::Save(const EchoMessage &obj, slk::Builder *builder) { slk::Save(obj, builder); } +void EchoMessage::Load(EchoMessage *obj, memgraph::slk::Reader *reader) { memgraph::slk::Load(obj, reader); } +void EchoMessage::Save(const EchoMessage &obj, memgraph::slk::Builder *builder) { memgraph::slk::Save(obj, builder); } TEST(Rpc, Call) { - communication::ServerContext server_context; + memgraph::communication::ServerContext server_context; Server server({"127.0.0.1", 0}, &server_context); server.Register([](auto *req_reader, auto *res_builder) { SumReq req; - slk::Load(&req, req_reader); + memgraph::slk::Load(&req, req_reader); SumRes res(req.x + req.y); - slk::Save(res, res_builder); + memgraph::slk::Save(res, res_builder); }); ASSERT_TRUE(server.Start()); std::this_thread::sleep_for(100ms); - communication::ClientContext client_context; + memgraph::communication::ClientContext client_context; Client client(server.endpoint(), &client_context); auto sum = client.Call(10, 20); EXPECT_EQ(sum.sum, 30); @@ -76,19 +76,19 @@ TEST(Rpc, Call) { } TEST(Rpc, Abort) { - communication::ServerContext server_context; + memgraph::communication::ServerContext server_context; Server server({"127.0.0.1", 0}, &server_context); server.Register([](auto *req_reader, auto *res_builder) { SumReq req; - slk::Load(&req, req_reader); + memgraph::slk::Load(&req, req_reader); std::this_thread::sleep_for(500ms); SumRes res(req.x + req.y); - slk::Save(res, res_builder); + memgraph::slk::Save(res, res_builder); }); ASSERT_TRUE(server.Start()); std::this_thread::sleep_for(100ms); - communication::ClientContext client_context; + memgraph::communication::ClientContext client_context; Client client(server.endpoint(), &client_context); std::thread thread([&client]() { @@ -97,7 +97,7 @@ TEST(Rpc, Abort) { client.Abort(); }); - utils::Timer timer; + memgraph::utils::Timer timer; EXPECT_THROW(client.Call(10, 20), RpcFailedException); EXPECT_LT(timer.Elapsed(), 200ms); @@ -108,7 +108,7 @@ TEST(Rpc, Abort) { } TEST(Rpc, ClientPool) { - communication::ServerContext server_context; + memgraph::communication::ServerContext server_context; Server server({"127.0.0.1", 0}, &server_context); server.Register([](const auto &req_reader, auto *res_builder) { SumReq req; @@ -120,7 +120,7 @@ TEST(Rpc, ClientPool) { ASSERT_TRUE(server.Start()); std::this_thread::sleep_for(100ms); - communication::ClientContext client_context; + memgraph::communication::ClientContext client_context; Client client(server.endpoint(), &client_context); // These calls should take more than 400ms because we're using a regular @@ -130,7 +130,7 @@ TEST(Rpc, ClientPool) { EXPECT_EQ(sum.sum, x + y); }; - utils::Timer t1; + memgraph::utils::Timer t1; std::vector threads; for (int i = 0; i < 4; ++i) { threads.emplace_back(get_sum_client, 2 * i, 2 * i + 1); @@ -142,7 +142,7 @@ TEST(Rpc, ClientPool) { EXPECT_GE(t1.Elapsed(), 400ms); - communication::ClientContext pool_context; + memgraph::communication::ClientContext pool_context; ClientPool pool(server.endpoint(), &pool_context); // These calls shouldn't take much more that 100ms because they execute in @@ -152,7 +152,7 @@ TEST(Rpc, ClientPool) { EXPECT_EQ(sum.sum, x + y); }; - utils::Timer t2; + memgraph::utils::Timer t2; for (int i = 0; i < 4; ++i) { threads.emplace_back(get_sum, 2 * i, 2 * i + 1); } @@ -166,19 +166,19 @@ TEST(Rpc, ClientPool) { } TEST(Rpc, LargeMessage) { - communication::ServerContext server_context; + memgraph::communication::ServerContext server_context; Server server({"127.0.0.1", 0}, &server_context); server.Register([](auto *req_reader, auto *res_builder) { EchoMessage res; - slk::Load(&res, req_reader); - slk::Save(res, res_builder); + memgraph::slk::Load(&res, req_reader); + memgraph::slk::Save(res, res_builder); }); ASSERT_TRUE(server.Start()); std::this_thread::sleep_for(100ms); std::string testdata(100000, 'a'); - communication::ClientContext client_context; + memgraph::communication::ClientContext client_context; Client client(server.endpoint(), &client_context); auto echo = client.Call(testdata); EXPECT_EQ(echo.data, testdata); @@ -188,12 +188,12 @@ TEST(Rpc, LargeMessage) { } TEST(Rpc, JumboMessage) { - communication::ServerContext server_context; + memgraph::communication::ServerContext server_context; Server server({"127.0.0.1", 0}, &server_context); server.Register([](auto *req_reader, auto *res_builder) { EchoMessage res; - slk::Load(&res, req_reader); - slk::Save(res, res_builder); + memgraph::slk::Load(&res, req_reader); + memgraph::slk::Save(res, res_builder); }); ASSERT_TRUE(server.Start()); std::this_thread::sleep_for(100ms); @@ -201,7 +201,7 @@ TEST(Rpc, JumboMessage) { // NOLINTNEXTLINE (bugprone-string-constructor) std::string testdata(10000000, 'a'); - communication::ClientContext client_context; + memgraph::communication::ClientContext client_context; Client client(server.endpoint(), &client_context); auto echo = client.Call(testdata); EXPECT_EQ(echo.data, testdata); @@ -211,23 +211,23 @@ TEST(Rpc, JumboMessage) { } TEST(Rpc, Stream) { - communication::ServerContext server_context; + memgraph::communication::ServerContext server_context; Server server({"127.0.0.1", 0}, &server_context); server.Register([](auto *req_reader, auto *res_builder) { EchoMessage req; - slk::Load(&req, req_reader); + memgraph::slk::Load(&req, req_reader); std::string payload; - slk::Load(&payload, req_reader); + memgraph::slk::Load(&payload, req_reader); EchoMessage res(req.data + payload); - slk::Save(res, res_builder); + memgraph::slk::Save(res, res_builder); }); ASSERT_TRUE(server.Start()); std::this_thread::sleep_for(100ms); - communication::ClientContext client_context; + memgraph::communication::ClientContext client_context; Client client(server.endpoint(), &client_context); auto stream = client.Stream("hello"); - slk::Save("world", stream.GetBuilder()); + memgraph::slk::Save("world", stream.GetBuilder()); auto echo = stream.AwaitResponse(); EXPECT_EQ(echo.data, "helloworld"); @@ -236,15 +236,15 @@ TEST(Rpc, Stream) { } TEST(Rpc, StreamLarge) { - communication::ServerContext server_context; + memgraph::communication::ServerContext server_context; Server server({"127.0.0.1", 0}, &server_context); server.Register([](auto *req_reader, auto *res_builder) { EchoMessage req; - slk::Load(&req, req_reader); + memgraph::slk::Load(&req, req_reader); std::string payload; - slk::Load(&payload, req_reader); + memgraph::slk::Load(&payload, req_reader); EchoMessage res(req.data + payload); - slk::Save(res, res_builder); + memgraph::slk::Save(res, res_builder); }); ASSERT_TRUE(server.Start()); std::this_thread::sleep_for(100ms); @@ -252,10 +252,10 @@ TEST(Rpc, StreamLarge) { std::string testdata1(50000, 'a'); std::string testdata2(50000, 'b'); - communication::ClientContext client_context; + memgraph::communication::ClientContext client_context; Client client(server.endpoint(), &client_context); auto stream = client.Stream(testdata1); - slk::Save(testdata2, stream.GetBuilder()); + memgraph::slk::Save(testdata2, stream.GetBuilder()); auto echo = stream.AwaitResponse(); EXPECT_EQ(echo.data, testdata1 + testdata2); @@ -264,15 +264,15 @@ TEST(Rpc, StreamLarge) { } TEST(Rpc, StreamJumbo) { - communication::ServerContext server_context; + memgraph::communication::ServerContext server_context; Server server({"127.0.0.1", 0}, &server_context); server.Register([](auto *req_reader, auto *res_builder) { EchoMessage req; - slk::Load(&req, req_reader); + memgraph::slk::Load(&req, req_reader); std::string payload; - slk::Load(&payload, req_reader); + memgraph::slk::Load(&payload, req_reader); EchoMessage res(req.data + payload); - slk::Save(res, res_builder); + memgraph::slk::Save(res, res_builder); }); ASSERT_TRUE(server.Start()); std::this_thread::sleep_for(100ms); @@ -282,10 +282,10 @@ TEST(Rpc, StreamJumbo) { // NOLINTNEXTLINE (bugprone-string-constructor) std::string testdata2(5000000, 'b'); - communication::ClientContext client_context; + memgraph::communication::ClientContext client_context; Client client(server.endpoint(), &client_context); auto stream = client.Stream(testdata1); - slk::Save(testdata2, stream.GetBuilder()); + memgraph::slk::Save(testdata2, stream.GetBuilder()); auto echo = stream.AwaitResponse(); EXPECT_EQ(echo.data, testdata1 + testdata2); diff --git a/tests/unit/rpc_messages.hpp b/tests/unit/rpc_messages.hpp index 8c734de1f..aa8b89fe3 100644 --- a/tests/unit/rpc_messages.hpp +++ b/tests/unit/rpc_messages.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,61 +16,61 @@ #include "utils/typeinfo.hpp" struct SumReq { - static const utils::TypeInfo kType; + static const memgraph::utils::TypeInfo kType; SumReq() {} // Needed for serialization. SumReq(int x, int y) : x(x), y(y) {} - static void Load(SumReq *obj, slk::Reader *reader); - static void Save(const SumReq &obj, slk::Builder *builder); + static void Load(SumReq *obj, memgraph::slk::Reader *reader); + static void Save(const SumReq &obj, memgraph::slk::Builder *builder); int x; int y; }; -const utils::TypeInfo SumReq::kType{0, "SumReq"}; +const memgraph::utils::TypeInfo SumReq::kType{0, "SumReq"}; struct SumRes { - static const utils::TypeInfo kType; + static const memgraph::utils::TypeInfo kType; SumRes() {} // Needed for serialization. SumRes(int sum) : sum(sum) {} - static void Load(SumRes *obj, slk::Reader *reader); - static void Save(const SumRes &obj, slk::Builder *builder); + static void Load(SumRes *obj, memgraph::slk::Reader *reader); + static void Save(const SumRes &obj, memgraph::slk::Builder *builder); int sum; }; -const utils::TypeInfo SumRes::kType{1, "SumRes"}; +const memgraph::utils::TypeInfo SumRes::kType{1, "SumRes"}; -namespace slk { +namespace memgraph::slk { void Save(const SumReq &sum, Builder *builder); void Load(SumReq *sum, Reader *reader); void Save(const SumRes &res, Builder *builder); void Load(SumRes *res, Reader *reader); -} // namespace slk +} // namespace memgraph::slk -using Sum = rpc::RequestResponse; +using Sum = memgraph::rpc::RequestResponse; struct EchoMessage { - static const utils::TypeInfo kType; + static const memgraph::utils::TypeInfo kType; EchoMessage() {} // Needed for serialization. EchoMessage(const std::string &data) : data(data) {} - static void Load(EchoMessage *obj, slk::Reader *reader); - static void Save(const EchoMessage &obj, slk::Builder *builder); + static void Load(EchoMessage *obj, memgraph::slk::Reader *reader); + static void Save(const EchoMessage &obj, memgraph::slk::Builder *builder); std::string data; }; -const utils::TypeInfo EchoMessage::kType{2, "EchoMessage"}; +const memgraph::utils::TypeInfo EchoMessage::kType{2, "EchoMessage"}; -namespace slk { +namespace memgraph::slk { void Save(const EchoMessage &echo, Builder *builder); void Load(EchoMessage *echo, Reader *reader); -} // namespace slk +} // namespace memgraph::slk -using Echo = rpc::RequestResponse; +using Echo = memgraph::rpc::RequestResponse; diff --git a/tests/unit/skip_list.cpp b/tests/unit/skip_list.cpp index a367a61c7..86fb4ae57 100644 --- a/tests/unit/skip_list.cpp +++ b/tests/unit/skip_list.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,7 +19,7 @@ #include "utils/timer.hpp" TEST(SkipList, Int) { - utils::SkipList list; + memgraph::utils::SkipList list; { auto acc = list.access(); for (int64_t i = -10; i <= 10; ++i) { @@ -74,7 +74,7 @@ TEST(SkipList, Int) { } TEST(SkipList, String) { - utils::SkipList list; + memgraph::utils::SkipList list; { auto acc = list.access(); for (int64_t i = -10; i <= 10; ++i) { @@ -138,7 +138,7 @@ TEST(SkipList, String) { } TEST(SkipList, StringMove) { - utils::SkipList list; + memgraph::utils::SkipList list; { auto acc = list.access(); for (int64_t i = -10; i <= 10; ++i) { @@ -165,7 +165,7 @@ TEST(SkipList, StringMove) { } TEST(SkipList, Basic) { - utils::SkipList list; + memgraph::utils::SkipList list; auto acc = list.access(); @@ -216,7 +216,7 @@ bool operator==(const OnlyCopyable &a, const OnlyCopyable &b) { return a.value = bool operator<(const OnlyCopyable &a, const OnlyCopyable &b) { return a.value < b.value; } TEST(SkipList, OnlyCopyable) { - utils::SkipList list; + memgraph::utils::SkipList list; std::vector vec{{1}, {2}, {3}, {4}, {5}}; auto acc = list.access(); auto ret = acc.insert(vec[1]); @@ -239,7 +239,7 @@ bool operator==(const OnlyMoveable &a, const OnlyMoveable &b) { return a.value = bool operator<(const OnlyMoveable &a, const OnlyMoveable &b) { return a.value < b.value; } TEST(SkipList, OnlyMoveable) { - utils::SkipList list; + memgraph::utils::SkipList list; std::vector vec; vec.push_back({1}); vec.push_back({2}); @@ -251,9 +251,9 @@ TEST(SkipList, OnlyMoveable) { } TEST(SkipList, Const) { - utils::SkipList list; + memgraph::utils::SkipList list; - auto func = [](const utils::SkipList &lst) { + auto func = [](const memgraph::utils::SkipList &lst) { auto acc = lst.access(); return acc.find(5); }; @@ -275,7 +275,7 @@ bool operator==(const MapObject &a, const uint64_t &b) { return a.key == b; } bool operator<(const MapObject &a, const uint64_t &b) { return a.key < b; } TEST(SkipList, MapExample) { - utils::SkipList list; + memgraph::utils::SkipList list; { auto accessor = list.access(); @@ -306,7 +306,7 @@ TEST(SkipList, MapExample) { } TEST(SkipList, Move) { - utils::SkipList list; + memgraph::utils::SkipList list; { auto acc = list.access(); @@ -327,7 +327,7 @@ TEST(SkipList, Move) { ASSERT_EQ(acc.size(), 2001); } - utils::SkipList moved(std::move(list)); + memgraph::utils::SkipList moved(std::move(list)); { auto acc = moved.access(); @@ -348,7 +348,7 @@ TEST(SkipList, Move) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(SkipList, Clear) { - utils::SkipList list; + memgraph::utils::SkipList list; { auto acc = list.access(); @@ -403,7 +403,7 @@ TEST(SkipList, Clear) { struct Inception { uint64_t id; - utils::SkipList data; + memgraph::utils::SkipList data; }; bool operator==(const Inception &a, const Inception &b) { return a.id == b.id; } bool operator<(const Inception &a, const Inception &b) { return a.id < b.id; } @@ -411,11 +411,11 @@ bool operator==(const Inception &a, const uint64_t &b) { return a.id == b; } bool operator<(const Inception &a, const uint64_t &b) { return a.id < b; } TEST(SkipList, Inception) { - utils::SkipList list; + memgraph::utils::SkipList list; { for (uint64_t i = 0; i < 5; ++i) { - utils::SkipList inner; + memgraph::utils::SkipList inner; auto acc_inner = inner.access(); for (uint64_t j = 0; j < 100; ++j) { acc_inner.insert(j + 1000 * i); @@ -447,7 +447,7 @@ TEST(SkipList, Inception) { } TEST(SkipList, FindEqualOrGreater) { - utils::SkipList list; + memgraph::utils::SkipList list; { auto acc = list.access(); @@ -492,7 +492,7 @@ bool operator==(const Counter &a, int64_t b) { return a.key == b; } bool operator<(const Counter &a, int64_t b) { return a.key < b; } TEST(SkipList, EstimateCount) { - utils::SkipList list; + memgraph::utils::SkipList list; // 100k elements will yield an expected maximum height of 17 const int kMaxElements = 100; @@ -514,7 +514,7 @@ TEST(SkipList, EstimateCount) { { uint64_t delta_min = std::numeric_limits::max(), delta_max = 0, delta_avg = 0; auto acc = list.access(); - utils::Timer timer; + memgraph::utils::Timer timer; for (int64_t i = 0; i < kMaxElements; ++i) { uint64_t count = acc.estimate_count(i); uint64_t delta = count >= kElementMembers ? count - kElementMembers : kElementMembers - count; @@ -542,51 +542,51 @@ TEST(SkipList, EstimateCount) { } } -#define MAKE_RANGE_BOTH_DEFINED_TEST(lower, upper) \ - { \ - for (int64_t i = 0; i < 10; ++i) { \ - for (int64_t j = 0; j < 10; ++j) { \ - auto acc = list.access(); \ - uint64_t blocks = 0; \ - if (utils::BoundType::lower == utils::BoundType::EXCLUSIVE && \ - utils::BoundType::upper == utils::BoundType::EXCLUSIVE) { \ - if (j > i) { \ - blocks = j - i - 1; \ - } \ - } else { \ - if (j >= i) { \ - blocks = j - i; \ - if (utils::BoundType::lower == utils::BoundType::INCLUSIVE && \ - utils::BoundType::upper == utils::BoundType::INCLUSIVE) { \ - ++blocks; \ - } \ - } \ - } \ - uint64_t count = \ - acc.estimate_range_count({{i, utils::BoundType::lower}}, {{j, utils::BoundType::upper}}, 1); \ - ASSERT_EQ(count, kElementMembers *blocks); \ - } \ - } \ +#define MAKE_RANGE_BOTH_DEFINED_TEST(lower, upper) \ + { \ + for (int64_t i = 0; i < 10; ++i) { \ + for (int64_t j = 0; j < 10; ++j) { \ + auto acc = list.access(); \ + uint64_t blocks = 0; \ + if (memgraph::utils::BoundType::lower == memgraph::utils::BoundType::EXCLUSIVE && \ + memgraph::utils::BoundType::upper == memgraph::utils::BoundType::EXCLUSIVE) { \ + if (j > i) { \ + blocks = j - i - 1; \ + } \ + } else { \ + if (j >= i) { \ + blocks = j - i; \ + if (memgraph::utils::BoundType::lower == memgraph::utils::BoundType::INCLUSIVE && \ + memgraph::utils::BoundType::upper == memgraph::utils::BoundType::INCLUSIVE) { \ + ++blocks; \ + } \ + } \ + } \ + uint64_t count = acc.estimate_range_count({{i, memgraph::utils::BoundType::lower}}, \ + {{j, memgraph::utils::BoundType::upper}}, 1); \ + ASSERT_EQ(count, kElementMembers *blocks); \ + } \ + } \ } -#define MAKE_RANGE_LOWER_INFINITY_TEST(upper_value, upper_type, blocks) \ - { \ - auto acc = list.access(); \ - uint64_t count = \ - acc.estimate_range_count(std::nullopt, {{upper_value, utils::BoundType::upper_type}}, 1); \ - ASSERT_EQ(count, kElementMembers *blocks); \ +#define MAKE_RANGE_LOWER_INFINITY_TEST(upper_value, upper_type, blocks) \ + { \ + auto acc = list.access(); \ + uint64_t count = \ + acc.estimate_range_count(std::nullopt, {{upper_value, memgraph::utils::BoundType::upper_type}}, 1); \ + ASSERT_EQ(count, kElementMembers *blocks); \ } -#define MAKE_RANGE_UPPER_INFINITY_TEST(lower_value, lower_type, blocks) \ - { \ - auto acc = list.access(); \ - uint64_t count = \ - acc.estimate_range_count({{lower_value, utils::BoundType::lower_type}}, std::nullopt, 1); \ - ASSERT_EQ(count, kElementMembers *blocks); \ +#define MAKE_RANGE_UPPER_INFINITY_TEST(lower_value, lower_type, blocks) \ + { \ + auto acc = list.access(); \ + uint64_t count = \ + acc.estimate_range_count({{lower_value, memgraph::utils::BoundType::lower_type}}, std::nullopt, 1); \ + ASSERT_EQ(count, kElementMembers *blocks); \ } TEST(SkipList, EstimateRangeCount) { - utils::SkipList list; + memgraph::utils::SkipList list; // 100k elements will yield an expected maximum height of 17 const int kMaxElements = 100; @@ -608,9 +608,9 @@ TEST(SkipList, EstimateRangeCount) { { uint64_t delta_min = std::numeric_limits::max(), delta_max = 0, delta_avg = 0; auto acc = list.access(); - utils::Timer timer; + memgraph::utils::Timer timer; for (int64_t i = 0; i < kMaxElements; ++i) { - uint64_t count = acc.estimate_range_count(std::nullopt, {{i, utils::BoundType::INCLUSIVE}}); + uint64_t count = acc.estimate_range_count(std::nullopt, {{i, memgraph::utils::BoundType::INCLUSIVE}}); uint64_t must_have = kElementMembers * (i + 1); uint64_t delta = count >= must_have ? count - must_have : must_have - count; delta_min = std::min(delta_min, delta); @@ -655,12 +655,13 @@ TEST(SkipList, EstimateRangeCount) { } template -void BenchmarkEstimateAverageNumberOfEquals(utils::SkipList *list, const TCmp &cmp) { +void BenchmarkEstimateAverageNumberOfEquals(memgraph::utils::SkipList *list, const TCmp &cmp) { std::cout << "List size: " << list->size() << std::endl; - std::cout << "The index will use layer " << utils::SkipListLayerForAverageEqualsEstimation(list->size()) << std::endl; + std::cout << "The index will use layer " << memgraph::utils::SkipListLayerForAverageEqualsEstimation(list->size()) + << std::endl; auto acc = list->access(); - for (int layer = 1; layer <= utils::kSkipListMaxHeight; ++layer) { - utils::Timer timer; + for (int layer = 1; layer <= memgraph::utils::kSkipListMaxHeight; ++layer) { + memgraph::utils::Timer timer; auto estimate = acc.estimate_average_number_of_equals(cmp, layer); auto duration = timer.Elapsed().count(); std::cout << "Estimate on layer " << layer << " is " << estimate << " in " << duration << std::endl; @@ -668,7 +669,7 @@ void BenchmarkEstimateAverageNumberOfEquals(utils::SkipList *list, const } TEST(SkipList, EstimateAverageNumberOfEquals1) { - utils::SkipList list; + memgraph::utils::SkipList list; // ~500k elements will yield an expected maximum height of 19. const int kMaxElements = 1000; @@ -708,7 +709,7 @@ TEST(SkipList, EstimateAverageNumberOfEquals1) { } TEST(SkipList, EstimateAverageNumberOfEquals2) { - utils::SkipList list; + memgraph::utils::SkipList list; // 100k elements will yield an expected maximum height of 17. const int kMaxElements = 100000; @@ -745,7 +746,7 @@ TEST(SkipList, EstimateAverageNumberOfEquals2) { } TEST(SkipList, EstimateAverageNumberOfEquals3) { - utils::SkipList list; + memgraph::utils::SkipList list; // 100k elements will yield an expected maximum height of 17 const int kMaxElements = 100; @@ -782,7 +783,7 @@ TEST(SkipList, EstimateAverageNumberOfEquals3) { } TEST(SkipList, EstimateAverageNumberOfEquals4) { - utils::SkipList list; + memgraph::utils::SkipList list; // ~300k elements will yield an expected maximum height of 18. const int kMaxElements = 100000; @@ -822,7 +823,7 @@ TEST(SkipList, EstimateAverageNumberOfEquals4) { } TEST(SkipList, EstimateAverageNumberOfEquals5) { - utils::SkipList list; + memgraph::utils::SkipList list; // ~500k elements will yield an expected maximum height of 19. const int kMaxElements = 1000000; diff --git a/tests/unit/slk_advanced.cpp b/tests/unit/slk_advanced.cpp index 6a2f5ed66..fab936fe0 100644 --- a/tests/unit/slk_advanced.cpp +++ b/tests/unit/slk_advanced.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,97 +18,99 @@ #include "storage/v2/temporal.hpp" TEST(SlkAdvanced, PropertyValueList) { - std::vector original{ - storage::PropertyValue("hello world!"), - storage::PropertyValue(5), - storage::PropertyValue(1.123423), - storage::PropertyValue(true), - storage::PropertyValue(), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))}; - ASSERT_EQ(original[0].type(), storage::PropertyValue::Type::String); - ASSERT_EQ(original[1].type(), storage::PropertyValue::Type::Int); - ASSERT_EQ(original[2].type(), storage::PropertyValue::Type::Double); - ASSERT_EQ(original[3].type(), storage::PropertyValue::Type::Bool); - ASSERT_EQ(original[4].type(), storage::PropertyValue::Type::Null); - ASSERT_EQ(original[5].type(), storage::PropertyValue::Type::TemporalData); + std::vector original{ + memgraph::storage::PropertyValue("hello world!"), + memgraph::storage::PropertyValue(5), + memgraph::storage::PropertyValue(1.123423), + memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))}; + ASSERT_EQ(original[0].type(), memgraph::storage::PropertyValue::Type::String); + ASSERT_EQ(original[1].type(), memgraph::storage::PropertyValue::Type::Int); + ASSERT_EQ(original[2].type(), memgraph::storage::PropertyValue::Type::Double); + ASSERT_EQ(original[3].type(), memgraph::storage::PropertyValue::Type::Bool); + ASSERT_EQ(original[4].type(), memgraph::storage::PropertyValue::Type::Null); + ASSERT_EQ(original[5].type(), memgraph::storage::PropertyValue::Type::TemporalData); - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); - std::vector decoded; + std::vector decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); } TEST(SlkAdvanced, PropertyValueMap) { - std::map original{ - {"hello", storage::PropertyValue("world")}, - {"number", storage::PropertyValue(5)}, - {"real", storage::PropertyValue(1.123423)}, - {"truth", storage::PropertyValue(true)}, - {"nothing", storage::PropertyValue()}, - {"date", storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))}}; - ASSERT_EQ(original["hello"].type(), storage::PropertyValue::Type::String); - ASSERT_EQ(original["number"].type(), storage::PropertyValue::Type::Int); - ASSERT_EQ(original["real"].type(), storage::PropertyValue::Type::Double); - ASSERT_EQ(original["truth"].type(), storage::PropertyValue::Type::Bool); - ASSERT_EQ(original["nothing"].type(), storage::PropertyValue::Type::Null); - ASSERT_EQ(original["date"].type(), storage::PropertyValue::Type::TemporalData); + std::map original{ + {"hello", memgraph::storage::PropertyValue("world")}, + {"number", memgraph::storage::PropertyValue(5)}, + {"real", memgraph::storage::PropertyValue(1.123423)}, + {"truth", memgraph::storage::PropertyValue(true)}, + {"nothing", memgraph::storage::PropertyValue()}, + {"date", + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))}}; + ASSERT_EQ(original["hello"].type(), memgraph::storage::PropertyValue::Type::String); + ASSERT_EQ(original["number"].type(), memgraph::storage::PropertyValue::Type::Int); + ASSERT_EQ(original["real"].type(), memgraph::storage::PropertyValue::Type::Double); + ASSERT_EQ(original["truth"].type(), memgraph::storage::PropertyValue::Type::Bool); + ASSERT_EQ(original["nothing"].type(), memgraph::storage::PropertyValue::Type::Null); + ASSERT_EQ(original["date"].type(), memgraph::storage::PropertyValue::Type::TemporalData); - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); - std::map decoded; + std::map decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); } TEST(SlkAdvanced, PropertyValueComplex) { - std::vector vec_v{ - storage::PropertyValue("hello world!"), - storage::PropertyValue(5), - storage::PropertyValue(1.123423), - storage::PropertyValue(true), - storage::PropertyValue(), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))}; - ASSERT_EQ(vec_v[0].type(), storage::PropertyValue::Type::String); - ASSERT_EQ(vec_v[1].type(), storage::PropertyValue::Type::Int); - ASSERT_EQ(vec_v[2].type(), storage::PropertyValue::Type::Double); - ASSERT_EQ(vec_v[3].type(), storage::PropertyValue::Type::Bool); - ASSERT_EQ(vec_v[4].type(), storage::PropertyValue::Type::Null); - ASSERT_EQ(vec_v[5].type(), storage::PropertyValue::Type::TemporalData); + std::vector vec_v{ + memgraph::storage::PropertyValue("hello world!"), + memgraph::storage::PropertyValue(5), + memgraph::storage::PropertyValue(1.123423), + memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))}; + ASSERT_EQ(vec_v[0].type(), memgraph::storage::PropertyValue::Type::String); + ASSERT_EQ(vec_v[1].type(), memgraph::storage::PropertyValue::Type::Int); + ASSERT_EQ(vec_v[2].type(), memgraph::storage::PropertyValue::Type::Double); + ASSERT_EQ(vec_v[3].type(), memgraph::storage::PropertyValue::Type::Bool); + ASSERT_EQ(vec_v[4].type(), memgraph::storage::PropertyValue::Type::Null); + ASSERT_EQ(vec_v[5].type(), memgraph::storage::PropertyValue::Type::TemporalData); - std::map map_v{ - {"hello", storage::PropertyValue("world")}, - {"number", storage::PropertyValue(5)}, - {"real", storage::PropertyValue(1.123423)}, - {"truth", storage::PropertyValue(true)}, - {"nothing", storage::PropertyValue()}, - {"date", storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))}}; - ASSERT_EQ(map_v["hello"].type(), storage::PropertyValue::Type::String); - ASSERT_EQ(map_v["number"].type(), storage::PropertyValue::Type::Int); - ASSERT_EQ(map_v["real"].type(), storage::PropertyValue::Type::Double); - ASSERT_EQ(map_v["truth"].type(), storage::PropertyValue::Type::Bool); - ASSERT_EQ(map_v["nothing"].type(), storage::PropertyValue::Type::Null); - ASSERT_EQ(map_v["date"].type(), storage::PropertyValue::Type::TemporalData); + std::map map_v{ + {"hello", memgraph::storage::PropertyValue("world")}, + {"number", memgraph::storage::PropertyValue(5)}, + {"real", memgraph::storage::PropertyValue(1.123423)}, + {"truth", memgraph::storage::PropertyValue(true)}, + {"nothing", memgraph::storage::PropertyValue()}, + {"date", + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))}}; + ASSERT_EQ(map_v["hello"].type(), memgraph::storage::PropertyValue::Type::String); + ASSERT_EQ(map_v["number"].type(), memgraph::storage::PropertyValue::Type::Int); + ASSERT_EQ(map_v["real"].type(), memgraph::storage::PropertyValue::Type::Double); + ASSERT_EQ(map_v["truth"].type(), memgraph::storage::PropertyValue::Type::Bool); + ASSERT_EQ(map_v["nothing"].type(), memgraph::storage::PropertyValue::Type::Null); + ASSERT_EQ(map_v["date"].type(), memgraph::storage::PropertyValue::Type::TemporalData); - storage::PropertyValue original( - std::vector{storage::PropertyValue(vec_v), storage::PropertyValue(map_v)}); - ASSERT_EQ(original.type(), storage::PropertyValue::Type::List); + memgraph::storage::PropertyValue original(std::vector{ + memgraph::storage::PropertyValue(vec_v), memgraph::storage::PropertyValue(map_v)}); + ASSERT_EQ(original.type(), memgraph::storage::PropertyValue::Type::List); - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); - storage::PropertyValue decoded; + memgraph::storage::PropertyValue decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); } diff --git a/tests/unit/slk_common.hpp b/tests/unit/slk_common.hpp index 54b3934af..d18ddb628 100644 --- a/tests/unit/slk_common.hpp +++ b/tests/unit/slk_common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,11 +22,11 @@ #include "slk/streams.hpp" #include "utils/logging.hpp" -namespace slk { +namespace memgraph::slk { -/// Class used for SLK tests. It creates a `slk::Builder` that can be written +/// Class used for SLK tests. It creates a `memgraph::slk::Builder` that can be written /// to. After you have written the data to the builder, you can get a -/// `slk::Reader` and try to decode the encoded data. +/// `memgraph::slk::Reader` and try to decode the encoded data. class Loopback { public: ~Loopback() { @@ -35,23 +35,23 @@ class Loopback { reader_->Finalize(); } - slk::Builder *GetBuilder() { + memgraph::slk::Builder *GetBuilder() { MG_ASSERT(!builder_, "You have already allocated a builder!"); - builder_ = std::make_unique( + builder_ = std::make_unique( [this](const uint8_t *data, size_t size, bool have_more) { Write(data, size, have_more); }); return builder_.get(); } - slk::Reader *GetReader() { + memgraph::slk::Reader *GetReader() { MG_ASSERT(builder_, "You must first get a builder before getting a reader!"); MG_ASSERT(!reader_, "You have already allocated a reader!"); builder_->Finalize(); - auto ret = slk::CheckStreamComplete(data_.data(), data_.size()); - MG_ASSERT(ret.status == slk::StreamStatus::COMPLETE); + auto ret = memgraph::slk::CheckStreamComplete(data_.data(), data_.size()); + MG_ASSERT(ret.status == memgraph::slk::StreamStatus::COMPLETE); MG_ASSERT(ret.stream_size == data_.size()); size_ = ret.encoded_data_size; Dump(); - reader_ = std::make_unique(data_.data(), data_.size()); + reader_ = std::make_unique(data_.data(), data_.size()); return reader_.get(); } @@ -79,9 +79,9 @@ class Loopback { } std::vector data_; - std::unique_ptr builder_; - std::unique_ptr reader_; + std::unique_ptr builder_; + std::unique_ptr reader_; size_t size_{0}; }; -} // namespace slk +} // namespace memgraph::slk diff --git a/tests/unit/slk_core.cpp b/tests/unit/slk_core.cpp index 823321317..65b916db3 100644 --- a/tests/unit/slk_core.cpp +++ b/tests/unit/slk_core.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,12 +19,12 @@ { \ ASSERT_NE(original_value, decoded_value); \ primitive_type original = original_value; \ - slk::Loopback loopback; \ + memgraph::slk::Loopback loopback; \ auto builder = loopback.GetBuilder(); \ - slk::Save(original, builder); \ + memgraph::slk::Save(original, builder); \ primitive_type decoded = decoded_value; \ auto reader = loopback.GetReader(); \ - slk::Load(&decoded, reader); \ + memgraph::slk::Load(&decoded, reader); \ ASSERT_EQ(original, decoded); \ ASSERT_EQ(loopback.size(), sizeof(primitive_type)); \ } @@ -45,101 +45,101 @@ TEST(SlkCore, Primitive) { TEST(SlkCore, String) { std::string original = "hello world"; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::string decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), sizeof(uint64_t) + original.size()); } TEST(SlkCore, ConstStringLiteral) { const char *original = "hello world"; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::string decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), sizeof(uint64_t) + strlen(original)); } TEST(SlkCore, VectorPrimitive) { std::vector original{1, 2, 3, 4, 5}; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::vector decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), sizeof(uint64_t) + original.size() * sizeof(int)); } TEST(SlkCore, VectorString) { std::vector original{"hai hai hai", "nandare!"}; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); uint64_t size = sizeof(uint64_t); for (const auto &item : original) { size += sizeof(uint64_t) + item.size(); } std::vector decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), size); } TEST(SlkCore, SetPrimitive) { std::set original{1, 2, 3, 4, 5}; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::set decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), sizeof(uint64_t) + original.size() * sizeof(int)); } TEST(SlkCore, SetString) { std::set original{"hai hai hai", "nandare!"}; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); uint64_t size = sizeof(uint64_t); for (const auto &item : original) { size += sizeof(uint64_t) + item.size(); } std::set decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), size); } TEST(SlkCore, MapPrimitive) { std::map original{{1, 2}, {3, 4}, {5, 6}}; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::map decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), sizeof(uint64_t) + original.size() * sizeof(int) * 2); } TEST(SlkCore, MapString) { std::map original{{"hai hai hai", "nandare!"}}; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); uint64_t size = sizeof(uint64_t); for (const auto &item : original) { size += sizeof(uint64_t) + item.first.size(); @@ -147,28 +147,28 @@ TEST(SlkCore, MapString) { } std::map decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), size); } TEST(SlkCore, UnorderedMapPrimitive) { std::unordered_map original{{1, 2}, {3, 4}, {5, 6}}; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::unordered_map decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), sizeof(uint64_t) + original.size() * sizeof(int) * 2); } TEST(SlkCore, UnorderedMapString) { std::unordered_map original{{"hai hai hai", "nandare!"}}; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); uint64_t size = sizeof(uint64_t); for (const auto &item : original) { size += sizeof(uint64_t) + item.first.size(); @@ -176,33 +176,33 @@ TEST(SlkCore, UnorderedMapString) { } std::unordered_map decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), size); } TEST(SlkCore, UniquePtrEmpty) { std::unique_ptr original; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::unique_ptr decoded = std::make_unique("nandare!"); ASSERT_NE(decoded.get(), nullptr); auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(decoded.get(), nullptr); ASSERT_EQ(loopback.size(), sizeof(bool)); } TEST(SlkCore, UniquePtrFull) { std::unique_ptr original = std::make_unique("nandare!"); - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::unique_ptr decoded; ASSERT_EQ(decoded.get(), nullptr); auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_NE(decoded.get(), nullptr); ASSERT_EQ(*original.get(), *decoded.get()); ASSERT_EQ(loopback.size(), sizeof(bool) + sizeof(uint64_t) + original.get()->size()); @@ -210,26 +210,26 @@ TEST(SlkCore, UniquePtrFull) { TEST(SlkCore, OptionalPrimitiveEmpty) { std::optional original; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::optional decoded = 5; ASSERT_NE(decoded, std::nullopt); auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(decoded, std::nullopt); ASSERT_EQ(loopback.size(), sizeof(bool)); } TEST(SlkCore, OptionalPrimitiveFull) { std::optional original = 5; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::optional decoded; ASSERT_EQ(decoded, std::nullopt); auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_NE(decoded, std::nullopt); ASSERT_EQ(*original, *decoded); ASSERT_EQ(loopback.size(), sizeof(bool) + sizeof(int)); @@ -237,26 +237,26 @@ TEST(SlkCore, OptionalPrimitiveFull) { TEST(SlkCore, OptionalStringEmpty) { std::optional original; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::optional decoded = "nandare!"; ASSERT_NE(decoded, std::nullopt); auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(decoded, std::nullopt); ASSERT_EQ(loopback.size(), sizeof(bool)); } TEST(SlkCore, OptionalStringFull) { std::optional original = "nandare!"; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::optional decoded; ASSERT_EQ(decoded, std::nullopt); auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_NE(decoded, std::nullopt); ASSERT_EQ(*original, *decoded); ASSERT_EQ(loopback.size(), sizeof(bool) + sizeof(uint64_t) + original->size()); @@ -264,12 +264,12 @@ TEST(SlkCore, OptionalStringFull) { TEST(SlkCore, Pair) { std::pair original{"nandare!", 5}; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::pair decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); ASSERT_EQ(loopback.size(), sizeof(uint64_t) + original.first.size() + sizeof(int)); } @@ -277,14 +277,14 @@ TEST(SlkCore, Pair) { TEST(SlkCore, SharedPtrEmpty) { std::shared_ptr original; std::vector saved; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder, &saved); + memgraph::slk::Save(original, builder, &saved); std::shared_ptr decoded = std::make_shared("nandare!"); std::vector> loaded; ASSERT_NE(decoded.get(), nullptr); auto reader = loopback.GetReader(); - slk::Load(&decoded, reader, &loaded); + memgraph::slk::Load(&decoded, reader, &loaded); ASSERT_EQ(decoded.get(), nullptr); ASSERT_EQ(saved.size(), 0); ASSERT_EQ(loaded.size(), 0); @@ -294,14 +294,14 @@ TEST(SlkCore, SharedPtrEmpty) { TEST(SlkCore, SharedPtrFull) { std::shared_ptr original = std::make_shared("nandare!"); std::vector saved; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder, &saved); + memgraph::slk::Save(original, builder, &saved); std::shared_ptr decoded; std::vector> loaded; ASSERT_EQ(decoded.get(), nullptr); auto reader = loopback.GetReader(); - slk::Load(&decoded, reader, &loaded); + memgraph::slk::Load(&decoded, reader, &loaded); ASSERT_NE(decoded.get(), nullptr); ASSERT_EQ(*original.get(), *decoded.get()); ASSERT_EQ(saved.size(), 1); @@ -315,23 +315,23 @@ TEST(SlkCore, SharedPtrMultiple) { std::shared_ptr ptr3 = std::make_shared("hai hai hai"); std::vector saved; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(ptr1, builder, &saved); - slk::Save(ptr2, builder, &saved); - slk::Save(ptr3, builder, &saved); - slk::Save(ptr1, builder, &saved); - slk::Save(ptr3, builder, &saved); + memgraph::slk::Save(ptr1, builder, &saved); + memgraph::slk::Save(ptr2, builder, &saved); + memgraph::slk::Save(ptr3, builder, &saved); + memgraph::slk::Save(ptr1, builder, &saved); + memgraph::slk::Save(ptr3, builder, &saved); std::shared_ptr dec1, dec2, dec3, dec4, dec5; std::vector> loaded; auto reader = loopback.GetReader(); - slk::Load(&dec1, reader, &loaded); - slk::Load(&dec2, reader, &loaded); - slk::Load(&dec3, reader, &loaded); - slk::Load(&dec4, reader, &loaded); - slk::Load(&dec5, reader, &loaded); + memgraph::slk::Load(&dec1, reader, &loaded); + memgraph::slk::Load(&dec2, reader, &loaded); + memgraph::slk::Load(&dec3, reader, &loaded); + memgraph::slk::Load(&dec4, reader, &loaded); + memgraph::slk::Load(&dec5, reader, &loaded); ASSERT_EQ(saved.size(), 2); ASSERT_EQ(loaded.size(), 2); @@ -366,22 +366,22 @@ TEST(SlkCore, SharedPtrInvalid) { std::shared_ptr ptr = std::make_shared("nandare!"); std::vector saved; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(ptr, builder, &saved); + memgraph::slk::Save(ptr, builder, &saved); // Here we mess with the `saved` vector to cause an invalid index to be // written to the SLK stream so that we can check the error handling in the // `Load` function later. saved.insert(saved.begin(), nullptr); // Save the pointer again with an invalid index. - slk::Save(ptr, builder, &saved); + memgraph::slk::Save(ptr, builder, &saved); std::shared_ptr dec1, dec2; std::vector> loaded; auto reader = loopback.GetReader(); - slk::Load(&dec1, reader, &loaded); - ASSERT_THROW(slk::Load(&dec2, reader, &loaded), slk::SlkDecodeException); + memgraph::slk::Load(&dec1, reader, &loaded); + ASSERT_THROW(memgraph::slk::Load(&dec2, reader, &loaded), memgraph::slk::SlkDecodeException); } TEST(SlkCore, Complex) { @@ -391,14 +391,14 @@ TEST(SlkCore, Complex) { original.get()->push_back(std::nullopt); original.get()->push_back("hai hai hai"); - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::unique_ptr>> decoded; ASSERT_EQ(decoded.get(), nullptr); auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_NE(decoded.get(), nullptr); ASSERT_EQ(*original.get(), *decoded.get()); @@ -419,7 +419,7 @@ struct Foo { bool operator==(const Foo &a, const Foo &b) { return a.name == b.name && a.value == b.value; } -namespace slk { +namespace memgraph::slk { void Save(const Foo &obj, Builder *builder) { Save(obj.name, builder); Save(obj.value, builder); @@ -429,20 +429,20 @@ void Load(Foo *obj, Reader *reader) { Load(&obj->name, reader); Load(&obj->value, reader); } -} // namespace slk +} // namespace memgraph::slk TEST(SlkCore, VectorStruct) { std::vector original; original.push_back({"hai hai hai", 5}); original.push_back({"nandare!", std::nullopt}); - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save(original, builder); + memgraph::slk::Save(original, builder); std::vector decoded; auto reader = loopback.GetReader(); - slk::Load(&decoded, reader); + memgraph::slk::Load(&decoded, reader); ASSERT_EQ(original, decoded); // clang-format off @@ -467,17 +467,17 @@ TEST(SlkCore, VectorSharedPtr) { original.push_back(ptr1); original.push_back(ptr3); - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save>(original, builder, - [&saved](const auto &item, auto *builder) { Save(item, builder, &saved); }); + memgraph::slk::Save>( + original, builder, [&saved](const auto &item, auto *builder) { Save(item, builder, &saved); }); std::vector> decoded; std::vector> loaded; auto reader = loopback.GetReader(); - slk::Load>(&decoded, reader, - [&loaded](auto *item, auto *reader) { Load(item, reader, &loaded); }); + memgraph::slk::Load>( + &decoded, reader, [&loaded](auto *item, auto *reader) { Load(item, reader, &loaded); }); ASSERT_EQ(decoded.size(), original.size()); @@ -500,17 +500,17 @@ TEST(SlkCore, OptionalSharedPtr) { std::optional> original = std::make_shared("nandare!"); std::vector saved; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save>(original, builder, - [&saved](const auto &item, auto *builder) { Save(item, builder, &saved); }); + memgraph::slk::Save>( + original, builder, [&saved](const auto &item, auto *builder) { Save(item, builder, &saved); }); std::optional> decoded; std::vector> loaded; auto reader = loopback.GetReader(); - slk::Load>(&decoded, reader, - [&loaded](auto *item, auto *reader) { Load(item, reader, &loaded); }); + memgraph::slk::Load>( + &decoded, reader, [&loaded](auto *item, auto *reader) { Load(item, reader, &loaded); }); ASSERT_NE(decoded, std::nullopt); @@ -524,17 +524,17 @@ TEST(SlkCore, OptionalSharedPtrEmpty) { std::optional> original; std::vector saved; - slk::Loopback loopback; + memgraph::slk::Loopback loopback; auto builder = loopback.GetBuilder(); - slk::Save>(original, builder, - [&saved](const auto &item, auto *builder) { Save(item, builder, &saved); }); + memgraph::slk::Save>( + original, builder, [&saved](const auto &item, auto *builder) { Save(item, builder, &saved); }); std::optional> decoded; std::vector> loaded; auto reader = loopback.GetReader(); - slk::Load>(&decoded, reader, - [&loaded](auto *item, auto *reader) { Load(item, reader, &loaded); }); + memgraph::slk::Load>( + &decoded, reader, [&loaded](auto *item, auto *reader) { Load(item, reader, &loaded); }); ASSERT_EQ(decoded, std::nullopt); diff --git a/tests/unit/slk_streams.cpp b/tests/unit/slk_streams.cpp index 12d44e51e..634eaecb5 100644 --- a/tests/unit/slk_streams.cpp +++ b/tests/unit/slk_streams.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -72,13 +72,13 @@ std::vector BufferToBinaryData(const uint8_t *data, size_t size, std return ret; } -BinaryData SizeToBinaryData(slk::SegmentSize size) { - return BinaryData(reinterpret_cast(&size), sizeof(slk::SegmentSize)); +BinaryData SizeToBinaryData(memgraph::slk::SegmentSize size) { + return BinaryData(reinterpret_cast(&size), sizeof(memgraph::slk::SegmentSize)); } TEST(Builder, SingleSegment) { std::vector buffer; - slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { + memgraph::slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { for (size_t i = 0; i < size; ++i) buffer.push_back(data[i]); }); @@ -86,10 +86,11 @@ TEST(Builder, SingleSegment) { builder.Save(input.data(), input.size()); builder.Finalize(); - ASSERT_EQ(buffer.size(), input.size() + 2 * sizeof(slk::SegmentSize)); + ASSERT_EQ(buffer.size(), input.size() + 2 * sizeof(memgraph::slk::SegmentSize)); - auto splits = BufferToBinaryData(buffer.data(), buffer.size(), - {sizeof(slk::SegmentSize), input.size(), sizeof(slk::SegmentSize)}); + auto splits = + BufferToBinaryData(buffer.data(), buffer.size(), + {sizeof(memgraph::slk::SegmentSize), input.size(), sizeof(memgraph::slk::SegmentSize)}); auto header_expected = SizeToBinaryData(input.size()); ASSERT_EQ(splits[0], header_expected); @@ -102,29 +103,31 @@ TEST(Builder, SingleSegment) { TEST(Builder, MultipleSegments) { std::vector buffer; - slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { + memgraph::slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { for (size_t i = 0; i < size; ++i) buffer.push_back(data[i]); }); - auto input = GetRandomData(slk::kSegmentMaxDataSize + 100); + auto input = GetRandomData(memgraph::slk::kSegmentMaxDataSize + 100); builder.Save(input.data(), input.size()); builder.Finalize(); - ASSERT_EQ(buffer.size(), input.size() + 3 * sizeof(slk::SegmentSize)); + ASSERT_EQ(buffer.size(), input.size() + 3 * sizeof(memgraph::slk::SegmentSize)); - auto splits = BufferToBinaryData(buffer.data(), buffer.size(), - {sizeof(slk::SegmentSize), slk::kSegmentMaxDataSize, sizeof(slk::SegmentSize), - input.size() - slk::kSegmentMaxDataSize, sizeof(slk::SegmentSize)}); + auto splits = BufferToBinaryData( + buffer.data(), buffer.size(), + {sizeof(memgraph::slk::SegmentSize), memgraph::slk::kSegmentMaxDataSize, sizeof(memgraph::slk::SegmentSize), + input.size() - memgraph::slk::kSegmentMaxDataSize, sizeof(memgraph::slk::SegmentSize)}); - auto datas = BufferToBinaryData(input.data(), input.size(), - {slk::kSegmentMaxDataSize, input.size() - slk::kSegmentMaxDataSize}); + auto datas = + BufferToBinaryData(input.data(), input.size(), + {memgraph::slk::kSegmentMaxDataSize, input.size() - memgraph::slk::kSegmentMaxDataSize}); - auto header1_expected = SizeToBinaryData(slk::kSegmentMaxDataSize); + auto header1_expected = SizeToBinaryData(memgraph::slk::kSegmentMaxDataSize); ASSERT_EQ(splits[0], header1_expected); ASSERT_EQ(splits[1], datas[0]); - auto header2_expected = SizeToBinaryData(input.size() - slk::kSegmentMaxDataSize); + auto header2_expected = SizeToBinaryData(input.size() - memgraph::slk::kSegmentMaxDataSize); ASSERT_EQ(splits[2], header2_expected); ASSERT_EQ(splits[3], datas[1]); @@ -135,7 +138,7 @@ TEST(Builder, MultipleSegments) { TEST(Reader, SingleSegment) { std::vector buffer; - slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { + memgraph::slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { for (size_t i = 0; i < size; ++i) buffer.push_back(data[i]); }); @@ -145,20 +148,20 @@ TEST(Reader, SingleSegment) { // test with missing data for (size_t i = 0; i < buffer.size(); ++i) { - slk::Reader reader(buffer.data(), i); - uint8_t block[slk::kSegmentMaxDataSize]; + memgraph::slk::Reader reader(buffer.data(), i); + uint8_t block[memgraph::slk::kSegmentMaxDataSize]; ASSERT_THROW( { reader.Load(block, input.size()); reader.Finalize(); }, - slk::SlkReaderException); + memgraph::slk::SlkReaderException); } // test with complete data { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize]; + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize]; reader.Load(block, input.size()); reader.Finalize(); auto output = BinaryData(block, input.size()); @@ -168,8 +171,8 @@ TEST(Reader, SingleSegment) { // test with leftover data { auto extended_buffer = BinaryData(buffer.data(), buffer.size()) + GetRandomData(5); - slk::Reader reader(extended_buffer.data(), extended_buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize]; + memgraph::slk::Reader reader(extended_buffer.data(), extended_buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize]; reader.Load(block, input.size()); reader.Finalize(); auto output = BinaryData(block, input.size()); @@ -178,23 +181,23 @@ TEST(Reader, SingleSegment) { // read more data than there is in the stream { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize]; - ASSERT_THROW(reader.Load(block, slk::kSegmentMaxDataSize), slk::SlkReaderException); + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize]; + ASSERT_THROW(reader.Load(block, memgraph::slk::kSegmentMaxDataSize), memgraph::slk::SlkReaderException); } // don't consume all data from the stream { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize]; + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize]; reader.Load(block, input.size() / 2); - ASSERT_THROW(reader.Finalize(), slk::SlkReaderException); + ASSERT_THROW(reader.Finalize(), memgraph::slk::SlkReaderException); } // read data with several loads { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize]; + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize]; for (size_t i = 0; i < input.size(); ++i) { reader.Load(block + i, 1); } @@ -206,39 +209,39 @@ TEST(Reader, SingleSegment) { // modify the end mark buffer[buffer.size() - 1] = 1; { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize]; + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize]; reader.Load(block, input.size()); - ASSERT_THROW(reader.Finalize(), slk::SlkReaderException); + ASSERT_THROW(reader.Finalize(), memgraph::slk::SlkReaderException); } } TEST(Reader, MultipleSegments) { std::vector buffer; - slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { + memgraph::slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { for (size_t i = 0; i < size; ++i) buffer.push_back(data[i]); }); - auto input = GetRandomData(slk::kSegmentMaxDataSize + 100); + auto input = GetRandomData(memgraph::slk::kSegmentMaxDataSize + 100); builder.Save(input.data(), input.size()); builder.Finalize(); // test with missing data for (size_t i = 0; i < buffer.size(); ++i) { - slk::Reader reader(buffer.data(), i); - uint8_t block[slk::kSegmentMaxDataSize * 2]; + memgraph::slk::Reader reader(buffer.data(), i); + uint8_t block[memgraph::slk::kSegmentMaxDataSize * 2]; ASSERT_THROW( { reader.Load(block, input.size()); reader.Finalize(); }, - slk::SlkReaderException); + memgraph::slk::SlkReaderException); } // test with complete data { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize * 2]; + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize * 2]; reader.Load(block, input.size()); reader.Finalize(); auto output = BinaryData(block, input.size()); @@ -248,8 +251,8 @@ TEST(Reader, MultipleSegments) { // test with leftover data { auto extended_buffer = BinaryData(buffer.data(), buffer.size()) + GetRandomData(5); - slk::Reader reader(extended_buffer.data(), extended_buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize * 2]; + memgraph::slk::Reader reader(extended_buffer.data(), extended_buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize * 2]; reader.Load(block, input.size()); reader.Finalize(); auto output = BinaryData(block, input.size()); @@ -258,23 +261,23 @@ TEST(Reader, MultipleSegments) { // read more data than there is in the stream { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize * 2]; - ASSERT_THROW(reader.Load(block, slk::kSegmentMaxDataSize * 2), slk::SlkReaderException); + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize * 2]; + ASSERT_THROW(reader.Load(block, memgraph::slk::kSegmentMaxDataSize * 2), memgraph::slk::SlkReaderException); } // don't consume all data from the stream { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize * 2]; + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize * 2]; reader.Load(block, input.size() / 2); - ASSERT_THROW(reader.Finalize(), slk::SlkReaderException); + ASSERT_THROW(reader.Finalize(), memgraph::slk::SlkReaderException); } // read data with several loads { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize * 2]; + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize * 2]; for (size_t i = 0; i < input.size(); ++i) { reader.Load(block + i, 1); } @@ -286,16 +289,16 @@ TEST(Reader, MultipleSegments) { // modify the end mark buffer[buffer.size() - 1] = 1; { - slk::Reader reader(buffer.data(), buffer.size()); - uint8_t block[slk::kSegmentMaxDataSize * 2]; + memgraph::slk::Reader reader(buffer.data(), buffer.size()); + uint8_t block[memgraph::slk::kSegmentMaxDataSize * 2]; reader.Load(block, input.size()); - ASSERT_THROW(reader.Finalize(), slk::SlkReaderException); + ASSERT_THROW(reader.Finalize(), memgraph::slk::SlkReaderException); } } TEST(CheckStreamComplete, SingleSegment) { std::vector buffer; - slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { + memgraph::slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { for (size_t i = 0; i < size; ++i) buffer.push_back(data[i]); }); @@ -304,29 +307,29 @@ TEST(CheckStreamComplete, SingleSegment) { builder.Finalize(); // test with missing data - for (size_t i = 0; i < sizeof(slk::SegmentSize); ++i) { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), i); - ASSERT_EQ(status, slk::StreamStatus::PARTIAL); - ASSERT_EQ(stream_size, slk::kSegmentMaxTotalSize); + for (size_t i = 0; i < sizeof(memgraph::slk::SegmentSize); ++i) { + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), i); + ASSERT_EQ(status, memgraph::slk::StreamStatus::PARTIAL); + ASSERT_EQ(stream_size, memgraph::slk::kSegmentMaxTotalSize); ASSERT_EQ(data_size, 0); } - for (size_t i = sizeof(slk::SegmentSize); i < sizeof(slk::SegmentSize) + input.size(); ++i) { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), i); - ASSERT_EQ(status, slk::StreamStatus::PARTIAL); - ASSERT_EQ(stream_size, slk::kSegmentMaxTotalSize + sizeof(slk::SegmentSize)); + for (size_t i = sizeof(memgraph::slk::SegmentSize); i < sizeof(memgraph::slk::SegmentSize) + input.size(); ++i) { + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), i); + ASSERT_EQ(status, memgraph::slk::StreamStatus::PARTIAL); + ASSERT_EQ(stream_size, memgraph::slk::kSegmentMaxTotalSize + sizeof(memgraph::slk::SegmentSize)); ASSERT_EQ(data_size, 0); } - for (size_t i = sizeof(slk::SegmentSize) + input.size(); i < buffer.size(); ++i) { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), i); - ASSERT_EQ(status, slk::StreamStatus::PARTIAL); - ASSERT_EQ(stream_size, slk::kSegmentMaxTotalSize + sizeof(slk::SegmentSize) + input.size()); + for (size_t i = sizeof(memgraph::slk::SegmentSize) + input.size(); i < buffer.size(); ++i) { + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), i); + ASSERT_EQ(status, memgraph::slk::StreamStatus::PARTIAL); + ASSERT_EQ(stream_size, memgraph::slk::kSegmentMaxTotalSize + sizeof(memgraph::slk::SegmentSize) + input.size()); ASSERT_EQ(data_size, input.size()); } // test with complete data { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), buffer.size()); - ASSERT_EQ(status, slk::StreamStatus::COMPLETE); + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), buffer.size()); + ASSERT_EQ(status, memgraph::slk::StreamStatus::COMPLETE); ASSERT_EQ(stream_size, buffer.size()); ASSERT_EQ(data_size, input.size()); } @@ -334,8 +337,9 @@ TEST(CheckStreamComplete, SingleSegment) { // test with leftover data { auto extended_buffer = BinaryData(buffer.data(), buffer.size()) + GetRandomData(5); - auto [status, stream_size, data_size] = slk::CheckStreamComplete(extended_buffer.data(), extended_buffer.size()); - ASSERT_EQ(status, slk::StreamStatus::COMPLETE); + auto [status, stream_size, data_size] = + memgraph::slk::CheckStreamComplete(extended_buffer.data(), extended_buffer.size()); + ASSERT_EQ(status, memgraph::slk::StreamStatus::COMPLETE); ASSERT_EQ(stream_size, buffer.size()); ASSERT_EQ(data_size, input.size()); } @@ -343,52 +347,55 @@ TEST(CheckStreamComplete, SingleSegment) { TEST(CheckStreamComplete, MultipleSegments) { std::vector buffer; - slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { + memgraph::slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool have_more) { for (size_t i = 0; i < size; ++i) buffer.push_back(data[i]); }); - auto input = GetRandomData(slk::kSegmentMaxDataSize + 100); + auto input = GetRandomData(memgraph::slk::kSegmentMaxDataSize + 100); builder.Save(input.data(), input.size()); builder.Finalize(); // test with missing data - for (size_t i = 0; i < sizeof(slk::SegmentSize); ++i) { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), i); - ASSERT_EQ(status, slk::StreamStatus::PARTIAL); - ASSERT_EQ(stream_size, slk::kSegmentMaxTotalSize); + for (size_t i = 0; i < sizeof(memgraph::slk::SegmentSize); ++i) { + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), i); + ASSERT_EQ(status, memgraph::slk::StreamStatus::PARTIAL); + ASSERT_EQ(stream_size, memgraph::slk::kSegmentMaxTotalSize); ASSERT_EQ(data_size, 0); } - for (size_t i = sizeof(slk::SegmentSize); i < sizeof(slk::SegmentSize) + slk::kSegmentMaxDataSize; ++i) { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), i); - ASSERT_EQ(status, slk::StreamStatus::PARTIAL); - ASSERT_EQ(stream_size, slk::kSegmentMaxTotalSize + sizeof(slk::SegmentSize)); + for (size_t i = sizeof(memgraph::slk::SegmentSize); + i < sizeof(memgraph::slk::SegmentSize) + memgraph::slk::kSegmentMaxDataSize; ++i) { + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), i); + ASSERT_EQ(status, memgraph::slk::StreamStatus::PARTIAL); + ASSERT_EQ(stream_size, memgraph::slk::kSegmentMaxTotalSize + sizeof(memgraph::slk::SegmentSize)); ASSERT_EQ(data_size, 0); } - for (size_t i = sizeof(slk::SegmentSize) + slk::kSegmentMaxDataSize; - i < sizeof(slk::SegmentSize) * 2 + slk::kSegmentMaxDataSize; ++i) { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), i); - ASSERT_EQ(status, slk::StreamStatus::PARTIAL); - ASSERT_EQ(stream_size, sizeof(slk::SegmentSize) + slk::kSegmentMaxDataSize + slk::kSegmentMaxTotalSize); - ASSERT_EQ(data_size, slk::kSegmentMaxDataSize); + for (size_t i = sizeof(memgraph::slk::SegmentSize) + memgraph::slk::kSegmentMaxDataSize; + i < sizeof(memgraph::slk::SegmentSize) * 2 + memgraph::slk::kSegmentMaxDataSize; ++i) { + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), i); + ASSERT_EQ(status, memgraph::slk::StreamStatus::PARTIAL); + ASSERT_EQ(stream_size, sizeof(memgraph::slk::SegmentSize) + memgraph::slk::kSegmentMaxDataSize + + memgraph::slk::kSegmentMaxTotalSize); + ASSERT_EQ(data_size, memgraph::slk::kSegmentMaxDataSize); } - for (size_t i = sizeof(slk::SegmentSize) * 2 + slk::kSegmentMaxDataSize; - i < sizeof(slk::SegmentSize) * 2 + input.size(); ++i) { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), i); - ASSERT_EQ(status, slk::StreamStatus::PARTIAL); - ASSERT_EQ(stream_size, sizeof(slk::SegmentSize) * 2 + slk::kSegmentMaxDataSize + slk::kSegmentMaxTotalSize); - ASSERT_EQ(data_size, slk::kSegmentMaxDataSize); + for (size_t i = sizeof(memgraph::slk::SegmentSize) * 2 + memgraph::slk::kSegmentMaxDataSize; + i < sizeof(memgraph::slk::SegmentSize) * 2 + input.size(); ++i) { + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), i); + ASSERT_EQ(status, memgraph::slk::StreamStatus::PARTIAL); + ASSERT_EQ(stream_size, sizeof(memgraph::slk::SegmentSize) * 2 + memgraph::slk::kSegmentMaxDataSize + + memgraph::slk::kSegmentMaxTotalSize); + ASSERT_EQ(data_size, memgraph::slk::kSegmentMaxDataSize); } - for (size_t i = sizeof(slk::SegmentSize) * 2 + input.size(); i < buffer.size(); ++i) { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), i); - ASSERT_EQ(status, slk::StreamStatus::PARTIAL); - ASSERT_EQ(stream_size, slk::kSegmentMaxTotalSize + sizeof(slk::SegmentSize) * 2 + input.size()); + for (size_t i = sizeof(memgraph::slk::SegmentSize) * 2 + input.size(); i < buffer.size(); ++i) { + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), i); + ASSERT_EQ(status, memgraph::slk::StreamStatus::PARTIAL); + ASSERT_EQ(stream_size, memgraph::slk::kSegmentMaxTotalSize + sizeof(memgraph::slk::SegmentSize) * 2 + input.size()); ASSERT_EQ(data_size, input.size()); } // test with complete data { - auto [status, stream_size, data_size] = slk::CheckStreamComplete(buffer.data(), buffer.size()); - ASSERT_EQ(status, slk::StreamStatus::COMPLETE); + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(buffer.data(), buffer.size()); + ASSERT_EQ(status, memgraph::slk::StreamStatus::COMPLETE); ASSERT_EQ(stream_size, buffer.size()); ASSERT_EQ(data_size, input.size()); } @@ -396,8 +403,9 @@ TEST(CheckStreamComplete, MultipleSegments) { // test with leftover data { auto extended_buffer = BinaryData(buffer.data(), buffer.size()) + GetRandomData(5); - auto [status, stream_size, data_size] = slk::CheckStreamComplete(extended_buffer.data(), extended_buffer.size()); - ASSERT_EQ(status, slk::StreamStatus::COMPLETE); + auto [status, stream_size, data_size] = + memgraph::slk::CheckStreamComplete(extended_buffer.data(), extended_buffer.size()); + ASSERT_EQ(status, memgraph::slk::StreamStatus::COMPLETE); ASSERT_EQ(stream_size, buffer.size()); ASSERT_EQ(data_size, input.size()); } @@ -405,8 +413,8 @@ TEST(CheckStreamComplete, MultipleSegments) { TEST(CheckStreamComplete, InvalidSegment) { auto input = SizeToBinaryData(0); - auto [status, stream_size, data_size] = slk::CheckStreamComplete(input.data(), input.size()); - ASSERT_EQ(status, slk::StreamStatus::INVALID); + auto [status, stream_size, data_size] = memgraph::slk::CheckStreamComplete(input.data(), input.size()); + ASSERT_EQ(status, memgraph::slk::StreamStatus::INVALID); ASSERT_EQ(stream_size, 0); ASSERT_EQ(data_size, 0); } diff --git a/tests/unit/small_vector.cpp b/tests/unit/small_vector.cpp index 2e509a9d6..756cc7b40 100644 --- a/tests/unit/small_vector.cpp +++ b/tests/unit/small_vector.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,7 +24,7 @@ TEST(SmallVector, BasicTest) { const int kMaxElements = 10; - utils::SmallVector small_vector; + memgraph::utils::SmallVector small_vector; for (int i = 0; i < kMaxElements; ++i) { small_vector.push_back(i); @@ -37,7 +37,7 @@ TEST(SmallVector, BasicTest) { TEST(SmallVector, Clear) { const int kMaxElements = 10; - utils::SmallVector small_vector; + memgraph::utils::SmallVector small_vector; for (int i = 0; i < kMaxElements + 1; ++i) { small_vector.push_back(i); @@ -54,7 +54,7 @@ TEST(SmallVector, Resize) { const int kSmallStorageSize = 5; const int kTwiceTheSmallStorage = 2 * kSmallStorageSize; const int kSomeRandomConst = 505; - utils::SmallVector small_vector; + memgraph::utils::SmallVector small_vector; for (int i = 0; i < kTwiceTheSmallStorage; ++i) { small_vector.push_back(i); @@ -71,7 +71,7 @@ TEST(SmallVector, Resize) { TEST(SmallVector, Reserve) { const int kMaxElements = 1000; const int kMaxElementsAfter = 1000; - utils::SmallVector small_vector; + memgraph::utils::SmallVector small_vector; EXPECT_EQ(small_vector.capacity(), kMaxElements); small_vector.reserve(kMaxElementsAfter); EXPECT_EQ(small_vector.capacity(), kMaxElementsAfter); @@ -81,7 +81,7 @@ TEST(SmallVector, Reserve) { TEST(SmallVector, PopBackVal) { const int kMaxElements = 10; - utils::SmallVector small_vector; + memgraph::utils::SmallVector small_vector; for (int i = 0; i < kMaxElements; ++i) { small_vector.push_back(std::to_string(i)); } @@ -96,16 +96,16 @@ TEST(SmallVector, Swap) { const int kSize1 = 10; const int kSize2 = 1000; - utils::SmallVector vector1; - utils::SmallVector vector2; + memgraph::utils::SmallVector vector1; + memgraph::utils::SmallVector vector2; - utils::SmallVector vector3; - utils::SmallVector vector4; + memgraph::utils::SmallVector vector3; + memgraph::utils::SmallVector vector4; - utils::SmallVector ref_vector1; - utils::SmallVector ref_vector2; - utils::SmallVector ref_vector3; - utils::SmallVector ref_vector4; + memgraph::utils::SmallVector ref_vector1; + memgraph::utils::SmallVector ref_vector2; + memgraph::utils::SmallVector ref_vector3; + memgraph::utils::SmallVector ref_vector4; for (int i = 0; i < kSize1; ++i) { int value = i % 3; @@ -146,7 +146,7 @@ TEST(SmallVector, Append1) { for (int i = 0; i < kMaxElements; ++i) { test_vector.push_back(i); } - utils::SmallVector small_vector = {20}; + memgraph::utils::SmallVector small_vector = {20}; small_vector.append(test_vector.begin(), test_vector.end()); EXPECT_EQ(20, small_vector[0]); for (int i = 0; i < kMaxElements; ++i) { @@ -157,8 +157,8 @@ TEST(SmallVector, Append1) { TEST(SmallVector, Append2) { const int kSize = 10; const std::string kElement = "dolje na koljena, reci mi moja voljena"; - utils::SmallVector test_vector(kSize, kElement); - utils::SmallVector small_vector; + memgraph::utils::SmallVector test_vector(kSize, kElement); + memgraph::utils::SmallVector small_vector; small_vector.append(kSize, kElement); EXPECT_EQ(small_vector.size(), kSize); EXPECT_EQ(test_vector, small_vector); @@ -166,8 +166,8 @@ TEST(SmallVector, Append2) { TEST(SmallVector, Append3) { const int kSize = 3; - utils::SmallVector test_vector = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5}; - utils::SmallVector small_vector = {1, 2, 3, 4, 5}; + memgraph::utils::SmallVector test_vector = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5}; + memgraph::utils::SmallVector small_vector = {1, 2, 3, 4, 5}; small_vector.append({1, 2, 3, 4, 5}); EXPECT_EQ(test_vector, small_vector); } @@ -176,8 +176,8 @@ TEST(SmallVector, Assign1) { const int kSize = 3; const int kElemNum = 100; const std::string kElement = "brate samo loudam malo toga sejvam"; - utils::SmallVector test_vector; - utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; + memgraph::utils::SmallVector test_vector; + memgraph::utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; for (int i = 0; i < kElemNum; ++i) { test_vector.push_back(kElement); } @@ -189,15 +189,15 @@ TEST(SmallVector, Assign1) { TEST(SmallVector, Assign2) { const int kSize = 3; const std::string kElement = "preko tjedna gospoda"; - utils::SmallVector test_vector = {kElement}; - utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; + memgraph::utils::SmallVector test_vector = {kElement}; + memgraph::utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; small_vector.assign({kElement}); EXPECT_EQ(test_vector, small_vector); } TEST(SmallVector, Erase) { const int kSize = 3; - utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; + memgraph::utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; small_vector.erase(small_vector.begin() + 1, small_vector.end()); EXPECT_EQ(1, small_vector.size()); EXPECT_EQ("a", small_vector[0]); @@ -209,8 +209,8 @@ TEST(SmallVector, Insert) { const int kSize = 3; const std::string kXXX = "xxx"; - utils::SmallVector test_vector = {"1", "2", "3", "4", "5"}; - utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; + memgraph::utils::SmallVector test_vector = {"1", "2", "3", "4", "5"}; + memgraph::utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; small_vector.insert(small_vector.begin(), kXXX); EXPECT_EQ(kXXX, small_vector[0]); @@ -233,7 +233,7 @@ TEST(SmallVector, Insert) { TEST(SmallVector, EmplaceBack) { const int kSize = 3; - utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; + memgraph::utils::SmallVector small_vector = {"a", "b", "c", "d", "e", "f"}; small_vector.emplace_back("g"); EXPECT_EQ("g", small_vector.back()); } @@ -241,7 +241,7 @@ TEST(SmallVector, EmplaceBack) { TEST(SmallVector, PushPopBack) { const int kSize = 3; const int kElemNum = 10000; - utils::SmallVector small_vector; + memgraph::utils::SmallVector small_vector; EXPECT_EQ(0, small_vector.size()); for (int i = 0; i < kElemNum; ++i) { small_vector.push_back(i); @@ -256,7 +256,7 @@ TEST(SmallVector, PushPopBack) { TEST(SmallVector, Capacity) { const int kSize = 3; const int kElemNum = 10000; - utils::SmallVector small_vector; + memgraph::utils::SmallVector small_vector; EXPECT_EQ(0, small_vector.size()); EXPECT_EQ(3, small_vector.capacity()); for (int i = 0; i < kElemNum; ++i) { @@ -269,7 +269,7 @@ TEST(SmallVector, Capacity) { TEST(SmallVector, Data) { const int kSize = 3; const int kElemNum = 100; - utils::SmallVector small_vector; + memgraph::utils::SmallVector small_vector; for (int i = 0; i < kElemNum; ++i) { small_vector.push_back(i); } @@ -282,7 +282,7 @@ TEST(SmallVector, Data) { TEST(SmallVector, Empty) { const int kSize = 3; const int kElemNum = 10000; - utils::SmallVector small_vector; + memgraph::utils::SmallVector small_vector; EXPECT_TRUE(small_vector.empty()); for (int i = 0; i < kElemNum; ++i) { small_vector.push_back(i); @@ -297,8 +297,8 @@ TEST(SmallVector, Empty) { TEST(SmallVector, Operators) { const int kSize = 3; const int kElemNum = 10000; - utils::SmallVector small_vector_1; - utils::SmallVector small_vector_2; + memgraph::utils::SmallVector small_vector_1; + memgraph::utils::SmallVector small_vector_2; for (int i = 0; i < kElemNum; ++i) { small_vector_1.push_back(i); diff --git a/tests/unit/socket.cpp b/tests/unit/socket.cpp index af000bcd5..ea09d935b 100644 --- a/tests/unit/socket.cpp +++ b/tests/unit/socket.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -19,12 +19,12 @@ #include "utils/timer.hpp" TEST(Socket, WaitForReadyRead) { - io::network::Socket server; + memgraph::io::network::Socket server; ASSERT_TRUE(server.Bind({"127.0.0.1", 0})); ASSERT_TRUE(server.Listen(1024)); std::thread thread([&server] { - io::network::Socket client; + memgraph::io::network::Socket client; ASSERT_TRUE(client.Connect(server.endpoint())); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); ASSERT_TRUE(client.Write("test")); @@ -39,7 +39,7 @@ TEST(Socket, WaitForReadyRead) { ASSERT_EQ(client->Read(buff, sizeof(buff)), -1); ASSERT_TRUE(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR); - utils::Timer timer; + memgraph::utils::Timer timer; ASSERT_TRUE(client->WaitForReadyRead()); ASSERT_GT(timer.Elapsed().count(), 1.0); @@ -49,13 +49,13 @@ TEST(Socket, WaitForReadyRead) { } TEST(Socket, WaitForReadyWrite) { - io::network::Socket server; + memgraph::io::network::Socket server; ASSERT_TRUE(server.Bind({"127.0.0.1", 0})); ASSERT_TRUE(server.Listen(1024)); std::thread thread([&server] { uint8_t buff[10000]; - io::network::Socket client; + memgraph::io::network::Socket client; ASSERT_TRUE(client.Connect(server.endpoint())); client.SetNonBlocking(); @@ -83,7 +83,7 @@ TEST(Socket, WaitForReadyWrite) { int len = 1024; ASSERT_EQ(setsockopt(client->fd(), SOL_SOCKET, SO_SNDBUF, &len, sizeof(len)), 0); - utils::Timer timer; + memgraph::utils::Timer timer; for (int i = 0; i < 1000000; ++i) { ASSERT_TRUE(client->Write("test")); } diff --git a/tests/unit/storage_test_utils.cpp b/tests/unit/storage_test_utils.cpp index a17c9b295..03c68a92f 100644 --- a/tests/unit/storage_test_utils.cpp +++ b/tests/unit/storage_test_utils.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -11,7 +11,7 @@ #include "storage_test_utils.hpp" -size_t CountVertices(storage::Storage::Accessor &storage_accessor, storage::View view) { +size_t CountVertices(memgraph::storage::Storage::Accessor &storage_accessor, memgraph::storage::View view) { auto vertices = storage_accessor.Vertices(view); size_t count = 0U; for (auto it = vertices.begin(); it != vertices.end(); ++it, ++count) diff --git a/tests/unit/storage_test_utils.hpp b/tests/unit/storage_test_utils.hpp index 81e4dd561..be85a34e7 100644 --- a/tests/unit/storage_test_utils.hpp +++ b/tests/unit/storage_test_utils.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -14,4 +14,4 @@ #include "storage/v2/storage.hpp" #include "storage/v2/view.hpp" -size_t CountVertices(storage::Storage::Accessor &storage_accessor, storage::View view); \ No newline at end of file +size_t CountVertices(memgraph::storage::Storage::Accessor &storage_accessor, memgraph::storage::View view); \ No newline at end of file diff --git a/tests/unit/storage_v2.cpp b/tests/unit/storage_v2.cpp index 90bf58231..b268ca8f8 100644 --- a/tests/unit/storage_v2.cpp +++ b/tests/unit/storage_v2.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,161 +23,161 @@ using testing::UnorderedElementsAre; // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, Commit) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - ASSERT_FALSE(acc.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - ASSERT_TRUE(acc.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 1U); + ASSERT_FALSE(acc.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(acc.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 1U); ASSERT_FALSE(acc.Commit().HasError()); } { auto acc = store.Access(); - ASSERT_TRUE(acc.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 1U); - ASSERT_TRUE(acc.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 1U); + ASSERT_TRUE(acc.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 1U); acc.Abort(); } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::NEW); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto res = acc.DeleteVertex(&*vertex); ASSERT_FALSE(res.HasError()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); acc.AdvanceCommand(); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); ASSERT_FALSE(acc.Commit().HasError()); } { auto acc = store.Access(); - ASSERT_FALSE(acc.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - ASSERT_FALSE(acc.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + ASSERT_FALSE(acc.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); acc.Abort(); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, Abort) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - ASSERT_FALSE(acc.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - ASSERT_TRUE(acc.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 1U); + ASSERT_FALSE(acc.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(acc.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 1U); acc.Abort(); } { auto acc = store.Access(); - ASSERT_FALSE(acc.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - ASSERT_FALSE(acc.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + ASSERT_FALSE(acc.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); acc.Abort(); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, AdvanceCommandCommit) { - storage::Storage store; - storage::Gid gid1 = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid2 = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid1 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid2 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex1 = acc.CreateVertex(); gid1 = vertex1.Gid(); - ASSERT_FALSE(acc.FindVertex(gid1, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - ASSERT_TRUE(acc.FindVertex(gid1, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 1U); + ASSERT_FALSE(acc.FindVertex(gid1, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(acc.FindVertex(gid1, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 1U); acc.AdvanceCommand(); auto vertex2 = acc.CreateVertex(); gid2 = vertex2.Gid(); - ASSERT_FALSE(acc.FindVertex(gid2, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 1U); - ASSERT_TRUE(acc.FindVertex(gid2, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 2U); + ASSERT_FALSE(acc.FindVertex(gid2, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc.FindVertex(gid2, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 2U); - ASSERT_TRUE(acc.FindVertex(gid1, storage::View::OLD).has_value()); - ASSERT_TRUE(acc.FindVertex(gid1, storage::View::NEW).has_value()); + ASSERT_TRUE(acc.FindVertex(gid1, memgraph::storage::View::OLD).has_value()); + ASSERT_TRUE(acc.FindVertex(gid1, memgraph::storage::View::NEW).has_value()); ASSERT_FALSE(acc.Commit().HasError()); } { auto acc = store.Access(); - ASSERT_TRUE(acc.FindVertex(gid1, storage::View::OLD).has_value()); - ASSERT_TRUE(acc.FindVertex(gid1, storage::View::NEW).has_value()); - ASSERT_TRUE(acc.FindVertex(gid2, storage::View::OLD).has_value()); - ASSERT_TRUE(acc.FindVertex(gid2, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 2U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 2U); + ASSERT_TRUE(acc.FindVertex(gid1, memgraph::storage::View::OLD).has_value()); + ASSERT_TRUE(acc.FindVertex(gid1, memgraph::storage::View::NEW).has_value()); + ASSERT_TRUE(acc.FindVertex(gid2, memgraph::storage::View::OLD).has_value()); + ASSERT_TRUE(acc.FindVertex(gid2, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 2U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 2U); acc.Abort(); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, AdvanceCommandAbort) { - storage::Storage store; - storage::Gid gid1 = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid2 = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid1 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid2 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex1 = acc.CreateVertex(); gid1 = vertex1.Gid(); - ASSERT_FALSE(acc.FindVertex(gid1, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - ASSERT_TRUE(acc.FindVertex(gid1, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 1U); + ASSERT_FALSE(acc.FindVertex(gid1, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(acc.FindVertex(gid1, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 1U); acc.AdvanceCommand(); auto vertex2 = acc.CreateVertex(); gid2 = vertex2.Gid(); - ASSERT_FALSE(acc.FindVertex(gid2, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 1U); - ASSERT_TRUE(acc.FindVertex(gid2, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 2U); + ASSERT_FALSE(acc.FindVertex(gid2, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc.FindVertex(gid2, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 2U); - ASSERT_TRUE(acc.FindVertex(gid1, storage::View::OLD).has_value()); - ASSERT_TRUE(acc.FindVertex(gid1, storage::View::NEW).has_value()); + ASSERT_TRUE(acc.FindVertex(gid1, memgraph::storage::View::OLD).has_value()); + ASSERT_TRUE(acc.FindVertex(gid1, memgraph::storage::View::NEW).has_value()); acc.Abort(); } { auto acc = store.Access(); - ASSERT_FALSE(acc.FindVertex(gid1, storage::View::OLD).has_value()); - ASSERT_FALSE(acc.FindVertex(gid1, storage::View::NEW).has_value()); - ASSERT_FALSE(acc.FindVertex(gid2, storage::View::OLD).has_value()); - ASSERT_FALSE(acc.FindVertex(gid2, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + ASSERT_FALSE(acc.FindVertex(gid1, memgraph::storage::View::OLD).has_value()); + ASSERT_FALSE(acc.FindVertex(gid1, memgraph::storage::View::NEW).has_value()); + ASSERT_FALSE(acc.FindVertex(gid2, memgraph::storage::View::OLD).has_value()); + ASSERT_FALSE(acc.FindVertex(gid2, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); acc.Abort(); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, SnapshotIsolation) { - storage::Storage store; + memgraph::storage::Storage store; auto acc1 = store.Access(); auto acc2 = store.Access(); @@ -185,67 +185,67 @@ TEST(StorageV2, SnapshotIsolation) { auto vertex = acc1.CreateVertex(); auto gid = vertex.Gid(); - ASSERT_FALSE(acc2.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc2, storage::View::OLD), 0U); - ASSERT_FALSE(acc2.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 1U); - EXPECT_EQ(CountVertices(acc2, storage::View::NEW), 0U); + ASSERT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 1U); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::NEW), 0U); ASSERT_FALSE(acc1.Commit().HasError()); - ASSERT_FALSE(acc2.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc2, storage::View::OLD), 0U); - ASSERT_FALSE(acc2.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc2, storage::View::NEW), 0U); + ASSERT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::NEW), 0U); acc2.Abort(); auto acc3 = store.Access(); - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::OLD), 1U); - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::NEW), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::NEW), 1U); acc3.Abort(); } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, AccessorMove) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - ASSERT_FALSE(acc.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - ASSERT_TRUE(acc.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 1U); + ASSERT_FALSE(acc.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(acc.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 1U); - storage::Storage::Accessor moved(std::move(acc)); + memgraph::storage::Storage::Accessor moved(std::move(acc)); - ASSERT_FALSE(moved.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(moved, storage::View::OLD), 0U); - ASSERT_TRUE(moved.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(moved, storage::View::NEW), 1U); + ASSERT_FALSE(moved.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(moved, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(moved.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(moved, memgraph::storage::View::NEW), 1U); ASSERT_FALSE(moved.Commit().HasError()); } { auto acc = store.Access(); - ASSERT_TRUE(acc.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 1U); - ASSERT_TRUE(acc.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 1U); + ASSERT_TRUE(acc.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 1U); acc.Abort(); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexDeleteCommit) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); auto acc1 = store.Access(); // read transaction auto acc2 = store.Access(); // write transaction @@ -254,10 +254,10 @@ TEST(StorageV2, VertexDeleteCommit) { { auto vertex = acc2.CreateVertex(); gid = vertex.Gid(); - ASSERT_FALSE(acc2.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc2, storage::View::OLD), 0U); - ASSERT_TRUE(acc2.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc2, storage::View::NEW), 1U); + ASSERT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::NEW), 1U); ASSERT_FALSE(acc2.Commit().HasError()); } @@ -265,32 +265,32 @@ TEST(StorageV2, VertexDeleteCommit) { auto acc4 = store.Access(); // write transaction // Check whether the vertex exists in transaction 1 - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 0U); - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 0U); // Check whether the vertex exists in transaction 3 - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::OLD), 1U); - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::NEW), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::NEW), 1U); // Delete the vertex in transaction 4 { - auto vertex = acc4.FindVertex(gid, storage::View::NEW); + auto vertex = acc4.FindVertex(gid, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); - EXPECT_EQ(CountVertices(acc4, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc4, storage::View::NEW), 1U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::NEW), 1U); auto res = acc4.DeleteVertex(&*vertex); ASSERT_TRUE(res.HasValue()); - EXPECT_EQ(CountVertices(acc4, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc4, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::NEW), 0U); acc4.AdvanceCommand(); - EXPECT_EQ(CountVertices(acc4, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc4, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::NEW), 0U); ASSERT_FALSE(acc4.Commit().HasError()); } @@ -298,28 +298,28 @@ TEST(StorageV2, VertexDeleteCommit) { auto acc5 = store.Access(); // read transaction // Check whether the vertex exists in transaction 1 - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 0U); - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 0U); // Check whether the vertex exists in transaction 3 - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::OLD), 1U); - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::NEW), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::NEW), 1U); // Check whether the vertex exists in transaction 5 - ASSERT_FALSE(acc5.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc5, storage::View::OLD), 0U); - ASSERT_FALSE(acc5.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc5, storage::View::NEW), 0U); + ASSERT_FALSE(acc5.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc5, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc5.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc5, memgraph::storage::View::NEW), 0U); } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexDeleteAbort) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); auto acc1 = store.Access(); // read transaction auto acc2 = store.Access(); // write transaction @@ -328,10 +328,10 @@ TEST(StorageV2, VertexDeleteAbort) { { auto vertex = acc2.CreateVertex(); gid = vertex.Gid(); - ASSERT_FALSE(acc2.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc2, storage::View::OLD), 0U); - ASSERT_TRUE(acc2.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc2, storage::View::NEW), 1U); + ASSERT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::NEW), 1U); ASSERT_FALSE(acc2.Commit().HasError()); } @@ -339,32 +339,32 @@ TEST(StorageV2, VertexDeleteAbort) { auto acc4 = store.Access(); // write transaction (aborted) // Check whether the vertex exists in transaction 1 - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 0U); - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 0U); // Check whether the vertex exists in transaction 3 - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::OLD), 1U); - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::NEW), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::NEW), 1U); // Delete the vertex in transaction 4, but abort the transaction { - auto vertex = acc4.FindVertex(gid, storage::View::NEW); + auto vertex = acc4.FindVertex(gid, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); - EXPECT_EQ(CountVertices(acc4, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc4, storage::View::NEW), 1U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::NEW), 1U); auto res = acc4.DeleteVertex(&*vertex); ASSERT_TRUE(res.HasValue()); - EXPECT_EQ(CountVertices(acc4, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc4, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::NEW), 0U); acc4.AdvanceCommand(); - EXPECT_EQ(CountVertices(acc4, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc4, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc4, memgraph::storage::View::NEW), 0U); acc4.Abort(); } @@ -373,38 +373,38 @@ TEST(StorageV2, VertexDeleteAbort) { auto acc6 = store.Access(); // write transaction // Check whether the vertex exists in transaction 1 - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 0U); - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 0U); // Check whether the vertex exists in transaction 3 - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::OLD), 1U); - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::NEW), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::NEW), 1U); // Check whether the vertex exists in transaction 5 - ASSERT_TRUE(acc5.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc5, storage::View::OLD), 1U); - ASSERT_TRUE(acc5.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc5, storage::View::NEW), 1U); + ASSERT_TRUE(acc5.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc5, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc5.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc5, memgraph::storage::View::NEW), 1U); // Delete the vertex in transaction 6 { - auto vertex = acc6.FindVertex(gid, storage::View::NEW); + auto vertex = acc6.FindVertex(gid, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); - EXPECT_EQ(CountVertices(acc6, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc6, storage::View::NEW), 1U); + EXPECT_EQ(CountVertices(acc6, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc6, memgraph::storage::View::NEW), 1U); auto res = acc6.DeleteVertex(&*vertex); ASSERT_TRUE(res.HasValue()); - EXPECT_EQ(CountVertices(acc6, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc6, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc6, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc6, memgraph::storage::View::NEW), 0U); acc6.AdvanceCommand(); - EXPECT_EQ(CountVertices(acc6, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc6, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc6, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc6, memgraph::storage::View::NEW), 0U); ASSERT_FALSE(acc6.Commit().HasError()); } @@ -412,28 +412,28 @@ TEST(StorageV2, VertexDeleteAbort) { auto acc7 = store.Access(); // read transaction // Check whether the vertex exists in transaction 1 - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 0U); - ASSERT_FALSE(acc1.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 0U); // Check whether the vertex exists in transaction 3 - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::OLD), 1U); - ASSERT_TRUE(acc3.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc3, storage::View::NEW), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc3, memgraph::storage::View::NEW), 1U); // Check whether the vertex exists in transaction 5 - ASSERT_TRUE(acc5.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc5, storage::View::OLD), 1U); - ASSERT_TRUE(acc5.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc5, storage::View::NEW), 1U); + ASSERT_TRUE(acc5.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc5, memgraph::storage::View::OLD), 1U); + ASSERT_TRUE(acc5.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc5, memgraph::storage::View::NEW), 1U); // Check whether the vertex exists in transaction 7 - ASSERT_FALSE(acc7.FindVertex(gid, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc7, storage::View::OLD), 0U); - ASSERT_FALSE(acc7.FindVertex(gid, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc7, storage::View::NEW), 0U); + ASSERT_FALSE(acc7.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc7, memgraph::storage::View::OLD), 0U); + ASSERT_FALSE(acc7.FindVertex(gid, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc7, memgraph::storage::View::NEW), 0U); // Commit all accessors ASSERT_FALSE(acc1.Commit().HasError()); @@ -444,8 +444,8 @@ TEST(StorageV2, VertexDeleteAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexDeleteSerializationError) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertex { @@ -460,46 +460,46 @@ TEST(StorageV2, VertexDeleteSerializationError) { // Delete vertex in accessor 1 { - auto vertex = acc1.FindVertex(gid, storage::View::OLD); + auto vertex = acc1.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 1U); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 1U); { auto res = acc1.DeleteVertex(&*vertex); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 0U); } { auto res = acc1.DeleteVertex(&*vertex); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 0U); } acc1.AdvanceCommand(); - EXPECT_EQ(CountVertices(acc1, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc1, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc1, memgraph::storage::View::NEW), 0U); } // Delete vertex in accessor 2 { - auto vertex = acc2.FindVertex(gid, storage::View::OLD); + auto vertex = acc2.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - EXPECT_EQ(CountVertices(acc2, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc2, storage::View::NEW), 1U); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::NEW), 1U); auto res = acc2.DeleteVertex(&*vertex); ASSERT_TRUE(res.HasError()); - ASSERT_EQ(res.GetError(), storage::Error::SERIALIZATION_ERROR); - EXPECT_EQ(CountVertices(acc2, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc2, storage::View::NEW), 1U); + ASSERT_EQ(res.GetError(), memgraph::storage::Error::SERIALIZATION_ERROR); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::NEW), 1U); acc2.AdvanceCommand(); - EXPECT_EQ(CountVertices(acc2, storage::View::OLD), 1U); - EXPECT_EQ(CountVertices(acc2, storage::View::NEW), 1U); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::OLD), 1U); + EXPECT_EQ(CountVertices(acc2, memgraph::storage::View::NEW), 1U); } // Finalize both accessors @@ -509,19 +509,19 @@ TEST(StorageV2, VertexDeleteSerializationError) { // Check whether the vertex exists { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_FALSE(vertex); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); ASSERT_FALSE(acc.Commit().HasError()); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexDeleteSpecialCases) { - storage::Storage store; - storage::Gid gid1 = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid2 = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid1 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid2 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertex and delete it in the same transaction, but abort the // transaction @@ -529,18 +529,18 @@ TEST(StorageV2, VertexDeleteSpecialCases) { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid1 = vertex.Gid(); - ASSERT_FALSE(acc.FindVertex(gid1, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - ASSERT_TRUE(acc.FindVertex(gid1, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 1U); + ASSERT_FALSE(acc.FindVertex(gid1, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(acc.FindVertex(gid1, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 1U); auto res = acc.DeleteVertex(&vertex); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); acc.AdvanceCommand(); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); acc.Abort(); } @@ -549,72 +549,72 @@ TEST(StorageV2, VertexDeleteSpecialCases) { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid2 = vertex.Gid(); - ASSERT_FALSE(acc.FindVertex(gid2, storage::View::OLD).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - ASSERT_TRUE(acc.FindVertex(gid2, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 1U); + ASSERT_FALSE(acc.FindVertex(gid2, memgraph::storage::View::OLD).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + ASSERT_TRUE(acc.FindVertex(gid2, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 1U); auto res = acc.DeleteVertex(&vertex); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); acc.AdvanceCommand(); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); ASSERT_FALSE(acc.Commit().HasError()); } // Check whether the vertices exist { auto acc = store.Access(); - ASSERT_FALSE(acc.FindVertex(gid1, storage::View::OLD).has_value()); - ASSERT_FALSE(acc.FindVertex(gid1, storage::View::NEW).has_value()); - ASSERT_FALSE(acc.FindVertex(gid2, storage::View::OLD).has_value()); - ASSERT_FALSE(acc.FindVertex(gid2, storage::View::NEW).has_value()); - EXPECT_EQ(CountVertices(acc, storage::View::OLD), 0U); - EXPECT_EQ(CountVertices(acc, storage::View::NEW), 0U); + ASSERT_FALSE(acc.FindVertex(gid1, memgraph::storage::View::OLD).has_value()); + ASSERT_FALSE(acc.FindVertex(gid1, memgraph::storage::View::NEW).has_value()); + ASSERT_FALSE(acc.FindVertex(gid2, memgraph::storage::View::OLD).has_value()); + ASSERT_FALSE(acc.FindVertex(gid2, memgraph::storage::View::NEW).has_value()); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::OLD), 0U); + EXPECT_EQ(CountVertices(acc, memgraph::storage::View::NEW), 0U); acc.Abort(); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexDeleteLabel) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create the vertex { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - ASSERT_FALSE(acc.FindVertex(gid, storage::View::OLD).has_value()); - ASSERT_TRUE(acc.FindVertex(gid, storage::View::NEW).has_value()); + ASSERT_FALSE(acc.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + ASSERT_TRUE(acc.FindVertex(gid, memgraph::storage::View::NEW).has_value()); ASSERT_FALSE(acc.Commit().HasError()); } // Add label, delete the vertex and check the label API (same command) { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::NEW); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); // Add label 5 ASSERT_TRUE(vertex->AddLabel(label).GetValue()); // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } @@ -623,23 +623,24 @@ TEST(StorageV2, VertexDeleteLabel) { ASSERT_TRUE(acc.DeleteVertex(&*vertex).GetValue()); // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_EQ(vertex->HasLabel(label, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Labels(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_EQ(vertex->HasLabel(label, memgraph::storage::View::NEW).GetError(), + memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); // Try to add the label { auto ret = vertex->AddLabel(label); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::DELETED_OBJECT); } // Try to remove the label { auto ret = vertex->RemoveLabel(label); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::DELETED_OBJECT); } acc.Abort(); @@ -648,26 +649,26 @@ TEST(StorageV2, VertexDeleteLabel) { // Add label, delete the vertex and check the label API (different command) { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::NEW); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); // Add label 5 ASSERT_TRUE(vertex->AddLabel(label).GetValue()); // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } @@ -676,15 +677,15 @@ TEST(StorageV2, VertexDeleteLabel) { acc.AdvanceCommand(); // Check whether label 5 exists - ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex->Labels(storage::View::OLD).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } @@ -693,36 +694,39 @@ TEST(StorageV2, VertexDeleteLabel) { ASSERT_TRUE(acc.DeleteVertex(&*vertex).GetValue()); // Check whether label 5 exists - ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_EQ(vertex->HasLabel(label, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_EQ(vertex->HasLabel(label, memgraph::storage::View::NEW).GetError(), + memgraph::storage::Error::DELETED_OBJECT); { - auto labels = vertex->Labels(storage::View::OLD).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_EQ(vertex->Labels(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); // Advance command acc.AdvanceCommand(); // Check whether label 5 exists - ASSERT_EQ(vertex->HasLabel(label, storage::View::OLD).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->HasLabel(label, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->Labels(storage::View::OLD).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->Labels(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->HasLabel(label, memgraph::storage::View::OLD).GetError(), + memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->HasLabel(label, memgraph::storage::View::NEW).GetError(), + memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); // Try to add the label { auto ret = vertex->AddLabel(label); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::DELETED_OBJECT); } // Try to remove the label { auto ret = vertex->RemoveLabel(label); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::DELETED_OBJECT); } acc.Abort(); @@ -731,42 +735,42 @@ TEST(StorageV2, VertexDeleteLabel) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexDeleteProperty) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create the vertex { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - ASSERT_FALSE(acc.FindVertex(gid, storage::View::OLD).has_value()); - ASSERT_TRUE(acc.FindVertex(gid, storage::View::NEW).has_value()); + ASSERT_FALSE(acc.FindVertex(gid, memgraph::storage::View::OLD).has_value()); + ASSERT_TRUE(acc.FindVertex(gid, memgraph::storage::View::NEW).has_value()); ASSERT_FALSE(acc.Commit().HasError()); } // Set property, delete the vertex and check the property API (same command) { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::NEW); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); // Check whether property 5 exists - ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); // Set property 5 to "nandare" - ASSERT_TRUE(vertex->SetProperty(property, storage::PropertyValue("nandare"))->IsNull()); + ASSERT_TRUE(vertex->SetProperty(property, memgraph::storage::PropertyValue("nandare"))->IsNull()); // Check whether property 5 exists - ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -775,16 +779,17 @@ TEST(StorageV2, VertexDeleteProperty) { ASSERT_TRUE(acc.DeleteVertex(&*vertex).GetValue()); // Check whether label 5 exists - ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Properties(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW).GetError(), + memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); // Try to set the property { - auto ret = vertex->SetProperty(property, storage::PropertyValue("haihai")); + auto ret = vertex->SetProperty(property, memgraph::storage::PropertyValue("haihai")); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::DELETED_OBJECT); } acc.Abort(); @@ -794,26 +799,26 @@ TEST(StorageV2, VertexDeleteProperty) { // command) { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::NEW); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); // Check whether property 5 exists - ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); // Set property 5 to "nandare" - ASSERT_TRUE(vertex->SetProperty(property, storage::PropertyValue("nandare"))->IsNull()); + ASSERT_TRUE(vertex->SetProperty(property, memgraph::storage::PropertyValue("nandare"))->IsNull()); // Check whether property 5 exists - ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -822,15 +827,15 @@ TEST(StorageV2, VertexDeleteProperty) { acc.AdvanceCommand(); // Check whether property 5 exists - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -839,29 +844,32 @@ TEST(StorageV2, VertexDeleteProperty) { ASSERT_TRUE(acc.DeleteVertex(&*vertex).GetValue()); // Check whether property 5 exists - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW).GetError(), + memgraph::storage::Error::DELETED_OBJECT); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->Properties(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); // Advance command acc.AdvanceCommand(); // Check whether property 5 exists - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->Properties(storage::View::OLD).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->Properties(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD).GetError(), + memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW).GetError(), + memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); // Try to set the property { - auto ret = vertex->SetProperty(property, storage::PropertyValue("haihai")); + auto ret = vertex->SetProperty(property, memgraph::storage::PropertyValue("haihai")); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::DELETED_OBJECT); } acc.Abort(); @@ -870,8 +878,8 @@ TEST(StorageV2, VertexDeleteProperty) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexLabelCommit) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); @@ -879,8 +887,8 @@ TEST(StorageV2, VertexLabelCommit) { auto label = acc.NameToLabel("label5"); - ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::NEW)->size(), 0); { auto res = vertex.AddLabel(label); @@ -888,9 +896,9 @@ TEST(StorageV2, VertexLabelCommit) { ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex.Labels(storage::View::NEW).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } @@ -905,35 +913,35 @@ TEST(StorageV2, VertexLabelCommit) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); - ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); { - auto labels = vertex->Labels(storage::View::OLD).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } auto other_label = acc.NameToLabel("other"); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::NEW).GetValue()); acc.Abort(); } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); @@ -944,15 +952,15 @@ TEST(StorageV2, VertexLabelCommit) { ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); { - auto labels = vertex->Labels(storage::View::OLD).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); { auto res = vertex->RemoveLabel(label); @@ -964,20 +972,20 @@ TEST(StorageV2, VertexLabelCommit) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); auto other_label = acc.NameToLabel("other"); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::NEW).GetValue()); acc.Abort(); } @@ -985,8 +993,8 @@ TEST(StorageV2, VertexLabelCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexLabelAbort) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create the vertex. { @@ -999,13 +1007,13 @@ TEST(StorageV2, VertexLabelAbort) { // Add label 5, but abort the transaction. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); { auto res = vertex->AddLabel(label); @@ -1013,9 +1021,9 @@ TEST(StorageV2, VertexLabelAbort) { ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } @@ -1032,20 +1040,20 @@ TEST(StorageV2, VertexLabelAbort) { // Check that label 5 doesn't exist. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); auto other_label = acc.NameToLabel("other"); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::NEW).GetValue()); acc.Abort(); } @@ -1053,13 +1061,13 @@ TEST(StorageV2, VertexLabelAbort) { // Add label 5. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); { auto res = vertex->AddLabel(label); @@ -1067,9 +1075,9 @@ TEST(StorageV2, VertexLabelAbort) { ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } @@ -1086,29 +1094,29 @@ TEST(StorageV2, VertexLabelAbort) { // Check that label 5 exists. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); - ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); { - auto labels = vertex->Labels(storage::View::OLD).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } auto other_label = acc.NameToLabel("other"); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::NEW).GetValue()); acc.Abort(); } @@ -1116,7 +1124,7 @@ TEST(StorageV2, VertexLabelAbort) { // Remove label 5, but abort the transaction. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); @@ -1127,15 +1135,15 @@ TEST(StorageV2, VertexLabelAbort) { ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); { - auto labels = vertex->Labels(storage::View::OLD).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); { auto res = vertex->RemoveLabel(label); @@ -1149,29 +1157,29 @@ TEST(StorageV2, VertexLabelAbort) { // Check that label 5 exists. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); - ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); { - auto labels = vertex->Labels(storage::View::OLD).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } auto other_label = acc.NameToLabel("other"); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::NEW).GetValue()); acc.Abort(); } @@ -1179,7 +1187,7 @@ TEST(StorageV2, VertexLabelAbort) { // Remove label 5. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); @@ -1190,15 +1198,15 @@ TEST(StorageV2, VertexLabelAbort) { ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); { - auto labels = vertex->Labels(storage::View::OLD).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); { auto res = vertex->RemoveLabel(label); @@ -1212,20 +1220,20 @@ TEST(StorageV2, VertexLabelAbort) { // Check that label 5 doesn't exist. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label = acc.NameToLabel("label5"); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); auto other_label = acc.NameToLabel("other"); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, memgraph::storage::View::NEW).GetValue()); acc.Abort(); } @@ -1233,8 +1241,8 @@ TEST(StorageV2, VertexLabelAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexLabelSerializationError) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); @@ -1247,18 +1255,18 @@ TEST(StorageV2, VertexLabelSerializationError) { // Add label 1 in accessor 1. { - auto vertex = acc1.FindVertex(gid, storage::View::OLD); + auto vertex = acc1.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label1 = acc1.NameToLabel("label1"); auto label2 = acc1.NameToLabel("label2"); - ASSERT_FALSE(vertex->HasLabel(label1, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label1, storage::View::NEW).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label2, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label2, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label1, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label1, memgraph::storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); { auto res = vertex->AddLabel(label1); @@ -1266,13 +1274,13 @@ TEST(StorageV2, VertexLabelSerializationError) { ASSERT_TRUE(res.GetValue()); } - ASSERT_FALSE(vertex->HasLabel(label1, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex->HasLabel(label1, storage::View::NEW).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label2, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label2, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label1, memgraph::storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label1, memgraph::storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label1); } @@ -1286,23 +1294,23 @@ TEST(StorageV2, VertexLabelSerializationError) { // Add label 2 in accessor 2. { - auto vertex = acc2.FindVertex(gid, storage::View::OLD); + auto vertex = acc2.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label1 = acc2.NameToLabel("label1"); auto label2 = acc2.NameToLabel("label2"); - ASSERT_FALSE(vertex->HasLabel(label1, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label1, storage::View::NEW).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label2, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label2, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex->HasLabel(label1, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label1, memgraph::storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Labels(memgraph::storage::View::NEW)->size(), 0); { auto res = vertex->AddLabel(label1); ASSERT_TRUE(res.HasError()); - ASSERT_EQ(res.GetError(), storage::Error::SERIALIZATION_ERROR); + ASSERT_EQ(res.GetError(), memgraph::storage::Error::SERIALIZATION_ERROR); } } @@ -1313,24 +1321,24 @@ TEST(StorageV2, VertexLabelSerializationError) { // Check which labels exist. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto label1 = acc.NameToLabel("label1"); auto label2 = acc.NameToLabel("label2"); - ASSERT_TRUE(vertex->HasLabel(label1, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label2, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label1, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, memgraph::storage::View::OLD).GetValue()); { - auto labels = vertex->Labels(storage::View::OLD).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label1); } - ASSERT_TRUE(vertex->HasLabel(label1, storage::View::NEW).GetValue()); - ASSERT_FALSE(vertex->HasLabel(label2, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label1, memgraph::storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex->Labels(storage::View::NEW).GetValue(); + auto labels = vertex->Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label1); } @@ -1341,8 +1349,8 @@ TEST(StorageV2, VertexLabelSerializationError) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexPropertyCommit) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); @@ -1350,31 +1358,31 @@ TEST(StorageV2, VertexPropertyCommit) { auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = vertex.SetProperty(property, storage::PropertyValue("temporary")); + auto old_value = vertex.SetProperty(property, memgraph::storage::PropertyValue("temporary")); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } - ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "temporary"); { - auto properties = vertex.Properties(storage::View::NEW).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto old_value = vertex.SetProperty(property, storage::PropertyValue("nandare")); + auto old_value = vertex.SetProperty(property, memgraph::storage::PropertyValue("nandare")); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex.Properties(storage::View::NEW).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -1383,57 +1391,57 @@ TEST(StorageV2, VertexPropertyCommit) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); { - auto old_value = vertex->SetProperty(property, storage::PropertyValue()); + auto old_value = vertex->SetProperty(property, memgraph::storage::PropertyValue()); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = vertex->SetProperty(property, storage::PropertyValue()); + auto old_value = vertex->SetProperty(property, memgraph::storage::PropertyValue()); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } @@ -1442,20 +1450,20 @@ TEST(StorageV2, VertexPropertyCommit) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1463,8 +1471,8 @@ TEST(StorageV2, VertexPropertyCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexPropertyAbort) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create the vertex. { @@ -1477,36 +1485,36 @@ TEST(StorageV2, VertexPropertyAbort) { // Set property 5 to "nandare", but abort the transaction. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = vertex->SetProperty(property, storage::PropertyValue("temporary")); + auto old_value = vertex->SetProperty(property, memgraph::storage::PropertyValue("temporary")); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "temporary"); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto old_value = vertex->SetProperty(property, storage::PropertyValue("nandare")); + auto old_value = vertex->SetProperty(property, memgraph::storage::PropertyValue("nandare")); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -1517,20 +1525,20 @@ TEST(StorageV2, VertexPropertyAbort) { // Check that property 5 is null. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1538,36 +1546,36 @@ TEST(StorageV2, VertexPropertyAbort) { // Set property 5 to "nandare". { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = vertex->SetProperty(property, storage::PropertyValue("temporary")); + auto old_value = vertex->SetProperty(property, memgraph::storage::PropertyValue("temporary")); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "temporary"); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto old_value = vertex->SetProperty(property, storage::PropertyValue("nandare")); + auto old_value = vertex->SetProperty(property, memgraph::storage::PropertyValue("nandare")); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -1578,29 +1586,29 @@ TEST(StorageV2, VertexPropertyAbort) { // Check that property 5 is "nandare". { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1608,40 +1616,40 @@ TEST(StorageV2, VertexPropertyAbort) { // Set property 5 to null, but abort the transaction. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto old_value = vertex->SetProperty(property, storage::PropertyValue()); + auto old_value = vertex->SetProperty(property, memgraph::storage::PropertyValue()); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); acc.Abort(); } @@ -1649,29 +1657,29 @@ TEST(StorageV2, VertexPropertyAbort) { // Check that property 5 is "nandare". { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1679,40 +1687,40 @@ TEST(StorageV2, VertexPropertyAbort) { // Set property 5 to null. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto old_value = vertex->SetProperty(property, storage::PropertyValue()); + auto old_value = vertex->SetProperty(property, memgraph::storage::PropertyValue()); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex->GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1720,20 +1728,20 @@ TEST(StorageV2, VertexPropertyAbort) { // Check that property 5 is null. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1741,8 +1749,8 @@ TEST(StorageV2, VertexPropertyAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexPropertySerializationError) { - storage::Storage store; - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store; + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); @@ -1755,32 +1763,32 @@ TEST(StorageV2, VertexPropertySerializationError) { // Set property 1 to 123 in accessor 1. { - auto vertex = acc1.FindVertex(gid, storage::View::OLD); + auto vertex = acc1.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property1 = acc1.NameToProperty("property1"); auto property2 = acc1.NameToProperty("property2"); - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = vertex->SetProperty(property1, storage::PropertyValue(123)); + auto old_value = vertex->SetProperty(property1, memgraph::storage::PropertyValue(123)); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex->GetProperty(property1, storage::View::NEW)->ValueInt(), 123); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property1, memgraph::storage::View::NEW)->ValueInt(), 123); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property1].ValueInt(), 123); } @@ -1788,23 +1796,23 @@ TEST(StorageV2, VertexPropertySerializationError) { // Set property 2 to "nandare" in accessor 2. { - auto vertex = acc2.FindVertex(gid, storage::View::OLD); + auto vertex = acc2.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property1 = acc2.NameToProperty("property1"); auto property2 = acc2.NameToProperty("property2"); - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW)->size(), 0); { - auto res = vertex->SetProperty(property2, storage::PropertyValue("nandare")); + auto res = vertex->SetProperty(property2, memgraph::storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasError()); - ASSERT_EQ(res.GetError(), storage::Error::SERIALIZATION_ERROR); + ASSERT_EQ(res.GetError(), memgraph::storage::Error::SERIALIZATION_ERROR); } } @@ -1815,24 +1823,24 @@ TEST(StorageV2, VertexPropertySerializationError) { // Check which properties exist. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto property1 = acc.NameToProperty("property1"); auto property2 = acc.NameToProperty("property2"); - ASSERT_EQ(vertex->GetProperty(property1, storage::View::OLD)->ValueInt(), 123); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property1, memgraph::storage::View::OLD)->ValueInt(), 123); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); { - auto properties = vertex->Properties(storage::View::OLD).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property1].ValueInt(), 123); } - ASSERT_EQ(vertex->GetProperty(property1, storage::View::NEW)->ValueInt(), 123); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property1, memgraph::storage::View::NEW)->ValueInt(), 123); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); { - auto properties = vertex->Properties(storage::View::NEW).GetValue(); + auto properties = vertex->Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property1].ValueInt(), 123); } @@ -1843,7 +1851,7 @@ TEST(StorageV2, VertexPropertySerializationError) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, VertexLabelPropertyMixed) { - storage::Storage store; + memgraph::storage::Storage store; auto acc = store.Access(); auto vertex = acc.CreateVertex(); @@ -1851,66 +1859,66 @@ TEST(StorageV2, VertexLabelPropertyMixed) { auto property = acc.NameToProperty("property5"); // Check whether label 5 and property 5 exist - ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::NEW)->size(), 0); // Add label 5 ASSERT_TRUE(vertex.AddLabel(label).GetValue()); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex.Labels(storage::View::NEW).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::NEW)->size(), 0); // Advance command acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex.Labels(storage::View::OLD).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } { - auto labels = vertex.Labels(storage::View::NEW).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex.GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex.Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex.GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::NEW)->size(), 0); // Set property 5 to "nandare" - ASSERT_TRUE(vertex.SetProperty(property, storage::PropertyValue("nandare"))->IsNull()); + ASSERT_TRUE(vertex.SetProperty(property, memgraph::storage::PropertyValue("nandare"))->IsNull()); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex.Labels(storage::View::OLD).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } { - auto labels = vertex.Labels(storage::View::NEW).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex.GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); - ASSERT_EQ(vertex.Properties(storage::View::OLD)->size(), 0); + ASSERT_TRUE(vertex.GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::OLD)->size(), 0); { - auto properties = vertex.Properties(storage::View::NEW).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -1919,56 +1927,56 @@ TEST(StorageV2, VertexLabelPropertyMixed) { acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex.Labels(storage::View::OLD).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } { - auto labels = vertex.Labels(storage::View::NEW).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); - ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = vertex.Properties(storage::View::OLD).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto properties = vertex.Properties(storage::View::NEW).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } // Set property 5 to "haihai" - ASSERT_FALSE(vertex.SetProperty(property, storage::PropertyValue("haihai"))->IsNull()); + ASSERT_FALSE(vertex.SetProperty(property, memgraph::storage::PropertyValue("haihai"))->IsNull()); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex.Labels(storage::View::OLD).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } { - auto labels = vertex.Labels(storage::View::NEW).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); - ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "haihai"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "haihai"); { - auto properties = vertex.Properties(storage::View::OLD).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto properties = vertex.Properties(storage::View::NEW).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "haihai"); } @@ -1977,27 +1985,27 @@ TEST(StorageV2, VertexLabelPropertyMixed) { acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex.Labels(storage::View::OLD).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } { - auto labels = vertex.Labels(storage::View::NEW).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), "haihai"); - ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "haihai"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "haihai"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "haihai"); { - auto properties = vertex.Properties(storage::View::OLD).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "haihai"); } { - auto properties = vertex.Properties(storage::View::NEW).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "haihai"); } @@ -2006,23 +2014,23 @@ TEST(StorageV2, VertexLabelPropertyMixed) { ASSERT_TRUE(vertex.RemoveLabel(label).GetValue()); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); { - auto labels = vertex.Labels(storage::View::OLD).GetValue(); + auto labels = vertex.Labels(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label); } - ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), "haihai"); - ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "haihai"); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "haihai"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "haihai"); { - auto properties = vertex.Properties(storage::View::OLD).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "haihai"); } { - auto properties = vertex.Properties(storage::View::NEW).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "haihai"); } @@ -2031,59 +2039,59 @@ TEST(StorageV2, VertexLabelPropertyMixed) { acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_FALSE(vertex.HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex.Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), "haihai"); - ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "haihai"); + ASSERT_FALSE(vertex.HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "haihai"); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "haihai"); { - auto properties = vertex.Properties(storage::View::OLD).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "haihai"); } { - auto properties = vertex.Properties(storage::View::NEW).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "haihai"); } // Set property 5 to null - ASSERT_FALSE(vertex.SetProperty(property, storage::PropertyValue())->IsNull()); + ASSERT_FALSE(vertex.SetProperty(property, memgraph::storage::PropertyValue())->IsNull()); // Check whether label 5 and property 5 exist - ASSERT_FALSE(vertex.HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex.Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), "haihai"); - ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); + ASSERT_FALSE(vertex.HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "haihai"); + ASSERT_TRUE(vertex.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); { - auto properties = vertex.Properties(storage::View::OLD).GetValue(); + auto properties = vertex.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "haihai"); } - ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::NEW)->size(), 0); // Advance command acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_FALSE(vertex.HasLabel(label, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); - ASSERT_EQ(vertex.Labels(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex.Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); + ASSERT_FALSE(vertex.HasLabel(label, memgraph::storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, memgraph::storage::View::NEW).GetValue()); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::NEW)->size(), 0); + ASSERT_TRUE(vertex.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::NEW)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } TEST(StorageV2, VertexPropertyClear) { - storage::Storage store; - storage::Gid gid; + memgraph::storage::Storage store; + memgraph::storage::Gid gid; auto property1 = store.NameToProperty("property1"); auto property2 = store.NameToProperty("property2"); { @@ -2091,7 +2099,7 @@ TEST(StorageV2, VertexPropertyClear) { auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - auto old_value = vertex.SetProperty(property1, storage::PropertyValue("value")); + auto old_value = vertex.SetProperty(property1, memgraph::storage::PropertyValue("value")); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); @@ -2099,13 +2107,13 @@ TEST(StorageV2, VertexPropertyClear) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_EQ(vertex->GetProperty(property1, storage::View::OLD)->ValueString(), "value"); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::OLD)->IsNull()); - ASSERT_THAT(vertex->Properties(storage::View::OLD).GetValue(), - UnorderedElementsAre(std::pair(property1, storage::PropertyValue("value")))); + ASSERT_EQ(vertex->GetProperty(property1, memgraph::storage::View::OLD)->ValueString(), "value"); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); + ASSERT_THAT(vertex->Properties(memgraph::storage::View::OLD).GetValue(), + UnorderedElementsAre(std::pair(property1, memgraph::storage::PropertyValue("value")))); { auto old_values = vertex->ClearProperties(); @@ -2113,9 +2121,9 @@ TEST(StorageV2, VertexPropertyClear) { ASSERT_FALSE(old_values->empty()); } - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW).GetValue().size(), 0); { auto old_values = vertex->ClearProperties(); @@ -2123,18 +2131,18 @@ TEST(StorageV2, VertexPropertyClear) { ASSERT_TRUE(old_values->empty()); } - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW).GetValue().size(), 0); acc.Abort(); } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto old_value = vertex->SetProperty(property2, storage::PropertyValue(42)); + auto old_value = vertex->SetProperty(property2, memgraph::storage::PropertyValue(42)); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); @@ -2142,14 +2150,14 @@ TEST(StorageV2, VertexPropertyClear) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_EQ(vertex->GetProperty(property1, storage::View::OLD)->ValueString(), "value"); - ASSERT_EQ(vertex->GetProperty(property2, storage::View::OLD)->ValueInt(), 42); - ASSERT_THAT(vertex->Properties(storage::View::OLD).GetValue(), - UnorderedElementsAre(std::pair(property1, storage::PropertyValue("value")), - std::pair(property2, storage::PropertyValue(42)))); + ASSERT_EQ(vertex->GetProperty(property1, memgraph::storage::View::OLD)->ValueString(), "value"); + ASSERT_EQ(vertex->GetProperty(property2, memgraph::storage::View::OLD)->ValueInt(), 42); + ASSERT_THAT(vertex->Properties(memgraph::storage::View::OLD).GetValue(), + UnorderedElementsAre(std::pair(property1, memgraph::storage::PropertyValue("value")), + std::pair(property2, memgraph::storage::PropertyValue(42)))); { auto old_values = vertex->ClearProperties(); @@ -2157,9 +2165,9 @@ TEST(StorageV2, VertexPropertyClear) { ASSERT_FALSE(old_values->empty()); } - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW).GetValue().size(), 0); { auto old_values = vertex->ClearProperties(); @@ -2167,27 +2175,27 @@ TEST(StorageV2, VertexPropertyClear) { ASSERT_TRUE(old_values->empty()); } - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW).GetValue().size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(vertex->Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(vertex->GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->Properties(memgraph::storage::View::NEW).GetValue().size(), 0); acc.Abort(); } } TEST(StorageV2, VertexNonexistentLabelPropertyEdgeAPI) { - storage::Storage store; + memgraph::storage::Storage store; auto label = store.NameToLabel("label"); auto property = store.NameToProperty("property"); @@ -2196,55 +2204,59 @@ TEST(StorageV2, VertexNonexistentLabelPropertyEdgeAPI) { auto vertex = acc.CreateVertex(); // Check state before (OLD view). - ASSERT_EQ(vertex.Labels(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.HasLabel(label, storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.Properties(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.InEdges(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.OutEdges(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.InDegree(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.OutDegree(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.HasLabel(label, memgraph::storage::View::OLD).GetError(), + memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::OLD).GetError(), + memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.InEdges(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.OutEdges(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.InDegree(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.OutDegree(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); // Check state before (NEW view). - ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex.HasLabel(label, storage::View::NEW), false); - ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex.GetProperty(property, storage::View::NEW), storage::PropertyValue()); - ASSERT_EQ(vertex.InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex.OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex.InDegree(storage::View::NEW), 0); - ASSERT_EQ(*vertex.OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex.HasLabel(label, memgraph::storage::View::NEW), false); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex.GetProperty(property, memgraph::storage::View::NEW), memgraph::storage::PropertyValue()); + ASSERT_EQ(vertex.InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex.OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex.InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(*vertex.OutDegree(memgraph::storage::View::NEW), 0); // Modify vertex. ASSERT_TRUE(vertex.AddLabel(label).HasValue()); - ASSERT_TRUE(vertex.SetProperty(property, storage::PropertyValue("value")).HasValue()); + ASSERT_TRUE(vertex.SetProperty(property, memgraph::storage::PropertyValue("value")).HasValue()); ASSERT_TRUE(acc.CreateEdge(&vertex, &vertex, acc.NameToEdgeType("edge")).HasValue()); // Check state after (OLD view). - ASSERT_EQ(vertex.Labels(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.HasLabel(label, storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.Properties(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.InEdges(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.OutEdges(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.InDegree(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(vertex.OutDegree(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.HasLabel(label, memgraph::storage::View::OLD).GetError(), + memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.GetProperty(property, memgraph::storage::View::OLD).GetError(), + memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.InEdges(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.OutEdges(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.InDegree(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(vertex.OutDegree(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); // Check state after (NEW view). - ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 1); - ASSERT_EQ(*vertex.HasLabel(label, storage::View::NEW), true); - ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 1); - ASSERT_EQ(*vertex.GetProperty(property, storage::View::NEW), storage::PropertyValue("value")); - ASSERT_EQ(vertex.InEdges(storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex.OutEdges(storage::View::NEW)->size(), 1); - ASSERT_EQ(*vertex.InDegree(storage::View::NEW), 1); - ASSERT_EQ(*vertex.OutDegree(storage::View::NEW), 1); + ASSERT_EQ(vertex.Labels(memgraph::storage::View::NEW)->size(), 1); + ASSERT_EQ(*vertex.HasLabel(label, memgraph::storage::View::NEW), true); + ASSERT_EQ(vertex.Properties(memgraph::storage::View::NEW)->size(), 1); + ASSERT_EQ(*vertex.GetProperty(property, memgraph::storage::View::NEW), memgraph::storage::PropertyValue("value")); + ASSERT_EQ(vertex.InEdges(memgraph::storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex.OutEdges(memgraph::storage::View::NEW)->size(), 1); + ASSERT_EQ(*vertex.InDegree(memgraph::storage::View::NEW), 1); + ASSERT_EQ(*vertex.OutDegree(memgraph::storage::View::NEW), 1); ASSERT_FALSE(acc.Commit().HasError()); } TEST(StorageV2, VertexVisibilitySingleTransaction) { - storage::Storage store; + memgraph::storage::Storage store; auto acc1 = store.Access(); auto acc2 = store.Access(); @@ -2252,47 +2264,47 @@ TEST(StorageV2, VertexVisibilitySingleTransaction) { auto vertex = acc1.CreateVertex(); auto gid = vertex.Gid(); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); ASSERT_TRUE(vertex.AddLabel(acc1.NameToLabel("label")).HasValue()); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); - ASSERT_TRUE(vertex.SetProperty(acc1.NameToProperty("meaning"), storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(vertex.SetProperty(acc1.NameToProperty("meaning"), memgraph::storage::PropertyValue(42)).HasValue()); auto acc3 = store.Access(); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); ASSERT_TRUE(acc1.DeleteVertex(&vertex).HasValue()); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc1.AdvanceCommand(); acc3.AdvanceCommand(); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc1.Abort(); acc2.Abort(); @@ -2300,8 +2312,8 @@ TEST(StorageV2, VertexVisibilitySingleTransaction) { } TEST(StorageV2, VertexVisibilityMultipleTransactions) { - storage::Storage store; - storage::Gid gid; + memgraph::storage::Storage store; + memgraph::storage::Gid gid; { auto acc1 = store.Access(); @@ -2310,24 +2322,24 @@ TEST(StorageV2, VertexVisibilityMultipleTransactions) { auto vertex = acc1.CreateVertex(); gid = vertex.Gid(); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); acc2.AdvanceCommand(); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); acc1.AdvanceCommand(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc2.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); ASSERT_FALSE(acc1.Commit().HasError()); ASSERT_FALSE(acc2.Commit().HasError()); @@ -2337,72 +2349,72 @@ TEST(StorageV2, VertexVisibilityMultipleTransactions) { auto acc1 = store.Access(); auto acc2 = store.Access(); - auto vertex = acc1.FindVertex(gid, storage::View::OLD); + auto vertex = acc1.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); ASSERT_TRUE(vertex->AddLabel(acc1.NameToLabel("label")).HasValue()); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); acc1.AdvanceCommand(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); acc2.AdvanceCommand(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); - ASSERT_TRUE(vertex->SetProperty(acc1.NameToProperty("meaning"), storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(vertex->SetProperty(acc1.NameToProperty("meaning"), memgraph::storage::PropertyValue(42)).HasValue()); auto acc3 = store.Access(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc1.AdvanceCommand(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc2.AdvanceCommand(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc3.AdvanceCommand(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); ASSERT_FALSE(acc1.Commit().HasError()); ASSERT_FALSE(acc2.Commit().HasError()); @@ -2413,46 +2425,46 @@ TEST(StorageV2, VertexVisibilityMultipleTransactions) { auto acc1 = store.Access(); auto acc2 = store.Access(); - auto vertex = acc1.FindVertex(gid, storage::View::OLD); + auto vertex = acc1.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); ASSERT_TRUE(acc1.DeleteVertex(&*vertex).HasValue()); auto acc3 = store.Access(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc2.AdvanceCommand(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc1.AdvanceCommand(); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc3.AdvanceCommand(); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc1.Abort(); acc2.Abort(); @@ -2462,13 +2474,13 @@ TEST(StorageV2, VertexVisibilityMultipleTransactions) { { auto acc = store.Access(); - EXPECT_TRUE(acc.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc.FindVertex(gid, memgraph::storage::View::NEW)); acc.AdvanceCommand(); - EXPECT_TRUE(acc.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc.FindVertex(gid, memgraph::storage::View::NEW)); acc.Abort(); } @@ -2477,46 +2489,46 @@ TEST(StorageV2, VertexVisibilityMultipleTransactions) { auto acc1 = store.Access(); auto acc2 = store.Access(); - auto vertex = acc1.FindVertex(gid, storage::View::OLD); + auto vertex = acc1.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); ASSERT_TRUE(acc1.DeleteVertex(&*vertex).HasValue()); auto acc3 = store.Access(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc2.AdvanceCommand(); - EXPECT_TRUE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_TRUE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc1.AdvanceCommand(); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); acc3.AdvanceCommand(); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc1.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc2.FindVertex(gid, storage::View::NEW)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::OLD)); - EXPECT_TRUE(acc3.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc1.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc2.FindVertex(gid, memgraph::storage::View::NEW)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_TRUE(acc3.FindVertex(gid, memgraph::storage::View::NEW)); ASSERT_FALSE(acc1.Commit().HasError()); ASSERT_FALSE(acc2.Commit().HasError()); @@ -2526,13 +2538,13 @@ TEST(StorageV2, VertexVisibilityMultipleTransactions) { { auto acc = store.Access(); - EXPECT_FALSE(acc.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc.FindVertex(gid, memgraph::storage::View::NEW)); acc.AdvanceCommand(); - EXPECT_FALSE(acc.FindVertex(gid, storage::View::OLD)); - EXPECT_FALSE(acc.FindVertex(gid, storage::View::NEW)); + EXPECT_FALSE(acc.FindVertex(gid, memgraph::storage::View::OLD)); + EXPECT_FALSE(acc.FindVertex(gid, memgraph::storage::View::NEW)); acc.Abort(); } @@ -2540,12 +2552,12 @@ TEST(StorageV2, VertexVisibilityMultipleTransactions) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2, DeletedVertexAccessor) { - storage::Storage store; + memgraph::storage::Storage store; const auto property = store.NameToProperty("property"); - const storage::PropertyValue property_value{"property_value"}; + const memgraph::storage::PropertyValue property_value{"property_value"}; - std::optional gid; + std::optional gid; // Create the vertex { auto acc = store.Access(); @@ -2556,7 +2568,7 @@ TEST(StorageV2, DeletedVertexAccessor) { } auto acc = store.Access(); - auto vertex = acc.FindVertex(*gid, storage::View::OLD); + auto vertex = acc.FindVertex(*gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); auto maybe_deleted_vertex = acc.DeleteVertex(&*vertex); ASSERT_FALSE(maybe_deleted_vertex.HasError()); @@ -2567,7 +2579,7 @@ TEST(StorageV2, DeletedVertexAccessor) { ASSERT_TRUE(deleted_vertex->ClearProperties().HasError()); // you can call read only methods - const auto maybe_property = deleted_vertex->GetProperty(property, storage::View::OLD); + const auto maybe_property = deleted_vertex->GetProperty(property, memgraph::storage::View::OLD); ASSERT_FALSE(maybe_property.HasError()); ASSERT_EQ(property_value, *maybe_property); ASSERT_FALSE(acc.Commit().HasError()); @@ -2576,7 +2588,7 @@ TEST(StorageV2, DeletedVertexAccessor) { // you can call read only methods and get valid results even after the // transaction which deleted the vertex committed, but only if the transaction // accessor is still alive - const auto maybe_property = deleted_vertex->GetProperty(property, storage::View::OLD); + const auto maybe_property = deleted_vertex->GetProperty(property, memgraph::storage::View::OLD); ASSERT_FALSE(maybe_property.HasError()); ASSERT_EQ(property_value, *maybe_property); } diff --git a/tests/unit/storage_v2_constraints.cpp b/tests/unit/storage_v2_constraints.cpp index 5329b3ada..5c0fde426 100644 --- a/tests/unit/storage_v2_constraints.cpp +++ b/tests/unit/storage_v2_constraints.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ #include "storage/v2/storage.hpp" // NOLINTNEXTLINE(google-build-using-namespace) -using namespace storage; +using namespace memgraph::storage; using testing::UnorderedElementsAre; diff --git a/tests/unit/storage_v2_decoder_encoder.cpp b/tests/unit/storage_v2_decoder_encoder.cpp index ae7396c88..9e2555ebd 100644 --- a/tests/unit/storage_v2_decoder_encoder.cpp +++ b/tests/unit/storage_v2_decoder_encoder.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -47,9 +47,9 @@ class DecoderEncoderTest : public ::testing::Test { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_F(DecoderEncoderTest, ReadMarker) { { - storage::durability::Encoder encoder; + memgraph::storage::durability::Encoder encoder; encoder.Initialize(storage_file, kTestMagic, kTestVersion); - for (const auto &item : storage::durability::kMarkersAll) { + for (const auto &item : memgraph::storage::durability::kMarkersAll) { encoder.WriteMarker(item); } { @@ -59,11 +59,11 @@ TEST_F(DecoderEncoderTest, ReadMarker) { encoder.Finalize(); } { - storage::durability::Decoder decoder; + memgraph::storage::durability::Decoder decoder; auto version = decoder.Initialize(storage_file, kTestMagic); ASSERT_TRUE(version); ASSERT_EQ(*version, kTestVersion); - for (const auto &item : storage::durability::kMarkersAll) { + for (const auto &item : memgraph::storage::durability::kMarkersAll) { auto decoded = decoder.ReadMarker(); ASSERT_TRUE(decoded); ASSERT_EQ(*decoded, item); @@ -81,7 +81,7 @@ TEST_F(DecoderEncoderTest, ReadMarker) { TEST_F(DecoderEncoderTest, Read##name) { \ std::vector dataset{__VA_ARGS__}; \ { \ - storage::durability::Encoder encoder; \ + memgraph::storage::durability::Encoder encoder; \ encoder.Initialize(storage_file, kTestMagic, kTestVersion); \ for (const auto &item : dataset) { \ encoder.Write##name(item); \ @@ -93,7 +93,7 @@ TEST_F(DecoderEncoderTest, ReadMarker) { encoder.Finalize(); \ } \ { \ - storage::durability::Decoder decoder; \ + memgraph::storage::durability::Decoder decoder; \ auto version = decoder.Initialize(storage_file, kTestMagic); \ ASSERT_TRUE(version); \ ASSERT_EQ(*version, kTestVersion); \ @@ -125,21 +125,23 @@ GENERATE_READ_TEST(String, std::string, "hello", "world", "nandare", "haihaihai" std::string(100000, 'a')); // NOLINTNEXTLINE(hicpp-special-member-functions) -GENERATE_READ_TEST(PropertyValue, storage::PropertyValue, storage::PropertyValue(), storage::PropertyValue(false), - storage::PropertyValue(true), storage::PropertyValue(123L), storage::PropertyValue(123.5), - storage::PropertyValue("nandare"), - storage::PropertyValue(std::vector{storage::PropertyValue("nandare"), - storage::PropertyValue(123L)}), - storage::PropertyValue(std::map{ - {"nandare", storage::PropertyValue(123)}}), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))); +GENERATE_READ_TEST( + PropertyValue, memgraph::storage::PropertyValue, memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(false), memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123L), memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue("nandare"), memgraph::storage::PropertyValue(123L)}), + memgraph::storage::PropertyValue(std::map{ + {"nandare", memgraph::storage::PropertyValue(123)}}), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))); // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define GENERATE_SKIP_TEST(name, type, ...) \ TEST_F(DecoderEncoderTest, Skip##name) { \ std::vector dataset{__VA_ARGS__}; \ { \ - storage::durability::Encoder encoder; \ + memgraph::storage::durability::Encoder encoder; \ encoder.Initialize(storage_file, kTestMagic, kTestVersion); \ for (const auto &item : dataset) { \ encoder.Write##name(item); \ @@ -151,7 +153,7 @@ GENERATE_READ_TEST(PropertyValue, storage::PropertyValue, storage::PropertyValue encoder.Finalize(); \ } \ { \ - storage::durability::Decoder decoder; \ + memgraph::storage::durability::Decoder decoder; \ auto version = decoder.Initialize(storage_file, kTestMagic); \ ASSERT_TRUE(version); \ ASSERT_EQ(*version, kTestVersion); \ @@ -170,58 +172,60 @@ GENERATE_READ_TEST(PropertyValue, storage::PropertyValue, storage::PropertyValue GENERATE_SKIP_TEST(String, std::string, "hello", "world", "nandare", "haihaihai", std::string(500000, 'a')); // NOLINTNEXTLINE(hicpp-special-member-functions) -GENERATE_SKIP_TEST(PropertyValue, storage::PropertyValue, storage::PropertyValue(), storage::PropertyValue(false), - storage::PropertyValue(true), storage::PropertyValue(123L), storage::PropertyValue(123.5), - storage::PropertyValue("nandare"), - storage::PropertyValue(std::vector{storage::PropertyValue("nandare"), - storage::PropertyValue(123L)}), - storage::PropertyValue(std::map{ - {"nandare", storage::PropertyValue(123)}}), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))); +GENERATE_SKIP_TEST( + PropertyValue, memgraph::storage::PropertyValue, memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(false), memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123L), memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue("nandare"), memgraph::storage::PropertyValue(123L)}), + memgraph::storage::PropertyValue(std::map{ + {"nandare", memgraph::storage::PropertyValue(123)}}), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))); // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define GENERATE_PARTIAL_READ_TEST(name, value) \ - TEST_F(DecoderEncoderTest, PartialRead##name) { \ - { \ - storage::durability::Encoder encoder; \ - encoder.Initialize(storage_file, kTestMagic, kTestVersion); \ - encoder.Write##name(value); \ - encoder.Finalize(); \ - } \ - { \ - utils::InputFile ifile; \ - utils::OutputFile ofile; \ - ASSERT_TRUE(ifile.Open(storage_file)); \ - ofile.Open(alternate_file, utils::OutputFile::Mode::OVERWRITE_EXISTING); \ - auto size = ifile.GetSize(); \ - for (size_t i = 0; i <= size; ++i) { \ - if (i != 0) { \ - uint8_t byte; \ - ASSERT_TRUE(ifile.Read(&byte, sizeof(byte))); \ - ofile.Write(&byte, sizeof(byte)); \ - ofile.Sync(); \ - } \ - storage::durability::Decoder decoder; \ - auto version = decoder.Initialize(alternate_file, kTestMagic); \ - if (i < kTestMagic.size() + sizeof(kTestVersion)) { \ - ASSERT_FALSE(version); \ - } else { \ - ASSERT_TRUE(version); \ - ASSERT_EQ(*version, kTestVersion); \ - } \ - if (i != size) { \ - ASSERT_FALSE(decoder.Read##name()); \ - } else { \ - auto decoded = decoder.Read##name(); \ - ASSERT_TRUE(decoded); \ - ASSERT_EQ(*decoded, value); \ - } \ - } \ - } \ +#define GENERATE_PARTIAL_READ_TEST(name, value) \ + TEST_F(DecoderEncoderTest, PartialRead##name) { \ + { \ + memgraph::storage::durability::Encoder encoder; \ + encoder.Initialize(storage_file, kTestMagic, kTestVersion); \ + encoder.Write##name(value); \ + encoder.Finalize(); \ + } \ + { \ + memgraph::utils::InputFile ifile; \ + memgraph::utils::OutputFile ofile; \ + ASSERT_TRUE(ifile.Open(storage_file)); \ + ofile.Open(alternate_file, memgraph::utils::OutputFile::Mode::OVERWRITE_EXISTING); \ + auto size = ifile.GetSize(); \ + for (size_t i = 0; i <= size; ++i) { \ + if (i != 0) { \ + uint8_t byte; \ + ASSERT_TRUE(ifile.Read(&byte, sizeof(byte))); \ + ofile.Write(&byte, sizeof(byte)); \ + ofile.Sync(); \ + } \ + memgraph::storage::durability::Decoder decoder; \ + auto version = decoder.Initialize(alternate_file, kTestMagic); \ + if (i < kTestMagic.size() + sizeof(kTestVersion)) { \ + ASSERT_FALSE(version); \ + } else { \ + ASSERT_TRUE(version); \ + ASSERT_EQ(*version, kTestVersion); \ + } \ + if (i != size) { \ + ASSERT_FALSE(decoder.Read##name()); \ + } else { \ + auto decoded = decoder.Read##name(); \ + ASSERT_TRUE(decoded); \ + ASSERT_EQ(*decoded, value); \ + } \ + } \ + } \ } // NOLINTNEXTLINE(hicpp-special-member-functions) -GENERATE_PARTIAL_READ_TEST(Marker, storage::durability::Marker::SECTION_VERTEX); +GENERATE_PARTIAL_READ_TEST(Marker, memgraph::storage::durability::Marker::SECTION_VERTEX); // NOLINTNEXTLINE(hicpp-special-member-functions) GENERATE_PARTIAL_READ_TEST(Bool, false); @@ -236,140 +240,144 @@ GENERATE_PARTIAL_READ_TEST(Double, 3.1415926535); GENERATE_PARTIAL_READ_TEST(String, "nandare"); // NOLINTNEXTLINE(hicpp-special-member-functions) -GENERATE_PARTIAL_READ_TEST(PropertyValue, - storage::PropertyValue(std::vector{ - storage::PropertyValue(), storage::PropertyValue(true), storage::PropertyValue(123L), - storage::PropertyValue(123.5), storage::PropertyValue("nandare"), - storage::PropertyValue{ - std::map{{"haihai", storage::PropertyValue()}}}, - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))})); +GENERATE_PARTIAL_READ_TEST( + PropertyValue, + memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(), memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123L), memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue{ + std::map{{"haihai", memgraph::storage::PropertyValue()}}}, + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))})); // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define GENERATE_PARTIAL_SKIP_TEST(name, value) \ - TEST_F(DecoderEncoderTest, PartialSkip##name) { \ - { \ - storage::durability::Encoder encoder; \ - encoder.Initialize(storage_file, kTestMagic, kTestVersion); \ - encoder.Write##name(value); \ - encoder.Finalize(); \ - } \ - { \ - utils::InputFile ifile; \ - utils::OutputFile ofile; \ - ASSERT_TRUE(ifile.Open(storage_file)); \ - ofile.Open(alternate_file, utils::OutputFile::Mode::OVERWRITE_EXISTING); \ - auto size = ifile.GetSize(); \ - for (size_t i = 0; i <= size; ++i) { \ - if (i != 0) { \ - uint8_t byte; \ - ASSERT_TRUE(ifile.Read(&byte, sizeof(byte))); \ - ofile.Write(&byte, sizeof(byte)); \ - ofile.Sync(); \ - } \ - storage::durability::Decoder decoder; \ - auto version = decoder.Initialize(alternate_file, kTestMagic); \ - if (i < kTestMagic.size() + sizeof(kTestVersion)) { \ - ASSERT_FALSE(version); \ - } else { \ - ASSERT_TRUE(version); \ - ASSERT_EQ(*version, kTestVersion); \ - } \ - if (i != size) { \ - ASSERT_FALSE(decoder.Skip##name()); \ - } else { \ - ASSERT_TRUE(decoder.Skip##name()); \ - } \ - } \ - } \ +#define GENERATE_PARTIAL_SKIP_TEST(name, value) \ + TEST_F(DecoderEncoderTest, PartialSkip##name) { \ + { \ + memgraph::storage::durability::Encoder encoder; \ + encoder.Initialize(storage_file, kTestMagic, kTestVersion); \ + encoder.Write##name(value); \ + encoder.Finalize(); \ + } \ + { \ + memgraph::utils::InputFile ifile; \ + memgraph::utils::OutputFile ofile; \ + ASSERT_TRUE(ifile.Open(storage_file)); \ + ofile.Open(alternate_file, memgraph::utils::OutputFile::Mode::OVERWRITE_EXISTING); \ + auto size = ifile.GetSize(); \ + for (size_t i = 0; i <= size; ++i) { \ + if (i != 0) { \ + uint8_t byte; \ + ASSERT_TRUE(ifile.Read(&byte, sizeof(byte))); \ + ofile.Write(&byte, sizeof(byte)); \ + ofile.Sync(); \ + } \ + memgraph::storage::durability::Decoder decoder; \ + auto version = decoder.Initialize(alternate_file, kTestMagic); \ + if (i < kTestMagic.size() + sizeof(kTestVersion)) { \ + ASSERT_FALSE(version); \ + } else { \ + ASSERT_TRUE(version); \ + ASSERT_EQ(*version, kTestVersion); \ + } \ + if (i != size) { \ + ASSERT_FALSE(decoder.Skip##name()); \ + } else { \ + ASSERT_TRUE(decoder.Skip##name()); \ + } \ + } \ + } \ } // NOLINTNEXTLINE(hicpp-special-member-functions) GENERATE_PARTIAL_SKIP_TEST(String, "nandare"); // NOLINTNEXTLINE(hicpp-special-member-functions) -GENERATE_PARTIAL_SKIP_TEST(PropertyValue, - storage::PropertyValue(std::vector{ - storage::PropertyValue(), storage::PropertyValue(true), storage::PropertyValue(123L), - storage::PropertyValue(123.5), storage::PropertyValue("nandare"), - storage::PropertyValue{ - std::map{{"haihai", storage::PropertyValue()}}}, - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23))})); +GENERATE_PARTIAL_SKIP_TEST( + PropertyValue, + memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(), memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123L), memgraph::storage::PropertyValue(123.5), + memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue{ + std::map{{"haihai", memgraph::storage::PropertyValue()}}}, + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23))})); // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_F(DecoderEncoderTest, PropertyValueInvalidMarker) { { - storage::durability::Encoder encoder; + memgraph::storage::durability::Encoder encoder; encoder.Initialize(storage_file, kTestMagic, kTestVersion); - encoder.WritePropertyValue(storage::PropertyValue(123L)); + encoder.WritePropertyValue(memgraph::storage::PropertyValue(123L)); encoder.Finalize(); } { - utils::OutputFile file; - file.Open(storage_file, utils::OutputFile::Mode::OVERWRITE_EXISTING); - for (auto marker : storage::durability::kMarkersAll) { + memgraph::utils::OutputFile file; + file.Open(storage_file, memgraph::utils::OutputFile::Mode::OVERWRITE_EXISTING); + for (auto marker : memgraph::storage::durability::kMarkersAll) { bool valid_marker; switch (marker) { - case storage::durability::Marker::TYPE_NULL: - case storage::durability::Marker::TYPE_BOOL: - case storage::durability::Marker::TYPE_INT: - case storage::durability::Marker::TYPE_DOUBLE: - case storage::durability::Marker::TYPE_STRING: - case storage::durability::Marker::TYPE_LIST: - case storage::durability::Marker::TYPE_MAP: - case storage::durability::Marker::TYPE_TEMPORAL_DATA: - case storage::durability::Marker::TYPE_PROPERTY_VALUE: + case memgraph::storage::durability::Marker::TYPE_NULL: + case memgraph::storage::durability::Marker::TYPE_BOOL: + case memgraph::storage::durability::Marker::TYPE_INT: + case memgraph::storage::durability::Marker::TYPE_DOUBLE: + case memgraph::storage::durability::Marker::TYPE_STRING: + case memgraph::storage::durability::Marker::TYPE_LIST: + case memgraph::storage::durability::Marker::TYPE_MAP: + case memgraph::storage::durability::Marker::TYPE_TEMPORAL_DATA: + case memgraph::storage::durability::Marker::TYPE_PROPERTY_VALUE: valid_marker = true; break; - case storage::durability::Marker::SECTION_VERTEX: - case storage::durability::Marker::SECTION_EDGE: - case storage::durability::Marker::SECTION_MAPPER: - case storage::durability::Marker::SECTION_METADATA: - case storage::durability::Marker::SECTION_INDICES: - case storage::durability::Marker::SECTION_CONSTRAINTS: - case storage::durability::Marker::SECTION_DELTA: - case storage::durability::Marker::SECTION_EPOCH_HISTORY: - case storage::durability::Marker::SECTION_OFFSETS: - case storage::durability::Marker::DELTA_VERTEX_CREATE: - case storage::durability::Marker::DELTA_VERTEX_DELETE: - case storage::durability::Marker::DELTA_VERTEX_ADD_LABEL: - case storage::durability::Marker::DELTA_VERTEX_REMOVE_LABEL: - case storage::durability::Marker::DELTA_VERTEX_SET_PROPERTY: - case storage::durability::Marker::DELTA_EDGE_CREATE: - case storage::durability::Marker::DELTA_EDGE_DELETE: - case storage::durability::Marker::DELTA_EDGE_SET_PROPERTY: - case storage::durability::Marker::DELTA_TRANSACTION_END: - case storage::durability::Marker::DELTA_LABEL_INDEX_CREATE: - case storage::durability::Marker::DELTA_LABEL_INDEX_DROP: - case storage::durability::Marker::DELTA_LABEL_PROPERTY_INDEX_CREATE: - case storage::durability::Marker::DELTA_LABEL_PROPERTY_INDEX_DROP: - case storage::durability::Marker::DELTA_EXISTENCE_CONSTRAINT_CREATE: - case storage::durability::Marker::DELTA_EXISTENCE_CONSTRAINT_DROP: - case storage::durability::Marker::DELTA_UNIQUE_CONSTRAINT_CREATE: - case storage::durability::Marker::DELTA_UNIQUE_CONSTRAINT_DROP: - case storage::durability::Marker::VALUE_FALSE: - case storage::durability::Marker::VALUE_TRUE: + case memgraph::storage::durability::Marker::SECTION_VERTEX: + case memgraph::storage::durability::Marker::SECTION_EDGE: + case memgraph::storage::durability::Marker::SECTION_MAPPER: + case memgraph::storage::durability::Marker::SECTION_METADATA: + case memgraph::storage::durability::Marker::SECTION_INDICES: + case memgraph::storage::durability::Marker::SECTION_CONSTRAINTS: + case memgraph::storage::durability::Marker::SECTION_DELTA: + case memgraph::storage::durability::Marker::SECTION_EPOCH_HISTORY: + case memgraph::storage::durability::Marker::SECTION_OFFSETS: + case memgraph::storage::durability::Marker::DELTA_VERTEX_CREATE: + case memgraph::storage::durability::Marker::DELTA_VERTEX_DELETE: + case memgraph::storage::durability::Marker::DELTA_VERTEX_ADD_LABEL: + case memgraph::storage::durability::Marker::DELTA_VERTEX_REMOVE_LABEL: + case memgraph::storage::durability::Marker::DELTA_VERTEX_SET_PROPERTY: + case memgraph::storage::durability::Marker::DELTA_EDGE_CREATE: + case memgraph::storage::durability::Marker::DELTA_EDGE_DELETE: + case memgraph::storage::durability::Marker::DELTA_EDGE_SET_PROPERTY: + case memgraph::storage::durability::Marker::DELTA_TRANSACTION_END: + case memgraph::storage::durability::Marker::DELTA_LABEL_INDEX_CREATE: + case memgraph::storage::durability::Marker::DELTA_LABEL_INDEX_DROP: + case memgraph::storage::durability::Marker::DELTA_LABEL_PROPERTY_INDEX_CREATE: + case memgraph::storage::durability::Marker::DELTA_LABEL_PROPERTY_INDEX_DROP: + case memgraph::storage::durability::Marker::DELTA_EXISTENCE_CONSTRAINT_CREATE: + case memgraph::storage::durability::Marker::DELTA_EXISTENCE_CONSTRAINT_DROP: + case memgraph::storage::durability::Marker::DELTA_UNIQUE_CONSTRAINT_CREATE: + case memgraph::storage::durability::Marker::DELTA_UNIQUE_CONSTRAINT_DROP: + case memgraph::storage::durability::Marker::VALUE_FALSE: + case memgraph::storage::durability::Marker::VALUE_TRUE: valid_marker = false; break; } // We only run this test with invalid markers. if (valid_marker) continue; { - file.SetPosition(utils::OutputFile::Position::RELATIVE_TO_END, - -(sizeof(uint64_t) + sizeof(storage::durability::Marker))); + file.SetPosition(memgraph::utils::OutputFile::Position::RELATIVE_TO_END, + -(sizeof(uint64_t) + sizeof(memgraph::storage::durability::Marker))); auto byte = static_cast(marker); file.Write(&byte, sizeof(byte)); file.Sync(); } { - storage::durability::Decoder decoder; + memgraph::storage::durability::Decoder decoder; auto version = decoder.Initialize(storage_file, kTestMagic); ASSERT_TRUE(version); ASSERT_EQ(*version, kTestVersion); ASSERT_FALSE(decoder.SkipPropertyValue()); } { - storage::durability::Decoder decoder; + memgraph::storage::durability::Decoder decoder; auto version = decoder.Initialize(storage_file, kTestMagic); ASSERT_TRUE(version); ASSERT_EQ(*version, kTestVersion); @@ -378,21 +386,21 @@ TEST_F(DecoderEncoderTest, PropertyValueInvalidMarker) { } { { - file.SetPosition(utils::OutputFile::Position::RELATIVE_TO_END, - -(sizeof(uint64_t) + sizeof(storage::durability::Marker))); + file.SetPosition(memgraph::utils::OutputFile::Position::RELATIVE_TO_END, + -(sizeof(uint64_t) + sizeof(memgraph::storage::durability::Marker))); uint8_t byte = 1; file.Write(&byte, sizeof(byte)); file.Sync(); } { - storage::durability::Decoder decoder; + memgraph::storage::durability::Decoder decoder; auto version = decoder.Initialize(storage_file, kTestMagic); ASSERT_TRUE(version); ASSERT_EQ(*version, kTestVersion); ASSERT_FALSE(decoder.SkipPropertyValue()); } { - storage::durability::Decoder decoder; + memgraph::storage::durability::Decoder decoder; auto version = decoder.Initialize(storage_file, kTestMagic); ASSERT_TRUE(version); ASSERT_EQ(*version, kTestVersion); @@ -405,13 +413,13 @@ TEST_F(DecoderEncoderTest, PropertyValueInvalidMarker) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_F(DecoderEncoderTest, DecoderPosition) { { - storage::durability::Encoder encoder; + memgraph::storage::durability::Encoder encoder; encoder.Initialize(storage_file, kTestMagic, kTestVersion); encoder.WriteBool(true); encoder.Finalize(); } { - storage::durability::Decoder decoder; + memgraph::storage::durability::Decoder decoder; auto version = decoder.Initialize(storage_file, kTestMagic); ASSERT_TRUE(version); ASSERT_EQ(*version, kTestVersion); @@ -430,7 +438,7 @@ TEST_F(DecoderEncoderTest, DecoderPosition) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_F(DecoderEncoderTest, EncoderPosition) { { - storage::durability::Encoder encoder; + memgraph::storage::durability::Encoder encoder; encoder.Initialize(storage_file, kTestMagic, kTestVersion); encoder.WriteBool(false); encoder.SetPosition(kTestMagic.size() + sizeof(kTestVersion)); @@ -439,7 +447,7 @@ TEST_F(DecoderEncoderTest, EncoderPosition) { encoder.Finalize(); } { - storage::durability::Decoder decoder; + memgraph::storage::durability::Decoder decoder; auto version = decoder.Initialize(storage_file, kTestMagic); ASSERT_TRUE(version); ASSERT_EQ(*version, kTestVersion); diff --git a/tests/unit/storage_v2_durability.cpp b/tests/unit/storage_v2_durability.cpp index 61bcd4fc4..fb91ad159 100644 --- a/tests/unit/storage_v2_durability.cpp +++ b/tests/unit/storage_v2_durability.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -54,16 +54,18 @@ class DurabilityTest : public ::testing::TestWithParam { public: DurabilityTest() - : base_vertex_gids_(kNumBaseVertices, storage::Gid::FromUint(std::numeric_limits::max())), - base_edge_gids_(kNumBaseEdges, storage::Gid::FromUint(std::numeric_limits::max())), - extended_vertex_gids_(kNumExtendedVertices, storage::Gid::FromUint(std::numeric_limits::max())), - extended_edge_gids_(kNumExtendedEdges, storage::Gid::FromUint(std::numeric_limits::max())) {} + : base_vertex_gids_(kNumBaseVertices, memgraph::storage::Gid::FromUint(std::numeric_limits::max())), + base_edge_gids_(kNumBaseEdges, memgraph::storage::Gid::FromUint(std::numeric_limits::max())), + extended_vertex_gids_(kNumExtendedVertices, + memgraph::storage::Gid::FromUint(std::numeric_limits::max())), + extended_edge_gids_(kNumExtendedEdges, memgraph::storage::Gid::FromUint(std::numeric_limits::max())) { + } void SetUp() override { Clear(); } void TearDown() override { Clear(); } - void CreateBaseDataset(storage::Storage *store, bool properties_on_edges) { + void CreateBaseDataset(memgraph::storage::Storage *store, bool properties_on_edges) { auto label_indexed = store->NameToLabel("base_indexed"); auto label_unindexed = store->NameToLabel("base_unindexed"); auto property_id = store->NameToProperty("id"); @@ -94,7 +96,8 @@ class DurabilityTest : public ::testing::TestWithParam { ASSERT_TRUE(vertex.AddLabel(label_unindexed).HasValue()); } if (i < kNumBaseVertices / 3 || i >= kNumBaseVertices / 2) { - ASSERT_TRUE(vertex.SetProperty(property_id, storage::PropertyValue(static_cast(i))).HasValue()); + ASSERT_TRUE( + vertex.SetProperty(property_id, memgraph::storage::PropertyValue(static_cast(i))).HasValue()); } ASSERT_FALSE(acc.Commit().HasError()); } @@ -102,11 +105,11 @@ class DurabilityTest : public ::testing::TestWithParam { // Create edges. for (uint64_t i = 0; i < kNumBaseEdges; ++i) { auto acc = store->Access(); - auto vertex1 = acc.FindVertex(base_vertex_gids_[(i / 2) % kNumBaseVertices], storage::View::OLD); + auto vertex1 = acc.FindVertex(base_vertex_gids_[(i / 2) % kNumBaseVertices], memgraph::storage::View::OLD); ASSERT_TRUE(vertex1); - auto vertex2 = acc.FindVertex(base_vertex_gids_[(i / 3) % kNumBaseVertices], storage::View::OLD); + auto vertex2 = acc.FindVertex(base_vertex_gids_[(i / 3) % kNumBaseVertices], memgraph::storage::View::OLD); ASSERT_TRUE(vertex2); - storage::EdgeTypeId et; + memgraph::storage::EdgeTypeId et; if (i < kNumBaseEdges / 2) { et = et1; } else { @@ -116,17 +119,18 @@ class DurabilityTest : public ::testing::TestWithParam { ASSERT_TRUE(edge.HasValue()); base_edge_gids_[i] = edge->Gid(); if (properties_on_edges) { - ASSERT_TRUE(edge->SetProperty(property_id, storage::PropertyValue(static_cast(i))).HasValue()); + ASSERT_TRUE( + edge->SetProperty(property_id, memgraph::storage::PropertyValue(static_cast(i))).HasValue()); } else { - auto ret = edge->SetProperty(property_id, storage::PropertyValue(static_cast(i))); + auto ret = edge->SetProperty(property_id, memgraph::storage::PropertyValue(static_cast(i))); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::PROPERTIES_DISABLED); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::PROPERTIES_DISABLED); } ASSERT_FALSE(acc.Commit().HasError()); } } - void CreateExtendedDataset(storage::Storage *store, bool single_transaction = false) { + void CreateExtendedDataset(memgraph::storage::Storage *store, bool single_transaction = false) { auto label_indexed = store->NameToLabel("extended_indexed"); auto label_unused = store->NameToLabel("extended_unused"); auto property_count = store->NameToProperty("count"); @@ -146,7 +150,7 @@ class DurabilityTest : public ::testing::TestWithParam { ASSERT_FALSE(store->CreateUniqueConstraint(label_unused, {property_count}).HasError()); // Storage accessor. - std::optional acc; + std::optional acc; if (single_transaction) acc.emplace(store->Access()); // Create vertices. @@ -158,7 +162,7 @@ class DurabilityTest : public ::testing::TestWithParam { ASSERT_TRUE(vertex.AddLabel(label_indexed).HasValue()); } if (i < kNumExtendedVertices / 3 || i >= kNumExtendedVertices / 2) { - ASSERT_TRUE(vertex.SetProperty(property_count, storage::PropertyValue("nandare")).HasValue()); + ASSERT_TRUE(vertex.SetProperty(property_count, memgraph::storage::PropertyValue("nandare")).HasValue()); } if (!single_transaction) ASSERT_FALSE(acc->Commit().HasError()); } @@ -166,11 +170,13 @@ class DurabilityTest : public ::testing::TestWithParam { // Create edges. for (uint64_t i = 0; i < kNumExtendedEdges; ++i) { if (!single_transaction) acc.emplace(store->Access()); - auto vertex1 = acc->FindVertex(extended_vertex_gids_[(i / 5) % kNumExtendedVertices], storage::View::NEW); + auto vertex1 = + acc->FindVertex(extended_vertex_gids_[(i / 5) % kNumExtendedVertices], memgraph::storage::View::NEW); ASSERT_TRUE(vertex1); - auto vertex2 = acc->FindVertex(extended_vertex_gids_[(i / 6) % kNumExtendedVertices], storage::View::NEW); + auto vertex2 = + acc->FindVertex(extended_vertex_gids_[(i / 6) % kNumExtendedVertices], memgraph::storage::View::NEW); ASSERT_TRUE(vertex2); - storage::EdgeTypeId et; + memgraph::storage::EdgeTypeId et; if (i < kNumExtendedEdges / 4) { et = et3; } else { @@ -185,7 +191,8 @@ class DurabilityTest : public ::testing::TestWithParam { if (single_transaction) ASSERT_FALSE(acc->Commit().HasError()); } - void VerifyDataset(storage::Storage *store, DatasetType type, bool properties_on_edges, bool verify_info = true) { + void VerifyDataset(memgraph::storage::Storage *store, DatasetType type, bool properties_on_edges, + bool verify_info = true) { auto base_label_indexed = store->NameToLabel("base_indexed"); auto base_label_unindexed = store->NameToLabel("base_unindexed"); auto property_id = store->NameToProperty("id"); @@ -274,20 +281,20 @@ class DurabilityTest : public ::testing::TestWithParam { if (have_base_dataset) { // Verify vertices. for (uint64_t i = 0; i < kNumBaseVertices; ++i) { - auto vertex = acc.FindVertex(base_vertex_gids_[i], storage::View::OLD); + auto vertex = acc.FindVertex(base_vertex_gids_[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto labels = vertex->Labels(storage::View::OLD); + auto labels = vertex->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); if (i < kNumBaseVertices / 2) { ASSERT_THAT(*labels, UnorderedElementsAre(base_label_indexed)); } else { ASSERT_THAT(*labels, UnorderedElementsAre(base_label_unindexed)); } - auto properties = vertex->Properties(storage::View::OLD); + auto properties = vertex->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); if (i < kNumBaseVertices / 3 || i >= kNumBaseVertices / 2) { ASSERT_EQ(properties->size(), 1); - ASSERT_EQ((*properties)[property_id], storage::PropertyValue(static_cast(i))); + ASSERT_EQ((*properties)[property_id], memgraph::storage::PropertyValue(static_cast(i))); } else { ASSERT_EQ(properties->size(), 0); } @@ -295,7 +302,7 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify edges. for (uint64_t i = 0; i < kNumBaseEdges; ++i) { - auto find_edge = [&](const auto &edges) -> std::optional { + auto find_edge = [&](const auto &edges) -> std::optional { for (const auto &edge : edges) { if (edge.Gid() == base_edge_gids_[i]) { return edge; @@ -305,9 +312,9 @@ class DurabilityTest : public ::testing::TestWithParam { }; { - auto vertex1 = acc.FindVertex(base_vertex_gids_[(i / 2) % kNumBaseVertices], storage::View::OLD); + auto vertex1 = acc.FindVertex(base_vertex_gids_[(i / 2) % kNumBaseVertices], memgraph::storage::View::OLD); ASSERT_TRUE(vertex1); - auto out_edges = vertex1->OutEdges(storage::View::OLD); + auto out_edges = vertex1->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(out_edges.HasValue()); auto edge1 = find_edge(*out_edges); ASSERT_TRUE(edge1); @@ -316,20 +323,20 @@ class DurabilityTest : public ::testing::TestWithParam { } else { ASSERT_EQ(edge1->EdgeType(), et2); } - auto properties = edge1->Properties(storage::View::OLD); + auto properties = edge1->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); if (properties_on_edges) { ASSERT_EQ(properties->size(), 1); - ASSERT_EQ((*properties)[property_id], storage::PropertyValue(static_cast(i))); + ASSERT_EQ((*properties)[property_id], memgraph::storage::PropertyValue(static_cast(i))); } else { ASSERT_EQ(properties->size(), 0); } } { - auto vertex2 = acc.FindVertex(base_vertex_gids_[(i / 3) % kNumBaseVertices], storage::View::OLD); + auto vertex2 = acc.FindVertex(base_vertex_gids_[(i / 3) % kNumBaseVertices], memgraph::storage::View::OLD); ASSERT_TRUE(vertex2); - auto in_edges = vertex2->InEdges(storage::View::OLD); + auto in_edges = vertex2->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(in_edges.HasValue()); auto edge2 = find_edge(*in_edges); ASSERT_TRUE(edge2); @@ -338,11 +345,11 @@ class DurabilityTest : public ::testing::TestWithParam { } else { ASSERT_EQ(edge2->EdgeType(), et2); } - auto properties = edge2->Properties(storage::View::OLD); + auto properties = edge2->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); if (properties_on_edges) { ASSERT_EQ(properties->size(), 1); - ASSERT_EQ((*properties)[property_id], storage::PropertyValue(static_cast(i))); + ASSERT_EQ((*properties)[property_id], memgraph::storage::PropertyValue(static_cast(i))); } else { ASSERT_EQ(properties->size(), 0); } @@ -351,9 +358,9 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify label indices. { - std::vector vertices; + std::vector vertices; vertices.reserve(kNumBaseVertices / 2); - for (auto vertex : acc.Vertices(base_label_unindexed, storage::View::OLD)) { + for (auto vertex : acc.Vertices(base_label_unindexed, memgraph::storage::View::OLD)) { vertices.push_back(vertex); } ASSERT_EQ(vertices.size(), kNumBaseVertices / 2); @@ -365,9 +372,9 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify label+property index. { - std::vector vertices; + std::vector vertices; vertices.reserve(kNumBaseVertices / 3); - for (auto vertex : acc.Vertices(base_label_indexed, property_id, storage::View::OLD)) { + for (auto vertex : acc.Vertices(base_label_indexed, property_id, memgraph::storage::View::OLD)) { vertices.push_back(vertex); } ASSERT_EQ(vertices.size(), kNumBaseVertices / 3); @@ -379,7 +386,7 @@ class DurabilityTest : public ::testing::TestWithParam { } else { // Verify vertices. for (uint64_t i = 0; i < kNumBaseVertices; ++i) { - auto vertex = acc.FindVertex(base_vertex_gids_[i], storage::View::OLD); + auto vertex = acc.FindVertex(base_vertex_gids_[i], memgraph::storage::View::OLD); ASSERT_FALSE(vertex); } @@ -387,7 +394,7 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify label indices. { uint64_t count = 0; - auto iterable = acc.Vertices(base_label_unindexed, storage::View::OLD); + auto iterable = acc.Vertices(base_label_unindexed, memgraph::storage::View::OLD); for (auto it = iterable.begin(); it != iterable.end(); ++it) { ++count; } @@ -397,7 +404,7 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify label+property index. { uint64_t count = 0; - auto iterable = acc.Vertices(base_label_indexed, property_id, storage::View::OLD); + auto iterable = acc.Vertices(base_label_indexed, property_id, memgraph::storage::View::OLD); for (auto it = iterable.begin(); it != iterable.end(); ++it) { ++count; } @@ -410,18 +417,18 @@ class DurabilityTest : public ::testing::TestWithParam { if (have_extended_dataset) { // Verify vertices. for (uint64_t i = 0; i < kNumExtendedVertices; ++i) { - auto vertex = acc.FindVertex(extended_vertex_gids_[i], storage::View::OLD); + auto vertex = acc.FindVertex(extended_vertex_gids_[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto labels = vertex->Labels(storage::View::OLD); + auto labels = vertex->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); if (i < kNumExtendedVertices / 2) { ASSERT_THAT(*labels, UnorderedElementsAre(extended_label_indexed)); } - auto properties = vertex->Properties(storage::View::OLD); + auto properties = vertex->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); if (i < kNumExtendedVertices / 3 || i >= kNumExtendedVertices / 2) { ASSERT_EQ(properties->size(), 1); - ASSERT_EQ((*properties)[property_count], storage::PropertyValue("nandare")); + ASSERT_EQ((*properties)[property_count], memgraph::storage::PropertyValue("nandare")); } else { ASSERT_EQ(properties->size(), 0); } @@ -429,7 +436,7 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify edges. for (uint64_t i = 0; i < kNumExtendedEdges; ++i) { - auto find_edge = [&](const auto &edges) -> std::optional { + auto find_edge = [&](const auto &edges) -> std::optional { for (const auto &edge : edges) { if (edge.Gid() == extended_edge_gids_[i]) { return edge; @@ -439,9 +446,10 @@ class DurabilityTest : public ::testing::TestWithParam { }; { - auto vertex1 = acc.FindVertex(extended_vertex_gids_[(i / 5) % kNumExtendedVertices], storage::View::OLD); + auto vertex1 = + acc.FindVertex(extended_vertex_gids_[(i / 5) % kNumExtendedVertices], memgraph::storage::View::OLD); ASSERT_TRUE(vertex1); - auto out_edges = vertex1->OutEdges(storage::View::OLD); + auto out_edges = vertex1->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(out_edges.HasValue()); auto edge1 = find_edge(*out_edges); ASSERT_TRUE(edge1); @@ -450,15 +458,16 @@ class DurabilityTest : public ::testing::TestWithParam { } else { ASSERT_EQ(edge1->EdgeType(), et4); } - auto properties = edge1->Properties(storage::View::OLD); + auto properties = edge1->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); ASSERT_EQ(properties->size(), 0); } { - auto vertex2 = acc.FindVertex(extended_vertex_gids_[(i / 6) % kNumExtendedVertices], storage::View::OLD); + auto vertex2 = + acc.FindVertex(extended_vertex_gids_[(i / 6) % kNumExtendedVertices], memgraph::storage::View::OLD); ASSERT_TRUE(vertex2); - auto in_edges = vertex2->InEdges(storage::View::OLD); + auto in_edges = vertex2->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(in_edges.HasValue()); auto edge2 = find_edge(*in_edges); ASSERT_TRUE(edge2); @@ -467,7 +476,7 @@ class DurabilityTest : public ::testing::TestWithParam { } else { ASSERT_EQ(edge2->EdgeType(), et4); } - auto properties = edge2->Properties(storage::View::OLD); + auto properties = edge2->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); ASSERT_EQ(properties->size(), 0); } @@ -475,9 +484,9 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify label indices. { - std::vector vertices; + std::vector vertices; vertices.reserve(kNumExtendedVertices / 2); - for (auto vertex : acc.Vertices(extended_label_unused, storage::View::OLD)) { + for (auto vertex : acc.Vertices(extended_label_unused, memgraph::storage::View::OLD)) { vertices.push_back(vertex); } ASSERT_EQ(vertices.size(), 0); @@ -485,9 +494,9 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify label+property index. { - std::vector vertices; + std::vector vertices; vertices.reserve(kNumExtendedVertices / 3); - for (auto vertex : acc.Vertices(extended_label_indexed, property_count, storage::View::OLD)) { + for (auto vertex : acc.Vertices(extended_label_indexed, property_count, memgraph::storage::View::OLD)) { vertices.push_back(vertex); } ASSERT_EQ(vertices.size(), kNumExtendedVertices / 3); @@ -499,7 +508,7 @@ class DurabilityTest : public ::testing::TestWithParam { } else { // Verify vertices. for (uint64_t i = 0; i < kNumExtendedVertices; ++i) { - auto vertex = acc.FindVertex(extended_vertex_gids_[i], storage::View::OLD); + auto vertex = acc.FindVertex(extended_vertex_gids_[i], memgraph::storage::View::OLD); ASSERT_FALSE(vertex); } @@ -507,7 +516,7 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify label indices. { uint64_t count = 0; - auto iterable = acc.Vertices(extended_label_unused, storage::View::OLD); + auto iterable = acc.Vertices(extended_label_unused, memgraph::storage::View::OLD); for (auto it = iterable.begin(); it != iterable.end(); ++it) { ++count; } @@ -517,7 +526,7 @@ class DurabilityTest : public ::testing::TestWithParam { // Verify label+property index. { uint64_t count = 0; - auto iterable = acc.Vertices(extended_label_indexed, property_count, storage::View::OLD); + auto iterable = acc.Vertices(extended_label_indexed, property_count, memgraph::storage::View::OLD); for (auto it = iterable.begin(); it != iterable.end(); ++it) { ++count; } @@ -549,33 +558,36 @@ class DurabilityTest : public ::testing::TestWithParam { } std::vector GetSnapshotsList() { - return GetFilesList(storage_directory / storage::durability::kSnapshotDirectory); + return GetFilesList(storage_directory / memgraph::storage::durability::kSnapshotDirectory); } std::vector GetBackupSnapshotsList() { - return GetFilesList(storage_directory / storage::durability::kBackupDirectory / - storage::durability::kSnapshotDirectory); + return GetFilesList(storage_directory / memgraph::storage::durability::kBackupDirectory / + memgraph::storage::durability::kSnapshotDirectory); } std::vector GetWalsList() { - return GetFilesList(storage_directory / storage::durability::kWalDirectory); + return GetFilesList(storage_directory / memgraph::storage::durability::kWalDirectory); } std::vector GetBackupWalsList() { - return GetFilesList(storage_directory / storage::durability::kBackupDirectory / storage::durability::kWalDirectory); + return GetFilesList(storage_directory / memgraph::storage::durability::kBackupDirectory / + memgraph::storage::durability::kWalDirectory); } void RestoreBackups() { { auto backup_snapshots = GetBackupSnapshotsList(); for (const auto &item : backup_snapshots) { - std::filesystem::rename(item, storage_directory / storage::durability::kSnapshotDirectory / item.filename()); + std::filesystem::rename( + item, storage_directory / memgraph::storage::durability::kSnapshotDirectory / item.filename()); } } { auto backup_wals = GetBackupWalsList(); for (const auto &item : backup_wals) { - std::filesystem::rename(item, storage_directory / storage::durability::kWalDirectory / item.filename()); + std::filesystem::rename(item, + storage_directory / memgraph::storage::durability::kWalDirectory / item.filename()); } } } @@ -600,42 +612,42 @@ class DurabilityTest : public ::testing::TestWithParam { std::filesystem::remove_all(storage_directory); } - std::vector base_vertex_gids_; - std::vector base_edge_gids_; - std::vector extended_vertex_gids_; - std::vector extended_edge_gids_; + std::vector base_vertex_gids_; + std::vector base_edge_gids_; + std::vector extended_vertex_gids_; + std::vector extended_edge_gids_; }; void DestroySnapshot(const std::filesystem::path &path) { - auto info = storage::durability::ReadSnapshotInfo(path); + auto info = memgraph::storage::durability::ReadSnapshotInfo(path); spdlog::info("Destroying snapshot {}", path); - utils::OutputFile file; - file.Open(path, utils::OutputFile::Mode::OVERWRITE_EXISTING); - file.SetPosition(utils::OutputFile::Position::SET, info.offset_vertices); - auto value = static_cast(storage::durability::Marker::TYPE_MAP); + memgraph::utils::OutputFile file; + file.Open(path, memgraph::utils::OutputFile::Mode::OVERWRITE_EXISTING); + file.SetPosition(memgraph::utils::OutputFile::Position::SET, info.offset_vertices); + auto value = static_cast(memgraph::storage::durability::Marker::TYPE_MAP); file.Write(&value, sizeof(value)); file.Sync(); file.Close(); } void DestroyWalFirstDelta(const std::filesystem::path &path) { - auto info = storage::durability::ReadWalInfo(path); + auto info = memgraph::storage::durability::ReadWalInfo(path); spdlog::info("Destroying WAL {}", path); - utils::OutputFile file; - file.Open(path, utils::OutputFile::Mode::OVERWRITE_EXISTING); - file.SetPosition(utils::OutputFile::Position::SET, info.offset_deltas); - auto value = static_cast(storage::durability::Marker::TYPE_MAP); + memgraph::utils::OutputFile file; + file.Open(path, memgraph::utils::OutputFile::Mode::OVERWRITE_EXISTING); + file.SetPosition(memgraph::utils::OutputFile::Position::SET, info.offset_deltas); + auto value = static_cast(memgraph::storage::durability::Marker::TYPE_MAP); file.Write(&value, sizeof(value)); file.Sync(); file.Close(); } void DestroyWalSuffix(const std::filesystem::path &path) { - auto info = storage::durability::ReadWalInfo(path); + auto info = memgraph::storage::durability::ReadWalInfo(path); spdlog::info("Destroying WAL {}", path); - utils::OutputFile file; - file.Open(path, utils::OutputFile::Mode::OVERWRITE_EXISTING); - ASSERT_LT(info.offset_deltas, file.SetPosition(utils::OutputFile::Position::RELATIVE_TO_END, -100)); + memgraph::utils::OutputFile file; + file.Open(path, memgraph::utils::OutputFile::Mode::OVERWRITE_EXISTING); + ASSERT_LT(info.offset_deltas, file.SetPosition(memgraph::utils::OutputFile::Position::RELATIVE_TO_END, -100)); uint8_t value = 0; for (size_t i = 0; i < 100; ++i) { file.Write(&value, sizeof(value)); @@ -651,8 +663,9 @@ INSTANTIATE_TEST_CASE_P(EdgesWithoutProperties, DurabilityTest, ::testing::Value TEST_P(DurabilityTest, SnapshotOnExit) { // Create snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); CreateBaseDataset(&store, GetParam()); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); CreateExtendedDataset(&store); @@ -665,8 +678,9 @@ TEST_P(DurabilityTest, SnapshotOnExit) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, GetParam()); // Try to use the storage. @@ -683,10 +697,10 @@ TEST_P(DurabilityTest, SnapshotOnExit) { TEST_P(DurabilityTest, SnapshotPeriodic) { // Create snapshot. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, .snapshot_interval = std::chrono::milliseconds(2000)}}); CreateBaseDataset(&store, GetParam()); std::this_thread::sleep_for(std::chrono::milliseconds(2500)); @@ -698,8 +712,9 @@ TEST_P(DurabilityTest, SnapshotPeriodic) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); // Try to use the storage. @@ -716,10 +731,10 @@ TEST_P(DurabilityTest, SnapshotPeriodic) { TEST_P(DurabilityTest, SnapshotFallback) { // Create snapshot. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, .snapshot_interval = std::chrono::milliseconds(3000)}}); CreateBaseDataset(&store, GetParam()); std::this_thread::sleep_for(std::chrono::milliseconds(3500)); @@ -741,8 +756,9 @@ TEST_P(DurabilityTest, SnapshotFallback) { } // Recover snapshot. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); // Try to use the storage. @@ -759,8 +775,9 @@ TEST_P(DurabilityTest, SnapshotFallback) { TEST_P(DurabilityTest, SnapshotEverythingCorrupt) { // Create unrelated snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); auto acc = store.Access(); for (uint64_t i = 0; i < 1000; ++i) { acc.CreateVertex(); @@ -778,16 +795,16 @@ TEST_P(DurabilityTest, SnapshotEverythingCorrupt) { { auto snapshots = GetSnapshotsList(); ASSERT_EQ(snapshots.size(), 1); - auto info = storage::durability::ReadSnapshotInfo(*snapshots.begin()); + auto info = memgraph::storage::durability::ReadSnapshotInfo(*snapshots.begin()); unrelated_uuid = info.uuid; } // Create snapshot. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, .snapshot_interval = std::chrono::milliseconds(2000)}}); CreateBaseDataset(&store, GetParam()); std::this_thread::sleep_for(std::chrono::milliseconds(2500)); @@ -813,7 +830,7 @@ TEST_P(DurabilityTest, SnapshotEverythingCorrupt) { auto snapshots = GetSnapshotsList(); ASSERT_GE(snapshots.size(), 2); for (const auto &snapshot : snapshots) { - auto info = storage::durability::ReadSnapshotInfo(snapshot); + auto info = memgraph::storage::durability::ReadSnapshotInfo(snapshot); if (info.uuid == unrelated_uuid) { spdlog::info("Skipping snapshot {}", snapshot); continue; @@ -825,8 +842,9 @@ TEST_P(DurabilityTest, SnapshotEverythingCorrupt) { // Recover snapshot. ASSERT_DEATH( { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); }, ""); } @@ -835,8 +853,9 @@ TEST_P(DurabilityTest, SnapshotEverythingCorrupt) { TEST_P(DurabilityTest, SnapshotRetention) { // Create unrelated snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); auto acc = store.Access(); for (uint64_t i = 0; i < 1000; ++i) { acc.CreateVertex(); @@ -851,10 +870,10 @@ TEST_P(DurabilityTest, SnapshotRetention) { // Create snapshot. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, .snapshot_interval = std::chrono::milliseconds(2000), .snapshot_retention_count = 3}}); // Restore unrelated snapshots after the database has been started. @@ -877,7 +896,7 @@ TEST_P(DurabilityTest, SnapshotRetention) { for (size_t i = 0; i < snapshots.size(); ++i) { const auto &path = snapshots[i]; // This shouldn't throw. - auto info = storage::durability::ReadSnapshotInfo(path); + auto info = memgraph::storage::durability::ReadSnapshotInfo(path); if (i == 0) uuid = info.uuid; if (i < snapshots.size() - 1) { ASSERT_EQ(info.uuid, uuid); @@ -888,8 +907,9 @@ TEST_P(DurabilityTest, SnapshotRetention) { } // Recover snapshot. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); // Try to use the storage. @@ -906,8 +926,9 @@ TEST_P(DurabilityTest, SnapshotRetention) { TEST_P(DurabilityTest, SnapshotMixedUUID) { // Create snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); CreateBaseDataset(&store, GetParam()); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); CreateExtendedDataset(&store); @@ -921,15 +942,17 @@ TEST_P(DurabilityTest, SnapshotMixedUUID) { // Recover snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, GetParam()); } // Create another snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); CreateBaseDataset(&store, GetParam()); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); } @@ -948,8 +971,9 @@ TEST_P(DurabilityTest, SnapshotMixedUUID) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); // Try to use the storage. @@ -966,8 +990,9 @@ TEST_P(DurabilityTest, SnapshotMixedUUID) { TEST_P(DurabilityTest, SnapshotBackup) { // Create snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); auto acc = store.Access(); for (uint64_t i = 0; i < 1000; ++i) { acc.CreateVertex(); @@ -982,10 +1007,10 @@ TEST_P(DurabilityTest, SnapshotBackup) { // Start storage without recovery. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT, .snapshot_interval = std::chrono::minutes(20)}}); } @@ -999,8 +1024,9 @@ TEST_P(DurabilityTest, SnapshotBackup) { TEST_F(DurabilityTest, SnapshotWithoutPropertiesOnEdgesRecoveryWithPropertiesOnEdges) { // Create snapshot. { - storage::Storage store({.items = {.properties_on_edges = false}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = false}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); CreateBaseDataset(&store, false); VerifyDataset(&store, DatasetType::ONLY_BASE, false); CreateExtendedDataset(&store); @@ -1013,8 +1039,9 @@ TEST_F(DurabilityTest, SnapshotWithoutPropertiesOnEdgesRecoveryWithPropertiesOnE ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot. - storage::Storage store({.items = {.properties_on_edges = true}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = true}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, false); // Try to use the storage. @@ -1031,8 +1058,9 @@ TEST_F(DurabilityTest, SnapshotWithoutPropertiesOnEdgesRecoveryWithPropertiesOnE TEST_F(DurabilityTest, SnapshotWithPropertiesOnEdgesRecoveryWithoutPropertiesOnEdges) { // Create snapshot. { - storage::Storage store({.items = {.properties_on_edges = true}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = true}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); CreateBaseDataset(&store, true); VerifyDataset(&store, DatasetType::ONLY_BASE, true); CreateExtendedDataset(&store); @@ -1047,8 +1075,9 @@ TEST_F(DurabilityTest, SnapshotWithPropertiesOnEdgesRecoveryWithoutPropertiesOnE // Recover snapshot. ASSERT_DEATH( { - storage::Storage store({.items = {.properties_on_edges = false}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = false}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); }, ""); } @@ -1057,8 +1086,9 @@ TEST_F(DurabilityTest, SnapshotWithPropertiesOnEdgesRecoveryWithoutPropertiesOnE TEST_F(DurabilityTest, SnapshotWithPropertiesOnEdgesButUnusedRecoveryWithoutPropertiesOnEdges) { // Create snapshot. { - storage::Storage store({.items = {.properties_on_edges = true}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = true}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); CreateBaseDataset(&store, true); VerifyDataset(&store, DatasetType::ONLY_BASE, true); CreateExtendedDataset(&store); @@ -1066,25 +1096,25 @@ TEST_F(DurabilityTest, SnapshotWithPropertiesOnEdgesButUnusedRecoveryWithoutProp // Remove properties from edges. { auto acc = store.Access(); - for (auto vertex : acc.Vertices(storage::View::OLD)) { - auto in_edges = vertex.InEdges(storage::View::OLD); + for (auto vertex : acc.Vertices(memgraph::storage::View::OLD)) { + auto in_edges = vertex.InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(in_edges.HasValue()); for (auto edge : *in_edges) { // TODO (mferencevic): Replace with `ClearProperties()` - auto props = edge.Properties(storage::View::NEW); + auto props = edge.Properties(memgraph::storage::View::NEW); ASSERT_TRUE(props.HasValue()); for (const auto &prop : *props) { - ASSERT_TRUE(edge.SetProperty(prop.first, storage::PropertyValue()).HasValue()); + ASSERT_TRUE(edge.SetProperty(prop.first, memgraph::storage::PropertyValue()).HasValue()); } } - auto out_edges = vertex.InEdges(storage::View::OLD); + auto out_edges = vertex.InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(out_edges.HasValue()); for (auto edge : *out_edges) { // TODO (mferencevic): Replace with `ClearProperties()` - auto props = edge.Properties(storage::View::NEW); + auto props = edge.Properties(memgraph::storage::View::NEW); ASSERT_TRUE(props.HasValue()); for (const auto &prop : *props) { - ASSERT_TRUE(edge.SetProperty(prop.first, storage::PropertyValue()).HasValue()); + ASSERT_TRUE(edge.SetProperty(prop.first, memgraph::storage::PropertyValue()).HasValue()); } } } @@ -1098,8 +1128,9 @@ TEST_F(DurabilityTest, SnapshotWithPropertiesOnEdgesButUnusedRecoveryWithoutProp ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot. - storage::Storage store({.items = {.properties_on_edges = false}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = false}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, false); // Try to use the storage. @@ -1116,12 +1147,13 @@ TEST_F(DurabilityTest, SnapshotWithPropertiesOnEdgesButUnusedRecoveryWithoutProp TEST_P(DurabilityTest, WalBasic) { // Create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); CreateBaseDataset(&store, GetParam()); CreateExtendedDataset(&store); } @@ -1132,8 +1164,9 @@ TEST_P(DurabilityTest, WalBasic) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, GetParam()); // Try to use the storage. @@ -1150,13 +1183,14 @@ TEST_P(DurabilityTest, WalBasic) { TEST_P(DurabilityTest, WalBackup) { // Create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_size_kibibytes = 1, - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_size_kibibytes = 1, + .wal_file_flush_every_n_tx = kFlushWalEvery}}); auto acc = store.Access(); for (uint64_t i = 0; i < 1000; ++i) { acc.CreateVertex(); @@ -1172,11 +1206,12 @@ TEST_P(DurabilityTest, WalBackup) { // Start storage without recovery. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20)}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20)}}); } ASSERT_EQ(GetSnapshotsList().size(), 0); @@ -1189,12 +1224,13 @@ TEST_P(DurabilityTest, WalBackup) { TEST_P(DurabilityTest, WalAppendToExisting) { // Create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); CreateBaseDataset(&store, GetParam()); } @@ -1205,20 +1241,22 @@ TEST_P(DurabilityTest, WalAppendToExisting) { // Recover WALs. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); } // Recover WALs and create more WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .recover_on_startup = true, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .recover_on_startup = true, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); CreateExtendedDataset(&store); } @@ -1228,8 +1266,9 @@ TEST_P(DurabilityTest, WalAppendToExisting) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, GetParam()); // Try to use the storage. @@ -1245,16 +1284,17 @@ TEST_P(DurabilityTest, WalAppendToExisting) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(DurabilityTest, WalCreateInSingleTransaction) { // NOLINTNEXTLINE(readability-isolate-declaration) - storage::Gid gid_v1, gid_v2, gid_e1, gid_v3; + memgraph::storage::Gid gid_v1, gid_v2, gid_e1, gid_v3; // Create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); auto acc = store.Access(); auto v1 = acc.CreateVertex(); gid_v1 = v1.Gid(); @@ -1267,13 +1307,14 @@ TEST_P(DurabilityTest, WalCreateInSingleTransaction) { ASSERT_TRUE(v1.AddLabel(store.NameToLabel("l12")).HasValue()); ASSERT_TRUE(v1.AddLabel(store.NameToLabel("l13")).HasValue()); if (GetParam()) { - ASSERT_TRUE(e1->SetProperty(store.NameToProperty("test"), storage::PropertyValue("nandare")).HasValue()); + ASSERT_TRUE( + e1->SetProperty(store.NameToProperty("test"), memgraph::storage::PropertyValue("nandare")).HasValue()); } ASSERT_TRUE(v2.AddLabel(store.NameToLabel("l21")).HasValue()); - ASSERT_TRUE(v2.SetProperty(store.NameToProperty("hello"), storage::PropertyValue("world")).HasValue()); + ASSERT_TRUE(v2.SetProperty(store.NameToProperty("hello"), memgraph::storage::PropertyValue("world")).HasValue()); auto v3 = acc.CreateVertex(); gid_v3 = v3.Gid(); - ASSERT_TRUE(v3.SetProperty(store.NameToProperty("v3"), storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(v3.SetProperty(store.NameToProperty("v3"), memgraph::storage::PropertyValue(42)).HasValue()); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1283,8 +1324,9 @@ TEST_P(DurabilityTest, WalCreateInSingleTransaction) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); { auto indices = store.ListAllIndices(); ASSERT_EQ(indices.label.size(), 0); @@ -1294,72 +1336,73 @@ TEST_P(DurabilityTest, WalCreateInSingleTransaction) { ASSERT_EQ(constraints.unique.size(), 0); auto acc = store.Access(); { - auto v1 = acc.FindVertex(gid_v1, storage::View::OLD); + auto v1 = acc.FindVertex(gid_v1, memgraph::storage::View::OLD); ASSERT_TRUE(v1); - auto labels = v1->Labels(storage::View::OLD); + auto labels = v1->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_THAT(*labels, UnorderedElementsAre(store.NameToLabel("l11"), store.NameToLabel("l12"), store.NameToLabel("l13"))); - auto props = v1->Properties(storage::View::OLD); + auto props = v1->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(props.HasValue()); ASSERT_EQ(props->size(), 0); - auto in_edges = v1->InEdges(storage::View::OLD); + auto in_edges = v1->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(in_edges.HasValue()); ASSERT_EQ(in_edges->size(), 0); - auto out_edges = v1->OutEdges(storage::View::OLD); + auto out_edges = v1->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(out_edges.HasValue()); ASSERT_EQ(out_edges->size(), 1); const auto &edge = (*out_edges)[0]; ASSERT_EQ(edge.Gid(), gid_e1); - auto edge_props = edge.Properties(storage::View::OLD); + auto edge_props = edge.Properties(memgraph::storage::View::OLD); ASSERT_TRUE(edge_props.HasValue()); if (GetParam()) { - ASSERT_THAT(*edge_props, UnorderedElementsAre( - std::make_pair(store.NameToProperty("test"), storage::PropertyValue("nandare")))); + ASSERT_THAT(*edge_props, UnorderedElementsAre(std::make_pair(store.NameToProperty("test"), + memgraph::storage::PropertyValue("nandare")))); } else { ASSERT_EQ(edge_props->size(), 0); } } { - auto v2 = acc.FindVertex(gid_v2, storage::View::OLD); + auto v2 = acc.FindVertex(gid_v2, memgraph::storage::View::OLD); ASSERT_TRUE(v2); - auto labels = v2->Labels(storage::View::OLD); + auto labels = v2->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_THAT(*labels, UnorderedElementsAre(store.NameToLabel("l21"))); - auto props = v2->Properties(storage::View::OLD); + auto props = v2->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(props.HasValue()); - ASSERT_THAT(*props, - UnorderedElementsAre(std::make_pair(store.NameToProperty("hello"), storage::PropertyValue("world")))); - auto in_edges = v2->InEdges(storage::View::OLD); + ASSERT_THAT(*props, UnorderedElementsAre(std::make_pair(store.NameToProperty("hello"), + memgraph::storage::PropertyValue("world")))); + auto in_edges = v2->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(in_edges.HasValue()); ASSERT_EQ(in_edges->size(), 1); const auto &edge = (*in_edges)[0]; ASSERT_EQ(edge.Gid(), gid_e1); - auto edge_props = edge.Properties(storage::View::OLD); + auto edge_props = edge.Properties(memgraph::storage::View::OLD); ASSERT_TRUE(edge_props.HasValue()); if (GetParam()) { - ASSERT_THAT(*edge_props, UnorderedElementsAre( - std::make_pair(store.NameToProperty("test"), storage::PropertyValue("nandare")))); + ASSERT_THAT(*edge_props, UnorderedElementsAre(std::make_pair(store.NameToProperty("test"), + memgraph::storage::PropertyValue("nandare")))); } else { ASSERT_EQ(edge_props->size(), 0); } - auto out_edges = v2->OutEdges(storage::View::OLD); + auto out_edges = v2->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(out_edges.HasValue()); ASSERT_EQ(out_edges->size(), 0); } { - auto v3 = acc.FindVertex(gid_v3, storage::View::OLD); + auto v3 = acc.FindVertex(gid_v3, memgraph::storage::View::OLD); ASSERT_TRUE(v3); - auto labels = v3->Labels(storage::View::OLD); + auto labels = v3->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_EQ(labels->size(), 0); - auto props = v3->Properties(storage::View::OLD); + auto props = v3->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(props.HasValue()); - ASSERT_THAT(*props, UnorderedElementsAre(std::make_pair(store.NameToProperty("v3"), storage::PropertyValue(42)))); - auto in_edges = v3->InEdges(storage::View::OLD); + ASSERT_THAT(*props, UnorderedElementsAre( + std::make_pair(store.NameToProperty("v3"), memgraph::storage::PropertyValue(42)))); + auto in_edges = v3->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(in_edges.HasValue()); ASSERT_EQ(in_edges->size(), 0); - auto out_edges = v3->OutEdges(storage::View::OLD); + auto out_edges = v3->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(out_edges.HasValue()); ASSERT_EQ(out_edges->size(), 0); } @@ -1379,12 +1422,13 @@ TEST_P(DurabilityTest, WalCreateInSingleTransaction) { TEST_P(DurabilityTest, WalCreateAndRemoveEverything) { // Create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); CreateBaseDataset(&store, GetParam()); CreateExtendedDataset(&store); auto indices = store.ListAllIndices(); @@ -1400,10 +1444,10 @@ TEST_P(DurabilityTest, WalCreateAndRemoveEverything) { } for (const auto &constraint : constraints.unique) { ASSERT_EQ(store.DropUniqueConstraint(constraint.first, constraint.second), - storage::UniqueConstraints::DeletionStatus::SUCCESS); + memgraph::storage::UniqueConstraints::DeletionStatus::SUCCESS); } auto acc = store.Access(); - for (auto vertex : acc.Vertices(storage::View::OLD)) { + for (auto vertex : acc.Vertices(memgraph::storage::View::OLD)) { ASSERT_TRUE(acc.DetachDeleteVertex(&vertex).HasValue()); } ASSERT_FALSE(acc.Commit().HasError()); @@ -1415,8 +1459,9 @@ TEST_P(DurabilityTest, WalCreateAndRemoveEverything) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); { auto indices = store.ListAllIndices(); ASSERT_EQ(indices.label.size(), 0); @@ -1426,7 +1471,7 @@ TEST_P(DurabilityTest, WalCreateAndRemoveEverything) { ASSERT_EQ(constraints.unique.size(), 0); auto acc = store.Access(); uint64_t count = 0; - auto iterable = acc.Vertices(storage::View::OLD); + auto iterable = acc.Vertices(memgraph::storage::View::OLD); for (auto it = iterable.begin(); it != iterable.end(); ++it) { ++count; } @@ -1446,15 +1491,15 @@ TEST_P(DurabilityTest, WalCreateAndRemoveEverything) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(DurabilityTest, WalTransactionOrdering) { // NOLINTNEXTLINE(readability-isolate-declaration) - storage::Gid gid1, gid2, gid3; + memgraph::storage::Gid gid1, gid2, gid3; // Create WAL. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, .snapshot_interval = std::chrono::minutes(20), .wal_file_size_kibibytes = 100000, .wal_file_flush_every_n_tx = kFlushWalEvery, @@ -1466,7 +1511,7 @@ TEST_P(DurabilityTest, WalTransactionOrdering) { { auto vertex2 = acc2.CreateVertex(); gid2 = vertex2.Gid(); - ASSERT_TRUE(vertex2.SetProperty(store.NameToProperty("id"), storage::PropertyValue(2)).HasValue()); + ASSERT_TRUE(vertex2.SetProperty(store.NameToProperty("id"), memgraph::storage::PropertyValue(2)).HasValue()); } auto acc3 = store.Access(); @@ -1475,14 +1520,14 @@ TEST_P(DurabilityTest, WalTransactionOrdering) { { auto vertex3 = acc3.CreateVertex(); gid3 = vertex3.Gid(); - ASSERT_TRUE(vertex3.SetProperty(store.NameToProperty("id"), storage::PropertyValue(3)).HasValue()); + ASSERT_TRUE(vertex3.SetProperty(store.NameToProperty("id"), memgraph::storage::PropertyValue(3)).HasValue()); } // Create vertex in transaction 1. { auto vertex1 = acc1.CreateVertex(); gid1 = vertex1.Gid(); - ASSERT_TRUE(vertex1.SetProperty(store.NameToProperty("id"), storage::PropertyValue(1)).HasValue()); + ASSERT_TRUE(vertex1.SetProperty(store.NameToProperty("id"), memgraph::storage::PropertyValue(1)).HasValue()); } // Commit transaction 3, then 1, then 2. @@ -1499,15 +1544,15 @@ TEST_P(DurabilityTest, WalTransactionOrdering) { // Verify WAL data. { auto path = GetWalsList().front(); - auto info = storage::durability::ReadWalInfo(path); - storage::durability::Decoder wal; - wal.Initialize(path, storage::durability::kWalMagic); + auto info = memgraph::storage::durability::ReadWalInfo(path); + memgraph::storage::durability::Decoder wal; + wal.Initialize(path, memgraph::storage::durability::kWalMagic); wal.SetPosition(info.offset_deltas); ASSERT_EQ(info.num_deltas, 9); - std::vector> data; + std::vector> data; for (uint64_t i = 0; i < info.num_deltas; ++i) { - auto timestamp = storage::durability::ReadWalDeltaHeader(&wal); - data.emplace_back(timestamp, storage::durability::ReadWalDeltaData(&wal)); + auto timestamp = memgraph::storage::durability::ReadWalDeltaHeader(&wal); + data.emplace_back(timestamp, memgraph::storage::durability::ReadWalDeltaData(&wal)); } // Verify timestamps. ASSERT_EQ(data[1].first, data[0].first); @@ -1519,46 +1564,47 @@ TEST_P(DurabilityTest, WalTransactionOrdering) { ASSERT_EQ(data[7].first, data[6].first); ASSERT_EQ(data[8].first, data[7].first); // Verify transaction 3. - ASSERT_EQ(data[0].second.type, storage::durability::WalDeltaData::Type::VERTEX_CREATE); + ASSERT_EQ(data[0].second.type, memgraph::storage::durability::WalDeltaData::Type::VERTEX_CREATE); ASSERT_EQ(data[0].second.vertex_create_delete.gid, gid3); - ASSERT_EQ(data[1].second.type, storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY); + ASSERT_EQ(data[1].second.type, memgraph::storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY); ASSERT_EQ(data[1].second.vertex_edge_set_property.gid, gid3); ASSERT_EQ(data[1].second.vertex_edge_set_property.property, "id"); - ASSERT_EQ(data[1].second.vertex_edge_set_property.value, storage::PropertyValue(3)); - ASSERT_EQ(data[2].second.type, storage::durability::WalDeltaData::Type::TRANSACTION_END); + ASSERT_EQ(data[1].second.vertex_edge_set_property.value, memgraph::storage::PropertyValue(3)); + ASSERT_EQ(data[2].second.type, memgraph::storage::durability::WalDeltaData::Type::TRANSACTION_END); // Verify transaction 1. - ASSERT_EQ(data[3].second.type, storage::durability::WalDeltaData::Type::VERTEX_CREATE); + ASSERT_EQ(data[3].second.type, memgraph::storage::durability::WalDeltaData::Type::VERTEX_CREATE); ASSERT_EQ(data[3].second.vertex_create_delete.gid, gid1); - ASSERT_EQ(data[4].second.type, storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY); + ASSERT_EQ(data[4].second.type, memgraph::storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY); ASSERT_EQ(data[4].second.vertex_edge_set_property.gid, gid1); ASSERT_EQ(data[4].second.vertex_edge_set_property.property, "id"); - ASSERT_EQ(data[4].second.vertex_edge_set_property.value, storage::PropertyValue(1)); - ASSERT_EQ(data[5].second.type, storage::durability::WalDeltaData::Type::TRANSACTION_END); + ASSERT_EQ(data[4].second.vertex_edge_set_property.value, memgraph::storage::PropertyValue(1)); + ASSERT_EQ(data[5].second.type, memgraph::storage::durability::WalDeltaData::Type::TRANSACTION_END); // Verify transaction 2. - ASSERT_EQ(data[6].second.type, storage::durability::WalDeltaData::Type::VERTEX_CREATE); + ASSERT_EQ(data[6].second.type, memgraph::storage::durability::WalDeltaData::Type::VERTEX_CREATE); ASSERT_EQ(data[6].second.vertex_create_delete.gid, gid2); - ASSERT_EQ(data[7].second.type, storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY); + ASSERT_EQ(data[7].second.type, memgraph::storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY); ASSERT_EQ(data[7].second.vertex_edge_set_property.gid, gid2); ASSERT_EQ(data[7].second.vertex_edge_set_property.property, "id"); - ASSERT_EQ(data[7].second.vertex_edge_set_property.value, storage::PropertyValue(2)); - ASSERT_EQ(data[8].second.type, storage::durability::WalDeltaData::Type::TRANSACTION_END); + ASSERT_EQ(data[7].second.vertex_edge_set_property.value, memgraph::storage::PropertyValue(2)); + ASSERT_EQ(data[8].second.type, memgraph::storage::durability::WalDeltaData::Type::TRANSACTION_END); } // Recover WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); { auto acc = store.Access(); - for (auto [gid, id] : std::vector>{{gid1, 1}, {gid2, 2}, {gid3, 3}}) { - auto vertex = acc.FindVertex(gid, storage::View::OLD); + for (auto [gid, id] : std::vector>{{gid1, 1}, {gid2, 2}, {gid3, 3}}) { + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto labels = vertex->Labels(storage::View::OLD); + auto labels = vertex->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_EQ(labels->size(), 0); - auto props = vertex->Properties(storage::View::OLD); + auto props = vertex->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(props.HasValue()); ASSERT_EQ(props->size(), 1); - ASSERT_EQ(props->at(store.NameToProperty("id")), storage::PropertyValue(id)); + ASSERT_EQ(props->at(store.NameToProperty("id")), memgraph::storage::PropertyValue(id)); } } @@ -1576,21 +1622,22 @@ TEST_P(DurabilityTest, WalTransactionOrdering) { TEST_P(DurabilityTest, WalCreateAndRemoveOnlyBaseDataset) { // Create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); CreateBaseDataset(&store, GetParam()); CreateExtendedDataset(&store); auto label_indexed = store.NameToLabel("base_indexed"); auto label_unindexed = store.NameToLabel("base_unindexed"); auto acc = store.Access(); - for (auto vertex : acc.Vertices(storage::View::OLD)) { - auto has_indexed = vertex.HasLabel(label_indexed, storage::View::OLD); + for (auto vertex : acc.Vertices(memgraph::storage::View::OLD)) { + auto has_indexed = vertex.HasLabel(label_indexed, memgraph::storage::View::OLD); ASSERT_TRUE(has_indexed.HasValue()); - auto has_unindexed = vertex.HasLabel(label_unindexed, storage::View::OLD); + auto has_unindexed = vertex.HasLabel(label_unindexed, memgraph::storage::View::OLD); if (!*has_indexed && !*has_unindexed) continue; ASSERT_TRUE(acc.DetachDeleteVertex(&vertex).HasValue()); } @@ -1603,8 +1650,9 @@ TEST_P(DurabilityTest, WalCreateAndRemoveOnlyBaseDataset) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::ONLY_EXTENDED_WITH_BASE_INDICES_AND_CONSTRAINTS, GetParam()); // Try to use the storage. @@ -1623,12 +1671,13 @@ TEST_P(DurabilityTest, WalDeathResilience) { if (pid == 0) { // Create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); // Create one million vertices. for (uint64_t i = 0; i < 1000000; ++i) { auto acc = store.Access(); @@ -1657,18 +1706,18 @@ TEST_P(DurabilityTest, WalDeathResilience) { const uint64_t kExtraItems = 1000; uint64_t count = 0; { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, .durability = { .storage_directory = storage_directory, .recover_on_startup = true, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, .snapshot_interval = std::chrono::minutes(20), .wal_file_flush_every_n_tx = kFlushWalEvery, }}); { auto acc = store.Access(); - auto iterable = acc.Vertices(storage::View::OLD); + auto iterable = acc.Vertices(memgraph::storage::View::OLD); for (auto it = iterable.begin(); it != iterable.end(); ++it) { ++count; } @@ -1690,12 +1739,13 @@ TEST_P(DurabilityTest, WalDeathResilience) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); { uint64_t current = 0; auto acc = store.Access(); - auto iterable = acc.Vertices(storage::View::OLD); + auto iterable = acc.Vertices(memgraph::storage::View::OLD); for (auto it = iterable.begin(); it != iterable.end(); ++it) { ++current; } @@ -1716,13 +1766,14 @@ TEST_P(DurabilityTest, WalDeathResilience) { TEST_P(DurabilityTest, WalMissingSecond) { // Create unrelated WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_size_kibibytes = 1, - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_size_kibibytes = 1, + .wal_file_flush_every_n_tx = kFlushWalEvery}}); auto acc = store.Access(); for (uint64_t i = 0; i < 1000; ++i) { acc.CreateVertex(); @@ -1739,15 +1790,16 @@ TEST_P(DurabilityTest, WalMissingSecond) { // Create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_size_kibibytes = 1, - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_size_kibibytes = 1, + .wal_file_flush_every_n_tx = kFlushWalEvery}}); const uint64_t kNumVertices = 1000; - std::vector gids; + std::vector gids; gids.reserve(kNumVertices); for (uint64_t i = 0; i < kNumVertices; ++i) { auto acc = store.Access(); @@ -1757,10 +1809,10 @@ TEST_P(DurabilityTest, WalMissingSecond) { } for (uint64_t i = 0; i < kNumVertices; ++i) { auto acc = store.Access(); - auto vertex = acc.FindVertex(gids[i], storage::View::OLD); + auto vertex = acc.FindVertex(gids[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE( - vertex->SetProperty(store.NameToProperty("nandare"), storage::PropertyValue("haihaihai!")).HasValue()); + ASSERT_TRUE(vertex->SetProperty(store.NameToProperty("nandare"), memgraph::storage::PropertyValue("haihaihai!")) + .HasValue()); ASSERT_FALSE(acc.Commit().HasError()); } } @@ -1790,8 +1842,9 @@ TEST_P(DurabilityTest, WalMissingSecond) { // Recover WALs. ASSERT_DEATH( { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); }, ""); } @@ -1800,13 +1853,14 @@ TEST_P(DurabilityTest, WalMissingSecond) { TEST_P(DurabilityTest, WalCorruptSecond) { // Create unrelated WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_size_kibibytes = 1, - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_size_kibibytes = 1, + .wal_file_flush_every_n_tx = kFlushWalEvery}}); auto acc = store.Access(); for (uint64_t i = 0; i < 1000; ++i) { acc.CreateVertex(); @@ -1823,15 +1877,16 @@ TEST_P(DurabilityTest, WalCorruptSecond) { // Create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_size_kibibytes = 1, - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_size_kibibytes = 1, + .wal_file_flush_every_n_tx = kFlushWalEvery}}); const uint64_t kNumVertices = 1000; - std::vector gids; + std::vector gids; gids.reserve(kNumVertices); for (uint64_t i = 0; i < kNumVertices; ++i) { auto acc = store.Access(); @@ -1841,10 +1896,10 @@ TEST_P(DurabilityTest, WalCorruptSecond) { } for (uint64_t i = 0; i < kNumVertices; ++i) { auto acc = store.Access(); - auto vertex = acc.FindVertex(gids[i], storage::View::OLD); + auto vertex = acc.FindVertex(gids[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE( - vertex->SetProperty(store.NameToProperty("nandare"), storage::PropertyValue("haihaihai!")).HasValue()); + ASSERT_TRUE(vertex->SetProperty(store.NameToProperty("nandare"), memgraph::storage::PropertyValue("haihaihai!")) + .HasValue()); ASSERT_FALSE(acc.Commit().HasError()); } } @@ -1873,8 +1928,9 @@ TEST_P(DurabilityTest, WalCorruptSecond) { // Recover WALs. ASSERT_DEATH( { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); }, ""); } @@ -1883,13 +1939,14 @@ TEST_P(DurabilityTest, WalCorruptSecond) { TEST_P(DurabilityTest, WalCorruptLastTransaction) { // Create WALs { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_size_kibibytes = 1, - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_size_kibibytes = 1, + .wal_file_flush_every_n_tx = kFlushWalEvery}}); CreateBaseDataset(&store, GetParam()); CreateExtendedDataset(&store, /* single_transaction = */ true); } @@ -1908,8 +1965,9 @@ TEST_P(DurabilityTest, WalCorruptLastTransaction) { } // Recover WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); // The extended dataset shouldn't be recovered because its WAL transaction was // corrupt. VerifyDataset(&store, DatasetType::ONLY_BASE_WITH_EXTENDED_INDICES_AND_CONSTRAINTS, GetParam()); @@ -1928,35 +1986,37 @@ TEST_P(DurabilityTest, WalCorruptLastTransaction) { TEST_P(DurabilityTest, WalAllOperationsInSingleTransaction) { // Create WALs { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_size_kibibytes = 1, - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_size_kibibytes = 1, + .wal_file_flush_every_n_tx = kFlushWalEvery}}); auto acc = store.Access(); auto vertex1 = acc.CreateVertex(); auto vertex2 = acc.CreateVertex(); ASSERT_TRUE(vertex1.AddLabel(acc.NameToLabel("nandare")).HasValue()); - ASSERT_TRUE(vertex2.SetProperty(acc.NameToProperty("haihai"), storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(vertex2.SetProperty(acc.NameToProperty("haihai"), memgraph::storage::PropertyValue(42)).HasValue()); ASSERT_TRUE(vertex1.RemoveLabel(acc.NameToLabel("nandare")).HasValue()); auto edge1 = acc.CreateEdge(&vertex1, &vertex2, acc.NameToEdgeType("et1")); ASSERT_TRUE(edge1.HasValue()); - ASSERT_TRUE(vertex2.SetProperty(acc.NameToProperty("haihai"), storage::PropertyValue()).HasValue()); + ASSERT_TRUE(vertex2.SetProperty(acc.NameToProperty("haihai"), memgraph::storage::PropertyValue()).HasValue()); auto vertex3 = acc.CreateVertex(); auto edge2 = acc.CreateEdge(&vertex3, &vertex3, acc.NameToEdgeType("et2")); ASSERT_TRUE(edge2.HasValue()); if (GetParam()) { - ASSERT_TRUE(edge2->SetProperty(acc.NameToProperty("meaning"), storage::PropertyValue(true)).HasValue()); - ASSERT_TRUE(edge1->SetProperty(acc.NameToProperty("hello"), storage::PropertyValue("world")).HasValue()); - ASSERT_TRUE(edge2->SetProperty(acc.NameToProperty("meaning"), storage::PropertyValue()).HasValue()); + ASSERT_TRUE(edge2->SetProperty(acc.NameToProperty("meaning"), memgraph::storage::PropertyValue(true)).HasValue()); + ASSERT_TRUE( + edge1->SetProperty(acc.NameToProperty("hello"), memgraph::storage::PropertyValue("world")).HasValue()); + ASSERT_TRUE(edge2->SetProperty(acc.NameToProperty("meaning"), memgraph::storage::PropertyValue()).HasValue()); } ASSERT_TRUE(vertex3.AddLabel(acc.NameToLabel("test")).HasValue()); - ASSERT_TRUE(vertex3.SetProperty(acc.NameToProperty("nonono"), storage::PropertyValue(-1)).HasValue()); - ASSERT_TRUE(vertex3.SetProperty(acc.NameToProperty("nonono"), storage::PropertyValue()).HasValue()); + ASSERT_TRUE(vertex3.SetProperty(acc.NameToProperty("nonono"), memgraph::storage::PropertyValue(-1)).HasValue()); + ASSERT_TRUE(vertex3.SetProperty(acc.NameToProperty("nonono"), memgraph::storage::PropertyValue()).HasValue()); if (GetParam()) { - ASSERT_TRUE(edge1->SetProperty(acc.NameToProperty("hello"), storage::PropertyValue()).HasValue()); + ASSERT_TRUE(edge1->SetProperty(acc.NameToProperty("hello"), memgraph::storage::PropertyValue()).HasValue()); } ASSERT_TRUE(vertex3.RemoveLabel(acc.NameToLabel("test")).HasValue()); ASSERT_TRUE(acc.DetachDeleteVertex(&vertex1).HasValue()); @@ -1972,12 +2032,13 @@ TEST_P(DurabilityTest, WalAllOperationsInSingleTransaction) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); { auto acc = store.Access(); uint64_t count = 0; - auto iterable = acc.Vertices(storage::View::OLD); + auto iterable = acc.Vertices(memgraph::storage::View::OLD); for (auto it = iterable.begin(); it != iterable.end(); ++it) { ++count; } @@ -1998,12 +2059,13 @@ TEST_P(DurabilityTest, WalAllOperationsInSingleTransaction) { TEST_P(DurabilityTest, WalAndSnapshot) { // Create snapshot and WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::milliseconds(2000), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::milliseconds(2000), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); CreateBaseDataset(&store, GetParam()); std::this_thread::sleep_for(std::chrono::milliseconds(2500)); CreateExtendedDataset(&store); @@ -2015,8 +2077,9 @@ TEST_P(DurabilityTest, WalAndSnapshot) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot and WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, GetParam()); // Try to use the storage. @@ -2033,8 +2096,9 @@ TEST_P(DurabilityTest, WalAndSnapshot) { TEST_P(DurabilityTest, WalAndSnapshotAppendToExistingSnapshot) { // Create snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); CreateBaseDataset(&store, GetParam()); } @@ -2045,20 +2109,22 @@ TEST_P(DurabilityTest, WalAndSnapshotAppendToExistingSnapshot) { // Recover snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); } // Recover snapshot and create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .recover_on_startup = true, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .recover_on_startup = true, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); CreateExtendedDataset(&store); } @@ -2068,8 +2134,9 @@ TEST_P(DurabilityTest, WalAndSnapshotAppendToExistingSnapshot) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot and WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, GetParam()); // Try to use the storage. @@ -2086,8 +2153,9 @@ TEST_P(DurabilityTest, WalAndSnapshotAppendToExistingSnapshot) { TEST_P(DurabilityTest, WalAndSnapshotAppendToExistingSnapshotAndWal) { // Create snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .snapshot_on_exit = true}}); CreateBaseDataset(&store, GetParam()); } @@ -2098,20 +2166,22 @@ TEST_P(DurabilityTest, WalAndSnapshotAppendToExistingSnapshotAndWal) { // Recover snapshot. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::ONLY_BASE, GetParam()); } // Recover snapshot and create WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .recover_on_startup = true, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .recover_on_startup = true, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); CreateExtendedDataset(&store); } @@ -2121,21 +2191,22 @@ TEST_P(DurabilityTest, WalAndSnapshotAppendToExistingSnapshotAndWal) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot and WALs and create more WALs. - storage::Gid vertex_gid; + memgraph::storage::Gid vertex_gid; { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .recover_on_startup = true, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .recover_on_startup = true, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_flush_every_n_tx = kFlushWalEvery}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, GetParam()); auto acc = store.Access(); auto vertex = acc.CreateVertex(); vertex_gid = vertex.Gid(); if (GetParam()) { - ASSERT_TRUE(vertex.SetProperty(store.NameToProperty("meaning"), storage::PropertyValue(42)).HasValue()); + ASSERT_TRUE(vertex.SetProperty(store.NameToProperty("meaning"), memgraph::storage::PropertyValue(42)).HasValue()); } ASSERT_FALSE(acc.Commit().HasError()); } @@ -2146,22 +2217,23 @@ TEST_P(DurabilityTest, WalAndSnapshotAppendToExistingSnapshotAndWal) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot and WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, GetParam(), /* verify_info = */ false); { auto acc = store.Access(); - auto vertex = acc.FindVertex(vertex_gid, storage::View::OLD); + auto vertex = acc.FindVertex(vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto labels = vertex->Labels(storage::View::OLD); + auto labels = vertex->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_EQ(labels->size(), 0); - auto props = vertex->Properties(storage::View::OLD); + auto props = vertex->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(props.HasValue()); if (GetParam()) { - ASSERT_THAT(*props, - UnorderedElementsAre(std::make_pair(store.NameToProperty("meaning"), storage::PropertyValue(42)))); + ASSERT_THAT(*props, UnorderedElementsAre( + std::make_pair(store.NameToProperty("meaning"), memgraph::storage::PropertyValue(42)))); } else { ASSERT_EQ(props->size(), 0); } @@ -2181,13 +2253,14 @@ TEST_P(DurabilityTest, WalAndSnapshotAppendToExistingSnapshotAndWal) { TEST_P(DurabilityTest, WalAndSnapshotWalRetention) { // Create unrelated WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::minutes(20), - .wal_file_size_kibibytes = 1, - .wal_file_flush_every_n_tx = kFlushWalEvery}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::minutes(20), + .wal_file_size_kibibytes = 1, + .wal_file_flush_every_n_tx = kFlushWalEvery}}); auto acc = store.Access(); for (uint64_t i = 0; i < 1000; ++i) { acc.CreateVertex(); @@ -2206,16 +2279,17 @@ TEST_P(DurabilityTest, WalAndSnapshotWalRetention) { // Create snapshot and WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::seconds(2), - .wal_file_size_kibibytes = 1, - .wal_file_flush_every_n_tx = 1}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::seconds(2), + .wal_file_size_kibibytes = 1, + .wal_file_flush_every_n_tx = 1}}); // Restore unrelated snapshots after the database has been started. RestoreBackups(); - utils::Timer timer; + memgraph::utils::Timer timer; // Allow at least 6 snapshots to be created. while (timer.Elapsed().count() < 13.0) { auto acc = store.Access(); @@ -2238,11 +2312,12 @@ TEST_P(DurabilityTest, WalAndSnapshotWalRetention) { // Recover and verify data. { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); auto acc = store.Access(); for (uint64_t j = 0; j < items_created; ++j) { - auto vertex = acc.FindVertex(storage::Gid::FromUint(j), storage::View::OLD); + auto vertex = acc.FindVertex(memgraph::storage::Gid::FromUint(j), memgraph::storage::View::OLD); ASSERT_TRUE(vertex); } } @@ -2255,8 +2330,9 @@ TEST_P(DurabilityTest, WalAndSnapshotWalRetention) { // shouldn't be possible because the initial WALs are already deleted. ASSERT_DEATH( { - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); }, ""); } @@ -2265,11 +2341,12 @@ TEST_P(DurabilityTest, WalAndSnapshotWalRetention) { TEST_P(DurabilityTest, SnapshotAndWalMixedUUID) { // Create unrelated snapshot and WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::seconds(2)}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::seconds(2)}}); auto acc = store.Access(); for (uint64_t i = 0; i < 1000; ++i) { acc.CreateVertex(); @@ -2285,11 +2362,12 @@ TEST_P(DurabilityTest, SnapshotAndWalMixedUUID) { // Create snapshot and WALs. { - storage::Storage store( + memgraph::storage::Storage store( {.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, - .snapshot_interval = std::chrono::seconds(2)}}); + .durability = { + .storage_directory = storage_directory, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_interval = std::chrono::seconds(2)}}); CreateBaseDataset(&store, GetParam()); std::this_thread::sleep_for(std::chrono::milliseconds(2500)); CreateExtendedDataset(&store); @@ -2310,8 +2388,9 @@ TEST_P(DurabilityTest, SnapshotAndWalMixedUUID) { ASSERT_EQ(GetBackupWalsList().size(), 0); // Recover snapshot and WALs. - storage::Storage store({.items = {.properties_on_edges = GetParam()}, - .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); + memgraph::storage::Storage store( + {.items = {.properties_on_edges = GetParam()}, + .durability = {.storage_directory = storage_directory, .recover_on_startup = true}}); VerifyDataset(&store, DatasetType::BASE_WITH_EXTENDED, GetParam()); // Try to use the storage. diff --git a/tests/unit/storage_v2_edge.cpp b/tests/unit/storage_v2_edge.cpp index 5a1c8ac98..1d62fe35a 100644 --- a/tests/unit/storage_v2_edge.cpp +++ b/tests/unit/storage_v2_edge.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -25,9 +25,9 @@ INSTANTIATE_TEST_CASE_P(EdgesWithoutProperties, StorageEdgeTest, ::testing::Valu // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeCreateFromSmallerCommit) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertices { @@ -42,8 +42,8 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerCommit) { // Create edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -57,58 +57,58 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerCommit) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -116,98 +116,98 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerCommit) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -215,9 +215,9 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeCreateFromLargerCommit) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertices { @@ -232,8 +232,8 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerCommit) { // Create edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -247,52 +247,52 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerCommit) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -300,86 +300,86 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerCommit) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -387,8 +387,8 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeCreateFromSameCommit) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_vertex = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_vertex = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertex { @@ -401,7 +401,7 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameCommit) { // Create edge { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); @@ -414,27 +414,27 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameCommit) { ASSERT_EQ(edge.ToVertex(), *vertex); // Check edges without filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -444,14 +444,14 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameCommit) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -459,51 +459,51 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameCommit) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); // Check edges without filters { - auto ret = vertex->InEdges(storage::View::OLD); + auto ret = vertex->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::OLD); + auto ret = vertex->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -513,18 +513,18 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameCommit) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -532,9 +532,9 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeCreateFromSmallerAbort) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertices { @@ -549,8 +549,8 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerAbort) { // Create edge, but abort the transaction { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -564,52 +564,52 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerAbort) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); acc.Abort(); } @@ -617,28 +617,28 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -646,8 +646,8 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerAbort) { // Create edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -661,52 +661,52 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerAbort) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -714,86 +714,86 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -801,9 +801,9 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSmallerAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeCreateFromLargerAbort) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertices { @@ -818,8 +818,8 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerAbort) { // Create edge, but abort the transaction { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -833,52 +833,52 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerAbort) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); acc.Abort(); } @@ -886,28 +886,28 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -915,8 +915,8 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerAbort) { // Create edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -930,52 +930,52 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerAbort) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -983,86 +983,86 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1070,8 +1070,8 @@ TEST_P(StorageEdgeTest, EdgeCreateFromLargerAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_vertex = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_vertex = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertex { @@ -1084,7 +1084,7 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { // Create edge, but abort the transaction { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); @@ -1097,27 +1097,27 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { ASSERT_EQ(edge.ToVertex(), *vertex); // Check edges without filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -1127,14 +1127,14 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); acc.Abort(); } @@ -1142,18 +1142,18 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); // Check edges without filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1161,7 +1161,7 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { // Create edge { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); @@ -1174,27 +1174,27 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { ASSERT_EQ(edge.ToVertex(), *vertex); // Check edges without filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -1204,14 +1204,14 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1219,51 +1219,51 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); // Check edges without filters { - auto ret = vertex->InEdges(storage::View::OLD); + auto ret = vertex->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::OLD); + auto ret = vertex->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -1273,22 +1273,22 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1296,9 +1296,9 @@ TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerCommit) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertices { @@ -1313,8 +1313,8 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerCommit) { // Create edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -1328,52 +1328,52 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerCommit) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1381,86 +1381,86 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerCommit) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1468,66 +1468,66 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerCommit) { // Delete edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); - auto edge = vertex_from->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1535,28 +1535,28 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerCommit) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1564,9 +1564,9 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeDeleteFromLargerCommit) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertices { @@ -1581,8 +1581,8 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerCommit) { // Create edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -1596,52 +1596,52 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerCommit) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1649,86 +1649,86 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerCommit) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1736,66 +1736,66 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerCommit) { // Delete edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); - auto edge = vertex_from->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1803,28 +1803,28 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerCommit) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1832,8 +1832,8 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_vertex = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_vertex = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertex { @@ -1846,7 +1846,7 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { // Create edge { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); @@ -1859,27 +1859,27 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { ASSERT_EQ(edge.ToVertex(), *vertex); // Check edges without filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -1889,14 +1889,14 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1904,51 +1904,51 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); // Check edges without filters { - auto ret = vertex->InEdges(storage::View::OLD); + auto ret = vertex->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::OLD); + auto ret = vertex->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -1958,22 +1958,22 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -1981,12 +1981,12 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { // Delete edge { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); ASSERT_TRUE(res.HasValue()); @@ -1994,43 +1994,43 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { // Check edges without filters { - auto ret = vertex->InEdges(storage::View::OLD); + auto ret = vertex->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex->OutEdges(storage::View::OLD); + auto ret = vertex->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2038,18 +2038,18 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); // Check edges without filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2057,9 +2057,9 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertices { @@ -2074,8 +2074,8 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) { // Create edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -2089,52 +2089,52 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2142,86 +2142,86 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2229,66 +2229,66 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) { // Delete the edge, but abort the transaction { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); - auto edge = vertex_from->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); acc.Abort(); } @@ -2296,86 +2296,86 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2383,66 +2383,66 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) { // Delete the edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); - auto edge = vertex_from->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2450,28 +2450,28 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2479,9 +2479,9 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertices { @@ -2496,8 +2496,8 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) { // Create edge { auto acc = store.Access(); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -2511,52 +2511,52 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) { ASSERT_EQ(edge.ToVertex(), *vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2564,86 +2564,86 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2651,66 +2651,66 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) { // Delete the edge, but abort the transaction { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); - auto edge = vertex_from->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); acc.Abort(); } @@ -2718,87 +2718,87 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2806,66 +2806,66 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) { // Delete the edge { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); - auto edge = vertex_from->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_to)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD, {}, &*vertex_from)->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_from)->size(), 1); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD, {}, &*vertex_to)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->size(), 1); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2873,28 +2873,28 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); // Check edges without filters - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2902,8 +2902,8 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_vertex = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_vertex = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create vertex { @@ -2916,7 +2916,7 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { // Create edge { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); @@ -2929,27 +2929,27 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { ASSERT_EQ(edge.ToVertex(), *vertex); // Check edges without filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0); { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -2959,14 +2959,14 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -2974,51 +2974,51 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); // Check edges without filters { - auto ret = vertex->InEdges(storage::View::OLD); + auto ret = vertex->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::OLD); + auto ret = vertex->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -3028,22 +3028,22 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -3051,12 +3051,12 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { // Delete the edge, but abort the transaction { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); ASSERT_TRUE(res.HasValue()); @@ -3064,43 +3064,43 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { // Check edges without filters { - auto ret = vertex->InEdges(storage::View::OLD); + auto ret = vertex->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex->OutEdges(storage::View::OLD); + auto ret = vertex->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); acc.Abort(); } @@ -3108,51 +3108,51 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); // Check edges without filters { - auto ret = vertex->InEdges(storage::View::OLD); + auto ret = vertex->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->InEdges(storage::View::NEW); + auto ret = vertex->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::OLD); + auto ret = vertex->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } { - auto ret = vertex->OutEdges(storage::View::NEW); + auto ret = vertex->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); @@ -3162,22 +3162,22 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -3185,12 +3185,12 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { // Delete the edge { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); auto et = acc.NameToEdgeType("et5"); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); ASSERT_TRUE(res.HasValue()); @@ -3198,43 +3198,43 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { // Check edges without filters { - auto ret = vertex->InEdges(storage::View::OLD); + auto ret = vertex->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex->OutEdges(storage::View::OLD); + auto ret = vertex->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } - ASSERT_EQ(vertex->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0); auto other_et = acc.NameToEdgeType("other"); // Check edges with filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->InEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et})->size(), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {et, other_et})->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {}, &*vertex)->size(), 1); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->size(), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->size(), 1); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -3242,18 +3242,18 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { // Check whether the edge exists { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); + auto vertex = acc.FindVertex(gid_vertex, memgraph::storage::View::NEW); ASSERT_TRUE(vertex); // Check edges without filters - ASSERT_EQ(vertex->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -3261,9 +3261,9 @@ TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create dataset { @@ -3284,32 +3284,32 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) { gid_to = vertex_to.Gid(); // Check edges - ASSERT_EQ(vertex_from.InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from.InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from.InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from.InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from.OutEdges(storage::View::NEW); + auto ret = vertex_from.OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from.OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from.OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), vertex_from); ASSERT_EQ(e.ToVertex(), vertex_to); } { - auto ret = vertex_to.InEdges(storage::View::NEW); + auto ret = vertex_to.InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to.InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to.InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), vertex_from); ASSERT_EQ(e.ToVertex(), vertex_to); } - ASSERT_EQ(vertex_to.OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to.OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to.OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to.OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -3317,8 +3317,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) { // Detach delete vertex { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -3328,7 +3328,7 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) { { auto ret = acc.DeleteVertex(&*vertex_from); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::VERTEX_HAS_EDGES); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES); } // Detach delete vertex @@ -3339,40 +3339,41 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) { } // Check edges - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex_from->InDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex_from->OutDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->OutDegree(memgraph::storage::View::NEW).GetError(), + memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -3380,28 +3381,28 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) { // Check dataset { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_FALSE(vertex_from); ASSERT_TRUE(vertex_to); // Check edges - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_vertex1 = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_vertex2 = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_vertex1 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_vertex2 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create dataset { @@ -3447,12 +3448,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { // Check edges { - auto ret = vertex1.InEdges(storage::View::NEW); + auto ret = vertex1.InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1.InDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex1.InDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -3467,12 +3468,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { } } { - auto ret = vertex1.OutEdges(storage::View::NEW); + auto ret = vertex1.OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1.OutDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex1.OutDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -3487,12 +3488,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { } } { - auto ret = vertex2.InEdges(storage::View::NEW); + auto ret = vertex2.InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2.InDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex2.InDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -3507,12 +3508,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { } } { - auto ret = vertex2.OutEdges(storage::View::NEW); + auto ret = vertex2.OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2.OutDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex2.OutDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -3533,8 +3534,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { // Detach delete vertex { auto acc = store.Access(); - auto vertex1 = acc.FindVertex(gid_vertex1, storage::View::NEW); - auto vertex2 = acc.FindVertex(gid_vertex2, storage::View::NEW); + auto vertex1 = acc.FindVertex(gid_vertex1, memgraph::storage::View::NEW); + auto vertex2 = acc.FindVertex(gid_vertex2, memgraph::storage::View::NEW); ASSERT_TRUE(vertex1); ASSERT_TRUE(vertex2); @@ -3547,7 +3548,7 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { { auto ret = acc.DeleteVertex(&*vertex1); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::VERTEX_HAS_EDGES); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES); } // Detach delete vertex @@ -3559,12 +3560,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { // Check edges { - auto ret = vertex1->InEdges(storage::View::OLD); + auto ret = vertex1->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->InDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -3578,15 +3579,15 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(e.ToVertex(), *vertex1); } } - ASSERT_EQ(vertex1->InEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex1->InDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex1->OutEdges(storage::View::OLD); + auto ret = vertex1->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->OutDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -3600,15 +3601,15 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(e.ToVertex(), *vertex1); } } - ASSERT_EQ(vertex1->OutEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex1->OutDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->OutDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex2->InEdges(storage::View::OLD); + auto ret = vertex2->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->InDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -3623,23 +3624,23 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { } } { - auto ret = vertex2->InEdges(storage::View::NEW); + auto ret = vertex2->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } { - auto ret = vertex2->OutEdges(storage::View::OLD); + auto ret = vertex2->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->OutDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -3654,11 +3655,11 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { } } { - auto ret = vertex2->OutEdges(storage::View::NEW); + auto ret = vertex2->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); @@ -3671,8 +3672,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { // Check dataset { auto acc = store.Access(); - auto vertex1 = acc.FindVertex(gid_vertex1, storage::View::NEW); - auto vertex2 = acc.FindVertex(gid_vertex2, storage::View::NEW); + auto vertex1 = acc.FindVertex(gid_vertex1, memgraph::storage::View::NEW); + auto vertex2 = acc.FindVertex(gid_vertex2, memgraph::storage::View::NEW); ASSERT_FALSE(vertex1); ASSERT_TRUE(vertex2); @@ -3680,44 +3681,44 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { // Check edges { - auto ret = vertex2->InEdges(storage::View::OLD); + auto ret = vertex2->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } { - auto ret = vertex2->InEdges(storage::View::NEW); + auto ret = vertex2->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } { - auto ret = vertex2->OutEdges(storage::View::OLD); + auto ret = vertex2->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } { - auto ret = vertex2->OutEdges(storage::View::NEW); + auto ret = vertex2->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); @@ -3728,9 +3729,9 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_from = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_to = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create dataset { @@ -3751,32 +3752,32 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { gid_to = vertex_to.Gid(); // Check edges - ASSERT_EQ(vertex_from.InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from.InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from.InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from.InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from.OutEdges(storage::View::NEW); + auto ret = vertex_from.OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from.OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from.OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), vertex_from); ASSERT_EQ(e.ToVertex(), vertex_to); } { - auto ret = vertex_to.InEdges(storage::View::NEW); + auto ret = vertex_to.InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to.InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to.InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), vertex_from); ASSERT_EQ(e.ToVertex(), vertex_to); } - ASSERT_EQ(vertex_to.OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to.OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to.OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to.OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -3784,8 +3785,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { // Detach delete vertex, but abort the transaction { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -3795,7 +3796,7 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { { auto ret = acc.DeleteVertex(&*vertex_from); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::VERTEX_HAS_EDGES); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES); } // Detach delete vertex @@ -3806,40 +3807,41 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { } // Check edges - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex_from->InDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex_from->OutDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->OutDegree(memgraph::storage::View::NEW).GetError(), + memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); acc.Abort(); } @@ -3847,40 +3849,40 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { // Check dataset { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); auto et = acc.NameToEdgeType("et5"); // Check edges - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0); { - auto ret = vertex_from->OutEdges(storage::View::NEW); + auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } { - auto ret = vertex_to->InEdges(storage::View::NEW); + auto ret = vertex_to->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -3888,8 +3890,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { // Detach delete vertex { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); @@ -3899,7 +3901,7 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { { auto ret = acc.DeleteVertex(&*vertex_from); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::VERTEX_HAS_EDGES); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES); } // Detach delete vertex @@ -3910,40 +3912,41 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { } // Check edges - ASSERT_EQ(vertex_from->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_from->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex_from->InDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex_from->OutEdges(storage::View::OLD); + auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_from->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_from->OutEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex_from->OutDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex_from->OutDegree(memgraph::storage::View::NEW).GetError(), + memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex_to->InEdges(storage::View::OLD); + auto ret = vertex_to->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -3951,28 +3954,28 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) { // Check dataset { auto acc = store.Access(); - auto vertex_from = acc.FindVertex(gid_from, storage::View::NEW); - auto vertex_to = acc.FindVertex(gid_to, storage::View::NEW); + auto vertex_from = acc.FindVertex(gid_from, memgraph::storage::View::NEW); + auto vertex_to = acc.FindVertex(gid_to, memgraph::storage::View::NEW); ASSERT_FALSE(vertex_from); ASSERT_TRUE(vertex_to); // Check edges - ASSERT_EQ(vertex_to->InEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->InEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->InDegree(storage::View::NEW), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::OLD)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::OLD), 0); - ASSERT_EQ(vertex_to->OutEdges(storage::View::NEW)->size(), 0); - ASSERT_EQ(*vertex_to->OutDegree(storage::View::NEW), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0); + ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { - storage::Storage store({.items = {.properties_on_edges = GetParam()}}); - storage::Gid gid_vertex1 = storage::Gid::FromUint(std::numeric_limits::max()); - storage::Gid gid_vertex2 = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = GetParam()}}); + memgraph::storage::Gid gid_vertex1 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Gid gid_vertex2 = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create dataset { @@ -4018,12 +4021,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // Check edges { - auto ret = vertex1.InEdges(storage::View::NEW); + auto ret = vertex1.InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1.InDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex1.InDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4038,12 +4041,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex1.OutEdges(storage::View::NEW); + auto ret = vertex1.OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1.OutDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex1.OutDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4058,12 +4061,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2.InEdges(storage::View::NEW); + auto ret = vertex2.InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2.InDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex2.InDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4078,12 +4081,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2.OutEdges(storage::View::NEW); + auto ret = vertex2.OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2.OutDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex2.OutDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4104,8 +4107,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // Detach delete vertex, but abort the transaction { auto acc = store.Access(); - auto vertex1 = acc.FindVertex(gid_vertex1, storage::View::NEW); - auto vertex2 = acc.FindVertex(gid_vertex2, storage::View::NEW); + auto vertex1 = acc.FindVertex(gid_vertex1, memgraph::storage::View::NEW); + auto vertex2 = acc.FindVertex(gid_vertex2, memgraph::storage::View::NEW); ASSERT_TRUE(vertex1); ASSERT_TRUE(vertex2); @@ -4118,7 +4121,7 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { { auto ret = acc.DeleteVertex(&*vertex1); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::VERTEX_HAS_EDGES); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES); } // Detach delete vertex @@ -4130,12 +4133,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // Check edges { - auto ret = vertex1->InEdges(storage::View::OLD); + auto ret = vertex1->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->InDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4149,15 +4152,15 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(e.ToVertex(), *vertex1); } } - ASSERT_EQ(vertex1->InEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex1->InDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex1->OutEdges(storage::View::OLD); + auto ret = vertex1->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->OutDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4171,15 +4174,15 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(e.ToVertex(), *vertex1); } } - ASSERT_EQ(vertex1->OutEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex1->OutDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->OutDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex2->InEdges(storage::View::OLD); + auto ret = vertex2->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->InDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4194,23 +4197,23 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2->InEdges(storage::View::NEW); + auto ret = vertex2->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } { - auto ret = vertex2->OutEdges(storage::View::OLD); + auto ret = vertex2->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->OutDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4225,11 +4228,11 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2->OutEdges(storage::View::NEW); + auto ret = vertex2->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); @@ -4242,8 +4245,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // Check dataset { auto acc = store.Access(); - auto vertex1 = acc.FindVertex(gid_vertex1, storage::View::NEW); - auto vertex2 = acc.FindVertex(gid_vertex2, storage::View::NEW); + auto vertex1 = acc.FindVertex(gid_vertex1, memgraph::storage::View::NEW); + auto vertex2 = acc.FindVertex(gid_vertex2, memgraph::storage::View::NEW); ASSERT_TRUE(vertex1); ASSERT_TRUE(vertex2); @@ -4254,12 +4257,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // Check edges { - auto ret = vertex1->InEdges(storage::View::OLD); + auto ret = vertex1->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->InDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4274,12 +4277,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex1->InEdges(storage::View::NEW); + auto ret = vertex1->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->InDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4294,12 +4297,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex1->OutEdges(storage::View::OLD); + auto ret = vertex1->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->OutDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4314,12 +4317,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex1->OutEdges(storage::View::NEW); + auto ret = vertex1->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->OutDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4334,12 +4337,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2->InEdges(storage::View::OLD); + auto ret = vertex2->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->InDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4354,12 +4357,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2->InEdges(storage::View::NEW); + auto ret = vertex2->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->InDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4374,12 +4377,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2->OutEdges(storage::View::OLD); + auto ret = vertex2->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->OutDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4394,12 +4397,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2->OutEdges(storage::View::NEW); + auto ret = vertex2->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->OutDegree(storage::View::NEW), 2); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4420,8 +4423,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // Detach delete vertex { auto acc = store.Access(); - auto vertex1 = acc.FindVertex(gid_vertex1, storage::View::NEW); - auto vertex2 = acc.FindVertex(gid_vertex2, storage::View::NEW); + auto vertex1 = acc.FindVertex(gid_vertex1, memgraph::storage::View::NEW); + auto vertex2 = acc.FindVertex(gid_vertex2, memgraph::storage::View::NEW); ASSERT_TRUE(vertex1); ASSERT_TRUE(vertex2); @@ -4434,7 +4437,7 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { { auto ret = acc.DeleteVertex(&*vertex1); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), storage::Error::VERTEX_HAS_EDGES); + ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES); } // Detach delete vertex @@ -4446,12 +4449,12 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // Check edges { - auto ret = vertex1->InEdges(storage::View::OLD); + auto ret = vertex1->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->InDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4465,15 +4468,15 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(e.ToVertex(), *vertex1); } } - ASSERT_EQ(vertex1->InEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex1->InDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex1->OutEdges(storage::View::OLD); + auto ret = vertex1->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex1->OutDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4487,15 +4490,15 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(e.ToVertex(), *vertex1); } } - ASSERT_EQ(vertex1->OutEdges(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex1->OutDegree(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); + ASSERT_EQ(vertex1->OutDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT); { - auto ret = vertex2->InEdges(storage::View::OLD); + auto ret = vertex2->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->InDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et1); @@ -4510,23 +4513,23 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2->InEdges(storage::View::NEW); + auto ret = vertex2->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } { - auto ret = vertex2->OutEdges(storage::View::OLD); + auto ret = vertex2->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); }); ASSERT_EQ(edges.size(), 2); - ASSERT_EQ(*vertex2->OutDegree(storage::View::OLD), 2); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 2); { auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et2); @@ -4541,11 +4544,11 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { } } { - auto ret = vertex2->OutEdges(storage::View::NEW); + auto ret = vertex2->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); @@ -4558,8 +4561,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // Check dataset { auto acc = store.Access(); - auto vertex1 = acc.FindVertex(gid_vertex1, storage::View::NEW); - auto vertex2 = acc.FindVertex(gid_vertex2, storage::View::NEW); + auto vertex1 = acc.FindVertex(gid_vertex1, memgraph::storage::View::NEW); + auto vertex2 = acc.FindVertex(gid_vertex2, memgraph::storage::View::NEW); ASSERT_FALSE(vertex1); ASSERT_TRUE(vertex2); @@ -4567,44 +4570,44 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // Check edges { - auto ret = vertex2->InEdges(storage::View::OLD); + auto ret = vertex2->InEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->InDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } { - auto ret = vertex2->InEdges(storage::View::NEW); + auto ret = vertex2->InEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->InDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } { - auto ret = vertex2->OutEdges(storage::View::OLD); + auto ret = vertex2->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->OutDegree(storage::View::OLD), 1); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } { - auto ret = vertex2->OutEdges(storage::View::NEW); + auto ret = vertex2->OutEdges(memgraph::storage::View::NEW); ASSERT_TRUE(ret.HasValue()); auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); - ASSERT_EQ(*vertex2->OutDegree(storage::View::NEW), 1); + ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1); auto e = edges[0]; ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); @@ -4615,8 +4618,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageWithProperties, EdgePropertyCommit) { - storage::Storage store({.items = {.properties_on_edges = true}}); - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = true}}); + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); @@ -4629,31 +4632,31 @@ TEST(StorageWithProperties, EdgePropertyCommit) { auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = edge.SetProperty(property, storage::PropertyValue("temporary")); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("temporary")); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "temporary"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto old_value = edge.SetProperty(property, storage::PropertyValue("nandare")); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("nandare")); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -4662,59 +4665,59 @@ TEST(StorageWithProperties, EdgePropertyCommit) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::OLD).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); { - auto old_value = edge.SetProperty(property, storage::PropertyValue()); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue()); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::OLD).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = edge.SetProperty(property, storage::PropertyValue()); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue()); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } @@ -4723,21 +4726,21 @@ TEST(StorageWithProperties, EdgePropertyCommit) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(edge.GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -4745,8 +4748,8 @@ TEST(StorageWithProperties, EdgePropertyCommit) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageWithProperties, EdgePropertyAbort) { - storage::Storage store({.items = {.properties_on_edges = true}}); - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = true}}); + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); // Create the vertex. { @@ -4764,37 +4767,37 @@ TEST(StorageWithProperties, EdgePropertyAbort) { // Set property 5 to "nandare", but abort the transaction. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = edge.SetProperty(property, storage::PropertyValue("temporary")); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("temporary")); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "temporary"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto old_value = edge.SetProperty(property, storage::PropertyValue("nandare")); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("nandare")); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -4805,21 +4808,21 @@ TEST(StorageWithProperties, EdgePropertyAbort) { // Check that property 5 is null. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(edge.GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -4827,37 +4830,37 @@ TEST(StorageWithProperties, EdgePropertyAbort) { // Set property 5 to "nandare". { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = edge.SetProperty(property, storage::PropertyValue("temporary")); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("temporary")); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "temporary"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto old_value = edge.SetProperty(property, storage::PropertyValue("nandare")); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("nandare")); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } @@ -4868,30 +4871,30 @@ TEST(StorageWithProperties, EdgePropertyAbort) { // Check that property 5 is "nandare". { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::OLD).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -4899,41 +4902,41 @@ TEST(StorageWithProperties, EdgePropertyAbort) { // Set property 5 to null, but abort the transaction. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::OLD).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto old_value = edge.SetProperty(property, storage::PropertyValue()); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue()); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::OLD).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); acc.Abort(); } @@ -4941,30 +4944,30 @@ TEST(StorageWithProperties, EdgePropertyAbort) { // Check that property 5 is "nandare". { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::OLD).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -4972,41 +4975,41 @@ TEST(StorageWithProperties, EdgePropertyAbort) { // Set property 5 to null. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::OLD).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto old_value = edge.SetProperty(property, storage::PropertyValue()); + auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue()); ASSERT_TRUE(old_value.HasValue()); ASSERT_FALSE(old_value->IsNull()); } - ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); + ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare"); { - auto properties = edge.Properties(storage::View::OLD).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } @@ -5014,21 +5017,21 @@ TEST(StorageWithProperties, EdgePropertyAbort) { // Check that property 5 is null. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(edge.GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } @@ -5036,8 +5039,8 @@ TEST(StorageWithProperties, EdgePropertyAbort) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageWithProperties, EdgePropertySerializationError) { - storage::Storage store({.items = {.properties_on_edges = true}}); - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = true}}); + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); @@ -5055,33 +5058,33 @@ TEST(StorageWithProperties, EdgePropertySerializationError) { // Set property 1 to 123 in accessor 1. { - auto vertex = acc1.FindVertex(gid, storage::View::OLD); + auto vertex = acc1.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property1 = acc1.NameToProperty("property1"); auto property2 = acc1.NameToProperty("property2"); - ASSERT_TRUE(edge.GetProperty(property1, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); { - auto old_value = edge.SetProperty(property1, storage::PropertyValue(123)); + auto old_value = edge.SetProperty(property1, memgraph::storage::PropertyValue(123)); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); } - ASSERT_TRUE(edge.GetProperty(property1, storage::View::OLD)->IsNull()); - ASSERT_EQ(edge.GetProperty(property1, storage::View::NEW)->ValueInt(), 123); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::OLD)->IsNull()); + ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::NEW)->ValueInt(), 123); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property1].ValueInt(), 123); } @@ -5089,24 +5092,24 @@ TEST(StorageWithProperties, EdgePropertySerializationError) { // Set property 2 to "nandare" in accessor 2. { - auto vertex = acc2.FindVertex(gid, storage::View::OLD); + auto vertex = acc2.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property1 = acc2.NameToProperty("property1"); auto property2 = acc2.NameToProperty("property2"); - ASSERT_TRUE(edge.GetProperty(property1, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); { - auto res = edge.SetProperty(property2, storage::PropertyValue("nandare")); + auto res = edge.SetProperty(property2, memgraph::storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasError()); - ASSERT_EQ(res.GetError(), storage::Error::SERIALIZATION_ERROR); + ASSERT_EQ(res.GetError(), memgraph::storage::Error::SERIALIZATION_ERROR); } } @@ -5117,25 +5120,25 @@ TEST(StorageWithProperties, EdgePropertySerializationError) { // Check which properties exist. { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property1 = acc.NameToProperty("property1"); auto property2 = acc.NameToProperty("property2"); - ASSERT_EQ(edge.GetProperty(property1, storage::View::OLD)->ValueInt(), 123); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::OLD)->IsNull()); + ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::OLD)->ValueInt(), 123); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); { - auto properties = edge.Properties(storage::View::OLD).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property1].ValueInt(), 123); } - ASSERT_EQ(edge.GetProperty(property1, storage::View::NEW)->ValueInt(), 123); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::NEW)->ValueInt(), 123); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); { - auto properties = edge.Properties(storage::View::NEW).GetValue(); + auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property1].ValueInt(), 123); } @@ -5145,8 +5148,8 @@ TEST(StorageWithProperties, EdgePropertySerializationError) { } TEST(StorageWithProperties, EdgePropertyClear) { - storage::Storage store({.items = {.properties_on_edges = true}}); - storage::Gid gid; + memgraph::storage::Storage store({.items = {.properties_on_edges = true}}); + memgraph::storage::Gid gid; auto property1 = store.NameToProperty("property1"); auto property2 = store.NameToProperty("property2"); { @@ -5159,7 +5162,7 @@ TEST(StorageWithProperties, EdgePropertyClear) { ASSERT_EQ(edge.FromVertex(), vertex); ASSERT_EQ(edge.ToVertex(), vertex); - auto old_value = edge.SetProperty(property1, storage::PropertyValue("value")); + auto old_value = edge.SetProperty(property1, memgraph::storage::PropertyValue("value")); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); @@ -5167,14 +5170,14 @@ TEST(StorageWithProperties, EdgePropertyClear) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; - ASSERT_EQ(edge.GetProperty(property1, storage::View::OLD)->ValueString(), "value"); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::OLD)->IsNull()); - ASSERT_THAT(edge.Properties(storage::View::OLD).GetValue(), - UnorderedElementsAre(std::pair(property1, storage::PropertyValue("value")))); + ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::OLD)->ValueString(), "value"); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull()); + ASSERT_THAT(edge.Properties(memgraph::storage::View::OLD).GetValue(), + UnorderedElementsAre(std::pair(property1, memgraph::storage::PropertyValue("value")))); { auto old_values = edge.ClearProperties(); @@ -5182,9 +5185,9 @@ TEST(StorageWithProperties, EdgePropertyClear) { ASSERT_FALSE(old_values->empty()); } - ASSERT_TRUE(edge.GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0); { auto old_values = edge.ClearProperties(); @@ -5192,19 +5195,19 @@ TEST(StorageWithProperties, EdgePropertyClear) { ASSERT_TRUE(old_values->empty()); } - ASSERT_TRUE(edge.GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0); acc.Abort(); } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; - auto old_value = edge.SetProperty(property2, storage::PropertyValue(42)); + auto old_value = edge.SetProperty(property2, memgraph::storage::PropertyValue(42)); ASSERT_TRUE(old_value.HasValue()); ASSERT_TRUE(old_value->IsNull()); @@ -5212,15 +5215,15 @@ TEST(StorageWithProperties, EdgePropertyClear) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; - ASSERT_EQ(edge.GetProperty(property1, storage::View::OLD)->ValueString(), "value"); - ASSERT_EQ(edge.GetProperty(property2, storage::View::OLD)->ValueInt(), 42); - ASSERT_THAT(edge.Properties(storage::View::OLD).GetValue(), - UnorderedElementsAre(std::pair(property1, storage::PropertyValue("value")), - std::pair(property2, storage::PropertyValue(42)))); + ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::OLD)->ValueString(), "value"); + ASSERT_EQ(edge.GetProperty(property2, memgraph::storage::View::OLD)->ValueInt(), 42); + ASSERT_THAT(edge.Properties(memgraph::storage::View::OLD).GetValue(), + UnorderedElementsAre(std::pair(property1, memgraph::storage::PropertyValue("value")), + std::pair(property2, memgraph::storage::PropertyValue(42)))); { auto old_values = edge.ClearProperties(); @@ -5228,9 +5231,9 @@ TEST(StorageWithProperties, EdgePropertyClear) { ASSERT_FALSE(old_values->empty()); } - ASSERT_TRUE(edge.GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0); { auto old_values = edge.ClearProperties(); @@ -5238,21 +5241,21 @@ TEST(StorageWithProperties, EdgePropertyClear) { ASSERT_TRUE(old_values->empty()); } - ASSERT_TRUE(edge.GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0); ASSERT_FALSE(acc.Commit().HasError()); } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; - ASSERT_TRUE(edge.GetProperty(property1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW).GetValue().size(), 0); + ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0); acc.Abort(); } @@ -5260,8 +5263,8 @@ TEST(StorageWithProperties, EdgePropertyClear) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageWithoutProperties, EdgePropertyAbort) { - storage::Storage store({.items = {.properties_on_edges = false}}); - storage::Gid gid = storage::Gid::FromUint(std::numeric_limits::max()); + memgraph::storage::Storage store({.items = {.properties_on_edges = false}}); + memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits::max()); { auto acc = store.Access(); auto vertex = acc.CreateVertex(); @@ -5275,61 +5278,61 @@ TEST(StorageWithoutProperties, EdgePropertyAbort) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); { - auto res = edge.SetProperty(property, storage::PropertyValue("temporary")); + auto res = edge.SetProperty(property, memgraph::storage::PropertyValue("temporary")); ASSERT_TRUE(res.HasError()); - ASSERT_EQ(res.GetError(), storage::Error::PROPERTIES_DISABLED); + ASSERT_EQ(res.GetError(), memgraph::storage::Error::PROPERTIES_DISABLED); } - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); { - auto res = edge.SetProperty(property, storage::PropertyValue("nandare")); + auto res = edge.SetProperty(property, memgraph::storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasError()); - ASSERT_EQ(res.GetError(), storage::Error::PROPERTIES_DISABLED); + ASSERT_EQ(res.GetError(), memgraph::storage::Error::PROPERTIES_DISABLED); } - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); acc.Abort(); } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; auto property = acc.NameToProperty("property5"); - ASSERT_TRUE(edge.GetProperty(property, storage::View::OLD)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0); - ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); - ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); + ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0); auto other_property = acc.NameToProperty("other"); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull()); acc.Abort(); } } TEST(StorageWithoutProperties, EdgePropertyClear) { - storage::Storage store({.items = {.properties_on_edges = false}}); - storage::Gid gid; + memgraph::storage::Storage store({.items = {.properties_on_edges = false}}); + memgraph::storage::Gid gid; { auto acc = store.Access(); auto vertex = acc.CreateVertex(); @@ -5343,18 +5346,18 @@ TEST(StorageWithoutProperties, EdgePropertyClear) { } { auto acc = store.Access(); - auto vertex = acc.FindVertex(gid, storage::View::OLD); + auto vertex = acc.FindVertex(gid, memgraph::storage::View::OLD); ASSERT_TRUE(vertex); - auto edge = vertex->OutEdges(storage::View::NEW).GetValue()[0]; + auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue()[0]; - ASSERT_EQ(edge.ClearProperties().GetError(), storage::Error::PROPERTIES_DISABLED); + ASSERT_EQ(edge.ClearProperties().GetError(), memgraph::storage::Error::PROPERTIES_DISABLED); acc.Abort(); } } TEST(StorageWithProperties, EdgeNonexistentPropertyAPI) { - storage::Storage store({.items = {.properties_on_edges = true}}); + memgraph::storage::Storage store({.items = {.properties_on_edges = true}}); auto property = store.NameToProperty("property"); @@ -5364,23 +5367,25 @@ TEST(StorageWithProperties, EdgeNonexistentPropertyAPI) { ASSERT_TRUE(edge.HasValue()); // Check state before (OLD view). - ASSERT_EQ(edge->Properties(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(edge->GetProperty(property, storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(edge->Properties(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(edge->GetProperty(property, memgraph::storage::View::OLD).GetError(), + memgraph::storage::Error::NONEXISTENT_OBJECT); // Check state before (NEW view). - ASSERT_EQ(edge->Properties(storage::View::NEW)->size(), 0); - ASSERT_EQ(*edge->GetProperty(property, storage::View::NEW), storage::PropertyValue()); + ASSERT_EQ(edge->Properties(memgraph::storage::View::NEW)->size(), 0); + ASSERT_EQ(*edge->GetProperty(property, memgraph::storage::View::NEW), memgraph::storage::PropertyValue()); // Modify edge. - ASSERT_TRUE(edge->SetProperty(property, storage::PropertyValue("value"))->IsNull()); + ASSERT_TRUE(edge->SetProperty(property, memgraph::storage::PropertyValue("value"))->IsNull()); // Check state after (OLD view). - ASSERT_EQ(edge->Properties(storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); - ASSERT_EQ(edge->GetProperty(property, storage::View::OLD).GetError(), storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(edge->Properties(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT); + ASSERT_EQ(edge->GetProperty(property, memgraph::storage::View::OLD).GetError(), + memgraph::storage::Error::NONEXISTENT_OBJECT); // Check state after (NEW view). - ASSERT_EQ(edge->Properties(storage::View::NEW)->size(), 1); - ASSERT_EQ(*edge->GetProperty(property, storage::View::NEW), storage::PropertyValue("value")); + ASSERT_EQ(edge->Properties(memgraph::storage::View::NEW)->size(), 1); + ASSERT_EQ(*edge->GetProperty(property, memgraph::storage::View::NEW), memgraph::storage::PropertyValue("value")); ASSERT_FALSE(acc.Commit().HasError()); } diff --git a/tests/unit/storage_v2_gc.cpp b/tests/unit/storage_v2_gc.cpp index d868ccebe..34b7b74aa 100644 --- a/tests/unit/storage_v2_gc.cpp +++ b/tests/unit/storage_v2_gc.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,10 +24,10 @@ using testing::UnorderedElementsAre; // then verify that GC didn't delete anything it shouldn't have. // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2Gc, Sanity) { - storage::Storage storage( - storage::Config{.gc = {.type = storage::Config::Gc::Type::PERIODIC, .interval = std::chrono::milliseconds(100)}}); + memgraph::storage::Storage storage(memgraph::storage::Config{ + .gc = {.type = memgraph::storage::Config::Gc::Type::PERIODIC, .interval = std::chrono::milliseconds(100)}}); - std::vector vertices; + std::vector vertices; { auto acc = storage.Access(); @@ -40,7 +40,7 @@ TEST(StorageV2Gc, Sanity) { acc.AdvanceCommand(); for (uint64_t i = 0; i < 1000; ++i) { - auto vertex = acc.FindVertex(vertices[i], storage::View::OLD); + auto vertex = acc.FindVertex(vertices[i], memgraph::storage::View::OLD); ASSERT_TRUE(vertex.has_value()); if (i % 5 == 0) { EXPECT_FALSE(acc.DeleteVertex(&vertex.value()).HasError()); @@ -51,8 +51,8 @@ TEST(StorageV2Gc, Sanity) { std::this_thread::sleep_for(std::chrono::milliseconds(300)); for (uint64_t i = 0; i < 1000; ++i) { - auto vertex_old = acc.FindVertex(vertices[i], storage::View::OLD); - auto vertex_new = acc.FindVertex(vertices[i], storage::View::NEW); + auto vertex_old = acc.FindVertex(vertices[i], memgraph::storage::View::OLD); + auto vertex_new = acc.FindVertex(vertices[i], memgraph::storage::View::NEW); EXPECT_TRUE(vertex_old.has_value()); EXPECT_EQ(vertex_new.has_value(), i % 5 != 0); } @@ -64,13 +64,13 @@ TEST(StorageV2Gc, Sanity) { { auto acc = storage.Access(); for (uint64_t i = 0; i < 1000; ++i) { - auto vertex = acc.FindVertex(vertices[i], storage::View::OLD); + auto vertex = acc.FindVertex(vertices[i], memgraph::storage::View::OLD); EXPECT_EQ(vertex.has_value(), i % 5 != 0); if (vertex.has_value()) { - EXPECT_FALSE(vertex->AddLabel(storage::LabelId::FromUint(3 * i)).HasError()); - EXPECT_FALSE(vertex->AddLabel(storage::LabelId::FromUint(3 * i + 1)).HasError()); - EXPECT_FALSE(vertex->AddLabel(storage::LabelId::FromUint(3 * i + 2)).HasError()); + EXPECT_FALSE(vertex->AddLabel(memgraph::storage::LabelId::FromUint(3 * i)).HasError()); + EXPECT_FALSE(vertex->AddLabel(memgraph::storage::LabelId::FromUint(3 * i + 1)).HasError()); + EXPECT_FALSE(vertex->AddLabel(memgraph::storage::LabelId::FromUint(3 * i + 2)).HasError()); } } @@ -79,19 +79,19 @@ TEST(StorageV2Gc, Sanity) { // Verify labels. for (uint64_t i = 0; i < 1000; ++i) { - auto vertex = acc.FindVertex(vertices[i], storage::View::NEW); + auto vertex = acc.FindVertex(vertices[i], memgraph::storage::View::NEW); EXPECT_EQ(vertex.has_value(), i % 5 != 0); if (vertex.has_value()) { - auto labels_old = vertex->Labels(storage::View::OLD); + auto labels_old = vertex->Labels(memgraph::storage::View::OLD); EXPECT_TRUE(labels_old.HasValue()); EXPECT_TRUE(labels_old->empty()); - auto labels_new = vertex->Labels(storage::View::NEW); + auto labels_new = vertex->Labels(memgraph::storage::View::NEW); EXPECT_TRUE(labels_new.HasValue()); - EXPECT_THAT(labels_new.GetValue(), - UnorderedElementsAre(storage::LabelId::FromUint(3 * i), storage::LabelId::FromUint(3 * i + 1), - storage::LabelId::FromUint(3 * i + 2))); + EXPECT_THAT(labels_new.GetValue(), UnorderedElementsAre(memgraph::storage::LabelId::FromUint(3 * i), + memgraph::storage::LabelId::FromUint(3 * i + 1), + memgraph::storage::LabelId::FromUint(3 * i + 2))); } } @@ -102,20 +102,21 @@ TEST(StorageV2Gc, Sanity) { { auto acc = storage.Access(); for (uint64_t i = 0; i < 1000; ++i) { - auto from_vertex = acc.FindVertex(vertices[i], storage::View::OLD); - auto to_vertex = acc.FindVertex(vertices[(i + 1) % 1000], storage::View::OLD); + auto from_vertex = acc.FindVertex(vertices[i], memgraph::storage::View::OLD); + auto to_vertex = acc.FindVertex(vertices[(i + 1) % 1000], memgraph::storage::View::OLD); EXPECT_EQ(from_vertex.has_value(), i % 5 != 0); EXPECT_EQ(to_vertex.has_value(), (i + 1) % 5 != 0); if (from_vertex.has_value() && to_vertex.has_value()) { EXPECT_FALSE( - acc.CreateEdge(&from_vertex.value(), &to_vertex.value(), storage::EdgeTypeId::FromUint(i)).HasError()); + acc.CreateEdge(&from_vertex.value(), &to_vertex.value(), memgraph::storage::EdgeTypeId::FromUint(i)) + .HasError()); } } // Detach delete some vertices. for (uint64_t i = 0; i < 1000; ++i) { - auto vertex = acc.FindVertex(vertices[i], storage::View::NEW); + auto vertex = acc.FindVertex(vertices[i], memgraph::storage::View::NEW); EXPECT_EQ(vertex.has_value(), i % 5 != 0); if (vertex.has_value()) { if (i % 3 == 0) { @@ -129,22 +130,22 @@ TEST(StorageV2Gc, Sanity) { // Vertify edges. for (uint64_t i = 0; i < 1000; ++i) { - auto vertex = acc.FindVertex(vertices[i], storage::View::NEW); + auto vertex = acc.FindVertex(vertices[i], memgraph::storage::View::NEW); EXPECT_EQ(vertex.has_value(), i % 5 != 0 && i % 3 != 0); if (vertex.has_value()) { - auto out_edges = vertex->OutEdges(storage::View::NEW); + auto out_edges = vertex->OutEdges(memgraph::storage::View::NEW); if (i % 5 != 4 && i % 3 != 2) { EXPECT_EQ(out_edges.GetValue().size(), 1); - EXPECT_EQ(*vertex->OutDegree(storage::View::NEW), 1); + EXPECT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1); EXPECT_EQ(out_edges.GetValue().at(0).EdgeType().AsUint(), i); } else { EXPECT_TRUE(out_edges->empty()); } - auto in_edges = vertex->InEdges(storage::View::NEW); + auto in_edges = vertex->InEdges(memgraph::storage::View::NEW); if (i % 5 != 1 && i % 3 != 1) { EXPECT_EQ(in_edges.GetValue().size(), 1); - EXPECT_EQ(*vertex->InDegree(storage::View::NEW), 1); + EXPECT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1); EXPECT_EQ(in_edges.GetValue().at(0).EdgeType().AsUint(), (i + 999) % 1000); } else { EXPECT_TRUE(in_edges->empty()); @@ -165,8 +166,8 @@ TEST(StorageV2Gc, Sanity) { // transaction 1 can still see them with that label. // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(StorageV2Gc, Indices) { - storage::Storage storage( - storage::Config{.gc = {.type = storage::Config::Gc::Type::PERIODIC, .interval = std::chrono::milliseconds(100)}}); + memgraph::storage::Storage storage(memgraph::storage::Config{ + .gc = {.type = memgraph::storage::Config::Gc::Type::PERIODIC, .interval = std::chrono::milliseconds(100)}}); ASSERT_TRUE(storage.CreateIndex(storage.NameToLabel("label"))); @@ -182,7 +183,7 @@ TEST(StorageV2Gc, Indices) { auto acc1 = storage.Access(); auto acc2 = storage.Access(); - for (auto vertex : acc2.Vertices(storage::View::OLD)) { + for (auto vertex : acc2.Vertices(memgraph::storage::View::OLD)) { ASSERT_TRUE(*vertex.RemoveLabel(acc2.NameToLabel("label"))); } ASSERT_FALSE(acc2.Commit().HasError()); @@ -190,8 +191,8 @@ TEST(StorageV2Gc, Indices) { // Wait for GC. std::this_thread::sleep_for(std::chrono::milliseconds(300)); - std::set gids; - for (auto vertex : acc1.Vertices(acc1.NameToLabel("label"), storage::View::OLD)) { + std::set gids; + for (auto vertex : acc1.Vertices(acc1.NameToLabel("label"), memgraph::storage::View::OLD)) { gids.insert(vertex.Gid()); } EXPECT_EQ(gids.size(), 1000); diff --git a/tests/unit/storage_v2_indices.cpp b/tests/unit/storage_v2_indices.cpp index 0144886ef..894752bf7 100644 --- a/tests/unit/storage_v2_indices.cpp +++ b/tests/unit/storage_v2_indices.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "storage/v2/temporal.hpp" // NOLINTNEXTLINE(google-build-using-namespace) -using namespace storage; +using namespace memgraph::storage; using testing::IsEmpty; using testing::UnorderedElementsAre; @@ -565,38 +565,38 @@ TEST_F(IndexTest, LabelPropertyIndexFiltering) { } // [1, +inf> - EXPECT_THAT( - GetIds(acc.Vertices(label1, prop_val, utils::MakeBoundInclusive(PropertyValue(1)), std::nullopt, View::OLD)), - UnorderedElementsAre(2, 3, 4, 5, 6, 7, 8, 9)); + EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, memgraph::utils::MakeBoundInclusive(PropertyValue(1)), + std::nullopt, View::OLD)), + UnorderedElementsAre(2, 3, 4, 5, 6, 7, 8, 9)); // <1, +inf> - EXPECT_THAT( - GetIds(acc.Vertices(label1, prop_val, utils::MakeBoundExclusive(PropertyValue(1)), std::nullopt, View::OLD)), - UnorderedElementsAre(4, 5, 6, 7, 8, 9)); + EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, memgraph::utils::MakeBoundExclusive(PropertyValue(1)), + std::nullopt, View::OLD)), + UnorderedElementsAre(4, 5, 6, 7, 8, 9)); // <-inf, 3] - EXPECT_THAT( - GetIds(acc.Vertices(label1, prop_val, std::nullopt, utils::MakeBoundInclusive(PropertyValue(3)), View::OLD)), - UnorderedElementsAre(0, 1, 2, 3, 4, 5, 6, 7)); + EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, std::nullopt, + memgraph::utils::MakeBoundInclusive(PropertyValue(3)), View::OLD)), + UnorderedElementsAre(0, 1, 2, 3, 4, 5, 6, 7)); // <-inf, 3> - EXPECT_THAT( - GetIds(acc.Vertices(label1, prop_val, std::nullopt, utils::MakeBoundExclusive(PropertyValue(3)), View::OLD)), - UnorderedElementsAre(0, 1, 2, 3, 4, 5)); + EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, std::nullopt, + memgraph::utils::MakeBoundExclusive(PropertyValue(3)), View::OLD)), + UnorderedElementsAre(0, 1, 2, 3, 4, 5)); // [1, 3] - EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, utils::MakeBoundInclusive(PropertyValue(1)), - utils::MakeBoundInclusive(PropertyValue(3)), View::OLD)), + EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, memgraph::utils::MakeBoundInclusive(PropertyValue(1)), + memgraph::utils::MakeBoundInclusive(PropertyValue(3)), View::OLD)), UnorderedElementsAre(2, 3, 4, 5, 6, 7)); // <1, 3] - EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, utils::MakeBoundExclusive(PropertyValue(1)), - utils::MakeBoundInclusive(PropertyValue(3)), View::OLD)), + EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, memgraph::utils::MakeBoundExclusive(PropertyValue(1)), + memgraph::utils::MakeBoundInclusive(PropertyValue(3)), View::OLD)), UnorderedElementsAre(4, 5, 6, 7)); // [1, 3> - EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, utils::MakeBoundInclusive(PropertyValue(1)), - utils::MakeBoundExclusive(PropertyValue(3)), View::OLD)), + EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, memgraph::utils::MakeBoundInclusive(PropertyValue(1)), + memgraph::utils::MakeBoundExclusive(PropertyValue(3)), View::OLD)), UnorderedElementsAre(2, 3, 4, 5)); // <1, 3> - EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, utils::MakeBoundExclusive(PropertyValue(1)), - utils::MakeBoundExclusive(PropertyValue(3)), View::OLD)), + EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, memgraph::utils::MakeBoundExclusive(PropertyValue(1)), + memgraph::utils::MakeBoundExclusive(PropertyValue(3)), View::OLD)), UnorderedElementsAre(4, 5)); } } @@ -619,8 +619,8 @@ TEST_F(IndexTest, LabelPropertyIndexCountEstimate) { EXPECT_EQ(acc.ApproximateVertexCount(label1, prop_val, PropertyValue(i)), i); } - EXPECT_EQ(acc.ApproximateVertexCount(label1, prop_val, utils::MakeBoundInclusive(PropertyValue(2)), - utils::MakeBoundInclusive(PropertyValue(6))), + EXPECT_EQ(acc.ApproximateVertexCount(label1, prop_val, memgraph::utils::MakeBoundInclusive(PropertyValue(2)), + memgraph::utils::MakeBoundInclusive(PropertyValue(6))), 2 + 3 + 4 + 5 + 6); } @@ -686,8 +686,9 @@ TEST_F(IndexTest, LabelPropertyIndexMixedIteration) { ASSERT_EQ(it, iterable.end()); } - auto verify = [&](const std::optional> &from, - const std::optional> &to, const std::vector &expected) { + auto verify = [&](const std::optional> &from, + const std::optional> &to, + const std::vector &expected) { auto acc = storage.Access(); auto iterable = acc.Vertices(label1, prop_val, from, to, View::OLD); size_t i = 0; @@ -702,97 +703,115 @@ TEST_F(IndexTest, LabelPropertyIndexMixedIteration) { // Range iteration with two specified bounds that have the same type should // yield the naturally expected items. - verify(utils::MakeBoundExclusive(PropertyValue(false)), utils::MakeBoundExclusive(PropertyValue(true)), {}); - verify(utils::MakeBoundExclusive(PropertyValue(false)), utils::MakeBoundInclusive(PropertyValue(true)), - {PropertyValue(true)}); - verify(utils::MakeBoundInclusive(PropertyValue(false)), utils::MakeBoundExclusive(PropertyValue(true)), - {PropertyValue(false)}); - verify(utils::MakeBoundInclusive(PropertyValue(false)), utils::MakeBoundInclusive(PropertyValue(true)), - {PropertyValue(false), PropertyValue(true)}); - verify(utils::MakeBoundExclusive(PropertyValue(0)), utils::MakeBoundExclusive(PropertyValue(1.8)), + verify(memgraph::utils::MakeBoundExclusive(PropertyValue(false)), + memgraph::utils::MakeBoundExclusive(PropertyValue(true)), {}); + verify(memgraph::utils::MakeBoundExclusive(PropertyValue(false)), + memgraph::utils::MakeBoundInclusive(PropertyValue(true)), {PropertyValue(true)}); + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(false)), + memgraph::utils::MakeBoundExclusive(PropertyValue(true)), {PropertyValue(false)}); + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(false)), + memgraph::utils::MakeBoundInclusive(PropertyValue(true)), {PropertyValue(false), PropertyValue(true)}); + verify(memgraph::utils::MakeBoundExclusive(PropertyValue(0)), memgraph::utils::MakeBoundExclusive(PropertyValue(1.8)), {PropertyValue(0.5), PropertyValue(1), PropertyValue(1.5)}); - verify(utils::MakeBoundExclusive(PropertyValue(0)), utils::MakeBoundInclusive(PropertyValue(1.8)), + verify(memgraph::utils::MakeBoundExclusive(PropertyValue(0)), memgraph::utils::MakeBoundInclusive(PropertyValue(1.8)), {PropertyValue(0.5), PropertyValue(1), PropertyValue(1.5)}); - verify(utils::MakeBoundInclusive(PropertyValue(0)), utils::MakeBoundExclusive(PropertyValue(1.8)), + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(0)), memgraph::utils::MakeBoundExclusive(PropertyValue(1.8)), {PropertyValue(0), PropertyValue(0.5), PropertyValue(1), PropertyValue(1.5)}); - verify(utils::MakeBoundInclusive(PropertyValue(0)), utils::MakeBoundInclusive(PropertyValue(1.8)), + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(0)), memgraph::utils::MakeBoundInclusive(PropertyValue(1.8)), {PropertyValue(0), PropertyValue(0.5), PropertyValue(1), PropertyValue(1.5)}); - verify(utils::MakeBoundExclusive(PropertyValue("b")), utils::MakeBoundExclusive(PropertyValue("memgraph")), - {PropertyValue("c")}); - verify(utils::MakeBoundExclusive(PropertyValue("b")), utils::MakeBoundInclusive(PropertyValue("memgraph")), - {PropertyValue("c")}); - verify(utils::MakeBoundInclusive(PropertyValue("b")), utils::MakeBoundExclusive(PropertyValue("memgraph")), - {PropertyValue("b"), PropertyValue("c")}); - verify(utils::MakeBoundInclusive(PropertyValue("b")), utils::MakeBoundInclusive(PropertyValue("memgraph")), - {PropertyValue("b"), PropertyValue("c")}); - verify(utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue(0.8)})), - utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue("b")})), + verify(memgraph::utils::MakeBoundExclusive(PropertyValue("b")), + memgraph::utils::MakeBoundExclusive(PropertyValue("memgraph")), {PropertyValue("c")}); + verify(memgraph::utils::MakeBoundExclusive(PropertyValue("b")), + memgraph::utils::MakeBoundInclusive(PropertyValue("memgraph")), {PropertyValue("c")}); + verify(memgraph::utils::MakeBoundInclusive(PropertyValue("b")), + memgraph::utils::MakeBoundExclusive(PropertyValue("memgraph")), {PropertyValue("b"), PropertyValue("c")}); + verify(memgraph::utils::MakeBoundInclusive(PropertyValue("b")), + memgraph::utils::MakeBoundInclusive(PropertyValue("memgraph")), {PropertyValue("b"), PropertyValue("c")}); + verify(memgraph::utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue(0.8)})), + memgraph::utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue("b")})), {PropertyValue(std::vector{PropertyValue(2)})}); - verify(utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue(0.8)})), - utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue("b")})), + verify(memgraph::utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue(0.8)})), + memgraph::utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue("b")})), {PropertyValue(std::vector{PropertyValue(2)})}); - verify(utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue(0.8)})), - utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue("b")})), + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue(0.8)})), + memgraph::utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue("b")})), {PropertyValue(std::vector{PropertyValue(0.8)}), PropertyValue(std::vector{PropertyValue(2)})}); - verify(utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue(0.8)})), - utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue("b")})), + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue(0.8)})), + memgraph::utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue("b")})), {PropertyValue(std::vector{PropertyValue(0.8)}), PropertyValue(std::vector{PropertyValue(2)})}); - verify(utils::MakeBoundExclusive(PropertyValue(std::map{{"id", PropertyValue(5.0)}})), - utils::MakeBoundExclusive(PropertyValue(std::map{{"id", PropertyValue("b")}})), + verify(memgraph::utils::MakeBoundExclusive( + PropertyValue(std::map{{"id", PropertyValue(5.0)}})), + memgraph::utils::MakeBoundExclusive( + PropertyValue(std::map{{"id", PropertyValue("b")}})), {PropertyValue(std::map{{"id", PropertyValue(10)}})}); - verify(utils::MakeBoundExclusive(PropertyValue(std::map{{"id", PropertyValue(5.0)}})), - utils::MakeBoundInclusive(PropertyValue(std::map{{"id", PropertyValue("b")}})), + verify(memgraph::utils::MakeBoundExclusive( + PropertyValue(std::map{{"id", PropertyValue(5.0)}})), + memgraph::utils::MakeBoundInclusive( + PropertyValue(std::map{{"id", PropertyValue("b")}})), {PropertyValue(std::map{{"id", PropertyValue(10)}})}); - verify(utils::MakeBoundInclusive(PropertyValue(std::map{{"id", PropertyValue(5.0)}})), - utils::MakeBoundExclusive(PropertyValue(std::map{{"id", PropertyValue("b")}})), + verify(memgraph::utils::MakeBoundInclusive( + PropertyValue(std::map{{"id", PropertyValue(5.0)}})), + memgraph::utils::MakeBoundExclusive( + PropertyValue(std::map{{"id", PropertyValue("b")}})), {PropertyValue(std::map{{"id", PropertyValue(5)}}), PropertyValue(std::map{{"id", PropertyValue(10)}})}); - verify(utils::MakeBoundInclusive(PropertyValue(std::map{{"id", PropertyValue(5.0)}})), - utils::MakeBoundInclusive(PropertyValue(std::map{{"id", PropertyValue("b")}})), + verify(memgraph::utils::MakeBoundInclusive( + PropertyValue(std::map{{"id", PropertyValue(5.0)}})), + memgraph::utils::MakeBoundInclusive( + PropertyValue(std::map{{"id", PropertyValue("b")}})), {PropertyValue(std::map{{"id", PropertyValue(5)}}), PropertyValue(std::map{{"id", PropertyValue(10)}})}); - verify(utils::MakeBoundExclusive(PropertyValue(temporals[0])), - utils::MakeBoundInclusive(PropertyValue(TemporalData{TemporalType::Date, 200})), + verify(memgraph::utils::MakeBoundExclusive(PropertyValue(temporals[0])), + memgraph::utils::MakeBoundInclusive(PropertyValue(TemporalData{TemporalType::Date, 200})), // LocalDateTime has a "higher" type number so it is not part of the range {PropertyValue(temporals[1])}); - verify(utils::MakeBoundExclusive(PropertyValue(temporals[0])), utils::MakeBoundInclusive(PropertyValue(temporals[2])), + verify(memgraph::utils::MakeBoundExclusive(PropertyValue(temporals[0])), + memgraph::utils::MakeBoundInclusive(PropertyValue(temporals[2])), {PropertyValue(temporals[1]), PropertyValue(temporals[2])}); - verify(utils::MakeBoundInclusive(PropertyValue(temporals[0])), utils::MakeBoundExclusive(PropertyValue(temporals[2])), + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(temporals[0])), + memgraph::utils::MakeBoundExclusive(PropertyValue(temporals[2])), {PropertyValue(temporals[0]), PropertyValue(temporals[1])}); - verify(utils::MakeBoundInclusive(PropertyValue(temporals[0])), utils::MakeBoundInclusive(PropertyValue(temporals[2])), + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(temporals[0])), + memgraph::utils::MakeBoundInclusive(PropertyValue(temporals[2])), {PropertyValue(temporals[0]), PropertyValue(temporals[1]), PropertyValue(temporals[2])}); // Range iteration with one unspecified bound should only yield items that // have the same type as the specified bound. - verify(utils::MakeBoundInclusive(PropertyValue(false)), std::nullopt, {PropertyValue(false), PropertyValue(true)}); - verify(std::nullopt, utils::MakeBoundExclusive(PropertyValue(true)), {PropertyValue(false)}); - verify(utils::MakeBoundInclusive(PropertyValue(1)), std::nullopt, + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(false)), std::nullopt, + {PropertyValue(false), PropertyValue(true)}); + verify(std::nullopt, memgraph::utils::MakeBoundExclusive(PropertyValue(true)), {PropertyValue(false)}); + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(1)), std::nullopt, {PropertyValue(1), PropertyValue(1.5), PropertyValue(2), PropertyValue(std::numeric_limits::max()), PropertyValue(std::numeric_limits::infinity())}); - verify(std::nullopt, utils::MakeBoundExclusive(PropertyValue(0)), + verify(std::nullopt, memgraph::utils::MakeBoundExclusive(PropertyValue(0)), {PropertyValue(-std::numeric_limits::infinity()), PropertyValue(std::numeric_limits::min()), PropertyValue(-1), PropertyValue(-0.5)}); - verify(utils::MakeBoundInclusive(PropertyValue("b")), std::nullopt, {PropertyValue("b"), PropertyValue("c")}); - verify(std::nullopt, utils::MakeBoundExclusive(PropertyValue("b")), {PropertyValue(""), PropertyValue("a")}); - verify(utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue(false)})), std::nullopt, + verify(memgraph::utils::MakeBoundInclusive(PropertyValue("b")), std::nullopt, + {PropertyValue("b"), PropertyValue("c")}); + verify(std::nullopt, memgraph::utils::MakeBoundExclusive(PropertyValue("b")), + {PropertyValue(""), PropertyValue("a")}); + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(std::vector{PropertyValue(false)})), + std::nullopt, {PropertyValue(std::vector{PropertyValue(0.8)}), PropertyValue(std::vector{PropertyValue(2)})}); - verify(std::nullopt, utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue(1)})), + verify(std::nullopt, memgraph::utils::MakeBoundExclusive(PropertyValue(std::vector{PropertyValue(1)})), {PropertyValue(std::vector()), PropertyValue(std::vector{PropertyValue(0.8)})}); - verify(utils::MakeBoundInclusive(PropertyValue(std::map{{"id", PropertyValue(false)}})), + verify(memgraph::utils::MakeBoundInclusive( + PropertyValue(std::map{{"id", PropertyValue(false)}})), std::nullopt, {PropertyValue(std::map{{"id", PropertyValue(5)}}), PropertyValue(std::map{{"id", PropertyValue(10)}})}); verify(std::nullopt, - utils::MakeBoundExclusive(PropertyValue(std::map{{"id", PropertyValue(7.5)}})), + memgraph::utils::MakeBoundExclusive( + PropertyValue(std::map{{"id", PropertyValue(7.5)}})), {PropertyValue(std::map()), PropertyValue(std::map{{"id", PropertyValue(5)}})}); - verify(utils::MakeBoundInclusive(PropertyValue(TemporalData(TemporalType::Date, 10))), std::nullopt, + verify(memgraph::utils::MakeBoundInclusive(PropertyValue(TemporalData(TemporalType::Date, 10))), std::nullopt, {PropertyValue(temporals[0]), PropertyValue(temporals[1]), PropertyValue(temporals[2])}); - verify(std::nullopt, utils::MakeBoundExclusive(PropertyValue(TemporalData(TemporalType::Duration, 0))), + verify(std::nullopt, memgraph::utils::MakeBoundExclusive(PropertyValue(TemporalData(TemporalType::Duration, 0))), {PropertyValue(temporals[0]), PropertyValue(temporals[1]), PropertyValue(temporals[2])}); // Range iteration with two specified bounds that don't have the same type @@ -800,10 +819,10 @@ TEST_F(IndexTest, LabelPropertyIndexMixedIteration) { for (size_t i = 0; i < values.size(); ++i) { for (size_t j = i; j < values.size(); ++j) { if (PropertyValue::AreComparableTypes(values[i].type(), values[j].type())) { - verify(utils::MakeBoundInclusive(values[i]), utils::MakeBoundInclusive(values[j]), + verify(memgraph::utils::MakeBoundInclusive(values[i]), memgraph::utils::MakeBoundInclusive(values[j]), {values.begin() + i, values.begin() + j + 1}); } else { - verify(utils::MakeBoundInclusive(values[i]), utils::MakeBoundInclusive(values[j]), {}); + verify(memgraph::utils::MakeBoundInclusive(values[i]), memgraph::utils::MakeBoundInclusive(values[j]), {}); } } } diff --git a/tests/unit/storage_v2_isolation_level.cpp b/tests/unit/storage_v2_isolation_level.cpp index 39ebb5ccd..f1e2aaf9c 100644 --- a/tests/unit/storage_v2_isolation_level.cpp +++ b/tests/unit/storage_v2_isolation_level.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,36 +15,36 @@ #include "storage/v2/storage.hpp" namespace { -int64_t VerticesCount(storage::Storage::Accessor &accessor) { +int64_t VerticesCount(memgraph::storage::Storage::Accessor &accessor) { int64_t count{0}; - for ([[maybe_unused]] const auto &vertex : accessor.Vertices(storage::View::NEW)) { + for ([[maybe_unused]] const auto &vertex : accessor.Vertices(memgraph::storage::View::NEW)) { ++count; } return count; } -constexpr std::array isolation_levels{storage::IsolationLevel::SNAPSHOT_ISOLATION, - storage::IsolationLevel::READ_COMMITTED, - storage::IsolationLevel::READ_UNCOMMITTED}; +constexpr std::array isolation_levels{memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION, + memgraph::storage::IsolationLevel::READ_COMMITTED, + memgraph::storage::IsolationLevel::READ_UNCOMMITTED}; -std::string_view IsolationLevelToString(const storage::IsolationLevel isolation_level) { +std::string_view IsolationLevelToString(const memgraph::storage::IsolationLevel isolation_level) { switch (isolation_level) { - case storage::IsolationLevel::SNAPSHOT_ISOLATION: + case memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION: return "SNAPSHOT_ISOLATION"; - case storage::IsolationLevel::READ_COMMITTED: + case memgraph::storage::IsolationLevel::READ_COMMITTED: return "READ_COMMITTED"; - case storage::IsolationLevel::READ_UNCOMMITTED: + case memgraph::storage::IsolationLevel::READ_UNCOMMITTED: return "READ_UNCOMMITTED"; } } } // namespace -class StorageIsolationLevelTest : public ::testing::TestWithParam { +class StorageIsolationLevelTest : public ::testing::TestWithParam { public: struct PrintToStringParamName { - std::string operator()(const testing::TestParamInfo &info) { - return std::string(IsolationLevelToString(static_cast(info.param))); + std::string operator()(const testing::TestParamInfo &info) { + return std::string(IsolationLevelToString(static_cast(info.param))); } }; }; @@ -53,7 +53,8 @@ TEST_P(StorageIsolationLevelTest, Visibility) { const auto default_isolation_level = GetParam(); for (const auto override_isolation_level : isolation_levels) { - storage::Storage storage{storage::Config{.transaction = {.isolation_level = default_isolation_level}}}; + memgraph::storage::Storage storage{ + memgraph::storage::Config{.transaction = {.isolation_level = default_isolation_level}}}; auto creator = storage.Access(); auto default_isolation_level_reader = storage.Access(); auto override_isolation_level_reader = storage.Access(override_isolation_level); @@ -71,7 +72,7 @@ TEST_P(StorageIsolationLevelTest, Visibility) { creator.CreateVertex(); const auto check_vertices_count = [i](auto &accessor, const auto isolation_level) { - const auto expected_count = isolation_level == storage::IsolationLevel::READ_UNCOMMITTED ? i : 0; + const auto expected_count = isolation_level == memgraph::storage::IsolationLevel::READ_UNCOMMITTED ? i : 0; EXPECT_EQ(VerticesCount(accessor), expected_count); }; check_vertices_count(default_isolation_level_reader, default_isolation_level); @@ -87,7 +88,7 @@ TEST_P(StorageIsolationLevelTest, Visibility) { IsolationLevelToString(default_isolation_level), IsolationLevelToString(override_isolation_level))); const auto check_vertices_count = [iteration_count](auto &accessor, const auto isolation_level) { const auto expected_count = - isolation_level == storage::IsolationLevel::SNAPSHOT_ISOLATION ? 0 : iteration_count; + isolation_level == memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION ? 0 : iteration_count; ASSERT_EQ(VerticesCount(accessor), expected_count); }; diff --git a/tests/unit/storage_v2_name_id_mapper.cpp b/tests/unit/storage_v2_name_id_mapper.cpp index d14844ce8..b7865d775 100644 --- a/tests/unit/storage_v2_name_id_mapper.cpp +++ b/tests/unit/storage_v2_name_id_mapper.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,7 +15,7 @@ // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(NameIdMapper, Basic) { - storage::NameIdMapper mapper; + memgraph::storage::NameIdMapper mapper; ASSERT_EQ(mapper.NameToId("n1"), 0); ASSERT_EQ(mapper.NameToId("n2"), 1); @@ -29,7 +29,7 @@ TEST(NameIdMapper, Basic) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(NameIdMapper, Correctness) { - storage::NameIdMapper mapper; + memgraph::storage::NameIdMapper mapper; ASSERT_DEATH(mapper.IdToName(0), ""); ASSERT_EQ(mapper.NameToId("n1"), 0); diff --git a/tests/unit/storage_v2_property_store.cpp b/tests/unit/storage_v2_property_store.cpp index 55d756d42..e247806d8 100644 --- a/tests/unit/storage_v2_property_store.cpp +++ b/tests/unit/storage_v2_property_store.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,41 +20,42 @@ using testing::UnorderedElementsAre; -const storage::PropertyValue kSampleValues[] = { - storage::PropertyValue(), - storage::PropertyValue(false), - storage::PropertyValue(true), - storage::PropertyValue(0), - storage::PropertyValue(33), - storage::PropertyValue(-33), - storage::PropertyValue(-3137), - storage::PropertyValue(3137), - storage::PropertyValue(310000007), - storage::PropertyValue(-310000007), - storage::PropertyValue(3100000000007L), - storage::PropertyValue(-3100000000007L), - storage::PropertyValue(0.0), - storage::PropertyValue(33.33), - storage::PropertyValue(-33.33), - storage::PropertyValue(3137.3137), - storage::PropertyValue(-3137.3137), - storage::PropertyValue("sample"), - storage::PropertyValue(std::string(404, 'n')), - storage::PropertyValue(std::vector{ - storage::PropertyValue(33), storage::PropertyValue(std::string("sample")), storage::PropertyValue(-33.33)}), - storage::PropertyValue( - std::vector{storage::PropertyValue(), storage::PropertyValue(false)}), - storage::PropertyValue(std::map{{"sample", storage::PropertyValue()}, - {"key", storage::PropertyValue(false)}}), - storage::PropertyValue( - std::map{{"test", storage::PropertyValue(33)}, - {"map", storage::PropertyValue(std::string("sample"))}, - {"item", storage::PropertyValue(-33.33)}}), - storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23)), +const memgraph::storage::PropertyValue kSampleValues[] = { + memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(false), + memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(0), + memgraph::storage::PropertyValue(33), + memgraph::storage::PropertyValue(-33), + memgraph::storage::PropertyValue(-3137), + memgraph::storage::PropertyValue(3137), + memgraph::storage::PropertyValue(310000007), + memgraph::storage::PropertyValue(-310000007), + memgraph::storage::PropertyValue(3100000000007L), + memgraph::storage::PropertyValue(-3100000000007L), + memgraph::storage::PropertyValue(0.0), + memgraph::storage::PropertyValue(33.33), + memgraph::storage::PropertyValue(-33.33), + memgraph::storage::PropertyValue(3137.3137), + memgraph::storage::PropertyValue(-3137.3137), + memgraph::storage::PropertyValue("sample"), + memgraph::storage::PropertyValue(std::string(404, 'n')), + memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(33), memgraph::storage::PropertyValue(std::string("sample")), + memgraph::storage::PropertyValue(-33.33)}), + memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(), memgraph::storage::PropertyValue(false)}), + memgraph::storage::PropertyValue(std::map{ + {"sample", memgraph::storage::PropertyValue()}, {"key", memgraph::storage::PropertyValue(false)}}), + memgraph::storage::PropertyValue(std::map{ + {"test", memgraph::storage::PropertyValue(33)}, + {"map", memgraph::storage::PropertyValue(std::string("sample"))}, + {"item", memgraph::storage::PropertyValue(-33.33)}}), + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23)), }; -void TestIsPropertyEqual(const storage::PropertyStore &store, storage::PropertyId property, - const storage::PropertyValue &value) { +void TestIsPropertyEqual(const memgraph::storage::PropertyStore &store, memgraph::storage::PropertyId property, + const memgraph::storage::PropertyValue &value) { ASSERT_TRUE(store.IsPropertyEqual(property, value)); for (const auto &sample : kSampleValues) { if (sample == value) { @@ -66,27 +67,27 @@ void TestIsPropertyEqual(const storage::PropertyStore &store, storage::PropertyI } TEST(PropertyStore, Simple) { - storage::PropertyStore props; - auto prop = storage::PropertyId::FromInt(42); - auto value = storage::PropertyValue(42); + memgraph::storage::PropertyStore props; + auto prop = memgraph::storage::PropertyId::FromInt(42); + auto value = memgraph::storage::PropertyValue(42); ASSERT_TRUE(props.SetProperty(prop, value)); ASSERT_EQ(props.GetProperty(prop), value); ASSERT_TRUE(props.HasProperty(prop)); TestIsPropertyEqual(props, prop, value); ASSERT_THAT(props.Properties(), UnorderedElementsAre(std::pair(prop, value))); - ASSERT_FALSE(props.SetProperty(prop, storage::PropertyValue())); + ASSERT_FALSE(props.SetProperty(prop, memgraph::storage::PropertyValue())); ASSERT_TRUE(props.GetProperty(prop).IsNull()); ASSERT_FALSE(props.HasProperty(prop)); - TestIsPropertyEqual(props, prop, storage::PropertyValue()); + TestIsPropertyEqual(props, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props.Properties().size(), 0); } TEST(PropertyStore, SimpleLarge) { - storage::PropertyStore props; - auto prop = storage::PropertyId::FromInt(42); + memgraph::storage::PropertyStore props; + auto prop = memgraph::storage::PropertyId::FromInt(42); { - auto value = storage::PropertyValue(std::string(10000, 'a')); + auto value = memgraph::storage::PropertyValue(std::string(10000, 'a')); ASSERT_TRUE(props.SetProperty(prop, value)); ASSERT_EQ(props.GetProperty(prop), value); ASSERT_TRUE(props.HasProperty(prop)); @@ -94,7 +95,8 @@ TEST(PropertyStore, SimpleLarge) { ASSERT_THAT(props.Properties(), UnorderedElementsAre(std::pair(prop, value))); } { - auto value = storage::PropertyValue(storage::TemporalData(storage::TemporalType::Date, 23)); + auto value = + memgraph::storage::PropertyValue(memgraph::storage::TemporalData(memgraph::storage::TemporalType::Date, 23)); ASSERT_FALSE(props.SetProperty(prop, value)); ASSERT_EQ(props.GetProperty(prop), value); ASSERT_TRUE(props.HasProperty(prop)); @@ -102,27 +104,27 @@ TEST(PropertyStore, SimpleLarge) { ASSERT_THAT(props.Properties(), UnorderedElementsAre(std::pair(prop, value))); } - ASSERT_FALSE(props.SetProperty(prop, storage::PropertyValue())); + ASSERT_FALSE(props.SetProperty(prop, memgraph::storage::PropertyValue())); ASSERT_TRUE(props.GetProperty(prop).IsNull()); ASSERT_FALSE(props.HasProperty(prop)); - TestIsPropertyEqual(props, prop, storage::PropertyValue()); + TestIsPropertyEqual(props, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props.Properties().size(), 0); } TEST(PropertyStore, EmptySetToNull) { - storage::PropertyStore props; - auto prop = storage::PropertyId::FromInt(42); - ASSERT_TRUE(props.SetProperty(prop, storage::PropertyValue())); + memgraph::storage::PropertyStore props; + auto prop = memgraph::storage::PropertyId::FromInt(42); + ASSERT_TRUE(props.SetProperty(prop, memgraph::storage::PropertyValue())); ASSERT_TRUE(props.GetProperty(prop).IsNull()); ASSERT_FALSE(props.HasProperty(prop)); - TestIsPropertyEqual(props, prop, storage::PropertyValue()); + TestIsPropertyEqual(props, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props.Properties().size(), 0); } TEST(PropertyStore, Clear) { - storage::PropertyStore props; - auto prop = storage::PropertyId::FromInt(42); - auto value = storage::PropertyValue(42); + memgraph::storage::PropertyStore props; + auto prop = memgraph::storage::PropertyId::FromInt(42); + auto value = memgraph::storage::PropertyValue(42); ASSERT_TRUE(props.SetProperty(prop, value)); ASSERT_EQ(props.GetProperty(prop), value); ASSERT_TRUE(props.HasProperty(prop)); @@ -131,27 +133,27 @@ TEST(PropertyStore, Clear) { ASSERT_TRUE(props.ClearProperties()); ASSERT_TRUE(props.GetProperty(prop).IsNull()); ASSERT_FALSE(props.HasProperty(prop)); - TestIsPropertyEqual(props, prop, storage::PropertyValue()); + TestIsPropertyEqual(props, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props.Properties().size(), 0); } TEST(PropertyStore, EmptyClear) { - storage::PropertyStore props; + memgraph::storage::PropertyStore props; ASSERT_FALSE(props.ClearProperties()); ASSERT_EQ(props.Properties().size(), 0); } TEST(PropertyStore, MoveConstruct) { - storage::PropertyStore props1; - auto prop = storage::PropertyId::FromInt(42); - auto value = storage::PropertyValue(42); + memgraph::storage::PropertyStore props1; + auto prop = memgraph::storage::PropertyId::FromInt(42); + auto value = memgraph::storage::PropertyValue(42); ASSERT_TRUE(props1.SetProperty(prop, value)); ASSERT_EQ(props1.GetProperty(prop), value); ASSERT_TRUE(props1.HasProperty(prop)); TestIsPropertyEqual(props1, prop, value); ASSERT_THAT(props1.Properties(), UnorderedElementsAre(std::pair(prop, value))); { - storage::PropertyStore props2(std::move(props1)); + memgraph::storage::PropertyStore props2(std::move(props1)); ASSERT_EQ(props2.GetProperty(prop), value); ASSERT_TRUE(props2.HasProperty(prop)); TestIsPropertyEqual(props2, prop, value); @@ -160,21 +162,21 @@ TEST(PropertyStore, MoveConstruct) { // NOLINTNEXTLINE(bugprone-use-after-move,clang-analyzer-cplusplus.Move,hicpp-invalid-access-moved) ASSERT_TRUE(props1.GetProperty(prop).IsNull()); ASSERT_FALSE(props1.HasProperty(prop)); - TestIsPropertyEqual(props1, prop, storage::PropertyValue()); + TestIsPropertyEqual(props1, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props1.Properties().size(), 0); } TEST(PropertyStore, MoveConstructLarge) { - storage::PropertyStore props1; - auto prop = storage::PropertyId::FromInt(42); - auto value = storage::PropertyValue(std::string(10000, 'a')); + memgraph::storage::PropertyStore props1; + auto prop = memgraph::storage::PropertyId::FromInt(42); + auto value = memgraph::storage::PropertyValue(std::string(10000, 'a')); ASSERT_TRUE(props1.SetProperty(prop, value)); ASSERT_EQ(props1.GetProperty(prop), value); ASSERT_TRUE(props1.HasProperty(prop)); TestIsPropertyEqual(props1, prop, value); ASSERT_THAT(props1.Properties(), UnorderedElementsAre(std::pair(prop, value))); { - storage::PropertyStore props2(std::move(props1)); + memgraph::storage::PropertyStore props2(std::move(props1)); ASSERT_EQ(props2.GetProperty(prop), value); ASSERT_TRUE(props2.HasProperty(prop)); TestIsPropertyEqual(props2, prop, value); @@ -183,22 +185,22 @@ TEST(PropertyStore, MoveConstructLarge) { // NOLINTNEXTLINE(bugprone-use-after-move,clang-analyzer-cplusplus.Move,hicpp-invalid-access-moved) ASSERT_TRUE(props1.GetProperty(prop).IsNull()); ASSERT_FALSE(props1.HasProperty(prop)); - TestIsPropertyEqual(props1, prop, storage::PropertyValue()); + TestIsPropertyEqual(props1, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props1.Properties().size(), 0); } TEST(PropertyStore, MoveAssign) { - storage::PropertyStore props1; - auto prop = storage::PropertyId::FromInt(42); - auto value = storage::PropertyValue(42); + memgraph::storage::PropertyStore props1; + auto prop = memgraph::storage::PropertyId::FromInt(42); + auto value = memgraph::storage::PropertyValue(42); ASSERT_TRUE(props1.SetProperty(prop, value)); ASSERT_EQ(props1.GetProperty(prop), value); ASSERT_TRUE(props1.HasProperty(prop)); TestIsPropertyEqual(props1, prop, value); ASSERT_THAT(props1.Properties(), UnorderedElementsAre(std::pair(prop, value))); { - auto value2 = storage::PropertyValue(68); - storage::PropertyStore props2; + auto value2 = memgraph::storage::PropertyValue(68); + memgraph::storage::PropertyStore props2; ASSERT_TRUE(props2.SetProperty(prop, value2)); ASSERT_EQ(props2.GetProperty(prop), value2); ASSERT_TRUE(props2.HasProperty(prop)); @@ -213,22 +215,22 @@ TEST(PropertyStore, MoveAssign) { // NOLINTNEXTLINE(bugprone-use-after-move,clang-analyzer-cplusplus.Move,hicpp-invalid-access-moved) ASSERT_TRUE(props1.GetProperty(prop).IsNull()); ASSERT_FALSE(props1.HasProperty(prop)); - TestIsPropertyEqual(props1, prop, storage::PropertyValue()); + TestIsPropertyEqual(props1, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props1.Properties().size(), 0); } TEST(PropertyStore, MoveAssignLarge) { - storage::PropertyStore props1; - auto prop = storage::PropertyId::FromInt(42); - auto value = storage::PropertyValue(std::string(10000, 'a')); + memgraph::storage::PropertyStore props1; + auto prop = memgraph::storage::PropertyId::FromInt(42); + auto value = memgraph::storage::PropertyValue(std::string(10000, 'a')); ASSERT_TRUE(props1.SetProperty(prop, value)); ASSERT_EQ(props1.GetProperty(prop), value); ASSERT_TRUE(props1.HasProperty(prop)); TestIsPropertyEqual(props1, prop, value); ASSERT_THAT(props1.Properties(), UnorderedElementsAre(std::pair(prop, value))); { - auto value2 = storage::PropertyValue(std::string(10000, 'b')); - storage::PropertyStore props2; + auto value2 = memgraph::storage::PropertyValue(std::string(10000, 'b')); + memgraph::storage::PropertyStore props2; ASSERT_TRUE(props2.SetProperty(prop, value2)); ASSERT_EQ(props2.GetProperty(prop), value2); ASSERT_TRUE(props2.HasProperty(prop)); @@ -243,23 +245,25 @@ TEST(PropertyStore, MoveAssignLarge) { // NOLINTNEXTLINE(bugprone-use-after-move,clang-analyzer-cplusplus.Move,hicpp-invalid-access-moved) ASSERT_TRUE(props1.GetProperty(prop).IsNull()); ASSERT_FALSE(props1.HasProperty(prop)); - TestIsPropertyEqual(props1, prop, storage::PropertyValue()); + TestIsPropertyEqual(props1, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props1.Properties().size(), 0); } TEST(PropertyStore, EmptySet) { - std::vector vec{storage::PropertyValue(true), storage::PropertyValue(123), - storage::PropertyValue()}; - std::map map{{"nandare", storage::PropertyValue(false)}}; - const storage::TemporalData temporal{storage::TemporalType::LocalDateTime, 23}; - std::vector data{storage::PropertyValue(true), storage::PropertyValue(123), - storage::PropertyValue(123.5), storage::PropertyValue("nandare"), - storage::PropertyValue(vec), storage::PropertyValue(map), - storage::PropertyValue(temporal)}; + std::vector vec{memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123), + memgraph::storage::PropertyValue()}; + std::map map{{"nandare", memgraph::storage::PropertyValue(false)}}; + const memgraph::storage::TemporalData temporal{memgraph::storage::TemporalType::LocalDateTime, 23}; + std::vector data{ + memgraph::storage::PropertyValue(true), memgraph::storage::PropertyValue(123), + memgraph::storage::PropertyValue(123.5), memgraph::storage::PropertyValue("nandare"), + memgraph::storage::PropertyValue(vec), memgraph::storage::PropertyValue(map), + memgraph::storage::PropertyValue(temporal)}; - auto prop = storage::PropertyId::FromInt(42); + auto prop = memgraph::storage::PropertyId::FromInt(42); for (const auto &value : data) { - storage::PropertyStore props; + memgraph::storage::PropertyStore props; ASSERT_TRUE(props.SetProperty(prop, value)); ASSERT_EQ(props.GetProperty(prop), value); @@ -271,42 +275,43 @@ TEST(PropertyStore, EmptySet) { ASSERT_TRUE(props.HasProperty(prop)); TestIsPropertyEqual(props, prop, value); ASSERT_THAT(props.Properties(), UnorderedElementsAre(std::pair(prop, value))); - ASSERT_FALSE(props.SetProperty(prop, storage::PropertyValue())); + ASSERT_FALSE(props.SetProperty(prop, memgraph::storage::PropertyValue())); ASSERT_TRUE(props.GetProperty(prop).IsNull()); ASSERT_FALSE(props.HasProperty(prop)); - TestIsPropertyEqual(props, prop, storage::PropertyValue()); + TestIsPropertyEqual(props, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props.Properties().size(), 0); - ASSERT_TRUE(props.SetProperty(prop, storage::PropertyValue())); + ASSERT_TRUE(props.SetProperty(prop, memgraph::storage::PropertyValue())); ASSERT_TRUE(props.GetProperty(prop).IsNull()); ASSERT_FALSE(props.HasProperty(prop)); - TestIsPropertyEqual(props, prop, storage::PropertyValue()); + TestIsPropertyEqual(props, prop, memgraph::storage::PropertyValue()); ASSERT_EQ(props.Properties().size(), 0); } } TEST(PropertyStore, FullSet) { - std::vector vec{storage::PropertyValue(true), storage::PropertyValue(123), - storage::PropertyValue()}; - std::map map{{"nandare", storage::PropertyValue(false)}}; - const storage::TemporalData temporal{storage::TemporalType::LocalDateTime, 23}; - std::map data{ - {storage::PropertyId::FromInt(1), storage::PropertyValue(true)}, - {storage::PropertyId::FromInt(2), storage::PropertyValue(123)}, - {storage::PropertyId::FromInt(3), storage::PropertyValue(123.5)}, - {storage::PropertyId::FromInt(4), storage::PropertyValue("nandare")}, - {storage::PropertyId::FromInt(5), storage::PropertyValue(vec)}, - {storage::PropertyId::FromInt(6), storage::PropertyValue(map)}, - {storage::PropertyId::FromInt(7), storage::PropertyValue(temporal)}}; + std::vector vec{memgraph::storage::PropertyValue(true), + memgraph::storage::PropertyValue(123), + memgraph::storage::PropertyValue()}; + std::map map{{"nandare", memgraph::storage::PropertyValue(false)}}; + const memgraph::storage::TemporalData temporal{memgraph::storage::TemporalType::LocalDateTime, 23}; + std::map data{ + {memgraph::storage::PropertyId::FromInt(1), memgraph::storage::PropertyValue(true)}, + {memgraph::storage::PropertyId::FromInt(2), memgraph::storage::PropertyValue(123)}, + {memgraph::storage::PropertyId::FromInt(3), memgraph::storage::PropertyValue(123.5)}, + {memgraph::storage::PropertyId::FromInt(4), memgraph::storage::PropertyValue("nandare")}, + {memgraph::storage::PropertyId::FromInt(5), memgraph::storage::PropertyValue(vec)}, + {memgraph::storage::PropertyId::FromInt(6), memgraph::storage::PropertyValue(map)}, + {memgraph::storage::PropertyId::FromInt(7), memgraph::storage::PropertyValue(temporal)}}; - std::vector alt{storage::PropertyValue(), - storage::PropertyValue(std::string()), - storage::PropertyValue(std::string(10, 'a')), - storage::PropertyValue(std::string(100, 'a')), - storage::PropertyValue(std::string(1000, 'a')), - storage::PropertyValue(std::string(10000, 'a')), - storage::PropertyValue(std::string(100000, 'a'))}; + std::vector alt{memgraph::storage::PropertyValue(), + memgraph::storage::PropertyValue(std::string()), + memgraph::storage::PropertyValue(std::string(10, 'a')), + memgraph::storage::PropertyValue(std::string(100, 'a')), + memgraph::storage::PropertyValue(std::string(1000, 'a')), + memgraph::storage::PropertyValue(std::string(10000, 'a')), + memgraph::storage::PropertyValue(std::string(100000, 'a'))}; - storage::PropertyStore props; + memgraph::storage::PropertyStore props; for (const auto &target : data) { for (const auto &item : data) { ASSERT_TRUE(props.SetProperty(item.first, item.second)); @@ -378,41 +383,47 @@ TEST(PropertyStore, FullSet) { for (const auto &item : data) { ASSERT_TRUE(props.GetProperty(item.first).IsNull()); ASSERT_FALSE(props.HasProperty(item.first)); - TestIsPropertyEqual(props, item.first, storage::PropertyValue()); + TestIsPropertyEqual(props, item.first, memgraph::storage::PropertyValue()); } } } TEST(PropertyStore, IntEncoding) { - std::map data{ - {storage::PropertyId::FromUint(0UL), storage::PropertyValue(std::numeric_limits::min())}, - {storage::PropertyId::FromUint(10UL), storage::PropertyValue(-137438953472L)}, - {storage::PropertyId::FromUint(std::numeric_limits::max()), storage::PropertyValue(-4294967297L)}, - {storage::PropertyId::FromUint(256UL), storage::PropertyValue(std::numeric_limits::min())}, - {storage::PropertyId::FromUint(1024UL), storage::PropertyValue(-1048576L)}, - {storage::PropertyId::FromUint(1025UL), storage::PropertyValue(-65537L)}, - {storage::PropertyId::FromUint(1026UL), storage::PropertyValue(std::numeric_limits::min())}, - {storage::PropertyId::FromUint(1027UL), storage::PropertyValue(-1024L)}, - {storage::PropertyId::FromUint(2000UL), storage::PropertyValue(-257L)}, - {storage::PropertyId::FromUint(3000UL), storage::PropertyValue(std::numeric_limits::min())}, - {storage::PropertyId::FromUint(4000UL), storage::PropertyValue(-1L)}, - {storage::PropertyId::FromUint(10000UL), storage::PropertyValue(0L)}, - {storage::PropertyId::FromUint(20000UL), storage::PropertyValue(1L)}, - {storage::PropertyId::FromUint(30000UL), storage::PropertyValue(std::numeric_limits::max())}, - {storage::PropertyId::FromUint(40000UL), storage::PropertyValue(256L)}, - {storage::PropertyId::FromUint(50000UL), storage::PropertyValue(1024L)}, - {storage::PropertyId::FromUint(std::numeric_limits::max()), - storage::PropertyValue(std::numeric_limits::max())}, - {storage::PropertyId::FromUint(65536UL), storage::PropertyValue(65536L)}, - {storage::PropertyId::FromUint(1048576UL), storage::PropertyValue(1048576L)}, - {storage::PropertyId::FromUint(std::numeric_limits::max()), - storage::PropertyValue(std::numeric_limits::max())}, - {storage::PropertyId::FromUint(4294967296UL), storage::PropertyValue(4294967296L)}, - {storage::PropertyId::FromUint(137438953472UL), storage::PropertyValue(137438953472L)}, - {storage::PropertyId::FromUint(std::numeric_limits::max()), - storage::PropertyValue(std::numeric_limits::max())}}; + std::map data{ + {memgraph::storage::PropertyId::FromUint(0UL), + memgraph::storage::PropertyValue(std::numeric_limits::min())}, + {memgraph::storage::PropertyId::FromUint(10UL), memgraph::storage::PropertyValue(-137438953472L)}, + {memgraph::storage::PropertyId::FromUint(std::numeric_limits::max()), + memgraph::storage::PropertyValue(-4294967297L)}, + {memgraph::storage::PropertyId::FromUint(256UL), + memgraph::storage::PropertyValue(std::numeric_limits::min())}, + {memgraph::storage::PropertyId::FromUint(1024UL), memgraph::storage::PropertyValue(-1048576L)}, + {memgraph::storage::PropertyId::FromUint(1025UL), memgraph::storage::PropertyValue(-65537L)}, + {memgraph::storage::PropertyId::FromUint(1026UL), + memgraph::storage::PropertyValue(std::numeric_limits::min())}, + {memgraph::storage::PropertyId::FromUint(1027UL), memgraph::storage::PropertyValue(-1024L)}, + {memgraph::storage::PropertyId::FromUint(2000UL), memgraph::storage::PropertyValue(-257L)}, + {memgraph::storage::PropertyId::FromUint(3000UL), + memgraph::storage::PropertyValue(std::numeric_limits::min())}, + {memgraph::storage::PropertyId::FromUint(4000UL), memgraph::storage::PropertyValue(-1L)}, + {memgraph::storage::PropertyId::FromUint(10000UL), memgraph::storage::PropertyValue(0L)}, + {memgraph::storage::PropertyId::FromUint(20000UL), memgraph::storage::PropertyValue(1L)}, + {memgraph::storage::PropertyId::FromUint(30000UL), + memgraph::storage::PropertyValue(std::numeric_limits::max())}, + {memgraph::storage::PropertyId::FromUint(40000UL), memgraph::storage::PropertyValue(256L)}, + {memgraph::storage::PropertyId::FromUint(50000UL), memgraph::storage::PropertyValue(1024L)}, + {memgraph::storage::PropertyId::FromUint(std::numeric_limits::max()), + memgraph::storage::PropertyValue(std::numeric_limits::max())}, + {memgraph::storage::PropertyId::FromUint(65536UL), memgraph::storage::PropertyValue(65536L)}, + {memgraph::storage::PropertyId::FromUint(1048576UL), memgraph::storage::PropertyValue(1048576L)}, + {memgraph::storage::PropertyId::FromUint(std::numeric_limits::max()), + memgraph::storage::PropertyValue(std::numeric_limits::max())}, + {memgraph::storage::PropertyId::FromUint(4294967296UL), memgraph::storage::PropertyValue(4294967296L)}, + {memgraph::storage::PropertyId::FromUint(137438953472UL), memgraph::storage::PropertyValue(137438953472L)}, + {memgraph::storage::PropertyId::FromUint(std::numeric_limits::max()), + memgraph::storage::PropertyValue(std::numeric_limits::max())}}; - storage::PropertyStore props; + memgraph::storage::PropertyStore props; for (const auto &item : data) { ASSERT_TRUE(props.SetProperty(item.first, item.second)); ASSERT_EQ(props.GetProperty(item.first), item.second); @@ -434,22 +445,22 @@ TEST(PropertyStore, IntEncoding) { for (const auto &item : data) { ASSERT_TRUE(props.GetProperty(item.first).IsNull()); ASSERT_FALSE(props.HasProperty(item.first)); - TestIsPropertyEqual(props, item.first, storage::PropertyValue()); + TestIsPropertyEqual(props, item.first, memgraph::storage::PropertyValue()); } } TEST(PropertyStore, IsPropertyEqualIntAndDouble) { - storage::PropertyStore props; - auto prop = storage::PropertyId::FromInt(42); + memgraph::storage::PropertyStore props; + auto prop = memgraph::storage::PropertyId::FromInt(42); - ASSERT_TRUE(props.SetProperty(prop, storage::PropertyValue(42))); + ASSERT_TRUE(props.SetProperty(prop, memgraph::storage::PropertyValue(42))); - std::vector> tests{ - {storage::PropertyValue(0), storage::PropertyValue(0.0)}, - {storage::PropertyValue(123), storage::PropertyValue(123.0)}, - {storage::PropertyValue(12345), storage::PropertyValue(12345.0)}, - {storage::PropertyValue(12345678), storage::PropertyValue(12345678.0)}, - {storage::PropertyValue(1234567890123L), storage::PropertyValue(1234567890123.0)}, + std::vector> tests{ + {memgraph::storage::PropertyValue(0), memgraph::storage::PropertyValue(0.0)}, + {memgraph::storage::PropertyValue(123), memgraph::storage::PropertyValue(123.0)}, + {memgraph::storage::PropertyValue(12345), memgraph::storage::PropertyValue(12345.0)}, + {memgraph::storage::PropertyValue(12345678), memgraph::storage::PropertyValue(12345678.0)}, + {memgraph::storage::PropertyValue(1234567890123L), memgraph::storage::PropertyValue(1234567890123.0)}, }; // Test equality with raw values. @@ -471,8 +482,8 @@ TEST(PropertyStore, IsPropertyEqualIntAndDouble) { ASSERT_TRUE(props.IsPropertyEqual(prop, test.first)); // Make both negative - test.first = storage::PropertyValue(test.first.ValueInt() * -1); - test.second = storage::PropertyValue(test.second.ValueDouble() * -1.0); + test.first = memgraph::storage::PropertyValue(test.first.ValueInt() * -1); + test.second = memgraph::storage::PropertyValue(test.second.ValueDouble() * -1.0); ASSERT_EQ(test.first, test.second); // Test -first, -second @@ -492,10 +503,10 @@ TEST(PropertyStore, IsPropertyEqualIntAndDouble) { // Test equality with values wrapped in lists. for (auto test : tests) { - test.first = - storage::PropertyValue(std::vector{storage::PropertyValue(test.first.ValueInt())}); - test.second = - storage::PropertyValue(std::vector{storage::PropertyValue(test.second.ValueDouble())}); + test.first = memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(test.first.ValueInt())}); + test.second = memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(test.second.ValueDouble())}); ASSERT_EQ(test.first, test.second); // Test first, second @@ -513,10 +524,10 @@ TEST(PropertyStore, IsPropertyEqualIntAndDouble) { ASSERT_TRUE(props.IsPropertyEqual(prop, test.first)); // Make both negative - test.first = storage::PropertyValue( - std::vector{storage::PropertyValue(test.first.ValueList()[0].ValueInt() * -1)}); - test.second = storage::PropertyValue( - std::vector{storage::PropertyValue(test.second.ValueList()[0].ValueDouble() * -1.0)}); + test.first = memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(test.first.ValueList()[0].ValueInt() * -1)}); + test.second = memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(test.second.ValueList()[0].ValueDouble() * -1.0)}); ASSERT_EQ(test.first, test.second); // Test -first, -second @@ -536,96 +547,105 @@ TEST(PropertyStore, IsPropertyEqualIntAndDouble) { } TEST(PropertyStore, IsPropertyEqualString) { - storage::PropertyStore props; - auto prop = storage::PropertyId::FromInt(42); - ASSERT_TRUE(props.SetProperty(prop, storage::PropertyValue("test"))); - ASSERT_TRUE(props.IsPropertyEqual(prop, storage::PropertyValue("test"))); + memgraph::storage::PropertyStore props; + auto prop = memgraph::storage::PropertyId::FromInt(42); + ASSERT_TRUE(props.SetProperty(prop, memgraph::storage::PropertyValue("test"))); + ASSERT_TRUE(props.IsPropertyEqual(prop, memgraph::storage::PropertyValue("test"))); // Different length. - ASSERT_FALSE(props.IsPropertyEqual(prop, storage::PropertyValue("helloworld"))); + ASSERT_FALSE(props.IsPropertyEqual(prop, memgraph::storage::PropertyValue("helloworld"))); // Same length, different value. - ASSERT_FALSE(props.IsPropertyEqual(prop, storage::PropertyValue("asdf"))); + ASSERT_FALSE(props.IsPropertyEqual(prop, memgraph::storage::PropertyValue("asdf"))); // Shortened and extended. - ASSERT_FALSE(props.IsPropertyEqual(prop, storage::PropertyValue("tes"))); - ASSERT_FALSE(props.IsPropertyEqual(prop, storage::PropertyValue("testt"))); + ASSERT_FALSE(props.IsPropertyEqual(prop, memgraph::storage::PropertyValue("tes"))); + ASSERT_FALSE(props.IsPropertyEqual(prop, memgraph::storage::PropertyValue("testt"))); } TEST(PropertyStore, IsPropertyEqualList) { - storage::PropertyStore props; - auto prop = storage::PropertyId::FromInt(42); - ASSERT_TRUE(props.SetProperty(prop, storage::PropertyValue(std::vector{ - storage::PropertyValue(42), storage::PropertyValue("test")}))); - ASSERT_TRUE(props.IsPropertyEqual(prop, storage::PropertyValue(std::vector{ - storage::PropertyValue(42), storage::PropertyValue("test")}))); + memgraph::storage::PropertyStore props; + auto prop = memgraph::storage::PropertyId::FromInt(42); + ASSERT_TRUE( + props.SetProperty(prop, memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(42), memgraph::storage::PropertyValue("test")}))); + ASSERT_TRUE(props.IsPropertyEqual( + prop, memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(42), memgraph::storage::PropertyValue("test")}))); // Different length. ASSERT_FALSE(props.IsPropertyEqual( - prop, storage::PropertyValue(std::vector{storage::PropertyValue(24)}))); + prop, memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(24)}))); // Same length, different value. - ASSERT_FALSE(props.IsPropertyEqual(prop, storage::PropertyValue(std::vector{ - storage::PropertyValue(42), storage::PropertyValue("asdf")}))); + ASSERT_FALSE(props.IsPropertyEqual( + prop, memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(42), memgraph::storage::PropertyValue("asdf")}))); // Shortened and extended. ASSERT_FALSE(props.IsPropertyEqual( - prop, storage::PropertyValue(std::vector{storage::PropertyValue(42)}))); - ASSERT_FALSE(props.IsPropertyEqual( - prop, storage::PropertyValue(std::vector{ - storage::PropertyValue(42), storage::PropertyValue("test"), storage::PropertyValue(true)}))); + prop, memgraph::storage::PropertyValue( + std::vector{memgraph::storage::PropertyValue(42)}))); + ASSERT_FALSE( + props.IsPropertyEqual(prop, memgraph::storage::PropertyValue(std::vector{ + memgraph::storage::PropertyValue(42), memgraph::storage::PropertyValue("test"), + memgraph::storage::PropertyValue(true)}))); } TEST(PropertyStore, IsPropertyEqualMap) { - storage::PropertyStore props; - auto prop = storage::PropertyId::FromInt(42); - ASSERT_TRUE( - props.SetProperty(prop, storage::PropertyValue(std::map{ - {"abc", storage::PropertyValue(42)}, {"zyx", storage::PropertyValue("test")}}))); - ASSERT_TRUE( - props.IsPropertyEqual(prop, storage::PropertyValue(std::map{ - {"abc", storage::PropertyValue(42)}, {"zyx", storage::PropertyValue("test")}}))); + memgraph::storage::PropertyStore props; + auto prop = memgraph::storage::PropertyId::FromInt(42); + ASSERT_TRUE(props.SetProperty( + prop, memgraph::storage::PropertyValue(std::map{ + {"abc", memgraph::storage::PropertyValue(42)}, {"zyx", memgraph::storage::PropertyValue("test")}}))); + ASSERT_TRUE(props.IsPropertyEqual( + prop, memgraph::storage::PropertyValue(std::map{ + {"abc", memgraph::storage::PropertyValue(42)}, {"zyx", memgraph::storage::PropertyValue("test")}}))); // Different length. - ASSERT_FALSE(props.IsPropertyEqual(prop, storage::PropertyValue(std::map{ - {"fgh", storage::PropertyValue(24)}}))); + ASSERT_FALSE(props.IsPropertyEqual( + prop, memgraph::storage::PropertyValue(std::map{ + {"fgh", memgraph::storage::PropertyValue(24)}}))); // Same length, different value. - ASSERT_FALSE( - props.IsPropertyEqual(prop, storage::PropertyValue(std::map{ - {"abc", storage::PropertyValue(42)}, {"zyx", storage::PropertyValue("testt")}}))); + ASSERT_FALSE(props.IsPropertyEqual( + prop, memgraph::storage::PropertyValue(std::map{ + {"abc", memgraph::storage::PropertyValue(42)}, {"zyx", memgraph::storage::PropertyValue("testt")}}))); // Same length, different key (different length). - ASSERT_FALSE( - props.IsPropertyEqual(prop, storage::PropertyValue(std::map{ - {"abc", storage::PropertyValue(42)}, {"zyxw", storage::PropertyValue("test")}}))); + ASSERT_FALSE(props.IsPropertyEqual( + prop, memgraph::storage::PropertyValue(std::map{ + {"abc", memgraph::storage::PropertyValue(42)}, {"zyxw", memgraph::storage::PropertyValue("test")}}))); // Same length, different key (same length). - ASSERT_FALSE( - props.IsPropertyEqual(prop, storage::PropertyValue(std::map{ - {"abc", storage::PropertyValue(42)}, {"zyw", storage::PropertyValue("test")}}))); + ASSERT_FALSE(props.IsPropertyEqual( + prop, memgraph::storage::PropertyValue(std::map{ + {"abc", memgraph::storage::PropertyValue(42)}, {"zyw", memgraph::storage::PropertyValue("test")}}))); // Shortened and extended. - ASSERT_FALSE(props.IsPropertyEqual(prop, storage::PropertyValue(std::map{ - {"abc", storage::PropertyValue(42)}}))); - ASSERT_FALSE(props.IsPropertyEqual(prop, storage::PropertyValue(std::map{ - {"abc", storage::PropertyValue(42)}, - {"sdf", storage::PropertyValue(true)}, - {"zyx", storage::PropertyValue("test")}}))); + ASSERT_FALSE(props.IsPropertyEqual( + prop, memgraph::storage::PropertyValue(std::map{ + {"abc", memgraph::storage::PropertyValue(42)}}))); + ASSERT_FALSE(props.IsPropertyEqual( + prop, memgraph::storage::PropertyValue(std::map{ + {"abc", memgraph::storage::PropertyValue(42)}, + {"sdf", memgraph::storage::PropertyValue(true)}, + {"zyx", memgraph::storage::PropertyValue("test")}}))); } TEST(PropertyStore, IsPropertyEqualTemporalData) { - storage::PropertyStore props; - auto prop = storage::PropertyId::FromInt(42); - const storage::TemporalData temporal{storage::TemporalType::Date, 23}; - ASSERT_TRUE(props.SetProperty(prop, storage::PropertyValue(temporal))); - ASSERT_TRUE(props.IsPropertyEqual(prop, storage::PropertyValue(temporal))); + memgraph::storage::PropertyStore props; + auto prop = memgraph::storage::PropertyId::FromInt(42); + const memgraph::storage::TemporalData temporal{memgraph::storage::TemporalType::Date, 23}; + ASSERT_TRUE(props.SetProperty(prop, memgraph::storage::PropertyValue(temporal))); + ASSERT_TRUE(props.IsPropertyEqual(prop, memgraph::storage::PropertyValue(temporal))); // Different type. - ASSERT_FALSE( - props.IsPropertyEqual(prop, storage::PropertyValue(storage::TemporalData{storage::TemporalType::Duration, 23}))); + ASSERT_FALSE(props.IsPropertyEqual(prop, memgraph::storage::PropertyValue(memgraph::storage::TemporalData{ + memgraph::storage::TemporalType::Duration, 23}))); // Same type, different value. - ASSERT_FALSE( - props.IsPropertyEqual(prop, storage::PropertyValue(storage::TemporalData{storage::TemporalType::Date, 30}))); + ASSERT_FALSE(props.IsPropertyEqual(prop, memgraph::storage::PropertyValue(memgraph::storage::TemporalData{ + memgraph::storage::TemporalType::Date, 30}))); } diff --git a/tests/unit/storage_v2_replication.cpp b/tests/unit/storage_v2_replication.cpp index 582f4d1c5..eed941b06 100644 --- a/tests/unit/storage_v2_replication.cpp +++ b/tests/unit/storage_v2_replication.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -40,24 +40,24 @@ class ReplicationTest : public ::testing::Test { }; TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { - storage::Storage main_store( + memgraph::storage::Storage main_store( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - storage::Storage replica_store( + memgraph::storage::Storage replica_store( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - replica_store.SetReplicaRole(io::network::Endpoint{"127.0.0.1", 10000}); + replica_store.SetReplicaRole(memgraph::io::network::Endpoint{"127.0.0.1", 10000}); ASSERT_FALSE(main_store - .RegisterReplica("REPLICA", io::network::Endpoint{"127.0.0.1", 10000}, - storage::replication::ReplicationMode::SYNC) + .RegisterReplica("REPLICA", memgraph::io::network::Endpoint{"127.0.0.1", 10000}, + memgraph::storage::replication::ReplicationMode::SYNC) .HasError()); // vertex create @@ -66,30 +66,32 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { const auto *vertex_label = "vertex_label"; const auto *vertex_property = "vertex_property"; const auto *vertex_property_value = "vertex_property_value"; - std::optional vertex_gid; + std::optional vertex_gid; { auto acc = main_store.Access(); auto v = acc.CreateVertex(); vertex_gid.emplace(v.Gid()); ASSERT_TRUE(v.AddLabel(main_store.NameToLabel(vertex_label)).HasValue()); - ASSERT_TRUE(v.SetProperty(main_store.NameToProperty(vertex_property), storage::PropertyValue(vertex_property_value)) + ASSERT_TRUE(v.SetProperty(main_store.NameToProperty(vertex_property), + memgraph::storage::PropertyValue(vertex_property_value)) .HasValue()); ASSERT_FALSE(acc.Commit().HasError()); } { auto acc = replica_store.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); - const auto labels = v->Labels(storage::View::OLD); + const auto labels = v->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_EQ(labels->size(), 1); ASSERT_THAT(*labels, UnorderedElementsAre(replica_store.NameToLabel(vertex_label))); - const auto properties = v->Properties(storage::View::OLD); + const auto properties = v->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); ASSERT_EQ(properties->size(), 1); - ASSERT_THAT(*properties, UnorderedElementsAre(std::make_pair(replica_store.NameToProperty(vertex_property), - storage::PropertyValue(vertex_property_value)))); + ASSERT_THAT(*properties, + UnorderedElementsAre(std::make_pair(replica_store.NameToProperty(vertex_property), + memgraph::storage::PropertyValue(vertex_property_value)))); ASSERT_FALSE(acc.Commit().HasError()); } @@ -97,7 +99,7 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { // vertex remove label { auto acc = main_store.Access(); - auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); ASSERT_TRUE(v->RemoveLabel(main_store.NameToLabel(vertex_label)).HasValue()); ASSERT_FALSE(acc.Commit().HasError()); @@ -105,9 +107,9 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { { auto acc = replica_store.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); - const auto labels = v->Labels(storage::View::OLD); + const auto labels = v->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_EQ(labels->size(), 0); ASSERT_FALSE(acc.Commit().HasError()); @@ -116,7 +118,7 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { // vertex delete { auto acc = main_store.Access(); - auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); ASSERT_TRUE(acc.DeleteVertex(&*v).HasValue()); ASSERT_FALSE(acc.Commit().HasError()); @@ -124,7 +126,7 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { { auto acc = replica_store.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_FALSE(v); vertex_gid.reset(); ASSERT_FALSE(acc.Commit().HasError()); @@ -135,20 +137,22 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { const auto *edge_type = "edge_type"; const auto *edge_property = "edge_property"; const auto *edge_property_value = "edge_property_value"; - std::optional edge_gid; + std::optional edge_gid; { auto acc = main_store.Access(); auto v = acc.CreateVertex(); vertex_gid.emplace(v.Gid()); auto edge = acc.CreateEdge(&v, &v, main_store.NameToEdgeType(edge_type)); ASSERT_TRUE(edge.HasValue()); - ASSERT_TRUE(edge->SetProperty(main_store.NameToProperty(edge_property), storage::PropertyValue(edge_property_value)) + ASSERT_TRUE(edge->SetProperty(main_store.NameToProperty(edge_property), + memgraph::storage::PropertyValue(edge_property_value)) .HasValue()); edge_gid.emplace(edge->Gid()); ASSERT_FALSE(acc.Commit().HasError()); } - const auto find_edge = [&](const auto &edges, const storage::Gid edge_gid) -> std::optional { + const auto find_edge = [&](const auto &edges, + const memgraph::storage::Gid edge_gid) -> std::optional { for (const auto &edge : edges) { if (edge.Gid() == edge_gid) { return edge; @@ -159,26 +163,27 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { { auto acc = replica_store.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); - const auto out_edges = v->OutEdges(storage::View::OLD); + const auto out_edges = v->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(out_edges.HasValue()); const auto edge = find_edge(*out_edges, *edge_gid); ASSERT_EQ(edge->EdgeType(), replica_store.NameToEdgeType(edge_type)); - const auto properties = edge->Properties(storage::View::OLD); + const auto properties = edge->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); ASSERT_EQ(properties->size(), 1); - ASSERT_THAT(*properties, UnorderedElementsAre(std::make_pair(replica_store.NameToProperty(edge_property), - storage::PropertyValue(edge_property_value)))); + ASSERT_THAT(*properties, + UnorderedElementsAre(std::make_pair(replica_store.NameToProperty(edge_property), + memgraph::storage::PropertyValue(edge_property_value)))); ASSERT_FALSE(acc.Commit().HasError()); } // delete edge { auto acc = main_store.Access(); - auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); - auto out_edges = v->OutEdges(storage::View::OLD); + auto out_edges = v->OutEdges(memgraph::storage::View::OLD); auto edge = find_edge(*out_edges, *edge_gid); ASSERT_TRUE(edge); ASSERT_TRUE(acc.DeleteEdge(&*edge).HasValue()); @@ -187,9 +192,9 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { { auto acc = replica_store.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); - const auto out_edges = v->OutEdges(storage::View::OLD); + const auto out_edges = v->OutEdges(memgraph::storage::View::OLD); ASSERT_TRUE(out_edges.HasValue()); ASSERT_FALSE(find_edge(*out_edges, *edge_gid)); ASSERT_FALSE(acc.Commit().HasError()); @@ -240,7 +245,7 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { ASSERT_EQ( main_store.DropUniqueConstraint(main_store.NameToLabel(label), {main_store.NameToProperty(property), main_store.NameToProperty(property_extra)}), - storage::UniqueConstraints::DeletionStatus::SUCCESS); + memgraph::storage::UniqueConstraints::DeletionStatus::SUCCESS); } { @@ -255,54 +260,55 @@ TEST_F(ReplicationTest, BasicSynchronousReplicationTest) { } TEST_F(ReplicationTest, MultipleSynchronousReplicationTest) { - storage::Storage main_store( + memgraph::storage::Storage main_store( {.durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - storage::Storage replica_store1( + memgraph::storage::Storage replica_store1( {.durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - replica_store1.SetReplicaRole(io::network::Endpoint{"127.0.0.1", 10000}); + replica_store1.SetReplicaRole(memgraph::io::network::Endpoint{"127.0.0.1", 10000}); - storage::Storage replica_store2( + memgraph::storage::Storage replica_store2( {.durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - replica_store2.SetReplicaRole(io::network::Endpoint{"127.0.0.1", 20000}); + replica_store2.SetReplicaRole(memgraph::io::network::Endpoint{"127.0.0.1", 20000}); ASSERT_FALSE(main_store - .RegisterReplica("REPLICA1", io::network::Endpoint{"127.0.0.1", 10000}, - storage::replication::ReplicationMode::SYNC) + .RegisterReplica("REPLICA1", memgraph::io::network::Endpoint{"127.0.0.1", 10000}, + memgraph::storage::replication::ReplicationMode::SYNC) .HasError()); ASSERT_FALSE(main_store - .RegisterReplica("REPLICA2", io::network::Endpoint{"127.0.0.1", 20000}, - storage::replication::ReplicationMode::SYNC) + .RegisterReplica("REPLICA2", memgraph::io::network::Endpoint{"127.0.0.1", 20000}, + memgraph::storage::replication::ReplicationMode::SYNC) .HasError()); const auto *vertex_label = "label"; const auto *vertex_property = "property"; const auto *vertex_property_value = "property_value"; - std::optional vertex_gid; + std::optional vertex_gid; { auto acc = main_store.Access(); auto v = acc.CreateVertex(); ASSERT_TRUE(v.AddLabel(main_store.NameToLabel(vertex_label)).HasValue()); - ASSERT_TRUE(v.SetProperty(main_store.NameToProperty(vertex_property), storage::PropertyValue(vertex_property_value)) + ASSERT_TRUE(v.SetProperty(main_store.NameToProperty(vertex_property), + memgraph::storage::PropertyValue(vertex_property_value)) .HasValue()); vertex_gid.emplace(v.Gid()); ASSERT_FALSE(acc.Commit().HasError()); } - const auto check_replica = [&](storage::Storage *replica_store) { + const auto check_replica = [&](memgraph::storage::Storage *replica_store) { auto acc = replica_store->Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); - const auto labels = v->Labels(storage::View::OLD); + const auto labels = v->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_THAT(*labels, UnorderedElementsAre(replica_store->NameToLabel(vertex_label))); ASSERT_FALSE(acc.Commit().HasError()); @@ -322,7 +328,7 @@ TEST_F(ReplicationTest, MultipleSynchronousReplicationTest) { // REPLICA1 should contain the new vertex { auto acc = replica_store1.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); ASSERT_FALSE(acc.Commit().HasError()); } @@ -330,21 +336,21 @@ TEST_F(ReplicationTest, MultipleSynchronousReplicationTest) { // REPLICA2 should not contain the new vertex { auto acc = replica_store2.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_FALSE(v); ASSERT_FALSE(acc.Commit().HasError()); } } TEST_F(ReplicationTest, RecoveryProcess) { - std::vector vertex_gids; + std::vector vertex_gids; // Force the creation of snapshot { - storage::Storage main_store( + memgraph::storage::Storage main_store( {.durability = { .storage_directory = storage_directory, .recover_on_startup = true, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, .snapshot_on_exit = true, }}); { @@ -358,11 +364,11 @@ TEST_F(ReplicationTest, RecoveryProcess) { { // Create second WAL - storage::Storage main_store( + memgraph::storage::Storage main_store( {.durability = { .storage_directory = storage_directory, .recover_on_startup = true, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL}}); + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL}}); // Create vertices in 2 different transactions { auto acc = main_store.Access(); @@ -378,11 +384,11 @@ TEST_F(ReplicationTest, RecoveryProcess) { } } - storage::Storage main_store( + memgraph::storage::Storage main_store( {.durability = { .storage_directory = storage_directory, .recover_on_startup = true, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); constexpr const auto *property_name = "property_name"; @@ -391,42 +397,44 @@ TEST_F(ReplicationTest, RecoveryProcess) { // Force the creation of current WAL file auto acc = main_store.Access(); for (const auto &vertex_gid : vertex_gids) { - auto v = acc.FindVertex(vertex_gid, storage::View::OLD); + auto v = acc.FindVertex(vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); ASSERT_TRUE( - v->SetProperty(main_store.NameToProperty(property_name), storage::PropertyValue(property_value)).HasValue()); + v->SetProperty(main_store.NameToProperty(property_name), memgraph::storage::PropertyValue(property_value)) + .HasValue()); } ASSERT_FALSE(acc.Commit().HasError()); } std::filesystem::path replica_storage_directory{std::filesystem::temp_directory_path() / "MG_test_unit_storage_v2_replication_replica"}; - utils::OnScopeExit replica_directory_cleaner([&]() { std::filesystem::remove_all(replica_storage_directory); }); + memgraph::utils::OnScopeExit replica_directory_cleaner( + [&]() { std::filesystem::remove_all(replica_storage_directory); }); constexpr const auto *vertex_label = "vertex_label"; { - storage::Storage replica_store( + memgraph::storage::Storage replica_store( {.durability = { .storage_directory = replica_storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL}}); + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL}}); - replica_store.SetReplicaRole(io::network::Endpoint{"127.0.0.1", 10000}); + replica_store.SetReplicaRole(memgraph::io::network::Endpoint{"127.0.0.1", 10000}); ASSERT_FALSE(main_store - .RegisterReplica("REPLICA1", io::network::Endpoint{"127.0.0.1", 10000}, - storage::replication::ReplicationMode::SYNC) + .RegisterReplica("REPLICA1", memgraph::io::network::Endpoint{"127.0.0.1", 10000}, + memgraph::storage::replication::ReplicationMode::SYNC) .HasError()); - ASSERT_EQ(main_store.GetReplicaState("REPLICA1"), storage::replication::ReplicaState::RECOVERY); + ASSERT_EQ(main_store.GetReplicaState("REPLICA1"), memgraph::storage::replication::ReplicaState::RECOVERY); - while (main_store.GetReplicaState("REPLICA1") != storage::replication::ReplicaState::READY) { + while (main_store.GetReplicaState("REPLICA1") != memgraph::storage::replication::ReplicaState::READY) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } { auto acc = main_store.Access(); for (const auto &vertex_gid : vertex_gids) { - auto v = acc.FindVertex(vertex_gid, storage::View::OLD); + auto v = acc.FindVertex(vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); ASSERT_TRUE(v->AddLabel(main_store.NameToLabel(vertex_label)).HasValue()); } @@ -435,37 +443,39 @@ TEST_F(ReplicationTest, RecoveryProcess) { { auto acc = replica_store.Access(); for (const auto &vertex_gid : vertex_gids) { - auto v = acc.FindVertex(vertex_gid, storage::View::OLD); + auto v = acc.FindVertex(vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); - const auto labels = v->Labels(storage::View::OLD); + const auto labels = v->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_THAT(*labels, UnorderedElementsAre(replica_store.NameToLabel(vertex_label))); - const auto properties = v->Properties(storage::View::OLD); + const auto properties = v->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); - ASSERT_THAT(*properties, UnorderedElementsAre(std::make_pair(replica_store.NameToProperty(property_name), - storage::PropertyValue(property_value)))); + ASSERT_THAT(*properties, + UnorderedElementsAre(std::make_pair(replica_store.NameToProperty(property_name), + memgraph::storage::PropertyValue(property_value)))); } ASSERT_FALSE(acc.Commit().HasError()); } } { - storage::Storage replica_store( + memgraph::storage::Storage replica_store( {.durability = { .storage_directory = replica_storage_directory, .recover_on_startup = true, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL}}); + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL}}); { auto acc = replica_store.Access(); for (const auto &vertex_gid : vertex_gids) { - auto v = acc.FindVertex(vertex_gid, storage::View::OLD); + auto v = acc.FindVertex(vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); - const auto labels = v->Labels(storage::View::OLD); + const auto labels = v->Labels(memgraph::storage::View::OLD); ASSERT_TRUE(labels.HasValue()); ASSERT_THAT(*labels, UnorderedElementsAre(replica_store.NameToLabel(vertex_label))); - const auto properties = v->Properties(storage::View::OLD); + const auto properties = v->Properties(memgraph::storage::View::OLD); ASSERT_TRUE(properties.HasValue()); - ASSERT_THAT(*properties, UnorderedElementsAre(std::make_pair(replica_store.NameToProperty(property_name), - storage::PropertyValue(property_value)))); + ASSERT_THAT(*properties, + UnorderedElementsAre(std::make_pair(replica_store.NameToProperty(property_name), + memgraph::storage::PropertyValue(property_value)))); } ASSERT_FALSE(acc.Commit().HasError()); } @@ -473,29 +483,29 @@ TEST_F(ReplicationTest, RecoveryProcess) { } TEST_F(ReplicationTest, BasicAsynchronousReplicationTest) { - storage::Storage main_store( + memgraph::storage::Storage main_store( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - storage::Storage replica_store_async( + memgraph::storage::Storage replica_store_async( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - replica_store_async.SetReplicaRole(io::network::Endpoint{"127.0.0.1", 20000}); + replica_store_async.SetReplicaRole(memgraph::io::network::Endpoint{"127.0.0.1", 20000}); ASSERT_FALSE(main_store - .RegisterReplica("REPLICA_ASYNC", io::network::Endpoint{"127.0.0.1", 20000}, - storage::replication::ReplicationMode::ASYNC) + .RegisterReplica("REPLICA_ASYNC", memgraph::io::network::Endpoint{"127.0.0.1", 20000}, + memgraph::storage::replication::ReplicationMode::ASYNC) .HasError()); constexpr size_t vertices_create_num = 10; - std::vector created_vertices; + std::vector created_vertices; for (size_t i = 0; i < vertices_create_num; ++i) { auto acc = main_store.Access(); auto v = acc.CreateVertex(); @@ -503,19 +513,19 @@ TEST_F(ReplicationTest, BasicAsynchronousReplicationTest) { ASSERT_FALSE(acc.Commit().HasError()); if (i == 0) { - ASSERT_EQ(main_store.GetReplicaState("REPLICA_ASYNC"), storage::replication::ReplicaState::REPLICATING); + ASSERT_EQ(main_store.GetReplicaState("REPLICA_ASYNC"), memgraph::storage::replication::ReplicaState::REPLICATING); } else { - ASSERT_EQ(main_store.GetReplicaState("REPLICA_ASYNC"), storage::replication::ReplicaState::RECOVERY); + ASSERT_EQ(main_store.GetReplicaState("REPLICA_ASYNC"), memgraph::storage::replication::ReplicaState::RECOVERY); } } - while (main_store.GetReplicaState("REPLICA_ASYNC") != storage::replication::ReplicaState::READY) { + while (main_store.GetReplicaState("REPLICA_ASYNC") != memgraph::storage::replication::ReplicaState::READY) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } ASSERT_TRUE(std::all_of(created_vertices.begin(), created_vertices.end(), [&](const auto vertex_gid) { auto acc = replica_store_async.Access(); - auto v = acc.FindVertex(vertex_gid, storage::View::OLD); + auto v = acc.FindVertex(vertex_gid, memgraph::storage::View::OLD); const bool exists = v.has_value(); EXPECT_FALSE(acc.Commit().HasError()); return exists; @@ -523,42 +533,42 @@ TEST_F(ReplicationTest, BasicAsynchronousReplicationTest) { } TEST_F(ReplicationTest, EpochTest) { - storage::Storage main_store( + memgraph::storage::Storage main_store( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - storage::Storage replica_store1( + memgraph::storage::Storage replica_store1( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - replica_store1.SetReplicaRole(io::network::Endpoint{"127.0.0.1", 10000}); + replica_store1.SetReplicaRole(memgraph::io::network::Endpoint{"127.0.0.1", 10000}); - storage::Storage replica_store2( + memgraph::storage::Storage replica_store2( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - replica_store2.SetReplicaRole(io::network::Endpoint{"127.0.0.1", 10001}); + replica_store2.SetReplicaRole(memgraph::io::network::Endpoint{"127.0.0.1", 10001}); ASSERT_FALSE(main_store - .RegisterReplica("REPLICA1", io::network::Endpoint{"127.0.0.1", 10000}, - storage::replication::ReplicationMode::SYNC) + .RegisterReplica("REPLICA1", memgraph::io::network::Endpoint{"127.0.0.1", 10000}, + memgraph::storage::replication::ReplicationMode::SYNC) .HasError()); ASSERT_FALSE(main_store - .RegisterReplica("REPLICA2", io::network::Endpoint{"127.0.0.1", 10001}, - storage::replication::ReplicationMode::SYNC) + .RegisterReplica("REPLICA2", memgraph::io::network::Endpoint{"127.0.0.1", 10001}, + memgraph::storage::replication::ReplicationMode::SYNC) .HasError()); - std::optional vertex_gid; + std::optional vertex_gid; { auto acc = main_store.Access(); const auto v = acc.CreateVertex(); @@ -567,13 +577,13 @@ TEST_F(ReplicationTest, EpochTest) { } { auto acc = replica_store1.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); ASSERT_FALSE(acc.Commit().HasError()); } { auto acc = replica_store2.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); ASSERT_FALSE(acc.Commit().HasError()); } @@ -583,8 +593,8 @@ TEST_F(ReplicationTest, EpochTest) { replica_store1.SetMainReplicationRole(); ASSERT_FALSE(replica_store1 - .RegisterReplica("REPLICA2", io::network::Endpoint{"127.0.0.1", 10001}, - storage::replication::ReplicationMode::SYNC) + .RegisterReplica("REPLICA2", memgraph::io::network::Endpoint{"127.0.0.1", 10001}, + memgraph::storage::replication::ReplicationMode::SYNC) .HasError()); { @@ -601,15 +611,15 @@ TEST_F(ReplicationTest, EpochTest) { // Replica1 should forward it's vertex to Replica2 { auto acc = replica_store2.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_TRUE(v); ASSERT_FALSE(acc.Commit().HasError()); } - replica_store1.SetReplicaRole(io::network::Endpoint{"127.0.0.1", 10000}); + replica_store1.SetReplicaRole(memgraph::io::network::Endpoint{"127.0.0.1", 10000}); ASSERT_TRUE(main_store - .RegisterReplica("REPLICA1", io::network::Endpoint{"127.0.0.1", 10000}, - storage::replication::ReplicationMode::SYNC) + .RegisterReplica("REPLICA1", memgraph::io::network::Endpoint{"127.0.0.1", 10000}, + memgraph::storage::replication::ReplicationMode::SYNC) .HasError()); { @@ -622,70 +632,71 @@ TEST_F(ReplicationTest, EpochTest) { // it's newest vertex { auto acc = replica_store1.Access(); - const auto v = acc.FindVertex(*vertex_gid, storage::View::OLD); + const auto v = acc.FindVertex(*vertex_gid, memgraph::storage::View::OLD); ASSERT_FALSE(v); ASSERT_FALSE(acc.Commit().HasError()); } } TEST_F(ReplicationTest, ReplicationInformation) { - storage::Storage main_store( + memgraph::storage::Storage main_store( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - storage::Storage replica_store1( + memgraph::storage::Storage replica_store1( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - const io::network::Endpoint replica1_endpoint{"127.0.0.1", 10000}; + const memgraph::io::network::Endpoint replica1_endpoint{"127.0.0.1", 10000}; replica_store1.SetReplicaRole(replica1_endpoint); - const io::network::Endpoint replica2_endpoint{"127.0.0.1", 10000}; - storage::Storage replica_store2( + const memgraph::io::network::Endpoint replica2_endpoint{"127.0.0.1", 10000}; + memgraph::storage::Storage replica_store2( {.items = {.properties_on_edges = true}, .durability = { .storage_directory = storage_directory, - .snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, + .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); replica_store2.SetReplicaRole(replica2_endpoint); const std::string replica1_name{"REPLICA1"}; ASSERT_FALSE(main_store - .RegisterReplica(replica1_name, replica1_endpoint, storage::replication::ReplicationMode::SYNC, - {.timeout = 2.0}) + .RegisterReplica(replica1_name, replica1_endpoint, + memgraph::storage::replication::ReplicationMode::SYNC, {.timeout = 2.0}) .HasError()); const std::string replica2_name{"REPLICA2"}; ASSERT_FALSE( - main_store.RegisterReplica(replica2_name, replica2_endpoint, storage::replication::ReplicationMode::ASYNC) + main_store + .RegisterReplica(replica2_name, replica2_endpoint, memgraph::storage::replication::ReplicationMode::ASYNC) .HasError()); - ASSERT_EQ(main_store.GetReplicationRole(), storage::ReplicationRole::MAIN); - ASSERT_EQ(replica_store1.GetReplicationRole(), storage::ReplicationRole::REPLICA); - ASSERT_EQ(replica_store2.GetReplicationRole(), storage::ReplicationRole::REPLICA); + ASSERT_EQ(main_store.GetReplicationRole(), memgraph::storage::ReplicationRole::MAIN); + ASSERT_EQ(replica_store1.GetReplicationRole(), memgraph::storage::ReplicationRole::REPLICA); + ASSERT_EQ(replica_store2.GetReplicationRole(), memgraph::storage::ReplicationRole::REPLICA); const auto replicas_info = main_store.ReplicasInfo(); ASSERT_EQ(replicas_info.size(), 2); const auto &first_info = replicas_info[0]; ASSERT_EQ(first_info.name, replica1_name); - ASSERT_EQ(first_info.mode, storage::replication::ReplicationMode::SYNC); + ASSERT_EQ(first_info.mode, memgraph::storage::replication::ReplicationMode::SYNC); ASSERT_TRUE(first_info.timeout); ASSERT_EQ(*first_info.timeout, 2.0); ASSERT_EQ(first_info.endpoint, replica1_endpoint); - ASSERT_EQ(first_info.state, storage::replication::ReplicaState::READY); + ASSERT_EQ(first_info.state, memgraph::storage::replication::ReplicaState::READY); const auto &second_info = replicas_info[1]; ASSERT_EQ(second_info.name, replica2_name); - ASSERT_EQ(second_info.mode, storage::replication::ReplicationMode::ASYNC); + ASSERT_EQ(second_info.mode, memgraph::storage::replication::ReplicationMode::ASYNC); ASSERT_FALSE(second_info.timeout); ASSERT_EQ(second_info.endpoint, replica2_endpoint); - ASSERT_EQ(second_info.state, storage::replication::ReplicaState::READY); + ASSERT_EQ(second_info.state, memgraph::storage::replication::ReplicaState::READY); } diff --git a/tests/unit/storage_v2_wal_file.cpp b/tests/unit/storage_v2_wal_file.cpp index c59976726..5eb554aab 100644 --- a/tests/unit/storage_v2_wal_file.cpp +++ b/tests/unit/storage_v2_wal_file.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,25 +27,25 @@ #include "utils/uuid.hpp" // Helper function used to convert between enum types. -storage::durability::WalDeltaData::Type StorageGlobalOperationToWalDeltaDataType( - storage::durability::StorageGlobalOperation operation) { +memgraph::storage::durability::WalDeltaData::Type StorageGlobalOperationToWalDeltaDataType( + memgraph::storage::durability::StorageGlobalOperation operation) { switch (operation) { - case storage::durability::StorageGlobalOperation::LABEL_INDEX_CREATE: - return storage::durability::WalDeltaData::Type::LABEL_INDEX_CREATE; - case storage::durability::StorageGlobalOperation::LABEL_INDEX_DROP: - return storage::durability::WalDeltaData::Type::LABEL_INDEX_DROP; - case storage::durability::StorageGlobalOperation::LABEL_PROPERTY_INDEX_CREATE: - return storage::durability::WalDeltaData::Type::LABEL_PROPERTY_INDEX_CREATE; - case storage::durability::StorageGlobalOperation::LABEL_PROPERTY_INDEX_DROP: - return storage::durability::WalDeltaData::Type::LABEL_PROPERTY_INDEX_DROP; - case storage::durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_CREATE: - return storage::durability::WalDeltaData::Type::EXISTENCE_CONSTRAINT_CREATE; - case storage::durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_DROP: - return storage::durability::WalDeltaData::Type::EXISTENCE_CONSTRAINT_DROP; - case storage::durability::StorageGlobalOperation::UNIQUE_CONSTRAINT_CREATE: - return storage::durability::WalDeltaData::Type::UNIQUE_CONSTRAINT_CREATE; - case storage::durability::StorageGlobalOperation::UNIQUE_CONSTRAINT_DROP: - return storage::durability::WalDeltaData::Type::UNIQUE_CONSTRAINT_DROP; + case memgraph::storage::durability::StorageGlobalOperation::LABEL_INDEX_CREATE: + return memgraph::storage::durability::WalDeltaData::Type::LABEL_INDEX_CREATE; + case memgraph::storage::durability::StorageGlobalOperation::LABEL_INDEX_DROP: + return memgraph::storage::durability::WalDeltaData::Type::LABEL_INDEX_DROP; + case memgraph::storage::durability::StorageGlobalOperation::LABEL_PROPERTY_INDEX_CREATE: + return memgraph::storage::durability::WalDeltaData::Type::LABEL_PROPERTY_INDEX_CREATE; + case memgraph::storage::durability::StorageGlobalOperation::LABEL_PROPERTY_INDEX_DROP: + return memgraph::storage::durability::WalDeltaData::Type::LABEL_PROPERTY_INDEX_DROP; + case memgraph::storage::durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_CREATE: + return memgraph::storage::durability::WalDeltaData::Type::EXISTENCE_CONSTRAINT_CREATE; + case memgraph::storage::durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_DROP: + return memgraph::storage::durability::WalDeltaData::Type::EXISTENCE_CONSTRAINT_DROP; + case memgraph::storage::durability::StorageGlobalOperation::UNIQUE_CONSTRAINT_CREATE: + return memgraph::storage::durability::WalDeltaData::Type::UNIQUE_CONSTRAINT_CREATE; + case memgraph::storage::durability::StorageGlobalOperation::UNIQUE_CONSTRAINT_DROP: + return memgraph::storage::durability::WalDeltaData::Type::UNIQUE_CONSTRAINT_DROP; } } @@ -58,68 +58,72 @@ class DeltaGenerator final { explicit Transaction(DeltaGenerator *gen) : gen_(gen), - transaction_(gen->transaction_id_++, gen->timestamp_++, storage::IsolationLevel::SNAPSHOT_ISOLATION) {} + transaction_(gen->transaction_id_++, gen->timestamp_++, + memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION) {} public: - storage::Vertex *CreateVertex() { - auto gid = storage::Gid::FromUint(gen_->vertices_count_++); - auto delta = storage::CreateDeleteObjectDelta(&transaction_); + memgraph::storage::Vertex *CreateVertex() { + auto gid = memgraph::storage::Gid::FromUint(gen_->vertices_count_++); + auto delta = memgraph::storage::CreateDeleteObjectDelta(&transaction_); auto &it = gen_->vertices_.emplace_back(gid, delta); delta->prev.Set(&it); { - storage::durability::WalDeltaData data; - data.type = storage::durability::WalDeltaData::Type::VERTEX_CREATE; + memgraph::storage::durability::WalDeltaData data; + data.type = memgraph::storage::durability::WalDeltaData::Type::VERTEX_CREATE; data.vertex_create_delete.gid = gid; data_.push_back(data); } return ⁢ } - void DeleteVertex(storage::Vertex *vertex) { - storage::CreateAndLinkDelta(&transaction_, &*vertex, storage::Delta::RecreateObjectTag()); + void DeleteVertex(memgraph::storage::Vertex *vertex) { + memgraph::storage::CreateAndLinkDelta(&transaction_, &*vertex, memgraph::storage::Delta::RecreateObjectTag()); { - storage::durability::WalDeltaData data; - data.type = storage::durability::WalDeltaData::Type::VERTEX_DELETE; + memgraph::storage::durability::WalDeltaData data; + data.type = memgraph::storage::durability::WalDeltaData::Type::VERTEX_DELETE; data.vertex_create_delete.gid = vertex->gid; data_.push_back(data); } } - void AddLabel(storage::Vertex *vertex, const std::string &label) { - auto label_id = storage::LabelId::FromUint(gen_->mapper_.NameToId(label)); + void AddLabel(memgraph::storage::Vertex *vertex, const std::string &label) { + auto label_id = memgraph::storage::LabelId::FromUint(gen_->mapper_.NameToId(label)); vertex->labels.push_back(label_id); - storage::CreateAndLinkDelta(&transaction_, &*vertex, storage::Delta::RemoveLabelTag(), label_id); + memgraph::storage::CreateAndLinkDelta(&transaction_, &*vertex, memgraph::storage::Delta::RemoveLabelTag(), + label_id); { - storage::durability::WalDeltaData data; - data.type = storage::durability::WalDeltaData::Type::VERTEX_ADD_LABEL; + memgraph::storage::durability::WalDeltaData data; + data.type = memgraph::storage::durability::WalDeltaData::Type::VERTEX_ADD_LABEL; data.vertex_add_remove_label.gid = vertex->gid; data.vertex_add_remove_label.label = label; data_.push_back(data); } } - void RemoveLabel(storage::Vertex *vertex, const std::string &label) { - auto label_id = storage::LabelId::FromUint(gen_->mapper_.NameToId(label)); + void RemoveLabel(memgraph::storage::Vertex *vertex, const std::string &label) { + auto label_id = memgraph::storage::LabelId::FromUint(gen_->mapper_.NameToId(label)); vertex->labels.erase(std::find(vertex->labels.begin(), vertex->labels.end(), label_id)); - storage::CreateAndLinkDelta(&transaction_, &*vertex, storage::Delta::AddLabelTag(), label_id); + memgraph::storage::CreateAndLinkDelta(&transaction_, &*vertex, memgraph::storage::Delta::AddLabelTag(), label_id); { - storage::durability::WalDeltaData data; - data.type = storage::durability::WalDeltaData::Type::VERTEX_REMOVE_LABEL; + memgraph::storage::durability::WalDeltaData data; + data.type = memgraph::storage::durability::WalDeltaData::Type::VERTEX_REMOVE_LABEL; data.vertex_add_remove_label.gid = vertex->gid; data.vertex_add_remove_label.label = label; data_.push_back(data); } } - void SetProperty(storage::Vertex *vertex, const std::string &property, const storage::PropertyValue &value) { - auto property_id = storage::PropertyId::FromUint(gen_->mapper_.NameToId(property)); + void SetProperty(memgraph::storage::Vertex *vertex, const std::string &property, + const memgraph::storage::PropertyValue &value) { + auto property_id = memgraph::storage::PropertyId::FromUint(gen_->mapper_.NameToId(property)); auto &props = vertex->properties; auto old_value = props.GetProperty(property_id); - storage::CreateAndLinkDelta(&transaction_, &*vertex, storage::Delta::SetPropertyTag(), property_id, old_value); + memgraph::storage::CreateAndLinkDelta(&transaction_, &*vertex, memgraph::storage::Delta::SetPropertyTag(), + property_id, old_value); props.SetProperty(property_id, value); { - storage::durability::WalDeltaData data; - data.type = storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY; + memgraph::storage::durability::WalDeltaData data; + data.type = memgraph::storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY; data.vertex_edge_set_property.gid = vertex->gid; data.vertex_edge_set_property.property = property; // We don't store the property value here. That is because the storage @@ -134,12 +138,12 @@ class DeltaGenerator final { auto commit_timestamp = gen_->timestamp_++; for (const auto &delta : transaction_.deltas) { auto owner = delta.prev.Get(); - while (owner.type == storage::PreviousPtr::Type::DELTA) { + while (owner.type == memgraph::storage::PreviousPtr::Type::DELTA) { owner = owner.delta->prev.Get(); } - if (owner.type == storage::PreviousPtr::Type::VERTEX) { + if (owner.type == memgraph::storage::PreviousPtr::Type::VERTEX) { gen_->wal_file_.AppendDelta(delta, *owner.vertex, commit_timestamp); - } else if (owner.type == storage::PreviousPtr::Type::EDGE) { + } else if (owner.type == memgraph::storage::PreviousPtr::Type::EDGE) { gen_->wal_file_.AppendDelta(delta, *owner.edge, commit_timestamp); } else { LOG_FATAL("Invalid delta owner!"); @@ -150,19 +154,20 @@ class DeltaGenerator final { if (gen_->valid_) { gen_->UpdateStats(commit_timestamp, transaction_.deltas.size() + 1); for (auto &data : data_) { - if (data.type == storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY) { + if (data.type == memgraph::storage::durability::WalDeltaData::Type::VERTEX_SET_PROPERTY) { // We need to put the final property value into the SET_PROPERTY // delta. auto vertex = std::find(gen_->vertices_.begin(), gen_->vertices_.end(), data.vertex_edge_set_property.gid); ASSERT_NE(vertex, gen_->vertices_.end()); - auto property_id = - storage::PropertyId::FromUint(gen_->mapper_.NameToId(data.vertex_edge_set_property.property)); + auto property_id = memgraph::storage::PropertyId::FromUint( + gen_->mapper_.NameToId(data.vertex_edge_set_property.property)); data.vertex_edge_set_property.value = vertex->properties.GetProperty(property_id); } gen_->data_.emplace_back(commit_timestamp, data); } - storage::durability::WalDeltaData data{.type = storage::durability::WalDeltaData::Type::TRANSACTION_END}; + memgraph::storage::durability::WalDeltaData data{ + .type = memgraph::storage::durability::WalDeltaData::Type::TRANSACTION_END}; gen_->data_.emplace_back(commit_timestamp, data); } } else { @@ -172,15 +177,15 @@ class DeltaGenerator final { private: DeltaGenerator *gen_; - storage::Transaction transaction_; - std::vector data_; + memgraph::storage::Transaction transaction_; + std::vector data_; }; - using DataT = std::vector>; + using DataT = std::vector>; DeltaGenerator(const std::filesystem::path &data_directory, bool properties_on_edges, uint64_t seq_num) - : uuid_(utils::GenerateUUID()), - epoch_id_(utils::GenerateUUID()), + : uuid_(memgraph::utils::GenerateUUID()), + epoch_id_(memgraph::utils::GenerateUUID()), seq_num_(seq_num), wal_file_(data_directory, uuid_, epoch_id_, {.properties_on_edges = properties_on_edges}, &mapper_, seq_num, &file_retainer_) {} @@ -188,36 +193,36 @@ class DeltaGenerator final { Transaction CreateTransaction() { return Transaction(this); } void ResetTransactionIds() { - transaction_id_ = storage::kTransactionInitialId; - timestamp_ = storage::kTimestampInitialId; + transaction_id_ = memgraph::storage::kTransactionInitialId; + timestamp_ = memgraph::storage::kTimestampInitialId; valid_ = false; } - void AppendOperation(storage::durability::StorageGlobalOperation operation, const std::string &label, + void AppendOperation(memgraph::storage::durability::StorageGlobalOperation operation, const std::string &label, const std::set properties = {}) { - auto label_id = storage::LabelId::FromUint(mapper_.NameToId(label)); - std::set property_ids; + auto label_id = memgraph::storage::LabelId::FromUint(mapper_.NameToId(label)); + std::set property_ids; for (const auto &property : properties) { - property_ids.insert(storage::PropertyId::FromUint(mapper_.NameToId(property))); + property_ids.insert(memgraph::storage::PropertyId::FromUint(mapper_.NameToId(property))); } wal_file_.AppendOperation(operation, label_id, property_ids, timestamp_); if (valid_) { UpdateStats(timestamp_, 1); - storage::durability::WalDeltaData data; + memgraph::storage::durability::WalDeltaData data; data.type = StorageGlobalOperationToWalDeltaDataType(operation); switch (operation) { - case storage::durability::StorageGlobalOperation::LABEL_INDEX_CREATE: - case storage::durability::StorageGlobalOperation::LABEL_INDEX_DROP: + case memgraph::storage::durability::StorageGlobalOperation::LABEL_INDEX_CREATE: + case memgraph::storage::durability::StorageGlobalOperation::LABEL_INDEX_DROP: data.operation_label.label = label; break; - case storage::durability::StorageGlobalOperation::LABEL_PROPERTY_INDEX_CREATE: - case storage::durability::StorageGlobalOperation::LABEL_PROPERTY_INDEX_DROP: - case storage::durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_CREATE: - case storage::durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_DROP: + case memgraph::storage::durability::StorageGlobalOperation::LABEL_PROPERTY_INDEX_CREATE: + case memgraph::storage::durability::StorageGlobalOperation::LABEL_PROPERTY_INDEX_DROP: + case memgraph::storage::durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_CREATE: + case memgraph::storage::durability::StorageGlobalOperation::EXISTENCE_CONSTRAINT_DROP: data.operation_label_property.label = label; data.operation_label_property.property = *properties.begin(); - case storage::durability::StorageGlobalOperation::UNIQUE_CONSTRAINT_CREATE: - case storage::durability::StorageGlobalOperation::UNIQUE_CONSTRAINT_DROP: + case memgraph::storage::durability::StorageGlobalOperation::UNIQUE_CONSTRAINT_CREATE: + case memgraph::storage::durability::StorageGlobalOperation::UNIQUE_CONSTRAINT_DROP: data.operation_label_properties.label = label; data.operation_label_properties.properties = properties; } @@ -227,7 +232,7 @@ class DeltaGenerator final { uint64_t GetPosition() { return wal_file_.GetSize(); } - storage::durability::WalInfo GetInfo() { + memgraph::storage::durability::WalInfo GetInfo() { return {.offset_metadata = 0, .offset_deltas = 0, .uuid = uuid_, @@ -253,13 +258,13 @@ class DeltaGenerator final { std::string epoch_id_; uint64_t seq_num_; - uint64_t transaction_id_{storage::kTransactionInitialId}; - uint64_t timestamp_{storage::kTimestampInitialId}; + uint64_t transaction_id_{memgraph::storage::kTransactionInitialId}; + uint64_t timestamp_{memgraph::storage::kTimestampInitialId}; uint64_t vertices_count_{0}; - std::list vertices_; - storage::NameIdMapper mapper_; + std::list vertices_; + memgraph::storage::NameIdMapper mapper_; - storage::durability::WalFile wal_file_; + memgraph::storage::durability::WalFile wal_file_; DataT data_; @@ -268,7 +273,7 @@ class DeltaGenerator final { uint64_t tx_to_{0}; uint64_t valid_{true}; - utils::FileRetainer file_retainer_; + memgraph::utils::FileRetainer file_retainer_; }; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) @@ -280,9 +285,10 @@ class DeltaGenerator final { } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define OPERATION(op, ...) gen.AppendOperation(storage::durability::StorageGlobalOperation::op, __VA_ARGS__) +#define OPERATION(op, ...) gen.AppendOperation(memgraph::storage::durability::StorageGlobalOperation::op, __VA_ARGS__) -void AssertWalInfoEqual(const storage::durability::WalInfo &a, const storage::durability::WalInfo &b) { +void AssertWalInfoEqual(const memgraph::storage::durability::WalInfo &a, + const memgraph::storage::durability::WalInfo &b) { ASSERT_EQ(a.uuid, b.uuid); ASSERT_EQ(a.epoch_id, b.epoch_id); ASSERT_EQ(a.seq_num, b.seq_num); @@ -292,14 +298,14 @@ void AssertWalInfoEqual(const storage::durability::WalInfo &a, const storage::du } void AssertWalDataEqual(const DeltaGenerator::DataT &data, const std::filesystem::path &path) { - auto info = storage::durability::ReadWalInfo(path); - storage::durability::Decoder wal; - wal.Initialize(path, storage::durability::kWalMagic); + auto info = memgraph::storage::durability::ReadWalInfo(path); + memgraph::storage::durability::Decoder wal; + wal.Initialize(path, memgraph::storage::durability::kWalMagic); wal.SetPosition(info.offset_deltas); DeltaGenerator::DataT current; for (uint64_t i = 0; i < info.num_deltas; ++i) { - auto timestamp = storage::durability::ReadWalDeltaHeader(&wal); - current.emplace_back(timestamp, storage::durability::ReadWalDeltaData(&wal)); + auto timestamp = memgraph::storage::durability::ReadWalDeltaHeader(&wal); + current.emplace_back(timestamp, memgraph::storage::durability::ReadWalDeltaData(&wal)); } ASSERT_EQ(data.size(), current.size()); ASSERT_EQ(data, current); @@ -343,27 +349,28 @@ TEST_P(WalFileTest, EmptyFile) { } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define GENERATE_SIMPLE_TEST(name, ops) \ - TEST_P(WalFileTest, name) { \ - storage::durability::WalInfo info; \ - DeltaGenerator::DataT data; \ - \ - { \ - DeltaGenerator gen(storage_directory, GetParam(), 5); \ - ops; \ - info = gen.GetInfo(); \ - data = gen.GetData(); \ - } \ - \ - auto wal_files = GetFilesList(); \ - ASSERT_EQ(wal_files.size(), 1); \ - \ - if (info.num_deltas == 0) { \ - ASSERT_THROW(storage::durability::ReadWalInfo(wal_files.front()), storage::durability::RecoveryFailure); \ - } else { \ - AssertWalInfoEqual(info, storage::durability::ReadWalInfo(wal_files.front())); \ - AssertWalDataEqual(data, wal_files.front()); \ - } \ +#define GENERATE_SIMPLE_TEST(name, ops) \ + TEST_P(WalFileTest, name) { \ + memgraph::storage::durability::WalInfo info; \ + DeltaGenerator::DataT data; \ + \ + { \ + DeltaGenerator gen(storage_directory, GetParam(), 5); \ + ops; \ + info = gen.GetInfo(); \ + data = gen.GetData(); \ + } \ + \ + auto wal_files = GetFilesList(); \ + ASSERT_EQ(wal_files.size(), 1); \ + \ + if (info.num_deltas == 0) { \ + ASSERT_THROW(memgraph::storage::durability::ReadWalInfo(wal_files.front()), \ + memgraph::storage::durability::RecoveryFailure); \ + } else { \ + AssertWalInfoEqual(info, memgraph::storage::durability::ReadWalInfo(wal_files.front())); \ + AssertWalDataEqual(data, wal_files.front()); \ + } \ } // NOLINTNEXTLINE(hicpp-special-member-functions) @@ -476,10 +483,10 @@ GENERATE_SIMPLE_TEST(AllTransactionOperationsWithEnd, { auto vertex2 = tx.CreateVertex(); tx.AddLabel(vertex1, "test"); tx.AddLabel(vertex2, "hello"); - tx.SetProperty(vertex2, "hello", storage::PropertyValue("nandare")); + tx.SetProperty(vertex2, "hello", memgraph::storage::PropertyValue("nandare")); tx.RemoveLabel(vertex1, "test"); - tx.SetProperty(vertex2, "hello", storage::PropertyValue(123)); - tx.SetProperty(vertex2, "hello", storage::PropertyValue()); + tx.SetProperty(vertex2, "hello", memgraph::storage::PropertyValue(123)); + tx.SetProperty(vertex2, "hello", memgraph::storage::PropertyValue()); tx.DeleteVertex(vertex1); }); }); @@ -490,10 +497,10 @@ GENERATE_SIMPLE_TEST(AllTransactionOperationsWithoutEnd, { auto vertex2 = tx.CreateVertex(); tx.AddLabel(vertex1, "test"); tx.AddLabel(vertex2, "hello"); - tx.SetProperty(vertex2, "hello", storage::PropertyValue("nandare")); + tx.SetProperty(vertex2, "hello", memgraph::storage::PropertyValue("nandare")); tx.RemoveLabel(vertex1, "test"); - tx.SetProperty(vertex2, "hello", storage::PropertyValue(123)); - tx.SetProperty(vertex2, "hello", storage::PropertyValue()); + tx.SetProperty(vertex2, "hello", memgraph::storage::PropertyValue(123)); + tx.SetProperty(vertex2, "hello", memgraph::storage::PropertyValue()); tx.DeleteVertex(vertex1); }); }); @@ -520,7 +527,7 @@ GENERATE_SIMPLE_TEST(InvalidTransactionOrdering, { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(WalFileTest, InvalidMarker) { - storage::durability::WalInfo info; + memgraph::storage::durability::WalInfo info; { DeltaGenerator gen(storage_directory, GetParam(), 5); @@ -532,29 +539,30 @@ TEST_P(WalFileTest, InvalidMarker) { ASSERT_EQ(wal_files.size(), 1); const auto &wal_file = wal_files.front(); - auto final_info = storage::durability::ReadWalInfo(wal_file); + auto final_info = memgraph::storage::durability::ReadWalInfo(wal_file); AssertWalInfoEqual(info, final_info); size_t i = 0; - for (auto marker : storage::durability::kMarkersAll) { - if (marker == storage::durability::Marker::SECTION_DELTA) continue; + for (auto marker : memgraph::storage::durability::kMarkersAll) { + if (marker == memgraph::storage::durability::Marker::SECTION_DELTA) continue; auto current_file = storage_directory / fmt::format("temporary_{}", i); ASSERT_TRUE(std::filesystem::copy_file(wal_file, current_file)); - utils::OutputFile file; - file.Open(current_file, utils::OutputFile::Mode::OVERWRITE_EXISTING); - file.SetPosition(utils::OutputFile::Position::SET, final_info.offset_deltas); + memgraph::utils::OutputFile file; + file.Open(current_file, memgraph::utils::OutputFile::Mode::OVERWRITE_EXISTING); + file.SetPosition(memgraph::utils::OutputFile::Position::SET, final_info.offset_deltas); auto value = static_cast(marker); file.Write(&value, sizeof(value)); file.Sync(); file.Close(); - ASSERT_THROW(storage::durability::ReadWalInfo(current_file), storage::durability::RecoveryFailure); + ASSERT_THROW(memgraph::storage::durability::ReadWalInfo(current_file), + memgraph::storage::durability::RecoveryFailure); ++i; } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_P(WalFileTest, PartialData) { - std::vector> infos; + std::vector> infos; { DeltaGenerator gen(storage_directory, GetParam(), 5); @@ -572,10 +580,10 @@ TEST_P(WalFileTest, PartialData) { auto vertex2 = tx.CreateVertex(); tx.AddLabel(vertex1, "test"); tx.AddLabel(vertex2, "hello"); - tx.SetProperty(vertex2, "hello", storage::PropertyValue("nandare")); + tx.SetProperty(vertex2, "hello", memgraph::storage::PropertyValue("nandare")); tx.RemoveLabel(vertex1, "test"); - tx.SetProperty(vertex2, "hello", storage::PropertyValue(123)); - tx.SetProperty(vertex2, "hello", storage::PropertyValue()); + tx.SetProperty(vertex2, "hello", memgraph::storage::PropertyValue(123)); + tx.SetProperty(vertex2, "hello", memgraph::storage::PropertyValue()); tx.DeleteVertex(vertex1); }); infos.emplace_back(gen.GetPosition(), gen.GetInfo()); @@ -585,23 +593,24 @@ TEST_P(WalFileTest, PartialData) { ASSERT_EQ(wal_files.size(), 1); const auto &wal_file = wal_files.front(); - AssertWalInfoEqual(infos.back().second, storage::durability::ReadWalInfo(wal_file)); + AssertWalInfoEqual(infos.back().second, memgraph::storage::durability::ReadWalInfo(wal_file)); auto current_file = storage_directory / "temporary"; - utils::InputFile infile; + memgraph::utils::InputFile infile; infile.Open(wal_file); uint64_t pos = 0; for (size_t i = 0; i < infile.GetSize(); ++i) { if (i < infos.front().first) { - ASSERT_THROW(storage::durability::ReadWalInfo(current_file), storage::durability::RecoveryFailure); + ASSERT_THROW(memgraph::storage::durability::ReadWalInfo(current_file), + memgraph::storage::durability::RecoveryFailure); } else { if (i >= infos[pos + 1].first) ++pos; - AssertWalInfoEqual(infos[pos].second, storage::durability::ReadWalInfo(current_file)); + AssertWalInfoEqual(infos[pos].second, memgraph::storage::durability::ReadWalInfo(current_file)); } { - utils::OutputFile outfile; - outfile.Open(current_file, utils::OutputFile::Mode::APPEND_TO_EXISTING); + memgraph::utils::OutputFile outfile; + outfile.Open(current_file, memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING); uint8_t value; ASSERT_TRUE(infile.Read(&value, sizeof(value))); outfile.Write(&value, sizeof(value)); @@ -610,5 +619,5 @@ TEST_P(WalFileTest, PartialData) { } } ASSERT_EQ(pos, infos.size() - 2); - AssertWalInfoEqual(infos[infos.size() - 1].second, storage::durability::ReadWalInfo(current_file)); + AssertWalInfoEqual(infos[infos.size() - 1].second, memgraph::storage::durability::ReadWalInfo(current_file)); } diff --git a/tests/unit/stripped.cpp b/tests/unit/stripped.cpp index a2fbd0491..1358ca4d2 100644 --- a/tests/unit/stripped.cpp +++ b/tests/unit/stripped.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,8 +21,8 @@ #include "query/frontend/stripped.hpp" #include "query/typed_value.hpp" -using namespace query; -using namespace query::frontend; +using namespace memgraph::query; +using namespace memgraph::query::frontend; namespace { @@ -33,7 +33,9 @@ void EXPECT_PROP_TRUE(const TypedValue &a) { EXPECT_TRUE(a.type() == TypedValue: void EXPECT_PROP_EQ(const TypedValue &a, const TypedValue &b) { EXPECT_PROP_TRUE(a == b); } -void EXPECT_PROP_EQ(const storage::PropertyValue &a, const TypedValue &b) { EXPECT_PROP_EQ(TypedValue(a), b); } +void EXPECT_PROP_EQ(const memgraph::storage::PropertyValue &a, const TypedValue &b) { + EXPECT_PROP_EQ(TypedValue(a), b); +} TEST(QueryStripper, NoLiterals) { StrippedQuery stripped("CREATE (n)"); diff --git a/tests/unit/typed_value.cpp b/tests/unit/typed_value.cpp index 972d6fed3..1eba51dbb 100644 --- a/tests/unit/typed_value.cpp +++ b/tests/unit/typed_value.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,15 +23,15 @@ #include "query/typed_value.hpp" #include "storage/v2/storage.hpp" -using query::TypedValue; -using query::TypedValueException; +using memgraph::query::TypedValue; +using memgraph::query::TypedValueException; class AllTypesFixture : public testing::Test { protected: std::vector values_; - storage::Storage db; - storage::Storage::Accessor storage_dba{db.Access()}; - query::DbAccessor dba{&storage_dba}; + memgraph::storage::Storage db; + memgraph::storage::Storage::Accessor storage_dba{db.Access()}; + memgraph::query::DbAccessor dba{&storage_dba}; void SetUp() override { values_.emplace_back(TypedValue()); @@ -49,7 +49,7 @@ class AllTypesFixture : public testing::Test { auto vertex = dba.InsertVertex(); values_.emplace_back(vertex); values_.emplace_back(*dba.InsertEdge(&vertex, &vertex, dba.NameToEdgeType("et"))); - values_.emplace_back(query::Path(dba.InsertVertex())); + values_.emplace_back(memgraph::query::Path(dba.InsertVertex())); } }; @@ -306,19 +306,21 @@ TEST_F(TypedValueArithmeticTest, Sum) { // Temporal Types // Duration - EXPECT_NO_THROW(TypedValue(utils::Duration(1)) + TypedValue(utils::Duration(1))); + EXPECT_NO_THROW(TypedValue(memgraph::utils::Duration(1)) + TypedValue(memgraph::utils::Duration(1))); // Date - EXPECT_NO_THROW(TypedValue(utils::Date(1)) + TypedValue(utils::Duration(1))); - EXPECT_NO_THROW(TypedValue(utils::Duration(1)) + TypedValue(utils::Date(1))); - EXPECT_THROW(TypedValue(utils::Date(1)) + TypedValue(utils::Date(1)), TypedValueException); + EXPECT_NO_THROW(TypedValue(memgraph::utils::Date(1)) + TypedValue(memgraph::utils::Duration(1))); + EXPECT_NO_THROW(TypedValue(memgraph::utils::Duration(1)) + TypedValue(memgraph::utils::Date(1))); + EXPECT_THROW(TypedValue(memgraph::utils::Date(1)) + TypedValue(memgraph::utils::Date(1)), TypedValueException); // LocalTime - EXPECT_NO_THROW(TypedValue(utils::LocalTime(1)) + TypedValue(utils::Duration(1))); - EXPECT_NO_THROW(TypedValue(utils::Duration(1)) + TypedValue(utils::LocalTime(1))); - EXPECT_THROW(TypedValue(utils::LocalTime(1)) + TypedValue(utils::LocalTime(1)), TypedValueException); + EXPECT_NO_THROW(TypedValue(memgraph::utils::LocalTime(1)) + TypedValue(memgraph::utils::Duration(1))); + EXPECT_NO_THROW(TypedValue(memgraph::utils::Duration(1)) + TypedValue(memgraph::utils::LocalTime(1))); + EXPECT_THROW(TypedValue(memgraph::utils::LocalTime(1)) + TypedValue(memgraph::utils::LocalTime(1)), + TypedValueException); // LocalDateTime - EXPECT_NO_THROW(TypedValue(utils::LocalDateTime(1)) + TypedValue(utils::Duration(1))); - EXPECT_NO_THROW(TypedValue(utils::Duration(1)) + TypedValue(utils::LocalDateTime(1))); - EXPECT_THROW(TypedValue(utils::LocalDateTime(1)) + TypedValue(utils::LocalDateTime(1)), TypedValueException); + EXPECT_NO_THROW(TypedValue(memgraph::utils::LocalDateTime(1)) + TypedValue(memgraph::utils::Duration(1))); + EXPECT_NO_THROW(TypedValue(memgraph::utils::Duration(1)) + TypedValue(memgraph::utils::LocalDateTime(1))); + EXPECT_THROW(TypedValue(memgraph::utils::LocalDateTime(1)) + TypedValue(memgraph::utils::LocalDateTime(1)), + TypedValueException); } TEST_F(TypedValueArithmeticTest, Difference) { @@ -333,22 +335,24 @@ TEST_F(TypedValueArithmeticTest, Difference) { EXPECT_FLOAT_EQ((TypedValue(2.5) - TypedValue(2)).ValueDouble(), 0.5); // Temporal Types // Duration - EXPECT_NO_THROW(TypedValue(utils::Duration(1)) - TypedValue(utils::Duration(1))); + EXPECT_NO_THROW(TypedValue(memgraph::utils::Duration(1)) - TypedValue(memgraph::utils::Duration(1))); // Date - EXPECT_NO_THROW(TypedValue(utils::Date(1)) - TypedValue(utils::Duration(1))); - EXPECT_NO_THROW(TypedValue(utils::Date(1)) - TypedValue(utils::Date(1))); - EXPECT_THROW(TypedValue(utils::Duration(1)) - TypedValue(utils::Date(1)), TypedValueException); + EXPECT_NO_THROW(TypedValue(memgraph::utils::Date(1)) - TypedValue(memgraph::utils::Duration(1))); + EXPECT_NO_THROW(TypedValue(memgraph::utils::Date(1)) - TypedValue(memgraph::utils::Date(1))); + EXPECT_THROW(TypedValue(memgraph::utils::Duration(1)) - TypedValue(memgraph::utils::Date(1)), TypedValueException); // LocalTime - EXPECT_NO_THROW(TypedValue(utils::LocalTime(1)) - TypedValue(utils::Duration(1))); - EXPECT_NO_THROW(TypedValue(utils::LocalTime(1)) - TypedValue(utils::LocalTime(1))); - EXPECT_THROW(TypedValue(utils::Duration(1)) - TypedValue(utils::LocalTime(1)), TypedValueException); + EXPECT_NO_THROW(TypedValue(memgraph::utils::LocalTime(1)) - TypedValue(memgraph::utils::Duration(1))); + EXPECT_NO_THROW(TypedValue(memgraph::utils::LocalTime(1)) - TypedValue(memgraph::utils::LocalTime(1))); + EXPECT_THROW(TypedValue(memgraph::utils::Duration(1)) - TypedValue(memgraph::utils::LocalTime(1)), + TypedValueException); // LocalDateTime - EXPECT_NO_THROW(TypedValue(utils::LocalDateTime(1)) - TypedValue(utils::Duration(1))); - EXPECT_NO_THROW(TypedValue(utils::LocalDateTime(1)) - TypedValue(utils::LocalDateTime(1))); - EXPECT_THROW(TypedValue(utils::Duration(1)) - TypedValue(utils::LocalDateTime(1)), TypedValueException); + EXPECT_NO_THROW(TypedValue(memgraph::utils::LocalDateTime(1)) - TypedValue(memgraph::utils::Duration(1))); + EXPECT_NO_THROW(TypedValue(memgraph::utils::LocalDateTime(1)) - TypedValue(memgraph::utils::LocalDateTime(1))); + EXPECT_THROW(TypedValue(memgraph::utils::Duration(1)) - TypedValue(memgraph::utils::LocalDateTime(1)), + TypedValueException); } -TEST_F(TypedValueArithmeticTest, Negate) { EXPECT_NO_THROW(-TypedValue(utils::Duration(1))); } +TEST_F(TypedValueArithmeticTest, Negate) { EXPECT_NO_THROW(-TypedValue(memgraph::utils::Duration(1))); } TEST_F(TypedValueArithmeticTest, Divison) { ExpectArithmeticThrowsAndNull(false, [](const TypedValue &a, const TypedValue &b) { return a / b; }); @@ -441,10 +445,10 @@ TEST_F(TypedValueLogicTest, LogicalXor) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_F(AllTypesFixture, ConstructionWithMemoryResource) { - utils::MonotonicBufferResource monotonic_memory(1024); + memgraph::utils::MonotonicBufferResource monotonic_memory(1024); std::vector values_with_custom_memory; for (const auto &value : values_) { - EXPECT_EQ(value.GetMemoryResource(), utils::NewDeleteResource()); + EXPECT_EQ(value.GetMemoryResource(), memgraph::utils::NewDeleteResource()); TypedValue copy_constructed_value(value, &monotonic_memory); EXPECT_EQ(copy_constructed_value.GetMemoryResource(), &monotonic_memory); values_with_custom_memory.emplace_back(std::move(copy_constructed_value)); @@ -456,30 +460,30 @@ TEST_F(AllTypesFixture, ConstructionWithMemoryResource) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_F(AllTypesFixture, AssignmentWithMemoryResource) { std::vector values_with_default_memory; - utils::MonotonicBufferResource monotonic_memory(1024); + memgraph::utils::MonotonicBufferResource monotonic_memory(1024); for (const auto &value : values_) { - EXPECT_EQ(value.GetMemoryResource(), utils::NewDeleteResource()); + EXPECT_EQ(value.GetMemoryResource(), memgraph::utils::NewDeleteResource()); TypedValue copy_assigned_value(&monotonic_memory); copy_assigned_value = value; EXPECT_EQ(copy_assigned_value.GetMemoryResource(), &monotonic_memory); - values_with_default_memory.emplace_back(utils::NewDeleteResource()); + values_with_default_memory.emplace_back(memgraph::utils::NewDeleteResource()); auto &move_assigned_value = values_with_default_memory.back(); move_assigned_value = std::move(copy_assigned_value); - EXPECT_EQ(move_assigned_value.GetMemoryResource(), utils::NewDeleteResource()); + EXPECT_EQ(move_assigned_value.GetMemoryResource(), memgraph::utils::NewDeleteResource()); } } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST_F(AllTypesFixture, PropagationOfMemoryOnConstruction) { - utils::MonotonicBufferResource monotonic_memory(1024); - std::vector> values_with_custom_memory(&monotonic_memory); + memgraph::utils::MonotonicBufferResource monotonic_memory(1024); + std::vector> values_with_custom_memory(&monotonic_memory); for (const auto &value : values_) { - EXPECT_EQ(value.GetMemoryResource(), utils::NewDeleteResource()); + EXPECT_EQ(value.GetMemoryResource(), memgraph::utils::NewDeleteResource()); values_with_custom_memory.emplace_back(value); const auto ©_constructed_value = values_with_custom_memory.back(); EXPECT_EQ(copy_constructed_value.GetMemoryResource(), &monotonic_memory); TypedValue copy(values_with_custom_memory.back()); - EXPECT_EQ(copy.GetMemoryResource(), utils::NewDeleteResource()); + EXPECT_EQ(copy.GetMemoryResource(), memgraph::utils::NewDeleteResource()); values_with_custom_memory.emplace_back(std::move(copy)); const auto &move_constructed_value = values_with_custom_memory.back(); EXPECT_EQ(move_constructed_value.GetMemoryResource(), &monotonic_memory); @@ -491,7 +495,7 @@ TEST_F(AllTypesFixture, PropagationOfMemoryOnConstruction) { ASSERT_EQ(moved.size(), original.size()); ASSERT_EQ(copied.size(), original.size()); for (size_t i = 0; i < value.ValueList().size(); ++i) { - EXPECT_EQ(original[i].GetMemoryResource(), utils::NewDeleteResource()); + EXPECT_EQ(original[i].GetMemoryResource(), memgraph::utils::NewDeleteResource()); EXPECT_EQ(moved[i].GetMemoryResource(), &monotonic_memory); EXPECT_EQ(copied[i].GetMemoryResource(), &monotonic_memory); EXPECT_TRUE(TypedValue::BoolEqual{}(original[i], moved[i])); @@ -507,7 +511,7 @@ TEST_F(AllTypesFixture, PropagationOfMemoryOnConstruction) { EXPECT_EQ(*kv.second.GetMemoryResource(), *memory_resource); }; for (const auto &kv : original) { - expect_allocator(kv, utils::NewDeleteResource()); + expect_allocator(kv, memgraph::utils::NewDeleteResource()); auto moved_it = moved.find(kv.first); ASSERT_NE(moved_it, moved.end()); expect_allocator(*moved_it, &monotonic_memory); @@ -522,7 +526,7 @@ TEST_F(AllTypesFixture, PropagationOfMemoryOnConstruction) { const auto &original = value.ValuePath(); const auto &moved = move_constructed_value.ValuePath(); const auto &copied = copy_constructed_value.ValuePath(); - EXPECT_EQ(original.GetMemoryResource(), utils::NewDeleteResource()); + EXPECT_EQ(original.GetMemoryResource(), memgraph::utils::NewDeleteResource()); EXPECT_EQ(moved.vertices(), original.vertices()); EXPECT_EQ(moved.edges(), original.edges()); EXPECT_EQ(moved.GetMemoryResource(), &monotonic_memory); diff --git a/tests/unit/utils_algorithm.cpp b/tests/unit/utils_algorithm.cpp index 85430817b..0e5d1d10b 100644 --- a/tests/unit/utils_algorithm.cpp +++ b/tests/unit/utils_algorithm.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -22,7 +22,7 @@ using vec = std::vector; using namespace std::string_literals; -using namespace utils; +using namespace memgraph::utils; TEST(Algorithm, PrintIterable) { // Checkss both variants of the function (using iterators and collections) diff --git a/tests/unit/utils_async_timer.cpp b/tests/unit/utils_async_timer.cpp index 5b67ac540..24be40231 100644 --- a/tests/unit/utils_async_timer.cpp +++ b/tests/unit/utils_async_timer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "utils/async_timer.hpp" -using AsyncTimer = utils::AsyncTimer; +using AsyncTimer = memgraph::utils::AsyncTimer; constexpr auto kSecondsInMilis = 1000.0; constexpr auto kIntervalInSeconds = 0.3; diff --git a/tests/unit/utils_csv_parsing.cpp b/tests/unit/utils_csv_parsing.cpp index 5ece08a12..3c852b171 100644 --- a/tests/unit/utils_csv_parsing.cpp +++ b/tests/unit/utils_csv_parsing.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -70,11 +70,11 @@ class FileWriter { }; std::string CreateRow(const std::vector &columns, const std::string_view delim) { - return utils::Join(columns, delim); + return memgraph::utils::Join(columns, delim); } auto ToPmrColumns(const std::vector &columns) { - utils::pmr::vector pmr_columns(utils::NewDeleteResource()); + memgraph::utils::pmr::vector pmr_columns(memgraph::utils::NewDeleteResource()); for (const auto &col : columns) { pmr_columns.emplace_back(col); } @@ -93,15 +93,15 @@ TEST_P(CsvReaderTest, CommaDelimiter) { writer.Close(); - utils::MemoryResource *mem{utils::NewDeleteResource()}; + memgraph::utils::MemoryResource *mem{memgraph::utils::NewDeleteResource()}; bool with_header = false; bool ignore_bad = false; - utils::pmr::string delimiter{",", mem}; - utils::pmr::string quote{"\"", mem}; + memgraph::utils::pmr::string delimiter{",", mem}; + memgraph::utils::pmr::string quote{"\"", mem}; - csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; - auto reader = csv::Reader(filepath, cfg, mem); + memgraph::csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; + auto reader = memgraph::csv::Reader(filepath, cfg, mem); auto parsed_row = reader.GetNextRow(mem); ASSERT_EQ(*parsed_row, ToPmrColumns(columns)); @@ -111,10 +111,10 @@ TEST_P(CsvReaderTest, SemicolonDelimiter) { const auto filepath = csv_directory / "bla.csv"; auto writer = FileWriter(filepath, GetParam()); - utils::MemoryResource *mem(utils::NewDeleteResource()); + memgraph::utils::MemoryResource *mem(memgraph::utils::NewDeleteResource()); - const utils::pmr::string delimiter{";", mem}; - const utils::pmr::string quote{"\"", mem}; + const memgraph::utils::pmr::string delimiter{";", mem}; + const memgraph::utils::pmr::string quote{"\"", mem}; const std::vector columns{"A", "B", "C"}; writer.WriteLine(CreateRow(columns, delimiter)); @@ -123,8 +123,8 @@ TEST_P(CsvReaderTest, SemicolonDelimiter) { const bool with_header = false; const bool ignore_bad = false; - const csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; - auto reader = csv::Reader(filepath, cfg, mem); + const memgraph::csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; + auto reader = memgraph::csv::Reader(filepath, cfg, mem); auto parsed_row = reader.GetNextRow(mem); ASSERT_EQ(*parsed_row, ToPmrColumns(columns)); @@ -137,10 +137,10 @@ TEST_P(CsvReaderTest, SkipBad) { const auto filepath = csv_directory / "bla.csv"; auto writer = FileWriter(filepath, GetParam()); - utils::MemoryResource *mem(utils::NewDeleteResource()); + memgraph::utils::MemoryResource *mem(memgraph::utils::NewDeleteResource()); - const utils::pmr::string delimiter{";", mem}; - const utils::pmr::string quote{"\"", mem}; + const memgraph::utils::pmr::string delimiter{";", mem}; + const memgraph::utils::pmr::string quote{"\"", mem}; const std::vector columns_bad{"A", "B", "\"\"C"}; writer.WriteLine(CreateRow(columns_bad, delimiter)); @@ -156,8 +156,8 @@ TEST_P(CsvReaderTest, SkipBad) { // parser's output should be solely the valid row; const bool with_header = false; const bool ignore_bad = true; - const csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; - auto reader = csv::Reader(filepath, cfg, mem); + const memgraph::csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; + auto reader = memgraph::csv::Reader(filepath, cfg, mem); auto parsed_row = reader.GetNextRow(mem); ASSERT_EQ(*parsed_row, ToPmrColumns(columns_good)); @@ -168,10 +168,10 @@ TEST_P(CsvReaderTest, SkipBad) { // an exception must be thrown; const bool with_header = false; const bool ignore_bad = false; - const csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; - auto reader = csv::Reader(filepath, cfg, mem); + const memgraph::csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; + auto reader = memgraph::csv::Reader(filepath, cfg, mem); - EXPECT_THROW(reader.GetNextRow(mem), csv::CsvReadException); + EXPECT_THROW(reader.GetNextRow(mem), memgraph::csv::CsvReadException); } } @@ -181,10 +181,10 @@ TEST_P(CsvReaderTest, AllRowsValid) { const auto filepath = csv_directory / "bla.csv"; auto writer = FileWriter(filepath, GetParam()); - utils::MemoryResource *mem(utils::NewDeleteResource()); + memgraph::utils::MemoryResource *mem(memgraph::utils::NewDeleteResource()); - const utils::pmr::string delimiter{",", mem}; - const utils::pmr::string quote{"\"", mem}; + const memgraph::utils::pmr::string delimiter{",", mem}; + const memgraph::utils::pmr::string quote{"\"", mem}; std::vector columns{"A", "B", "C"}; writer.WriteLine(CreateRow(columns, delimiter)); @@ -195,8 +195,8 @@ TEST_P(CsvReaderTest, AllRowsValid) { const bool with_header = false; const bool ignore_bad = false; - const csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; - auto reader = csv::Reader(filepath, cfg); + const memgraph::csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; + auto reader = memgraph::csv::Reader(filepath, cfg); const auto pmr_columns = ToPmrColumns(columns); while (auto parsed_row = reader.GetNextRow(mem)) { @@ -210,10 +210,10 @@ TEST_P(CsvReaderTest, SkipAllRows) { const auto filepath = csv_directory / "bla.csv"; auto writer = FileWriter(filepath, GetParam()); - utils::MemoryResource *mem(utils::NewDeleteResource()); + memgraph::utils::MemoryResource *mem(memgraph::utils::NewDeleteResource()); - const utils::pmr::string delimiter{",", mem}; - const utils::pmr::string quote{"\"", mem}; + const memgraph::utils::pmr::string delimiter{",", mem}; + const memgraph::utils::pmr::string quote{"\"", mem}; const std::vector columns_bad{"A", "B", "\"\"C"}; writer.WriteLine(CreateRow(columns_bad, delimiter)); @@ -224,8 +224,8 @@ TEST_P(CsvReaderTest, SkipAllRows) { const bool with_header = false; const bool ignore_bad = true; - const csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; - auto reader = csv::Reader(filepath, cfg); + const memgraph::csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; + auto reader = memgraph::csv::Reader(filepath, cfg); auto parsed_row = reader.GetNextRow(mem); ASSERT_EQ(parsed_row, std::nullopt); @@ -235,10 +235,10 @@ TEST_P(CsvReaderTest, WithHeader) { const auto filepath = csv_directory / "bla.csv"; auto writer = FileWriter(filepath, GetParam()); - utils::MemoryResource *mem(utils::NewDeleteResource()); + memgraph::utils::MemoryResource *mem(memgraph::utils::NewDeleteResource()); - const utils::pmr::string delimiter{",", mem}; - const utils::pmr::string quote{"\"", mem}; + const memgraph::utils::pmr::string delimiter{",", mem}; + const memgraph::utils::pmr::string quote{"\"", mem}; const std::vector header{"A", "B", "C"}; const std::vector columns{"1", "2", "3"}; @@ -251,8 +251,8 @@ TEST_P(CsvReaderTest, WithHeader) { const bool with_header = true; const bool ignore_bad = false; - const csv::Reader::Config cfg(with_header, ignore_bad, delimiter, quote); - auto reader = csv::Reader(filepath, cfg); + const memgraph::csv::Reader::Config cfg(with_header, ignore_bad, delimiter, quote); + auto reader = memgraph::csv::Reader(filepath, cfg); const auto pmr_header = ToPmrColumns(header); ASSERT_EQ(reader.GetHeader(), pmr_header); @@ -270,10 +270,10 @@ TEST_P(CsvReaderTest, MultilineQuotedString) { const auto filepath = csv_directory / "bla.csv"; auto writer = FileWriter(filepath, GetParam()); - utils::MemoryResource *mem(utils::NewDeleteResource()); + memgraph::utils::MemoryResource *mem(memgraph::utils::NewDeleteResource()); - const utils::pmr::string delimiter{",", mem}; - const utils::pmr::string quote{"\"", mem}; + const memgraph::utils::pmr::string delimiter{",", mem}; + const memgraph::utils::pmr::string quote{"\"", mem}; const std::vector first_row{"A", "B", "C"}; const std::vector multiline_first{"D", "\"E", "\"\"F"}; @@ -287,8 +287,8 @@ TEST_P(CsvReaderTest, MultilineQuotedString) { const bool with_header = false; const bool ignore_bad = true; - const csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; - auto reader = csv::Reader(filepath, cfg); + const memgraph::csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; + auto reader = memgraph::csv::Reader(filepath, cfg); auto parsed_row = reader.GetNextRow(mem); ASSERT_EQ(*parsed_row, ToPmrColumns(first_row)); @@ -304,10 +304,10 @@ TEST_P(CsvReaderTest, EmptyColumns) { const auto filepath = csv_directory / "bla.csv"; auto writer = FileWriter(filepath, GetParam()); - utils::MemoryResource *mem(utils::NewDeleteResource()); + memgraph::utils::MemoryResource *mem(memgraph::utils::NewDeleteResource()); - const utils::pmr::string delimiter{",", mem}; - const utils::pmr::string quote{"\"", mem}; + const memgraph::utils::pmr::string delimiter{",", mem}; + const memgraph::utils::pmr::string quote{"\"", mem}; std::vector> expected_rows{{"", "B", "C"}, {"A", "", "C"}, {"A", "B", ""}}; @@ -319,8 +319,8 @@ TEST_P(CsvReaderTest, EmptyColumns) { const bool with_header = false; const bool ignore_bad = false; - const csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; - auto reader = csv::Reader(filepath, cfg); + const memgraph::csv::Reader::Config cfg{with_header, ignore_bad, delimiter, quote}; + auto reader = memgraph::csv::Reader(filepath, cfg); for (const auto &expected_row : expected_rows) { const auto pmr_expected_row = ToPmrColumns(expected_row); diff --git a/tests/unit/utils_exceptions.cpp b/tests/unit/utils_exceptions.cpp index 635a64a57..437e93f67 100644 --- a/tests/unit/utils_exceptions.cpp +++ b/tests/unit/utils_exceptions.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -12,19 +12,19 @@ #include #include -void i_will_throw() { throw utils::BasicException("this is not ok"); } +void i_will_throw() { throw memgraph::utils::BasicException("this is not ok"); } void bar() { i_will_throw(); } void foo() { bar(); } -void i_will_throw_stacktrace_exception() { throw utils::StacktraceException("this is not {}", "ok!"); } +void i_will_throw_stacktrace_exception() { throw memgraph::utils::StacktraceException("this is not {}", "ok!"); } void bar_stacktrace() { i_will_throw_stacktrace_exception(); } void foo_stacktrace() { bar_stacktrace(); } TEST(ExceptionsTest, ThrowBasicAndStackExceptions) { - ASSERT_THROW(foo(), utils::BasicException); - ASSERT_THROW(foo_stacktrace(), utils::StacktraceException); + ASSERT_THROW(foo(), memgraph::utils::BasicException); + ASSERT_THROW(foo_stacktrace(), memgraph::utils::StacktraceException); } diff --git a/tests/unit/utils_file.cpp b/tests/unit/utils_file.cpp index b9c7e6130..f394c45ca 100644 --- a/tests/unit/utils_file.cpp +++ b/tests/unit/utils_file.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -46,7 +46,7 @@ const std::map kPermsAll = { }; fs::perms GetPermsFromFilename(const std::string &name) { - auto split = utils::Split(name, "_"); + auto split = memgraph::utils::Split(name, "_"); return kPermsAll.at(split[split.size() - 1]); } @@ -110,7 +110,7 @@ class UtilsFileTest : public ::testing::Test { { ASSERT_TRUE(fs::exists(storage / dir)); auto dir_status = fs::symlink_status(storage / dir); - if (!utils::StartsWith(dir, "symlink")) { + if (!memgraph::utils::StartsWith(dir, "symlink")) { ASSERT_EQ(dir_status.permissions() & fs::perms::all, GetPermsFromFilename(dir)); } fs::permissions(storage / dir, fs::perms::owner_all, fs::perm_options::add); @@ -118,7 +118,7 @@ class UtilsFileTest : public ::testing::Test { for (const auto &file : kFilesAll) { ASSERT_TRUE(fs::exists(storage / dir / file)); auto file_status = fs::symlink_status(storage / dir / file); - if (!utils::StartsWith(file, "symlink")) { + if (!memgraph::utils::StartsWith(file, "symlink")) { ASSERT_EQ(file_status.permissions() & fs::perms::all, GetPermsFromFilename(file)); } } @@ -142,15 +142,15 @@ class UtilsFileTest : public ::testing::Test { }; TEST(UtilsFile, PermissionDenied) { - auto ret = utils::ReadLines("/root/.bashrc"); + auto ret = memgraph::utils::ReadLines("/root/.bashrc"); ASSERT_EQ(ret.size(), 0); } TEST_F(UtilsFileTest, ReadLines) { for (const auto &dir : kDirsAll) { for (const auto &file : kFilesAll) { - auto ret = utils::ReadLines(storage / dir / file); - if (utils::EndsWith(dir, "000") || utils::EndsWith(file, "000")) { + auto ret = memgraph::utils::ReadLines(storage / dir / file); + if (memgraph::utils::EndsWith(dir, "000") || memgraph::utils::EndsWith(file, "000")) { ASSERT_EQ(ret.size(), 0); } else { ASSERT_EQ(ret.size(), 2); @@ -162,20 +162,20 @@ TEST_F(UtilsFileTest, ReadLines) { TEST_F(UtilsFileTest, EnsureDirAndDeleteDir) { for (const auto &dir : kDirsAll) { for (const auto &file : kFilesAll) { - ASSERT_FALSE(utils::EnsureDir(storage / dir / file)); - ASSERT_FALSE(utils::DeleteDir(storage / dir / file)); + ASSERT_FALSE(memgraph::utils::EnsureDir(storage / dir / file)); + ASSERT_FALSE(memgraph::utils::DeleteDir(storage / dir / file)); } auto path = storage / dir / "test"; - auto ret = utils::EnsureDir(path); - if (utils::EndsWith(dir, "000")) { + auto ret = memgraph::utils::EnsureDir(path); + if (memgraph::utils::EndsWith(dir, "000")) { ASSERT_FALSE(ret); - ASSERT_FALSE(utils::DeleteDir(path)); + ASSERT_FALSE(memgraph::utils::DeleteDir(path)); } else { ASSERT_TRUE(ret); ASSERT_TRUE(fs::exists(path)); ASSERT_TRUE(fs::is_directory(path)); CreateFile(path / "test"); - ASSERT_TRUE(utils::DeleteDir(path)); + ASSERT_TRUE(memgraph::utils::DeleteDir(path)); } } } @@ -183,13 +183,13 @@ TEST_F(UtilsFileTest, EnsureDirAndDeleteDir) { TEST_F(UtilsFileTest, EnsureDirOrDie) { for (const auto &dir : kDirsAll) { for (const auto &file : kFilesAll) { - ASSERT_DEATH(utils::EnsureDirOrDie(storage / dir / file), ""); + ASSERT_DEATH(memgraph::utils::EnsureDirOrDie(storage / dir / file), ""); } auto path = storage / dir / "test"; - if (utils::EndsWith(dir, "000")) { - ASSERT_DEATH(utils::EnsureDirOrDie(path), ""); + if (memgraph::utils::EndsWith(dir, "000")) { + ASSERT_DEATH(memgraph::utils::EnsureDirOrDie(path), ""); } else { - utils::EnsureDirOrDie(path); + memgraph::utils::EnsureDirOrDie(path); } } } @@ -197,11 +197,11 @@ TEST_F(UtilsFileTest, EnsureDirOrDie) { TEST_F(UtilsFileTest, OutputFileExisting) { for (const auto &dir : kDirsAll) { for (const auto &file : kFilesAll) { - utils::OutputFile handle; - if (utils::EndsWith(dir, "000") || utils::EndsWith(file, "000")) { - ASSERT_DEATH(handle.Open(storage / dir / file, utils::OutputFile::Mode::APPEND_TO_EXISTING), ""); + memgraph::utils::OutputFile handle; + if (memgraph::utils::EndsWith(dir, "000") || memgraph::utils::EndsWith(file, "000")) { + ASSERT_DEATH(handle.Open(storage / dir / file, memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING), ""); } else { - handle.Open(storage / dir / file, utils::OutputFile::Mode::APPEND_TO_EXISTING); + handle.Open(storage / dir / file, memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING); ASSERT_TRUE(handle.IsOpen()); ASSERT_EQ(handle.path(), storage / dir / file); handle.Write("hello world!\n", 13); @@ -214,12 +214,12 @@ TEST_F(UtilsFileTest, OutputFileExisting) { TEST_F(UtilsFileTest, OutputFileNew) { for (const auto &dir : kDirsAll) { - utils::OutputFile handle; + memgraph::utils::OutputFile handle; auto path = storage / dir / "test"; - if (utils::EndsWith(dir, "000")) { - ASSERT_DEATH(handle.Open(path, utils::OutputFile::Mode::APPEND_TO_EXISTING), ""); + if (memgraph::utils::EndsWith(dir, "000")) { + ASSERT_DEATH(handle.Open(path, memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING), ""); } else { - handle.Open(path, utils::OutputFile::Mode::APPEND_TO_EXISTING); + handle.Open(path, memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING); ASSERT_TRUE(handle.IsOpen()); ASSERT_EQ(handle.path(), path); handle.Write("hello world!\n"); @@ -230,23 +230,26 @@ TEST_F(UtilsFileTest, OutputFileNew) { } TEST_F(UtilsFileTest, OutputFileInvalidUsage) { - utils::OutputFile handle; + memgraph::utils::OutputFile handle; ASSERT_DEATH(handle.Write("hello!"), ""); ASSERT_DEATH(handle.Sync(), ""); ASSERT_DEATH(handle.Close(), ""); - handle.Open(storage / "existing_dir_777" / "existing_file_777", utils::OutputFile::Mode::APPEND_TO_EXISTING); - ASSERT_DEATH( - handle.Open(storage / "existing_dir_770" / "existing_file_770", utils::OutputFile::Mode::APPEND_TO_EXISTING), ""); + handle.Open(storage / "existing_dir_777" / "existing_file_777", + memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING); + ASSERT_DEATH(handle.Open(storage / "existing_dir_770" / "existing_file_770", + memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING), + ""); handle.Write("hello!"); handle.Sync(); handle.Close(); } TEST_F(UtilsFileTest, OutputFileMove) { - utils::OutputFile original; - original.Open(storage / "existing_dir_777" / "existing_file_777", utils::OutputFile::Mode::APPEND_TO_EXISTING); + memgraph::utils::OutputFile original; + original.Open(storage / "existing_dir_777" / "existing_file_777", + memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING); - utils::OutputFile moved(std::move(original)); + memgraph::utils::OutputFile moved(std::move(original)); ASSERT_DEATH(original.Write("hello!"), ""); ASSERT_DEATH(original.Sync(), ""); @@ -260,21 +263,23 @@ TEST_F(UtilsFileTest, OutputFileMove) { moved.Sync(); moved.Close(); - original.Open(storage / "existing_dir_770" / "existing_file_770", utils::OutputFile::Mode::APPEND_TO_EXISTING); + original.Open(storage / "existing_dir_770" / "existing_file_770", + memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING); original.Close(); } TEST_F(UtilsFileTest, OutputFileDescriptorLeackage) { for (int i = 0; i < 100000; ++i) { - utils::OutputFile handle; - handle.Open(storage / "existing_dir_777" / "existing_file_777", utils::OutputFile::Mode::APPEND_TO_EXISTING); + memgraph::utils::OutputFile handle; + handle.Open(storage / "existing_dir_777" / "existing_file_777", + memgraph::utils::OutputFile::Mode::APPEND_TO_EXISTING); } } TEST_F(UtilsFileTest, ConcurrentReadingAndWritting) { const auto file_path = storage / "existing_dir_777" / "existing_file_777"; - utils::OutputFile handle; - handle.Open(file_path, utils::OutputFile::Mode::OVERWRITE_EXISTING); + memgraph::utils::OutputFile handle; + handle.Open(file_path, memgraph::utils::OutputFile::Mode::OVERWRITE_EXISTING); std::default_random_engine engine(586478780); std::uniform_int_distribution random_short_wait(1, 10); @@ -300,13 +305,13 @@ TEST_F(UtilsFileTest, ConcurrentReadingAndWritting) { // thread that will read all of the data. constexpr size_t number_of_reads = 550; std::vector reader_threads(reader_threads_num); - utils::Synchronized, utils::SpinLock> max_read_counts; + memgraph::utils::Synchronized, memgraph::utils::SpinLock> max_read_counts; for (size_t i = 0; i < reader_threads_num; ++i) { reader_threads.emplace_back([&] { for (size_t i = 0; i < number_of_reads; ++i) { handle.DisableFlushing(); auto [buffer, buffer_size] = handle.CurrentBuffer(); - utils::InputFile input_handle; + memgraph::utils::InputFile input_handle; input_handle.Open(file_path); std::optional previous_number; size_t total_read_count = 0; diff --git a/tests/unit/utils_file_locker.cpp b/tests/unit/utils_file_locker.cpp index 29e19da42..ed4abe7c5 100644 --- a/tests/unit/utils_file_locker.cpp +++ b/tests/unit/utils_file_locker.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -58,7 +58,7 @@ class FileLockerParameterizedTest : public FileLockerTest, TEST_P(FileLockerParameterizedTest, DeleteWhileLocking) { CreateFiles(1); - utils::FileRetainer file_retainer; + memgraph::utils::FileRetainer file_retainer; const auto save_path = std::filesystem::current_path(); std::filesystem::current_path(testing_directory); const auto file = std::filesystem::path("1"); @@ -79,7 +79,7 @@ TEST_P(FileLockerParameterizedTest, DeleteWhileLocking) { TEST_P(FileLockerParameterizedTest, DeleteWhileInLocker) { CreateFiles(1); - utils::FileRetainer file_retainer; + memgraph::utils::FileRetainer file_retainer; const auto save_path = std::filesystem::current_path(); std::filesystem::current_path(testing_directory); const auto file = std::filesystem::path("1"); @@ -101,7 +101,7 @@ TEST_P(FileLockerParameterizedTest, DeleteWhileInLocker) { } TEST_P(FileLockerParameterizedTest, DirectoryLock) { - utils::FileRetainer file_retainer; + memgraph::utils::FileRetainer file_retainer; // For this test we create the following file structure // testing_directory // 1 @@ -152,7 +152,7 @@ TEST_P(FileLockerParameterizedTest, DirectoryLock) { } TEST_P(FileLockerParameterizedTest, RemovePath) { - utils::FileRetainer file_retainer; + memgraph::utils::FileRetainer file_retainer; ASSERT_TRUE(std::filesystem::create_directory(testing_directory)); const auto save_path = std::filesystem::current_path(); std::filesystem::current_path(testing_directory); @@ -196,7 +196,7 @@ INSTANTIATE_TEST_CASE_P(FileLockerPathVariantTests, FileLockerParameterizedTest, TEST_F(FileLockerTest, MultipleLockers) { CreateFiles(3); - utils::FileRetainer file_retainer; + memgraph::utils::FileRetainer file_retainer; const auto file1 = testing_directory / "1"; const auto file2 = testing_directory / "2"; const auto common_file = testing_directory / "3"; @@ -257,7 +257,7 @@ TEST_F(FileLockerTest, MultipleLockersAndDeleters) { const auto random_file = [&]() { return testing_directory / fmt::format("{}", file_distribution(engine)); }; - utils::FileRetainer file_retainer; + memgraph::utils::FileRetainer file_retainer; constexpr size_t thread_num = 8; constexpr size_t file_access_num = 800; diff --git a/tests/unit/utils_license.cpp b/tests/unit/utils_license.cpp index 4b6890d00..82b5cbe34 100644 --- a/tests/unit/utils_license.cpp +++ b/tests/unit/utils_license.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -21,7 +21,7 @@ class LicenseTest : public ::testing::Test { settings->Initialize(settings_directory); license_checker.emplace(); - utils::license::RegisterLicenseSettings(*license_checker, *settings); + memgraph::utils::license::RegisterLicenseSettings(*license_checker, *settings); license_checker->StartBackgroundLicenseChecker(*settings); } @@ -37,20 +37,20 @@ class LicenseTest : public ::testing::Test { ASSERT_EQ(license_checker->IsValidLicenseFast(), expected_valid); } - std::optional settings; - std::optional license_checker; + std::optional settings; + std::optional license_checker; }; TEST_F(LicenseTest, EncodeDecode) { const std::array licenses = { - utils::license::License{"Organization", 1, 2}, - utils::license::License{"", -1, 0}, - utils::license::License{"Some very long name for the organization Ltd", -999, -9999}, + memgraph::utils::license::License{"Organization", 1, 2}, + memgraph::utils::license::License{"", -1, 0}, + memgraph::utils::license::License{"Some very long name for the organization Ltd", -999, -9999}, }; for (const auto &license : licenses) { - const auto result = utils::license::Encode(license); - auto maybe_license = utils::license::Decode(result); + const auto result = memgraph::utils::license::Encode(license); + auto maybe_license = memgraph::utils::license::Decode(result); ASSERT_TRUE(maybe_license); ASSERT_EQ(*maybe_license, license); } @@ -69,9 +69,10 @@ TEST_F(LicenseTest, TestingFlag) { TEST_F(LicenseTest, LicenseOrganizationName) { const std::string organization_name{"Memgraph"}; - utils::license::License license{.organization_name = organization_name, .valid_until = 0, .memory_limit = 0}; + memgraph::utils::license::License license{ + .organization_name = organization_name, .valid_until = 0, .memory_limit = 0}; - settings->SetValue("enterprise.license", utils::license::Encode(license)); + settings->SetValue("enterprise.license", memgraph::utils::license::Encode(license)); settings->SetValue("organization.name", organization_name); CheckLicenseValidity(true); @@ -90,10 +91,10 @@ TEST_F(LicenseTest, Expiration) { std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); const auto delta = std::chrono::seconds(1); const auto valid_until = now + delta; - utils::license::License license{ + memgraph::utils::license::License license{ .organization_name = organization_name, .valid_until = valid_until.count(), .memory_limit = 0}; - settings->SetValue("enterprise.license", utils::license::Encode(license)); + settings->SetValue("enterprise.license", memgraph::utils::license::Encode(license)); settings->SetValue("organization.name", organization_name); CheckLicenseValidity(true); @@ -103,8 +104,9 @@ TEST_F(LicenseTest, Expiration) { } { SCOPED_TRACE("License with valid_until = 0 is always valid"); - utils::license::License license{.organization_name = organization_name, .valid_until = 0, .memory_limit = 0}; - settings->SetValue("enterprise.license", utils::license::Encode(license)); + memgraph::utils::license::License license{ + .organization_name = organization_name, .valid_until = 0, .memory_limit = 0}; + settings->SetValue("enterprise.license", memgraph::utils::license::Encode(license)); settings->SetValue("organization.name", organization_name); CheckLicenseValidity(true); } @@ -114,8 +116,9 @@ TEST_F(LicenseTest, LicenseInfoOverride) { CheckLicenseValidity(false); const std::string organization_name{"Memgraph"}; - utils::license::License license{.organization_name = organization_name, .valid_until = 0, .memory_limit = 0}; - const std::string license_key = utils::license::Encode(license); + memgraph::utils::license::License license{ + .organization_name = organization_name, .valid_until = 0, .memory_limit = 0}; + const std::string license_key = memgraph::utils::license::Encode(license); { SCOPED_TRACE("Checker should use overrides instead of info from the settings"); diff --git a/tests/unit/utils_math.cpp b/tests/unit/utils_math.cpp index 4a1a79679..0435d1083 100644 --- a/tests/unit/utils_math.cpp +++ b/tests/unit/utils_math.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,6 +18,6 @@ TEST(UtilsMath, Log2) { for (uint64_t i = 1; i < 1000000; ++i) { - ASSERT_EQ(utils::Log2(i), static_cast(log2(i))); + ASSERT_EQ(memgraph::utils::Log2(i), static_cast(log2(i))); } } diff --git a/tests/unit/utils_memory.cpp b/tests/unit/utils_memory.cpp index 50395b7cb..a6adfc90f 100644 --- a/tests/unit/utils_memory.cpp +++ b/tests/unit/utils_memory.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "utils/memory.hpp" -class TestMemory final : public utils::MemoryResource { +class TestMemory final : public memgraph::utils::MemoryResource { public: size_t new_count_{0}; size_t delete_count_{0}; @@ -36,7 +36,7 @@ class TestMemory final : public utils::MemoryResource { // aligned to 2 * alignment. Then we can offset the ptr so that it's never // aligned to 2 * alignment. This ought to make allocator alignment issues // more obvious. - void *ptr = utils::NewDeleteResource()->Allocate(alignment + bytes + kPadSize, 2U * alignment); + void *ptr = memgraph::utils::NewDeleteResource()->Allocate(alignment + bytes + kPadSize, 2U * alignment); // Clear allocated memory to 0xFF, marking the invalid region. memset(ptr, 0xFF, alignment + bytes + pad_size); // Offset the ptr so it's not aligned to 2 * alignment, but still aligned to @@ -51,14 +51,15 @@ class TestMemory final : public utils::MemoryResource { void DoDeallocate(void *ptr, size_t bytes, size_t alignment) override { delete_count_++; // Deallocate the original ptr, before alignment adjustment. - return utils::NewDeleteResource()->Deallocate(static_cast(ptr) - alignment, alignment + bytes + kPadSize, - 2U * alignment); + return memgraph::utils::NewDeleteResource()->Deallocate(static_cast(ptr) - alignment, + alignment + bytes + kPadSize, 2U * alignment); } - bool DoIsEqual(const utils::MemoryResource &other) const noexcept override { return this == &other; } + bool DoIsEqual(const memgraph::utils::MemoryResource &other) const noexcept override { return this == &other; } }; -void *CheckAllocation(utils::MemoryResource *mem, size_t bytes, size_t alignment = alignof(std::max_align_t)) { +void *CheckAllocation(memgraph::utils::MemoryResource *mem, size_t bytes, + size_t alignment = alignof(std::max_align_t)) { void *ptr = mem->Allocate(bytes, alignment); if (alignment > alignof(std::max_align_t)) alignment = alignof(std::max_align_t); EXPECT_TRUE(ptr); @@ -74,7 +75,7 @@ void *CheckAllocation(utils::MemoryResource *mem, size_t bytes, size_t alignment TEST(MonotonicBufferResource, AllocationWithinInitialSize) { TestMemory test_mem; { - utils::MonotonicBufferResource mem(1024, &test_mem); + memgraph::utils::MonotonicBufferResource mem(1024, &test_mem); void *fst_ptr = CheckAllocation(&mem, 24, 1); void *snd_ptr = CheckAllocation(&mem, 1000, 1); EXPECT_EQ(test_mem.new_count_, 1); @@ -94,13 +95,13 @@ TEST(MonotonicBufferResource, AllocationWithinInitialSize) { TEST(MonotonicBufferResource, AllocationOverInitialSize) { TestMemory test_mem; { - utils::MonotonicBufferResource mem(1024, &test_mem); + memgraph::utils::MonotonicBufferResource mem(1024, &test_mem); CheckAllocation(&mem, 1025, 1); EXPECT_EQ(test_mem.new_count_, 1); } EXPECT_EQ(test_mem.delete_count_, 1); { - utils::MonotonicBufferResource mem(1024, &test_mem); + memgraph::utils::MonotonicBufferResource mem(1024, &test_mem); CheckAllocation(&mem, 1025); EXPECT_EQ(test_mem.new_count_, 2); } @@ -110,7 +111,7 @@ TEST(MonotonicBufferResource, AllocationOverInitialSize) { TEST(MonotonicBufferResource, AllocationOverCapacity) { TestMemory test_mem; { - utils::MonotonicBufferResource mem(1000, &test_mem); + memgraph::utils::MonotonicBufferResource mem(1000, &test_mem); CheckAllocation(&mem, 24, 1); EXPECT_EQ(test_mem.new_count_, 1); CheckAllocation(&mem, 976); @@ -131,26 +132,26 @@ TEST(MonotonicBufferResource, AllocationOverCapacity) { } TEST(MonotonicBufferResource, AllocationWithAlignmentNotPowerOf2) { - utils::MonotonicBufferResource mem(1024); + memgraph::utils::MonotonicBufferResource mem(1024); EXPECT_THROW(mem.Allocate(24, 3), std::bad_alloc); EXPECT_THROW(mem.Allocate(24, 0), std::bad_alloc); } TEST(MonotonicBufferResource, AllocationWithSize0) { - utils::MonotonicBufferResource mem(1024); + memgraph::utils::MonotonicBufferResource mem(1024); EXPECT_THROW(mem.Allocate(0), std::bad_alloc); } // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(MonotonicBufferResource, AllocationWithAlignmentGreaterThanMaxAlign) { TestMemory test_mem; - utils::MonotonicBufferResource mem(1024, &test_mem); + memgraph::utils::MonotonicBufferResource mem(1024, &test_mem); CheckAllocation(&mem, 24, 2U * alignof(std::max_align_t)); } TEST(MonotonicBufferResource, AllocationWithSizeOverflow) { size_t max_size = std::numeric_limits::max(); - utils::MonotonicBufferResource mem(1024); + memgraph::utils::MonotonicBufferResource mem(1024); // Setup so that the next allocation aligning max_size causes overflow. mem.Allocate(1, 1); EXPECT_THROW(mem.Allocate(max_size, 4), std::bad_alloc); @@ -162,7 +163,7 @@ TEST(MonotonicBufferResource, AllocationWithInitialBufferOnStack) { constexpr size_t stack_data_size = 1024; char stack_data[stack_data_size]; memset(stack_data, 0x42, stack_data_size); - utils::MonotonicBufferResource mem(&stack_data[0], stack_data_size, &test_mem); + memgraph::utils::MonotonicBufferResource mem(&stack_data[0], stack_data_size, &test_mem); { char *ptr = reinterpret_cast(CheckAllocation(&mem, 1, 1)); EXPECT_EQ(&stack_data[0], ptr); @@ -199,7 +200,7 @@ TEST(PoolResource, SingleSmallBlockAllocations) { TestMemory test_mem; const size_t max_blocks_per_chunk = 3U; const size_t max_block_size = 64U; - utils::PoolResource mem(max_blocks_per_chunk, max_block_size, &test_mem); + memgraph::utils::PoolResource mem(max_blocks_per_chunk, max_block_size, &test_mem); // Fill the first chunk. CheckAllocation(&mem, 64U, 1U); // May allocate more than once due to bookkeeping. @@ -230,7 +231,7 @@ TEST(PoolResource, MultipleSmallBlockAllocations) { TestMemory test_mem; const size_t max_blocks_per_chunk = 1U; const size_t max_block_size = 64U; - utils::PoolResource mem(max_blocks_per_chunk, max_block_size, &test_mem); + memgraph::utils::PoolResource mem(max_blocks_per_chunk, max_block_size, &test_mem); CheckAllocation(&mem, 64U); CheckAllocation(&mem, 18U, 2U); CheckAllocation(&mem, 24U, 8U); @@ -253,7 +254,7 @@ TEST(PoolResource, BigBlockAllocations) { TestMemory test_mem; const size_t max_blocks_per_chunk = 3U; const size_t max_block_size = 64U; - utils::PoolResource mem(max_blocks_per_chunk, max_block_size, &test_mem); + memgraph::utils::PoolResource mem(max_blocks_per_chunk, max_block_size, &test_mem); CheckAllocation(&mem, max_block_size + 1, 1U); // May allocate more than once per block due to bookkeeping. EXPECT_GE(test_mem.new_count_, 1U); @@ -272,7 +273,7 @@ TEST(PoolResource, BigBlockAllocations) { TEST(PoolResource, BlockSizeIsNotMultipleOfAlignment) { const size_t max_blocks_per_chunk = 3U; const size_t max_block_size = 64U; - utils::PoolResource mem(max_blocks_per_chunk, max_block_size); + memgraph::utils::PoolResource mem(max_blocks_per_chunk, max_block_size); EXPECT_THROW(mem.Allocate(64U, 24U), std::bad_alloc); EXPECT_THROW(mem.Allocate(63U), std::bad_alloc); EXPECT_THROW(mem.Allocate(max_block_size + 1, max_block_size), std::bad_alloc); @@ -282,18 +283,18 @@ TEST(PoolResource, BlockSizeIsNotMultipleOfAlignment) { TEST(PoolResource, AllocationWithOverflow) { { const size_t max_blocks_per_chunk = 2U; - utils::PoolResource mem(max_blocks_per_chunk, std::numeric_limits::max()); + memgraph::utils::PoolResource mem(max_blocks_per_chunk, std::numeric_limits::max()); EXPECT_THROW(mem.Allocate(std::numeric_limits::max(), 1U), std::bad_alloc); // Throws because initial chunk block is aligned to - // utils::Ceil2(block_size), which wraps in this case. + // memgraph::utils::Ceil2(block_size), which wraps in this case. EXPECT_THROW(mem.Allocate((std::numeric_limits::max() - 1U) / max_blocks_per_chunk, 1U), std::bad_alloc); } { - const size_t max_blocks_per_chunk = utils::impl::Pool::MaxBlocksInChunk(); - utils::PoolResource mem(max_blocks_per_chunk, std::numeric_limits::max()); + const size_t max_blocks_per_chunk = memgraph::utils::impl::Pool::MaxBlocksInChunk(); + memgraph::utils::PoolResource mem(max_blocks_per_chunk, std::numeric_limits::max()); EXPECT_THROW(mem.Allocate(std::numeric_limits::max(), 1U), std::bad_alloc); // Throws because initial chunk block is aligned to - // utils::Ceil2(block_size), which wraps in this case. + // memgraph::utils::Ceil2(block_size), which wraps in this case. EXPECT_THROW(mem.Allocate((std::numeric_limits::max() - 1U) / max_blocks_per_chunk, 1U), std::bad_alloc); } } @@ -302,7 +303,7 @@ TEST(PoolResource, BlockDeallocation) { TestMemory test_mem; const size_t max_blocks_per_chunk = 2U; const size_t max_block_size = 64U; - utils::PoolResource mem(max_blocks_per_chunk, max_block_size, &test_mem); + memgraph::utils::PoolResource mem(max_blocks_per_chunk, max_block_size, &test_mem); auto *ptr = CheckAllocation(&mem, max_block_size); test_mem.new_count_ = 0U; // Do another allocation before deallocating `ptr`, so that we are sure that @@ -321,21 +322,21 @@ TEST(PoolResource, BlockDeallocation) { EXPECT_EQ(test_mem.new_count_, 0U); } -class AllocationTrackingMemory final : public utils::MemoryResource { +class AllocationTrackingMemory final : public memgraph::utils::MemoryResource { public: std::vector allocated_sizes_; private: void *DoAllocate(size_t bytes, size_t alignment) override { allocated_sizes_.push_back(bytes); - return utils::NewDeleteResource()->Allocate(bytes, alignment); + return memgraph::utils::NewDeleteResource()->Allocate(bytes, alignment); } void DoDeallocate(void *ptr, size_t bytes, size_t alignment) override { - return utils::NewDeleteResource()->Deallocate(ptr, bytes, alignment); + return memgraph::utils::NewDeleteResource()->Deallocate(ptr, bytes, alignment); } - bool DoIsEqual(const utils::MemoryResource &other) const noexcept override { return this == &other; } + bool DoIsEqual(const memgraph::utils::MemoryResource &other) const noexcept override { return this == &other; } }; // NOLINTNEXTLINE(hicpp-special-member-functions) @@ -343,7 +344,7 @@ TEST(MonotonicBufferResource, ResetGrowthFactor) { AllocationTrackingMemory test_mem; constexpr size_t stack_data_size = 1024; char stack_data[stack_data_size]; - utils::MonotonicBufferResource mem(&stack_data[0], stack_data_size, &test_mem); + memgraph::utils::MonotonicBufferResource mem(&stack_data[0], stack_data_size, &test_mem); mem.Allocate(stack_data_size + 1); mem.Release(); mem.Allocate(stack_data_size + 1); @@ -354,36 +355,36 @@ TEST(MonotonicBufferResource, ResetGrowthFactor) { // NOLINTNEXTLINE(hicpp-special-member-functions) class ContainerWithAllocatorLast final { public: - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; ContainerWithAllocatorLast() = default; explicit ContainerWithAllocatorLast(int value) : value_(value) {} - ContainerWithAllocatorLast(int value, utils::MemoryResource *memory) : memory_(memory), value_(value) {} + ContainerWithAllocatorLast(int value, memgraph::utils::MemoryResource *memory) : memory_(memory), value_(value) {} ContainerWithAllocatorLast(const ContainerWithAllocatorLast &other) : value_(other.value_) {} - ContainerWithAllocatorLast(const ContainerWithAllocatorLast &other, utils::MemoryResource *memory) + ContainerWithAllocatorLast(const ContainerWithAllocatorLast &other, memgraph::utils::MemoryResource *memory) : memory_(memory), value_(other.value_) {} - utils::MemoryResource *memory_{nullptr}; + memgraph::utils::MemoryResource *memory_{nullptr}; int value_{0}; }; // NOLINTNEXTLINE(hicpp-special-member-functions) class ContainerWithAllocatorFirst final { public: - using allocator_type = utils::Allocator; + using allocator_type = memgraph::utils::Allocator; ContainerWithAllocatorFirst() = default; explicit ContainerWithAllocatorFirst(int value) : value_(value) {} - ContainerWithAllocatorFirst(std::allocator_arg_t, utils::MemoryResource *memory, int value) + ContainerWithAllocatorFirst(std::allocator_arg_t, memgraph::utils::MemoryResource *memory, int value) : memory_(memory), value_(value) {} ContainerWithAllocatorFirst(const ContainerWithAllocatorFirst &other) : value_(other.value_) {} - ContainerWithAllocatorFirst(std::allocator_arg_t, utils::MemoryResource *memory, + ContainerWithAllocatorFirst(std::allocator_arg_t, memgraph::utils::MemoryResource *memory, const ContainerWithAllocatorFirst &other) : memory_(memory), value_(other.value_) {} - utils::MemoryResource *memory_{nullptr}; + memgraph::utils::MemoryResource *memory_{nullptr}; int value_{0}; }; @@ -395,34 +396,34 @@ using ContainersWithAllocators = ::testing::Types> vec(utils::NewDeleteResource()); + std::vector> vec(memgraph::utils::NewDeleteResource()); vec.emplace_back(42); const auto &c = vec.front(); EXPECT_EQ(c.value_, 42); - EXPECT_EQ(c.memory_, utils::NewDeleteResource()); + EXPECT_EQ(c.memory_, memgraph::utils::NewDeleteResource()); } TYPED_TEST(AllocatorTest, PropagatesToStdPairUsesAllocator) { { std::vector, - utils::Allocator>> - vec(utils::NewDeleteResource()); + memgraph::utils::Allocator>> + vec(memgraph::utils::NewDeleteResource()); vec.emplace_back(1, 2); const auto &pair = vec.front(); EXPECT_EQ(pair.first.value_, 1); EXPECT_EQ(pair.second.value_, 2); - EXPECT_EQ(pair.first.memory_, utils::NewDeleteResource()); - EXPECT_EQ(pair.second.memory_, utils::NewDeleteResource()); + EXPECT_EQ(pair.first.memory_, memgraph::utils::NewDeleteResource()); + EXPECT_EQ(pair.second.memory_, memgraph::utils::NewDeleteResource()); } { std::vector, - utils::Allocator>> - vec(utils::NewDeleteResource()); + memgraph::utils::Allocator>> + vec(memgraph::utils::NewDeleteResource()); vec.emplace_back(1, 2); const auto &pair = vec.front(); EXPECT_EQ(pair.first.value_, 1); EXPECT_EQ(pair.second.value_, 2); - EXPECT_EQ(pair.first.memory_, utils::NewDeleteResource()); - EXPECT_EQ(pair.second.memory_, utils::NewDeleteResource()); + EXPECT_EQ(pair.first.memory_, memgraph::utils::NewDeleteResource()); + EXPECT_EQ(pair.second.memory_, memgraph::utils::NewDeleteResource()); } } diff --git a/tests/unit/utils_memory_tracker.cpp b/tests/unit/utils_memory_tracker.cpp index 09151481d..57ea80064 100644 --- a/tests/unit/utils_memory_tracker.cpp +++ b/tests/unit/utils_memory_tracker.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include TEST(MemoryTrackerTest, ExceptionEnabler) { - utils::MemoryTracker memory_tracker; + memgraph::utils::MemoryTracker memory_tracker; constexpr size_t hard_limit = 10; memory_tracker.SetHardLimit(hard_limit); @@ -31,7 +31,7 @@ TEST(MemoryTrackerTest, ExceptionEnabler) { // we use the OnScopeExit so the test doesn't deadlock when // an ASSERT fails - utils::OnScopeExit thread_notifier{[&] { + memgraph::utils::OnScopeExit thread_notifier{[&] { // tell the second thread it can finish its test can_continue = true; }}; @@ -40,9 +40,9 @@ TEST(MemoryTrackerTest, ExceptionEnabler) { }}; std::thread t2{[&] { - utils::MemoryTracker::OutOfMemoryExceptionEnabler exception_enabler; + memgraph::utils::MemoryTracker::OutOfMemoryExceptionEnabler exception_enabler; enabler_created = true; - ASSERT_THROW(memory_tracker.Alloc(hard_limit + 1), utils::OutOfMemoryException); + ASSERT_THROW(memory_tracker.Alloc(hard_limit + 1), memgraph::utils::OutOfMemoryException); // hold the enabler until the first thread finishes while (!can_continue) @@ -54,17 +54,17 @@ TEST(MemoryTrackerTest, ExceptionEnabler) { } TEST(MemoryTrackerTest, ExceptionBlocker) { - utils::MemoryTracker memory_tracker; + memgraph::utils::MemoryTracker memory_tracker; constexpr size_t hard_limit = 10; memory_tracker.SetHardLimit(hard_limit); - utils::MemoryTracker::OutOfMemoryExceptionEnabler exception_enabler; + memgraph::utils::MemoryTracker::OutOfMemoryExceptionEnabler exception_enabler; { - utils::MemoryTracker::OutOfMemoryExceptionBlocker exception_blocker; + memgraph::utils::MemoryTracker::OutOfMemoryExceptionBlocker exception_blocker; ASSERT_NO_THROW(memory_tracker.Alloc(hard_limit + 1)); ASSERT_EQ(memory_tracker.Amount(), hard_limit + 1); } - ASSERT_THROW(memory_tracker.Alloc(hard_limit + 1), utils::OutOfMemoryException); + ASSERT_THROW(memory_tracker.Alloc(hard_limit + 1), memgraph::utils::OutOfMemoryException); } diff --git a/tests/unit/utils_on_scope_exit.cpp b/tests/unit/utils_on_scope_exit.cpp index 6f958e9b0..7a1807186 100644 --- a/tests/unit/utils_on_scope_exit.cpp +++ b/tests/unit/utils_on_scope_exit.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ TEST(OnScopeExit, BasicUsage) { int variable = 1; { ASSERT_EQ(variable, 1); - utils::OnScopeExit on_exit([&variable] { variable = 2; }); + memgraph::utils::OnScopeExit on_exit([&variable] { variable = 2; }); EXPECT_EQ(variable, 1); } EXPECT_EQ(variable, 2); diff --git a/tests/unit/utils_rwlock.cpp b/tests/unit/utils_rwlock.cpp index 165f71bd6..e3752e989 100644 --- a/tests/unit/utils_rwlock.cpp +++ b/tests/unit/utils_rwlock.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -20,13 +20,13 @@ using namespace std::chrono_literals; TEST(RWLock, MultipleReaders) { - utils::RWLock rwlock(utils::RWLock::Priority::READ); + memgraph::utils::RWLock rwlock(memgraph::utils::RWLock::Priority::READ); std::vector threads; - utils::Timer timer; + memgraph::utils::Timer timer; for (int i = 0; i < 3; ++i) { threads.push_back(std::thread([&rwlock] { - std::shared_lock lock(rwlock); + std::shared_lock lock(rwlock); std::this_thread::sleep_for(100ms); })); } @@ -40,13 +40,13 @@ TEST(RWLock, MultipleReaders) { } TEST(RWLock, SingleWriter) { - utils::RWLock rwlock(utils::RWLock::Priority::READ); + memgraph::utils::RWLock rwlock(memgraph::utils::RWLock::Priority::READ); std::vector threads; - utils::Timer timer; + memgraph::utils::Timer timer; for (int i = 0; i < 3; ++i) { threads.push_back(std::thread([&rwlock] { - std::unique_lock lock(rwlock); + std::unique_lock lock(rwlock); std::this_thread::sleep_for(100ms); })); } @@ -66,19 +66,19 @@ TEST(RWLock, ReadPriority) { * - Thread 2 successfuly acquires a shared lock at T = 60ms, even though * there's a writer waiting. */ - utils::RWLock rwlock(utils::RWLock::Priority::READ); + memgraph::utils::RWLock rwlock(memgraph::utils::RWLock::Priority::READ); rwlock.lock_shared(); bool first = true; std::thread t1([&rwlock, &first] { std::this_thread::sleep_for(30ms); - std::unique_lock lock(rwlock); + std::unique_lock lock(rwlock); EXPECT_FALSE(first); }); std::thread t2([&rwlock, &first] { std::this_thread::sleep_for(60ms); - std::shared_lock lock(rwlock); + std::shared_lock lock(rwlock); EXPECT_TRUE(first); first = false; }); @@ -96,20 +96,20 @@ TEST(RWLock, WritePriority) { * - Thread 2 tries to acquire a shared lock at T = 60ms, but it is not able * to because of write priority. */ - utils::RWLock rwlock(utils::RWLock::Priority::WRITE); + memgraph::utils::RWLock rwlock(memgraph::utils::RWLock::Priority::WRITE); rwlock.lock_shared(); bool first = true; std::thread t1([&rwlock, &first] { std::this_thread::sleep_for(30ms); - std::unique_lock lock(rwlock); + std::unique_lock lock(rwlock); EXPECT_TRUE(first); first = false; }); std::thread t2([&rwlock, &first] { std::this_thread::sleep_for(60ms); - std::shared_lock lock(rwlock); + std::shared_lock lock(rwlock); EXPECT_FALSE(first); }); @@ -121,7 +121,7 @@ TEST(RWLock, WritePriority) { } TEST(RWLock, TryLock) { - utils::RWLock rwlock(utils::RWLock::Priority::WRITE); + memgraph::utils::RWLock rwlock(memgraph::utils::RWLock::Priority::WRITE); rwlock.lock(); std::thread t1([&rwlock] { EXPECT_FALSE(rwlock.try_lock()); }); diff --git a/tests/unit/utils_scheduler.cpp b/tests/unit/utils_scheduler.cpp index 497c9b7cd..707cc36b0 100644 --- a/tests/unit/utils_scheduler.cpp +++ b/tests/unit/utils_scheduler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,7 +23,7 @@ TEST(Scheduler, TestFunctionExecuting) { std::atomic x{0}; std::function func{[&x]() { ++x; }}; - utils::Scheduler scheduler; + memgraph::utils::Scheduler scheduler; scheduler.Run("Test", std::chrono::seconds(1), func); EXPECT_EQ(x, 0); diff --git a/tests/unit/utils_settings.cpp b/tests/unit/utils_settings.cpp index d6a6c8c6c..388e467ed 100644 --- a/tests/unit/utils_settings.cpp +++ b/tests/unit/utils_settings.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -27,7 +27,7 @@ class SettingsTest : public ::testing::Test { }; namespace { -void CheckSettingValue(const utils::Settings &settings, const std::string &setting_name, +void CheckSettingValue(const memgraph::utils::Settings &settings, const std::string &setting_name, const std::string &expected_value) { auto maybe_value = settings.GetValue(setting_name); ASSERT_TRUE(maybe_value) << "Failed to access registered setting"; @@ -40,14 +40,14 @@ TEST_F(SettingsTest, RegisterSetting) { const std::string default_value{"value"}; { - utils::Settings settings; + memgraph::utils::Settings settings; settings.Initialize(settings_directory); settings.RegisterSetting(setting_name, default_value, DummyCallback); CheckSettingValue(settings, setting_name, default_value); } { - utils::Settings settings; + memgraph::utils::Settings settings; settings.Initialize(settings_directory); // registering the same object shouldn't change its value settings.RegisterSetting(setting_name, fmt::format("{}-modified", default_value), DummyCallback); @@ -59,7 +59,7 @@ TEST_F(SettingsTest, RegisterSettingCallback) { const std::string setting_name{"name"}; const std::string default_value{"value"}; - utils::Settings settings; + memgraph::utils::Settings settings; settings.Initialize(settings_directory); size_t callback_counter{0}; @@ -85,7 +85,7 @@ TEST_F(SettingsTest, GetSetRegisteredSetting) { const std::string setting_value{"value"}; const std::string default_value{"default"}; - utils::Settings settings; + memgraph::utils::Settings settings; settings.Initialize(settings_directory); settings.RegisterSetting(setting_name, default_value, DummyCallback); @@ -95,14 +95,14 @@ TEST_F(SettingsTest, GetSetRegisteredSetting) { } TEST_F(SettingsTest, GetSetUnregisteredSetting) { - utils::Settings settings; + memgraph::utils::Settings settings; settings.Initialize(settings_directory); ASSERT_FALSE(settings.GetValue("Somesetting")) << "Accessed unregistered setting"; ASSERT_FALSE(settings.SetValue("Somesetting", "Somevalue")) << "Modified unregistered setting"; } TEST_F(SettingsTest, Initialization) { - utils::Settings settings; + memgraph::utils::Settings settings; settings.Initialize(settings_directory); ASSERT_NO_FATAL_FAILURE(settings.GetValue("setting")); ASSERT_NO_FATAL_FAILURE(settings.SetValue("setting", "value")); @@ -125,7 +125,7 @@ std::vector> GenerateSettings(const size_t a TEST_F(SettingsTest, AllSettings) { const auto generated_settings = GenerateSettings(100); - utils::Settings settings; + memgraph::utils::Settings settings; settings.Initialize(settings_directory); for (const auto &[setting_name, setting_value] : generated_settings) { settings.RegisterSetting(setting_name, setting_value, DummyCallback); @@ -136,7 +136,7 @@ TEST_F(SettingsTest, AllSettings) { TEST_F(SettingsTest, Persistance) { auto generated_settings = GenerateSettings(100); - utils::Settings settings; + memgraph::utils::Settings settings; settings.Initialize(settings_directory); for (const auto &[setting_name, setting_value] : generated_settings) { diff --git a/tests/unit/utils_signals.cpp b/tests/unit/utils_signals.cpp index e11db0b2d..cf53abfbd 100644 --- a/tests/unit/utils_signals.cpp +++ b/tests/unit/utils_signals.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -26,9 +26,9 @@ */ TEST(Signals, Handler) { - ASSERT_TRUE(utils::SignalHandler::RegisterHandler(utils::Signal::SegmentationFault, []() { + ASSERT_TRUE(memgraph::utils::SignalHandler::RegisterHandler(memgraph::utils::Signal::SegmentationFault, []() { std::cout << "Segmentation Fault" << std::endl; - utils::Stacktrace stacktrace; + memgraph::utils::Stacktrace stacktrace; std::cout << stacktrace.dump() << std::endl; })); @@ -36,7 +36,7 @@ TEST(Signals, Handler) { } TEST(Signals, Ignore) { - ASSERT_TRUE(utils::SignalIgnore(utils::Signal::Pipe)); + ASSERT_TRUE(memgraph::utils::SignalIgnore(memgraph::utils::Signal::Pipe)); std::raise(SIGPIPE); } @@ -45,7 +45,7 @@ TEST(Signals, Ignore) { * globally. */ TEST(SignalsMultithreaded, Ignore) { - ASSERT_TRUE(utils::SignalIgnore(utils::Signal::BusError)); + ASSERT_TRUE(memgraph::utils::SignalIgnore(memgraph::utils::Signal::BusError)); std::thread thread([] { std::raise(SIGBUS); }); thread.join(); } diff --git a/tests/unit/utils_string.cpp b/tests/unit/utils_string.cpp index b49aa562a..4cde1dfe1 100644 --- a/tests/unit/utils_string.cpp +++ b/tests/unit/utils_string.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ using vec = std::vector; -using namespace utils; +using namespace memgraph::utils; TEST(String, LTrim) { EXPECT_EQ(LTrim(" \t\n\r ab\r\n\t ab \r\t "), "ab\r\n\t ab \r\t "); diff --git a/tests/unit/utils_synchronized.cpp b/tests/unit/utils_synchronized.cpp index e5166f67a..3d472c3e7 100644 --- a/tests/unit/utils_synchronized.cpp +++ b/tests/unit/utils_synchronized.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -16,9 +16,10 @@ #include "utils/rw_lock.hpp" #include "utils/synchronized.hpp" -static_assert(utils::SharedMutex, "std::shared_mutex must be considered as shared mutex!"); -static_assert(utils::SharedMutex, "utils::RWLock must be considered as shared mutex!"); -static_assert(!utils::SharedMutex, "std::mutex must not be considered as shared mutex!"); +static_assert(memgraph::utils::SharedMutex, "std::shared_mutex must be considered as shared mutex!"); +static_assert(memgraph::utils::SharedMutex, + "memgraph::utils::RWLock must be considered as shared mutex!"); +static_assert(!memgraph::utils::SharedMutex, "std::mutex must not be considered as shared mutex!"); class NoMoveNoCopy { public: @@ -33,23 +34,23 @@ class NoMoveNoCopy { TEST(Synchronized, Constructors) { { - utils::Synchronized> vec; + memgraph::utils::Synchronized> vec; EXPECT_TRUE(vec->empty()); } { std::vector data = {1, 2, 3}; - utils::Synchronized> vec(data); + memgraph::utils::Synchronized> vec(data); EXPECT_EQ(data.size(), 3); EXPECT_EQ(vec->size(), 3); } { std::vector data = {1, 2, 3}; - utils::Synchronized> vec(std::move(data)); + memgraph::utils::Synchronized> vec(std::move(data)); // data is guaranteed by the standard to be empty after move EXPECT_TRUE(data.empty()); EXPECT_EQ(vec->size(), 3); } - { utils::Synchronized object(3, 4); } + { memgraph::utils::Synchronized object(3, 4); } } bool test_lock_locked = false; @@ -183,19 +184,19 @@ void CheckReadLock(TSynchronizedVector &my_vector, const size_t expected_size) { } TEST(Synchronized, Usage) { - utils::Synchronized, TestLock> my_vector; + memgraph::utils::Synchronized, TestLock> my_vector; CheckWriteLock(my_vector); } TEST(Synchronized, SharedUsage) { - utils::Synchronized, TestSharedLock> my_vector; + memgraph::utils::Synchronized, TestSharedLock> my_vector; CheckWriteLock(my_vector); { SCOPED_TRACE("Non const reference"); ASSERT_NO_FATAL_FAILURE(CheckReadLock(my_vector, 2)); } { - const utils::Synchronized, TestSharedLock> &my_const_vector = my_vector; + const memgraph::utils::Synchronized, TestSharedLock> &my_const_vector = my_vector; SCOPED_TRACE("Const reference"); ASSERT_NO_FATAL_FAILURE(CheckReadLock(my_const_vector, 2)); } diff --git a/tests/unit/utils_temporal.cpp b/tests/unit/utils_temporal.cpp index 8b12f08b2..11b94238f 100644 --- a/tests/unit/utils_temporal.cpp +++ b/tests/unit/utils_temporal.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -23,17 +23,17 @@ namespace { -std::string ToString(const utils::DateParameters &date_parameters) { +std::string ToString(const memgraph::utils::DateParameters &date_parameters) { return fmt::format("{:04d}-{:02d}-{:02d}", date_parameters.year, date_parameters.month, date_parameters.day); } -std::string ToString(const utils::LocalTimeParameters &local_time_parameters) { +std::string ToString(const memgraph::utils::LocalTimeParameters &local_time_parameters) { return fmt::format("{:02}:{:02d}:{:02d}", local_time_parameters.hour, local_time_parameters.minute, local_time_parameters.second); } struct TestDateParameters { - utils::DateParameters date_parameters; + memgraph::utils::DateParameters date_parameters; bool should_throw; }; @@ -44,7 +44,7 @@ constexpr std::array test_dates{TestDateParameters{{-1996, 11, 22}, true}, TestD TestDateParameters{{1200, 2, 29}, false}, TestDateParameters{{10000, 12, 3}, true}}; struct TestLocalTimeParameters { - utils::LocalTimeParameters local_time_parameters; + memgraph::utils::LocalTimeParameters local_time_parameters; bool should_throw; }; @@ -63,11 +63,11 @@ constexpr std::array test_local_times{TestLocalTimeParameters{{.hour = 24}, true } // namespace TEST(TemporalTest, DateConstruction) { - std::optional test_date; + std::optional test_date; for (const auto [date_parameters, should_throw] : test_dates) { if (should_throw) { - EXPECT_THROW(test_date.emplace(date_parameters), utils::BasicException) << ToString(date_parameters); + EXPECT_THROW(test_date.emplace(date_parameters), memgraph::utils::BasicException) << ToString(date_parameters); } else { EXPECT_NO_THROW(test_date.emplace(date_parameters)) << ToString(date_parameters); } @@ -76,39 +76,39 @@ TEST(TemporalTest, DateConstruction) { TEST(TemporalTest, DateMicrosecondsSinceEpochConversion) { const auto check_microseconds = [](const auto date_parameters) { - utils::Date initial_date{date_parameters}; + memgraph::utils::Date initial_date{date_parameters}; const auto microseconds = initial_date.MicrosecondsSinceEpoch(); - utils::Date new_date{microseconds}; + memgraph::utils::Date new_date{microseconds}; ASSERT_EQ(initial_date, new_date); }; - check_microseconds(utils::DateParameters{2020, 11, 22}); - check_microseconds(utils::DateParameters{1900, 2, 22}); - check_microseconds(utils::DateParameters{0, 1, 1}); - check_microseconds(utils::DateParameters{1994, 12, 7}); + check_microseconds(memgraph::utils::DateParameters{2020, 11, 22}); + check_microseconds(memgraph::utils::DateParameters{1900, 2, 22}); + check_microseconds(memgraph::utils::DateParameters{0, 1, 1}); + check_microseconds(memgraph::utils::DateParameters{1994, 12, 7}); - ASSERT_THROW(check_microseconds(utils::DateParameters{-10, 1, 1}), utils::BasicException); + ASSERT_THROW(check_microseconds(memgraph::utils::DateParameters{-10, 1, 1}), memgraph::utils::BasicException); { - utils::Date date{utils::DateParameters{1970, 1, 1}}; + memgraph::utils::Date date{memgraph::utils::DateParameters{1970, 1, 1}}; ASSERT_EQ(date.MicrosecondsSinceEpoch(), 0); } { - utils::Date date{utils::DateParameters{1910, 1, 1}}; + memgraph::utils::Date date{memgraph::utils::DateParameters{1910, 1, 1}}; ASSERT_LT(date.MicrosecondsSinceEpoch(), 0); } { - utils::Date date{utils::DateParameters{2021, 1, 1}}; + memgraph::utils::Date date{memgraph::utils::DateParameters{2021, 1, 1}}; ASSERT_GT(date.MicrosecondsSinceEpoch(), 0); } } TEST(TemporalTest, LocalTimeConstruction) { - std::optional test_local_time; + std::optional test_local_time; for (const auto [local_time_parameters, should_throw] : test_local_times) { if (should_throw) { - ASSERT_THROW(test_local_time.emplace(local_time_parameters), utils::BasicException); + ASSERT_THROW(test_local_time.emplace(local_time_parameters), memgraph::utils::BasicException); } else { ASSERT_NO_THROW(test_local_time.emplace(local_time_parameters)); } @@ -116,69 +116,74 @@ TEST(TemporalTest, LocalTimeConstruction) { } TEST(TemporalTest, LocalTimeMicrosecondsSinceEpochConversion) { - const auto check_microseconds = [](const utils::LocalTimeParameters ¶meters) { - utils::LocalTime initial_local_time{parameters}; + const auto check_microseconds = [](const memgraph::utils::LocalTimeParameters ¶meters) { + memgraph::utils::LocalTime initial_local_time{parameters}; const auto microseconds = initial_local_time.MicrosecondsSinceEpoch(); - utils::LocalTime new_local_time{microseconds}; + memgraph::utils::LocalTime new_local_time{microseconds}; ASSERT_EQ(initial_local_time, new_local_time); }; - check_microseconds(utils::LocalTimeParameters{23, 59, 59, 999, 999}); - check_microseconds(utils::LocalTimeParameters{0, 0, 0, 0, 0}); - check_microseconds(utils::LocalTimeParameters{14, 8, 55, 321, 452}); + check_microseconds(memgraph::utils::LocalTimeParameters{23, 59, 59, 999, 999}); + check_microseconds(memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 0}); + check_microseconds(memgraph::utils::LocalTimeParameters{14, 8, 55, 321, 452}); } TEST(TemporalTest, LocalDateTimeMicrosecondsSinceEpochConversion) { - const auto check_microseconds = [](const utils::DateParameters date_parameters, - const utils::LocalTimeParameters &local_time_parameters) { - utils::LocalDateTime initial_local_date_time{date_parameters, local_time_parameters}; + const auto check_microseconds = [](const memgraph::utils::DateParameters date_parameters, + const memgraph::utils::LocalTimeParameters &local_time_parameters) { + memgraph::utils::LocalDateTime initial_local_date_time{date_parameters, local_time_parameters}; const auto microseconds = initial_local_date_time.MicrosecondsSinceEpoch(); - utils::LocalDateTime new_local_date_time{microseconds}; + memgraph::utils::LocalDateTime new_local_date_time{microseconds}; ASSERT_EQ(initial_local_date_time, new_local_date_time); }; - check_microseconds(utils::DateParameters{2020, 11, 22}, utils::LocalTimeParameters{0, 0, 0, 0, 0}); - check_microseconds(utils::DateParameters{1900, 2, 22}, utils::LocalTimeParameters{0, 0, 0, 0, 0}); - check_microseconds(utils::DateParameters{0, 1, 1}, utils::LocalTimeParameters{0, 0, 0, 0, 0}); + check_microseconds(memgraph::utils::DateParameters{2020, 11, 22}, + memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 0}); + check_microseconds(memgraph::utils::DateParameters{1900, 2, 22}, memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 0}); + check_microseconds(memgraph::utils::DateParameters{0, 1, 1}, memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 0}); - check_microseconds(utils::DateParameters{1961, 1, 1}, utils::LocalTimeParameters{15, 44, 12}); - check_microseconds(utils::DateParameters{1969, 12, 31}, utils::LocalTimeParameters{23, 59, 59}); + check_microseconds(memgraph::utils::DateParameters{1961, 1, 1}, memgraph::utils::LocalTimeParameters{15, 44, 12}); + check_microseconds(memgraph::utils::DateParameters{1969, 12, 31}, memgraph::utils::LocalTimeParameters{23, 59, 59}); { - utils::LocalDateTime local_date_time(utils::DateParameters{1970, 1, 1}, utils::LocalTimeParameters{0, 0, 0, 0, 0}); + memgraph::utils::LocalDateTime local_date_time(memgraph::utils::DateParameters{1970, 1, 1}, + memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 0}); ASSERT_EQ(local_date_time.MicrosecondsSinceEpoch(), 0); } { - utils::LocalDateTime local_date_time(utils::DateParameters{1970, 1, 1}, utils::LocalTimeParameters{0, 0, 0, 0, 1}); + memgraph::utils::LocalDateTime local_date_time(memgraph::utils::DateParameters{1970, 1, 1}, + memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 1}); ASSERT_GT(local_date_time.MicrosecondsSinceEpoch(), 0); } { - utils::LocalTimeParameters local_time_parameters{12, 10, 40, 42, 42}; - utils::LocalDateTime local_date_time{utils::DateParameters{1970, 1, 1}, local_time_parameters}; + memgraph::utils::LocalTimeParameters local_time_parameters{12, 10, 40, 42, 42}; + memgraph::utils::LocalDateTime local_date_time{memgraph::utils::DateParameters{1970, 1, 1}, local_time_parameters}; ASSERT_EQ(local_date_time.MicrosecondsSinceEpoch(), - utils::LocalTime{local_time_parameters}.MicrosecondsSinceEpoch()); + memgraph::utils::LocalTime{local_time_parameters}.MicrosecondsSinceEpoch()); } { - utils::LocalDateTime local_date_time(utils::DateParameters{1910, 1, 1}, utils::LocalTimeParameters{0, 0, 0, 0, 0}); + memgraph::utils::LocalDateTime local_date_time(memgraph::utils::DateParameters{1910, 1, 1}, + memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 0}); ASSERT_LT(local_date_time.MicrosecondsSinceEpoch(), 0); } { - utils::LocalDateTime local_date_time(utils::DateParameters{2021, 1, 1}, utils::LocalTimeParameters{0, 0, 0, 0, 0}); + memgraph::utils::LocalDateTime local_date_time(memgraph::utils::DateParameters{2021, 1, 1}, + memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 0}); ASSERT_GT(local_date_time.MicrosecondsSinceEpoch(), 0); } { // Assert ordering for dates prior the unix epoch. // If this test fails, our storage indexes will be incorrect. - utils::LocalDateTime ldt({1969, 12, 31}, {0, 0, 0}); - utils::LocalDateTime ldt2({1969, 12, 31}, {23, 59, 59}); + memgraph::utils::LocalDateTime ldt({1969, 12, 31}, {0, 0, 0}); + memgraph::utils::LocalDateTime ldt2({1969, 12, 31}, {23, 59, 59}); ASSERT_LT(ldt.MicrosecondsSinceEpoch(), ldt2.MicrosecondsSinceEpoch()); } } TEST(TemporalTest, DurationConversion) { { - utils::Duration duration{{.minute = 123.25}}; + memgraph::utils::Duration duration{{.minute = 123.25}}; const auto microseconds = duration.microseconds; - utils::LocalDateTime local_date_time{microseconds}; + memgraph::utils::LocalDateTime local_date_time{microseconds}; ASSERT_EQ(local_date_time.date.year, 1970); ASSERT_EQ(local_date_time.date.month, 1); ASSERT_EQ(local_date_time.date.day, 1); @@ -191,62 +196,65 @@ TEST(TemporalTest, DurationConversion) { namespace { using namespace std::literals; constexpr std::array parsing_test_dates_extended{ - std::make_pair("2020-11-22"sv, utils::DateParameters{2020, 11, 22}), - std::make_pair("2020-11"sv, utils::DateParameters{2020, 11}), + std::make_pair("2020-11-22"sv, memgraph::utils::DateParameters{2020, 11, 22}), + std::make_pair("2020-11"sv, memgraph::utils::DateParameters{2020, 11}), }; -constexpr std::array parsing_test_dates_basic{std::make_pair("20201122"sv, utils::DateParameters{2020, 11, 22})}; +constexpr std::array parsing_test_dates_basic{ + std::make_pair("20201122"sv, memgraph::utils::DateParameters{2020, 11, 22})}; constexpr std::array parsing_test_local_time_extended{ - std::make_pair("19:23:21.123456"sv, utils::LocalTimeParameters{19, 23, 21, 123, 456}), - std::make_pair("19:23:21.123"sv, utils::LocalTimeParameters{19, 23, 21, 123}), - std::make_pair("19:23:21"sv, utils::LocalTimeParameters{19, 23, 21}), - std::make_pair("19:23"sv, utils::LocalTimeParameters{19, 23}), - std::make_pair("00:00:00.000000"sv, utils::LocalTimeParameters{0, 0, 0, 0, 0}), - std::make_pair("01:02:03.004005"sv, utils::LocalTimeParameters{1, 2, 3, 4, 5}), + std::make_pair("19:23:21.123456"sv, memgraph::utils::LocalTimeParameters{19, 23, 21, 123, 456}), + std::make_pair("19:23:21.123"sv, memgraph::utils::LocalTimeParameters{19, 23, 21, 123}), + std::make_pair("19:23:21"sv, memgraph::utils::LocalTimeParameters{19, 23, 21}), + std::make_pair("19:23"sv, memgraph::utils::LocalTimeParameters{19, 23}), + std::make_pair("00:00:00.000000"sv, memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 0}), + std::make_pair("01:02:03.004005"sv, memgraph::utils::LocalTimeParameters{1, 2, 3, 4, 5}), }; constexpr std::array parsing_test_local_time_basic{ - std::make_pair("192321.123456"sv, utils::LocalTimeParameters{19, 23, 21, 123, 456}), - std::make_pair("192321.123"sv, utils::LocalTimeParameters{19, 23, 21, 123}), - std::make_pair("192321"sv, utils::LocalTimeParameters{19, 23, 21}), - std::make_pair("1923"sv, utils::LocalTimeParameters{19, 23}), - std::make_pair("19"sv, utils::LocalTimeParameters{19}), - std::make_pair("000000.000000"sv, utils::LocalTimeParameters{0, 0, 0, 0, 0}), - std::make_pair("010203.004005"sv, utils::LocalTimeParameters{1, 2, 3, 4, 5}), + std::make_pair("192321.123456"sv, memgraph::utils::LocalTimeParameters{19, 23, 21, 123, 456}), + std::make_pair("192321.123"sv, memgraph::utils::LocalTimeParameters{19, 23, 21, 123}), + std::make_pair("192321"sv, memgraph::utils::LocalTimeParameters{19, 23, 21}), + std::make_pair("1923"sv, memgraph::utils::LocalTimeParameters{19, 23}), + std::make_pair("19"sv, memgraph::utils::LocalTimeParameters{19}), + std::make_pair("000000.000000"sv, memgraph::utils::LocalTimeParameters{0, 0, 0, 0, 0}), + std::make_pair("010203.004005"sv, memgraph::utils::LocalTimeParameters{1, 2, 3, 4, 5}), }; } // namespace TEST(TemporalTest, DateParsing) { for (const auto &[string, date_parameters] : parsing_test_dates_extended) { - ASSERT_EQ(utils::ParseDateParameters(string).first, date_parameters); + ASSERT_EQ(memgraph::utils::ParseDateParameters(string).first, date_parameters); } for (const auto &[string, date_parameters] : parsing_test_dates_basic) { - ASSERT_EQ(utils::ParseDateParameters(string).first, date_parameters); + ASSERT_EQ(memgraph::utils::ParseDateParameters(string).first, date_parameters); } - ASSERT_THROW(utils::ParseDateParameters("202-011-22"), utils::BasicException); - ASSERT_THROW(utils::ParseDateParameters("2020-1-022"), utils::BasicException); - ASSERT_THROW(utils::ParseDateParameters("2020-11-2-"), utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDateParameters("202-011-22"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDateParameters("2020-1-022"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDateParameters("2020-11-2-"), memgraph::utils::BasicException); } TEST(TemporalTest, LocalTimeParsing) { for (const auto &[string, local_time_parameters] : parsing_test_local_time_extended) { - ASSERT_EQ(utils::ParseLocalTimeParameters(string).first, local_time_parameters) << ToString(local_time_parameters); + ASSERT_EQ(memgraph::utils::ParseLocalTimeParameters(string).first, local_time_parameters) + << ToString(local_time_parameters); const auto time_string = fmt::format("T{}", string); - ASSERT_EQ(utils::ParseLocalTimeParameters(time_string).first, local_time_parameters) + ASSERT_EQ(memgraph::utils::ParseLocalTimeParameters(time_string).first, local_time_parameters) << ToString(local_time_parameters); } for (const auto &[string, local_time_parameters] : parsing_test_local_time_basic) { - ASSERT_EQ(utils::ParseLocalTimeParameters(string).first, local_time_parameters) << ToString(local_time_parameters); - ASSERT_EQ(utils::ParseLocalTimeParameters(fmt::format("T{}", string)).first, local_time_parameters) + ASSERT_EQ(memgraph::utils::ParseLocalTimeParameters(string).first, local_time_parameters) + << ToString(local_time_parameters); + ASSERT_EQ(memgraph::utils::ParseLocalTimeParameters(fmt::format("T{}", string)).first, local_time_parameters) << ToString(local_time_parameters); } - ASSERT_THROW(utils::ParseLocalTimeParameters("19:20:21s"), utils::BasicException); - ASSERT_THROW(utils::ParseLocalTimeParameters("1920:21"), utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseLocalTimeParameters("19:20:21s"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseLocalTimeParameters("1920:21"), memgraph::utils::BasicException); } TEST(TemporalTest, LocalDateTimeParsing) { @@ -255,7 +263,7 @@ TEST(TemporalTest, LocalDateTimeParsing) { for (const auto &[local_time_string, local_time_parameters] : local_times) { const auto local_date_time_string = fmt::format("{}T{}", date_string, local_time_string); if (is_valid) { - EXPECT_EQ(utils::ParseLocalDateTimeParameters(local_date_time_string), + EXPECT_EQ(memgraph::utils::ParseLocalDateTimeParameters(local_date_time_string), (std::pair{date_parameters, local_time_parameters})); } } @@ -278,57 +286,67 @@ void CheckDurationParameters(const auto &values, const auto &expected) { } TEST(TemporalTest, DurationParsing) { - ASSERT_THROW(utils::ParseDurationParameters("P12Y"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("P12Y32DT2M"), utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("P12Y"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("P12Y32DT2M"), memgraph::utils::BasicException); - CheckDurationParameters(utils::ParseDurationParameters("PT26H"), utils::DurationParameters{.hour = 26}); - CheckDurationParameters(utils::ParseDurationParameters("PT2M"), utils::DurationParameters{.minute = 2.0}); - CheckDurationParameters(utils::ParseDurationParameters("PT22S"), utils::DurationParameters{.second = 22}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("PT26H"), + memgraph::utils::DurationParameters{.hour = 26}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("PT2M"), + memgraph::utils::DurationParameters{.minute = 2.0}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("PT22S"), + memgraph::utils::DurationParameters{.second = 22}); - CheckDurationParameters(utils::ParseDurationParameters("PT.33S"), utils::DurationParameters{.second = 0.33}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("PT.33S"), + memgraph::utils::DurationParameters{.second = 0.33}); - CheckDurationParameters(utils::ParseDurationParameters("PT2M3S"), - utils::DurationParameters{.minute = 2.0, .second = 3.0}); - CheckDurationParameters(utils::ParseDurationParameters("PT2.5H"), utils::DurationParameters{.hour = 2.5}); - CheckDurationParameters(utils::ParseDurationParameters("P2DT2.5H"), - utils::DurationParameters{.day = 2.0, .hour = 2.5}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("PT2M3S"), + memgraph::utils::DurationParameters{.minute = 2.0, .second = 3.0}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("PT2.5H"), + memgraph::utils::DurationParameters{.hour = 2.5}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P2DT2.5H"), + memgraph::utils::DurationParameters{.day = 2.0, .hour = 2.5}); - ASSERT_THROW(utils::ParseDurationParameters("P2M3S"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("PTM3S"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("P2M3Y"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("PT2Y3M"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("12Y32DT2M"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("PY"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters(""), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("PT2M3SX"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("PT2M3S32"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("PT2.5M3S"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("PT2.5M3.5S"), utils::BasicException); - ASSERT_THROW(utils::ParseDurationParameters("PT2.5M3.-5S"), utils::BasicException); - CheckDurationParameters(utils::ParseDurationParameters("P1256.5D"), utils::DurationParameters{1256.5}); - CheckDurationParameters(utils::ParseDurationParameters("P1222DT2H"), utils::DurationParameters{1222, 2}); - CheckDurationParameters(utils::ParseDurationParameters("P1222DT2H44M"), utils::DurationParameters{1222, 2, 44}); - CheckDurationParameters(utils::ParseDurationParameters("P22DT1H9M20S"), utils::DurationParameters{22, 1, 9, 20}); - CheckDurationParameters(utils::ParseDurationParameters("P22DT1H9M20.100S"), utils::DurationParameters{ - 22, - 1, - 9, - 20.1, - }); - CheckDurationParameters(utils::ParseDurationParameters("P-22222222DT1H9M20.100S"), - utils::DurationParameters{-22222222, 1, 9, 20.1}); - CheckDurationParameters(utils::ParseDurationParameters("P-22222222DT-10H8M21.200S"), - utils::DurationParameters{-22222222, -10, 8, 21.2}); - CheckDurationParameters(utils::ParseDurationParameters("P-22222222DT-1H-7M22.300S"), - utils::DurationParameters{-22222222, -1, -7, 22.3}); - CheckDurationParameters(utils::ParseDurationParameters("P-22222222DT-1H-6M-20.100S"), - utils::DurationParameters{-22222222, -1, -6, -20.1}); - CheckDurationParameters(utils::ParseDurationParameters("P-22222222DT-1H-5M-20.100S"), - utils::DurationParameters{-22222222, -1, -5, -20.1}); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("P2M3S"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("PTM3S"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("P2M3Y"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("PT2Y3M"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("12Y32DT2M"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("PY"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters(""), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("PT2M3SX"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("PT2M3S32"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("PT2.5M3S"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("PT2.5M3.5S"), memgraph::utils::BasicException); + ASSERT_THROW(memgraph::utils::ParseDurationParameters("PT2.5M3.-5S"), memgraph::utils::BasicException); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P1256.5D"), + memgraph::utils::DurationParameters{1256.5}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P1222DT2H"), + memgraph::utils::DurationParameters{1222, 2}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P1222DT2H44M"), + memgraph::utils::DurationParameters{1222, 2, 44}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P22DT1H9M20S"), + memgraph::utils::DurationParameters{22, 1, 9, 20}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P22DT1H9M20.100S"), + memgraph::utils::DurationParameters{ + 22, + 1, + 9, + 20.1, + }); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P-22222222DT1H9M20.100S"), + memgraph::utils::DurationParameters{-22222222, 1, 9, 20.1}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P-22222222DT-10H8M21.200S"), + memgraph::utils::DurationParameters{-22222222, -10, 8, 21.2}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P-22222222DT-1H-7M22.300S"), + memgraph::utils::DurationParameters{-22222222, -1, -7, 22.3}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P-22222222DT-1H-6M-20.100S"), + memgraph::utils::DurationParameters{-22222222, -1, -6, -20.1}); + CheckDurationParameters(memgraph::utils::ParseDurationParameters("P-22222222DT-1H-5M-20.100S"), + memgraph::utils::DurationParameters{-22222222, -1, -5, -20.1}); } TEST(TemporalTest, PrintDate) { - const auto unix_epoch = utils::Date(utils::DateParameters{1970, 1, 1}); + const auto unix_epoch = memgraph::utils::Date(memgraph::utils::DateParameters{1970, 1, 1}); std::ostringstream stream; stream << unix_epoch; ASSERT_TRUE(stream); @@ -336,7 +354,7 @@ TEST(TemporalTest, PrintDate) { } TEST(TemporalTest, PrintLocalTime) { - const auto lt = utils::LocalTime({13, 2, 40, 100, 50}); + const auto lt = memgraph::utils::LocalTime({13, 2, 40, 100, 50}); std::ostringstream stream; stream << lt; ASSERT_TRUE(stream); @@ -344,29 +362,29 @@ TEST(TemporalTest, PrintLocalTime) { } TEST(TemporalTest, PrintDuration) { - const auto dur = utils::Duration({1, 0, 0, 0, 0, 0}); + const auto dur = memgraph::utils::Duration({1, 0, 0, 0, 0, 0}); std::ostringstream stream; stream << dur; ASSERT_TRUE(stream); ASSERT_EQ(stream.view(), "P1DT0H0M0.000000S"); stream.str(""); stream.clear(); - const auto complex_dur = utils::Duration({10, 3, 30, 33, 100, 50}); + const auto complex_dur = memgraph::utils::Duration({10, 3, 30, 33, 100, 50}); stream << complex_dur; ASSERT_TRUE(stream); ASSERT_EQ(stream.view(), "P10DT3H30M33.100050S"); stream.str(""); stream.clear(); - const auto negative_dur = utils::Duration({-10, -3, -30, -33, -100, -50}); + const auto negative_dur = memgraph::utils::Duration({-10, -3, -30, -33, -100, -50}); stream << negative_dur; ASSERT_TRUE(stream); ASSERT_EQ(stream.view(), "P-10DT-3H-30M-33.100050S"); } TEST(TemporalTest, PrintLocalDateTime) { - const auto unix_epoch = utils::Date(utils::DateParameters{1970, 1, 1}); - const auto lt = utils::LocalTime({13, 2, 40, 100, 50}); - utils::LocalDateTime ldt(unix_epoch, lt); + const auto unix_epoch = memgraph::utils::Date(memgraph::utils::DateParameters{1970, 1, 1}); + const auto lt = memgraph::utils::LocalTime({13, 2, 40, 100, 50}); + memgraph::utils::LocalDateTime ldt(unix_epoch, lt); std::ostringstream stream; stream << ldt; ASSERT_TRUE(stream); @@ -375,14 +393,14 @@ TEST(TemporalTest, PrintLocalDateTime) { TEST(TemporalTest, DurationAddition) { // a >= 0 && b >= 0 - const auto zero = utils::Duration(0); - const auto one = utils::Duration(1); + const auto zero = memgraph::utils::Duration(0); + const auto one = memgraph::utils::Duration(1); const auto two = one + one; const auto four = two + two; ASSERT_EQ(two.microseconds, 2); ASSERT_EQ(four.microseconds, 4); - const auto max = utils::Duration(std::numeric_limits::max()); - ASSERT_THROW(max + one, utils::BasicException); + const auto max = memgraph::utils::Duration(std::numeric_limits::max()); + ASSERT_THROW(max + one, memgraph::utils::BasicException); ASSERT_EQ(zero + zero, zero); ASSERT_EQ(max + zero, max); @@ -392,8 +410,8 @@ TEST(TemporalTest, DurationAddition) { const auto neg_four = neg_two + neg_two; ASSERT_EQ(neg_two.microseconds, -2); ASSERT_EQ(neg_four.microseconds, -4); - const auto min = utils::Duration(std::numeric_limits::min()); - ASSERT_THROW(min + neg_one, utils::BasicException); + const auto min = memgraph::utils::Duration(std::numeric_limits::min()); + ASSERT_THROW(min + neg_one, memgraph::utils::BasicException); ASSERT_EQ(min + zero, min); // a < 0, b > 0 && a > 0 , b < 0 @@ -405,13 +423,13 @@ TEST(TemporalTest, DurationAddition) { // a {min, max} && b {min, max} ASSERT_EQ(min + max, neg_one); ASSERT_EQ(max + min, neg_one); - ASSERT_THROW(min + min, utils::BasicException); - ASSERT_THROW(max + max, utils::BasicException); + ASSERT_THROW(min + min, memgraph::utils::BasicException); + ASSERT_THROW(max + max, memgraph::utils::BasicException); } TEST(TemporalTest, DurationSubtraction) { // a >= 0 && b >= 0 - const auto one = utils::Duration(1); + const auto one = memgraph::utils::Duration(1); const auto two = one + one; const auto zero = one - one; ASSERT_EQ(zero.microseconds, 0); @@ -419,161 +437,174 @@ TEST(TemporalTest, DurationSubtraction) { const auto neg_two = zero - two; ASSERT_EQ(neg_one.microseconds, -1); ASSERT_EQ(neg_two.microseconds, -2); - const auto max = utils::Duration(std::numeric_limits::max()); - const auto min_minus_one = utils::Duration(std::numeric_limits::min() + 1); + const auto max = memgraph::utils::Duration(std::numeric_limits::max()); + const auto min_minus_one = memgraph::utils::Duration(std::numeric_limits::min() + 1); ASSERT_EQ(max - zero, max); ASSERT_EQ(zero - max, min_minus_one); // a < 0 && b < 0 ASSERT_EQ(neg_two - neg_two, zero); - const auto min = utils::Duration(std::numeric_limits::min()); - ASSERT_THROW(min - one, utils::BasicException); + const auto min = memgraph::utils::Duration(std::numeric_limits::min()); + ASSERT_THROW(min - one, memgraph::utils::BasicException); ASSERT_EQ(min - zero, min); // a < 0, b > 0 && a > 0 , b < 0 ASSERT_EQ(neg_one - one, neg_two); ASSERT_EQ(one - neg_one, two); - const auto neg_three = utils::Duration(-3); + const auto neg_three = memgraph::utils::Duration(-3); const auto three = -neg_three; ASSERT_EQ(neg_two - one, neg_three); ASSERT_EQ(one - neg_two, three); // a {min, max} && b {min, max} - ASSERT_THROW(min - max, utils::BasicException); - ASSERT_THROW(max - min, utils::BasicException); + ASSERT_THROW(min - max, memgraph::utils::BasicException); + ASSERT_THROW(max - min, memgraph::utils::BasicException); // There is no positive representation of min - ASSERT_THROW(min - min, utils::BasicException); + ASSERT_THROW(min - min, memgraph::utils::BasicException); ASSERT_EQ(max - max, zero); } TEST(TemporalTest, LocalTimeAndDurationAddition) { - const auto half_past_one = utils::LocalTime({1, 30, 10}); - const auto three = half_past_one + utils::Duration({10, 1, 30, 2, 22, 45}); - const auto three_symmetrical = utils::Duration({10, 1, 30, 2, 22, 45}) + half_past_one; - ASSERT_EQ(three, utils::LocalTime({3, 0, 12, 22, 45})); - ASSERT_EQ(three_symmetrical, utils::LocalTime({3, 0, 12, 22, 45})); + const auto half_past_one = memgraph::utils::LocalTime({1, 30, 10}); + const auto three = half_past_one + memgraph::utils::Duration({10, 1, 30, 2, 22, 45}); + const auto three_symmetrical = memgraph::utils::Duration({10, 1, 30, 2, 22, 45}) + half_past_one; + ASSERT_EQ(three, memgraph::utils::LocalTime({3, 0, 12, 22, 45})); + ASSERT_EQ(three_symmetrical, memgraph::utils::LocalTime({3, 0, 12, 22, 45})); - const auto half_an_hour_before_midnight = utils::LocalTime({23, 30, 10}); + const auto half_an_hour_before_midnight = memgraph::utils::LocalTime({23, 30, 10}); { - const auto half_past_midnight = half_an_hour_before_midnight + utils::Duration({1, 1, 0, 0}); - ASSERT_EQ(half_past_midnight, utils::LocalTime({.minute = 30, .second = 10})); + const auto half_past_midnight = half_an_hour_before_midnight + memgraph::utils::Duration({1, 1, 0, 0}); + ASSERT_EQ(half_past_midnight, memgraph::utils::LocalTime({.minute = 30, .second = 10})); } - const auto identity = half_an_hour_before_midnight + utils::Duration({.day = 1}); + const auto identity = half_an_hour_before_midnight + memgraph::utils::Duration({.day = 1}); ASSERT_EQ(identity, half_an_hour_before_midnight); - ASSERT_EQ(identity, half_an_hour_before_midnight + utils::Duration({.day = 1, .hour = 24})); - const auto an_hour_and_a_half_before_midnight = utils::LocalTime({22, 30, 10}); - ASSERT_EQ(half_an_hour_before_midnight + utils::Duration({.hour = 23}), an_hour_and_a_half_before_midnight); + ASSERT_EQ(identity, half_an_hour_before_midnight + memgraph::utils::Duration({.day = 1, .hour = 24})); + const auto an_hour_and_a_half_before_midnight = memgraph::utils::LocalTime({22, 30, 10}); + ASSERT_EQ(half_an_hour_before_midnight + memgraph::utils::Duration({.hour = 23}), an_hour_and_a_half_before_midnight); - const auto minus_one_hour = utils::Duration({-10, -1, 0, 0, -20, -20}); - const auto minus_one_hour_exact = utils::Duration({.day = -10, .hour = -1}); + const auto minus_one_hour = memgraph::utils::Duration({-10, -1, 0, 0, -20, -20}); + const auto minus_one_hour_exact = memgraph::utils::Duration({.day = -10, .hour = -1}); { const auto half_past_midnight = half_past_one + minus_one_hour; - ASSERT_EQ(half_past_midnight, utils::LocalTime({0, 30, 9, 979, 980})); - ASSERT_EQ(half_past_midnight + minus_one_hour_exact, utils::LocalTime({23, 30, 9, 979, 980})); + ASSERT_EQ(half_past_midnight, memgraph::utils::LocalTime({0, 30, 9, 979, 980})); + ASSERT_EQ(half_past_midnight + minus_one_hour_exact, memgraph::utils::LocalTime({23, 30, 9, 979, 980})); - const auto minus_two_hours_thirty_mins = utils::Duration({-10, -2, -30, -9}); - ASSERT_EQ(half_past_midnight + minus_two_hours_thirty_mins, utils::LocalTime({22, 0, 0, 979, 980})); + const auto minus_two_hours_thirty_mins = memgraph::utils::Duration({-10, -2, -30, -9}); + ASSERT_EQ(half_past_midnight + minus_two_hours_thirty_mins, memgraph::utils::LocalTime({22, 0, 0, 979, 980})); - ASSERT_NO_THROW(half_past_midnight + (utils::Duration(std::numeric_limits::max()))); - ASSERT_EQ(half_past_midnight + (utils::Duration(std::numeric_limits::max())), - utils::LocalTime({4, 31, 4, 755, 787})); - ASSERT_NO_THROW(half_past_midnight + (utils::Duration(std::numeric_limits::min()))); - ASSERT_EQ(half_past_midnight + (utils::Duration(std::numeric_limits::min())), - utils::LocalTime({20, 29, 15, 204, 172})); + ASSERT_NO_THROW(half_past_midnight + (memgraph::utils::Duration(std::numeric_limits::max()))); + ASSERT_EQ(half_past_midnight + (memgraph::utils::Duration(std::numeric_limits::max())), + memgraph::utils::LocalTime({4, 31, 4, 755, 787})); + ASSERT_NO_THROW(half_past_midnight + (memgraph::utils::Duration(std::numeric_limits::min()))); + ASSERT_EQ(half_past_midnight + (memgraph::utils::Duration(std::numeric_limits::min())), + memgraph::utils::LocalTime({20, 29, 15, 204, 172})); } } TEST(TemporalTest, LocalTimeAndDurationSubtraction) { - const auto half_past_one = utils::LocalTime({1, 30, 10}); - const auto midnight = half_past_one - utils::Duration({10, 1, 30, 10}); - ASSERT_EQ(midnight, utils::LocalTime()); - ASSERT_EQ(midnight - utils::Duration({-10, -1, -30, -10}), utils::LocalTime({1, 30, 10})); + const auto half_past_one = memgraph::utils::LocalTime({1, 30, 10}); + const auto midnight = half_past_one - memgraph::utils::Duration({10, 1, 30, 10}); + ASSERT_EQ(midnight, memgraph::utils::LocalTime()); + ASSERT_EQ(midnight - memgraph::utils::Duration({-10, -1, -30, -10}), memgraph::utils::LocalTime({1, 30, 10})); - const auto almost_an_hour_and_a_half_before_midnight = midnight - utils::Duration({10, 1, 30, 1, 20, 20}); - ASSERT_EQ(almost_an_hour_and_a_half_before_midnight, utils::LocalTime({22, 29, 58, 979, 980})); + const auto almost_an_hour_and_a_half_before_midnight = midnight - memgraph::utils::Duration({10, 1, 30, 1, 20, 20}); + ASSERT_EQ(almost_an_hour_and_a_half_before_midnight, memgraph::utils::LocalTime({22, 29, 58, 979, 980})); - ASSERT_NO_THROW(midnight - (utils::Duration(std::numeric_limits::max()))); - ASSERT_EQ(midnight - (utils::Duration(std::numeric_limits::max())), utils::LocalTime({19, 59, 5, 224, 193})); - ASSERT_THROW(midnight - utils::Duration(std::numeric_limits::min()), utils::BasicException); + ASSERT_NO_THROW(midnight - (memgraph::utils::Duration(std::numeric_limits::max()))); + ASSERT_EQ(midnight - (memgraph::utils::Duration(std::numeric_limits::max())), + memgraph::utils::LocalTime({19, 59, 5, 224, 193})); + ASSERT_THROW(midnight - memgraph::utils::Duration(std::numeric_limits::min()), + memgraph::utils::BasicException); } TEST(TemporalTest, LocalTimeDeltaDuration) { - const auto half_past_one = utils::LocalTime({1, 30, 10}); - const auto half_past_two = utils::LocalTime({2, 30, 10}); + const auto half_past_one = memgraph::utils::LocalTime({1, 30, 10}); + const auto half_past_two = memgraph::utils::LocalTime({2, 30, 10}); const auto an_hour_negative = half_past_one - half_past_two; - ASSERT_EQ(an_hour_negative, utils::Duration({.hour = -1})); + ASSERT_EQ(an_hour_negative, memgraph::utils::Duration({.hour = -1})); const auto an_hour = half_past_two - half_past_one; - ASSERT_EQ(an_hour, utils::Duration({.hour = 1})); + ASSERT_EQ(an_hour, memgraph::utils::Duration({.hour = 1})); } TEST(TemporalTest, DateAddition) { - const auto unix_epoch = utils::Date({1970, 1, 1}); - const auto one_day_after_unix_epoch = unix_epoch + utils::Duration({.day = 1}); - const auto one_day_after_unix_epoch_symmetrical = utils::Duration({.day = 1}) + unix_epoch; - ASSERT_EQ(one_day_after_unix_epoch, utils::Date({1970, 1, 2})); + const auto unix_epoch = memgraph::utils::Date({1970, 1, 1}); + const auto one_day_after_unix_epoch = unix_epoch + memgraph::utils::Duration({.day = 1}); + const auto one_day_after_unix_epoch_symmetrical = memgraph::utils::Duration({.day = 1}) + unix_epoch; + ASSERT_EQ(one_day_after_unix_epoch, memgraph::utils::Date({1970, 1, 2})); ASSERT_EQ(one_day_after_unix_epoch_symmetrical, one_day_after_unix_epoch); - const auto one_month_after_unix_epoch = unix_epoch + utils::Duration({.day = 31}); - ASSERT_EQ(one_month_after_unix_epoch, utils::Date({1970, 2, 1})); + const auto one_month_after_unix_epoch = unix_epoch + memgraph::utils::Duration({.day = 31}); + ASSERT_EQ(one_month_after_unix_epoch, memgraph::utils::Date({1970, 2, 1})); - const auto one_year_after_unix_epoch = unix_epoch + utils::Duration({.day = 365}); - ASSERT_EQ(one_year_after_unix_epoch, utils::Date({1971, 1, 1})); + const auto one_year_after_unix_epoch = unix_epoch + memgraph::utils::Duration({.day = 365}); + ASSERT_EQ(one_year_after_unix_epoch, memgraph::utils::Date({1971, 1, 1})); - const auto last_day_of_unix_epoch = one_year_after_unix_epoch + utils::Duration({.day = -1}); - ASSERT_EQ(last_day_of_unix_epoch, utils::Date({1970, 12, 31})); + const auto last_day_of_unix_epoch = one_year_after_unix_epoch + memgraph::utils::Duration({.day = -1}); + ASSERT_EQ(last_day_of_unix_epoch, memgraph::utils::Date({1970, 12, 31})); - const auto one_day_before_unix_epoch = unix_epoch + utils::Duration({.day = -1}); - ASSERT_EQ(one_day_before_unix_epoch, utils::Date({1969, 12, 31})); + const auto one_day_before_unix_epoch = unix_epoch + memgraph::utils::Duration({.day = -1}); + ASSERT_EQ(one_day_before_unix_epoch, memgraph::utils::Date({1969, 12, 31})); - ASSERT_EQ(last_day_of_unix_epoch + utils::Duration({.day = -31}), utils::Date({1970, 11, 30})); - ASSERT_THROW(unix_epoch + utils::Duration(std::numeric_limits::max()), utils::BasicException); - ASSERT_THROW(unix_epoch + utils::Duration(std::numeric_limits::min()), utils::BasicException); + ASSERT_EQ(last_day_of_unix_epoch + memgraph::utils::Duration({.day = -31}), memgraph::utils::Date({1970, 11, 30})); + ASSERT_THROW(unix_epoch + memgraph::utils::Duration(std::numeric_limits::max()), + memgraph::utils::BasicException); + ASSERT_THROW(unix_epoch + memgraph::utils::Duration(std::numeric_limits::min()), + memgraph::utils::BasicException); } TEST(TemporalTest, DateSubstraction) { - const auto day_after_unix_epoch = utils::Date({1970, 1, 2}); - const auto unix_epoch = day_after_unix_epoch - utils::Duration({.day = 1}); - ASSERT_EQ(unix_epoch, utils::Date({1970, 1, 1})); - ASSERT_EQ(utils::Date({1971, 1, 1}) - utils::Duration({.day = 1}), utils::Date({1970, 12, 31})); - ASSERT_EQ(utils::Date({1971, 1, 1}) - utils::Duration({.day = -1}), utils::Date({1971, 1, 2})); - ASSERT_THROW(unix_epoch - utils::Duration(std::numeric_limits::max()), utils::BasicException); - ASSERT_THROW(unix_epoch - utils::Duration(std::numeric_limits::min()), utils::BasicException); + const auto day_after_unix_epoch = memgraph::utils::Date({1970, 1, 2}); + const auto unix_epoch = day_after_unix_epoch - memgraph::utils::Duration({.day = 1}); + ASSERT_EQ(unix_epoch, memgraph::utils::Date({1970, 1, 1})); + ASSERT_EQ(memgraph::utils::Date({1971, 1, 1}) - memgraph::utils::Duration({.day = 1}), + memgraph::utils::Date({1970, 12, 31})); + ASSERT_EQ(memgraph::utils::Date({1971, 1, 1}) - memgraph::utils::Duration({.day = -1}), + memgraph::utils::Date({1971, 1, 2})); + ASSERT_THROW(unix_epoch - memgraph::utils::Duration(std::numeric_limits::max()), + memgraph::utils::BasicException); + ASSERT_THROW(unix_epoch - memgraph::utils::Duration(std::numeric_limits::min()), + memgraph::utils::BasicException); } TEST(TemporalTest, DateDelta) { - const auto unix_epoch = utils::Date({1970, 1, 1}); - const auto one_year_after_unix_epoch = utils::Date({1971, 1, 1}); - ASSERT_EQ(one_year_after_unix_epoch - unix_epoch, utils::Duration({.day = 365})); - ASSERT_EQ(unix_epoch - one_year_after_unix_epoch, utils::Duration({.day = -365})); + const auto unix_epoch = memgraph::utils::Date({1970, 1, 1}); + const auto one_year_after_unix_epoch = memgraph::utils::Date({1971, 1, 1}); + ASSERT_EQ(one_year_after_unix_epoch - unix_epoch, memgraph::utils::Duration({.day = 365})); + ASSERT_EQ(unix_epoch - one_year_after_unix_epoch, memgraph::utils::Duration({.day = -365})); } TEST(TemporalTest, LocalDateTimeAdditionSubtraction) { - const auto unix_epoch = utils::LocalDateTime({1970, 1, 1}, {.hour = 12}); - auto one_day_after_unix_epoch = unix_epoch + utils::Duration({.hour = 24}); - auto one_day_after_unix_epoch_symmetrical = utils::Duration({.hour = 24}) + unix_epoch; - ASSERT_EQ(one_day_after_unix_epoch, utils::LocalDateTime({1970, 1, 2}, {.hour = 12})); + const auto unix_epoch = memgraph::utils::LocalDateTime({1970, 1, 1}, {.hour = 12}); + auto one_day_after_unix_epoch = unix_epoch + memgraph::utils::Duration({.hour = 24}); + auto one_day_after_unix_epoch_symmetrical = memgraph::utils::Duration({.hour = 24}) + unix_epoch; + ASSERT_EQ(one_day_after_unix_epoch, memgraph::utils::LocalDateTime({1970, 1, 2}, {.hour = 12})); ASSERT_EQ(one_day_after_unix_epoch_symmetrical, one_day_after_unix_epoch); - const auto one_day_before_unix_epoch = utils::LocalDateTime({1969, 12, 31}, {23, 59, 59}); - ASSERT_EQ(one_day_before_unix_epoch + utils::Duration({.second = 1}), utils::LocalDateTime({1970, 1, 1}, {})); + const auto one_day_before_unix_epoch = memgraph::utils::LocalDateTime({1969, 12, 31}, {23, 59, 59}); + ASSERT_EQ(one_day_before_unix_epoch + memgraph::utils::Duration({.second = 1}), + memgraph::utils::LocalDateTime({1970, 1, 1}, {})); - one_day_after_unix_epoch = unix_epoch + utils::Duration({.day = 1}); - ASSERT_EQ(one_day_after_unix_epoch, utils::LocalDateTime({1970, 1, 2}, {.hour = 12})); + one_day_after_unix_epoch = unix_epoch + memgraph::utils::Duration({.day = 1}); + ASSERT_EQ(one_day_after_unix_epoch, memgraph::utils::LocalDateTime({1970, 1, 2}, {.hour = 12})); - ASSERT_EQ(one_day_after_unix_epoch + utils::Duration({.day = -1}), unix_epoch); - ASSERT_EQ(one_day_after_unix_epoch - utils::Duration({.day = 1}), unix_epoch); - ASSERT_THROW(one_day_after_unix_epoch + utils::Duration(std::numeric_limits::max()), utils::BasicException); - ASSERT_THROW(one_day_after_unix_epoch + utils::Duration(std::numeric_limits::min()), utils::BasicException); - ASSERT_THROW(one_day_after_unix_epoch - utils::Duration(std::numeric_limits::max()), utils::BasicException); - ASSERT_THROW(one_day_after_unix_epoch - utils::Duration(std::numeric_limits::min()), utils::BasicException); + ASSERT_EQ(one_day_after_unix_epoch + memgraph::utils::Duration({.day = -1}), unix_epoch); + ASSERT_EQ(one_day_after_unix_epoch - memgraph::utils::Duration({.day = 1}), unix_epoch); + ASSERT_THROW(one_day_after_unix_epoch + memgraph::utils::Duration(std::numeric_limits::max()), + memgraph::utils::BasicException); + ASSERT_THROW(one_day_after_unix_epoch + memgraph::utils::Duration(std::numeric_limits::min()), + memgraph::utils::BasicException); + ASSERT_THROW(one_day_after_unix_epoch - memgraph::utils::Duration(std::numeric_limits::max()), + memgraph::utils::BasicException); + ASSERT_THROW(one_day_after_unix_epoch - memgraph::utils::Duration(std::numeric_limits::min()), + memgraph::utils::BasicException); } TEST(TemporalTest, LocalDateTimeDelta) { - const auto unix_epoch = utils::LocalDateTime({1970, 1, 1}, {1, 1, 1}); - const auto one_year_after_unix_epoch = utils::LocalDateTime({1971, 2, 1}, {12, 1, 1}); - const auto two_years_after_unix_epoch = utils::LocalDateTime({1972, 2, 1}, {1, 1, 1, 20, 34}); - ASSERT_EQ(one_year_after_unix_epoch - unix_epoch, utils::Duration({.day = 396, .hour = 11})); - ASSERT_EQ(unix_epoch - one_year_after_unix_epoch, utils::Duration({.day = -396, .hour = -11})); + const auto unix_epoch = memgraph::utils::LocalDateTime({1970, 1, 1}, {1, 1, 1}); + const auto one_year_after_unix_epoch = memgraph::utils::LocalDateTime({1971, 2, 1}, {12, 1, 1}); + const auto two_years_after_unix_epoch = memgraph::utils::LocalDateTime({1972, 2, 1}, {1, 1, 1, 20, 34}); + ASSERT_EQ(one_year_after_unix_epoch - unix_epoch, memgraph::utils::Duration({.day = 396, .hour = 11})); + ASSERT_EQ(unix_epoch - one_year_after_unix_epoch, memgraph::utils::Duration({.day = -396, .hour = -11})); ASSERT_EQ(two_years_after_unix_epoch - unix_epoch, - utils::Duration({.day = 761, .millisecond = 20, .microsecond = 34})); + memgraph::utils::Duration({.day = 761, .millisecond = 20, .microsecond = 34})); } diff --git a/tests/unit/utils_thread_pool.cpp b/tests/unit/utils_thread_pool.cpp index 79862f764..8a092533d 100644 --- a/tests/unit/utils_thread_pool.cpp +++ b/tests/unit/utils_thread_pool.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,7 +24,7 @@ TEST(ThreadPool, Basic) { constexpr std::array pool_sizes{1, 2, 4, 8, 100}; for (const auto pool_size : pool_sizes) { - utils::ThreadPool pool{pool_size}; + memgraph::utils::ThreadPool pool{pool_size}; std::atomic count{0}; for (size_t i = 0; i < adder_count; ++i) { diff --git a/tests/unit/utils_timestamp.cpp b/tests/unit/utils_timestamp.cpp index 174a737ac..4e5b2cfc9 100644 --- a/tests/unit/utils_timestamp.cpp +++ b/tests/unit/utils_timestamp.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,20 +17,20 @@ #include TEST(TimestampTest, BasicUsage) { - auto timestamp = utils::Timestamp::Now(); + auto timestamp = memgraph::utils::Timestamp::Now(); std::cout << timestamp << std::endl; - std::cout << utils::Timestamp::Now() << std::endl; + std::cout << memgraph::utils::Timestamp::Now() << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(250)); - std::cout << utils::Timestamp::Now().ToIso8601() << std::endl; + std::cout << memgraph::utils::Timestamp::Now().ToIso8601() << std::endl; - ASSERT_GT(utils::Timestamp::Now(), timestamp); + ASSERT_GT(memgraph::utils::Timestamp::Now(), timestamp); std::cout << std::boolalpha; - std::cout << (timestamp == utils::Timestamp::Now()) << std::endl; + std::cout << (timestamp == memgraph::utils::Timestamp::Now()) << std::endl; - ASSERT_NE(timestamp, utils::Timestamp::Now()); + ASSERT_NE(timestamp, memgraph::utils::Timestamp::Now()); } diff --git a/tests/unit/websocket.cpp b/tests/unit/websocket.cpp index 12a627758..90d8d3d29 100644 --- a/tests/unit/websocket.cpp +++ b/tests/unit/websocket.cpp @@ -37,14 +37,14 @@ using tcp = boost::asio::ip::tcp; constexpr auto kResponseSuccess{"success"}; constexpr auto kResponseMessage{"message"}; -struct MockAuth : public communication::websocket::AuthenticationInterface { +struct MockAuth : public memgraph::communication::websocket::AuthenticationInterface { MockAuth() = default; bool Authenticate(const std::string & /*username*/, const std::string & /*password*/) const override { return authentication; } - bool HasUserPermission(const std::string & /*username*/, auth::Permission /*permission*/) const override { + bool HasUserPermission(const std::string & /*username*/, memgraph::auth::Permission /*permission*/) const override { return authorization; } @@ -72,8 +72,8 @@ class WebSocketServerTest : public ::testing::Test { std::string ServerAddress() const { return websocket_server.GetEndpoint().address().to_string(); } MockAuth auth; - communication::ServerContext context{}; - communication::websocket::Server websocket_server; + memgraph::communication::ServerContext context{}; + memgraph::communication::websocket::Server websocket_server; }; class Client { @@ -117,8 +117,8 @@ TEST(WebSocketServer, WebsocketWorkflow) { * assigns them automatically. */ MockAuth auth{}; - communication::ServerContext context{}; - communication::websocket::Server websocket_server({"0.0.0.0", 0}, &context, auth); + memgraph::communication::ServerContext context{}; + memgraph::communication::websocket::Server websocket_server({"0.0.0.0", 0}, &context, auth); const auto port = websocket_server.GetEndpoint().port(); SCOPED_TRACE(fmt::format("Checking port number different then 0: {}", port)); diff --git a/tools/gdb-plugins/operator_tree.py b/tools/gdb-plugins/operator_tree.py index c5adf9d67..0f72b4b65 100644 --- a/tools/gdb-plugins/operator_tree.py +++ b/tools/gdb-plugins/operator_tree.py @@ -7,7 +7,7 @@ def _logical_operator_type(): '''Returns the LogicalOperator gdb.Type''' # This is a function, because the type may appear during gdb runtime. # Therefore, we cannot assign it on import. - return gdb.lookup_type('query::plan::LogicalOperator') + return gdb.lookup_type('memgraph::query::plan::LogicalOperator') def _iter_fields_and_base_classes(value): @@ -98,7 +98,7 @@ class PrintOperatorTree(gdb.Command): logical_operator_type = _logical_operator_type() if operator.type.code in (gdb.TYPE_CODE_PTR, gdb.TYPE_CODE_REF): operator = operator.referenced_value() - if _is_smart_ptr(operator, 'query::plan::LogicalOperator'): + if _is_smart_ptr(operator, 'memgraph::query::plan::LogicalOperator'): operator = _smart_ptr_pointee(operator).dereference() if not _is_instance(operator, logical_operator_type): raise gdb.GdbError("Expected a '%s', but got '%s'" % diff --git a/tools/gdb-plugins/pretty_printers.py b/tools/gdb-plugins/pretty_printers.py index 7545af029..af75a9724 100644 --- a/tools/gdb-plugins/pretty_printers.py +++ b/tools/gdb-plugins/pretty_printers.py @@ -5,12 +5,12 @@ import gdb.printing def build_memgraph_pretty_printers(): '''Instantiate and return all memgraph pretty printer classes.''' pp = gdb.printing.RegexpCollectionPrettyPrinter('memgraph') - pp.add_printer('query::TypedValue', '^query::TypedValue$', TypedValuePrinter) + pp.add_printer('memgraph::query::TypedValue', '^memgraph::query::TypedValue$', TypedValuePrinter) return pp class TypedValuePrinter(gdb.printing.PrettyPrinter): - '''Pretty printer for query::TypedValue''' + '''Pretty printer for memgraph::query::TypedValue''' def __init__(self, val): super(TypedValuePrinter, self).__init__('TypedValue') self.val = val @@ -19,25 +19,25 @@ class TypedValuePrinter(gdb.printing.PrettyPrinter): def _to_str(val): return '{%s %s}' % (value_type, self.val[val]) value_type = str(self.val['type_']) - if value_type == 'query::TypedValue::Type::Null': + if value_type == 'memgraph::query::TypedValue::Type::Null': return '{%s}' % value_type - elif value_type == 'query::TypedValue::Type::Bool': + elif value_type == 'memgraph::query::TypedValue::Type::Bool': return _to_str('bool_v') - elif value_type == 'query::TypedValue::Type::Int': + elif value_type == 'memgraph::query::TypedValue::Type::Int': return _to_str('int_v') - elif value_type == 'query::TypedValue::Type::Double': + elif value_type == 'memgraph::query::TypedValue::Type::Double': return _to_str('double_v') - elif value_type == 'query::TypedValue::Type::String': + elif value_type == 'memgraph::query::TypedValue::Type::String': return _to_str('string_v') - elif value_type == 'query::TypedValue::Type::List': + elif value_type == 'memgraph::query::TypedValue::Type::List': return _to_str('list_v') - elif value_type == 'query::TypedValue::Type::Map': + elif value_type == 'memgraph::query::TypedValue::Type::Map': return _to_str('map_v') - elif value_type == 'query::TypedValue::Type::Vertex': + elif value_type == 'memgraph::query::TypedValue::Type::Vertex': return _to_str('vertex_v') - elif value_type == 'query::TypedValue::Type::Edge': + elif value_type == 'memgraph::query::TypedValue::Type::Edge': return _to_str('edge_v') - elif value_type == 'query::TypedValue::Type::Path': + elif value_type == 'memgraph::query::TypedValue::Type::Path': return _to_str('path_v') return '{%s}' % value_type