From d4e3c4cd108a5d2af879009acb1e101444b6b8df Mon Sep 17 00:00:00 2001 From: Marko Budiselic <marko.budiselic@memgraph.io> Date: Sat, 18 Feb 2017 11:54:37 +0100 Subject: [PATCH] clang format has been run on all hpp and cpp files under src and tests --- format.sh | 12 + src/communication/bolt/communication.hpp | 7 +- src/communication/bolt/v1/bolt.cpp | 30 +- src/communication/bolt/v1/bolt.hpp | 20 +- src/communication/bolt/v1/config.hpp | 15 +- src/communication/bolt/v1/messaging/codes.hpp | 48 +- src/communication/bolt/v1/packing/codes.hpp | 82 +- src/communication/bolt/v1/packing/types.hpp | 51 +- .../bolt/v1/serialization/bolt_serializer.cpp | 31 +- .../bolt/v1/serialization/bolt_serializer.hpp | 79 +- .../bolt/v1/serialization/record_stream.hpp | 246 +- src/communication/bolt/v1/server/server.hpp | 84 +- src/communication/bolt/v1/server/worker.hpp | 123 +- src/communication/bolt/v1/session.cpp | 52 +- src/communication/bolt/v1/session.hpp | 36 +- src/communication/bolt/v1/states.cpp | 19 +- src/communication/bolt/v1/states.hpp | 19 +- src/communication/bolt/v1/states/error.cpp | 74 +- src/communication/bolt/v1/states/error.hpp | 13 +- src/communication/bolt/v1/states/executor.cpp | 155 +- src/communication/bolt/v1/states/executor.hpp | 54 +- .../bolt/v1/states/handshake.cpp | 24 +- .../bolt/v1/states/handshake.hpp | 13 +- src/communication/bolt/v1/states/init.cpp | 59 +- src/communication/bolt/v1/states/init.hpp | 22 +- .../bolt/v1/states/message_parser.hpp | 33 +- src/communication/bolt/v1/states/state.hpp | 25 +- .../bolt/v1/transport/bolt_decoder.cpp | 123 +- .../bolt/v1/transport/bolt_decoder.hpp | 48 +- .../bolt/v1/transport/bolt_encoder.hpp | 343 +- .../bolt/v1/transport/buffer.cpp | 14 +- .../bolt/v1/transport/buffer.hpp | 33 +- .../bolt/v1/transport/chunked_buffer.hpp | 76 +- .../bolt/v1/transport/chunked_decoder.hpp | 82 +- .../bolt/v1/transport/chunked_encoder.hpp | 123 +- .../bolt/v1/transport/socket_stream.hpp | 38 +- .../bolt/v1/transport/stream_error.hpp | 11 +- .../v1/transport/streamed_bolt_decoder.hpp | 561 +- src/config/config.cpp | 7 +- src/config/config.hpp | 16 +- src/data_structures/bitset/dynamic_bitset.hpp | 239 +- src/data_structures/bloom/bloom_filter.hpp | 90 +- src/data_structures/concurrent/common.hpp | 108 +- .../concurrent/concurrent_bloom_map.hpp | 33 +- .../concurrent/concurrent_list.hpp | 594 +- .../concurrent/concurrent_map.hpp | 110 +- .../concurrent/concurrent_multimap.hpp | 98 +- .../concurrent/concurrent_multiset.hpp | 79 +- .../concurrent/concurrent_set.hpp | 16 +- src/data_structures/concurrent/skiplist.hpp | 16 +- .../concurrent/skiplist_gc.hpp | 82 +- src/data_structures/kdtree/build.hpp | 79 +- src/data_structures/kdtree/kdnode.hpp | 46 +- src/data_structures/kdtree/kdtree.hpp | 33 +- src/data_structures/kdtree/math.hpp | 30 +- src/data_structures/kdtree/nns.hpp | 120 +- src/data_structures/kdtree/point.hpp | 32 +- src/data_structures/list/lockfree_list.hpp | 357 +- src/data_structures/map/rh_common.hpp | 542 +- src/data_structures/map/rh_hashmap.hpp | 294 +- src/data_structures/map/rh_hashmultimap.hpp | 573 +- src/data_structures/ptr_int.hpp | 65 +- .../queue/bounded_spsc_queue.hpp | 112 +- src/data_structures/queue/mpsc_queue.hpp | 198 +- src/data_structures/queue/slqueue.hpp | 82 +- src/data_structures/slrbtree.hpp | 10 +- src/data_structures/slstack.hpp | 34 +- src/data_structures/stack/array_stack.hpp | 6 +- src/data_structures/static_array.hpp | 75 +- src/data_structures/union_find/union_find.hpp | 142 +- src/database/creation_exception.hpp | 3 +- src/database/graph_db.cpp | 6 +- src/database/graph_db.hpp | 30 +- src/database/graph_db_accessor.cpp | 68 +- src/database/graph_db_accessor.hpp | 14 +- src/dbms/cleaner.cpp | 100 +- src/dbms/cleaner.hpp | 28 +- src/dbms/dbms.cpp | 26 +- src/dbms/dbms.hpp | 64 +- src/import/base_import.hpp | 263 +- src/import/csv_import.hpp | 611 +- src/import/element_skeleton.hpp | 13 +- src/import/fillings/bool.hpp | 31 +- src/import/fillings/common.hpp | 7 +- src/import/fillings/filler.hpp | 11 +- src/import/fillings/float.hpp | 34 +- src/import/fillings/from.hpp | 46 +- src/import/fillings/id.hpp | 55 +- src/import/fillings/int64.hpp | 34 +- src/import/fillings/label.hpp | 37 +- src/import/fillings/skip.hpp | 17 +- src/import/fillings/string.hpp | 34 +- src/import/fillings/to.hpp | 45 +- src/import/fillings/type.hpp | 29 +- src/io/network/addrinfo.hpp | 48 +- src/io/network/client.hpp | 36 +- src/io/network/epoll.hpp | 63 +- src/io/network/event_listener.hpp | 122 +- src/io/network/network_error.hpp | 11 +- src/io/network/secure_socket.hpp | 100 +- src/io/network/secure_stream_reader.hpp | 70 +- src/io/network/server.hpp | 59 +- src/io/network/socket.hpp | 256 +- src/io/network/stream_listener.hpp | 58 +- src/io/network/stream_reader.hpp | 123 +- src/io/network/tcp/stream.hpp | 38 +- src/io/network/test.cpp | 159 +- src/io/network/tls.cpp | 65 +- src/io/network/tls.hpp | 36 +- src/io/network/tls_error.hpp | 11 +- src/logging/default.cpp | 28 +- src/logging/default.hpp | 14 +- src/logging/levels.cpp | 4 +- src/logging/levels.hpp | 35 +- src/logging/log.cpp | 15 +- src/logging/log.hpp | 76 +- src/logging/loggable.hpp | 28 +- src/logging/logger.hpp | 124 +- src/logging/logs/async_log.cpp | 45 +- src/logging/logs/async_log.hpp | 25 +- src/logging/logs/sync_log.cpp | 12 +- src/logging/logs/sync_log.hpp | 11 +- src/logging/streams/format.hpp | 35 +- src/logging/streams/stderr.cpp | 5 +- src/logging/streams/stderr.hpp | 7 +- src/logging/streams/stdout.cpp | 5 +- src/logging/streams/stdout.hpp | 7 +- src/memory/deferred_recycler.hpp | 32 +- src/memory/freelist.hpp | 25 +- src/memory/hp.hpp | 205 +- src/memory/lazy_gc.hpp | 26 +- src/memory/literals.hpp | 24 +- src/memory/memory.hpp | 58 +- src/memory/recycler.hpp | 57 +- src/mvcc/cre_exp.hpp | 45 +- src/mvcc/hints.hpp | 149 +- src/mvcc/id.cpp | 24 +- src/mvcc/id.hpp | 23 +- src/mvcc/mvcc_error.hpp | 11 +- src/mvcc/record.hpp | 207 +- src/mvcc/serialization_error.hpp | 13 +- src/mvcc/version.hpp | 54 +- src/mvcc/version_list.hpp | 310 +- src/query/backend/cpp/generator.hpp | 4 +- src/query/engine.hpp | 7 +- src/query/exception/cpp_code_generator.hpp | 7 +- src/query/exception/decoder_exception.hpp | 7 +- src/query/exception/plan_compilation.hpp | 7 +- src/query/exception/plan_execution.hpp | 7 +- src/query/exception/query_engine.hpp | 7 +- .../generated/CypherBaseListener.cpp | 7 +- .../generated/CypherBaseVisitor.cpp | 7 +- .../opencypher/generated/CypherLexer.cpp | 2190 ++-- .../opencypher/generated/CypherListener.cpp | 7 +- .../opencypher/generated/CypherParser.cpp | 9870 +++++++++-------- .../opencypher/generated/CypherVisitor.cpp | 7 +- src/query/stripper.hpp | 7 +- src/serialization/graph_decoder.hpp | 47 +- src/serialization/graph_encoder.hpp | 67 +- src/serialization/serialization.hpp | 138 +- src/snapshot/snapshot_decoder.cpp | 153 +- src/snapshot/snapshot_decoder.hpp | 199 +- src/snapshot/snapshot_encoder.cpp | 177 +- src/snapshot/snapshot_encoder.hpp | 123 +- src/snapshot/snapshot_engine.cpp | 505 +- src/snapshot/snapshot_engine.hpp | 80 +- src/snapshot/snapshoter.cpp | 97 +- src/snapshot/snapshoter.hpp | 32 +- src/storage/edge.hpp | 6 +- src/storage/edge_accessor.cpp | 6 +- src/storage/edge_accessor.hpp | 6 +- src/storage/garbage/delete_sensitive.hpp | 7 +- src/storage/garbage/garbage.cpp | 22 +- src/storage/garbage/garbage.hpp | 26 +- src/storage/locking/lock_status.hpp | 6 +- src/storage/locking/record_lock.cpp | 30 +- src/storage/locking/record_lock.hpp | 25 +- src/storage/record_accessor.cpp | 48 +- src/storage/record_accessor.hpp | 61 +- src/storage/typed_value.cpp | 123 +- src/storage/typed_value.hpp | 36 +- src/storage/typed_value_store.cpp | 37 +- src/storage/typed_value_store.hpp | 2 +- src/storage/typed_value_utils.hpp | 7 +- src/storage/unique_object_store.hpp | 18 +- src/storage/util.hpp | 9 +- src/storage/vertex.hpp | 3 +- src/storage/vertex_accessor.cpp | 18 +- src/storage/vertex_accessor.hpp | 6 +- src/storage/writer/rapidjson_stringwriter.hpp | 65 +- src/template_engine/engine.cpp | 25 +- src/template_engine/engine.hpp | 4 +- src/test/allocator.cpp | 92 +- src/test/dynamic_bitset.cpp | 25 +- src/threading/hazard_ptr.hpp | 157 +- src/threading/hazard_store.hpp | 128 +- src/threading/id.hpp | 3 +- src/threading/pool.hpp | 118 +- src/threading/sync/caslock.hpp | 37 +- src/threading/sync/futex.hpp | 247 +- src/threading/sync/lock_timeout_error.hpp | 7 +- src/threading/sync/timed_spinlock.hpp | 54 +- src/threading/task.hpp | 119 +- src/threading/test.cpp | 24 +- src/threading/thread.cpp | 9 +- src/threading/thread.hpp | 54 +- src/transactions/commit_log.hpp | 72 +- src/transactions/engine.hpp | 168 +- src/transactions/lock_store.hpp | 79 +- src/transactions/snapshot.cpp | 13 +- src/transactions/snapshot.hpp | 81 +- src/transactions/transaction.cpp | 33 +- src/transactions/transaction.hpp | 35 +- src/transactions/transaction_read.cpp | 32 +- src/transactions/transaction_read.hpp | 47 +- src/transactions/transaction_store.hpp | 35 +- src/utils/algorithm.hpp | 12 +- src/utils/align.hpp | 4 +- src/utils/assert.hpp | 51 +- src/utils/auto_scope.hpp | 30 +- src/utils/bash_colors.hpp | 13 +- src/utils/border.hpp | 84 +- src/utils/bswap.hpp | 42 +- src/utils/buffer.hpp | 52 +- src/utils/char_str.hpp | 27 +- src/utils/command_line/arguments.hpp | 8 +- src/utils/config/config.hpp | 11 +- src/utils/counters/atomic_counter.hpp | 23 +- src/utils/counters/ring_counter.hpp | 34 +- src/utils/counters/simple_counter.hpp | 21 +- src/utils/cpu_relax.hpp | 11 +- src/utils/crtp.hpp | 13 +- src/utils/datetime/datetime.hpp | 38 +- src/utils/datetime/datetime_error.hpp | 8 +- src/utils/datetime/timestamp.hpp | 117 +- src/utils/dynamic_lib.hpp | 170 +- src/utils/eq_wrapper.hpp | 23 +- src/utils/exceptions/basic_exception.hpp | 37 +- src/utils/exceptions/non_exaustive_switch.hpp | 7 +- src/utils/exceptions/not_yet_implemented.hpp | 9 +- src/utils/exceptions/out_of_memory.hpp | 7 +- src/utils/file.hpp | 56 +- src/utils/fswatcher.hpp | 647 +- src/utils/handle_write.hpp | 11 +- src/utils/hashing/fnv.hpp | 14 +- src/utils/hashing/fnv32.hpp | 48 +- src/utils/hashing/fnv64.hpp | 48 +- src/utils/ioc/container.hpp | 142 +- src/utils/iterator/accessor.hpp | 33 +- src/utils/iterator/combined.hpp | 71 +- src/utils/iterator/composable.hpp | 292 +- src/utils/iterator/count.hpp | 41 +- src/utils/iterator/filter.hpp | 61 +- src/utils/iterator/flat_map.hpp | 99 +- src/utils/iterator/for_all.hpp | 45 +- src/utils/iterator/inspect.hpp | 64 +- src/utils/iterator/iterator_accessor.hpp | 101 +- src/utils/iterator/iterator_base.hpp | 11 +- src/utils/iterator/lambda_iterator.hpp | 54 +- src/utils/iterator/limited_map.hpp | 60 +- src/utils/iterator/map.hpp | 56 +- src/utils/iterator/query.hpp | 21 +- src/utils/iterator/range_iterator.hpp | 90 +- src/utils/iterator/virtual_iter.hpp | 46 +- src/utils/linux.hpp | 50 +- src/utils/mark_ref.hpp | 37 +- src/utils/memory/allocator.hpp | 43 +- src/utils/memory/atomic_shared_ptr.hpp | 28 +- src/utils/memory/block_allocator.hpp | 80 +- src/utils/memory/maker.hpp | 25 +- src/utils/memory/stack_allocator.hpp | 171 +- src/utils/numerics/ceil.hpp | 16 +- src/utils/numerics/log2.hpp | 4 +- src/utils/numerics/saturate.cpp | 9 +- src/utils/numerics/saturate.hpp | 3 +- src/utils/option.hpp | 322 +- src/utils/option_ptr.hpp | 29 +- src/utils/order.hpp | 9 +- src/utils/pass_key.hpp | 5 +- src/utils/random/fast_binomial.hpp | 90 +- src/utils/random/xorshift128plus.hpp | 72 +- src/utils/reference_wrapper.hpp | 43 +- src/utils/signals/handler.hpp | 51 +- src/utils/stacktrace/log.hpp | 9 +- src/utils/stacktrace/stacktrace.hpp | 142 +- src/utils/stream_wrapper.hpp | 27 +- src/utils/string/all.hpp | 2 +- src/utils/string/file.hpp | 44 +- src/utils/string/intercalate.hpp | 26 +- src/utils/string/join.hpp | 19 +- src/utils/string/linereader.hpp | 27 +- src/utils/string/replace.hpp | 19 +- src/utils/string/split.hpp | 41 +- src/utils/string/streq.hpp | 36 +- src/utils/string/transform.hpp | 8 +- src/utils/string/trim.hpp | 19 +- src/utils/string/weak_string.hpp | 97 +- src/utils/string_buffer.hpp | 64 +- src/utils/sys.hpp | 52 +- src/utils/sysinfo/memory.hpp | 71 +- src/utils/terminate_handler.hpp | 30 +- src/utils/time/timer.hpp | 70 +- src/utils/timer/timer.hpp | 210 +- src/utils/total_ordering.hpp | 2 +- src/utils/total_ordering_with.hpp | 59 +- src/utils/type_discovery.hpp | 135 +- src/utils/underlying_cast.hpp | 2 +- src/utils/variadic/variadic.hpp | 50 +- src/utils/visitor/visitable.hpp | 7 +- src/utils/visitor/visitor.hpp | 41 +- src/utils/void.hpp | 9 +- .../bloom/basic_bloom_filter.cpp | 55 +- .../concurrent/bloom_map_concurrent.cpp | 180 +- .../concurrent/map_concurrent.cpp | 291 +- .../concurrent/map_mix_concurrent.cpp | 106 +- tests/benchmark/query/strip/stripper.cpp | 54 +- tests/concurrent/conncurent_list.cpp | 132 +- tests/concurrent/dynamic_bitset.cpp | 61 +- tests/concurrent/dynamic_bitset_clear_n.cpp | 85 +- tests/concurrent/dynamic_bitset_set.cpp | 32 +- tests/concurrent/dynamic_bitset_set_n.cpp | 37 +- tests/concurrent/sl_insert.cpp | 53 +- tests/concurrent/sl_insert_competetive.cpp | 55 +- tests/concurrent/sl_map.cpp | 139 +- tests/concurrent/sl_memory.cpp | 30 +- tests/concurrent/sl_memory_leak.cpp | 133 +- tests/concurrent/sl_multiiterator.cpp | 75 +- tests/concurrent/sl_multiiterator_remove.cpp | 149 +- .../sl_multiiterator_remove_duplicates.cpp | 134 +- tests/concurrent/sl_multimap.cpp | 207 +- tests/concurrent/sl_multiset.cpp | 102 +- tests/concurrent/sl_remove_competetive.cpp | 93 +- tests/concurrent/sl_remove_disjoint.cpp | 70 +- tests/concurrent/sl_remove_joint.cpp | 103 +- tests/concurrent/sl_set.cpp | 93 +- tests/concurrent/sl_simulation.cpp | 96 +- tests/concurrent/timer.cpp | 60 +- .../hardcoded_query/clique_001.cpp | 264 +- .../hardcoded_query/create_account_return.cpp | 65 +- .../hardcoded_query/create_edge.cpp | 51 +- .../create_full_profile_return.cpp | 52 +- .../create_label_name_return.cpp | 47 +- .../create_other_name_return.cpp | 47 +- .../hardcoded_query/create_prop_return.cpp | 43 +- .../hardcoded_query/create_return_g.cpp | 52 +- .../match_all_n_detach_delete.cpp | 38 +- .../hardcoded_query/match_delete_garment.cpp | 48 +- .../hardcoded_query/match_delete_profile.cpp | 48 +- .../hardcoded_query/match_delete_score.cpp | 125 +- .../hardcoded_query/match_edge_score.cpp | 123 +- .../match_garment_set_label_return_labels.cpp | 72 +- .../match_garment_set_return.cpp | 58 +- .../hardcoded_query/match_profile_return.cpp | 49 +- .../hardcoded_query/match_return.cpp | 49 +- .../merge_path_return_edge.cpp | 82 +- .../hardcoded_query/merge_set_return.cpp | 152 +- tests/integration/query_engine.cpp | 37 +- tests/integration/query_engine_common.hpp | 176 +- .../stream/print_record_stream.hpp | 60 +- tests/manual/antlr_parser.cpp | 32 +- tests/manual/query_engine.cpp | 105 +- tests/manual/query_hash.cpp | 43 +- tests/unit/basic_bloom_filter.cpp | 42 +- tests/unit/block_allocator.cpp | 27 +- tests/unit/chunked_decoder.cpp | 53 +- tests/unit/chunked_encoder.cpp | 150 +- tests/unit/concurrent_list.cpp | 119 +- tests/unit/concurrent_map.cpp | 89 +- tests/unit/concurrent_set.cpp | 61 +- tests/unit/dynamic_bitset.cpp | 30 +- tests/unit/fswatcher.cpp | 185 +- tests/unit/graph_db_accessor.cpp | 28 +- tests/unit/program_argument.cpp | 113 +- tests/unit/ptr_int.cpp | 32 +- tests/unit/record_edge_vertex_accessor.cpp | 18 +- tests/unit/rh_hashmap.cpp | 218 +- tests/unit/rh_hashmultimap.cpp | 396 +- tests/unit/signal_handler.cpp | 22 +- tests/unit/skiplist_reverse_iteration.cpp | 18 +- tests/unit/skiplistset.cpp | 58 +- tests/unit/stack_allocator.cpp | 39 +- tests/unit/template_engine.cpp | 16 +- tests/unit/typed_value.cpp | 87 +- tests/unit/typed_value_store.cpp | 10 +- tests/unit/union_find.cpp | 96 +- tests/unit/unique_object_store.cpp | 21 +- 386 files changed, 19085 insertions(+), 20574 deletions(-) create mode 100755 format.sh diff --git a/format.sh b/format.sh new file mode 100755 index 000000000..2c2243fec --- /dev/null +++ b/format.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# This scrips runs clang-format recursively on all files under specified +# directories. Formatting configuration is defined in .clang-format. + +clang_format="clang-format" + +for directory in src tests +do + echo "formatting code under $directory/" + find "$directory" \( -name '*.hpp' -or -name '*.cpp' \) -print0 | xargs -0 "${clang_format}" -i +done diff --git a/src/communication/bolt/communication.hpp b/src/communication/bolt/communication.hpp index c52945361..35a8fe064 100644 --- a/src/communication/bolt/communication.hpp +++ b/src/communication/bolt/communication.hpp @@ -1,9 +1,8 @@ #pragma once -#include "io/network/socket.hpp" #include "communication/bolt/v1/serialization/record_stream.hpp" +#include "io/network/socket.hpp" -namespace communication -{ - using OutputStream = bolt::RecordStream<io::Socket>; +namespace communication { +using OutputStream = bolt::RecordStream<io::Socket>; } diff --git a/src/communication/bolt/v1/bolt.cpp b/src/communication/bolt/v1/bolt.cpp index 9efd1b10c..9dd35d6ad 100644 --- a/src/communication/bolt/v1/bolt.cpp +++ b/src/communication/bolt/v1/bolt.cpp @@ -2,26 +2,18 @@ #include "communication/bolt/v1/session.hpp" -namespace bolt -{ +namespace bolt { -Bolt::Bolt() -{ -} - -Session* Bolt::create_session(io::Socket&& socket) -{ - // TODO fix session lifecycle handling - // dangling pointers are not cool :) - - // TODO attach currently active Db - - return new Session(std::forward<io::Socket>(socket), *this); -} - -void Bolt::close(Session* session) -{ - session->socket.close(); +Bolt::Bolt() {} + +Session* Bolt::create_session(io::Socket&& socket) { + // TODO fix session lifecycle handling + // dangling pointers are not cool :) + + // TODO attach currently active Db + + return new Session(std::forward<io::Socket>(socket), *this); } +void Bolt::close(Session* session) { session->socket.close(); } } diff --git a/src/communication/bolt/v1/bolt.hpp b/src/communication/bolt/v1/bolt.hpp index 0c9453931..b4791a206 100644 --- a/src/communication/bolt/v1/bolt.hpp +++ b/src/communication/bolt/v1/bolt.hpp @@ -4,22 +4,20 @@ #include "dbms/dbms.hpp" #include "io/network/socket.hpp" -namespace bolt -{ +namespace bolt { class Session; -class Bolt -{ - friend class Session; +class Bolt { + friend class Session; -public: - Bolt(); + public: + Bolt(); - Session *create_session(io::Socket &&socket); - void close(Session *session); + Session *create_session(io::Socket &&socket); + void close(Session *session); - States states; - Dbms dbms; + States states; + Dbms dbms; }; } diff --git a/src/communication/bolt/v1/config.hpp b/src/communication/bolt/v1/config.hpp index fcec2a207..c05680b7a 100644 --- a/src/communication/bolt/v1/config.hpp +++ b/src/communication/bolt/v1/config.hpp @@ -2,16 +2,13 @@ #include <cstddef> -namespace bolt -{ +namespace bolt { -namespace config -{ - /** chunk size */ - static constexpr size_t N = 65535; +namespace config { +/** chunk size */ +static constexpr size_t N = 65535; - /** end mark */ - static constexpr size_t C = N + 2; +/** end mark */ +static constexpr size_t C = N + 2; } - } diff --git a/src/communication/bolt/v1/messaging/codes.hpp b/src/communication/bolt/v1/messaging/codes.hpp index 19083199c..09a8f9cfe 100644 --- a/src/communication/bolt/v1/messaging/codes.hpp +++ b/src/communication/bolt/v1/messaging/codes.hpp @@ -3,44 +3,36 @@ #include "utils/types/byte.hpp" #include "utils/underlying_cast.hpp" -namespace bolt -{ +namespace bolt { -enum class MessageCode : byte -{ - Init = 0x01, - AckFailure = 0x0E, - Reset = 0x0F, +enum class MessageCode : byte { + Init = 0x01, + AckFailure = 0x0E, + Reset = 0x0F, - Run = 0x10, - DiscardAll = 0x2F, - PullAll = 0x3F, + Run = 0x10, + DiscardAll = 0x2F, + PullAll = 0x3F, - Record = 0x71, - Success = 0x70, - Ignored = 0x7E, - Failure = 0x7F + Record = 0x71, + Success = 0x70, + Ignored = 0x7E, + Failure = 0x7F }; -inline bool operator==(byte value, MessageCode code) -{ - return value == underlying_cast(code); +inline bool operator==(byte value, MessageCode code) { + return value == underlying_cast(code); } -inline bool operator==(MessageCode code, byte value) -{ - return operator==(value, code); +inline bool operator==(MessageCode code, byte value) { + return operator==(value, code); } -inline bool operator!=(byte value, MessageCode code) -{ - return !operator==(value, code); +inline bool operator!=(byte value, MessageCode code) { + return !operator==(value, code); } -inline bool operator!=(MessageCode code, byte value) -{ - return operator!=(value, code); +inline bool operator!=(MessageCode code, byte value) { + return operator!=(value, code); } - - } diff --git a/src/communication/bolt/v1/packing/codes.hpp b/src/communication/bolt/v1/packing/codes.hpp index 2b91e14b2..607ddd6f8 100644 --- a/src/communication/bolt/v1/packing/codes.hpp +++ b/src/communication/bolt/v1/packing/codes.hpp @@ -2,65 +2,57 @@ #include <cstdint> -namespace bolt -{ +namespace bolt { -namespace pack -{ +namespace pack { -enum Code : uint8_t -{ - TinyString = 0x80, - TinyList = 0x90, - TinyMap = 0xA0, +enum Code : uint8_t { + TinyString = 0x80, + TinyList = 0x90, + TinyMap = 0xA0, - TinyStruct = 0xB0, - StructOne = 0xB1, - StructTwo = 0xB2, + TinyStruct = 0xB0, + StructOne = 0xB1, + StructTwo = 0xB2, - Null = 0xC0, + Null = 0xC0, - Float64 = 0xC1, + Float64 = 0xC1, - False = 0xC2, - True = 0xC3, + False = 0xC2, + True = 0xC3, - Int8 = 0xC8, - Int16 = 0xC9, - Int32 = 0xCA, - Int64 = 0xCB, + Int8 = 0xC8, + Int16 = 0xC9, + Int32 = 0xCA, + Int64 = 0xCB, - Bytes8 = 0xCC, - Bytes16 = 0xCD, - Bytes32 = 0xCE, + Bytes8 = 0xCC, + Bytes16 = 0xCD, + Bytes32 = 0xCE, - String8 = 0xD0, - String16 = 0xD1, - String32 = 0xD2, + String8 = 0xD0, + String16 = 0xD1, + String32 = 0xD2, - List8 = 0xD4, - List16 = 0xD5, - List32 = 0xD6, + List8 = 0xD4, + List16 = 0xD5, + List32 = 0xD6, - Map8 = 0xD8, - Map16 = 0xD9, - Map32 = 0xDA, - MapStream = 0xDB, + Map8 = 0xD8, + Map16 = 0xD9, + Map32 = 0xDA, + MapStream = 0xDB, - Node = 0x4E, - Relationship = 0x52, - Path = 0x50, + Node = 0x4E, + Relationship = 0x52, + Path = 0x50, - Struct8 = 0xDC, - Struct16 = 0xDD, - EndOfStream = 0xDF, -}; - -enum Rule : uint8_t -{ - MaxInitStructSize = 0x02 + Struct8 = 0xDC, + Struct16 = 0xDD, + EndOfStream = 0xDF, }; +enum Rule : uint8_t { MaxInitStructSize = 0x02 }; } - } diff --git a/src/communication/bolt/v1/packing/types.hpp b/src/communication/bolt/v1/packing/types.hpp index d561fdc3f..ede64bba3 100644 --- a/src/communication/bolt/v1/packing/types.hpp +++ b/src/communication/bolt/v1/packing/types.hpp @@ -1,42 +1,39 @@ #pragma once -namespace bolt -{ +namespace bolt { -enum class PackType -{ - /** denotes absence of a value */ - Null, +enum class PackType { + /** denotes absence of a value */ + Null, - /** denotes a type with two possible values (t/f) */ - Boolean, + /** denotes a type with two possible values (t/f) */ + Boolean, - /** 64-bit signed integral number */ - Integer, + /** 64-bit signed integral number */ + Integer, - /** 64-bit floating point number */ - Float, + /** 64-bit floating point number */ + Float, - /** binary data */ - Bytes, + /** binary data */ + Bytes, - /** unicode string */ - String, + /** unicode string */ + String, - /** collection of values */ - List, + /** collection of values */ + List, - /** collection of zero or more key/value pairs */ - Map, + /** collection of zero or more key/value pairs */ + Map, - /** zero or more packstream values */ - Struct, + /** zero or more packstream values */ + Struct, - /** denotes stream value end */ - EndOfStream, + /** denotes stream value end */ + EndOfStream, - /** reserved for future use */ - Reserved + /** reserved for future use */ + Reserved }; - } diff --git a/src/communication/bolt/v1/serialization/bolt_serializer.cpp b/src/communication/bolt/v1/serialization/bolt_serializer.cpp index b6051a32a..49008a80b 100644 --- a/src/communication/bolt/v1/serialization/bolt_serializer.cpp +++ b/src/communication/bolt/v1/serialization/bolt_serializer.cpp @@ -8,9 +8,8 @@ #include "database/graph_db.hpp" #include "storage/typed_value_store.hpp" -template<class Stream> +template <class Stream> void bolt::BoltSerializer<Stream>::write(const VertexAccessor &vertex) { - // write signatures for the node struct and node data type encoder.write_struct_header(3); encoder.write(underlying_cast(pack::Node)); @@ -19,7 +18,7 @@ void bolt::BoltSerializer<Stream>::write(const VertexAccessor &vertex) { // use internal IDs, but need to give something to Bolt // note that OpenCypher has no id(x) function, so the client // should not be able to do anything with this value anyway - encoder.write_integer(0); // uID + encoder.write_integer(0); // uID // write the list of labels auto labels = vertex.labels(); @@ -30,13 +29,14 @@ void bolt::BoltSerializer<Stream>::write(const VertexAccessor &vertex) { // write the properties const TypedValueStore<GraphDb::Property> &props = vertex.Properties(); encoder.write_map_header(props.size()); - props.Accept([this, &vertex](const GraphDb::Property prop, const TypedValue &value) { - this->encoder.write(vertex.db_accessor().property_name(prop)); - this->write(value); - }); + props.Accept( + [this, &vertex](const GraphDb::Property prop, const TypedValue &value) { + this->encoder.write(vertex.db_accessor().property_name(prop)); + this->write(value); + }); } -template<class Stream> +template <class Stream> void bolt::BoltSerializer<Stream>::write(const EdgeAccessor &edge) { // write signatures for the edge struct and edge data type encoder.write_struct_header(5); @@ -54,7 +54,7 @@ void bolt::BoltSerializer<Stream>::write(const EdgeAccessor &edge) { encoder.write(edge.db_accessor().edge_type_name(edge.edge_type())); // write the property map - const TypedValueStore<GraphDb::Property>& props = edge.Properties(); + const TypedValueStore<GraphDb::Property> &props = edge.Properties(); encoder.write_map_header(props.size()); props.Accept([this, &edge](GraphDb::Property prop, const TypedValue &value) { this->encoder.write(edge.db_accessor().property_name(prop)); @@ -62,9 +62,8 @@ void bolt::BoltSerializer<Stream>::write(const EdgeAccessor &edge) { }); } -template<class Stream> -void bolt::BoltSerializer<Stream>::write(const TypedValue& value) { - +template <class Stream> +void bolt::BoltSerializer<Stream>::write(const TypedValue &value) { switch (value.type_) { case TypedValue::Type::Null: encoder.write_null(); @@ -84,8 +83,9 @@ void bolt::BoltSerializer<Stream>::write(const TypedValue& value) { } } -template<class Stream> -void bolt::BoltSerializer<Stream>::write_failure(const std::map<std::string, std::string> &data) { +template <class Stream> +void bolt::BoltSerializer<Stream>::write_failure( + const std::map<std::string, std::string> &data) { encoder.message_failure(); encoder.write_map_header(data.size()); for (auto const &kv : data) { @@ -94,6 +94,5 @@ void bolt::BoltSerializer<Stream>::write_failure(const std::map<std::string, std } } -template -class bolt::BoltSerializer<bolt::BoltEncoder< +template class bolt::BoltSerializer<bolt::BoltEncoder< bolt::ChunkedEncoder<bolt::ChunkedBuffer<bolt::SocketStream<io::Socket>>>>>; diff --git a/src/communication/bolt/v1/serialization/bolt_serializer.hpp b/src/communication/bolt/v1/serialization/bolt_serializer.hpp index 919a0d37e..a05102177 100644 --- a/src/communication/bolt/v1/serialization/bolt_serializer.hpp +++ b/src/communication/bolt/v1/serialization/bolt_serializer.hpp @@ -10,48 +10,49 @@ namespace bolt { - template<class Stream> - class BoltSerializer { +template <class Stream> +class BoltSerializer { + public: + BoltSerializer(Stream &stream) : encoder(stream) {} - public: - BoltSerializer(Stream &stream) : encoder(stream) {} + /** Serializes the vertex accessor into the packstream format + * + * struct[size = 3] Vertex [signature = 0x4E] { + * Integer node_id; + * List<String> labels; + * Map<String, Value> properties; + * } + * + */ + void write(const VertexAccessor &vertex); - /** Serializes the vertex accessor into the packstream format - * - * struct[size = 3] Vertex [signature = 0x4E] { - * Integer node_id; - * List<String> labels; - * Map<String, Value> properties; - * } - * - */ - void write(const VertexAccessor &vertex); + /** Serializes the edge accessor into the packstream format + * + * struct[size = 5] Edge [signature = 0x52] { + * Integer edge_id; // IMPORTANT: always 0 since we + * don't do IDs + * Integer start_node_id; // IMPORTANT: always 0 since we + * don't do IDs + * Integer end_node_id; // IMPORTANT: always 0 since we + * don't do IDs + * String type; + * Map<String, Value> properties; + * } + * + */ + void write(const EdgeAccessor &edge); - /** Serializes the edge accessor into the packstream format - * - * struct[size = 5] Edge [signature = 0x52] { - * Integer edge_id; // IMPORTANT: always 0 since we don't do IDs - * Integer start_node_id; // IMPORTANT: always 0 since we don't do IDs - * Integer end_node_id; // IMPORTANT: always 0 since we don't do IDs - * String type; - * Map<String, Value> properties; - * } - * - */ - void write(const EdgeAccessor &edge); + // TODO document + void write_failure(const std::map<std::string, std::string> &data); - // TODO document - void write_failure(const std::map<std::string, std::string> &data); + /** + * Writes a TypedValue (typically a property value in the edge or vertex). + * + * @param value The value to write. + */ + void write(const TypedValue &value); - /** - * Writes a TypedValue (typically a property value in the edge or vertex). - * - * @param value The value to write. - */ - void write(const TypedValue& value); - - protected: - Stream &encoder; - - }; + protected: + Stream &encoder; +}; } diff --git a/src/communication/bolt/v1/serialization/record_stream.hpp b/src/communication/bolt/v1/serialization/record_stream.hpp index ff0db58e4..e7cfb332d 100644 --- a/src/communication/bolt/v1/serialization/record_stream.hpp +++ b/src/communication/bolt/v1/serialization/record_stream.hpp @@ -13,152 +13,148 @@ namespace bolt { * compiled queries have to use this class in order to return results * query code should not know about bolt protocol */ - template<class Socket> - class RecordStream { - public: - RecordStream(Socket &socket) : socket(socket) { - logger = logging::log->logger("Record Stream"); +template <class Socket> +class RecordStream { + public: + RecordStream(Socket &socket) : socket(socket) { + logger = logging::log->logger("Record Stream"); + } + + ~RecordStream() = default; + + // TODO: create apstract methods that are not bolt specific --------------- + void write_success() { + logger.trace("write_success"); + bolt_encoder.message_success(); + } + + void write_success_empty() { + logger.trace("write_success_empty"); + bolt_encoder.message_success_empty(); + } + + void write_ignored() { + logger.trace("write_ignored"); + bolt_encoder.message_ignored(); + } + + void write_empty_fields() { + bolt_encoder.message_success(); + bolt_encoder.write_map_header(1); + bolt_encoder.write_string("fields"); + write_list_header(0); + chunk(); + } + + void write_fields(const std::vector<std::string> &fields) { + // TODO: that should be one level below? + bolt_encoder.message_success(); + + bolt_encoder.write_map_header(1); + bolt_encoder.write_string("fields"); + write_list_header(fields.size()); + + for (auto &name : fields) { + bolt_encoder.write_string(name); } - ~RecordStream() = default; + chunk(); + send(); + } - // TODO: create apstract methods that are not bolt specific --------------- - void write_success() { - logger.trace("write_success"); - bolt_encoder.message_success(); - } + void write_field(const std::string &field) { + bolt_encoder.message_success(); + bolt_encoder.write_map_header(1); + bolt_encoder.write_string("fields"); + write_list_header(1); + bolt_encoder.write_string(field); + chunk(); + send(); + } - void write_success_empty() { - logger.trace("write_success_empty"); - bolt_encoder.message_success_empty(); - } + void write_list_header(size_t size) { bolt_encoder.write_list_header(size); } - void write_ignored() { - logger.trace("write_ignored"); - bolt_encoder.message_ignored(); - } + void write_record() { bolt_encoder.message_record(); } - void write_empty_fields() { - bolt_encoder.message_success(); - bolt_encoder.write_map_header(1); - bolt_encoder.write_string("fields"); - write_list_header(0); - chunk(); - } + // writes metadata at the end of the message + // TODO: write whole implementation (currently, only type is supported) + // { "stats": { "nodes created": 1, "properties set": 1}, + // "type": "r" | "rw" | ... + void write_meta(const std::string &type) { + bolt_encoder.message_success(); + bolt_encoder.write_map_header(1); + bolt_encoder.write_string("type"); + bolt_encoder.write_string(type); + chunk(); + } - void write_fields(const std::vector<std::string> &fields) { - // TODO: that should be one level below? - bolt_encoder.message_success(); + void write_failure(const std::map<std::string, std::string> &data) { + serializer.write_failure(data); + chunk(); + } - bolt_encoder.write_map_header(1); - bolt_encoder.write_string("fields"); - write_list_header(fields.size()); + void write_count(const size_t count) { + write_record(); + write_list_header(1); + write(count); + chunk(); + } - for (auto &name : fields) { - bolt_encoder.write_string(name); - } + void write(const VertexAccessor &vertex) { serializer.write(vertex); } - chunk(); - send(); - } + void write_vertex_record(const VertexAccessor &va) { + write_record(); + write_list_header(1); + write(va); + chunk(); + } - void write_field(const std::string &field) { - bolt_encoder.message_success(); - bolt_encoder.write_map_header(1); - bolt_encoder.write_string("fields"); - write_list_header(1); - bolt_encoder.write_string(field); - chunk(); - send(); - } + void write(const EdgeAccessor &edge) { serializer.write(edge); } - void write_list_header(size_t size) { - bolt_encoder.write_list_header(size); - } + void write_edge_record(const EdgeAccessor &ea) { + write_record(); + write_list_header(1); + write(ea); + chunk(); + } - void write_record() { bolt_encoder.message_record(); } + void write(const TypedValue &value) { serializer.write(value); } - // writes metadata at the end of the message - // TODO: write whole implementation (currently, only type is supported) - // { "stats": { "nodes created": 1, "properties set": 1}, - // "type": "r" | "rw" | ... - void write_meta(const std::string &type) { - bolt_encoder.message_success(); - bolt_encoder.write_map_header(1); - bolt_encoder.write_string("type"); - bolt_encoder.write_string(type); - chunk(); - } + void send() { chunked_buffer.flush(); } - void write_failure(const std::map<std::string, std::string> &data) { - serializer.write_failure(data); - chunk(); - } + void chunk() { chunked_encoder.write_chunk(); } - void write_count(const size_t count) { - write_record(); - write_list_header(1); - write(count); - chunk(); - } + // TODO WTF is this test doing here? + void _write_test() { + logger.trace("write_test"); - void write(const VertexAccessor &vertex) { serializer.write(vertex); } + write_fields({{"name"}}); - void write_vertex_record(const VertexAccessor &va) { - write_record(); - write_list_header(1); - write(va); - chunk(); - } + write_record(); + write_list_header(1); + bolt_encoder.write("max"); - void write(const EdgeAccessor &edge) { serializer.write(edge); } + write_record(); + write_list_header(1); + bolt_encoder.write("paul"); - void write_edge_record(const EdgeAccessor &ea) { - write_record(); - write_list_header(1); - write(ea); - chunk(); - } + write_success_empty(); + } - void write(const TypedValue& value) { - serializer.write(value); - } + protected: + Logger logger; - void send() { chunked_buffer.flush(); } + private: + using socket_t = SocketStream<Socket>; + using buffer_t = ChunkedBuffer<socket_t>; + using chunked_encoder_t = ChunkedEncoder<buffer_t>; + using bolt_encoder_t = BoltEncoder<chunked_encoder_t>; + using bolt_serializer_t = BoltSerializer<bolt_encoder_t>; - void chunk() { chunked_encoder.write_chunk(); } - - // TODO WTF is this test doing here? - void _write_test() { - logger.trace("write_test"); - - write_fields({{"name"}}); - - write_record(); - write_list_header(1); - bolt_encoder.write("max"); - - write_record(); - write_list_header(1); - bolt_encoder.write("paul"); - - write_success_empty(); - } - - protected: - Logger logger; - - private: - using socket_t = SocketStream<Socket>; - using buffer_t = ChunkedBuffer<socket_t>; - using chunked_encoder_t = ChunkedEncoder<buffer_t>; - using bolt_encoder_t = BoltEncoder<chunked_encoder_t>; - using bolt_serializer_t = BoltSerializer<bolt_encoder_t>; - - socket_t socket; - buffer_t chunked_buffer{socket}; - chunked_encoder_t chunked_encoder{chunked_buffer}; - bolt_encoder_t bolt_encoder{chunked_encoder}; - bolt_serializer_t serializer{bolt_encoder}; - }; + socket_t socket; + buffer_t chunked_buffer{socket}; + chunked_encoder_t chunked_encoder{chunked_buffer}; + bolt_encoder_t bolt_encoder{chunked_encoder}; + bolt_serializer_t serializer{bolt_encoder}; +}; } diff --git a/src/communication/bolt/v1/server/server.hpp b/src/communication/bolt/v1/server/server.hpp index b7d11a579..79e130afd 100644 --- a/src/communication/bolt/v1/server/server.hpp +++ b/src/communication/bolt/v1/server/server.hpp @@ -1,72 +1,62 @@ #pragma once -#include <vector> -#include <memory> -#include <thread> #include <atomic> #include <cassert> +#include <memory> +#include <thread> +#include <vector> -#include "io/network/server.hpp" #include "communication/bolt/v1/bolt.hpp" +#include "io/network/server.hpp" #include "logging/default.hpp" -namespace bolt -{ +namespace bolt { template <class Worker> -class Server : public io::Server<Server<Worker>> -{ -public: - Server(io::Socket&& socket) - : io::Server<Server<Worker>>(std::forward<io::Socket>(socket)), - logger(logging::log->logger("bolt::Server")) {} +class Server : public io::Server<Server<Worker>> { + public: + Server(io::Socket&& socket) + : io::Server<Server<Worker>>(std::forward<io::Socket>(socket)), + logger(logging::log->logger("bolt::Server")) {} - void start(size_t n) - { - workers.reserve(n); + void start(size_t n) { + workers.reserve(n); - for(size_t i = 0; i < n; ++i) - { - workers.push_back(std::make_shared<Worker>(bolt)); - workers.back()->start(alive); - } - - while(alive) - { - this->wait_and_process_events(); - } + for (size_t i = 0; i < n; ++i) { + workers.push_back(std::make_shared<Worker>(bolt)); + workers.back()->start(alive); } - void shutdown() - { - alive.store(false); - - for(auto& worker : workers) - worker->thread.join(); + while (alive) { + this->wait_and_process_events(); } + } - void on_connect() - { - assert(idx < workers.size()); + void shutdown() { + alive.store(false); - logger.trace("on connect"); + for (auto& worker : workers) worker->thread.join(); + } - if(UNLIKELY(!workers[idx]->accept(this->socket))) - return; + void on_connect() { + assert(idx < workers.size()); - idx = idx == workers.size() - 1 ? 0 : idx + 1; - } + logger.trace("on connect"); - void on_wait_timeout() {} + if (UNLIKELY(!workers[idx]->accept(this->socket))) return; -private: - Bolt bolt; + idx = idx == workers.size() - 1 ? 0 : idx + 1; + } - std::vector<typename Worker::sptr> workers; - std::atomic<bool> alive {true}; + void on_wait_timeout() {} - int idx {0}; - Logger logger; + private: + Bolt bolt; + + std::vector<typename Worker::sptr> workers; + std::atomic<bool> alive{true}; + + int idx{0}; + Logger logger; }; - } diff --git a/src/communication/bolt/v1/server/worker.hpp b/src/communication/bolt/v1/server/worker.hpp index fbcaf2d45..afbdfc697 100644 --- a/src/communication/bolt/v1/server/worker.hpp +++ b/src/communication/bolt/v1/server/worker.hpp @@ -12,103 +12,92 @@ #include "io/network/stream_reader.hpp" #include "logging/default.hpp" -namespace bolt -{ +namespace bolt { template <class Worker> class Server; -class Worker : public io::StreamReader<Worker, Session> -{ - friend class bolt::Server<Worker>; +class Worker : public io::StreamReader<Worker, Session> { + friend class bolt::Server<Worker>; -public: - using sptr = std::shared_ptr<Worker>; + public: + using sptr = std::shared_ptr<Worker>; - Worker(Bolt &bolt) : bolt(bolt) - { - logger = logging::log->logger("bolt::Worker"); - } + Worker(Bolt &bolt) : bolt(bolt) { + logger = logging::log->logger("bolt::Worker"); + } - Session &on_connect(io::Socket &&socket) - { - logger.trace("Accepting connection on socket {}", socket.id()); + Session &on_connect(io::Socket &&socket) { + logger.trace("Accepting connection on socket {}", socket.id()); - return *bolt.get().create_session(std::forward<io::Socket>(socket)); - } + return *bolt.get().create_session(std::forward<io::Socket>(socket)); + } - void on_error(Session &) - { - logger.trace("[on_error] errno = {}", errno); + void on_error(Session &) { + logger.trace("[on_error] errno = {}", errno); #ifndef NDEBUG - auto err = io::NetworkError(""); - logger.debug("{}", err.what()); + auto err = io::NetworkError(""); + logger.debug("{}", err.what()); #endif - logger.error("Error occured in this session"); - } + logger.error("Error occured in this session"); + } - void on_wait_timeout() {} + void on_wait_timeout() {} - Buffer on_alloc(Session &) - { - /* logger.trace("[on_alloc] Allocating {}B", sizeof buf); */ + Buffer on_alloc(Session &) { + /* logger.trace("[on_alloc] Allocating {}B", sizeof buf); */ - return Buffer{buf, sizeof buf}; - } + return Buffer{buf, sizeof buf}; + } - void on_read(Session &session, Buffer &buf) - { - logger.trace("[on_read] Received {}B", buf.len); + void on_read(Session &session, Buffer &buf) { + logger.trace("[on_read] Received {}B", buf.len); #ifndef NDEBUG - std::stringstream stream; + std::stringstream stream; - for (size_t i = 0; i < buf.len; ++i) - stream << fmt::format("{:02X} ", static_cast<byte>(buf.ptr[i])); + for (size_t i = 0; i < buf.len; ++i) + stream << fmt::format("{:02X} ", static_cast<byte>(buf.ptr[i])); - logger.trace("[on_read] {}", stream.str()); + logger.trace("[on_read] {}", stream.str()); #endif - try { - session.execute(reinterpret_cast<const byte *>(buf.ptr), buf.len); - } catch (const std::exception &e) { - logger.error("Error occured while executing statement."); - logger.error("{}", e.what()); - // TODO: report to client - } + try { + session.execute(reinterpret_cast<const byte *>(buf.ptr), buf.len); + } catch (const std::exception &e) { + logger.error("Error occured while executing statement."); + logger.error("{}", e.what()); + // TODO: report to client } + } - void on_close(Session &session) - { - logger.trace("[on_close] Client closed the connection"); - session.close(); - } + void on_close(Session &session) { + logger.trace("[on_close] Client closed the connection"); + session.close(); + } - template <class... Args> - void on_exception(Session &session, Args &&... args) - { - logger.error("Error occured in this session"); - logger.error(args...); + template <class... Args> + void on_exception(Session &session, Args &&... args) { + logger.error("Error occured in this session"); + logger.error(args...); - // TODO: Do something about it - } + // TODO: Do something about it + } - char buf[65536]; + char buf[65536]; -protected: - std::reference_wrapper<Bolt> bolt; + protected: + std::reference_wrapper<Bolt> bolt; - Logger logger; - std::thread thread; + Logger logger; + std::thread thread; - void start(std::atomic<bool> &alive) - { - thread = std::thread([&, this]() { - while (alive) - wait_and_process_events(); - }); - } + void start(std::atomic<bool> &alive) { + thread = std::thread([&, this]() { + while (alive) wait_and_process_events(); + }); + } }; } diff --git a/src/communication/bolt/v1/session.cpp b/src/communication/bolt/v1/session.cpp index d1303bdf9..09146ada5 100644 --- a/src/communication/bolt/v1/session.cpp +++ b/src/communication/bolt/v1/session.cpp @@ -1,46 +1,42 @@ #include "communication/bolt/v1/session.hpp" -namespace bolt -{ +namespace bolt { Session::Session(io::Socket &&socket, Bolt &bolt) - : Stream(std::forward<io::Socket>(socket)), bolt(bolt) -{ - logger = logging::log->logger("Session"); + : Stream(std::forward<io::Socket>(socket)), bolt(bolt) { + logger = logging::log->logger("Session"); - // start with a handshake state - state = bolt.states.handshake.get(); + // start with a handshake state + state = bolt.states.handshake.get(); } bool Session::alive() const { return state != nullptr; } -void Session::execute(const byte *data, size_t len) -{ - // mark the end of the message - auto end = data + len; +void Session::execute(const byte *data, size_t len) { + // mark the end of the message + auto end = data + len; - while (true) { - auto size = end - data; + while (true) { + auto size = end - data; - if (LIKELY(connected)) { - logger.debug("Decoding chunk of size {}", size); - auto finished = decoder.decode(data, size); + if (LIKELY(connected)) { + logger.debug("Decoding chunk of size {}", size); + auto finished = decoder.decode(data, size); - if (!finished) return; - } else { - logger.debug("Decoding handshake of size {}", size); - decoder.handshake(data, size); - } - - state = state->run(*this); - decoder.reset(); + if (!finished) return; + } else { + logger.debug("Decoding handshake of size {}", size); + decoder.handshake(data, size); } + + state = state->run(*this); + decoder.reset(); + } } -void Session::close() -{ - logger.debug("Closing session"); - bolt.close(this); +void Session::close() { + logger.debug("Closing session"); + bolt.close(this); } GraphDbAccessor Session::active_db() { return bolt.dbms.active(); } diff --git a/src/communication/bolt/v1/session.hpp b/src/communication/bolt/v1/session.hpp index 6f58c4d43..387e16f56 100644 --- a/src/communication/bolt/v1/session.hpp +++ b/src/communication/bolt/v1/session.hpp @@ -3,41 +3,41 @@ #include "io/network/socket.hpp" #include "io/network/tcp/stream.hpp" +#include "communication/bolt/communication.hpp" #include "communication/bolt/v1/bolt.hpp" #include "communication/bolt/v1/serialization/record_stream.hpp" #include "communication/bolt/v1/states/state.hpp" #include "communication/bolt/v1/transport/bolt_decoder.hpp" #include "communication/bolt/v1/transport/bolt_encoder.hpp" -#include "communication/bolt/communication.hpp" #include "logging/default.hpp" namespace bolt { - class Session : public io::tcp::Stream<io::Socket> { - public: - using Decoder = BoltDecoder; - using OutputStream = communication::OutputStream; +class Session : public io::tcp::Stream<io::Socket> { + public: + using Decoder = BoltDecoder; + using OutputStream = communication::OutputStream; - Session(io::Socket &&socket, Bolt &bolt); + Session(io::Socket &&socket, Bolt &bolt); - bool alive() const; + bool alive() const; - void execute(const byte *data, size_t len); + void execute(const byte *data, size_t len); - void close(); + void close(); - Bolt &bolt; + Bolt &bolt; - GraphDbAccessor active_db(); + GraphDbAccessor active_db(); - Decoder decoder; - OutputStream output_stream{socket}; + Decoder decoder; + OutputStream output_stream{socket}; - bool connected{false}; - State *state; + bool connected{false}; + State *state; - protected: - Logger logger; - }; + protected: + Logger logger; +}; } diff --git a/src/communication/bolt/v1/states.cpp b/src/communication/bolt/v1/states.cpp index 12d001aca..e30592a2c 100644 --- a/src/communication/bolt/v1/states.cpp +++ b/src/communication/bolt/v1/states.cpp @@ -1,19 +1,16 @@ #include "communication/bolt/v1/states.hpp" -#include "communication/bolt/v1/states/handshake.hpp" -#include "communication/bolt/v1/states/init.hpp" #include "communication/bolt/v1/states/error.hpp" #include "communication/bolt/v1/states/executor.hpp" +#include "communication/bolt/v1/states/handshake.hpp" +#include "communication/bolt/v1/states/init.hpp" -namespace bolt -{ +namespace bolt { -States::States() -{ - handshake = std::make_unique<Handshake>(); - init = std::make_unique<Init>(); - executor = std::make_unique<Executor>(); - error = std::make_unique<Error>(); +States::States() { + handshake = std::make_unique<Handshake>(); + init = std::make_unique<Init>(); + executor = std::make_unique<Executor>(); + error = std::make_unique<Error>(); } - } diff --git a/src/communication/bolt/v1/states.hpp b/src/communication/bolt/v1/states.hpp index d15a1b747..3849e0d64 100644 --- a/src/communication/bolt/v1/states.hpp +++ b/src/communication/bolt/v1/states.hpp @@ -3,18 +3,15 @@ #include "communication/bolt/v1/states/state.hpp" #include "logging/log.hpp" -namespace bolt -{ +namespace bolt { -class States -{ -public: - States(); +class States { + public: + States(); - State::uptr handshake; - State::uptr init; - State::uptr executor; - State::uptr error; + State::uptr handshake; + State::uptr init; + State::uptr executor; + State::uptr error; }; - } diff --git a/src/communication/bolt/v1/states/error.cpp b/src/communication/bolt/v1/states/error.cpp index 27f6bb339..cd78a7906 100644 --- a/src/communication/bolt/v1/states/error.cpp +++ b/src/communication/bolt/v1/states/error.cpp @@ -1,55 +1,47 @@ #include "communication/bolt/v1/states/error.hpp" -namespace bolt -{ +namespace bolt { Error::Error() : State(logging::log->logger("Error State")) {} -State* Error::run(Session& session) -{ - logger.trace("Run"); +State* Error::run(Session& session) { + logger.trace("Run"); - session.decoder.read_byte(); - auto message_type = session.decoder.read_byte(); + session.decoder.read_byte(); + auto message_type = session.decoder.read_byte(); - logger.trace("Message type byte is: {:02X}", message_type); + logger.trace("Message type byte is: {:02X}", message_type); - if (message_type == MessageCode::PullAll) - { - session.output_stream.write_ignored(); - session.output_stream.chunk(); - session.output_stream.send(); - return this; - } - else if(message_type == MessageCode::AckFailure) - { - // TODO reset current statement? is it even necessary? - logger.trace("AckFailure received"); - - session.output_stream.write_success_empty(); - session.output_stream.chunk(); - session.output_stream.send(); - - return session.bolt.states.executor.get(); - } - else if(message_type == MessageCode::Reset) - { - // TODO rollback current transaction - // discard all records waiting to be sent - - session.output_stream.write_success_empty(); - session.output_stream.chunk(); - session.output_stream.send(); - - return session.bolt.states.executor.get(); - } - - // TODO: write this as single call + if (message_type == MessageCode::PullAll) { session.output_stream.write_ignored(); session.output_stream.chunk(); session.output_stream.send(); - return this; -} + } else if (message_type == MessageCode::AckFailure) { + // TODO reset current statement? is it even necessary? + logger.trace("AckFailure received"); + session.output_stream.write_success_empty(); + session.output_stream.chunk(); + session.output_stream.send(); + + return session.bolt.states.executor.get(); + } else if (message_type == MessageCode::Reset) { + // TODO rollback current transaction + // discard all records waiting to be sent + + session.output_stream.write_success_empty(); + session.output_stream.chunk(); + session.output_stream.send(); + + return session.bolt.states.executor.get(); + } + + // TODO: write this as single call + session.output_stream.write_ignored(); + session.output_stream.chunk(); + session.output_stream.send(); + + return this; +} } diff --git a/src/communication/bolt/v1/states/error.hpp b/src/communication/bolt/v1/states/error.hpp index 6c9b37d6c..ec2bc306e 100644 --- a/src/communication/bolt/v1/states/error.hpp +++ b/src/communication/bolt/v1/states/error.hpp @@ -3,15 +3,12 @@ #include "communication/bolt/v1/session.hpp" #include "communication/bolt/v1/states/state.hpp" -namespace bolt -{ +namespace bolt { -class Error : public State -{ -public: - Error(); +class Error : public State { + public: + Error(); - State *run(Session &session) override; + State *run(Session &session) override; }; - } diff --git a/src/communication/bolt/v1/states/executor.cpp b/src/communication/bolt/v1/states/executor.cpp index fb79e1752..b5cbc028b 100644 --- a/src/communication/bolt/v1/states/executor.cpp +++ b/src/communication/bolt/v1/states/executor.cpp @@ -6,112 +6,93 @@ #include "barrier/barrier.cpp" #endif -namespace bolt -{ +namespace bolt { Executor::Executor() : State(logging::log->logger("Executor")) {} -State *Executor::run(Session &session) -{ - // just read one byte that represents the struct type, we can skip the - // information contained in this byte - session.decoder.read_byte(); +State *Executor::run(Session &session) { + // just read one byte that represents the struct type, we can skip the + // information contained in this byte + session.decoder.read_byte(); - logger.debug("Run"); + logger.debug("Run"); - auto message_type = session.decoder.read_byte(); + auto message_type = session.decoder.read_byte(); - if (message_type == MessageCode::Run) - { - Query q; + if (message_type == MessageCode::Run) { + Query q; - q.statement = session.decoder.read_string(); + q.statement = session.decoder.read_string(); - try - { - return this->run(session, q); - // TODO: RETURN success MAYBE - } - catch (const QueryEngineException &e) - { - session.output_stream.write_failure( - {{"code", "Memgraph.QueryEngineException"}, - {"message", e.what()}}); - session.output_stream.send(); - return session.bolt.states.error.get(); - } catch (std::exception &e) { - session.output_stream.write_failure( - {{"code", "Memgraph.Exception"}, - {"message", e.what()}}); - session.output_stream.send(); - return session.bolt.states.error.get(); - } + try { + return this->run(session, q); + // TODO: RETURN success MAYBE + } catch (const QueryEngineException &e) { + session.output_stream.write_failure( + {{"code", "Memgraph.QueryEngineException"}, {"message", e.what()}}); + session.output_stream.send(); + return session.bolt.states.error.get(); + } catch (std::exception &e) { + session.output_stream.write_failure( + {{"code", "Memgraph.Exception"}, {"message", e.what()}}); + session.output_stream.send(); + return session.bolt.states.error.get(); } - else if (message_type == MessageCode::PullAll) - { - pull_all(session); - } - else if (message_type == MessageCode::DiscardAll) - { - discard_all(session); - } - else if (message_type == MessageCode::Reset) - { - // TODO: rollback current transaction - // discard all records waiting to be sent - return this; - } - else - { - logger.error("Unrecognized message recieved"); - logger.debug("Invalid message type 0x{:02X}", message_type); - - return session.bolt.states.error.get(); - } - + } else if (message_type == MessageCode::PullAll) { + pull_all(session); + } else if (message_type == MessageCode::DiscardAll) { + discard_all(session); + } else if (message_type == MessageCode::Reset) { + // TODO: rollback current transaction + // discard all records waiting to be sent return this; + } else { + logger.error("Unrecognized message recieved"); + logger.debug("Invalid message type 0x{:02X}", message_type); + + return session.bolt.states.error.get(); + } + + return this; } -State *Executor::run(Session &session, Query &query) -{ - logger.trace("[Run] '{}'", query.statement); +State *Executor::run(Session &session, Query &query) { + logger.trace("[Run] '{}'", query.statement); - auto db_accessor = session.active_db(); - logger.debug("[ActiveDB] '{}'", db_accessor.name()); + auto db_accessor = session.active_db(); + logger.debug("[ActiveDB] '{}'", db_accessor.name()); - auto is_successfully_executed = - query_engine.Run(query.statement, db_accessor, session.output_stream); - - if (!is_successfully_executed) - { - session.output_stream.write_failure( - {{"code", "Memgraph.QueryExecutionFail"}, - {"message", "Query execution has failed (probably there is no " - "element or there are some problems with concurrent " - "access -> client has to resolve problems with " - "concurrent access)"}}); - session.output_stream.send(); - return session.bolt.states.error.get(); - } - - return this; -} - -void Executor::pull_all(Session &session) -{ - logger.trace("[PullAll]"); + auto is_successfully_executed = + query_engine.Run(query.statement, db_accessor, session.output_stream); + if (!is_successfully_executed) { + session.output_stream.write_failure( + {{"code", "Memgraph.QueryExecutionFail"}, + {"message", + "Query execution has failed (probably there is no " + "element or there are some problems with concurrent " + "access -> client has to resolve problems with " + "concurrent access)"}}); session.output_stream.send(); + return session.bolt.states.error.get(); + } + + return this; } -void Executor::discard_all(Session &session) -{ - logger.trace("[DiscardAll]"); +void Executor::pull_all(Session &session) { + logger.trace("[PullAll]"); - // TODO: discard state + session.output_stream.send(); +} - session.output_stream.write_success(); - session.output_stream.chunk(); - session.output_stream.send(); +void Executor::discard_all(Session &session) { + logger.trace("[DiscardAll]"); + + // TODO: discard state + + session.output_stream.write_success(); + session.output_stream.chunk(); + session.output_stream.send(); } } diff --git a/src/communication/bolt/v1/states/executor.hpp b/src/communication/bolt/v1/states/executor.hpp index 80d4da949..92b4ae651 100644 --- a/src/communication/bolt/v1/states/executor.hpp +++ b/src/communication/bolt/v1/states/executor.hpp @@ -1,44 +1,38 @@ #pragma once -#include "communication/bolt/v1/states/state.hpp" #include "communication/bolt/v1/session.hpp" +#include "communication/bolt/v1/states/state.hpp" #include "query/engine.hpp" -namespace bolt -{ +namespace bolt { -class Executor : public State -{ - struct Query - { - std::string statement; - }; +class Executor : public State { + struct Query { + std::string statement; + }; -public: - Executor(); + public: + Executor(); - State* run(Session& session) override final; + State* run(Session& session) override final; -protected: - /* Execute an incoming query - * - */ - State* run(Session& session, Query& query); + protected: + /* Execute an incoming query + * + */ + State* run(Session& session, Query& query); - /* Send all remaining results to the client - * - */ - void pull_all(Session& session); + /* Send all remaining results to the client + * + */ + void pull_all(Session& session); - /* Discard all remaining results - * - */ - void discard_all(Session& session); - -private: - QueryEngine<communication::OutputStream> query_engine; + /* Discard all remaining results + * + */ + void discard_all(Session& session); + private: + QueryEngine<communication::OutputStream> query_engine; }; - } - diff --git a/src/communication/bolt/v1/states/handshake.cpp b/src/communication/bolt/v1/states/handshake.cpp index aba159361..c7f3767aa 100644 --- a/src/communication/bolt/v1/states/handshake.cpp +++ b/src/communication/bolt/v1/states/handshake.cpp @@ -2,8 +2,7 @@ #include "communication/bolt/v1/session.hpp" -namespace bolt -{ +namespace bolt { static constexpr uint32_t preamble = 0x6060B017; @@ -11,21 +10,18 @@ static constexpr byte protocol[4] = {0x00, 0x00, 0x00, 0x01}; Handshake::Handshake() : State(logging::log->logger("Handshake")) {} -State* Handshake::run(Session& session) -{ - logger.debug("run"); +State* Handshake::run(Session& session) { + logger.debug("run"); - if(UNLIKELY(session.decoder.read_uint32() != preamble)) - return nullptr; + if (UNLIKELY(session.decoder.read_uint32() != preamble)) return nullptr; - // TODO so far we only support version 1 of the protocol so it doesn't - // make sense to check which version the client prefers - // this will change in the future + // TODO so far we only support version 1 of the protocol so it doesn't + // make sense to check which version the client prefers + // this will change in the future - session.connected = true; - session.socket.write(protocol, sizeof protocol); + session.connected = true; + session.socket.write(protocol, sizeof protocol); - return session.bolt.states.init.get(); + return session.bolt.states.init.get(); } - } diff --git a/src/communication/bolt/v1/states/handshake.hpp b/src/communication/bolt/v1/states/handshake.hpp index e5967dc46..422cc97ae 100644 --- a/src/communication/bolt/v1/states/handshake.hpp +++ b/src/communication/bolt/v1/states/handshake.hpp @@ -2,14 +2,11 @@ #include "communication/bolt/v1/states/state.hpp" -namespace bolt -{ +namespace bolt { -class Handshake : public State -{ -public: - Handshake(); - State* run(Session& session) override; +class Handshake : public State { + public: + Handshake(); + State* run(Session& session) override; }; - } diff --git a/src/communication/bolt/v1/states/init.cpp b/src/communication/bolt/v1/states/init.cpp index bc76eafa5..c35c10828 100644 --- a/src/communication/bolt/v1/states/init.cpp +++ b/src/communication/bolt/v1/states/init.cpp @@ -5,53 +5,50 @@ #include "utils/likely.hpp" -namespace bolt -{ +namespace bolt { Init::Init() : MessageParser<Init>(logging::log->logger("Init")) {} -State *Init::parse(Session &session, Message &message) -{ - logger.debug("bolt::Init.parse()"); +State *Init::parse(Session &session, Message &message) { + logger.debug("bolt::Init.parse()"); - auto struct_type = session.decoder.read_byte(); + auto struct_type = session.decoder.read_byte(); - if (UNLIKELY((struct_type & 0x0F) > pack::Rule::MaxInitStructSize)) { - logger.debug("{}", struct_type); + if (UNLIKELY((struct_type & 0x0F) > pack::Rule::MaxInitStructSize)) { + logger.debug("{}", struct_type); - logger.debug( - "Expected struct marker of max size 0x{:02} instead of 0x{:02X}", - (unsigned)pack::Rule::MaxInitStructSize, (unsigned)struct_type); + logger.debug( + "Expected struct marker of max size 0x{:02} instead of 0x{:02X}", + (unsigned)pack::Rule::MaxInitStructSize, (unsigned)struct_type); - return nullptr; - } + return nullptr; + } - auto message_type = session.decoder.read_byte(); + auto message_type = session.decoder.read_byte(); - if (UNLIKELY(message_type != MessageCode::Init)) { - logger.debug("Expected Init (0x01) instead of (0x{:02X})", - (unsigned)message_type); + if (UNLIKELY(message_type != MessageCode::Init)) { + logger.debug("Expected Init (0x01) instead of (0x{:02X})", + (unsigned)message_type); - return nullptr; - } + return nullptr; + } - message.client_name = session.decoder.read_string(); + message.client_name = session.decoder.read_string(); - if (struct_type == pack::Code::StructTwo) { - // TODO process authentication tokens - } + if (struct_type == pack::Code::StructTwo) { + // TODO process authentication tokens + } - return this; + return this; } -State *Init::execute(Session &session, Message &message) -{ - logger.debug("Client connected '{}'", message.client_name); +State *Init::execute(Session &session, Message &message) { + logger.debug("Client connected '{}'", message.client_name); - session.output_stream.write_success_empty(); - session.output_stream.chunk(); - session.output_stream.send(); + session.output_stream.write_success_empty(); + session.output_stream.chunk(); + session.output_stream.send(); - return session.bolt.states.executor.get(); + return session.bolt.states.executor.get(); } } diff --git a/src/communication/bolt/v1/states/init.hpp b/src/communication/bolt/v1/states/init.hpp index b471e078d..734f36f44 100644 --- a/src/communication/bolt/v1/states/init.hpp +++ b/src/communication/bolt/v1/states/init.hpp @@ -2,21 +2,17 @@ #include "communication/bolt/v1/states/message_parser.hpp" -namespace bolt -{ +namespace bolt { -class Init : public MessageParser<Init> -{ -public: - struct Message - { - std::string client_name; - }; +class Init : public MessageParser<Init> { + public: + struct Message { + std::string client_name; + }; - Init(); + Init(); - State* parse(Session& session, Message& message); - State* execute(Session& session, Message& message); + State* parse(Session& session, Message& message); + State* execute(Session& session, Message& message); }; - } diff --git a/src/communication/bolt/v1/states/message_parser.hpp b/src/communication/bolt/v1/states/message_parser.hpp index 0c86753b1..75d8d6943 100644 --- a/src/communication/bolt/v1/states/message_parser.hpp +++ b/src/communication/bolt/v1/states/message_parser.hpp @@ -4,30 +4,27 @@ #include "communication/bolt/v1/states/state.hpp" #include "utils/crtp.hpp" -namespace bolt -{ +namespace bolt { template <class Derived> -class MessageParser : public State, public Crtp<Derived> -{ -public: - MessageParser(Logger &&logger) : logger(std::forward<Logger>(logger)) {} +class MessageParser : public State, public Crtp<Derived> { + public: + MessageParser(Logger &&logger) : logger(std::forward<Logger>(logger)) {} - State *run(Session &session) override final - { - typename Derived::Message message; + State *run(Session &session) override final { + typename Derived::Message message; - logger.debug("Parsing message"); - auto next = this->derived().parse(session, message); + logger.debug("Parsing message"); + auto next = this->derived().parse(session, message); - // return next state if parsing was unsuccessful (i.e. error state) - if (next != &this->derived()) return next; + // return next state if parsing was unsuccessful (i.e. error state) + if (next != &this->derived()) return next; - logger.debug("Executing state"); - return this->derived().execute(session, message); - } + logger.debug("Executing state"); + return this->derived().execute(session, message); + } -protected: - Logger logger; + protected: + Logger logger; }; } diff --git a/src/communication/bolt/v1/states/state.hpp b/src/communication/bolt/v1/states/state.hpp index 2915cc29d..3321fc32b 100644 --- a/src/communication/bolt/v1/states/state.hpp +++ b/src/communication/bolt/v1/states/state.hpp @@ -1,30 +1,27 @@ #pragma once -#include <cstdlib> #include <cstdint> +#include <cstdlib> #include <memory> #include "logging/default.hpp" -namespace bolt -{ +namespace bolt { class Session; -class State -{ -public: - using uptr = std::unique_ptr<State>; +class State { + public: + using uptr = std::unique_ptr<State>; - State() = default; - State(Logger logger) : logger(logger) {} + State() = default; + State(Logger logger) : logger(logger) {} - virtual ~State() = default; + virtual ~State() = default; - virtual State* run(Session& session) = 0; + virtual State* run(Session& session) = 0; -protected: - Logger logger; + protected: + Logger logger; }; - } diff --git a/src/communication/bolt/v1/transport/bolt_decoder.cpp b/src/communication/bolt/v1/transport/bolt_decoder.cpp index 973ce5989..da36a3f9f 100644 --- a/src/communication/bolt/v1/transport/bolt_decoder.cpp +++ b/src/communication/bolt/v1/transport/bolt_decoder.cpp @@ -4,59 +4,52 @@ #include "logging/default.hpp" #include "utils/bswap.hpp" -namespace bolt -{ +namespace bolt { -void BoltDecoder::handshake(const byte *&data, size_t len) -{ - buffer.write(data, len); - data += len; +void BoltDecoder::handshake(const byte *&data, size_t len) { + buffer.write(data, len); + data += len; } -bool BoltDecoder::decode(const byte *&data, size_t len) -{ - return decoder(data, len); +bool BoltDecoder::decode(const byte *&data, size_t len) { + return decoder(data, len); } bool BoltDecoder::empty() const { return pos == buffer.size(); } -void BoltDecoder::reset() -{ - buffer.clear(); - pos = 0; +void BoltDecoder::reset() { + buffer.clear(); + pos = 0; } byte BoltDecoder::peek() const { return buffer[pos]; } byte BoltDecoder::read_byte() { return buffer[pos++]; } -void BoltDecoder::read_bytes(void *dest, size_t n) -{ - std::memcpy(dest, buffer.data() + pos, n); - pos += n; +void BoltDecoder::read_bytes(void *dest, size_t n) { + std::memcpy(dest, buffer.data() + pos, n); + pos += n; } template <class T> -T parse(const void *data) -{ - // reinterpret bytes as the target value - auto value = reinterpret_cast<const T *>(data); +T parse(const void *data) { + // reinterpret bytes as the target value + auto value = reinterpret_cast<const T *>(data); - // swap values to little endian - return bswap(*value); + // swap values to little endian + return bswap(*value); } template <class T> -T parse(Buffer &buffer, size_t &pos) -{ - // get a pointer to the data we're converting - auto ptr = buffer.data() + pos; +T parse(Buffer &buffer, size_t &pos) { + // get a pointer to the data we're converting + auto ptr = buffer.data() + pos; - // skip sizeof bytes that we're going to read - pos += sizeof(T); + // skip sizeof bytes that we're going to read + pos += sizeof(T); - // read and convert the value - return parse<T>(ptr); + // read and convert the value + return parse<T>(ptr); } int16_t BoltDecoder::read_int16() { return parse<int16_t>(buffer, pos); } @@ -71,46 +64,44 @@ int64_t BoltDecoder::read_int64() { return parse<int64_t>(buffer, pos); } uint64_t BoltDecoder::read_uint64() { return parse<uint64_t>(buffer, pos); } -double BoltDecoder::read_float64() -{ - auto v = parse<int64_t>(buffer, pos); - return *reinterpret_cast<const double *>(&v); +double BoltDecoder::read_float64() { + auto v = parse<int64_t>(buffer, pos); + return *reinterpret_cast<const double *>(&v); } -std::string BoltDecoder::read_string() -{ - auto marker = read_byte(); +std::string BoltDecoder::read_string() { + auto marker = read_byte(); - std::string res; - uint32_t size; - - // if the first 4 bits equal to 1000 (0x8), this is a tiny string - if ((marker & 0xF0) == pack::TinyString) { - // size is stored in the lower 4 bits of the marker byte - size = marker & 0x0F; - } - // if the marker is 0xD0, size is an 8-bit unsigned integer - else if (marker == pack::String8) { - size = read_byte(); - } - // if the marker is 0xD1, size is a 16-bit big-endian unsigned integer - else if (marker == pack::String16) { - size = read_uint16(); - } - // if the marker is 0xD2, size is a 32-bit big-endian unsigned integer - else if (marker == pack::String32) { - size = read_uint32(); - } else { - // TODO error? - return res; - } - - if (size == 0) return res; - - res.append(reinterpret_cast<const char *>(raw()), size); - pos += size; + std::string res; + uint32_t size; + // if the first 4 bits equal to 1000 (0x8), this is a tiny string + if ((marker & 0xF0) == pack::TinyString) { + // size is stored in the lower 4 bits of the marker byte + size = marker & 0x0F; + } + // if the marker is 0xD0, size is an 8-bit unsigned integer + else if (marker == pack::String8) { + size = read_byte(); + } + // if the marker is 0xD1, size is a 16-bit big-endian unsigned integer + else if (marker == pack::String16) { + size = read_uint16(); + } + // if the marker is 0xD2, size is a 32-bit big-endian unsigned integer + else if (marker == pack::String32) { + size = read_uint32(); + } else { + // TODO error? return res; + } + + if (size == 0) return res; + + res.append(reinterpret_cast<const char *>(raw()), size); + pos += size; + + return res; } const byte *BoltDecoder::raw() const { return buffer.data() + pos; } diff --git a/src/communication/bolt/v1/transport/bolt_decoder.hpp b/src/communication/bolt/v1/transport/bolt_decoder.hpp index d80f3dc31..d752671bc 100644 --- a/src/communication/bolt/v1/transport/bolt_decoder.hpp +++ b/src/communication/bolt/v1/transport/bolt_decoder.hpp @@ -4,40 +4,38 @@ #include "communication/bolt/v1/transport/chunked_decoder.hpp" #include "utils/types/byte.hpp" -namespace bolt -{ +namespace bolt { -class BoltDecoder -{ -public: - void handshake(const byte *&data, size_t len); - bool decode(const byte *&data, size_t len); +class BoltDecoder { + public: + void handshake(const byte *&data, size_t len); + bool decode(const byte *&data, size_t len); - bool empty() const; - void reset(); + bool empty() const; + void reset(); - byte peek() const; - byte read_byte(); - void read_bytes(void *dest, size_t n); + byte peek() const; + byte read_byte(); + void read_bytes(void *dest, size_t n); - int16_t read_int16(); - uint16_t read_uint16(); + int16_t read_int16(); + uint16_t read_uint16(); - int32_t read_int32(); - uint32_t read_uint32(); + int32_t read_int32(); + uint32_t read_uint32(); - int64_t read_int64(); - uint64_t read_uint64(); + int64_t read_int64(); + uint64_t read_uint64(); - double read_float64(); + double read_float64(); - std::string read_string(); + std::string read_string(); -private: - Buffer buffer; - ChunkedDecoder<Buffer> decoder{buffer}; - size_t pos{0}; + private: + Buffer buffer; + ChunkedDecoder<Buffer> decoder{buffer}; + size_t pos{0}; - const byte *raw() const; + const byte *raw() const; }; } diff --git a/src/communication/bolt/v1/transport/bolt_encoder.hpp b/src/communication/bolt/v1/transport/bolt_encoder.hpp index 1637a36d4..fdd54ddb3 100644 --- a/src/communication/bolt/v1/transport/bolt_encoder.hpp +++ b/src/communication/bolt/v1/transport/bolt_encoder.hpp @@ -8,212 +8,189 @@ #include "utils/bswap.hpp" #include "utils/types/byte.hpp" -namespace bolt -{ +namespace bolt { template <class Stream> -class BoltEncoder -{ - static constexpr int64_t plus_2_to_the_31 = 2147483648L; - static constexpr int64_t plus_2_to_the_15 = 32768L; - static constexpr int64_t plus_2_to_the_7 = 128L; - static constexpr int64_t minus_2_to_the_4 = -16L; - static constexpr int64_t minus_2_to_the_7 = -128L; - static constexpr int64_t minus_2_to_the_15 = -32768L; - static constexpr int64_t minus_2_to_the_31 = -2147483648L; +class BoltEncoder { + static constexpr int64_t plus_2_to_the_31 = 2147483648L; + static constexpr int64_t plus_2_to_the_15 = 32768L; + static constexpr int64_t plus_2_to_the_7 = 128L; + static constexpr int64_t minus_2_to_the_4 = -16L; + static constexpr int64_t minus_2_to_the_7 = -128L; + static constexpr int64_t minus_2_to_the_15 = -32768L; + static constexpr int64_t minus_2_to_the_31 = -2147483648L; -public: - BoltEncoder(Stream &stream) : stream(stream) - { - logger = logging::log->logger("Bolt Encoder"); + public: + BoltEncoder(Stream &stream) : stream(stream) { + logger = logging::log->logger("Bolt Encoder"); + } + + void write(byte value) { write_byte(value); } + + void write_byte(byte value) { + logger.trace("write byte: {}", value); + stream.write(value); + } + + void write(const byte *values, size_t n) { stream.write(values, n); } + + void write_null() { stream.write(pack::Null); } + + void write(bool value) { write_bool(value); } + + void write_bool(bool value) { + if (value) + write_true(); + else + write_false(); + } + + void write_true() { stream.write(pack::True); } + + void write_false() { stream.write(pack::False); } + + template <class T> + void write_value(T value) { + value = bswap(value); + stream.write(reinterpret_cast<const byte *>(&value), sizeof(value)); + } + + void write_integer(int64_t value) { + if (value >= minus_2_to_the_4 && value < plus_2_to_the_7) { + write(static_cast<byte>(value)); + } else if (value >= minus_2_to_the_7 && value < minus_2_to_the_4) { + write(pack::Int8); + write(static_cast<byte>(value)); + } else if (value >= minus_2_to_the_15 && value < plus_2_to_the_15) { + write(pack::Int16); + write_value(static_cast<int16_t>(value)); + } else if (value >= minus_2_to_the_31 && value < plus_2_to_the_31) { + write(pack::Int32); + write_value(static_cast<int32_t>(value)); + } else { + write(pack::Int64); + write_value(value); } + } - void write(byte value) { write_byte(value); } + void write(double value) { write_double(value); } - void write_byte(byte value) - { - logger.trace("write byte: {}", value); - stream.write(value); + void write_double(double value) { + write(pack::Float64); + write_value(*reinterpret_cast<const int64_t *>(&value)); + } + + void write_map_header(size_t size) { + if (size < 0x10) { + write(static_cast<byte>(pack::TinyMap | size)); + } else if (size <= 0xFF) { + write(pack::Map8); + write(static_cast<byte>(size)); + } else if (size <= 0xFFFF) { + write(pack::Map16); + write_value<uint16_t>(size); + } else { + write(pack::Map32); + write_value<uint32_t>(size); } + } - void write(const byte *values, size_t n) { stream.write(values, n); } + void write_empty_map() { write(pack::TinyMap); } - void write_null() { stream.write(pack::Null); } - - void write(bool value) { write_bool(value); } - - void write_bool(bool value) - { - if (value) - write_true(); - else - write_false(); + void write_list_header(size_t size) { + if (size < 0x10) { + write(static_cast<byte>(pack::TinyList | size)); + } else if (size <= 0xFF) { + write(pack::List8); + write(static_cast<byte>(size)); + } else if (size <= 0xFFFF) { + write(pack::List16); + write_value<uint16_t>(size); + } else { + write(pack::List32); + write_value<uint32_t>(size); } + } - void write_true() { stream.write(pack::True); } + void write_empty_list() { write(pack::TinyList); } - void write_false() { stream.write(pack::False); } - - template <class T> - void write_value(T value) - { - value = bswap(value); - stream.write(reinterpret_cast<const byte *>(&value), sizeof(value)); + void write_string_header(size_t size) { + if (size < 0x10) { + write(static_cast<byte>(pack::TinyString | size)); + } else if (size <= 0xFF) { + write(pack::String8); + write(static_cast<byte>(size)); + } else if (size <= 0xFFFF) { + write(pack::String16); + write_value<uint16_t>(size); + } else { + write(pack::String32); + write_value<uint32_t>(size); } + } - void write_integer(int64_t value) - { - if (value >= minus_2_to_the_4 && value < plus_2_to_the_7) { - write(static_cast<byte>(value)); - } else if (value >= minus_2_to_the_7 && value < minus_2_to_the_4) { - write(pack::Int8); - write(static_cast<byte>(value)); - } else if (value >= minus_2_to_the_15 && value < plus_2_to_the_15) { - write(pack::Int16); - write_value(static_cast<int16_t>(value)); - } else if (value >= minus_2_to_the_31 && value < plus_2_to_the_31) { - write(pack::Int32); - write_value(static_cast<int32_t>(value)); - } else { - write(pack::Int64); - write_value(value); - } + void write(const std::string &str) { write_string(str); } + + void write_string(const std::string &str) { + write_string(str.c_str(), str.size()); + } + + void write_string(const char *str, size_t len) { + write_string_header(len); + write(reinterpret_cast<const byte *>(str), len); + } + + void write_struct_header(size_t size) { + if (size < 0x10) { + write(static_cast<byte>(pack::TinyStruct | size)); + } else if (size <= 0xFF) { + write(pack::Struct8); + write(static_cast<byte>(size)); + } else { + write(pack::Struct16); + write_value<uint16_t>(size); } + } - void write(double value) { write_double(value); } + void message_success() { + write_struct_header(1); + write(underlying_cast(MessageCode::Success)); + } - void write_double(double value) - { - write(pack::Float64); - write_value(*reinterpret_cast<const int64_t *>(&value)); - } + void message_success_empty() { + message_success(); + write_empty_map(); + } - void write_map_header(size_t size) - { - if (size < 0x10) { - write(static_cast<byte>(pack::TinyMap | size)); - } else if (size <= 0xFF) { - write(pack::Map8); - write(static_cast<byte>(size)); - } else if (size <= 0xFFFF) { - write(pack::Map16); - write_value<uint16_t>(size); - } else { - write(pack::Map32); - write_value<uint32_t>(size); - } - } + void message_record() { + write_struct_header(1); + write(underlying_cast(MessageCode::Record)); + } - void write_empty_map() { write(pack::TinyMap); } + void message_record_empty() { + message_record(); + write_empty_list(); + } - void write_list_header(size_t size) - { - if (size < 0x10) { - write(static_cast<byte>(pack::TinyList | size)); - } else if (size <= 0xFF) { - write(pack::List8); - write(static_cast<byte>(size)); - } else if (size <= 0xFFFF) { - write(pack::List16); - write_value<uint16_t>(size); - } else { - write(pack::List32); - write_value<uint32_t>(size); - } - } + void message_ignored() { + write_struct_header(0); + write(underlying_cast(MessageCode::Ignored)); + } - void write_empty_list() { write(pack::TinyList); } + void message_failure() { + write_struct_header(1); + write(underlying_cast(MessageCode::Failure)); + } - void write_string_header(size_t size) - { - if (size < 0x10) { - write(static_cast<byte>(pack::TinyString | size)); - } else if (size <= 0xFF) { - write(pack::String8); - write(static_cast<byte>(size)); - } else if (size <= 0xFFFF) { - write(pack::String16); - write_value<uint16_t>(size); - } else { - write(pack::String32); - write_value<uint32_t>(size); - } - } + void message_ignored_empty() { + message_ignored(); + write_empty_map(); + } - void write(const std::string& str) { - write_string(str); - } + protected: + Logger logger; - void write_string(const std::string &str) - { - write_string(str.c_str(), str.size()); - } - - void write_string(const char *str, size_t len) - { - write_string_header(len); - write(reinterpret_cast<const byte *>(str), len); - } - - void write_struct_header(size_t size) - { - if (size < 0x10) { - write(static_cast<byte>(pack::TinyStruct | size)); - } else if (size <= 0xFF) { - write(pack::Struct8); - write(static_cast<byte>(size)); - } else { - write(pack::Struct16); - write_value<uint16_t>(size); - } - } - - void message_success() - { - write_struct_header(1); - write(underlying_cast(MessageCode::Success)); - } - - void message_success_empty() - { - message_success(); - write_empty_map(); - } - - void message_record() - { - write_struct_header(1); - write(underlying_cast(MessageCode::Record)); - } - - void message_record_empty() - { - message_record(); - write_empty_list(); - } - - void message_ignored() - { - write_struct_header(0); - write(underlying_cast(MessageCode::Ignored)); - } - - void message_failure() - { - write_struct_header(1); - write(underlying_cast(MessageCode::Failure)); - } - - void message_ignored_empty() - { - message_ignored(); - write_empty_map(); - } - -protected: - Logger logger; - -private: - Stream &stream; + private: + Stream &stream; }; } diff --git a/src/communication/bolt/v1/transport/buffer.cpp b/src/communication/bolt/v1/transport/buffer.cpp index 3406135e6..e5bf838f8 100644 --- a/src/communication/bolt/v1/transport/buffer.cpp +++ b/src/communication/bolt/v1/transport/buffer.cpp @@ -1,16 +1,10 @@ #include "communication/bolt/v1/transport/buffer.hpp" -namespace bolt -{ +namespace bolt { -void Buffer::write(const byte* data, size_t len) -{ - buffer.insert(buffer.end(), data, data + len); -} - -void Buffer::clear() -{ - buffer.clear(); +void Buffer::write(const byte* data, size_t len) { + buffer.insert(buffer.end(), data, data + len); } +void Buffer::clear() { buffer.clear(); } } diff --git a/src/communication/bolt/v1/transport/buffer.hpp b/src/communication/bolt/v1/transport/buffer.hpp index 51dc89ce6..4de68a722 100644 --- a/src/communication/bolt/v1/transport/buffer.hpp +++ b/src/communication/bolt/v1/transport/buffer.hpp @@ -6,34 +6,21 @@ #include "utils/types/byte.hpp" -namespace bolt -{ +namespace bolt { -class Buffer -{ -public: - void write(const byte* data, size_t len); +class Buffer { + public: + void write(const byte* data, size_t len); - void clear(); + void clear(); - size_t size() const - { - return buffer.size(); - } + size_t size() const { return buffer.size(); } - byte operator[](size_t idx) const - { - return buffer[idx]; - } + byte operator[](size_t idx) const { return buffer[idx]; } - const byte* data() const - { - return buffer.data(); - } + const byte* data() const { return buffer.data(); } -private: - std::vector<byte> buffer; + private: + std::vector<byte> buffer; }; - - } diff --git a/src/communication/bolt/v1/transport/chunked_buffer.hpp b/src/communication/bolt/v1/transport/chunked_buffer.hpp index 6a8b8332f..0fa07e1b4 100644 --- a/src/communication/bolt/v1/transport/chunked_buffer.hpp +++ b/src/communication/bolt/v1/transport/chunked_buffer.hpp @@ -1,65 +1,57 @@ #pragma once +#include <cstring> #include <memory> #include <vector> -#include <cstring> #include "communication/bolt/v1/config.hpp" -#include "utils/types/byte.hpp" #include "logging/default.hpp" +#include "utils/types/byte.hpp" -namespace bolt -{ +namespace bolt { template <class Stream> -class ChunkedBuffer -{ - static constexpr size_t C = bolt::config::C; /* chunk size */ +class ChunkedBuffer { + static constexpr size_t C = bolt::config::C; /* chunk size */ -public: - ChunkedBuffer(Stream &stream) : stream(stream) - { - logger = logging::log->logger("Chunked Buffer"); - } + public: + ChunkedBuffer(Stream &stream) : stream(stream) { + logger = logging::log->logger("Chunked Buffer"); + } - void write(const byte *values, size_t n) - { - logger.trace("Write {} bytes", n); + void write(const byte *values, size_t n) { + logger.trace("Write {} bytes", n); - // total size of the buffer is now bigger for n - size += n; + // total size of the buffer is now bigger for n + size += n; - // reserve enough spece for the new data - buffer.reserve(size); + // reserve enough spece for the new data + buffer.reserve(size); - // copy new data - std::copy(values, values + n, std::back_inserter(buffer)); - } + // copy new data + std::copy(values, values + n, std::back_inserter(buffer)); + } - void flush() - { - stream.get().write(&buffer.front(), size); + void flush() { + stream.get().write(&buffer.front(), size); - logger.trace("Flushed {} bytes", size); + logger.trace("Flushed {} bytes", size); - // GC - // TODO: impelement a better strategy - buffer.clear(); + // GC + // TODO: impelement a better strategy + buffer.clear(); - // reset size - size = 0; - } + // reset size + size = 0; + } - ~ChunkedBuffer() - { - } + ~ChunkedBuffer() {} -private: - Logger logger; - // every new stream.write creates new TCP package - std::reference_wrapper<Stream> stream; - std::vector<byte> buffer; - size_t size {0}; + private: + Logger logger; + // every new stream.write creates new TCP package + std::reference_wrapper<Stream> stream; + std::vector<byte> buffer; + size_t size{0}; }; - } diff --git a/src/communication/bolt/v1/transport/chunked_decoder.hpp b/src/communication/bolt/v1/transport/chunked_decoder.hpp index b7252b59f..ba7a36d67 100644 --- a/src/communication/bolt/v1/transport/chunked_decoder.hpp +++ b/src/communication/bolt/v1/transport/chunked_decoder.hpp @@ -9,62 +9,56 @@ #include "utils/likely.hpp" #include "utils/types/byte.hpp" -namespace bolt -{ +namespace bolt { template <class Stream> -class ChunkedDecoder -{ -public: - class DecoderError : public BasicException - { - public: - using BasicException::BasicException; - }; +class ChunkedDecoder { + public: + class DecoderError : public BasicException { + public: + using BasicException::BasicException; + }; - ChunkedDecoder(Stream& stream) : stream(stream) {} + ChunkedDecoder(Stream &stream) : stream(stream) {} - /* Decode chunked data - * - * Chunk format looks like: - * - * |Header| Data ||Header| Data || ... || End | - * | 2B | size bytes || 2B | size bytes || ... ||00 00| - */ - bool decode(const byte *&chunk, size_t n) - { - while (n > 0) - { - // get size from first two bytes in the chunk - auto size = get_size(chunk); + /* Decode chunked data + * + * Chunk format looks like: + * + * |Header| Data ||Header| Data || ... || End | + * | 2B | size bytes || 2B | size bytes || ... ||00 00| + */ + bool decode(const byte *&chunk, size_t n) { + while (n > 0) { + // get size from first two bytes in the chunk + auto size = get_size(chunk); - if (UNLIKELY(size + 2 > n)) - throw DecoderError("Chunk size larger than available data."); + if (UNLIKELY(size + 2 > n)) + throw DecoderError("Chunk size larger than available data."); - // advance chunk to pass those two bytes - chunk += 2; - n -= 2; + // advance chunk to pass those two bytes + chunk += 2; + n -= 2; - // if chunk size is 0, we're done! - if (size == 0) return true; + // if chunk size is 0, we're done! + if (size == 0) return true; - stream.get().write(chunk, size); + stream.get().write(chunk, size); - chunk += size; - n -= size; - } - - return false; + chunk += size; + n -= size; } - bool operator()(const byte *&chunk, size_t n) { return decode(chunk, n); } + return false; + } -private: - std::reference_wrapper<Stream> stream; + bool operator()(const byte *&chunk, size_t n) { return decode(chunk, n); } - size_t get_size(const byte *chunk) - { - return size_t(chunk[0]) << 8 | chunk[1]; - } + private: + std::reference_wrapper<Stream> stream; + + size_t get_size(const byte *chunk) { + return size_t(chunk[0]) << 8 | chunk[1]; + } }; } diff --git a/src/communication/bolt/v1/transport/chunked_encoder.hpp b/src/communication/bolt/v1/transport/chunked_encoder.hpp index f8181e270..72d6b8c9c 100644 --- a/src/communication/bolt/v1/transport/chunked_encoder.hpp +++ b/src/communication/bolt/v1/transport/chunked_encoder.hpp @@ -8,85 +8,76 @@ #include "logging/default.hpp" #include "utils/likely.hpp" -namespace bolt -{ +namespace bolt { template <class Stream> -class ChunkedEncoder -{ - static constexpr size_t N = bolt::config::N; - static constexpr size_t C = bolt::config::C; +class ChunkedEncoder { + static constexpr size_t N = bolt::config::N; + static constexpr size_t C = bolt::config::C; -public: - using byte = unsigned char; + public: + using byte = unsigned char; - ChunkedEncoder(Stream &stream) - : logger(logging::log->logger("Chunked Encoder")), stream(stream) - { + ChunkedEncoder(Stream &stream) + : logger(logging::log->logger("Chunked Encoder")), stream(stream) {} + + static constexpr size_t chunk_size = N - 2; + + void write(byte value) { + if (UNLIKELY(pos == N)) write_chunk(); + + chunk[pos++] = value; + } + + void write(const byte *values, size_t n) { + logger.trace("write {} bytes", n); + + while (n > 0) { + auto size = n < N - pos ? n : N - pos; + + std::memcpy(chunk.data() + pos, values, size); + + pos += size; + n -= size; + + // TODO: see how bolt splits message over more TCP packets, + // test for more TCP packets + if (pos == N) write_chunk(); } + } - static constexpr size_t chunk_size = N - 2; + void write_chunk() { + write_chunk_header(); - void write(byte value) - { - if (UNLIKELY(pos == N)) write_chunk(); + // write two zeros to signal message end + chunk[pos++] = 0x00; + chunk[pos++] = 0x00; - chunk[pos++] = value; - } + flush(); + } - void write(const byte *values, size_t n) - { - logger.trace("write {} bytes", n); + private: + Logger logger; + std::reference_wrapper<Stream> stream; - while (n > 0) { - auto size = n < N - pos ? n : N - pos; + std::array<byte, C> chunk; + size_t pos{2}; - std::memcpy(chunk.data() + pos, values, size); + void write_chunk_header() { + // write the size of the chunk + uint16_t size = pos - 2; - pos += size; - n -= size; + // write the higher byte + chunk[0] = size >> 8; - // TODO: see how bolt splits message over more TCP packets, - // test for more TCP packets - if (pos == N) write_chunk(); - } - } + // write the lower byte + chunk[1] = size & 0xFF; + } - void write_chunk() - { - write_chunk_header(); - - // write two zeros to signal message end - chunk[pos++] = 0x00; - chunk[pos++] = 0x00; - - flush(); - } - -private: - Logger logger; - std::reference_wrapper<Stream> stream; - - std::array<byte, C> chunk; - size_t pos{2}; - - void write_chunk_header() - { - // write the size of the chunk - uint16_t size = pos - 2; - - // write the higher byte - chunk[0] = size >> 8; - - // write the lower byte - chunk[1] = size & 0xFF; - } - - void flush() - { - // write chunk to the stream - stream.get().write(chunk.data(), pos); - pos = 2; - } + void flush() { + // write chunk to the stream + stream.get().write(chunk.data(), pos); + pos = 2; + } }; } diff --git a/src/communication/bolt/v1/transport/socket_stream.hpp b/src/communication/bolt/v1/transport/socket_stream.hpp index 9467ac5ca..97653d1fe 100644 --- a/src/communication/bolt/v1/transport/socket_stream.hpp +++ b/src/communication/bolt/v1/transport/socket_stream.hpp @@ -1,39 +1,33 @@ #pragma once #include <cstdint> -#include <vector> #include <cstdio> +#include <vector> -#include "io/network/socket.hpp" #include "communication/bolt/v1/transport/stream_error.hpp" +#include "io/network/socket.hpp" -namespace bolt -{ +namespace bolt { template <typename Stream> -class SocketStream -{ -public: - using byte = uint8_t; +class SocketStream { + public: + using byte = uint8_t; - SocketStream(Stream& socket) : socket(socket) {} + SocketStream(Stream& socket) : socket(socket) {} - void write(const byte* data, size_t n) - { - while(n > 0) - { - auto written = socket.get().write(data, n); + void write(const byte* data, size_t n) { + while (n > 0) { + auto written = socket.get().write(data, n); - if(UNLIKELY(written == -1)) - throw StreamError("Can't write to stream"); + if (UNLIKELY(written == -1)) throw StreamError("Can't write to stream"); - n -= written; - data += written; - } + n -= written; + data += written; } + } -private: - std::reference_wrapper<Stream> socket; + private: + std::reference_wrapper<Stream> socket; }; - } diff --git a/src/communication/bolt/v1/transport/stream_error.hpp b/src/communication/bolt/v1/transport/stream_error.hpp index fec4525dd..047b3b5ac 100644 --- a/src/communication/bolt/v1/transport/stream_error.hpp +++ b/src/communication/bolt/v1/transport/stream_error.hpp @@ -2,13 +2,10 @@ #include "utils/exceptions/basic_exception.hpp" -namespace bolt -{ +namespace bolt { -class StreamError : BasicException -{ -public: - using BasicException::BasicException; +class StreamError : BasicException { + public: + using BasicException::BasicException; }; - } diff --git a/src/communication/bolt/v1/transport/streamed_bolt_decoder.hpp b/src/communication/bolt/v1/transport/streamed_bolt_decoder.hpp index c190690ae..8211fa962 100644 --- a/src/communication/bolt/v1/transport/streamed_bolt_decoder.hpp +++ b/src/communication/bolt/v1/transport/streamed_bolt_decoder.hpp @@ -7,324 +7,301 @@ #include "utils/bswap.hpp" #include "utils/types/byte.hpp" -namespace bolt -{ +namespace bolt { // BoltDecoder for streams. Meant for use in SnapshotDecoder. // This should be recoded to recieve the current caller so that decoder can // based on a current type call it. template <class STREAM> -class StreamedBoltDecoder -{ - static constexpr int64_t plus_2_to_the_31 = 2147483648L; - static constexpr int64_t plus_2_to_the_15 = 32768L; - static constexpr int64_t plus_2_to_the_7 = 128L; - static constexpr int64_t minus_2_to_the_4 = -16L; - static constexpr int64_t minus_2_to_the_7 = -128L; - static constexpr int64_t minus_2_to_the_15 = -32768L; - static constexpr int64_t minus_2_to_the_31 = -2147483648L; +class StreamedBoltDecoder { + static constexpr int64_t plus_2_to_the_31 = 2147483648L; + static constexpr int64_t plus_2_to_the_15 = 32768L; + static constexpr int64_t plus_2_to_the_7 = 128L; + static constexpr int64_t minus_2_to_the_4 = -16L; + static constexpr int64_t minus_2_to_the_7 = -128L; + static constexpr int64_t minus_2_to_the_15 = -32768L; + static constexpr int64_t minus_2_to_the_31 = -2147483648L; -public: - StreamedBoltDecoder(STREAM &stream) : stream(stream) {} + public: + StreamedBoltDecoder(STREAM &stream) : stream(stream) {} - // Returns mark of a data. - size_t mark() { return peek_byte(); } + // Returns mark of a data. + size_t mark() { return peek_byte(); } - // Calls handle with current primitive data. Throws DecoderException if it - // isn't a primitive. - template <class H, class T> - T accept_primitive(H &handle) - { - switch (byte()) { - case pack::False: { - return handle.handle(false); - } - case pack::True: { - return handle.handle(true); - } - case pack::Float64: { - return handle.handle(read_double()); - } - default: { - return handle.handle(integer()); - } - }; + // Calls handle with current primitive data. Throws DecoderException if it + // isn't a primitive. + template <class H, class T> + T accept_primitive(H &handle) { + switch (byte()) { + case pack::False: { + return handle.handle(false); + } + case pack::True: { + return handle.handle(true); + } + case pack::Float64: { + return handle.handle(read_double()); + } + default: { return handle.handle(integer()); } + }; + } + + // Reads map header. Throws DecoderException if it isn't map header. + size_t map_header() { + auto marker = byte(); + + size_t size; + + if ((marker & 0xF0) == pack::TinyMap) { + size = marker & 0x0F; + + } else if (marker == pack::Map8) { + size = byte(); + + } else if (marker == pack::Map16) { + size = read<uint16_t>(); + + } else if (marker == pack::Map32) { + size = read<uint32_t>(); + + } else { + // Error + throw DecoderException( + "StreamedBoltDecoder: Tryed to read map header but found ", marker); } - // Reads map header. Throws DecoderException if it isn't map header. - size_t map_header() - { - auto marker = byte(); + return size; + } - size_t size; + bool is_list() { + auto marker = peek_byte(); - if ((marker & 0xF0) == pack::TinyMap) { - size = marker & 0x0F; + if ((marker & 0xF0) == pack::TinyList) { + return true; - } else if (marker == pack::Map8) { - size = byte(); + } else if (marker == pack::List8) { + return true; - } else if (marker == pack::Map16) { - size = read<uint16_t>(); + } else if (marker == pack::List16) { + return true; - } else if (marker == pack::Map32) { - size = read<uint32_t>(); + } else if (marker == pack::List32) { + return true; + } else { + return false; + } + } - } else { - // Error - throw DecoderException( - "StreamedBoltDecoder: Tryed to read map header but found ", - marker); - } + // Reads list header. Throws DecoderException if it isn't list header. + size_t list_header() { + auto marker = byte(); - return size; + if ((marker & 0xF0) == pack::TinyList) { + return marker & 0x0F; + + } else if (marker == pack::List8) { + return byte(); + + } else if (marker == pack::List16) { + return read<uint16_t>(); + + } else if (marker == pack::List32) { + return read<uint32_t>(); + + } else { + // Error + throw DecoderException( + "StreamedBoltDecoder: Tryed to read list header but found ", marker); + } + } + + bool is_bool() { + auto marker = peek_byte(); + + if (marker == pack::True) { + return true; + } else if (marker == pack::False) { + return true; + } else { + return false; + } + } + + // Reads bool.Throws DecoderException if it isn't bool. + bool read_bool() { + auto marker = byte(); + + if (marker == pack::True) { + return true; + } else if (marker == pack::False) { + return false; + } else { + throw DecoderException( + "StreamedBoltDecoder: Tryed to read bool header but found ", marker); + } + } + + bool is_integer() { + auto marker = peek_byte(); + + if (marker >= minus_2_to_the_4 && marker < plus_2_to_the_7) { + return true; + + } else if (marker == pack::Int8) { + return true; + + } else if (marker == pack::Int16) { + return true; + + } else if (marker == pack::Int32) { + return true; + + } else if (marker == pack::Int64) { + return true; + + } else { + return false; + } + } + + // Reads integer.Throws DecoderException if it isn't integer. + int64_t integer() { + auto marker = byte(); + + if (marker >= minus_2_to_the_4 && marker < plus_2_to_the_7) { + return marker; + + } else if (marker == pack::Int8) { + return byte(); + + } else if (marker == pack::Int16) { + return read<int16_t>(); + + } else if (marker == pack::Int32) { + return read<int32_t>(); + + } else if (marker == pack::Int64) { + return read<int64_t>(); + + } else { + throw DecoderException( + "StreamedBoltDecoder: Tryed to read integer but found ", marker); + } + } + + bool is_double() { + auto marker = peek_byte(); + + return marker == pack::Float64; + } + + // Reads double.Throws DecoderException if it isn't double. + double read_double() { + auto marker = byte(); + if (marker == pack::Float64) { + auto tmp = read<int64_t>(); + return *reinterpret_cast<const double *>(&tmp); + } else { + throw DecoderException( + "StreamedBoltDecoder: Tryed to read double but found ", marker); + } + } + + bool is_string() { + auto marker = peek_byte(); + + // if the first 4 bits equal to 1000 (0x8), this is a tiny string + if ((marker & 0xF0) == pack::TinyString) { + return true; + } + // if the marker is 0xD0, size is an 8-bit unsigned integer + else if (marker == pack::String8) { + return true; + } + // if the marker is 0xD1, size is a 16-bit big-endian unsigned integer + else if (marker == pack::String16) { + return true; + } + // if the marker is 0xD2, size is a 32-bit big-endian unsigned integer + else if (marker == pack::String32) { + return true; + + } else { + return false; + } + } + + // Reads string into res. Throws DecoderException if it isn't string. + void string(std::string &res) { + if (!string_try(res)) { + throw DecoderException( + "StreamedBoltDecoder: Tryed to read string but found ", + std::to_string(peek_byte())); + } + } + // Try-s to read string. Retunrns true on success. If it didn't succed + // stream remains unchanged + bool string_try(std::string &res) { + auto marker = peek_byte(); + + uint32_t size; + + // if the first 4 bits equal to 1000 (0x8), this is a tiny string + if ((marker & 0xF0) == pack::TinyString) { + byte(); + // size is stored in the lower 4 bits of the marker byte + size = marker & 0x0F; + } + // if the marker is 0xD0, size is an 8-bit unsigned integer + else if (marker == pack::String8) { + byte(); + size = byte(); + } + // if the marker is 0xD1, size is a 16-bit big-endian unsigned integer + else if (marker == pack::String16) { + byte(); + size = read<uint16_t>(); + } + // if the marker is 0xD2, size is a 32-bit big-endian unsigned integer + else if (marker == pack::String32) { + byte(); + size = read<uint32_t>(); + } else { + // Error + return false; } - bool is_list() - { - auto marker = peek_byte(); - - if ((marker & 0xF0) == pack::TinyList) { - return true; - - } else if (marker == pack::List8) { - return true; - - } else if (marker == pack::List16) { - return true; - - } else if (marker == pack::List32) { - return true; - } else { - return false; - } + if (size > 0) { + res.resize(size); + stream.read(&res.front(), size); + } else { + res.clear(); } - // Reads list header. Throws DecoderException if it isn't list header. - size_t list_header() - { - auto marker = byte(); + return true; + } - if ((marker & 0xF0) == pack::TinyList) { - return marker & 0x0F; + private: + // Reads T from stream. It doens't care for alligment so this is valid only + // for primitives. + template <class T> + T read() { + buffer.resize(sizeof(T)); - } else if (marker == pack::List8) { - return byte(); + // Load value + stream.read(&buffer.front(), sizeof(T)); - } else if (marker == pack::List16) { - return read<uint16_t>(); + // reinterpret bytes as the target value + auto value = reinterpret_cast<const T *>(&buffer.front()); - } else if (marker == pack::List32) { - return read<uint32_t>(); + // swap values to little endian + return bswap(*value); + } - } else { - // Error - throw DecoderException( - "StreamedBoltDecoder: Tryed to read list header but found ", - marker); - } - } + ::byte byte() { return stream.get(); } + ::byte peek_byte() { return stream.peek(); } - bool is_bool() - { - auto marker = peek_byte(); - - if (marker == pack::True) { - return true; - } else if (marker == pack::False) { - return true; - } else { - return false; - } - } - - // Reads bool.Throws DecoderException if it isn't bool. - bool read_bool() - { - auto marker = byte(); - - if (marker == pack::True) { - return true; - } else if (marker == pack::False) { - return false; - } else { - throw DecoderException( - "StreamedBoltDecoder: Tryed to read bool header but found ", - marker); - } - } - - bool is_integer() - { - auto marker = peek_byte(); - - if (marker >= minus_2_to_the_4 && marker < plus_2_to_the_7) { - return true; - - } else if (marker == pack::Int8) { - return true; - - } else if (marker == pack::Int16) { - return true; - - } else if (marker == pack::Int32) { - return true; - - } else if (marker == pack::Int64) { - return true; - - } else { - return false; - } - } - - // Reads integer.Throws DecoderException if it isn't integer. - int64_t integer() - { - - auto marker = byte(); - - if (marker >= minus_2_to_the_4 && marker < plus_2_to_the_7) { - return marker; - - } else if (marker == pack::Int8) { - return byte(); - - } else if (marker == pack::Int16) { - return read<int16_t>(); - - } else if (marker == pack::Int32) { - return read<int32_t>(); - - } else if (marker == pack::Int64) { - return read<int64_t>(); - - } else { - throw DecoderException( - "StreamedBoltDecoder: Tryed to read integer but found ", - marker); - } - } - - bool is_double() - { - auto marker = peek_byte(); - - return marker == pack::Float64; - } - - // Reads double.Throws DecoderException if it isn't double. - double read_double() - { - auto marker = byte(); - if (marker == pack::Float64) { - auto tmp = read<int64_t>(); - return *reinterpret_cast<const double *>(&tmp); - } else { - throw DecoderException( - "StreamedBoltDecoder: Tryed to read double but found ", marker); - } - } - - bool is_string() - { - auto marker = peek_byte(); - - // if the first 4 bits equal to 1000 (0x8), this is a tiny string - if ((marker & 0xF0) == pack::TinyString) { - return true; - } - // if the marker is 0xD0, size is an 8-bit unsigned integer - else if (marker == pack::String8) { - return true; - } - // if the marker is 0xD1, size is a 16-bit big-endian unsigned integer - else if (marker == pack::String16) { - return true; - } - // if the marker is 0xD2, size is a 32-bit big-endian unsigned integer - else if (marker == pack::String32) { - return true; - - } else { - return false; - } - } - - // Reads string into res. Throws DecoderException if it isn't string. - void string(std::string &res) - { - if (!string_try(res)) { - throw DecoderException( - "StreamedBoltDecoder: Tryed to read string but found ", - std::to_string(peek_byte())); - } - } - // Try-s to read string. Retunrns true on success. If it didn't succed - // stream remains unchanged - bool string_try(std::string &res) - { - auto marker = peek_byte(); - - uint32_t size; - - // if the first 4 bits equal to 1000 (0x8), this is a tiny string - if ((marker & 0xF0) == pack::TinyString) { - byte(); - // size is stored in the lower 4 bits of the marker byte - size = marker & 0x0F; - } - // if the marker is 0xD0, size is an 8-bit unsigned integer - else if (marker == pack::String8) { - byte(); - size = byte(); - } - // if the marker is 0xD1, size is a 16-bit big-endian unsigned integer - else if (marker == pack::String16) { - byte(); - size = read<uint16_t>(); - } - // if the marker is 0xD2, size is a 32-bit big-endian unsigned integer - else if (marker == pack::String32) { - byte(); - size = read<uint32_t>(); - } else { - // Error - return false; - } - - if (size > 0) { - res.resize(size); - stream.read(&res.front(), size); - } else { - res.clear(); - } - - return true; - } - -private: - // Reads T from stream. It doens't care for alligment so this is valid only - // for primitives. - template <class T> - T read() - { - buffer.resize(sizeof(T)); - - // Load value - stream.read(&buffer.front(), sizeof(T)); - - // reinterpret bytes as the target value - auto value = reinterpret_cast<const T *>(&buffer.front()); - - // swap values to little endian - return bswap(*value); - } - - ::byte byte() { return stream.get(); } - ::byte peek_byte() { return stream.peek(); } - - STREAM &stream; - std::string buffer; + STREAM &stream; + std::string buffer; }; }; diff --git a/src/config/config.cpp b/src/config/config.cpp index 708e5e2e7..891745878 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -1,7 +1,6 @@ #include "config/config.hpp" -namespace config -{ +namespace config { const char *MemgraphConfig::env_config_key = "MEMGRAPH_CONFIG"; const char *MemgraphConfig::default_file_path = "/etc/memgraph/config.yaml"; @@ -11,8 +10,6 @@ const char *MemgraphConfig::default_file_path = "/etc/memgraph/config.yaml"; // Example: // --cleaning_cycle_sec or -ccs, etc. std::set<std::string> MemgraphConfig::arguments = { - "cleaning_cycle_sec", - "snapshot_cycle_sec", + "cleaning_cycle_sec", "snapshot_cycle_sec", }; - } diff --git a/src/config/config.hpp b/src/config/config.hpp index fa88e4924..85234d6f9 100644 --- a/src/config/config.hpp +++ b/src/config/config.hpp @@ -2,23 +2,21 @@ #include "utils/config/config.hpp" -#include <string> #include <set> +#include <string> -namespace config -{ +namespace config { // this class is used as a Definition class of config::Config class from utils // number of elements should be small, // it depends on implementation of config::Config class // in other words number of fields in Definition class should be related // to the number of config keys -class MemgraphConfig -{ -public: - static const char *env_config_key; - static const char *default_file_path; - static std::set<std::string> arguments; +class MemgraphConfig { + public: + static const char *env_config_key; + static const char *default_file_path; + static std::set<std::string> arguments; }; // -- all possible Memgraph's keys -- diff --git a/src/data_structures/bitset/dynamic_bitset.hpp b/src/data_structures/bitset/dynamic_bitset.hpp index 2190b7238..e7415322b 100644 --- a/src/data_structures/bitset/dynamic_bitset.hpp +++ b/src/data_structures/bitset/dynamic_bitset.hpp @@ -7,149 +7,132 @@ #include "threading/sync/spinlock.hpp" template <class block_t = uint8_t, size_t chunk_size = 32768> -class DynamicBitset : Lockable<SpinLock> -{ - struct Block - { - Block() = default; +class DynamicBitset : Lockable<SpinLock> { + struct Block { + Block() = default; - Block(Block &) = delete; - Block(Block &&) = delete; + Block(Block &) = delete; + Block(Block &&) = delete; - static constexpr size_t size = sizeof(block_t) * 8; + static constexpr size_t size = sizeof(block_t) * 8; - constexpr block_t bitmask(size_t group_size) const - { - return (block_t)(-1) >> (size - group_size); - } - - block_t at(size_t k, size_t n, std::memory_order order) - { - assert(k + n - 1 < size); - return (block.load(order) >> k) & bitmask(n); - } - - void set(size_t k, size_t n, std::memory_order order) - { - assert(k + n - 1 < size); - block.fetch_or(bitmask(n) << k, order); - } - - void clear(size_t k, size_t n, std::memory_order order) - { - assert(k + n - 1 < size); - block.fetch_and(~(bitmask(n) << k), order); - } - - std::atomic<block_t> block{0}; - }; - - struct Chunk - { - Chunk() : next(nullptr) - { - static_assert(chunk_size % sizeof(block_t) == 0, - "chunk size not divisible by block size"); - } - - Chunk(Chunk &) = delete; - Chunk(Chunk &&) = delete; - - static constexpr size_t size = chunk_size * Block::size; - static constexpr size_t n_blocks = chunk_size / sizeof(block_t); - - block_t at(size_t k, size_t n, std::memory_order order) - { - return blocks[k / Block::size].at(k % Block::size, n, order); - } - - void set(size_t k, size_t n, std::memory_order order) - { - blocks[k / Block::size].set(k % Block::size, n, order); - } - - void clear(size_t k, size_t n, std::memory_order order) - { - blocks[k / Block::size].clear(k % Block::size, n, order); - } - - Block blocks[n_blocks]; - std::atomic<Chunk *> next; - }; - -public: - DynamicBitset() : head(new Chunk()) {} - - DynamicBitset(DynamicBitset &) = delete; - DynamicBitset(DynamicBitset &&) = delete; - - ~DynamicBitset() - { - auto now = head.load(); - while (now != nullptr) { - auto next = now->next.load(); - delete now; - now = next; - } + constexpr block_t bitmask(size_t group_size) const { + return (block_t)(-1) >> (size - group_size); } - block_t at(size_t k, size_t n) - { - auto &chunk = find_chunk(k); - return chunk.at(k, n, std::memory_order_seq_cst); + block_t at(size_t k, size_t n, std::memory_order order) { + assert(k + n - 1 < size); + return (block.load(order) >> k) & bitmask(n); } - bool at(size_t k) - { - auto &chunk = find_chunk(k); - return chunk.at(k, 1, std::memory_order_seq_cst); + void set(size_t k, size_t n, std::memory_order order) { + assert(k + n - 1 < size); + block.fetch_or(bitmask(n) << k, order); } - void set(size_t k, size_t n = 1) - { - auto &chunk = find_chunk(k); - return chunk.set(k, n, std::memory_order_seq_cst); + void clear(size_t k, size_t n, std::memory_order order) { + assert(k + n - 1 < size); + block.fetch_and(~(bitmask(n) << k), order); } - void clear(size_t k, size_t n = 1) - { - auto &chunk = find_chunk(k); - return chunk.clear(k, n, std::memory_order_seq_cst); + std::atomic<block_t> block{0}; + }; + + struct Chunk { + Chunk() : next(nullptr) { + static_assert(chunk_size % sizeof(block_t) == 0, + "chunk size not divisible by block size"); } -private: - Chunk &find_chunk(size_t &k) - { - Chunk *chunk = head.load(), *next = nullptr; + Chunk(Chunk &) = delete; + Chunk(Chunk &&) = delete; - // while i'm not in the right chunk - // (my index is bigger than the size of this chunk) - while (k >= Chunk::size) { - next = chunk->next.load(); + static constexpr size_t size = chunk_size * Block::size; + static constexpr size_t n_blocks = chunk_size / sizeof(block_t); - // if a next chunk exists, switch to it and decrement my - // pointer by the size of the current chunk - if (next != nullptr) { - chunk = next; - k -= Chunk::size; - continue; - } - - // the next chunk does not exist and we need it. take an exclusive - // lock to prevent others that also want to create a new chunk - // from creating it - auto guard = acquire_unique(); - - // double-check locking. if the chunk exists now, some other thread - // has just created it, continue searching for my chunk - if (chunk->next.load() != nullptr) continue; - - chunk->next.store(new Chunk()); - } - - assert(chunk != nullptr); - return *chunk; + block_t at(size_t k, size_t n, std::memory_order order) { + return blocks[k / Block::size].at(k % Block::size, n, order); } - std::atomic<Chunk *> head; + void set(size_t k, size_t n, std::memory_order order) { + blocks[k / Block::size].set(k % Block::size, n, order); + } + + void clear(size_t k, size_t n, std::memory_order order) { + blocks[k / Block::size].clear(k % Block::size, n, order); + } + + Block blocks[n_blocks]; + std::atomic<Chunk *> next; + }; + + public: + DynamicBitset() : head(new Chunk()) {} + + DynamicBitset(DynamicBitset &) = delete; + DynamicBitset(DynamicBitset &&) = delete; + + ~DynamicBitset() { + auto now = head.load(); + while (now != nullptr) { + auto next = now->next.load(); + delete now; + now = next; + } + } + + block_t at(size_t k, size_t n) { + auto &chunk = find_chunk(k); + return chunk.at(k, n, std::memory_order_seq_cst); + } + + bool at(size_t k) { + auto &chunk = find_chunk(k); + return chunk.at(k, 1, std::memory_order_seq_cst); + } + + void set(size_t k, size_t n = 1) { + auto &chunk = find_chunk(k); + return chunk.set(k, n, std::memory_order_seq_cst); + } + + void clear(size_t k, size_t n = 1) { + auto &chunk = find_chunk(k); + return chunk.clear(k, n, std::memory_order_seq_cst); + } + + private: + Chunk &find_chunk(size_t &k) { + Chunk *chunk = head.load(), *next = nullptr; + + // while i'm not in the right chunk + // (my index is bigger than the size of this chunk) + while (k >= Chunk::size) { + next = chunk->next.load(); + + // if a next chunk exists, switch to it and decrement my + // pointer by the size of the current chunk + if (next != nullptr) { + chunk = next; + k -= Chunk::size; + continue; + } + + // the next chunk does not exist and we need it. take an exclusive + // lock to prevent others that also want to create a new chunk + // from creating it + auto guard = acquire_unique(); + + // double-check locking. if the chunk exists now, some other thread + // has just created it, continue searching for my chunk + if (chunk->next.load() != nullptr) continue; + + chunk->next.store(new Chunk()); + } + + assert(chunk != nullptr); + return *chunk; + } + + std::atomic<Chunk *> head; }; diff --git a/src/data_structures/bloom/bloom_filter.hpp b/src/data_structures/bloom/bloom_filter.hpp index 8df2a5e13..a3c8eb760 100644 --- a/src/data_structures/bloom/bloom_filter.hpp +++ b/src/data_structures/bloom/bloom_filter.hpp @@ -13,64 +13,56 @@ * Type specifies the type of data stored */ template <class Type, int BucketSize = 8> -class BloomFilter -{ -private: - using HashFunction = std::function<uint64_t(const Type &)>; - using CompresionFunction = std::function<int(uint64_t)>; +class BloomFilter { + private: + using HashFunction = std::function<uint64_t(const Type &)>; + using CompresionFunction = std::function<int(uint64_t)>; - std::bitset<BucketSize> filter_; - std::vector<HashFunction> hashes_; - CompresionFunction compression_; - std::vector<int> buckets; + std::bitset<BucketSize> filter_; + std::vector<HashFunction> hashes_; + CompresionFunction compression_; + std::vector<int> buckets; - int default_compression(uint64_t hash) { return hash % BucketSize; } + int default_compression(uint64_t hash) { return hash % BucketSize; } - void get_buckets(const Type &data) - { - for (int i = 0; i < hashes_.size(); i++) - buckets[i] = compression_(hashes_[i](data)); + void get_buckets(const Type &data) { + for (int i = 0; i < hashes_.size(); i++) + buckets[i] = compression_(hashes_[i](data)); + } + + void print_buckets(std::vector<uint64_t> &buckets) { + for (int i = 0; i < buckets.size(); i++) { + std::cout << buckets[i] << " "; } + std::cout << std::endl; + } - void print_buckets(std::vector<uint64_t> &buckets) - { - for (int i = 0; i < buckets.size(); i++) - { - std::cout << buckets[i] << " "; - } - std::cout << std::endl; - } + public: + BloomFilter(std::vector<HashFunction> funcs, + CompresionFunction compression = {}) + : hashes_(funcs) { + if (!compression) + compression_ = std::bind(&BloomFilter::default_compression, this, + std::placeholders::_1); + else + compression_ = compression; -public: - BloomFilter(std::vector<HashFunction> funcs, - CompresionFunction compression = {}) - : hashes_(funcs) - { - if (!compression) - compression_ = std::bind(&BloomFilter::default_compression, this, - std::placeholders::_1); - else - compression_ = compression; + buckets.resize(hashes_.size()); + } - buckets.resize(hashes_.size()); - } + bool contains(const Type &data) { + get_buckets(data); + bool contains_element = true; - bool contains(const Type &data) - { - get_buckets(data); - bool contains_element = true; + for (int i = 0; i < buckets.size(); i++) + contains_element &= filter_[buckets[i]]; - for (int i = 0; i < buckets.size(); i++) - contains_element &= filter_[buckets[i]]; + return contains_element; + } - return contains_element; - } + void insert(const Type &data) { + get_buckets(data); - void insert(const Type &data) - { - get_buckets(data); - - for (int i = 0; i < buckets.size(); i++) - filter_[buckets[i]] = true; - } + for (int i = 0; i < buckets.size(); i++) filter_[buckets[i]] = true; + } }; diff --git a/src/data_structures/concurrent/common.hpp b/src/data_structures/concurrent/common.hpp index c0c69eaa8..81ccd62d2 100644 --- a/src/data_structures/concurrent/common.hpp +++ b/src/data_structures/concurrent/common.hpp @@ -11,89 +11,79 @@ template <typename K, typename T> class Item : public TotalOrdering<Item<K, T>>, public TotalOrdering<K, Item<K, T>>, public TotalOrdering<Item<K, T>, K>, - public pair<const K, T> -{ -public: - using pair<const K, T>::pair; + public pair<const K, T> { + public: + using pair<const K, T>::pair; - friend constexpr bool operator<(const Item &lhs, const Item &rhs) - { - return lhs.first < rhs.first; - } + friend constexpr bool operator<(const Item &lhs, const Item &rhs) { + return lhs.first < rhs.first; + } - friend constexpr bool operator==(const Item &lhs, const Item &rhs) - { - return lhs.first == rhs.first; - } + friend constexpr bool operator==(const Item &lhs, const Item &rhs) { + return lhs.first == rhs.first; + } - friend constexpr bool operator<(const K &lhs, const Item &rhs) - { - return lhs < rhs.first; - } + friend constexpr bool operator<(const K &lhs, const Item &rhs) { + return lhs < rhs.first; + } - friend constexpr bool operator==(const K &lhs, const Item &rhs) - { - return lhs == rhs.first; - } + friend constexpr bool operator==(const K &lhs, const Item &rhs) { + return lhs == rhs.first; + } - friend constexpr bool operator<(const Item &lhs, const K &rhs) - { - return lhs.first < rhs; - } + friend constexpr bool operator<(const Item &lhs, const K &rhs) { + return lhs.first < rhs; + } - friend constexpr bool operator==(const Item &lhs, const K &rhs) - { - return lhs.first == rhs; - } + friend constexpr bool operator==(const Item &lhs, const K &rhs) { + return lhs.first == rhs; + } }; // Common base for accessor of all derived containers(ConcurrentMap, // ConcurrentSet, ...) from SkipList. template <typename T> -class AccessorBase -{ - typedef SkipList<T> list; - typedef typename SkipList<T>::Iterator list_it; - typedef typename SkipList<T>::ConstIterator list_it_con; +class AccessorBase { + typedef SkipList<T> list; + typedef typename SkipList<T>::Iterator list_it; + typedef typename SkipList<T>::ConstIterator list_it_con; -protected: - AccessorBase(list *skiplist) : accessor(skiplist->access()) {} + protected: + AccessorBase(list *skiplist) : accessor(skiplist->access()) {} -public: - AccessorBase(const AccessorBase &) = delete; + public: + AccessorBase(const AccessorBase &) = delete; - AccessorBase(AccessorBase &&other) : accessor(std::move(other.accessor)) {} + AccessorBase(AccessorBase &&other) : accessor(std::move(other.accessor)) {} - ~AccessorBase() {} + ~AccessorBase() {} - size_t size() { return accessor.size(); }; + size_t size() { return accessor.size(); }; - list_it begin() { return accessor.begin(); } + list_it begin() { return accessor.begin(); } - list_it_con begin() const { return accessor.cbegin(); } + list_it_con begin() const { return accessor.cbegin(); } - list_it_con cbegin() const { return accessor.cbegin(); } + list_it_con cbegin() const { return accessor.cbegin(); } - list_it end() { return accessor.end(); } + list_it end() { return accessor.end(); } - list_it_con end() const { return accessor.cend(); } + list_it_con end() const { return accessor.cend(); } - list_it_con cend() const { return accessor.cend(); } + list_it_con cend() const { return accessor.cend(); } - template <class K> - typename SkipList<T>::template MultiIterator<K> end(const K &data) - { - return accessor.template mend<K>(data); - } + template <class K> + typename SkipList<T>::template MultiIterator<K> end(const K &data) { + return accessor.template mend<K>(data); + } - template <class K> - typename SkipList<T>::template MultiIterator<K> mend(const K &data) - { - return accessor.template mend<K>(data); - } + template <class K> + typename SkipList<T>::template MultiIterator<K> mend(const K &data) { + return accessor.template mend<K>(data); + } - size_t size() const { return accessor.size(); } + size_t size() const { return accessor.size(); } -protected: - typename list::Accessor accessor; + protected: + typename list::Accessor accessor; }; diff --git a/src/data_structures/concurrent/concurrent_bloom_map.hpp b/src/data_structures/concurrent/concurrent_bloom_map.hpp index 8ffca031e..1e9de6179 100644 --- a/src/data_structures/concurrent/concurrent_bloom_map.hpp +++ b/src/data_structures/concurrent/concurrent_bloom_map.hpp @@ -1,9 +1,8 @@ #pragma once #include "data_structures/concurrent/common.hpp" -#include "data_structures/concurrent/skiplist.hpp" #include "data_structures/concurrent/concurrent_map.hpp" - +#include "data_structures/concurrent/skiplist.hpp" using std::pair; @@ -12,25 +11,25 @@ class ConcurrentBloomMap { using item_t = Item<Key, Value>; using list_it = typename SkipList<item_t>::Iterator; - private: - ConcurrentMap<Key, Value> map_; - BloomFilter filter_; + private: + ConcurrentMap<Key, Value> map_; + BloomFilter filter_; - public: - ConcurrentBloomMap(BloomFilter filter) : filter_(filter) {} + public: + ConcurrentBloomMap(BloomFilter filter) : filter_(filter) {} - std::pair<list_it, bool> insert(const Key &key, const Value &data) { - filter_.insert(key); + std::pair<list_it, bool> insert(const Key &key, const Value &data) { + filter_.insert(key); - auto accessor = std::move(map_.access()); + auto accessor = std::move(map_.access()); - return accessor.insert(key, data); - } + return accessor.insert(key, data); + } - bool contains(const Key &key) { - if (!filter_.contains(key)) return false; + bool contains(const Key &key) { + if (!filter_.contains(key)) return false; - auto accessor = map_.access(); - return accessor.contains(key); - } + auto accessor = map_.access(); + return accessor.contains(key); + } }; diff --git a/src/data_structures/concurrent/concurrent_list.hpp b/src/data_structures/concurrent/concurrent_list.hpp index f35b3d3f1..ab942c794 100644 --- a/src/data_structures/concurrent/concurrent_list.hpp +++ b/src/data_structures/concurrent/concurrent_list.hpp @@ -8,330 +8,308 @@ // TODO: reimplement this. It's correct but somewhat inefecient and it could be // done better. template <class T> -class ConcurrentList -{ -private: - template <class V> - static V load(std::atomic<V> &atomic) - { - return atomic.load(std::memory_order_acquire); +class ConcurrentList { + private: + template <class V> + static V load(std::atomic<V> &atomic) { + return atomic.load(std::memory_order_acquire); + } + + template <class V> + static void store(std::atomic<V> &atomic, + V desired) { // Maybe could be relaxed + atomic.store(desired, std::memory_order_release); + } + + template <class V> + static bool cas( + std::atomic<V> &atomic, V expected, + V desired) { // Could be relaxed but must be at least Release. + return atomic.compare_exchange_strong(expected, desired, + std::memory_order_seq_cst); + } + + template <class V> + static V *swap(std::atomic<V *> &atomic, V *desired) { // Could be relaxed + return atomic.exchange(desired, std::memory_order_seq_cst); + } + + // Basic element in a ConcurrentList + class Node { + public: + Node(const T &data) : data(data) {} + Node(T &&data) : data(std::move(data)) {} + + // Carried data + T data; + + // Next element in list or nullptr if end. + std::atomic<Node *> next{nullptr}; + + // Next removed element in list or nullptr if end. + std::atomic<Node *> next_rem{nullptr}; + + // True if node has logicaly been removed from list. + std::atomic<bool> removed{false}; + }; + + // Base for Mutable and Immutable iterators. Also serves as accessor to the + // list uses for safe garbage disposall. + template <class It> + class IteratorBase : public Crtp<It> { + friend class ConcurrentList; + + protected: + IteratorBase() : list(nullptr), curr(nullptr) {} + + IteratorBase(ConcurrentList *list) : list(list) { + assert(list != nullptr); + // Increment number of iterators accessing list. + list->active_threads_no_++; + // Start from the begining of list. + reset(); } - template <class V> - static void store(std::atomic<V> &atomic, V desired) - { // Maybe could be relaxed - atomic.store(desired, std::memory_order_release); + public: + IteratorBase(const IteratorBase &) = delete; + + IteratorBase(IteratorBase &&other) + : list(other.list), curr(other.curr), prev(other.prev) { + other.list = nullptr; + other.curr = nullptr; + other.prev = nullptr; } - template <class V> - static bool cas(std::atomic<V> &atomic, V expected, V desired) - { // Could be relaxed but must be at least Release. - return atomic.compare_exchange_strong(expected, desired, - std::memory_order_seq_cst); + ~IteratorBase() { + if (list == nullptr) { + return; + } + + auto head_rem = load(list->removed); + + // Next IF checks if this thread is responisble for disposall of + // collected garbage. + // Fetch could be relaxed + // There exist possibility that no one will delete garbage at this + // time but it will be deleted at some other time. + if (list->active_threads_no_.fetch_sub(1) == + 1 && // I am the last one accessing + head_rem != nullptr && // There is some garbage + cas<Node *>(list->removed, head_rem, + nullptr) // No new garbage was added. + ) { + // Delete all removed node following chain of next_rem starting + // from head_rem. + auto now = head_rem; + do { + auto next = load(now->next_rem); + delete now; + now = next; + } while (now != nullptr); + } } - template <class V> - static V *swap(std::atomic<V *> &atomic, V *desired) - { // Could be relaxed - return atomic.exchange(desired, std::memory_order_seq_cst); + IteratorBase &operator=(IteratorBase const &other) = delete; + IteratorBase &operator=(IteratorBase &&other) = delete; + + T &operator*() const { + assert(valid()); + return curr->data; + } + T *operator->() const { + assert(valid()); + return &(curr->data); } - // Basic element in a ConcurrentList - class Node - { - public: - Node(const T &data) : data(data) {} - Node(T &&data) : data(std::move(data)) {} + bool valid() const { return curr != nullptr; } - // Carried data - T data; + // Iterating is wait free. + It &operator++() { + assert(valid()); + do { + prev = curr; + curr = load(curr->next); + } while (valid() && is_removed()); // Loop ends if end of list is + // found or if not removed + // element is found. + return this->derived(); + } + It &operator++(int) { return operator++(); } - // Next element in list or nullptr if end. - std::atomic<Node *> next{nullptr}; - - // Next removed element in list or nullptr if end. - std::atomic<Node *> next_rem{nullptr}; - - // True if node has logicaly been removed from list. - std::atomic<bool> removed{false}; - }; - - // Base for Mutable and Immutable iterators. Also serves as accessor to the - // list uses for safe garbage disposall. - template <class It> - class IteratorBase : public Crtp<It> - { - friend class ConcurrentList; - - protected: - IteratorBase() : list(nullptr), curr(nullptr) {} - - IteratorBase(ConcurrentList *list) : list(list) - { - assert(list != nullptr); - // Increment number of iterators accessing list. - list->active_threads_no_++; - // Start from the begining of list. - reset(); - } - - public: - IteratorBase(const IteratorBase &) = delete; - - IteratorBase(IteratorBase &&other) - : list(other.list), curr(other.curr), prev(other.prev) - { - other.list = nullptr; - other.curr = nullptr; - other.prev = nullptr; - } - - ~IteratorBase() - { - if (list == nullptr) { - return; - } - - auto head_rem = load(list->removed); - - // Next IF checks if this thread is responisble for disposall of - // collected garbage. - // Fetch could be relaxed - // There exist possibility that no one will delete garbage at this - // time but it will be deleted at some other time. - if (list->active_threads_no_.fetch_sub(1) == 1 && // I am the last one accessing - head_rem != nullptr && // There is some garbage - cas<Node *>(list->removed, head_rem, - nullptr) // No new garbage was added. - ) { - // Delete all removed node following chain of next_rem starting - // from head_rem. - auto now = head_rem; - do { - auto next = load(now->next_rem); - delete now; - now = next; - } while (now != nullptr); - } - } - - IteratorBase &operator=(IteratorBase const &other) = delete; - IteratorBase &operator=(IteratorBase &&other) = delete; - - T &operator*() const - { - assert(valid()); - return curr->data; - } - T *operator->() const - { - assert(valid()); - return &(curr->data); - } - - bool valid() const { return curr != nullptr; } - - // Iterating is wait free. - It &operator++() - { - assert(valid()); - do { - prev = curr; - curr = load(curr->next); - } while (valid() && is_removed()); // Loop ends if end of list is - // found or if not removed - // element is found. - return this->derived(); - } - It &operator++(int) { return operator++(); } - - bool is_removed() - { - assert(valid()); - return load(curr->removed); - } - - // Returns IteratorBase to begining - void reset() - { - prev = nullptr; - curr = load(list->head); - if (valid() && is_removed()) { - operator++(); - } - } - - // Adds to the begining of list - // It is lock free but it isn't wait free. - void push(T &&data) - { - // It could be done with unique_ptr but while this could meen memory - // leak on excpetion, unique_ptr could meean use after free. Memory - // leak is less dangerous. - auto node = new Node(data); - Node *next = nullptr; - // Insert at begining of list. Retrys on failure. - do { - next = load(list->head); - // First connect to next. - store(node->next, next); - // Then try to set as head. - } while (!cas(list->head, next, node)); - - list->count_.fetch_add(1); - } - - // True only if this call removed the element. Only reason for fail is - // if the element is already removed. - // Remove has deadlock if another thread dies between marking node for - // removal and the disconnection. - // This can be improved with combinig the removed flag with prev.next or - // curr.next - bool remove() - { - assert(valid()); - // Try to logically remove it. - if (cas(curr->removed, false, true)) { - // I removed it!!! - // Try to disconnect it from list. - if (!disconnect()) { - // Disconnection failed because Node relative location in - // list changed. Whe firstly must find it again and then try - // to disconnect it again. - find_and_disconnect(); - } - // Add to list of to be garbage collected. - store(curr->next_rem, swap(list->removed, curr)); - list->count_.fetch_sub(1); - return true; - } - return false; - } - - friend bool operator==(const It &a, const It &b) - { - return a.curr == b.curr; - } - - friend bool operator!=(const It &a, const It &b) { return !(a == b); } - - private: - // Fids current element starting from the begining of the list Retrys - // until it succesffuly disconnects it. - void find_and_disconnect() - { - Node *bef = nullptr; - auto now = load(list->head); - auto next = load(curr->next); - while (now != nullptr) { - if (now == curr) { - // Found it. - prev = bef; // Set the correct previous node in list. - if (disconnect()) { - // succesffuly disconnected it. - return; - } - // Let's try again from the begining. - bef = nullptr; - now = load(list->head); - } else if (now == next) { // Comparison with next is - // optimization for early return. - return; - } else { - // Now isn't the one whe are looking for lets try next one. - bef = now; - now = load(now->next); - } - } - } - - // Trys to disconnect currrent element from - bool disconnect() - { - auto next = load(curr->next); - if (prev != nullptr) { - store(prev->next, next); - if (load(prev->removed)) { - // previous isn't previous any more. - return false; - } - } else if (!cas(list->head, curr, next)) { - return false; - } - return true; - } - - ConcurrentList *list; - Node *prev{nullptr}; - Node *curr; - }; - -public: - class ConstIterator : public IteratorBase<ConstIterator> - { - friend class ConcurrentList; - - public: - using IteratorBase<ConstIterator>::IteratorBase; - - const T &operator*() const - { - return IteratorBase<ConstIterator>::operator*(); - } - - const T *operator->() const - { - return IteratorBase<ConstIterator>::operator->(); - } - - operator const T &() const - { - return IteratorBase<ConstIterator>::operator T &(); - } - }; - - class Iterator : public IteratorBase<Iterator> - { - friend class ConcurrentList; - - public: - using IteratorBase<Iterator>::IteratorBase; - }; - -public: - ConcurrentList() = default; - - ConcurrentList(ConcurrentList &) = delete; - ConcurrentList(ConcurrentList &&) = delete; - - ~ConcurrentList() - { - auto now = head.load(); - while (now != nullptr) { - auto next = now->next.load(); - delete now; - now = next; - } + bool is_removed() { + assert(valid()); + return load(curr->removed); } - void operator=(ConcurrentList &) = delete; + // Returns IteratorBase to begining + void reset() { + prev = nullptr; + curr = load(list->head); + if (valid() && is_removed()) { + operator++(); + } + } - Iterator begin() { return Iterator(this); } + // Adds to the begining of list + // It is lock free but it isn't wait free. + void push(T &&data) { + // It could be done with unique_ptr but while this could meen memory + // leak on excpetion, unique_ptr could meean use after free. Memory + // leak is less dangerous. + auto node = new Node(data); + Node *next = nullptr; + // Insert at begining of list. Retrys on failure. + do { + next = load(list->head); + // First connect to next. + store(node->next, next); + // Then try to set as head. + } while (!cas(list->head, next, node)); - ConstIterator cbegin() { return ConstIterator(this); } + list->count_.fetch_add(1); + } - Iterator end() { return Iterator(); } + // True only if this call removed the element. Only reason for fail is + // if the element is already removed. + // Remove has deadlock if another thread dies between marking node for + // removal and the disconnection. + // This can be improved with combinig the removed flag with prev.next or + // curr.next + bool remove() { + assert(valid()); + // Try to logically remove it. + if (cas(curr->removed, false, true)) { + // I removed it!!! + // Try to disconnect it from list. + if (!disconnect()) { + // Disconnection failed because Node relative location in + // list changed. Whe firstly must find it again and then try + // to disconnect it again. + find_and_disconnect(); + } + // Add to list of to be garbage collected. + store(curr->next_rem, swap(list->removed, curr)); + list->count_.fetch_sub(1); + return true; + } + return false; + } - ConstIterator cend() { return ConstIterator(); } + friend bool operator==(const It &a, const It &b) { + return a.curr == b.curr; + } - std::size_t active_threads_no() { return active_threads_no_.load(); } - std::size_t size() { return count_.load(); } + friend bool operator!=(const It &a, const It &b) { return !(a == b); } -private: - // TODO: use lazy GC or something else as a garbage collection strategy - // use the same principle as in skiplist - std::atomic<std::size_t> active_threads_no_{0}; - std::atomic<std::size_t> count_{0}; - std::atomic<Node *> head{nullptr}; - std::atomic<Node *> removed{nullptr}; + private: + // Fids current element starting from the begining of the list Retrys + // until it succesffuly disconnects it. + void find_and_disconnect() { + Node *bef = nullptr; + auto now = load(list->head); + auto next = load(curr->next); + while (now != nullptr) { + if (now == curr) { + // Found it. + prev = bef; // Set the correct previous node in list. + if (disconnect()) { + // succesffuly disconnected it. + return; + } + // Let's try again from the begining. + bef = nullptr; + now = load(list->head); + } else if (now == next) { // Comparison with next is + // optimization for early return. + return; + } else { + // Now isn't the one whe are looking for lets try next one. + bef = now; + now = load(now->next); + } + } + } + + // Trys to disconnect currrent element from + bool disconnect() { + auto next = load(curr->next); + if (prev != nullptr) { + store(prev->next, next); + if (load(prev->removed)) { + // previous isn't previous any more. + return false; + } + } else if (!cas(list->head, curr, next)) { + return false; + } + return true; + } + + ConcurrentList *list; + Node *prev{nullptr}; + Node *curr; + }; + + public: + class ConstIterator : public IteratorBase<ConstIterator> { + friend class ConcurrentList; + + public: + using IteratorBase<ConstIterator>::IteratorBase; + + const T &operator*() const { + return IteratorBase<ConstIterator>::operator*(); + } + + const T *operator->() const { + return IteratorBase<ConstIterator>::operator->(); + } + + operator const T &() const { + return IteratorBase<ConstIterator>::operator T &(); + } + }; + + class Iterator : public IteratorBase<Iterator> { + friend class ConcurrentList; + + public: + using IteratorBase<Iterator>::IteratorBase; + }; + + public: + ConcurrentList() = default; + + ConcurrentList(ConcurrentList &) = delete; + ConcurrentList(ConcurrentList &&) = delete; + + ~ConcurrentList() { + auto now = head.load(); + while (now != nullptr) { + auto next = now->next.load(); + delete now; + now = next; + } + } + + void operator=(ConcurrentList &) = delete; + + Iterator begin() { return Iterator(this); } + + ConstIterator cbegin() { return ConstIterator(this); } + + Iterator end() { return Iterator(); } + + ConstIterator cend() { return ConstIterator(); } + + std::size_t active_threads_no() { return active_threads_no_.load(); } + std::size_t size() { return count_.load(); } + + private: + // TODO: use lazy GC or something else as a garbage collection strategy + // use the same principle as in skiplist + std::atomic<std::size_t> active_threads_no_{0}; + std::atomic<std::size_t> count_{0}; + std::atomic<Node *> head{nullptr}; + std::atomic<Node *> removed{nullptr}; }; diff --git a/src/data_structures/concurrent/concurrent_map.hpp b/src/data_structures/concurrent/concurrent_map.hpp index dee7aa645..1c9a0e579 100644 --- a/src/data_structures/concurrent/concurrent_map.hpp +++ b/src/data_structures/concurrent/concurrent_map.hpp @@ -12,82 +12,70 @@ using std::pair; * @tparam T is a type of data. */ template <typename K, typename T> -class ConcurrentMap -{ - typedef Item<K, T> item_t; - typedef SkipList<item_t> list; - typedef typename SkipList<item_t>::Iterator list_it; - typedef typename SkipList<item_t>::ConstIterator list_it_con; +class ConcurrentMap { + typedef Item<K, T> item_t; + typedef SkipList<item_t> list; + typedef typename SkipList<item_t>::Iterator list_it; + typedef typename SkipList<item_t>::ConstIterator list_it_con; -public: - ConcurrentMap() {} + public: + ConcurrentMap() {} - class Accessor : public AccessorBase<item_t> - { - friend class ConcurrentMap; + class Accessor : public AccessorBase<item_t> { + friend class ConcurrentMap; - using AccessorBase<item_t>::AccessorBase; + using AccessorBase<item_t>::AccessorBase; - private: - using AccessorBase<item_t>::accessor; + private: + using AccessorBase<item_t>::accessor; - public: - std::pair<list_it, bool> insert(const K &key, const T &data) - { - return accessor.insert(item_t(key, data)); - } + public: + std::pair<list_it, bool> insert(const K &key, const T &data) { + return accessor.insert(item_t(key, data)); + } - std::pair<list_it, bool> insert(const K &key, T &&data) - { - return accessor.insert(item_t(key, std::move(data))); - } + std::pair<list_it, bool> insert(const K &key, T &&data) { + return accessor.insert(item_t(key, std::move(data))); + } - std::pair<list_it, bool> insert(K &&key, T &&data) - { - return accessor.insert( - item_t(std::forward<K>(key), std::forward<T>(data))); - } + std::pair<list_it, bool> insert(K &&key, T &&data) { + return accessor.insert( + item_t(std::forward<K>(key), std::forward<T>(data))); + } - template <class... Args1, class... Args2> - std::pair<list_it, bool> emplace(const K &key, - std::tuple<Args1...> first_args, - std::tuple<Args2...> second_args) - { - return accessor.emplace( - key, std::piecewise_construct, - std::forward<std::tuple<Args1...>>(first_args), - std::forward<std::tuple<Args2...>>(second_args)); - } + template <class... Args1, class... Args2> + std::pair<list_it, bool> emplace(const K &key, + std::tuple<Args1...> first_args, + std::tuple<Args2...> second_args) { + return accessor.emplace(key, std::piecewise_construct, + std::forward<std::tuple<Args1...>>(first_args), + std::forward<std::tuple<Args2...>>(second_args)); + } - list_it_con find(const K &key) const { return accessor.find(key); } + list_it_con find(const K &key) const { return accessor.find(key); } - list_it find(const K &key) { return accessor.find(key); } + list_it find(const K &key) { return accessor.find(key); } - // Returns iterator to item or first larger if it doesn't exist. - list_it_con find_or_larger(const T &item) const - { - return accessor.find_or_larger(item); - } + // Returns iterator to item or first larger if it doesn't exist. + list_it_con find_or_larger(const T &item) const { + return accessor.find_or_larger(item); + } - // Returns iterator to item or first larger if it doesn't exist. - list_it find_or_larger(const T &item) - { - return accessor.find_or_larger(item); - } + // Returns iterator to item or first larger if it doesn't exist. + list_it find_or_larger(const T &item) { + return accessor.find_or_larger(item); + } - bool contains(const K &key) const - { - return this->find(key) != this->end(); - } + bool contains(const K &key) const { return this->find(key) != this->end(); } - bool remove(const K &key) { return accessor.remove(key); } - }; + bool remove(const K &key) { return accessor.remove(key); } + }; - Accessor access() { return Accessor(&skiplist); } + Accessor access() { return Accessor(&skiplist); } - // TODO: - // const Accessor access() const { return Accessor(&skiplist); } + // TODO: + // const Accessor access() const { return Accessor(&skiplist); } -private: - list skiplist; + private: + list skiplist; }; diff --git a/src/data_structures/concurrent/concurrent_multimap.hpp b/src/data_structures/concurrent/concurrent_multimap.hpp index 2d822f0bd..3d9d350ec 100644 --- a/src/data_structures/concurrent/concurrent_multimap.hpp +++ b/src/data_structures/concurrent/concurrent_multimap.hpp @@ -12,77 +12,63 @@ using std::pair; * @tparam T is a type of data. */ template <typename K, typename T> -class ConcurrentMultiMap -{ - typedef Item<K, T> item_t; - typedef SkipList<item_t> list; - typedef typename SkipList<item_t>::Iterator list_it; - typedef typename SkipList<item_t>::ConstIterator list_it_con; - typedef typename SkipList<item_t>::template MultiIterator<K> list_it_multi; +class ConcurrentMultiMap { + typedef Item<K, T> item_t; + typedef SkipList<item_t> list; + typedef typename SkipList<item_t>::Iterator list_it; + typedef typename SkipList<item_t>::ConstIterator list_it_con; + typedef typename SkipList<item_t>::template MultiIterator<K> list_it_multi; -public: - ConcurrentMultiMap() {} + public: + ConcurrentMultiMap() {} - class Accessor : public AccessorBase<item_t> - { - friend class ConcurrentMultiMap<K, T>; + class Accessor : public AccessorBase<item_t> { + friend class ConcurrentMultiMap<K, T>; - using AccessorBase<item_t>::AccessorBase; + using AccessorBase<item_t>::AccessorBase; - private: - using AccessorBase<item_t>::accessor; + private: + using AccessorBase<item_t>::accessor; - public: - list_it insert(const K &key, const T &data) - { - return accessor.insert_non_unique(item_t(key, data)); - } + public: + list_it insert(const K &key, const T &data) { + return accessor.insert_non_unique(item_t(key, data)); + } - list_it insert(const K &key, T &&data) - { - return accessor.insert_non_unique( - item_t(key, std::forward<T>(data))); - } + list_it insert(const K &key, T &&data) { + return accessor.insert_non_unique(item_t(key, std::forward<T>(data))); + } - list_it insert(K &&key, T &&data) - { - return accessor.insert_non_unique( - item_t(std::forward<K>(key), std::forward<T>(data))); - } + list_it insert(K &&key, T &&data) { + return accessor.insert_non_unique( + item_t(std::forward<K>(key), std::forward<T>(data))); + } - list_it_multi find_multi(const K &key) - { - return accessor.find_multi(key); - } + list_it_multi find_multi(const K &key) { return accessor.find_multi(key); } - list_it_con find(const K &key) const { return accessor.find(key); } + list_it_con find(const K &key) const { return accessor.find(key); } - list_it find(const K &key) { return accessor.find(key); } + list_it find(const K &key) { return accessor.find(key); } - // Returns iterator to item or first larger if it doesn't exist. - list_it_con find_or_larger(const T &item) const - { - return accessor.find_or_larger(item); - } + // Returns iterator to item or first larger if it doesn't exist. + list_it_con find_or_larger(const T &item) const { + return accessor.find_or_larger(item); + } - // Returns iterator to item or first larger if it doesn't exist. - list_it find_or_larger(const T &item) - { - return accessor.find_or_larger(item); - } + // Returns iterator to item or first larger if it doesn't exist. + list_it find_or_larger(const T &item) { + return accessor.find_or_larger(item); + } - bool contains(const K &key) const - { - return this->find(key) != this->end(); - } + bool contains(const K &key) const { return this->find(key) != this->end(); } - bool remove(const K &key) { return accessor.remove(key); } - }; + bool remove(const K &key) { return accessor.remove(key); } + }; - Accessor access() { return Accessor(&skiplist); } + Accessor access() { return Accessor(&skiplist); } - const Accessor access() const { return Accessor(&skiplist); } + const Accessor access() const { return Accessor(&skiplist); } -private: - list skiplist; + private: + list skiplist; }; diff --git a/src/data_structures/concurrent/concurrent_multiset.hpp b/src/data_structures/concurrent/concurrent_multiset.hpp index 980293280..1b4d32092 100644 --- a/src/data_structures/concurrent/concurrent_multiset.hpp +++ b/src/data_structures/concurrent/concurrent_multiset.hpp @@ -5,63 +5,54 @@ // Multi thread safe multiset based on skiplist. // T - type of data. template <class T> -class ConcurrentMultiSet -{ - typedef SkipList<T> list; - typedef typename SkipList<T>::Iterator list_it; - typedef typename SkipList<T>::ConstIterator list_it_con; +class ConcurrentMultiSet { + typedef SkipList<T> list; + typedef typename SkipList<T>::Iterator list_it; + typedef typename SkipList<T>::ConstIterator list_it_con; -public: - ConcurrentMultiSet() {} + public: + ConcurrentMultiSet() {} - class Accessor : public AccessorBase<T> - { - friend class ConcurrentMultiSet; + class Accessor : public AccessorBase<T> { + friend class ConcurrentMultiSet; - using AccessorBase<T>::AccessorBase; + using AccessorBase<T>::AccessorBase; - private: - using AccessorBase<T>::accessor; + private: + using AccessorBase<T>::accessor; - public: - list_it insert(const T &item) - { - return accessor.insert_non_unique(item); - } + public: + list_it insert(const T &item) { return accessor.insert_non_unique(item); } - list_it insert(T &&item) - { - return accessor.insert_non_unique(std::forward<T>(item)); - } + list_it insert(T &&item) { + return accessor.insert_non_unique(std::forward<T>(item)); + } - list_it_con find(const T &item) const { return accessor.find(item); } + list_it_con find(const T &item) const { return accessor.find(item); } - list_it find(const T &item) { return accessor.find(item); } + list_it find(const T &item) { return accessor.find(item); } - // Returns iterator to item or first larger if it doesn't exist. - list_it_con find_or_larger(const T &item) const - { - return accessor.find_or_larger(item); - } + // Returns iterator to item or first larger if it doesn't exist. + list_it_con find_or_larger(const T &item) const { + return accessor.find_or_larger(item); + } - // Returns iterator to item or first larger if it doesn't exist. - list_it find_or_larger(const T &item) - { - return accessor.find_or_larger(item); - } + // Returns iterator to item or first larger if it doesn't exist. + list_it find_or_larger(const T &item) { + return accessor.find_or_larger(item); + } - bool contains(const T &item) const - { - return this->find(item) != this->end(); - } + bool contains(const T &item) const { + return this->find(item) != this->end(); + } - bool remove(const T &item) { return accessor.remove(item); } - }; + bool remove(const T &item) { return accessor.remove(item); } + }; - Accessor access() { return Accessor(&skiplist); } + Accessor access() { return Accessor(&skiplist); } - const Accessor access() const { return Accessor(&skiplist); } + const Accessor access() const { return Accessor(&skiplist); } -private: - list skiplist; + private: + list skiplist; }; diff --git a/src/data_structures/concurrent/concurrent_set.hpp b/src/data_structures/concurrent/concurrent_set.hpp index b748eb4f9..906803af0 100644 --- a/src/data_structures/concurrent/concurrent_set.hpp +++ b/src/data_structures/concurrent/concurrent_set.hpp @@ -5,13 +5,13 @@ // Multi thread safe set based on skiplist. // T - type of data. -template<class T> +template <class T> class ConcurrentSet { typedef SkipList<T> list; typedef typename SkipList<T>::Iterator list_it; typedef typename SkipList<T>::ConstIterator list_it_con; -public: + public: ConcurrentSet() {} class Accessor : public AccessorBase<T> { @@ -19,10 +19,10 @@ public: using AccessorBase<T>::AccessorBase; - private: + private: using AccessorBase<T>::accessor; - public: + public: std::pair<list_it, bool> insert(const T &item) { return accessor.insert(item); } @@ -36,19 +36,19 @@ public: list_it find(const T &item) { return accessor.find(item); } // Returns iterator to item or first larger if it doesn't exist. - template<class K> + template <class K> list_it_con find_or_larger(const K &item) const { return accessor.find_or_larger(item); } // Returns iterator to item or first larger if it doesn't exist. - template<class K> + template <class K> list_it find_or_larger(const K &item) { return accessor.find_or_larger(item); } // Returns iterator to item or first larger if it doesn't exist. - template<class K> + template <class K> list_it_con cfind_or_larger(const K &item) { return accessor.template find_or_larger<list_it_con, K>(item); } @@ -64,6 +64,6 @@ public: const Accessor access() const { return Accessor(&skiplist); } -private: + private: list skiplist; }; diff --git a/src/data_structures/concurrent/skiplist.hpp b/src/data_structures/concurrent/skiplist.hpp index 8bef383bf..05783a8ac 100644 --- a/src/data_structures/concurrent/skiplist.hpp +++ b/src/data_structures/concurrent/skiplist.hpp @@ -192,9 +192,7 @@ class SkipList : private Lockable<lock_t> { this->data.emplace(std::forward<Args>(args)...); } - Node(const T &data, uint8_t height) : Node(height) { - this->data.set(data); - } + Node(const T &data, uint8_t height) : Node(height) { this->data.set(data); } Node(T &&data, uint8_t height) : Node(height) { this->data.set(std::move(data)); @@ -391,8 +389,7 @@ class SkipList : private Lockable<lock_t> { pred = node, node = pred->forward(level); } - if (level_found == -1 && !less(prev, node)) - level_found = level; + if (level_found == -1 && !less(prev, node)) level_found = level; preds_[level] = pred; } @@ -955,7 +952,8 @@ class SkipList : private Lockable<lock_t> { * of node. */ // TODO this code is not DRY w.r.t. the other insert function (rvalue ref) - std::pair<Iterator, bool> insert(Node *preds[], Node *succs[], const T &data) { + std::pair<Iterator, bool> insert(Node *preds[], Node *succs[], + const T &data) { while (true) { // TODO: before here was data.first auto level = find_path(this, H - 1, data, preds, succs); @@ -978,9 +976,9 @@ class SkipList : private Lockable<lock_t> { // has the locks if (!lock_nodes<true>(height, guards, preds, succs)) continue; - return {insert_here(Node::create(data, height), preds, succs, - height, guards), - true}; + return { + insert_here(Node::create(data, height), preds, succs, height, guards), + true}; } } diff --git a/src/data_structures/concurrent/skiplist_gc.hpp b/src/data_structures/concurrent/skiplist_gc.hpp index 6bacfab7c..c5c4098f7 100644 --- a/src/data_structures/concurrent/skiplist_gc.hpp +++ b/src/data_structures/concurrent/skiplist_gc.hpp @@ -3,56 +3,54 @@ // TODO: remove from here and from the project #include <iostream> +#include "logging/loggable.hpp" #include "memory/freelist.hpp" #include "memory/lazy_gc.hpp" #include "threading/sync/spinlock.hpp" -#include "logging/loggable.hpp" template <class T, class lock_t = SpinLock> -class SkiplistGC : public LazyGC<SkiplistGC<T, lock_t>, lock_t>, public Loggable -{ -public: - SkiplistGC() : Loggable("SkiplistGC") {} +class SkiplistGC : public LazyGC<SkiplistGC<T, lock_t>, lock_t>, + public Loggable { + public: + SkiplistGC() : Loggable("SkiplistGC") {} - // release_ref method should be called by a thread - // when the thread finish it job over object - // which has to be lazy cleaned - // if thread counter becames zero, all objects in the local_freelist - // are going to be deleted - // the only problem with this approach is that - // GC may never be called, but for now we can deal with that - void release_ref() + // release_ref method should be called by a thread + // when the thread finish it job over object + // which has to be lazy cleaned + // if thread counter becames zero, all objects in the local_freelist + // are going to be deleted + // the only problem with this approach is that + // GC may never be called, but for now we can deal with that + void release_ref() { + std::vector<T *> local_freelist; + + // take freelist if there is no more threads { - std::vector<T *> local_freelist; - - // take freelist if there is no more threads - { - auto lock = this->acquire_unique(); - assert(this->count > 0); - --this->count; - if (this->count == 0) { - freelist.swap(local_freelist); - } - } - - if (local_freelist.size() > 0) { - logger.trace("GC started"); - logger.trace("Local list size: {}", local_freelist.size()); - long long counter = 0; - // destroy all elements from local_freelist - for (auto element : local_freelist) { - - if (element->flags.is_marked()) { - T::destroy(element); - counter++; - } - } - logger.trace("Number of destroyed elements: {}", counter); - } + auto lock = this->acquire_unique(); + assert(this->count > 0); + --this->count; + if (this->count == 0) { + freelist.swap(local_freelist); + } } - void collect(T *node) { freelist.add(node); } + if (local_freelist.size() > 0) { + logger.trace("GC started"); + logger.trace("Local list size: {}", local_freelist.size()); + long long counter = 0; + // destroy all elements from local_freelist + for (auto element : local_freelist) { + if (element->flags.is_marked()) { + T::destroy(element); + counter++; + } + } + logger.trace("Number of destroyed elements: {}", counter); + } + } -private: - FreeList<T> freelist; + void collect(T *node) { freelist.add(node); } + + private: + FreeList<T> freelist; }; diff --git a/src/data_structures/kdtree/build.hpp b/src/data_structures/kdtree/build.hpp index 9ebd9700e..26fcb79b1 100644 --- a/src/data_structures/kdtree/build.hpp +++ b/src/data_structures/kdtree/build.hpp @@ -1,11 +1,11 @@ #pragma once -#include <vector> #include <algorithm> #include <functional> +#include <vector> -#include "math.hpp" #include "kdnode.hpp" +#include "math.hpp" namespace kd { @@ -13,55 +13,52 @@ template <class T, class U> using Nodes = std::vector<KdNode<T, U>*>; template <class T, class U> -KdNode<T, U>* build(Nodes<T, U>& nodes, byte axis = 0) -{ - // if there are no elements left, we've completed building of this branch - if(nodes.empty()) - return nullptr; +KdNode<T, U>* build(Nodes<T, U>& nodes, byte axis = 0) { + // if there are no elements left, we've completed building of this branch + if (nodes.empty()) return nullptr; - // comparison function to use for sorting the elements - auto fsort = [axis](KdNode<T, U>* a, KdNode<T, U>* b) -> bool - { return kd::math::axial_distance(a->coord, b->coord, axis) < 0; }; + // comparison function to use for sorting the elements + auto fsort = [axis](KdNode<T, U>* a, KdNode<T, U>* b) -> bool { + return kd::math::axial_distance(a->coord, b->coord, axis) < 0; + }; - size_t median = nodes.size() / 2; + size_t median = nodes.size() / 2; - // partial sort nodes vector to compute median and ensure that elements - // less than median are positioned before the median so we can slice it - // nicely + // partial sort nodes vector to compute median and ensure that elements + // less than median are positioned before the median so we can slice it + // nicely - // internal implementation is O(n) worst case - // tl;dr http://en.wikipedia.org/wiki/Introselect - std::nth_element(nodes.begin(), nodes.begin() + median, nodes.end(), fsort); + // internal implementation is O(n) worst case + // tl;dr http://en.wikipedia.org/wiki/Introselect + std::nth_element(nodes.begin(), nodes.begin() + median, nodes.end(), fsort); - // set axis for the node - auto node = nodes.at(median); - node->axis = axis; - - // slice the vector into two halves - auto left = Nodes<T, U>(nodes.begin(), nodes.begin() + median); - auto right = Nodes<T, U>(nodes.begin() + median + 1, nodes.end()); - - // recursively build left and right branches - node->left = build(left, axis ^ 1); - node->right = build(right, axis ^ 1); + // set axis for the node + auto node = nodes.at(median); + node->axis = axis; - return node; + // slice the vector into two halves + auto left = Nodes<T, U>(nodes.begin(), nodes.begin() + median); + auto right = Nodes<T, U>(nodes.begin() + median + 1, nodes.end()); + + // recursively build left and right branches + node->left = build(left, axis ^ 1); + node->right = build(right, axis ^ 1); + + return node; } template <class T, class U, class It> -KdNode<T, U>* build(It first, It last) -{ - Nodes<T, U> kdnodes; +KdNode<T, U>* build(It first, It last) { + Nodes<T, U> kdnodes; - std::transform(first, last, std::back_inserter(kdnodes), - [&](const std::pair<Point<T>, U>& element) { - auto key = element.first; - auto data = element.second; - return new KdNode<T, U>(key, data); - }); + std::transform(first, last, std::back_inserter(kdnodes), + [&](const std::pair<Point<T>, U>& element) { + auto key = element.first; + auto data = element.second; + return new KdNode<T, U>(key, data); + }); - // build the tree from the kdnodes and return the root node - return build(kdnodes); + // build the tree from the kdnodes and return the root node + return build(kdnodes); } - } diff --git a/src/data_structures/kdtree/kdnode.hpp b/src/data_structures/kdtree/kdnode.hpp index e3719d4c4..aed58b401 100644 --- a/src/data_structures/kdtree/kdnode.hpp +++ b/src/data_structures/kdtree/kdnode.hpp @@ -7,38 +7,40 @@ namespace kd { template <class T, class U> -class KdNode -{ -public: - KdNode(const U& data) - : axis(0), coord(Point<T>(0, 0)), left(nullptr), right(nullptr), data(data) { } +class KdNode { + public: + KdNode(const U& data) + : axis(0), + coord(Point<T>(0, 0)), + left(nullptr), + right(nullptr), + data(data) {} - KdNode(const Point<T>& coord, const U& data) - : axis(0), coord(coord), left(nullptr), right(nullptr), data(data) { } + KdNode(const Point<T>& coord, const U& data) + : axis(0), coord(coord), left(nullptr), right(nullptr), data(data) {} - KdNode(unsigned char axis, const Point<T>& coord, const U& data) - : axis(axis), coord(coord), left(nullptr), right(nullptr), data(data) { } + KdNode(unsigned char axis, const Point<T>& coord, const U& data) + : axis(axis), coord(coord), left(nullptr), right(nullptr), data(data) {} - KdNode(unsigned char axis, const Point<T>& coord, KdNode<T, U>* left, KdNode<T, U>* right, const U& data) - : axis(axis), coord(coord), left(left), right(right), data(data) { } + KdNode(unsigned char axis, const Point<T>& coord, KdNode<T, U>* left, + KdNode<T, U>* right, const U& data) + : axis(axis), coord(coord), left(left), right(right), data(data) {} - ~KdNode(); + ~KdNode(); - unsigned char axis; + unsigned char axis; - Point<T> coord; + Point<T> coord; - KdNode<T, U>* left; - KdNode<T, U>* right; + KdNode<T, U>* left; + KdNode<T, U>* right; - U data; + U data; }; template <class T, class U> -KdNode<T, U>::~KdNode() -{ - delete left; - delete right; +KdNode<T, U>::~KdNode() { + delete left; + delete right; } - } diff --git a/src/data_structures/kdtree/kdtree.hpp b/src/data_structures/kdtree/kdtree.hpp index 0474a2592..540557cda 100644 --- a/src/data_structures/kdtree/kdtree.hpp +++ b/src/data_structures/kdtree/kdtree.hpp @@ -5,36 +5,31 @@ #include "build.hpp" #include "nns.hpp" -namespace kd -{ +namespace kd { template <class T, class U> -class KdTree -{ -public: - KdTree() {} +class KdTree { + public: + KdTree() {} - template <class It> - KdTree(It first, It last); + template <class It> + KdTree(It first, It last); - const U& lookup(const Point<T>& pk) const; + const U& lookup(const Point<T>& pk) const; -protected: - std::unique_ptr<KdNode<float, U>> root; + protected: + std::unique_ptr<KdNode<float, U>> root; }; template <class T, class U> -const U& KdTree<T, U>::lookup(const Point<T>& pk) const -{ - // do a nearest neighbour search on the tree - return kd::nns(pk, root.get())->data; +const U& KdTree<T, U>::lookup(const Point<T>& pk) const { + // do a nearest neighbour search on the tree + return kd::nns(pk, root.get())->data; } template <class T, class U> template <class It> -KdTree<T, U>::KdTree(It first, It last) -{ - root.reset(kd::build<T, U, It>(first, last)); +KdTree<T, U>::KdTree(It first, It last) { + root.reset(kd::build<T, U, It>(first, last)); } - } diff --git a/src/data_structures/kdtree/math.hpp b/src/data_structures/kdtree/math.hpp index 1b1821319..e40e58c0a 100644 --- a/src/data_structures/kdtree/math.hpp +++ b/src/data_structures/kdtree/math.hpp @@ -1,7 +1,7 @@ #pragma once -#include <limits> #include <cmath> +#include <limits> #include "point.hpp" @@ -11,30 +11,24 @@ namespace math { using byte = unsigned char; // returns the squared distance between two points -template<class T> -T distance_sq(const Point<T>& a, const Point<T>& b) -{ - auto dx = a.longitude - b.longitude; - auto dy = a.latitude - b.latitude; - return dx * dx + dy * dy; +template <class T> +T distance_sq(const Point<T>& a, const Point<T>& b) { + auto dx = a.longitude - b.longitude; + auto dy = a.latitude - b.latitude; + return dx * dx + dy * dy; } // returns the distance between two points -template<class T> -T distance(const Point<T>& a, const Point<T>& b) -{ - return std::sqrt(distance_sq(a, b)); +template <class T> +T distance(const Point<T>& a, const Point<T>& b) { + return std::sqrt(distance_sq(a, b)); } // returns the distance between two points looking at a specific axis // \param axis 0 if abscissa else 1 if ordinate template <class T> -T axial_distance(const Point<T>& a, const Point<T>& b, byte axis) -{ - return axis == 0 ? - a.longitude - b.longitude: - a.latitude - b.latitude; -} - +T axial_distance(const Point<T>& a, const Point<T>& b, byte axis) { + return axis == 0 ? a.longitude - b.longitude : a.latitude - b.latitude; +} } } diff --git a/src/data_structures/kdtree/nns.hpp b/src/data_structures/kdtree/nns.hpp index e4da22de6..b5801b316 100644 --- a/src/data_structures/kdtree/nns.hpp +++ b/src/data_structures/kdtree/nns.hpp @@ -1,86 +1,80 @@ #pragma once +#include "kdnode.hpp" #include "math.hpp" #include "point.hpp" -#include "kdnode.hpp" namespace kd { -// helper class for calculating the nearest neighbour in a kdtree +// helper class for calculating the nearest neighbour in a kdtree template <class T, class U> -struct Result -{ - Result() - : node(nullptr), distance_sq(std::numeric_limits<T>::infinity()) {} +struct Result { + Result() : node(nullptr), distance_sq(std::numeric_limits<T>::infinity()) {} - Result(const KdNode<T, U>* node, T distance_sq) - : node(node), distance_sq(distance_sq) {} + Result(const KdNode<T, U>* node, T distance_sq) + : node(node), distance_sq(distance_sq) {} - const KdNode<T, U>* node; - T distance_sq; + const KdNode<T, U>* node; + T distance_sq; }; - // a recursive implementation for the kdtree nearest neighbour search // \param p the point for which we search for the nearest neighbour // \param node the root of the subtree during recursive descent // \param best the place to save the best result so far template <class T, class U> -void nns(const Point<T>& p, const KdNode<T, U>* const node, Result<T, U>& best) -{ - if(node == nullptr) - return; +void nns(const Point<T>& p, const KdNode<T, U>* const node, + Result<T, U>& best) { + if (node == nullptr) return; - T d = math::distance_sq(p, node->coord); + T d = math::distance_sq(p, node->coord); - // keep record of the closest point C found so far - if(d < best.distance_sq) - { - best.node = node; - best.distance_sq = d; - } + // keep record of the closest point C found so far + if (d < best.distance_sq) { + best.node = node; + best.distance_sq = d; + } - // where to traverse next? - // what to prune? + // where to traverse next? + // what to prune? - // | - // possible | - // prune * - // area | - - - - -* P - // | - // - // |----------| - // dx - // - - // possible prune - // RIGHT area - // - // --------*------ --- - // | | - // LEFT | - // | | dy - // | - // | | - // * p --- + // | + // possible | + // prune * + // area | - - - - -* P + // | + // + // |----------| + // dx + // - T axd = math::axial_distance(p, node->coord, node->axis); + // possible prune + // RIGHT area + // + // --------*------ --- + // | | + // LEFT | + // | | dy + // | + // | | + // * p --- - // traverse the subtree in order that - // maximizes the probability for pruning - auto near = axd > 0 ? node->right : node->left; - auto far = axd > 0 ? node->left : node->right; + T axd = math::axial_distance(p, node->coord, node->axis); - // try near first - nns(p, near, best); + // traverse the subtree in order that + // maximizes the probability for pruning + auto near = axd > 0 ? node->right : node->left; + auto far = axd > 0 ? node->left : node->right; - // prune subtrees once their bounding boxes say - // that they can't contain any point closer than C - if(axd * axd >= best.distance_sq) - return; + // try near first + nns(p, near, best); - // try other subtree - nns(p, far, best); + // prune subtrees once their bounding boxes say + // that they can't contain any point closer than C + if (axd * axd >= best.distance_sq) return; + + // try other subtree + nns(p, far, best); } // an implementation for the kdtree nearest neighbour search @@ -88,14 +82,12 @@ void nns(const Point<T>& p, const KdNode<T, U>* const node, Result<T, U>& best) // \param root the root of the tree // \return the nearest neighbour for the point p template <class T, class U> -const KdNode<T, U>* nns(const Point<T>& p, const KdNode<T, U>* root) -{ - Result<T, U> best; +const KdNode<T, U>* nns(const Point<T>& p, const KdNode<T, U>* root) { + Result<T, U> best; - // begin recursive search - nns(p, root, best); + // begin recursive search + nns(p, root, best); - return best.node; + return best.node; } - } diff --git a/src/data_structures/kdtree/point.hpp b/src/data_structures/kdtree/point.hpp index 113c9a627..11110ff45 100644 --- a/src/data_structures/kdtree/point.hpp +++ b/src/data_structures/kdtree/point.hpp @@ -5,26 +5,22 @@ namespace kd { template <class T> -class Point -{ -public: - Point(T latitude, T longitude) - : latitude(latitude), longitude(longitude) {} +class Point { + public: + Point(T latitude, T longitude) : latitude(latitude), longitude(longitude) {} - // latitude - // y - // ^ - // | - // 0---> x longitude + // latitude + // y + // ^ + // | + // 0---> x longitude - T latitude; - T longitude; + T latitude; + T longitude; - /// nice stream formatting with the standard << operator - friend std::ostream& operator<< (std::ostream& stream, const Point& p) { - return stream << "(lat: " << p.latitude - << ", lng: " << p.longitude << ')'; - } + /// nice stream formatting with the standard << operator + friend std::ostream& operator<<(std::ostream& stream, const Point& p) { + return stream << "(lat: " << p.latitude << ", lng: " << p.longitude << ')'; + } }; - } diff --git a/src/data_structures/list/lockfree_list.hpp b/src/data_structures/list/lockfree_list.hpp index 5f9a96924..57f6a35d1 100644 --- a/src/data_structures/list/lockfree_list.hpp +++ b/src/data_structures/list/lockfree_list.hpp @@ -1,243 +1,216 @@ #pragma once -#include <atomic> #include <unistd.h> +#include <atomic> -#include "threading/sync/lockable.hpp" #include "memory/hp.hpp" +#include "threading/sync/lockable.hpp" -namespace lockfree -{ +namespace lockfree { template <class T, size_t sleep_time = 250> -class List : Lockable<SpinLock> -{ -public: - List() = default; +class List : Lockable<SpinLock> { + public: + List() = default; - List(List&) = delete; - List(List&&) = delete; + List(List&) = delete; + List(List&&) = delete; - void operator=(List&) = delete; + void operator=(List&) = delete; - class read_iterator - { - public: - // constructor - read_iterator(T* curr) : - curr(curr), - hazard_ref(std::move(memory::HP::get().insert(curr))) {} + class read_iterator { + public: + // constructor + read_iterator(T* curr) + : curr(curr), hazard_ref(std::move(memory::HP::get().insert(curr))) {} - // no copy constructor - read_iterator(read_iterator& other) = delete; + // no copy constructor + read_iterator(read_iterator& other) = delete; - // move constructor - read_iterator(read_iterator&& other) : - curr(other.curr), - hazard_ref(std::move(other.hazard_ref)) {} - - T& operator*() { return *curr; } - T* operator->() { return curr; } + // move constructor + read_iterator(read_iterator&& other) + : curr(other.curr), hazard_ref(std::move(other.hazard_ref)) {} - operator T*() { return curr; } + T& operator*() { return *curr; } + T* operator->() { return curr; } - read_iterator& operator++() - { - auto& hp = memory::HP::get(); - hazard_ref = std::move(hp.insert(curr->next.load())); + operator T*() { return curr; } - curr = curr->next.load(); - return *this; - } - - read_iterator& operator++(int) - { - return operator++(); - } + read_iterator& operator++() { + auto& hp = memory::HP::get(); + hazard_ref = std::move(hp.insert(curr->next.load())); - bool has_next() - { - if (curr->next == nullptr) - return false; - return true; - } - - private: - T* curr; - memory::HP::reference hazard_ref; - }; - - class read_write_iterator - { - friend class List<T, sleep_time>; - - public: - read_write_iterator(T* prev, T* curr) : - prev(prev), - curr(curr), - hazard_ref(std::move(memory::HP::get().insert(curr))) {} - - // no copy constructor - read_write_iterator(read_write_iterator& other) = delete; - - // move constructor - read_write_iterator(read_write_iterator&& other) : - prev(other.prev), - curr(other.curr), - hazard_ref(std::move(other.hazard_ref)) {} - - T& operator*() { return *curr; } - T* operator->() { return curr; } - - operator T*() { return curr; } - - read_write_iterator& operator++() - { - auto& hp = memory::HP::get(); - hazard_ref = std::move(hp.insert(curr->next.load())); - - prev = curr; - curr = curr->next.load(); - return *this; - } - - read_write_iterator& operator++(int) - { - return operator++(); - } - - private: - T* prev; - T* curr; - memory::HP::reference hazard_ref; - }; - - read_iterator begin() - { - return read_iterator(head.load()); + curr = curr->next.load(); + return *this; } - read_write_iterator rw_begin() - { - return read_write_iterator(nullptr, head.load()); + read_iterator& operator++(int) { return operator++(); } + + bool has_next() { + if (curr->next == nullptr) return false; + return true; } - void push_front(T* node) - { - // we want to push an item to front of a list like this - // HEAD --> [1] --> [2] --> [3] --> ... - - // read the value of head atomically and set the node's next pointer - // to point to the same location as head + private: + T* curr; + memory::HP::reference hazard_ref; + }; - // HEAD --------> [1] --> [2] --> [3] --> ... - // | - // | - // NODE ------+ + class read_write_iterator { + friend class List<T, sleep_time>; - T* h = node->next = head.load(); + public: + read_write_iterator(T* prev, T* curr) + : prev(prev), + curr(curr), + hazard_ref(std::move(memory::HP::get().insert(curr))) {} - // atomically do: if the value of node->next is equal to current value - // of head, make the head to point to the node. - // if this fails (another thread has just made progress), update the - // value of node->next to the current value of head and retry again - // until you succeed + // no copy constructor + read_write_iterator(read_write_iterator& other) = delete; - // HEAD ----|CAS|----------> [1] --> [2] --> [3] --> ... - // | | | - // | v | - // +-------|CAS|---> NODE ---+ + // move constructor + read_write_iterator(read_write_iterator&& other) + : prev(other.prev), + curr(other.curr), + hazard_ref(std::move(other.hazard_ref)) {} - while(!head.compare_exchange_weak(h, node)) - { - node->next.store(h); - usleep(sleep_time); - } + T& operator*() { return *curr; } + T* operator->() { return curr; } - // the final state of the list after compare-and-swap looks like this + operator T*() { return curr; } - // HEAD [1] --> [2] --> [3] --> ... - // | | - // | | - // +---> NODE ---+ + read_write_iterator& operator++() { + auto& hp = memory::HP::get(); + hazard_ref = std::move(hp.insert(curr->next.load())); + + prev = curr; + curr = curr->next.load(); + return *this; } - bool remove(read_write_iterator& it) - { - // acquire an exclusive guard. - // we only care about push_front and iterator performance so we can - // we only care about push_front and iterator performance so we can - // tradeoff some remove speed for better reads and inserts. remove is - // used exclusively by the GC thread(s) so it can be slower - auto guard = acquire_unique(); + read_write_iterator& operator++(int) { return operator++(); } - // even though concurrent removes are synchronized, we need to worry - // about concurrent reads (solved by using atomics) and concurrent - // inserts to head (VERY dangerous, suffers from ABA problem, solved - // by simply not deleting the head node until it gets pushed further - // down the list) + private: + T* prev; + T* curr; + memory::HP::reference hazard_ref; + }; - // check if we're deleting the head node. we can't do that because of - // the ABA problem so just return false for now. the logic behind this - // is that this node will move further down the list next time the - // garbage collector traverses this list and therefore it will become - // deletable - if(it.prev == nullptr) { - std::cout << "prev null" << std::endl; - return false; - } + read_iterator begin() { return read_iterator(head.load()); } - // HEAD --> ... --> [i] --> [i + 1] --> [i + 2] --> ... - // - // prev curr next + read_write_iterator rw_begin() { + return read_write_iterator(nullptr, head.load()); + } - auto prev = it.prev; - auto curr = it.curr; - auto next = curr->next.load(std::memory_order_acquire); + void push_front(T* node) { + // we want to push an item to front of a list like this + // HEAD --> [1] --> [2] --> [3] --> ... - // effectively remove the curr node from the list + // read the value of head atomically and set the node's next pointer + // to point to the same location as head - // +---------------------+ - // | | - // | v - // HEAD --> ... --> [i] [i + 1] --> [i + 2] --> ... - // - // prev curr next + // HEAD --------> [1] --> [2] --> [3] --> ... + // | + // | + // NODE ------+ - prev->next.store(next, std::memory_order_release); + T* h = node->next = head.load(); - // curr is now removed from the list so no iterators will be able - // to reach it at this point, but we still need to check the hazard - // pointers and wait until everyone who currently holds a reference to - // it has stopped using it before we can physically delete it - - // TODO: test more appropriate - auto& hp = memory::HP::get(); + // atomically do: if the value of node->next is equal to current value + // of head, make the head to point to the node. + // if this fails (another thread has just made progress), update the + // value of node->next to the current value of head and retry again + // until you succeed - while(hp.find(reinterpret_cast<uintptr_t>(curr))) - sleep(sleep_time); - - delete curr; - - return true; + // HEAD ----|CAS|----------> [1] --> [2] --> [3] --> ... + // | | | + // | v | + // +-------|CAS|---> NODE ---+ + + while (!head.compare_exchange_weak(h, node)) { + node->next.store(h); + usleep(sleep_time); } -private: - std::atomic<T*> head { nullptr }; + // the final state of the list after compare-and-swap looks like this + + // HEAD [1] --> [2] --> [3] --> ... + // | | + // | | + // +---> NODE ---+ + } + + bool remove(read_write_iterator& it) { + // acquire an exclusive guard. + // we only care about push_front and iterator performance so we can + // we only care about push_front and iterator performance so we can + // tradeoff some remove speed for better reads and inserts. remove is + // used exclusively by the GC thread(s) so it can be slower + auto guard = acquire_unique(); + + // even though concurrent removes are synchronized, we need to worry + // about concurrent reads (solved by using atomics) and concurrent + // inserts to head (VERY dangerous, suffers from ABA problem, solved + // by simply not deleting the head node until it gets pushed further + // down the list) + + // check if we're deleting the head node. we can't do that because of + // the ABA problem so just return false for now. the logic behind this + // is that this node will move further down the list next time the + // garbage collector traverses this list and therefore it will become + // deletable + if (it.prev == nullptr) { + std::cout << "prev null" << std::endl; + return false; + } + + // HEAD --> ... --> [i] --> [i + 1] --> [i + 2] --> ... + // + // prev curr next + + auto prev = it.prev; + auto curr = it.curr; + auto next = curr->next.load(std::memory_order_acquire); + + // effectively remove the curr node from the list + + // +---------------------+ + // | | + // | v + // HEAD --> ... --> [i] [i + 1] --> [i + 2] --> ... + // + // prev curr next + + prev->next.store(next, std::memory_order_release); + + // curr is now removed from the list so no iterators will be able + // to reach it at this point, but we still need to check the hazard + // pointers and wait until everyone who currently holds a reference to + // it has stopped using it before we can physically delete it + + // TODO: test more appropriate + auto& hp = memory::HP::get(); + + while (hp.find(reinterpret_cast<uintptr_t>(curr))) sleep(sleep_time); + + delete curr; + + return true; + } + + private: + std::atomic<T*> head{nullptr}; }; template <class T, size_t sleep_time> bool operator==(typename List<T, sleep_time>::read_iterator& a, - typename List<T, sleep_time>::read_iterator& b) -{ - return a->curr == b->curr; + typename List<T, sleep_time>::read_iterator& b) { + return a->curr == b->curr; } template <class T, size_t sleep_time> bool operator!=(typename List<T, sleep_time>::read_iterator& a, - typename List<T, sleep_time>::read_iterator& b) -{ - return !operator==(a, b); + typename List<T, sleep_time>::read_iterator& b) { + return !operator==(a, b); } - } diff --git a/src/data_structures/map/rh_common.hpp b/src/data_structures/map/rh_common.hpp index 5df918c9b..c9a7c91eb 100644 --- a/src/data_structures/map/rh_common.hpp +++ b/src/data_structures/map/rh_common.hpp @@ -11,315 +11,275 @@ // D must have method K& get_key() // K must be comparable with ==. template <class K, class D, size_t init_size_pow2 = 2> -class RhBase -{ -protected: - class Combined - { +class RhBase { + protected: + class Combined { + public: + Combined() : data(0) {} - public: - Combined() : data(0) {} + Combined(D *data, size_t off) { this->data = ((size_t)data) | off; } - Combined(D *data, size_t off) { this->data = ((size_t)data) | off; } + bool valid() const { return data != 0; } - bool valid() const { return data != 0; } + size_t off() const { return data & 0x7; } - size_t off() const { return data & 0x7; } + void decrement_off_unsafe() { data--; } - void decrement_off_unsafe() { data--; } - - bool decrement_off() - { - if (off() > 0) { - data--; - return true; - } - return false; - } - - bool increment_off() - { - if (off() < 7) { - data++; - return true; - } - return false; - } - - D *ptr() const { return (D *)(data & (~(0x7))); } - - bool equal(const K &key, size_t off) - { - return this->off() == off && key == ptr()->get_key(); - } - - friend bool operator==(const Combined &a, const Combined &b) - { - return a.off() == b.off() && - a.ptr()->get_key() == b.ptr()->get_key(); - } - - friend bool operator!=(const Combined &a, const Combined &b) - { - return !(a == b); - } - - private: - size_t data; - }; - - // Base for all iterators. It can start from any point in map. - template <class It> - class IteratorBase : public Crtp<It> - { - protected: - IteratorBase() : map(nullptr) { advanced = index = ~((size_t)0); } - IteratorBase(const RhBase *map) - { - index = 0; - while (index < map->capacity && !map->array[index].valid()) { - index++; - } - if (index >= map->capacity) { - this->map = nullptr; - advanced = index = ~((size_t)0); - } else { - this->map = map; - advanced = index; - } - } - IteratorBase(const RhBase *map, size_t start) - : map(map), index(start), advanced(0) - { - } - - const RhBase *map; - - // How many times did whe advance. - size_t advanced; - - // Current position in array - size_t index; - - public: - IteratorBase(const IteratorBase &) = default; - IteratorBase(IteratorBase &&) = default; - - D *operator*() - { - assert(index < map->capacity && map->array[index].valid()); - return map->array[index].ptr(); - } - - D *operator->() - { - assert(index < map->capacity && map->array[index].valid()); - return map->array[index].ptr(); - } - - It &operator++() - { - assert(index < map->capacity && map->array[index].valid()); - auto mask = map->mask(); - do { - advanced++; - if (advanced >= map->capacity) { - // Whe have advanced more than the capacity of map is so whe - // are done. - map = nullptr; - advanced = index = ~((size_t)0); - break; - } - index = (index + 1) & mask; - } while (!map->array[index].valid()); // Check if there is element - // at current position. - - return this->derived(); - } - - It &operator++(int) { return operator++(); } - - friend bool operator==(const It &a, const It &b) - { - return a.index == b.index && a.map == b.map; - } - - friend bool operator!=(const It &a, const It &b) { return !(a == b); } - }; - -public: - class ConstIterator : public IteratorBase<ConstIterator> - { - friend class RhBase; - - protected: - ConstIterator(const RhBase *map) : IteratorBase<ConstIterator>(map) {} - ConstIterator(const RhBase *map, size_t index) - : IteratorBase<ConstIterator>(map, index) - { - } - - public: - ConstIterator() = default; - ConstIterator(const ConstIterator &) = default; - - const D *operator->() - { - return IteratorBase<ConstIterator>::operator->(); - } - - const D *operator*() - { - return IteratorBase<ConstIterator>::operator*(); - } - }; - - class Iterator : public IteratorBase<Iterator> - { - friend class RhBase; - - protected: - Iterator(const RhBase *map) : IteratorBase<Iterator>(map) {} - Iterator(const RhBase *map, size_t index) - : IteratorBase<Iterator>(map, index) - { - } - - public: - Iterator() = default; - Iterator(const Iterator &) = default; - }; - - RhBase() {} - - RhBase(const RhBase &other) { copy_from(other); } - - RhBase(RhBase &&other) { take_from(std::move(other)); } - - ~RhBase() { this->clear(); } - - RhBase &operator=(const RhBase &other) - { - clear(); - copy_from(other); - return *this; - } - - RhBase &operator=(RhBase &&other) - { - clear(); - take_from(std::move(other)); - return *this; - } - - Iterator begin() { return Iterator(this); } - - ConstIterator begin() const { return ConstIterator(this); } - - ConstIterator cbegin() const { return ConstIterator(this); } - - Iterator end() { return Iterator(); } - - ConstIterator end() const { return ConstIterator(); } - - ConstIterator cend() const { return ConstIterator(); } - -protected: - // Copys RAW BYTE data from other RhBase. - void copy_from(const RhBase &other) - { - capacity = other.capacity; - count = other.count; - if (capacity > 0) { - size_t bytes = sizeof(Combined) * capacity; - array = (Combined *)malloc(bytes); - memcpy(array, other.array, bytes); - - } else { - array = nullptr; - } - } - - // Takes data from other RhBase. - void take_from(RhBase &&other) - { - capacity = other.capacity; - count = other.count; - array = other.array; - other.array = nullptr; - other.count = 0; - other.capacity = 0; - } - - // Initiazes array with given capacity. - void init_array(size_t capacity) - { - size_t bytes = sizeof(Combined) * capacity; - array = (Combined *)malloc(bytes); - std::memset(array, 0, bytes); - this->capacity = capacity; - } - - // True if before array has some values. - // Before array must be released in the caller. - bool increase_size() - { - if (capacity == 0) { - // assert(array == nullptr && count == 0); - size_t new_size = 1 << init_size_pow2; - init_array(new_size); - return false; - } - size_t new_size = capacity * 2; - init_array(new_size); - count = 0; + bool decrement_off() { + if (off() > 0) { + data--; return true; + } + return false; } - Iterator create_it(size_t index) { return Iterator(this, index); } - ConstIterator create_it(size_t index) const - { - return ConstIterator(this, index); + bool increment_off() { + if (off() < 7) { + data++; + return true; + } + return false; } -public: - // Cleares all data. - void clear() - { - free(array); - array = nullptr; - capacity = 0; - count = 0; + D *ptr() const { return (D *)(data & (~(0x7))); } + + bool equal(const K &key, size_t off) { + return this->off() == off && key == ptr()->get_key(); } - size_t size() const { return count; } - -protected: - size_t before_index(size_t now, size_t mask) - { - return (now - 1) & mask; // THIS IS VALID + friend bool operator==(const Combined &a, const Combined &b) { + return a.off() == b.off() && a.ptr()->get_key() == b.ptr()->get_key(); } - size_t index(const K &key, size_t mask) const - { - return hash(std::hash<K>()(key)) & mask; + friend bool operator!=(const Combined &a, const Combined &b) { + return !(a == b); } - // NOTE: This is rather expensive but offers good distribution. - size_t hash(size_t x) const - { - x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9); - x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb); - x = x ^ (x >> 31); - return x; + private: + size_t data; + }; + + // Base for all iterators. It can start from any point in map. + template <class It> + class IteratorBase : public Crtp<It> { + protected: + IteratorBase() : map(nullptr) { advanced = index = ~((size_t)0); } + IteratorBase(const RhBase *map) { + index = 0; + while (index < map->capacity && !map->array[index].valid()) { + index++; + } + if (index >= map->capacity) { + this->map = nullptr; + advanced = index = ~((size_t)0); + } else { + this->map = map; + advanced = index; + } + } + IteratorBase(const RhBase *map, size_t start) + : map(map), index(start), advanced(0) {} + + const RhBase *map; + + // How many times did whe advance. + size_t advanced; + + // Current position in array + size_t index; + + public: + IteratorBase(const IteratorBase &) = default; + IteratorBase(IteratorBase &&) = default; + + D *operator*() { + assert(index < map->capacity && map->array[index].valid()); + return map->array[index].ptr(); } - size_t mask() const { return capacity - 1; } + D *operator->() { + assert(index < map->capacity && map->array[index].valid()); + return map->array[index].ptr(); + } - Combined *array = nullptr; - size_t capacity = 0; - size_t count = 0; + It &operator++() { + assert(index < map->capacity && map->array[index].valid()); + auto mask = map->mask(); + do { + advanced++; + if (advanced >= map->capacity) { + // Whe have advanced more than the capacity of map is so whe + // are done. + map = nullptr; + advanced = index = ~((size_t)0); + break; + } + index = (index + 1) & mask; + } while (!map->array[index].valid()); // Check if there is element + // at current position. - friend class IteratorBase<Iterator>; - friend class IteratorBase<ConstIterator>; + return this->derived(); + } + + It &operator++(int) { return operator++(); } + + friend bool operator==(const It &a, const It &b) { + return a.index == b.index && a.map == b.map; + } + + friend bool operator!=(const It &a, const It &b) { return !(a == b); } + }; + + public: + class ConstIterator : public IteratorBase<ConstIterator> { + friend class RhBase; + + protected: + ConstIterator(const RhBase *map) : IteratorBase<ConstIterator>(map) {} + ConstIterator(const RhBase *map, size_t index) + : IteratorBase<ConstIterator>(map, index) {} + + public: + ConstIterator() = default; + ConstIterator(const ConstIterator &) = default; + + const D *operator->() { return IteratorBase<ConstIterator>::operator->(); } + + const D *operator*() { return IteratorBase<ConstIterator>::operator*(); } + }; + + class Iterator : public IteratorBase<Iterator> { + friend class RhBase; + + protected: + Iterator(const RhBase *map) : IteratorBase<Iterator>(map) {} + Iterator(const RhBase *map, size_t index) + : IteratorBase<Iterator>(map, index) {} + + public: + Iterator() = default; + Iterator(const Iterator &) = default; + }; + + RhBase() {} + + RhBase(const RhBase &other) { copy_from(other); } + + RhBase(RhBase &&other) { take_from(std::move(other)); } + + ~RhBase() { this->clear(); } + + RhBase &operator=(const RhBase &other) { + clear(); + copy_from(other); + return *this; + } + + RhBase &operator=(RhBase &&other) { + clear(); + take_from(std::move(other)); + return *this; + } + + Iterator begin() { return Iterator(this); } + + ConstIterator begin() const { return ConstIterator(this); } + + ConstIterator cbegin() const { return ConstIterator(this); } + + Iterator end() { return Iterator(); } + + ConstIterator end() const { return ConstIterator(); } + + ConstIterator cend() const { return ConstIterator(); } + + protected: + // Copys RAW BYTE data from other RhBase. + void copy_from(const RhBase &other) { + capacity = other.capacity; + count = other.count; + if (capacity > 0) { + size_t bytes = sizeof(Combined) * capacity; + array = (Combined *)malloc(bytes); + memcpy(array, other.array, bytes); + + } else { + array = nullptr; + } + } + + // Takes data from other RhBase. + void take_from(RhBase &&other) { + capacity = other.capacity; + count = other.count; + array = other.array; + other.array = nullptr; + other.count = 0; + other.capacity = 0; + } + + // Initiazes array with given capacity. + void init_array(size_t capacity) { + size_t bytes = sizeof(Combined) * capacity; + array = (Combined *)malloc(bytes); + std::memset(array, 0, bytes); + this->capacity = capacity; + } + + // True if before array has some values. + // Before array must be released in the caller. + bool increase_size() { + if (capacity == 0) { + // assert(array == nullptr && count == 0); + size_t new_size = 1 << init_size_pow2; + init_array(new_size); + return false; + } + size_t new_size = capacity * 2; + init_array(new_size); + count = 0; + return true; + } + + Iterator create_it(size_t index) { return Iterator(this, index); } + ConstIterator create_it(size_t index) const { + return ConstIterator(this, index); + } + + public: + // Cleares all data. + void clear() { + free(array); + array = nullptr; + capacity = 0; + count = 0; + } + + size_t size() const { return count; } + + protected: + size_t before_index(size_t now, size_t mask) { + return (now - 1) & mask; // THIS IS VALID + } + + size_t index(const K &key, size_t mask) const { + return hash(std::hash<K>()(key)) & mask; + } + + // NOTE: This is rather expensive but offers good distribution. + size_t hash(size_t x) const { + x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9); + x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb); + x = x ^ (x >> 31); + return x; + } + + size_t mask() const { return capacity - 1; } + + Combined *array = nullptr; + size_t capacity = 0; + size_t count = 0; + + friend class IteratorBase<Iterator>; + friend class IteratorBase<ConstIterator>; }; diff --git a/src/data_structures/map/rh_hashmap.hpp b/src/data_structures/map/rh_hashmap.hpp index 277cc53f7..ff73a2355 100644 --- a/src/data_structures/map/rh_hashmap.hpp +++ b/src/data_structures/map/rh_hashmap.hpp @@ -12,166 +12,160 @@ // K must be comparable with ==. // HashMap behaves as if it isn't owner of entrys. template <class K, class D, size_t init_size_pow2 = 2> -class RhHashMap : public RhBase<K, D, init_size_pow2> -{ - typedef RhBase<K, D, init_size_pow2> base; - using base::array; - using base::index; - using base::capacity; - using base::count; - using typename base::Combined; +class RhHashMap : public RhBase<K, D, init_size_pow2> { + typedef RhBase<K, D, init_size_pow2> base; + using base::array; + using base::index; + using base::capacity; + using base::count; + using typename base::Combined; - void increase_size() - { - size_t old_size = capacity; - auto a = array; - if (base::increase_size()) { - for (int i = 0; i < old_size; i++) { - if (a[i].valid()) { - insert(a[i].ptr()); - } - } + void increase_size() { + size_t old_size = capacity; + auto a = array; + if (base::increase_size()) { + for (int i = 0; i < old_size; i++) { + if (a[i].valid()) { + insert(a[i].ptr()); } - - free(a); + } } -public: - using base::RhBase; + free(a); + } - bool contains(const K &key) { return find(key).is_present(); } + public: + using base::RhBase; - OptionPtr<D> find(const K key) - { - size_t mask = this->mask(); - size_t now = index(key, mask); - size_t off = 0; - size_t border = 8 <= capacity ? 8 : capacity; + bool contains(const K &key) { return find(key).is_present(); } - while (off < border) { - Combined other = array[now]; - if (other.valid()) { - auto other_off = other.off(); - if (other_off == off && key == other.ptr()->get_key()) { - // Found data. - return OptionPtr<D>(other.ptr()); + OptionPtr<D> find(const K key) { + size_t mask = this->mask(); + size_t now = index(key, mask); + size_t off = 0; + size_t border = 8 <= capacity ? 8 : capacity; - } else if (other_off < off) { // Other is rich - break; - } // Else other has equal or greater offset, so he is poor. - } else { - // Empty slot means that there is no searched data. - break; + while (off < border) { + Combined other = array[now]; + if (other.valid()) { + auto other_off = other.off(); + if (other_off == off && key == other.ptr()->get_key()) { + // Found data. + return OptionPtr<D>(other.ptr()); + + } else if (other_off < off) { // Other is rich + break; + } // Else other has equal or greater offset, so he is poor. + } else { + // Empty slot means that there is no searched data. + break; + } + + off++; + now = (now + 1) & mask; + } + return OptionPtr<D>(); + } + + // Inserts element. Returns true if element wasn't in the map. + bool insert(D *data) { + if (count < capacity) { + size_t mask = this->mask(); + auto key = std::ref(data->get_key()); + size_t now = index(key, mask); + size_t off = 0; + size_t border = 8 <= capacity ? 8 : capacity; + + while (off < border) { + Combined other = array[now]; + if (other.valid()) { + auto other_off = other.off(); + if (other_off == off && key == other.ptr()->get_key()) { + // Element already exists. + return false; + + } else if (other_off < off) { // Other is rich + // Set data. + array[now] = Combined(data, off); + + // Move other data to the higher indexes, + while (other.increment_off()) { + now = (now + 1) & mask; + auto tmp = array[now]; + array[now] = other; + other = tmp; + if (!other.valid()) { + count++; + return true; + } } + data = other.ptr(); + break; // Cant insert removed element because it would + // be to far from his real place. + } // Else other has equal or greater offset, so he is poor. + } else { + // Data can be placed in this empty slot. + array[now] = Combined(data, off); + count++; + return true; + } - off++; + off++; + now = (now + 1) & mask; + } + } + + // There isn't enough space for element pointed by data so whe must + // increase array. + increase_size(); + return insert(data); + } + + // Removes element. Returns removed element if it existed. + OptionPtr<D> remove(const K &key) { + size_t mask = this->mask(); + size_t now = index(key, mask); + size_t off = 0; + size_t border = 8 <= capacity ? 8 : capacity; + + while (off < border) { + Combined other = array[now]; + if (other.valid()) { + auto other_off = other.off(); + auto other_ptr = other.ptr(); + if (other_off == off && key == other_ptr->get_key()) { // Found it + + auto before = now; + // Whe must move other elements one slot lower. + do { + // This is alright even for off=0 on found element + // because it wont be seen. + other.decrement_off_unsafe(); + + array[before] = other; + before = now; now = (now + 1) & mask; - } - return OptionPtr<D>(); - } - - // Inserts element. Returns true if element wasn't in the map. - bool insert(D *data) - { - if (count < capacity) { - size_t mask = this->mask(); - auto key = std::ref(data->get_key()); - size_t now = index(key, mask); - size_t off = 0; - size_t border = 8 <= capacity ? 8 : capacity; - - while (off < border) { - Combined other = array[now]; - if (other.valid()) { - auto other_off = other.off(); - if (other_off == off && key == other.ptr()->get_key()) { - // Element already exists. - return false; - - } else if (other_off < off) { // Other is rich - // Set data. - array[now] = Combined(data, off); - - // Move other data to the higher indexes, - while (other.increment_off()) { - now = (now + 1) & mask; - auto tmp = array[now]; - array[now] = other; - other = tmp; - if (!other.valid()) { - count++; - return true; - } - } - data = other.ptr(); - break; // Cant insert removed element because it would - // be to far from his real place. - } // Else other has equal or greater offset, so he is poor. - } else { - // Data can be placed in this empty slot. - array[now] = Combined(data, off); - count++; - return true; - } - - off++; - now = (now + 1) & mask; - } - } - - // There isn't enough space for element pointed by data so whe must - // increase array. - increase_size(); - return insert(data); - } - - // Removes element. Returns removed element if it existed. - OptionPtr<D> remove(const K &key) - { - size_t mask = this->mask(); - size_t now = index(key, mask); - size_t off = 0; - size_t border = 8 <= capacity ? 8 : capacity; - - while (off < border) { - Combined other = array[now]; - if (other.valid()) { - auto other_off = other.off(); - auto other_ptr = other.ptr(); - if (other_off == off && - key == other_ptr->get_key()) { // Found it - - auto before = now; - // Whe must move other elements one slot lower. - do { - // This is alright even for off=0 on found element - // because it wont be seen. - other.decrement_off_unsafe(); - - array[before] = other; - before = now; - now = (now + 1) & mask; - other = array[now]; - } while (other.valid() && - other.off() > 0); // Exit if whe encounter empty - // slot or data which is exactly - // in slot which it want's to be. - - array[before] = Combined(); - count--; - return OptionPtr<D>(other_ptr); - - } else if (other_off < off) { // Other is rich - break; - } // Else other has equal or greater offset, so he is poor. - } else { - // If the element to be removed existed in map it would be here. - break; - } - - off++; - now = (now + 1) & mask; - } - return OptionPtr<D>(); + other = array[now]; + } while (other.valid() && + other.off() > 0); // Exit if whe encounter empty + // slot or data which is exactly + // in slot which it want's to be. + + array[before] = Combined(); + count--; + return OptionPtr<D>(other_ptr); + + } else if (other_off < off) { // Other is rich + break; + } // Else other has equal or greater offset, so he is poor. + } else { + // If the element to be removed existed in map it would be here. + break; + } + + off++; + now = (now + 1) & mask; } + return OptionPtr<D>(); + } }; diff --git a/src/data_structures/map/rh_hashmultimap.hpp b/src/data_structures/map/rh_hashmultimap.hpp index ce1b0aad0..994965d2e 100644 --- a/src/data_structures/map/rh_hashmultimap.hpp +++ b/src/data_structures/map/rh_hashmultimap.hpp @@ -37,322 +37,305 @@ // |...|c:a|c|...|c|b|...|b||a|...|a|...| => off(a) = 2 // ... template <class K, class D, size_t init_size_pow2 = 2> -class RhHashMultiMap : public RhBase<K, D, init_size_pow2> -{ - typedef RhBase<K, D, init_size_pow2> base; - using base::array; - using base::index; - using base::capacity; - using base::count; - using typename base::Combined; - using base::before_index; - using base::create_it; +class RhHashMultiMap : public RhBase<K, D, init_size_pow2> { + typedef RhBase<K, D, init_size_pow2> base; + using base::array; + using base::index; + using base::capacity; + using base::count; + using typename base::Combined; + using base::before_index; + using base::create_it; - void increase_size() - { - size_t old_size = capacity; - auto a = array; - if (base::increase_size()) { - for (int i = 0; i < old_size; i++) { - if (a[i].valid()) { - add(a[i].ptr()); - } - } + void increase_size() { + size_t old_size = capacity; + auto a = array; + if (base::increase_size()) { + for (int i = 0; i < old_size; i++) { + if (a[i].valid()) { + add(a[i].ptr()); } - - free(a); + } } -public: - using base::RhBase; - using base::end; - using typename base::ConstIterator; - using typename base::Iterator; + free(a); + } - bool contains(const K &key) const { return find_index(key).is_present(); } + public: + using base::RhBase; + using base::end; + using typename base::ConstIterator; + using typename base::Iterator; - Iterator find(const K &key_in) - { - auto index = find_index(key_in); - if (index) { - return create_it(index.get()); + bool contains(const K &key) const { return find_index(key).is_present(); } + + Iterator find(const K &key_in) { + auto index = find_index(key_in); + if (index) { + return create_it(index.get()); + } else { + return end(); + } + } + + ConstIterator find(const K &key_in) const { + auto index = find_index(key_in); + if (index) { + return create_it(index.get()); + } else { + return end(); + } + } + + private: + Option<size_t> find_index(const K &key_in) const { + if (count > 0) { + auto key = std::ref(key_in); + size_t mask = this->mask(); + size_t now = index(key, mask); + size_t off = 0; + size_t border = 8 <= capacity ? 8 : capacity; + Combined other = array[now]; + while (other.valid() && off < border) { + auto other_off = other.off(); + if (other_off == off && key == other.ptr()->get_key()) { + return Option<size_t>(now); + + } else if (other_off < off) { // Other is rich + break; + + } else { // Else other has equal or greater off, so he is poor. + if (UNLIKELY(skip(now, other, other_off, mask))) { + break; + } + off++; + } + } + } + + return Option<size_t>(); + } + + public: + // Inserts element. + void add(D *data) { add(data->get_key(), data); } + + // Inserts element with the given key. + void add(const K &key_in, D *data) { + assert(key_in == data->get_key()); + + if (count < capacity) { + auto key = std::ref(key_in); + size_t mask = this->mask(); + size_t now = index(key, mask); + size_t start = now; + size_t off = 0; + size_t border = 8 <= capacity ? 8 : capacity; + + Combined other = array[now]; + while (off < border) { + if (other.valid()) { + const size_t other_off = other.off(); + bool multi = false; + if (other_off == off && other.ptr()->get_key() == key) { + // Found the same + // Must skip same keyd values to insert new value at the + // end. + do { + now = (now + 1) & mask; + other = array[now]; + if (!other.valid()) { + // Found empty slot in which data ca be added. + set(now, data, off); + return; + } + } while (other.equal(key, off)); + // There is no empty slot after same keyed values. + multi = true; + } else if (other_off > off || + other_poor(other, mask, start, + now)) { // Else other has equal or + // greater off, so he is poor. + skip(now, other, other_off, mask); // TRUE IS IMPOSSIBLE + off++; + continue; + } + + // Data will be insrted at current slot and all other data + // will be displaced for one slot. + array[now] = Combined(data, off); + auto start_insert = now; + while (is_off_adjusted(other, mask, start_insert, now, multi) || + other.increment_off()) { + now = (now + 1) & mask; + auto tmp = array[now]; + array[now] = other; + other = tmp; + if (!other.valid()) { + // Found empty slot which means i can finish now. + count++; + return; + } + } + data = other.ptr(); + break; // Cant insert removed element } else { - return end(); + // Found empty slot for data. + set(now, data, off); + return; } + } } - ConstIterator find(const K &key_in) const - { - auto index = find_index(key_in); - if (index) { - return create_it(index.get()); - } else { - return end(); - } - } + // There is't enough space for data. + increase_size(); + add(data); + } -private: - Option<size_t> find_index(const K &key_in) const - { - if (count > 0) { - auto key = std::ref(key_in); - size_t mask = this->mask(); - size_t now = index(key, mask); - size_t off = 0; - size_t border = 8 <= capacity ? 8 : capacity; - Combined other = array[now]; - while (other.valid() && off < border) { - auto other_off = other.off(); - if (other_off == off && key == other.ptr()->get_key()) { - return Option<size_t>(now); + // Removes element equal by key and value. Returns true if it existed. + bool remove(D *data) { + if (count > 0) { + auto key = std::ref(data->get_key()); + size_t mask = this->mask(); + size_t now = index(key, mask); + size_t off = 0; + size_t border = 8 <= capacity ? 8 : capacity; + Combined other = array[now]; - } else if (other_off < off) { // Other is rich - break; - - } else { // Else other has equal or greater off, so he is poor. - if (UNLIKELY(skip(now, other, other_off, mask))) { - break; - } - off++; - } + while (other.valid() && off < border) { + const size_t other_off = other.off(); + if (other_off == off && key == other.ptr()->get_key()) { + // Found same key data. + auto founded = capacity; + size_t started = now; + bool multi = false; + // Must find slot with searched data. + do { + if (other.ptr() == data) { + // founded it. + founded = now; } - } - - return Option<size_t>(); - } - -public: - // Inserts element. - void add(D *data) { add(data->get_key(), data); } - - // Inserts element with the given key. - void add(const K &key_in, D *data) - { - assert(key_in == data->get_key()); - - if (count < capacity) { - auto key = std::ref(key_in); - size_t mask = this->mask(); - size_t now = index(key, mask); - size_t start = now; - size_t off = 0; - size_t border = 8 <= capacity ? 8 : capacity; - - Combined other = array[now]; - while (off < border) { - if (other.valid()) { - const size_t other_off = other.off(); - bool multi = false; - if (other_off == off && other.ptr()->get_key() == key) { - // Found the same - // Must skip same keyd values to insert new value at the - // end. - do { - now = (now + 1) & mask; - other = array[now]; - if (!other.valid()) { - // Found empty slot in which data ca be added. - set(now, data, off); - return; - } - } while (other.equal(key, off)); - // There is no empty slot after same keyed values. - multi = true; - } else if (other_off > off || - other_poor(other, mask, start, - now)) { // Else other has equal or - // greater off, so he is poor. - skip(now, other, other_off, mask); // TRUE IS IMPOSSIBLE - off++; - continue; - } - - // Data will be insrted at current slot and all other data - // will be displaced for one slot. - array[now] = Combined(data, off); - auto start_insert = now; - while (is_off_adjusted(other, mask, start_insert, now, - multi) || - other.increment_off()) { - now = (now + 1) & mask; - auto tmp = array[now]; - array[now] = other; - other = tmp; - if (!other.valid()) { - // Found empty slot which means i can finish now. - count++; - return; - } - } - data = other.ptr(); - break; // Cant insert removed element - } else { - // Found empty slot for data. - set(now, data, off); - return; - } - } - } - - // There is't enough space for data. - increase_size(); - add(data); - } - - // Removes element equal by key and value. Returns true if it existed. - bool remove(D *data) - { - if (count > 0) { - auto key = std::ref(data->get_key()); - size_t mask = this->mask(); - size_t now = index(key, mask); - size_t off = 0; - size_t border = 8 <= capacity ? 8 : capacity; - Combined other = array[now]; - - while (other.valid() && off < border) { - const size_t other_off = other.off(); - if (other_off == off && key == other.ptr()->get_key()) { - // Found same key data. - auto founded = capacity; - size_t started = now; - bool multi = false; - // Must find slot with searched data. - do { - if (other.ptr() == data) { - // founded it. - founded = now; - } - now = (now + 1) & mask; - other = array[now]; - if (!other.valid() || UNLIKELY(started == now)) { - // Reason is possibility of map full of same values. - break; - } - } while (other.equal(key, off) && (multi = true)); - - if (founded == capacity) { - // Didn't found the data. - return false; - } - - // Data will be removed by moving other data by one slot - // before. - auto bef = before_index(now, mask); - array[founded] = array[bef]; - - auto start_rem = bef; - while (other.valid() && - (is_off_adjusted_rem(other, mask, start_rem, bef, - now, multi) || - other.decrement_off())) { - array[bef] = other; - bef = now; - now = (now + 1) & mask; - other = array[now]; - } - - array[bef] = Combined(); - count--; - return true; - - } else if (other_off < off) { // Other is rich - break; - - } else { // Else other has equal or greater off, so he is poor. - // Must skip values of same keys but different key than - // data. - if (UNLIKELY(skip(now, other, other_off, mask))) { - break; - } - off++; - } - } - } - return false; - } - -private: - // Skips same key valus as other. true if whole map is full of same key - // values. - bool skip(size_t &now, Combined &other, size_t other_off, size_t mask) const - { - auto other_key = other.ptr()->get_key(); - size_t start = now; - do { now = (now + 1) & mask; other = array[now]; - if (UNLIKELY(start == now)) { // Reason is possibility of map - // full of same values. - return true; + if (!other.valid() || UNLIKELY(started == now)) { + // Reason is possibility of map full of same values. + break; } - } while (other.valid() && other.equal(other_key, other_off)); - return false; - } + } while (other.equal(key, off) && (multi = true)); - void set(size_t now, D *data, size_t off) - { - array[now] = Combined(data, off); - count++; - } - - // True if no adjusment is needed, false otherwise. - bool is_off_adjusted(Combined &com, size_t mask, size_t start, size_t now, - bool multi) - { - if (com.off() == 0) { // Must be adjusted + if (founded == capacity) { + // Didn't found the data. return false; - } - size_t cin = index(com.ptr()->get_key(), mask); - if (outside(start, now, cin)) { // Outside [start,now] interval - return multi; - } - auto a = array[cin]; - auto b = array[(cin + 1) & mask]; - return a == b; - // Check if different key has eneterd in to - // range of other. - } + } - bool other_poor(Combined other, size_t mask, size_t start, size_t now) - { - // If other index is smaller then he is poorer. - return outside_left_weak(start, now, - index(other.ptr()->get_key(), mask)); - } + // Data will be removed by moving other data by one slot + // before. + auto bef = before_index(now, mask); + array[founded] = array[bef]; - // True if no adjusment is needed, false otherwise. - bool is_off_adjusted_rem(Combined &com, size_t mask, size_t start, - size_t bef, size_t now, bool multi) - { - if (com.off() == 0) { // Must be adjusted - return false; - } - size_t cin = index(com.ptr()->get_key(), mask); - if (cin == bef) { - return false; - } - if (outside(start, now, cin)) { - return multi; - } - auto a = array[cin]; - auto b = array[before_index(cin, mask)]; - return b.valid() && a == b; - // Check if different key has eneterd in to - // range of other. - } + auto start_rem = bef; + while (other.valid() && (is_off_adjusted_rem(other, mask, start_rem, + bef, now, multi) || + other.decrement_off())) { + array[bef] = other; + bef = now; + now = (now + 1) & mask; + other = array[now]; + } - // True if p is uutside [start,end] interval - bool outside(size_t start, size_t end, size_t p) - { - return (start <= end && (p < start || p > end)) || - (end < start && p < start && p > end); - } + array[bef] = Combined(); + count--; + return true; - // True if p is outside <start,end] interval - bool outside_left_weak(size_t start, size_t end, size_t p) - { - return (start <= end && (p <= start || p > end)) || - (end < start && p <= start && p > end); + } else if (other_off < off) { // Other is rich + break; + + } else { // Else other has equal or greater off, so he is poor. + // Must skip values of same keys but different key than + // data. + if (UNLIKELY(skip(now, other, other_off, mask))) { + break; + } + off++; + } + } } + return false; + } + + private: + // Skips same key valus as other. true if whole map is full of same key + // values. + bool skip(size_t &now, Combined &other, size_t other_off, size_t mask) const { + auto other_key = other.ptr()->get_key(); + size_t start = now; + do { + now = (now + 1) & mask; + other = array[now]; + if (UNLIKELY(start == now)) { // Reason is possibility of map + // full of same values. + return true; + } + } while (other.valid() && other.equal(other_key, other_off)); + return false; + } + + void set(size_t now, D *data, size_t off) { + array[now] = Combined(data, off); + count++; + } + + // True if no adjusment is needed, false otherwise. + bool is_off_adjusted(Combined &com, size_t mask, size_t start, size_t now, + bool multi) { + if (com.off() == 0) { // Must be adjusted + return false; + } + size_t cin = index(com.ptr()->get_key(), mask); + if (outside(start, now, cin)) { // Outside [start,now] interval + return multi; + } + auto a = array[cin]; + auto b = array[(cin + 1) & mask]; + return a == b; + // Check if different key has eneterd in to + // range of other. + } + + bool other_poor(Combined other, size_t mask, size_t start, size_t now) { + // If other index is smaller then he is poorer. + return outside_left_weak(start, now, index(other.ptr()->get_key(), mask)); + } + + // True if no adjusment is needed, false otherwise. + bool is_off_adjusted_rem(Combined &com, size_t mask, size_t start, size_t bef, + size_t now, bool multi) { + if (com.off() == 0) { // Must be adjusted + return false; + } + size_t cin = index(com.ptr()->get_key(), mask); + if (cin == bef) { + return false; + } + if (outside(start, now, cin)) { + return multi; + } + auto a = array[cin]; + auto b = array[before_index(cin, mask)]; + return b.valid() && a == b; + // Check if different key has eneterd in to + // range of other. + } + + // True if p is uutside [start,end] interval + bool outside(size_t start, size_t end, size_t p) { + return (start <= end && (p < start || p > end)) || + (end < start && p < start && p > end); + } + + // True if p is outside <start,end] interval + bool outside_left_weak(size_t start, size_t end, size_t p) { + return (start <= end && (p <= start || p > end)) || + (end < start && p <= start && p > end); + } }; diff --git a/src/data_structures/ptr_int.hpp b/src/data_structures/ptr_int.hpp index 9cf0ba709..fdbe0c213 100644 --- a/src/data_structures/ptr_int.hpp +++ b/src/data_structures/ptr_int.hpp @@ -5,50 +5,45 @@ #include "utils/numerics/log2.hpp" template <typename PtrT> -struct PointerPackTraits -{ - // here is a place to embed something like platform specific things - // TODO: cover more cases - constexpr static int free_bits = utils::log2(alignof(PtrT)); +struct PointerPackTraits { + // here is a place to embed something like platform specific things + // TODO: cover more cases + constexpr static int free_bits = utils::log2(alignof(PtrT)); - static auto get_ptr(uintptr_t value) { return (PtrT)(value); } + static auto get_ptr(uintptr_t value) { return (PtrT)(value); } }; template <typename PtrT, int IntBits, typename IntT = unsigned, typename PtrTraits = PointerPackTraits<PtrT>> -class PtrInt -{ -private: - constexpr static int int_shift = PtrTraits::free_bits - IntBits; - constexpr static uintptr_t ptr_mask = - ~(uintptr_t)(((intptr_t)1 << PtrTraits::free_bits) - 1); - constexpr static uintptr_t int_mask = - (uintptr_t)(((intptr_t)1 << IntBits) - 1); +class PtrInt { + private: + constexpr static int int_shift = PtrTraits::free_bits - IntBits; + constexpr static uintptr_t ptr_mask = + ~(uintptr_t)(((intptr_t)1 << PtrTraits::free_bits) - 1); + constexpr static uintptr_t int_mask = + (uintptr_t)(((intptr_t)1 << IntBits) - 1); - uintptr_t value {0}; + uintptr_t value{0}; -public: - PtrInt(PtrT pointer, IntT integer) - { - set_ptr(pointer); - set_int(integer); - } + public: + PtrInt(PtrT pointer, IntT integer) { + set_ptr(pointer); + set_int(integer); + } - auto set_ptr(PtrT pointer) - { - auto integer = static_cast<uintptr_t>(get_int()); - auto ptr = reinterpret_cast<uintptr_t>(pointer); - value = (ptr_mask & ptr) | (integer << int_shift); - } + auto set_ptr(PtrT pointer) { + auto integer = static_cast<uintptr_t>(get_int()); + auto ptr = reinterpret_cast<uintptr_t>(pointer); + value = (ptr_mask & ptr) | (integer << int_shift); + } - auto set_int(IntT integer) - { - auto ptr = reinterpret_cast<uintptr_t>(get_ptr()); - auto int_shifted = static_cast<uintptr_t>(integer << int_shift); - value = (int_mask & int_shifted) | ptr; - } + auto set_int(IntT integer) { + auto ptr = reinterpret_cast<uintptr_t>(get_ptr()); + auto int_shifted = static_cast<uintptr_t>(integer << int_shift); + value = (int_mask & int_shifted) | ptr; + } - auto get_ptr() const { return PtrTraits::get_ptr(value & ptr_mask); } + auto get_ptr() const { return PtrTraits::get_ptr(value & ptr_mask); } - auto get_int() const { return (IntT)((value >> int_shift) & int_mask); } + auto get_int() const { return (IntT)((value >> int_shift) & int_mask); } }; diff --git a/src/data_structures/queue/bounded_spsc_queue.hpp b/src/data_structures/queue/bounded_spsc_queue.hpp index 8f2ed93c1..8fb181652 100644 --- a/src/data_structures/queue/bounded_spsc_queue.hpp +++ b/src/data_structures/queue/bounded_spsc_queue.hpp @@ -3,85 +3,75 @@ #include <atomic> #include <memory> -namespace lockfree -{ +namespace lockfree { template <class T, size_t N> -class BoundedSpscQueue -{ -public: - static constexpr size_t size = N; +class BoundedSpscQueue { + public: + static constexpr size_t size = N; - BoundedSpscQueue() = default; + BoundedSpscQueue() = default; - BoundedSpscQueue(const BoundedSpscQueue&) = delete; - BoundedSpscQueue(BoundedSpscQueue&&) = delete; + BoundedSpscQueue(const BoundedSpscQueue&) = delete; + BoundedSpscQueue(BoundedSpscQueue&&) = delete; - BoundedSpscQueue& operator=(const BoundedSpscQueue&) = delete; + BoundedSpscQueue& operator=(const BoundedSpscQueue&) = delete; - bool push(const T& item) - { - // load the current tail - // [] [] [1] [2] [3] [4] [5] [$] [] - // H T - auto t = tail.load(std::memory_order_relaxed); + bool push(const T& item) { + // load the current tail + // [] [] [1] [2] [3] [4] [5] [$] [] + // H T + auto t = tail.load(std::memory_order_relaxed); - // what will next tail be after we push - // [] [] [1] [2] [3] [4] [5] [$] [ ] - // H T T' - auto next = increment(t); + // what will next tail be after we push + // [] [] [1] [2] [3] [4] [5] [$] [ ] + // H T T' + auto next = increment(t); - // check if queue is full and do nothing if it is - // [3] [4] [5] [6] [7] [8] [$] [ 1 ] [2] - // T T'H - if(next == head.load(std::memory_order_acquire)) - return false; + // check if queue is full and do nothing if it is + // [3] [4] [5] [6] [7] [8] [$] [ 1 ] [2] + // T T'H + if (next == head.load(std::memory_order_acquire)) return false; - // insert the item into the empty spot - // [] [] [1] [2] [3] [4] [5] [ ] [] - // H T T' - items[t] = item; + // insert the item into the empty spot + // [] [] [1] [2] [3] [4] [5] [ ] [] + // H T T' + items[t] = item; - // release the tail to the consumer (serialization point) - // [] [] [1] [2] [3] [4] [5] [ $ ] [] - // H T T' - tail.store(next, std::memory_order_release); + // release the tail to the consumer (serialization point) + // [] [] [1] [2] [3] [4] [5] [ $ ] [] + // H T T' + tail.store(next, std::memory_order_release); - return true; - } + return true; + } - bool pop(T& item) - { - // [] [] [1] [2] [3] [4] [5] [$] [] - // H T - auto h = head.load(std::memory_order_relaxed); + bool pop(T& item) { + // [] [] [1] [2] [3] [4] [5] [$] [] + // H T + auto h = head.load(std::memory_order_relaxed); - // [] [] [] [] [ $ ] [] [] [] [] - // H T - if(h == tail.load(std::memory_order_acquire)) - return false; + // [] [] [] [] [ $ ] [] [] [] [] + // H T + if (h == tail.load(std::memory_order_acquire)) return false; - // move an item from the queue - item = std::move(items[h]); + // move an item from the queue + item = std::move(items[h]); - // serialization point wrt producer - // [] [] [] [2] [3] [4] [5] [$] [] - // H T - head.store(increment(h), std::memory_order_release); + // serialization point wrt producer + // [] [] [] [2] [3] [4] [5] [$] [] + // H T + head.store(increment(h), std::memory_order_release); - return true; - } + return true; + } -private: - static constexpr size_t capacity = N + 1; + private: + static constexpr size_t capacity = N + 1; - std::array<T, capacity> items; - std::atomic<size_t> head {0}, tail {0}; + std::array<T, capacity> items; + std::atomic<size_t> head{0}, tail{0}; - size_t increment(size_t idx) const - { - return (idx + 1) % capacity; - } + size_t increment(size_t idx) const { return (idx + 1) % capacity; } }; - } diff --git a/src/data_structures/queue/mpsc_queue.hpp b/src/data_structures/queue/mpsc_queue.hpp index 373cfc94b..d582a654a 100644 --- a/src/data_structures/queue/mpsc_queue.hpp +++ b/src/data_structures/queue/mpsc_queue.hpp @@ -3,12 +3,11 @@ #include <atomic> #include <memory> -namespace lockfree -{ +namespace lockfree { /** @brief Multiple-Producer Single-Consumer Queue * A wait-free (*) multiple-producer single-consumer queue. - * + * * features: * - wait-free * - fast producers (only one atomic XCHG and and one atomic store with @@ -22,7 +21,8 @@ namespace lockfree * * (*) there is a small window of inconsistency from the lock free design * see the url below for details - * URL: http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue + * URL: + * http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue * * mine is not intrusive for better modularity, but with slightly worse * performance because it needs to do two memory allocations instead of @@ -31,119 +31,111 @@ namespace lockfree * @tparam T Type of the items to store in the queue */ template <class T> -class MpscQueue -{ - struct Node - { - Node(Node* next, std::unique_ptr<T>&& item) - : next(next), item(std::forward<std::unique_ptr<T>>(item)) {} +class MpscQueue { + struct Node { + Node(Node* next, std::unique_ptr<T>&& item) + : next(next), item(std::forward<std::unique_ptr<T>>(item)) {} - std::atomic<Node*> next; - std::unique_ptr<T> item; - }; + std::atomic<Node*> next; + std::unique_ptr<T> item; + }; -public: - MpscQueue() - { - auto stub = new Node(nullptr, nullptr); - head.store(stub); - tail = stub; + public: + MpscQueue() { + auto stub = new Node(nullptr, nullptr); + head.store(stub); + tail = stub; + } + + ~MpscQueue() { + // purge all elements from the queue + while (pop()) { } - ~MpscQueue() - { - // purge all elements from the queue - while(pop()) {} + // we are left with a stub, delete that + delete tail; + } - // we are left with a stub, delete that - delete tail; + MpscQueue(MpscQueue&) = delete; + MpscQueue(MpscQueue&&) = delete; + + /** @brief Pushes an item into the queue. + * + * Pushes an item into the front of the queue. + * + * @param item std::unique_ptr<T> An item to push into the queue + * @return void + */ + void push(std::unique_ptr<T>&& item) { + push(new Node(nullptr, std::forward<std::unique_ptr<T>>(item))); + } + + /** @brief Pops a node from the queue. + * + * Pops and returns a node from the back of the queue. + * + * @return std::unique_ptr<T> A pointer to the node popped from the + * queue, nullptr if nothing was popped + */ + std::unique_ptr<T> pop() { + auto tail = this->tail; + + // serialization point wrt producers + auto next = tail->next.load(std::memory_order_acquire); + + if (next) { + // remove the last stub from the queue + // make [2] the next stub and return it's data + // + // H --> [n] <- ... <- [2] <--+--[STUB] +-- T + // | | + // +-----------+ + this->tail = next; + + // delete the stub node + // H --> [n] <- ... <- [STUB] <-- T + delete tail; + + return std::move(next->item); } - MpscQueue(MpscQueue&) = delete; - MpscQueue(MpscQueue&&) = delete; + return nullptr; + } - /** @brief Pushes an item into the queue. - * - * Pushes an item into the front of the queue. - * - * @param item std::unique_ptr<T> An item to push into the queue - * @return void - */ - void push(std::unique_ptr<T>&& item) - { - push(new Node(nullptr, std::forward<std::unique_ptr<T>>(item))); - } + private: + std::atomic<Node*> head; + Node* tail; - /** @brief Pops a node from the queue. - * - * Pops and returns a node from the back of the queue. - * - * @return std::unique_ptr<T> A pointer to the node popped from the - * queue, nullptr if nothing was popped - */ - std::unique_ptr<T> pop() - { - auto tail = this->tail; - - // serialization point wrt producers - auto next = tail->next.load(std::memory_order_acquire); + /** @brief Pushes a new node into the queue. + * + * Pushes a new node containing the item into the front of the queue. + * + * @param node Node* A pointer to node you want to push into the queue + * @return void + */ + void push(Node* node) { + // initial state + // H --> [3] <- [2] <- [STUB] <-- T - if(next) - { - // remove the last stub from the queue - // make [2] the next stub and return it's data - // - // H --> [n] <- ... <- [2] <--+--[STUB] +-- T - // | | - // +-----------+ - this->tail = next; + // serialization point wrt producers, acquire-release + auto old = head.exchange(node, std::memory_order_acq_rel); - // delete the stub node - // H --> [n] <- ... <- [STUB] <-- T - delete tail; + // after exchange + // H --> [4] [3] <- [2] <- [STUB] <-- T - return std::move(next->item); - } + // this is the window of inconsistency, if the producer is blocked + // here, the consumer is also blocked. but this window is extremely + // small, it's followed by a store operation which is a + // serialization point wrt consumer - return nullptr; - } + // old holds a pointer to node [3] and we need to link the [3] to a + // newly created node [4] using release semantics -private: - std::atomic<Node*> head; - Node* tail; + // serialization point wrt consumer, release + old->next.store(node, std::memory_order_release); - /** @brief Pushes a new node into the queue. - * - * Pushes a new node containing the item into the front of the queue. - * - * @param node Node* A pointer to node you want to push into the queue - * @return void - */ - void push(Node* node) - { - // initial state - // H --> [3] <- [2] <- [STUB] <-- T - - // serialization point wrt producers, acquire-release - auto old = head.exchange(node, std::memory_order_acq_rel); - - // after exchange - // H --> [4] [3] <- [2] <- [STUB] <-- T - - // this is the window of inconsistency, if the producer is blocked - // here, the consumer is also blocked. but this window is extremely - // small, it's followed by a store operation which is a - // serialization point wrt consumer - - // old holds a pointer to node [3] and we need to link the [3] to a - // newly created node [4] using release semantics - - // serialization point wrt consumer, release - old->next.store(node, std::memory_order_release); - - // finally, we have a queue like this - // H --> [4] <- [3] <- [2] <- [1] <-- T - } + // finally, we have a queue like this + // H --> [4] <- [3] <- [2] <- [1] <-- T + } }; - } diff --git a/src/data_structures/queue/slqueue.hpp b/src/data_structures/queue/slqueue.hpp index fe231acba..3e3fe8bc2 100644 --- a/src/data_structures/queue/slqueue.hpp +++ b/src/data_structures/queue/slqueue.hpp @@ -6,58 +6,48 @@ #include "threading/sync/spinlock.hpp" template <class T> -class SlQueue : Lockable<SpinLock> -{ -public: +class SlQueue : Lockable<SpinLock> { + public: + template <class... Args> + void emplace(Args&&... args) { + auto guard = acquire_unique(); + queue.emplace(args...); + } - template <class... Args> - void emplace(Args&&... args) - { - auto guard = acquire_unique(); - queue.emplace(args...); - } + void push(const T& item) { + auto guard = acquire_unique(); + queue.push(item); + } - void push(const T& item) - { - auto guard = acquire_unique(); - queue.push(item); - } + T front() { + auto guard = acquire_unique(); + return queue.front(); + } - T front() - { - auto guard = acquire_unique(); - return queue.front(); - } + void pop() { + auto guard = acquire_unique(); + queue.pop(); + } - void pop() - { - auto guard = acquire_unique(); - queue.pop(); - } + bool pop(T& item) { + auto guard = acquire_unique(); + if (queue.empty()) return false; - bool pop(T& item) - { - auto guard = acquire_unique(); - if(queue.empty()) - return false; + item = std::move(queue.front()); + queue.pop(); + return true; + } - item = std::move(queue.front()); - queue.pop(); - return true; - } + bool empty() { + auto guard = acquire_unique(); + return queue.empty(); + } - bool empty() - { - auto guard = acquire_unique(); - return queue.empty(); - } + size_t size() { + auto guard = acquire_unique(); + return queue.size(); + } - size_t size() - { - auto guard = acquire_unique(); - return queue.size(); - } - -private: - std::queue<T> queue; + private: + std::queue<T> queue; }; diff --git a/src/data_structures/slrbtree.hpp b/src/data_structures/slrbtree.hpp index 4dd7d874c..52cbc9bbd 100644 --- a/src/data_structures/slrbtree.hpp +++ b/src/data_structures/slrbtree.hpp @@ -5,10 +5,8 @@ #include "threading/sync/spinlock.hpp" template <class K, class T> -class SlRbTree : Lockable<SpinLock> -{ -public: - -private: - std::map<K, T> tree; +class SlRbTree : Lockable<SpinLock> { + public: + private: + std::map<K, T> tree; }; diff --git a/src/data_structures/slstack.hpp b/src/data_structures/slstack.hpp index 0acd3e626..3ec1b7534 100644 --- a/src/data_structures/slstack.hpp +++ b/src/data_structures/slstack.hpp @@ -2,31 +2,27 @@ #include <stack> -#include "threading/sync/spinlock.hpp" #include "threading/sync/lockable.hpp" +#include "threading/sync/spinlock.hpp" template <class T> -class SpinLockStack : Lockable<SpinLock> -{ -public: +class SpinLockStack : Lockable<SpinLock> { + public: + T pop() { + auto guard = acquire(); - T pop() - { - auto guard = acquire(); + T elem = stack.top(); + stack.pop(); - T elem = stack.top(); - stack.pop(); + return elem; + } - return elem; - } + void push(const T& elem) { + auto guard = acquire(); - void push(const T& elem) - { - auto guard = acquire(); + stack.push(elem); + } - stack.push(elem); - } - -private: - std::stack<T> stack; + private: + std::stack<T> stack; }; diff --git a/src/data_structures/stack/array_stack.hpp b/src/data_structures/stack/array_stack.hpp index a2b05934c..efef0b258 100644 --- a/src/data_structures/stack/array_stack.hpp +++ b/src/data_structures/stack/array_stack.hpp @@ -1,8 +1,6 @@ #pragma once template <class T> -class ArrayStack -{ - -private: +class ArrayStack { + private: }; diff --git a/src/data_structures/static_array.hpp b/src/data_structures/static_array.hpp index 5729dfe75..78bef417b 100644 --- a/src/data_structures/static_array.hpp +++ b/src/data_structures/static_array.hpp @@ -5,61 +5,54 @@ // data structure namespace short ds // TODO: document strategy related to namespace naming // (namespace names should be short but eazy to memorize) -namespace ds -{ +namespace ds { // static array is data structure which size (capacity) can be known at compile // time // this data structure isn't concurrent template <typename T, size_t N> -class static_array -{ -public: - // default constructor - static_array() {} +class static_array { + public: + // default constructor + static_array() {} - // explicit constructor which populates the data array with - // initial values, array structure after initialization - // is N * [initial_value] - explicit static_array(const T &initial_value) - { - for (size_t i = 0; i < size(); ++i) { - data[i] = initial_value; - } + // explicit constructor which populates the data array with + // initial values, array structure after initialization + // is N * [initial_value] + explicit static_array(const T &initial_value) { + for (size_t i = 0; i < size(); ++i) { + data[i] = initial_value; } + } - // returns array size - size_t size() const { return N; } + // returns array size + size_t size() const { return N; } - // returns element reference on specific index - T &operator[](size_t index) - { - runtime_assert(index < N, "Index " << index << " must be less than " - << N); - return data[index]; - } + // returns element reference on specific index + T &operator[](size_t index) { + runtime_assert(index < N, "Index " << index << " must be less than " << N); + return data[index]; + } - // returns const element reference on specific index - const T &operator[](size_t index) const - { - runtime_assert(index < N, "Index " << index << " must be less than " - << N); - return data[index]; - } + // returns const element reference on specific index + const T &operator[](size_t index) const { + runtime_assert(index < N, "Index " << index << " must be less than " << N); + return data[index]; + } - // returns begin iterator - T *begin() { return &data[0]; } + // returns begin iterator + T *begin() { return &data[0]; } - // returns const begin iterator - const T *begin() const { return &data[0]; } + // returns const begin iterator + const T *begin() const { return &data[0]; } - // returns end iterator - T *end() { return &data[N]; } + // returns end iterator + T *end() { return &data[N]; } - // returns const end iterator - const T *end() const { return &data[N]; } + // returns const end iterator + const T *end() const { return &data[N]; } -private: - T data[N]; + private: + T data[N]; }; } diff --git a/src/data_structures/union_find/union_find.hpp b/src/data_structures/union_find/union_find.hpp index c43db20b9..04cb08ae1 100644 --- a/src/data_structures/union_find/union_find.hpp +++ b/src/data_structures/union_find/union_find.hpp @@ -1,7 +1,7 @@ #pragma once -#include <vector> #include <memory> +#include <vector> template <class uintXX_t = uint32_t> /** @@ -9,93 +9,79 @@ template <class uintXX_t = uint32_t> * setting and checking in logarithmic complexity. Memory * complexity is linear. */ -class UnionFind -{ -public: - /** - * Constructor, creates a UnionFind structure of fixed size. - * - * @param n Number of elements in the data structure. - */ - UnionFind(uintXX_t n) : set_count(n), count(n), parent(n) - { - for(auto i = 0; i < n; ++i) - count[i] = 1, parent[i] = i; - } +class UnionFind { + public: + /** + * Constructor, creates a UnionFind structure of fixed size. + * + * @param n Number of elements in the data structure. + */ + UnionFind(uintXX_t n) : set_count(n), count(n), parent(n) { + for (auto i = 0; i < n; ++i) count[i] = 1, parent[i] = i; + } - /** - * Connects two elements (and thereby the sets they belong - * to). If they are already connected the function has no effect. - * - * Has O(alpha(n)) time complexity. - * - * @param p First element. - * @param q Second element. - */ - void connect(uintXX_t p, uintXX_t q) - { - auto rp = root(p); - auto rq = root(q); + /** + * Connects two elements (and thereby the sets they belong + * to). If they are already connected the function has no effect. + * + * Has O(alpha(n)) time complexity. + * + * @param p First element. + * @param q Second element. + */ + void connect(uintXX_t p, uintXX_t q) { + auto rp = root(p); + auto rq = root(q); - // if roots are equal, we don't have to do anything - if(rp == rq) - return; + // if roots are equal, we don't have to do anything + if (rp == rq) return; - // merge the smaller subtree to the root of the larger subtree - if(count[rp] < count[rq]) - parent[rp] = rq, count[rp] += count[rp]; - else - parent[rq] = rp, count[rp] += count[rq]; + // merge the smaller subtree to the root of the larger subtree + if (count[rp] < count[rq]) + parent[rp] = rq, count[rp] += count[rp]; + else + parent[rq] = rp, count[rp] += count[rq]; - // update the number of groups - set_count--; - } + // update the number of groups + set_count--; + } - /** - * Indicates if two elements are connected. Has O(alpha(n)) time - * complexity. - * - * @param p First element. - * @param q Second element. - * @return See above. - */ - bool find(uintXX_t p, uintXX_t q) - { - return root(p) == root(q); - } + /** + * Indicates if two elements are connected. Has O(alpha(n)) time + * complexity. + * + * @param p First element. + * @param q Second element. + * @return See above. + */ + bool find(uintXX_t p, uintXX_t q) { return root(p) == root(q); } - /** - * Returns the number of disjoint sets in this UnionFind. - * - * @return See above. - */ - uintXX_t size() const - { - return set_count; - } + /** + * Returns the number of disjoint sets in this UnionFind. + * + * @return See above. + */ + uintXX_t size() const { return set_count; } -private: - uintXX_t set_count; + private: + uintXX_t set_count; - // array of subtree counts - std::vector<uintXX_t> count; + // array of subtree counts + std::vector<uintXX_t> count; - // array of tree indices - std::vector<uintXX_t> parent; - - uintXX_t root(uintXX_t p) - { - auto r = p; - auto newp = p; + // array of tree indices + std::vector<uintXX_t> parent; - // find the node connected to itself, that's the root - while(parent[r] != r) - r = parent[r]; + uintXX_t root(uintXX_t p) { + auto r = p; + auto newp = p; - // do some path compression to enable faster searches - while(p != r) - newp = parent[p], parent[p] = r, p = newp; + // find the node connected to itself, that's the root + while (parent[r] != r) r = parent[r]; - return r; - } + // do some path compression to enable faster searches + while (p != r) newp = parent[p], parent[p] = r, p = newp; + + return r; + } }; diff --git a/src/database/creation_exception.hpp b/src/database/creation_exception.hpp index d05ffba17..44ca571dc 100644 --- a/src/database/creation_exception.hpp +++ b/src/database/creation_exception.hpp @@ -12,7 +12,6 @@ * be created. Typically due to database overload. */ class CreationException : public BasicException { -public: + public: using BasicException::BasicException; }; - diff --git a/src/database/graph_db.cpp b/src/database/graph_db.cpp index 9f2bfb4e9..d225a969b 100644 --- a/src/database/graph_db.cpp +++ b/src/database/graph_db.cpp @@ -1,10 +1,10 @@ +#include "database/graph_db.hpp" #include <storage/edge.hpp> #include "database/creation_exception.hpp" -#include "database/graph_db.hpp" //#include "snapshot/snapshoter.hpp" GraphDb::GraphDb(const std::string &name, bool import_snapshot) : name_(name) { -// if (import_snapshot) -// snap_engine.import(); + // if (import_snapshot) + // snap_engine.import(); } diff --git a/src/database/graph_db.hpp b/src/database/graph_db.hpp index e2387cc8c..99f8ba750 100644 --- a/src/database/graph_db.hpp +++ b/src/database/graph_db.hpp @@ -1,11 +1,11 @@ #pragma once -#include "data_structures/concurrent/skiplist.hpp" -#include "transactions/engine.hpp" -#include "mvcc/version_list.hpp" -#include "utils/pass_key.hpp" #include "data_structures/concurrent/concurrent_set.hpp" +#include "data_structures/concurrent/skiplist.hpp" +#include "mvcc/version_list.hpp" #include "storage/unique_object_store.hpp" +#include "transactions/engine.hpp" +#include "utils/pass_key.hpp" // forward declaring Edge and Vertex because they use // GraphDb::Label etc., and therefore include this header @@ -26,13 +26,11 @@ class EdgeAccessor; * exposed to client functions. The GraphDbAccessor is used for that. */ class GraphDb { - -public: - + public: // definitions for what data types are used for a Label, Property, EdgeType - using Label = std::string*; - using EdgeType = std::string*; - using Property = std::string*; + using Label = std::string *; + using EdgeType = std::string *; + using Property = std::string *; /** * Construct database with a custom name. @@ -52,19 +50,19 @@ public: tx::Engine tx_engine; /** garbage collector related to this database*/ -// TODO bring back garbage collection -// Garbage garbage = {tx_engine}; + // TODO bring back garbage collection + // Garbage garbage = {tx_engine}; -// TODO bring back shapshot engine -// SnapshotEngine snap_engine = {*this}; + // TODO bring back shapshot engine + // SnapshotEngine snap_engine = {*this}; // database name // TODO consider if this is even necessary const std::string name_; // main storage for the graph - SkipList<mvcc::VersionList<Vertex>*> vertices_; - SkipList<mvcc::VersionList<Edge>*> edges_; + SkipList<mvcc::VersionList<Vertex> *> vertices_; + SkipList<mvcc::VersionList<Edge> *> edges_; // unique object stores ConcurrentSet<std::string> labels_; diff --git a/src/database/graph_db_accessor.cpp b/src/database/graph_db_accessor.cpp index e2d5ae496..b431db2b7 100644 --- a/src/database/graph_db_accessor.cpp +++ b/src/database/graph_db_accessor.cpp @@ -1,37 +1,33 @@ -#include "database/creation_exception.hpp" #include "database/graph_db_accessor.hpp" +#include "database/creation_exception.hpp" -#include "storage/vertex.hpp" -#include "storage/vertex_accessor.hpp" #include "storage/edge.hpp" #include "storage/edge_accessor.hpp" +#include "storage/vertex.hpp" +#include "storage/vertex_accessor.hpp" +GraphDbAccessor::GraphDbAccessor(GraphDb& db) + : db_(db), transaction_(std::move(db.tx_engine.begin())) {} -GraphDbAccessor::GraphDbAccessor(GraphDb& db) : db_(db), transaction_(std::move(db.tx_engine.begin())) {} - -const std::string& GraphDbAccessor::name() const { - return db_.name_; -} +const std::string& GraphDbAccessor::name() const { return db_.name_; } VertexAccessor GraphDbAccessor::insert_vertex() { - // create a vertex auto vertex_vlist = new mvcc::VersionList<Vertex>(); - Vertex *vertex = vertex_vlist->insert(transaction_); + Vertex* vertex = vertex_vlist->insert(transaction_); // insert the newly created record into the main storage // TODO make the number of tries configurable for (int i = 0; i < 5; ++i) { bool success = db_.vertices_.access().insert(vertex_vlist).second; - if (success) - return VertexAccessor(*vertex_vlist, *vertex, *this); + if (success) return VertexAccessor(*vertex_vlist, *vertex, *this); // TODO sleep for some configurable amount of time } throw CreationException("Unable to create a Vertex after 5 attempts"); } -bool GraphDbAccessor::remove_vertex(VertexAccessor &vertex_accessor) { +bool GraphDbAccessor::remove_vertex(VertexAccessor& vertex_accessor) { // TODO consider if this works well with MVCC if (vertex_accessor.out_degree() > 0 || vertex_accessor.in_degree() > 0) return false; @@ -40,15 +36,13 @@ bool GraphDbAccessor::remove_vertex(VertexAccessor &vertex_accessor) { return true; } -void GraphDbAccessor::detach_remove_vertex(VertexAccessor &vertex_accessor) { +void GraphDbAccessor::detach_remove_vertex(VertexAccessor& vertex_accessor) { // removing edges via accessors is both safe // and it should remove all the pointers in the relevant // vertices (including this one) - for (auto edge_accessor : vertex_accessor.in()) - remove_edge(edge_accessor); + for (auto edge_accessor : vertex_accessor.in()) remove_edge(edge_accessor); - for (auto edge_accessor : vertex_accessor.out()) - remove_edge(edge_accessor); + for (auto edge_accessor : vertex_accessor.out()) remove_edge(edge_accessor); // mvcc removal of the vertex vertex_accessor.vlist_.remove(&vertex_accessor.update(), transaction_); @@ -60,24 +54,22 @@ std::vector<VertexAccessor> GraphDbAccessor::vertices() { std::vector<VertexAccessor> accessors; accessors.reserve(sl_accessor.size()); - for (auto vlist : sl_accessor){ + for (auto vlist : sl_accessor) { auto record = vlist->find(transaction_); - if (record == nullptr) - continue; + if (record == nullptr) continue; accessors.emplace_back(*vlist, *record, *this); - } + } return accessors; } -EdgeAccessor GraphDbAccessor::insert_edge( - VertexAccessor& from, - VertexAccessor& to, - GraphDb::EdgeType edge_type) { - +EdgeAccessor GraphDbAccessor::insert_edge(VertexAccessor& from, + VertexAccessor& to, + GraphDb::EdgeType edge_type) { // create an edge auto edge_vlist = new mvcc::VersionList<Edge>(); - Edge* edge = edge_vlist->insert(transaction_, from.vlist_, to.vlist_, edge_type); + Edge* edge = + edge_vlist->insert(transaction_, from.vlist_, to.vlist_, edge_type); // set the vertex connections to this edge from.update().out_.emplace_back(edge_vlist); @@ -87,8 +79,7 @@ EdgeAccessor GraphDbAccessor::insert_edge( // TODO make the number of tries configurable for (int i = 0; i < 5; ++i) { bool success = db_.edges_.access().insert(edge_vlist).second; - if (success) - return EdgeAccessor(*edge_vlist, *edge, *this); + if (success) return EdgeAccessor(*edge_vlist, *edge, *this); // TODO sleep for some amount of time } @@ -99,7 +90,8 @@ EdgeAccessor GraphDbAccessor::insert_edge( * Removes the given edge pointer from a vector of pointers. * Does NOT maintain edge pointer ordering (for efficiency). */ -void swap_out_edge(std::vector<mvcc::VersionList<Edge>*> &edges, mvcc::VersionList<Edge> *edge) { +void swap_out_edge(std::vector<mvcc::VersionList<Edge>*>& edges, + mvcc::VersionList<Edge>* edge) { auto found = std::find(edges.begin(), edges.end(), edge); assert(found != edges.end()); std::swap(*found, edges.back()); @@ -118,10 +110,9 @@ std::vector<EdgeAccessor> GraphDbAccessor::edges() { std::vector<EdgeAccessor> accessors; accessors.reserve(sl_accessor.size()); - for (auto vlist : sl_accessor){ + for (auto vlist : sl_accessor) { auto record = vlist->find(transaction_); - if (record == nullptr) - continue; + if (record == nullptr) continue; accessors.emplace_back(*vlist, *record, *this); } @@ -136,11 +127,13 @@ std::string& GraphDbAccessor::label_name(const GraphDb::Label label) const { return *label; } -GraphDb::EdgeType GraphDbAccessor::edge_type(const std::string& edge_type_name){ +GraphDb::EdgeType GraphDbAccessor::edge_type( + const std::string& edge_type_name) { return &(*db_.edge_types_.access().insert(edge_type_name).first); } -std::string& GraphDbAccessor::edge_type_name(const GraphDb::EdgeType edge_type) const { +std::string& GraphDbAccessor::edge_type_name( + const GraphDb::EdgeType edge_type) const { return *edge_type; } @@ -148,6 +141,7 @@ GraphDb::Property GraphDbAccessor::property(const std::string& property_name) { return &(*db_.properties_.access().insert(property_name).first); } -std::string& GraphDbAccessor::property_name(const GraphDb::Property property) const { +std::string& GraphDbAccessor::property_name( + const GraphDb::Property property) const { return *property; } diff --git a/src/database/graph_db_accessor.hpp b/src/database/graph_db_accessor.hpp index 8c9f27dfd..a73eeaaae 100644 --- a/src/database/graph_db_accessor.hpp +++ b/src/database/graph_db_accessor.hpp @@ -8,7 +8,6 @@ #include "graph_db.hpp" #include "transactions/transaction.hpp" - /** * An accessor for the database object: exposes functions * for operating on the database. All the functions in @@ -18,9 +17,7 @@ * the creation. */ class GraphDbAccessor { - -public: - + public: /** * Creates an accessor for the given database. * @@ -48,7 +45,7 @@ public: * @param vertex_accessor Accessor to vertex. * @return If or not the vertex was deleted. */ - bool remove_vertex(VertexAccessor &vertex_accessor); + bool remove_vertex(VertexAccessor& vertex_accessor); /** * Removes the vertex of the given accessor along with all it's outgoing @@ -56,7 +53,7 @@ public: * * @param vertex_accessor Accessor to a vertex. */ - void detach_remove_vertex(VertexAccessor &vertex_accessor); + void detach_remove_vertex(VertexAccessor& vertex_accessor); /** * Returns accessors to all the vertices in the graph. @@ -73,7 +70,8 @@ public: * @param type Edge type. * @return An accessor to the edge. */ - EdgeAccessor insert_edge(VertexAccessor& from, VertexAccessor& to, GraphDb::EdgeType type); + EdgeAccessor insert_edge(VertexAccessor& from, VertexAccessor& to, + GraphDb::EdgeType type); /** * Removes an edge from the graph. @@ -134,6 +132,6 @@ public: /** The current transaction */ tx::Transaction transaction_; -private: + private: GraphDb& db_; }; diff --git a/src/dbms/cleaner.cpp b/src/dbms/cleaner.cpp index 29667a2c7..e0503f0f6 100644 --- a/src/dbms/cleaner.cpp +++ b/src/dbms/cleaner.cpp @@ -9,65 +9,61 @@ #include "logging/default.hpp" -Cleaning::Cleaning(ConcurrentMap<std::string, GraphDb> &dbs, size_t cleaning_cycle) - : dbms(dbs), cleaning_cycle(cleaning_cycle) -{ - // Start the cleaning thread - cleaners.push_back( - std::make_unique<Thread>([&, cleaning_cycle = cleaning_cycle ]() { - Logger logger = logging::log->logger("Cleaner"); - logger.info("Started with cleaning cycle of {} sec", - cleaning_cycle); +Cleaning::Cleaning(ConcurrentMap<std::string, GraphDb> &dbs, + size_t cleaning_cycle) + : dbms(dbs), cleaning_cycle(cleaning_cycle) { + // Start the cleaning thread + cleaners.push_back( + std::make_unique<Thread>([&, cleaning_cycle = cleaning_cycle ]() { + Logger logger = logging::log->logger("Cleaner"); + logger.info("Started with cleaning cycle of {} sec", cleaning_cycle); - std::time_t last_clean = std::time(nullptr); - while (cleaning.load(std::memory_order_acquire)) { - std::time_t now = std::time(nullptr); + std::time_t last_clean = std::time(nullptr); + while (cleaning.load(std::memory_order_acquire)) { + std::time_t now = std::time(nullptr); - // Maybe it's cleaning time. - if (now >= last_clean + cleaning_cycle) { - logger.info("Started cleaning cyle"); + // Maybe it's cleaning time. + if (now >= last_clean + cleaning_cycle) { + logger.info("Started cleaning cyle"); - // Clean all databases - for (auto &db : dbs.access()) { - logger.info("Cleaning database \"{}\"", db.first); - DbTransaction t(db.second); - try { - logger.info("Cleaning edges"); - t.clean_edge_section(); + // Clean all databases + for (auto &db : dbs.access()) { + logger.info("Cleaning database \"{}\"", db.first); + DbTransaction t(db.second); + try { + logger.info("Cleaning edges"); + t.clean_edge_section(); - logger.info("Cleaning vertices"); - t.clean_vertex_section(); + logger.info("Cleaning vertices"); + t.clean_vertex_section(); - logger.info("Cleaning garbage"); - db.second.garbage.clean(); + logger.info("Cleaning garbage"); + db.second.garbage.clean(); - } catch (const std::exception &e) { - logger.error( - "Error occured while cleaning database \"{}\"", - db.first); - logger.error("{}", e.what()); - } - // NOTE: Whe should commit even if error occured. - t.trans.commit(); - } - last_clean = now; - logger.info("Finished cleaning cyle"); - - } else { - - // Cleaning isn't scheduled for now so i should sleep. - std::this_thread::sleep_for(std::chrono::seconds(1)); - } + } catch (const std::exception &e) { + logger.error("Error occured while cleaning database \"{}\"", + db.first); + logger.error("{}", e.what()); + } + // NOTE: Whe should commit even if error occured. + t.trans.commit(); } - })); + last_clean = now; + logger.info("Finished cleaning cyle"); + + } else { + // Cleaning isn't scheduled for now so i should sleep. + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + } + })); } -Cleaning::~Cleaning() -{ - // Stop cleaning - cleaning.store(false, std::memory_order_release); - for (auto &t : cleaners) { - // Join with cleaners - t.get()->join(); - } +Cleaning::~Cleaning() { + // Stop cleaning + cleaning.store(false, std::memory_order_release); + for (auto &t : cleaners) { + // Join with cleaners + t.get()->join(); + } } diff --git a/src/dbms/cleaner.hpp b/src/dbms/cleaner.hpp index c75f26db0..a3bd6908f 100644 --- a/src/dbms/cleaner.hpp +++ b/src/dbms/cleaner.hpp @@ -5,24 +5,22 @@ class Thread; -class Cleaning -{ +class Cleaning { + public: + // How much sec is a cleaning_cycle in which cleaner will clean at most + // once. Starts cleaner thread. + Cleaning(ConcurrentMap<std::string, GraphDb> &dbs, size_t cleaning_cycle); -public: - // How much sec is a cleaning_cycle in which cleaner will clean at most - // once. Starts cleaner thread. - Cleaning(ConcurrentMap<std::string, GraphDb> &dbs, size_t cleaning_cycle); + // Destroys this object after this thread joins cleaning thread. + ~Cleaning(); - // Destroys this object after this thread joins cleaning thread. - ~Cleaning(); + private: + ConcurrentMap<std::string, GraphDb> &dbms; -private: - ConcurrentMap<std::string, GraphDb> &dbms; + const size_t cleaning_cycle; - const size_t cleaning_cycle; + std::vector<std::unique_ptr<Thread>> cleaners; - std::vector<std::unique_ptr<Thread>> cleaners; - - // Should i continue cleaning. - std::atomic<bool> cleaning = {true}; + // Should i continue cleaning. + std::atomic<bool> cleaning = {true}; }; diff --git a/src/dbms/dbms.cpp b/src/dbms/dbms.cpp index b04734dd3..a72435c4c 100644 --- a/src/dbms/dbms.cpp +++ b/src/dbms/dbms.cpp @@ -1,21 +1,21 @@ #include "dbms/dbms.hpp" GraphDbAccessor Dbms::active() { - return GraphDbAccessor(*active_db.load(std::memory_order_acquire)); + return GraphDbAccessor(*active_db.load(std::memory_order_acquire)); } GraphDbAccessor Dbms::active(const std::string &name) { - auto acc = dbs.access(); - // create db if it doesn't exist - auto it = acc.find(name); - if (it == acc.end()) { - it = acc.emplace(name, std::forward_as_tuple(name), - std::forward_as_tuple(name)) - .first; - } + auto acc = dbs.access(); + // create db if it doesn't exist + auto it = acc.find(name); + if (it == acc.end()) { + it = acc.emplace(name, std::forward_as_tuple(name), + std::forward_as_tuple(name)) + .first; + } - // set and return active db - auto &db = it->second; - active_db.store(&db, std::memory_order_release); - return GraphDbAccessor(db); + // set and return active db + auto &db = it->second; + active_db.store(&db, std::memory_order_release); + return GraphDbAccessor(db); } diff --git a/src/dbms/dbms.hpp b/src/dbms/dbms.hpp index 83b7b9948..6d4b4e2be 100644 --- a/src/dbms/dbms.hpp +++ b/src/dbms/dbms.hpp @@ -8,42 +8,42 @@ //#include "dbms/cleaner.hpp" //#include "snapshot/snapshoter.hpp" -class Dbms -{ -public: - Dbms() { - // create the default database and set is a active - active("default"); - } +class Dbms { + public: + Dbms() { + // create the default database and set is a active + active("default"); + } - /** - * Returns an accessor to the active database. - */ - GraphDbAccessor active(); + /** + * Returns an accessor to the active database. + */ + GraphDbAccessor active(); - /** - * Set the database with the given name to be active. - * If there is no database with the given name, - * it's created. - * - * @return an accessor to the database with the given name. - */ - GraphDbAccessor active(const std::string &name); + /** + * Set the database with the given name to be active. + * If there is no database with the given name, + * it's created. + * + * @return an accessor to the database with the given name. + */ + GraphDbAccessor active(const std::string &name); - // TODO: DELETE action + // TODO: DELETE action -private: - // dbs container - ConcurrentMap<std::string, GraphDb> dbs; + private: + // dbs container + ConcurrentMap<std::string, GraphDb> dbs; - // currently active database - std::atomic<GraphDb *> active_db; + // currently active database + std::atomic<GraphDb *> active_db; -// // Cleaning thread. -// TODO re-enable cleaning -// Cleaning cleaning = {dbs, CONFIG_INTEGER(config::CLEANING_CYCLE_SEC)}; -// -// // Snapshoting thread. -// TODO re-enable cleaning -// Snapshoter snapshoter = {dbs, CONFIG_INTEGER(config::SNAPSHOT_CYCLE_SEC)}; + // // Cleaning thread. + // TODO re-enable cleaning + // Cleaning cleaning = {dbs, CONFIG_INTEGER(config::CLEANING_CYCLE_SEC)}; + // + // // Snapshoting thread. + // TODO re-enable cleaning + // Snapshoter snapshoter = {dbs, + // CONFIG_INTEGER(config::SNAPSHOT_CYCLE_SEC)}; }; diff --git a/src/import/base_import.hpp b/src/import/base_import.hpp index 793664ed9..2389105ef 100644 --- a/src/import/base_import.hpp +++ b/src/import/base_import.hpp @@ -24,158 +24,149 @@ using namespace std; static Option<VertexAccessor> empty_op_vacc; // Base importer with common facilities. -class BaseImporter -{ +class BaseImporter { + public: + BaseImporter(DbAccessor &db, Logger &&logger) + : db(db), logger(std::move(logger)) {} -public: - BaseImporter(DbAccessor &db, Logger &&logger) - : db(db), logger(std::move(logger)) - { - } + char *cstr(string &str) { return &str[0]; } - char *cstr(string &str) { return &str[0]; } + bool split(string &str, char mark, vector<char *> &sub_str) { + return split(cstr(str), mark, sub_str); + } - bool split(string &str, char mark, vector<char *> &sub_str) - { - return split(cstr(str), mark, sub_str); - } + // Occurances of mark are changed with '\0'. sub_str is filled with + // pointers to parts of str splited by mark in ascending order. Empty + // sub_str are included. Doesn't split inside quotations and + // open_bracket,closed_bracket. + // Returns true if it was succesfully parsed. + bool split(char *str, char mark, vector<char *> &sub_str) { + int head = 0; + bool in_text = false; + bool in_array = false; - // Occurances of mark are changed with '\0'. sub_str is filled with - // pointers to parts of str splited by mark in ascending order. Empty - // sub_str are included. Doesn't split inside quotations and - // open_bracket,closed_bracket. - // Returns true if it was succesfully parsed. - bool split(char *str, char mark, vector<char *> &sub_str) - { + for (int i = 0; str[i] != '\0'; i++) { + char &c = str[i]; - int head = 0; - bool in_text = false; - bool in_array = false; - - for (int i = 0; str[i] != '\0'; i++) { - char &c = str[i]; - - // IN TEXT check - if (c == quotations_mark) { - in_text = !in_text; - if (in_text && head == i) { - c = '\0'; - head = i + 1; - } else if (!in_text && !in_array) { - c = '\0'; - } - continue; - } else if (in_text) { - continue; - } - - // IN ARRAY check - if (c == open_bracket) { - if (in_array) { - logger.error("Nested arrays aren't supported."); - return false; - } - in_array = true; - continue; - } - if (in_array) { - if (c == closed_bracket) { - in_array = false; - } - continue; - } - - // SPLIT CHECK - if (c == mark) { - c = '\0'; - sub_str.push_back(&str[head]); - head = i + 1; - } + // IN TEXT check + if (c == quotations_mark) { + in_text = !in_text; + if (in_text && head == i) { + c = '\0'; + head = i + 1; + } else if (!in_text && !in_array) { + c = '\0'; } + continue; + } else if (in_text) { + continue; + } - sub_str.push_back(&str[head]); - - return true; - } - - // Extracts parts of str while stripping parts of array chars and qutation - // marks. Parts are separated with delimiter. - void extract(char *str, const char delimiter, vector<char *> &sub_str) - { - int head = 0; - bool in_text = false; - - for (int i = 0; str[i] != '\0'; i++) { - char &c = str[i]; - - // IN TEXT check - if (c == quotations_mark) { - in_text = !in_text; - if (in_text) { - } else { - c = '\0'; - sub_str.push_back(&str[head]); - head = i + 1; - } - head = i + 1; - continue; - } else if (in_text) { - continue; - } - - // IN ARRAY check - if (c == open_bracket) { - head = i + 1; - continue; - } else if (c == closed_bracket) { - c = '\0'; - if (i > head) { - sub_str.push_back(&str[head]); - } - head = i + 1; - continue; - } - - // SPLIT CHECK - if (c == delimiter) { - c = '\0'; - if (i > head) { - sub_str.push_back(&str[head]); - } - head = i + 1; - } else if (c == ' ' && i == head) { - head++; - } + // IN ARRAY check + if (c == open_bracket) { + if (in_array) { + logger.error("Nested arrays aren't supported."); + return false; } + in_array = true; + continue; + } + if (in_array) { + if (c == closed_bracket) { + in_array = false; + } + continue; + } + // SPLIT CHECK + if (c == mark) { + c = '\0'; sub_str.push_back(&str[head]); + head = i + 1; + } } - // Optionaly return vertex with given import local id if it exists. - Option<VertexAccessor> const &get_vertex(size_t id) - { - if (vertices.size() > id) { - return vertices[id]; + sub_str.push_back(&str[head]); + + return true; + } + + // Extracts parts of str while stripping parts of array chars and qutation + // marks. Parts are separated with delimiter. + void extract(char *str, const char delimiter, vector<char *> &sub_str) { + int head = 0; + bool in_text = false; + + for (int i = 0; str[i] != '\0'; i++) { + char &c = str[i]; + + // IN TEXT check + if (c == quotations_mark) { + in_text = !in_text; + if (in_text) { } else { - cout << vertices.size() << " -> " << id << endl; - return empty_op_vacc; + c = '\0'; + sub_str.push_back(&str[head]); + head = i + 1; } + head = i + 1; + continue; + } else if (in_text) { + continue; + } + + // IN ARRAY check + if (c == open_bracket) { + head = i + 1; + continue; + } else if (c == closed_bracket) { + c = '\0'; + if (i > head) { + sub_str.push_back(&str[head]); + } + head = i + 1; + continue; + } + + // SPLIT CHECK + if (c == delimiter) { + c = '\0'; + if (i > head) { + sub_str.push_back(&str[head]); + } + head = i + 1; + } else if (c == ' ' && i == head) { + head++; + } } -public: - DbAccessor &db; - Logger logger; + sub_str.push_back(&str[head]); + } - // Varius marks and delimiters. They can be freely changed here and - // everything will work. - char parts_mark = ','; - char parts_array_mark = ','; - char type_mark = ':'; - char quotations_mark = '"'; - char open_bracket = '['; - char closed_bracket = ']'; + // Optionaly return vertex with given import local id if it exists. + Option<VertexAccessor> const &get_vertex(size_t id) { + if (vertices.size() > id) { + return vertices[id]; + } else { + cout << vertices.size() << " -> " << id << endl; + return empty_op_vacc; + } + } -protected: - // All created vertices which have import local id. - vector<Option<VertexAccessor>> vertices; + public: + DbAccessor &db; + Logger logger; + + // Varius marks and delimiters. They can be freely changed here and + // everything will work. + char parts_mark = ','; + char parts_array_mark = ','; + char type_mark = ':'; + char quotations_mark = '"'; + char open_bracket = '['; + char closed_bracket = ']'; + + protected: + // All created vertices which have import local id. + vector<Option<VertexAccessor>> vertices; }; diff --git a/src/import/csv_import.hpp b/src/import/csv_import.hpp index 9f1283e45..c284e8150 100644 --- a/src/import/csv_import.hpp +++ b/src/import/csv_import.hpp @@ -59,311 +59,293 @@ bool equal_str(const char *a, const char *b) { return strcasecmp(a, b) == 0; } // If name is missing the column data wont be saved into the elements. // if the type is missing the column will be interperted as type string. If // neither name nor type are present column will be skipped. -class CSVImporter : public BaseImporter -{ +class CSVImporter : public BaseImporter { + public: + CSVImporter(DbAccessor &db) + : BaseImporter(db, logging::log->logger("CSV_import")) {} -public: - CSVImporter(DbAccessor &db) - : BaseImporter(db, logging::log->logger("CSV_import")) - { + // Loads data from stream and returns number of loaded vertexes. + size_t import_vertices(std::fstream &file) { + return import<TypeGroupVertex>(file, create_vertex, true); + } + + // Loads data from stream and returns number of loaded edges. + size_t import_edges(std::fstream &file) { + return import<TypeGroupEdge>(file, create_edge, false); + } + + private: + // Loads data from file and returns number of loaded name. + // TG - TypeGroup + // F - function which will create element from filled element skelleton. + template <class TG, class F> + size_t import(std::fstream &file, F f, bool vertex) { + string line; + vector<char *> sub_str; + vector<unique_ptr<Filler>> fillers; + vector<char *> tmp; + + // HEADERS + if (!getline(file, line)) { + logger.error("No lines"); + return 0; } - // Loads data from stream and returns number of loaded vertexes. - size_t import_vertices(std::fstream &file) - { - return import<TypeGroupVertex>(file, create_vertex, true); + if (!split(line, parts_mark, sub_str)) { + logger.error("Illegal headers"); + return 0; } - // Loads data from stream and returns number of loaded edges. - size_t import_edges(std::fstream &file) - { - return import<TypeGroupEdge>(file, create_edge, false); + for (auto p : sub_str) { + auto o = get_filler<TG>(p, tmp, vertex); + if (o.is_present()) { + fillers.push_back(o.take()); + } else { + return 0; + } + } + sub_str.clear(); + + // LOAD DATA LINES + size_t count = 0; + size_t line_no = 1; + ElementSkeleton es(db); + while (std::getline(file, line)) { + sub_str.clear(); + es.clear(); + + if (split(line, parts_mark, sub_str)) { + check_for_part_count(sub_str.size() - fillers.size(), line_no); + + int n = min(sub_str.size(), fillers.size()); + for (int i = 0; i < n; i++) { + auto er = fillers[i]->fill(es, sub_str[i]); + if (er.is_present()) { + logger.error("{} on line: {}", er.get(), line_no); + } + } + + if (f(this, es, line_no)) { + count++; + } + } + + line_no++; } -private: - // Loads data from file and returns number of loaded name. - // TG - TypeGroup - // F - function which will create element from filled element skelleton. - template <class TG, class F> - size_t import(std::fstream &file, F f, bool vertex) - { - string line; - vector<char *> sub_str; - vector<unique_ptr<Filler>> fillers; - vector<char *> tmp; - - // HEADERS - if (!getline(file, line)) { - logger.error("No lines"); - return 0; - } - - if (!split(line, parts_mark, sub_str)) { - logger.error("Illegal headers"); - return 0; - } - - for (auto p : sub_str) { - auto o = get_filler<TG>(p, tmp, vertex); - if (o.is_present()) { - fillers.push_back(o.take()); - } else { - return 0; - } - } - sub_str.clear(); - - // LOAD DATA LINES - size_t count = 0; - size_t line_no = 1; - ElementSkeleton es(db); - while (std::getline(file, line)) { - sub_str.clear(); - es.clear(); - - if (split(line, parts_mark, sub_str)) { - check_for_part_count(sub_str.size() - fillers.size(), line_no); - - int n = min(sub_str.size(), fillers.size()); - for (int i = 0; i < n; i++) { - auto er = fillers[i]->fill(es, sub_str[i]); - if (er.is_present()) { - logger.error("{} on line: {}", er.get(), line_no); - } - } - - if (f(this, es, line_no)) { - count++; - } - } - - line_no++; - } - - return count; - } - - static bool create_vertex(CSVImporter *im, ElementSkeleton &es, - size_t line_no) - { - auto va = es.add_vertex(); - auto id = es.element_id(); - if (id.is_present()) { - - if (im->vertices.size() <= id.get()) { - Option<VertexAccessor> empty = make_option<VertexAccessor>(); - im->vertices.insert(im->vertices.end(), - id.get() - im->vertices.size() + 1, empty); - } - if (im->vertices[id.get()].is_present()) { - im->logger.error("Vertex on line: {} has same id with another " - "previously loaded vertex", - line_no); - return false; - } else { - im->vertices[id.get()] = make_option(std::move(va)); - return true; - } - } else { - im->logger.warn("Missing import local vertex id for vertex on " - "line: {}", - line_no); - } + return count; + } + static bool create_vertex(CSVImporter *im, ElementSkeleton &es, + size_t line_no) { + auto va = es.add_vertex(); + auto id = es.element_id(); + if (id.is_present()) { + if (im->vertices.size() <= id.get()) { + Option<VertexAccessor> empty = make_option<VertexAccessor>(); + im->vertices.insert(im->vertices.end(), + id.get() - im->vertices.size() + 1, empty); + } + if (im->vertices[id.get()].is_present()) { + im->logger.error( + "Vertex on line: {} has same id with another " + "previously loaded vertex", + line_no); + return false; + } else { + im->vertices[id.get()] = make_option(std::move(va)); return true; + } + } else { + im->logger.warn( + "Missing import local vertex id for vertex on " + "line: {}", + line_no); } - static bool create_edge(CSVImporter *im, ElementSkeleton &es, - size_t line_no) - { - auto o = es.add_edge(); - if (!o.is_present()) { - return true; - } else { - im->logger.error("{} on line: {}", o.get(), line_no); - return false; - } + return true; + } + + static bool create_edge(CSVImporter *im, ElementSkeleton &es, + size_t line_no) { + auto o = es.add_edge(); + if (!o.is_present()) { + return true; + } else { + im->logger.error("{} on line: {}", o.get(), line_no); + return false; + } + } + + template <class TG> + typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey property_key( + const char *name, Flags type) { + assert(false); + } + + // Returns filler for name:type in header_part. None if error occured. + template <class TG> + Option<unique_ptr<Filler>> get_filler(char *header_part, + vector<char *> &tmp_vec, bool vertex) { + tmp_vec.clear(); + split(header_part, type_mark, tmp_vec); + + const char *name = tmp_vec[0]; + const char *type = tmp_vec[1]; + + if (tmp_vec.size() > 2) { + logger.error("To much sub parts in header part"); + return make_option<unique_ptr<Filler>>(); + + } else if (tmp_vec.size() < 2) { + if (tmp_vec.size() == 1) { + logger.warn( + "Column: {} doesn't have specified type so string " + "type will be used", + tmp_vec[0]); + name = tmp_vec[0]; + type = _string; + + } else { + logger.warn("Empty colum definition, skiping column."); + std::unique_ptr<Filler> f(new SkipFiller()); + return make_option(std::move(f)); + } + + } else { + name = tmp_vec[0]; + type = tmp_vec[1]; } - template <class TG> - typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey - property_key(const char *name, Flags type) - { - assert(false); + // Create adequat filler + if (equal_str(type, "id")) { + std::unique_ptr<Filler> f( + name[0] == '\0' ? new IdFiller<TG>() + : new IdFiller<TG>(make_option( + property_key<TG>(name, Flags::Int64)))); + return make_option(std::move(f)); + + } else if (equal_str(type, "start_id") || equal_str(type, "from_id") || + equal_str(type, "from") || equal_str(type, "source")) { + std::unique_ptr<Filler> f(new FromFiller(*this)); + return make_option(std::move(f)); + + } else if (equal_str(type, "label")) { + std::unique_ptr<Filler> f(new LabelFiller(*this)); + return make_option(std::move(f)); + + } else if (equal_str(type, "end_id") || equal_str(type, "to_id") || + equal_str(type, "to") || equal_str(type, "target")) { + std::unique_ptr<Filler> f(new ToFiller(*this)); + return make_option(std::move(f)); + + } else if (equal_str(type, "type")) { + std::unique_ptr<Filler> f(new TypeFiller(*this)); + return make_option(std::move(f)); + + } else if (name[0] == '\0') { // OTHER FILLERS REQUIRE NAME + logger.warn("Unnamed column of type: {} will be skipped.", type); + std::unique_ptr<Filler> f(new SkipFiller()); + return make_option(std::move(f)); + + // *********************** PROPERTIES + } else if (equal_str(type, "bool")) { + std::unique_ptr<Filler> f( + new BoolFiller<TG>(property_key<TG>(name, Flags::Bool))); + return make_option(std::move(f)); + + } else if (equal_str(type, "double") || + (UPLIFT_PRIMITIVES && equal_str(type, "float"))) { + std::unique_ptr<Filler> f( + new DoubleFiller<TG>(property_key<TG>(name, Flags::Double))); + return make_option(std::move(f)); + + } else if (equal_str(type, "float")) { + std::unique_ptr<Filler> f( + new FloatFiller<TG>(property_key<TG>(name, Flags::Float))); + return make_option(std::move(f)); + + } else if (equal_str(type, "long") || + (UPLIFT_PRIMITIVES && equal_str(type, "int"))) { + std::unique_ptr<Filler> f( + new Int64Filler<TG>(property_key<TG>(name, Flags::Int64))); + return make_option(std::move(f)); + + } else if (equal_str(type, "int")) { + std::unique_ptr<Filler> f( + new Int32Filler<TG>(property_key<TG>(name, Flags::Int32))); + return make_option(std::move(f)); + + } else if (equal_str(type, "string")) { + std::unique_ptr<Filler> f( + new StringFiller<TG>(property_key<TG>(name, Flags::String))); + return make_option(std::move(f)); + + } else if (equal_str(type, "bool[]")) { + std::unique_ptr<Filler> f(make_array_filler<TG, bool, ArrayBool>( + *this, property_key<TG>(name, Flags::ArrayBool), to_bool)); + return make_option(std::move(f)); + + } else if (equal_str(type, "double[]") || + (UPLIFT_PRIMITIVES && equal_str(type, "float[]"))) { + std::unique_ptr<Filler> f(make_array_filler<TG, double, ArrayDouble>( + *this, property_key<TG>(name, Flags::ArrayDouble), to_double)); + return make_option(std::move(f)); + + } else if (equal_str(type, "float[]")) { + std::unique_ptr<Filler> f(make_array_filler<TG, float, ArrayFloat>( + *this, property_key<TG>(name, Flags::ArrayFloat), to_float)); + return make_option(std::move(f)); + + } else if (equal_str(type, "long[]") || + (UPLIFT_PRIMITIVES && equal_str(type, "int[]"))) { + std::unique_ptr<Filler> f(make_array_filler<TG, int64_t, ArrayInt64>( + *this, property_key<TG>(name, Flags::ArrayInt64), to_int64)); + return make_option(std::move(f)); + + } else if (equal_str(type, "int[]")) { + std::unique_ptr<Filler> f(make_array_filler<TG, int32_t, ArrayInt32>( + *this, property_key<TG>(name, Flags::ArrayInt32), to_int32)); + return make_option(std::move(f)); + + } else if (equal_str(type, "string[]")) { + std::unique_ptr<Filler> f(make_array_filler<TG, std::string, ArrayString>( + *this, property_key<TG>(name, Flags::ArrayString), to_string)); + return make_option(std::move(f)); + + } else { + logger.error("Unknown type: {}", type); + return make_option<unique_ptr<Filler>>(); } + } - // Returns filler for name:type in header_part. None if error occured. - template <class TG> - Option<unique_ptr<Filler>> get_filler(char *header_part, - vector<char *> &tmp_vec, bool vertex) - { - tmp_vec.clear(); - split(header_part, type_mark, tmp_vec); - - const char *name = tmp_vec[0]; - const char *type = tmp_vec[1]; - - if (tmp_vec.size() > 2) { - logger.error("To much sub parts in header part"); - return make_option<unique_ptr<Filler>>(); - - } else if (tmp_vec.size() < 2) { - if (tmp_vec.size() == 1) { - logger.warn("Column: {} doesn't have specified type so string " - "type will be used", - tmp_vec[0]); - name = tmp_vec[0]; - type = _string; - - } else { - logger.warn("Empty colum definition, skiping column."); - std::unique_ptr<Filler> f(new SkipFiller()); - return make_option(std::move(f)); - } - - } else { - name = tmp_vec[0]; - type = tmp_vec[1]; - } - - // Create adequat filler - if (equal_str(type, "id")) { - std::unique_ptr<Filler> f( - name[0] == '\0' ? new IdFiller<TG>() - : new IdFiller<TG>(make_option( - property_key<TG>(name, Flags::Int64)))); - return make_option(std::move(f)); - - } else if (equal_str(type, "start_id") || equal_str(type, "from_id") || - equal_str(type, "from") || equal_str(type, "source")) { - std::unique_ptr<Filler> f(new FromFiller(*this)); - return make_option(std::move(f)); - - } else if (equal_str(type, "label")) { - std::unique_ptr<Filler> f(new LabelFiller(*this)); - return make_option(std::move(f)); - - } else if (equal_str(type, "end_id") || equal_str(type, "to_id") || - equal_str(type, "to") || equal_str(type, "target")) { - std::unique_ptr<Filler> f(new ToFiller(*this)); - return make_option(std::move(f)); - - } else if (equal_str(type, "type")) { - std::unique_ptr<Filler> f(new TypeFiller(*this)); - return make_option(std::move(f)); - - } else if (name[0] == '\0') { // OTHER FILLERS REQUIRE NAME - logger.warn("Unnamed column of type: {} will be skipped.", type); - std::unique_ptr<Filler> f(new SkipFiller()); - return make_option(std::move(f)); - - // *********************** PROPERTIES - } else if (equal_str(type, "bool")) { - std::unique_ptr<Filler> f( - new BoolFiller<TG>(property_key<TG>(name, Flags::Bool))); - return make_option(std::move(f)); - - } else if (equal_str(type, "double") || - (UPLIFT_PRIMITIVES && equal_str(type, "float"))) { - std::unique_ptr<Filler> f( - new DoubleFiller<TG>(property_key<TG>(name, Flags::Double))); - return make_option(std::move(f)); - - } else if (equal_str(type, "float")) { - std::unique_ptr<Filler> f( - new FloatFiller<TG>(property_key<TG>(name, Flags::Float))); - return make_option(std::move(f)); - - } else if (equal_str(type, "long") || - (UPLIFT_PRIMITIVES && equal_str(type, "int"))) { - std::unique_ptr<Filler> f( - new Int64Filler<TG>(property_key<TG>(name, Flags::Int64))); - return make_option(std::move(f)); - - } else if (equal_str(type, "int")) { - std::unique_ptr<Filler> f( - new Int32Filler<TG>(property_key<TG>(name, Flags::Int32))); - return make_option(std::move(f)); - - } else if (equal_str(type, "string")) { - std::unique_ptr<Filler> f( - new StringFiller<TG>(property_key<TG>(name, Flags::String))); - return make_option(std::move(f)); - - } else if (equal_str(type, "bool[]")) { - std::unique_ptr<Filler> f(make_array_filler<TG, bool, ArrayBool>( - *this, property_key<TG>(name, Flags::ArrayBool), to_bool)); - return make_option(std::move(f)); - - } else if (equal_str(type, "double[]") || - (UPLIFT_PRIMITIVES && equal_str(type, "float[]"))) { - std::unique_ptr<Filler> f( - make_array_filler<TG, double, ArrayDouble>( - *this, property_key<TG>(name, Flags::ArrayDouble), - to_double)); - return make_option(std::move(f)); - - } else if (equal_str(type, "float[]")) { - std::unique_ptr<Filler> f(make_array_filler<TG, float, ArrayFloat>( - *this, property_key<TG>(name, Flags::ArrayFloat), to_float)); - return make_option(std::move(f)); - - } else if (equal_str(type, "long[]") || - (UPLIFT_PRIMITIVES && equal_str(type, "int[]"))) { - std::unique_ptr<Filler> f( - make_array_filler<TG, int64_t, ArrayInt64>( - *this, property_key<TG>(name, Flags::ArrayInt64), - to_int64)); - return make_option(std::move(f)); - - } else if (equal_str(type, "int[]")) { - std::unique_ptr<Filler> f( - make_array_filler<TG, int32_t, ArrayInt32>( - *this, property_key<TG>(name, Flags::ArrayInt32), - to_int32)); - return make_option(std::move(f)); - - } else if (equal_str(type, "string[]")) { - std::unique_ptr<Filler> f( - make_array_filler<TG, std::string, ArrayString>( - *this, property_key<TG>(name, Flags::ArrayString), - to_string)); - return make_option(std::move(f)); - - } else { - logger.error("Unknown type: {}", type); - return make_option<unique_ptr<Filler>>(); - } - } - - void check_for_part_count(long diff, long line_no) - { - if (diff != 0) { - if (diff < 0) { - logger.warn("Line no: {} has less parts then specified in " - "header. Missing: {} parts", - line_no, diff); - } else { - logger.warn("Line no: {} has more parts then specified in " - "header. Extra: {} parts", - line_no, diff); - } - } + void check_for_part_count(long diff, long line_no) { + if (diff != 0) { + if (diff < 0) { + logger.warn( + "Line no: {} has less parts then specified in " + "header. Missing: {} parts", + line_no, diff); + } else { + logger.warn( + "Line no: {} has more parts then specified in " + "header. Extra: {} parts", + line_no, diff); + } } + } }; template <> PropertyFamily<TypeGroupVertex>::PropertyType::PropertyFamilyKey -CSVImporter::property_key<TypeGroupVertex>(const char *name, Flags type) -{ - return db.vertex_property_key(name, Type(type)); +CSVImporter::property_key<TypeGroupVertex>(const char *name, Flags type) { + return db.vertex_property_key(name, Type(type)); } template <> PropertyFamily<TypeGroupEdge>::PropertyType::PropertyFamilyKey -CSVImporter::property_key<TypeGroupEdge>(const char *name, Flags type) -{ - return db.edge_property_key(name, Type(type)); +CSVImporter::property_key<TypeGroupEdge>(const char *name, Flags type) { + return db.edge_property_key(name, Type(type)); } // Imports all -v "vertex_file_path.csv" vertices and -e "edge_file_path.csv" @@ -371,48 +353,47 @@ CSVImporter::property_key<TypeGroupEdge>(const char *name, Flags type) // -d delimiter => sets delimiter for parsing .csv files. Default is , // -ad delimiter => sets delimiter for parsing arrays in .csv. Default is // Returns (no loaded vertices,no loaded edges) -std::pair<size_t, size_t> -import_csv_from_arguments(Db &db, std::vector<std::string> ¶) -{ - DbAccessor t(db); - CSVImporter imp(t); +std::pair<size_t, size_t> import_csv_from_arguments( + Db &db, std::vector<std::string> ¶) { + DbAccessor t(db); + CSVImporter imp(t); - imp.parts_mark = get_argument(para, "-d", ",")[0]; - imp.parts_array_mark = get_argument(para, "-ad", ",")[0]; + imp.parts_mark = get_argument(para, "-d", ",")[0]; + imp.parts_array_mark = get_argument(para, "-ad", ",")[0]; - // IMPORT VERTICES - size_t l_v = 0; - auto o = take_argument(para, "-v"); - while (o.is_present()) { - std::fstream file(o.get()); + // IMPORT VERTICES + size_t l_v = 0; + auto o = take_argument(para, "-v"); + while (o.is_present()) { + std::fstream file(o.get()); - imp.logger.info("Importing vertices from file: {}", o.get()); + imp.logger.info("Importing vertices from file: {}", o.get()); - auto n = imp.import_vertices(file); - l_v = +n; + auto n = imp.import_vertices(file); + l_v = +n; - imp.logger.info("Loaded: {} vertices from {}", n, o.get()); + imp.logger.info("Loaded: {} vertices from {}", n, o.get()); - o = take_argument(para, "-v"); - } + o = take_argument(para, "-v"); + } + + // IMPORT EDGES + size_t l_e = 0; + o = take_argument(para, "-e"); + while (o.is_present()) { + std::fstream file(o.get()); + + imp.logger.info("Importing edges from file: {}", o.get()); + + auto n = imp.import_edges(file); + l_e = +n; + + imp.logger.info("Loaded: {} edges from {}", n, o.get()); - // IMPORT EDGES - size_t l_e = 0; o = take_argument(para, "-e"); - while (o.is_present()) { - std::fstream file(o.get()); + } - imp.logger.info("Importing edges from file: {}", o.get()); + t.commit(); - auto n = imp.import_edges(file); - l_e = +n; - - imp.logger.info("Loaded: {} edges from {}", n, o.get()); - - o = take_argument(para, "-e"); - } - - t.commit(); - - return std::make_pair(l_v, l_e); + return std::make_pair(l_v, l_e); } diff --git a/src/import/element_skeleton.hpp b/src/import/element_skeleton.hpp index 8cf9bb437..5fa1b3461 100644 --- a/src/import/element_skeleton.hpp +++ b/src/import/element_skeleton.hpp @@ -3,16 +3,15 @@ #include <cassert> #include "database/db_accessor.hpp" -#include "storage/vertex_accessor.hpp" #include "storage/model/typed_value.hpp" #include "storage/model/typed_value_store.hpp" +#include "storage/vertex_accessor.hpp" // Holder for element data which he can then insert as a vertex or edge into the // database depending on the available data and called add_* method. class ElementSkeleton { - -public: - ElementSkeleton(DbAccessor &db) : db(db) {}; + public: + ElementSkeleton(DbAccessor &db) : db(db){}; void add_property(StoredProperty<TypeGroupVertex> &&prop) { properties_v.push_back(std::move(prop)); @@ -22,9 +21,7 @@ public: properties_e.push_back(std::move(prop)); } - void set_element_id(size_t id) { - el_id = make_option<size_t>(std::move(id)); - } + void set_element_id(size_t id) { el_id = make_option<size_t>(std::move(id)); } void add_label(Label const &label) { labels.push_back(&label); } @@ -91,7 +88,7 @@ public: // Returns import local id. Option<size_t> element_id() { return el_id; } -private: + private: DbAccessor &db; Option<size_t> el_id; diff --git a/src/import/fillings/bool.hpp b/src/import/fillings/bool.hpp index 7c6640faf..ee8f8757b 100644 --- a/src/import/fillings/bool.hpp +++ b/src/import/fillings/bool.hpp @@ -9,26 +9,21 @@ // Parses boolean. // TG - Type group template <class TG> -class BoolFiller : public Filler -{ +class BoolFiller : public Filler { + public: + BoolFiller(typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key) + : key(key) {} -public: - BoolFiller(typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key) - : key(key) - { + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + if (str[0] != '\0') { + data.add_property(StoredProperty<TG>(Bool(to_bool(str)), key)); } - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - if (str[0] != '\0') { - data.add_property(StoredProperty<TG>(Bool(to_bool(str)), key)); - } + return make_option<std::string>(); + } - return make_option<std::string>(); - } - -private: - typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key; + private: + typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key; }; diff --git a/src/import/fillings/common.hpp b/src/import/fillings/common.hpp index e1266c4f4..55b949d1b 100644 --- a/src/import/fillings/common.hpp +++ b/src/import/fillings/common.hpp @@ -1,15 +1,14 @@ #pragma once +#include <strings.h> #include <cstdlib> #include <cstdlib> #include <iostream> #include <string> -#include <strings.h> #include "storage/model/properties/all.hpp" -bool string2bool(const char *v) -{ - return strcasecmp(v, "true") == 0 || atoi(v) != 0; +bool string2bool(const char *v) { + return strcasecmp(v, "true") == 0 || atoi(v) != 0; } bool to_bool(const char *str) { return string2bool(str); } diff --git a/src/import/fillings/filler.hpp b/src/import/fillings/filler.hpp index 27e331653..1596cfa04 100644 --- a/src/import/fillings/filler.hpp +++ b/src/import/fillings/filler.hpp @@ -5,10 +5,9 @@ // Common class for varius classes which accept one part from data line in // import, parses it and adds it into element skelleton. -class Filler -{ -public: - // Fills skeleton with data from str. Returns error description if - // error occurs. - virtual Option<std::string> fill(ElementSkeleton &data, char *str) = 0; +class Filler { + public: + // Fills skeleton with data from str. Returns error description if + // error occurs. + virtual Option<std::string> fill(ElementSkeleton &data, char *str) = 0; }; diff --git a/src/import/fillings/float.hpp b/src/import/fillings/float.hpp index 17d749ff8..fddff537f 100644 --- a/src/import/fillings/float.hpp +++ b/src/import/fillings/float.hpp @@ -9,26 +9,20 @@ // Parses float. // TG - Type group template <class TG> -class FloatFiller : public Filler -{ - -public: - FloatFiller( - typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key) - : key(key) - { - } - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - if (str[0] != '\0') { - data.add_property(StoredProperty<TG>(Float(to_float(str)), key)); - } - - return make_option<std::string>(); +class FloatFiller : public Filler { + public: + FloatFiller(typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key) + : key(key) {} + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + if (str[0] != '\0') { + data.add_property(StoredProperty<TG>(Float(to_float(str)), key)); } -private: - typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key; + return make_option<std::string>(); + } + + private: + typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key; }; diff --git a/src/import/fillings/from.hpp b/src/import/fillings/from.hpp index 435c6fc59..8097029f0 100644 --- a/src/import/fillings/from.hpp +++ b/src/import/fillings/from.hpp @@ -7,32 +7,28 @@ #include "storage/model/properties/property_family.hpp" // Parses from id of vertex for edge. -class FromFiller : public Filler -{ +class FromFiller : public Filler { + public: + FromFiller(BaseImporter &db) : bim(db) {} -public: - FromFiller(BaseImporter &db) : bim(db) {} - - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - if (str[0] != '\0') { - auto id = atol(str); - Option<VertexAccessor> const &oav = bim.get_vertex(id); - if (oav.is_present()) { - data.set_from(VertexAccessor(oav.get())); - return make_option<std::string>(); - } else { - return make_option( - std::string("Unknown vertex in from field with id: ") + - str); - } - } else { - return make_option(std::string("From field must be spceified")); - } + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + if (str[0] != '\0') { + auto id = atol(str); + Option<VertexAccessor> const &oav = bim.get_vertex(id); + if (oav.is_present()) { + data.set_from(VertexAccessor(oav.get())); + return make_option<std::string>(); + } else { + return make_option( + std::string("Unknown vertex in from field with id: ") + str); + } + } else { + return make_option(std::string("From field must be spceified")); } + } -private: - BaseImporter &bim; + private: + BaseImporter &bim; }; diff --git a/src/import/fillings/id.hpp b/src/import/fillings/id.hpp index 9808089c3..b22a92d57 100644 --- a/src/import/fillings/id.hpp +++ b/src/import/fillings/id.hpp @@ -5,40 +5,31 @@ // Parses import local Id. // TG - Type group template <class TG> -class IdFiller : public Filler -{ +class IdFiller : public Filler { + public: + IdFiller() + : key(make_option< + typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey>()) {} -public: - IdFiller() - : key(make_option< - typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey>()) - { + IdFiller( + Option<typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey> key) + : key(key) { + assert(!key.is_present() || key.get().prop_type() == Type(Flags::Int64)); + } + + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + if (str[0] != '\0') { + data.set_element_id(atol(str)); + if (key.is_present()) { + data.add_property(StoredProperty<TG>(Int64(to_int64(str)), key.get())); + } } - IdFiller( - Option<typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey> - key) - : key(key) - { - assert(!key.is_present() || - key.get().prop_type() == Type(Flags::Int64)); - } + return make_option<std::string>(); + } - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - if (str[0] != '\0') { - data.set_element_id(atol(str)); - if (key.is_present()) { - data.add_property( - StoredProperty<TG>(Int64(to_int64(str)), key.get())); - } - } - - return make_option<std::string>(); - } - -private: - Option<typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey> key; + private: + Option<typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey> key; }; diff --git a/src/import/fillings/int64.hpp b/src/import/fillings/int64.hpp index 437de3b8f..e3296ba4a 100644 --- a/src/import/fillings/int64.hpp +++ b/src/import/fillings/int64.hpp @@ -9,26 +9,20 @@ // Parses int64. // TG - Type group template <class TG> -class Int64Filler : public Filler -{ - -public: - Int64Filler( - typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key) - : key(key) - { - } - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - if (str[0] != '\0') { - data.add_property(StoredProperty<TG>(Int64(to_int64(str)), key)); - } - - return make_option<std::string>(); +class Int64Filler : public Filler { + public: + Int64Filler(typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key) + : key(key) {} + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + if (str[0] != '\0') { + data.add_property(StoredProperty<TG>(Int64(to_int64(str)), key)); } -private: - typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key; + return make_option<std::string>(); + } + + private: + typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key; }; diff --git a/src/import/fillings/label.hpp b/src/import/fillings/label.hpp index fe85c32f5..cdefd099c 100644 --- a/src/import/fillings/label.hpp +++ b/src/import/fillings/label.hpp @@ -4,27 +4,24 @@ #include "import/fillings/filler.hpp" // Parses array of labels. -class LabelFiller : public Filler -{ +class LabelFiller : public Filler { + public: + LabelFiller(BaseImporter &db) : bim(db) {} -public: - LabelFiller(BaseImporter &db) : bim(db) {} - - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - sub_str.clear(); - bim.extract(str, bim.parts_array_mark, sub_str); - for (auto s : sub_str) { - if (s[0] != '\0') { - data.add_label(bim.db.label_find_or_create(s)); - } - } - return make_option<std::string>(); + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + sub_str.clear(); + bim.extract(str, bim.parts_array_mark, sub_str); + for (auto s : sub_str) { + if (s[0] != '\0') { + data.add_label(bim.db.label_find_or_create(s)); + } } + return make_option<std::string>(); + } -private: - BaseImporter &bim; - vector<char *> sub_str; + private: + BaseImporter &bim; + vector<char *> sub_str; }; diff --git a/src/import/fillings/skip.hpp b/src/import/fillings/skip.hpp index 53e21fdc0..9510a00d1 100644 --- a/src/import/fillings/skip.hpp +++ b/src/import/fillings/skip.hpp @@ -7,14 +7,11 @@ #include "storage/model/properties/property_family.hpp" // Skips column. -class SkipFiller : public Filler -{ - -public: - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - return make_option<std::string>(); - } +class SkipFiller : public Filler { + public: + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + return make_option<std::string>(); + } }; diff --git a/src/import/fillings/string.hpp b/src/import/fillings/string.hpp index 4e9014db9..08bf1c619 100644 --- a/src/import/fillings/string.hpp +++ b/src/import/fillings/string.hpp @@ -9,26 +9,20 @@ // Parses string. // TG - Type group template <class TG> -class StringFiller : public Filler -{ - -public: - StringFiller( - typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key) - : key(key) - { - } - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - if (str[0] != '\0') { - data.add_property(StoredProperty<TG>(String(to_string(str)), key)); - } - - return make_option<std::string>(); +class StringFiller : public Filler { + public: + StringFiller(typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key) + : key(key) {} + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + if (str[0] != '\0') { + data.add_property(StoredProperty<TG>(String(to_string(str)), key)); } -private: - typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key; + return make_option<std::string>(); + } + + private: + typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey key; }; diff --git a/src/import/fillings/to.hpp b/src/import/fillings/to.hpp index 44249e521..01b02b151 100644 --- a/src/import/fillings/to.hpp +++ b/src/import/fillings/to.hpp @@ -7,31 +7,28 @@ #include "storage/model/properties/property_family.hpp" // Parses to import local id of vertex for edge. -class ToFiller : public Filler -{ +class ToFiller : public Filler { + public: + ToFiller(BaseImporter &db) : bim(db) {} -public: - ToFiller(BaseImporter &db) : bim(db) {} - - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - if (str[0] != '\0') { - auto id = atol(str); - Option<VertexAccessor> const &oav = bim.get_vertex(id); - if (oav.is_present()) { - data.set_to(VertexAccessor(oav.get())); - return make_option<std::string>(); - } else { - return make_option( - std::string("Unknown vertex in to field with id: ") + str); - } - } else { - return make_option(std::string("To field must be spceified")); - } + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + if (str[0] != '\0') { + auto id = atol(str); + Option<VertexAccessor> const &oav = bim.get_vertex(id); + if (oav.is_present()) { + data.set_to(VertexAccessor(oav.get())); + return make_option<std::string>(); + } else { + return make_option(std::string("Unknown vertex in to field with id: ") + + str); + } + } else { + return make_option(std::string("To field must be spceified")); } + } -private: - BaseImporter &bim; + private: + BaseImporter &bim; }; diff --git a/src/import/fillings/type.hpp b/src/import/fillings/type.hpp index 5556e9dd4..83334f321 100644 --- a/src/import/fillings/type.hpp +++ b/src/import/fillings/type.hpp @@ -4,23 +4,20 @@ #include "import/fillings/filler.hpp" // Parses type of edge. -class TypeFiller : public Filler -{ +class TypeFiller : public Filler { + public: + TypeFiller(BaseImporter &db) : bim(db) {} -public: - TypeFiller(BaseImporter &db) : bim(db) {} - - // Fills skeleton with data from str. Returns error description if - // error occurs. - Option<std::string> fill(ElementSkeleton &data, char *str) final - { - if (str[0] != '\0') { - data.set_type(bim.db.type_find_or_create(str)); - } - - return make_option<std::string>(); + // Fills skeleton with data from str. Returns error description if + // error occurs. + Option<std::string> fill(ElementSkeleton &data, char *str) final { + if (str[0] != '\0') { + data.set_type(bim.db.type_find_or_create(str)); } -private: - BaseImporter &bim; + return make_option<std::string>(); + } + + private: + BaseImporter &bim; }; diff --git a/src/io/network/addrinfo.hpp b/src/io/network/addrinfo.hpp index e85b289c5..1766b8ff8 100644 --- a/src/io/network/addrinfo.hpp +++ b/src/io/network/addrinfo.hpp @@ -1,46 +1,38 @@ #pragma once -#include <cstring> #include <netdb.h> +#include <cstring> #include "io/network/network_error.hpp" #include "utils/underlying_cast.hpp" -namespace io -{ +namespace io { -class AddrInfo -{ - AddrInfo(struct addrinfo* info) : info(info) {} +class AddrInfo { + AddrInfo(struct addrinfo* info) : info(info) {} -public: - ~AddrInfo() - { - freeaddrinfo(info); - } + public: + ~AddrInfo() { freeaddrinfo(info); } - static AddrInfo get(const char* addr, const char* port) - { - struct addrinfo hints; - memset(&hints, 0, sizeof(struct addrinfo)); + static AddrInfo get(const char* addr, const char* port) { + struct addrinfo hints; + memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; // IPv4 and IPv6 - hints.ai_socktype = SOCK_STREAM; // TCP socket - hints.ai_flags = AI_PASSIVE; + hints.ai_family = AF_UNSPEC; // IPv4 and IPv6 + hints.ai_socktype = SOCK_STREAM; // TCP socket + hints.ai_flags = AI_PASSIVE; - struct addrinfo* result; - auto status = getaddrinfo(addr, port, &hints, &result); + struct addrinfo* result; + auto status = getaddrinfo(addr, port, &hints, &result); - if(status != 0) - throw NetworkError(gai_strerror(status)); + if (status != 0) throw NetworkError(gai_strerror(status)); - return AddrInfo(result); - } + return AddrInfo(result); + } - operator struct addrinfo*() { return info; } + operator struct addrinfo*() { return info; } -private: - struct addrinfo* info; + private: + struct addrinfo* info; }; - } diff --git a/src/io/network/client.hpp b/src/io/network/client.hpp index 6df50e520..a66ced6be 100644 --- a/src/io/network/client.hpp +++ b/src/io/network/client.hpp @@ -2,34 +2,28 @@ #include "io/network/stream_reader.hpp" -namespace io -{ +namespace io { template <class Derived, class Stream> -class Client : public StreamReader<Derived, Stream> -{ -public: - bool connect(const std::string& host, const std::string& port) - { - return connect(host.c_str(), port.c_str()); - } +class Client : public StreamReader<Derived, Stream> { + public: + bool connect(const std::string& host, const std::string& port) { + return connect(host.c_str(), port.c_str()); + } - bool connect(const char* host, const char* port) - { - auto socket = io::Socket::connect(host, port); + bool connect(const char* host, const char* port) { + auto socket = io::Socket::connect(host, port); - if(!socket.is_open()) - return false; + if (!socket.is_open()) return false; - socket.set_non_blocking(); + socket.set_non_blocking(); - auto& stream = this->derived().on_connect(std::move(socket)); + auto& stream = this->derived().on_connect(std::move(socket)); - stream.event.events = EPOLLIN | EPOLLET | EPOLLRDHUP; - this->add(stream); + stream.event.events = EPOLLIN | EPOLLET | EPOLLRDHUP; + this->add(stream); - return true; - } + return true; + } }; - } diff --git a/src/io/network/epoll.hpp b/src/io/network/epoll.hpp index 1b64828f7..053c01a5b 100644 --- a/src/io/network/epoll.hpp +++ b/src/io/network/epoll.hpp @@ -4,54 +4,43 @@ #include <sys/epoll.h> #include "io/network/socket.hpp" -#include "utils/likely.hpp" #include "logging/default.hpp" +#include "utils/likely.hpp" -namespace io -{ +namespace io { -class EpollError : BasicException -{ -public: - using BasicException::BasicException; +class EpollError : BasicException { + public: + using BasicException::BasicException; }; -class Epoll -{ -public: - using Event = struct epoll_event; +class Epoll { + public: + using Event = struct epoll_event; - Epoll(int flags) : - logger(logging::log->logger("io::Epoll")) - { - epoll_fd = epoll_create1(flags); + Epoll(int flags) : logger(logging::log->logger("io::Epoll")) { + epoll_fd = epoll_create1(flags); - if(UNLIKELY(epoll_fd == -1)) - throw EpollError("Can't create epoll file descriptor"); - } + if (UNLIKELY(epoll_fd == -1)) + throw EpollError("Can't create epoll file descriptor"); + } - template <class Stream> - void add(Stream& stream, Event* event) - { - auto status = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, stream, event); + template <class Stream> + void add(Stream& stream, Event* event) { + auto status = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, stream, event); - if(UNLIKELY(status)) - throw EpollError("Can't add an event to epoll listener."); - } + if (UNLIKELY(status)) + throw EpollError("Can't add an event to epoll listener."); + } - int wait(Event* events, int max_events, int timeout) - { - return epoll_wait(epoll_fd, events, max_events, timeout); - } + int wait(Event* events, int max_events, int timeout) { + return epoll_wait(epoll_fd, events, max_events, timeout); + } - int id() const - { - return epoll_fd; - } + int id() const { return epoll_fd; } -private: - int epoll_fd; - Logger logger; + private: + int epoll_fd; + Logger logger; }; - } diff --git a/src/io/network/event_listener.hpp b/src/io/network/event_listener.hpp index d951fa6c3..1b103c66f 100644 --- a/src/io/network/event_listener.hpp +++ b/src/io/network/event_listener.hpp @@ -1,90 +1,82 @@ #pragma once #include "io/network/epoll.hpp" -#include "utils/crtp.hpp" #include "logging/default.hpp" +#include "utils/crtp.hpp" -namespace io -{ +namespace io { template <class Derived, size_t max_events = 64, int wait_timeout = -1> -class EventListener : public Crtp<Derived> -{ -public: - using Crtp<Derived>::derived; +class EventListener : public Crtp<Derived> { + public: + using Crtp<Derived>::derived; - EventListener(uint32_t flags = 0) : - listener(flags), - logger(logging::log->logger("io::EventListener")) - { - } + EventListener(uint32_t flags = 0) + : listener(flags), logger(logging::log->logger("io::EventListener")) {} - void wait_and_process_events() - { - // TODO hardcoded a wait timeout because of thread joining - // when you shutdown the server. This should be wait_timeout of the - // template parameter and should almost never change from that. - // thread joining should be resolved using a signal that interrupts - // the system call. + void wait_and_process_events() { + // TODO hardcoded a wait timeout because of thread joining + // when you shutdown the server. This should be wait_timeout of the + // template parameter and should almost never change from that. + // thread joining should be resolved using a signal that interrupts + // the system call. - // waits for an event/multiple events and returns a maximum of - // max_events and stores them in the events array. it waits for - // wait_timeout milliseconds. if wait_timeout is achieved, returns 0 - - auto n = listener.wait(events, max_events, 200); + // waits for an event/multiple events and returns a maximum of + // max_events and stores them in the events array. it waits for + // wait_timeout milliseconds. if wait_timeout is achieved, returns 0 + + auto n = listener.wait(events, max_events, 200); #ifndef NDEBUG #ifndef LOG_NO_TRACE - if (n > 0) - logger.trace("number of events: {}", n); + if (n > 0) logger.trace("number of events: {}", n); #endif #endif - // go through all events and process them in order - for (int i = 0; i < n; ++i) { - auto &event = events[i]; + // go through all events and process them in order + for (int i = 0; i < n; ++i) { + auto &event = events[i]; - try { - // hangup event - if (UNLIKELY(event.events & EPOLLRDHUP)) { - this->derived().on_close_event(event); - continue; - } - - // there was an error on the server side - if (UNLIKELY(!(event.events & EPOLLIN) || - event.events & (EPOLLHUP | EPOLLERR))) { - this->derived().on_error_event(event); - continue; - } - - // we have some data waiting to be read - this->derived().on_data_event(event); - } catch (const std::exception &e) { - this->derived().on_exception_event( - event, "Error occured while processing event \n{}", - e.what()); - } + try { + // hangup event + if (UNLIKELY(event.events & EPOLLRDHUP)) { + this->derived().on_close_event(event); + continue; } - // this will be optimized out :D - if (wait_timeout < 0) return; + // there was an error on the server side + if (UNLIKELY(!(event.events & EPOLLIN) || + event.events & (EPOLLHUP | EPOLLERR))) { + this->derived().on_error_event(event); + continue; + } - // if there was events, continue to wait on new events - if (n != 0) return; - - // wait timeout occurred and there were no events. if wait_timeout - // is -1 there will never be any timeouts so client should provide - // an empty function. in that case the conditional above and the - // function call will be optimized out by the compiler - this->derived().on_wait_timeout(); + // we have some data waiting to be read + this->derived().on_data_event(event); + } catch (const std::exception &e) { + this->derived().on_exception_event( + event, "Error occured while processing event \n{}", e.what()); + } } -protected: - Epoll listener; - Epoll::Event events[max_events]; + // this will be optimized out :D + if (wait_timeout < 0) return; -private: - Logger logger; + // if there was events, continue to wait on new events + if (n != 0) return; + + // wait timeout occurred and there were no events. if wait_timeout + // is -1 there will never be any timeouts so client should provide + // an empty function. in that case the conditional above and the + // function call will be optimized out by the compiler + this->derived().on_wait_timeout(); + } + + protected: + Epoll listener; + Epoll::Event events[max_events]; + + private: + Logger logger; }; } diff --git a/src/io/network/network_error.hpp b/src/io/network/network_error.hpp index ed528a07b..0c96a7a9c 100644 --- a/src/io/network/network_error.hpp +++ b/src/io/network/network_error.hpp @@ -4,13 +4,10 @@ #include "utils/exceptions/basic_exception.hpp" -namespace io -{ +namespace io { -class NetworkError : public BasicException -{ -public: - using BasicException::BasicException; +class NetworkError : public BasicException { + public: + using BasicException::BasicException; }; - } diff --git a/src/io/network/secure_socket.hpp b/src/io/network/secure_socket.hpp index c79ff3c12..264aa68a2 100644 --- a/src/io/network/secure_socket.hpp +++ b/src/io/network/secure_socket.hpp @@ -1,93 +1,63 @@ #pragma once -#include "tls.hpp" #include "io/network/socket.hpp" +#include "tls.hpp" #include "tls_error.hpp" #include "utils/types/byte.hpp" #include <iostream> -namespace io -{ +namespace io { -class SecureSocket -{ -public: - SecureSocket(Socket&& socket, const Tls::Context& tls) - : socket(std::forward<Socket>(socket)) - { - ssl = SSL_new(tls); - SSL_set_fd(ssl, this->socket); +class SecureSocket { + public: + SecureSocket(Socket&& socket, const Tls::Context& tls) + : socket(std::forward<Socket>(socket)) { + ssl = SSL_new(tls); + SSL_set_fd(ssl, this->socket); - SSL_set_accept_state(ssl); + SSL_set_accept_state(ssl); - if(SSL_accept(ssl) <= 0) - ERR_print_errors_fp(stderr); - } + if (SSL_accept(ssl) <= 0) ERR_print_errors_fp(stderr); + } - SecureSocket(SecureSocket&& other) - { - *this = std::forward<SecureSocket>(other); - } + SecureSocket(SecureSocket&& other) { + *this = std::forward<SecureSocket>(other); + } - SecureSocket& operator=(SecureSocket&& other) - { - socket = std::move(other.socket); + SecureSocket& operator=(SecureSocket&& other) { + socket = std::move(other.socket); - ssl = other.ssl; - other.ssl = nullptr; + ssl = other.ssl; + other.ssl = nullptr; - return *this; - } + return *this; + } - ~SecureSocket() - { - if(ssl == nullptr) - return; + ~SecureSocket() { + if (ssl == nullptr) return; - std::cout << "DELETING SSL" << std::endl; + std::cout << "DELETING SSL" << std::endl; - SSL_free(ssl); - } + SSL_free(ssl); + } - int error(int status) - { - return SSL_get_error(ssl, status); - } + int error(int status) { return SSL_get_error(ssl, status); } - int write(const std::string& str) - { - return write(str.c_str(), str.size()); - } + int write(const std::string& str) { return write(str.c_str(), str.size()); } - int write(const byte* data, size_t len) - { - return SSL_write(ssl, data, len); - } + int write(const byte* data, size_t len) { return SSL_write(ssl, data, len); } - int write(const char* data, size_t len) - { - return SSL_write(ssl, data, len); - } + int write(const char* data, size_t len) { return SSL_write(ssl, data, len); } - int read(char* buffer, size_t len) - { - return SSL_read(ssl, buffer, len); - } + int read(char* buffer, size_t len) { return SSL_read(ssl, buffer, len); } - operator int() - { - return socket; - } + operator int() { return socket; } - operator Socket&() - { - return socket; - } + operator Socket&() { return socket; } -private: - Socket socket; - SSL* ssl {nullptr}; + private: + Socket socket; + SSL* ssl{nullptr}; }; - } diff --git a/src/io/network/secure_stream_reader.hpp b/src/io/network/secure_stream_reader.hpp index 6a2c26b2a..591a232bd 100644 --- a/src/io/network/secure_stream_reader.hpp +++ b/src/io/network/secure_stream_reader.hpp @@ -5,57 +5,47 @@ #include "io/network/stream_reader.hpp" #include "logging/default.hpp" -namespace io -{ +namespace io { using namespace memory::literals; template <class Derived, class Stream> -class SecureStreamReader : public StreamReader<Derived, Stream> -{ -public: - struct Buffer - { - char* ptr; - size_t len; - }; +class SecureStreamReader : public StreamReader<Derived, Stream> { + public: + struct Buffer { + char* ptr; + size_t len; + }; - SecureStreamReader(uint32_t flags = 0) - : StreamReader<Derived, Stream>(flags) {} + SecureStreamReader(uint32_t flags = 0) + : StreamReader<Derived, Stream>(flags) {} - void on_data(Stream& stream) - { - while(true) - { - // allocate the buffer to fill the data - auto buf = this->derived().on_alloc(stream); + void on_data(Stream& stream) { + while (true) { + // allocate the buffer to fill the data + auto buf = this->derived().on_alloc(stream); - // read from the buffer at most buf.len bytes - auto len = stream.socket.read(buf.ptr, buf.len); + // read from the buffer at most buf.len bytes + auto len = stream.socket.read(buf.ptr, buf.len); - if(LIKELY(len > 0)) - { - buf.len = len; - return this->derived().on_read(stream, buf); - } + if (LIKELY(len > 0)) { + buf.len = len; + return this->derived().on_read(stream, buf); + } - auto err = stream.socket.error(len); + auto err = stream.socket.error(len); - // the socket is not ready for reading yet - if(err == SSL_ERROR_WANT_READ || - err == SSL_ERROR_WANT_WRITE || - err == SSL_ERROR_WANT_X509_LOOKUP) - { - return; - } + // the socket is not ready for reading yet + if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE || + err == SSL_ERROR_WANT_X509_LOOKUP) { + return; + } - // the socket notified a close event - if(err == SSL_ERROR_ZERO_RETURN) - return stream.close(); + // the socket notified a close event + if (err == SSL_ERROR_ZERO_RETURN) return stream.close(); - // some other error occurred, check errno - return this->derived().on_error(stream); - } + // some other error occurred, check errno + return this->derived().on_error(stream); } + } }; - } diff --git a/src/io/network/server.hpp b/src/io/network/server.hpp index 8f6fc1c0e..368ae4a5d 100644 --- a/src/io/network/server.hpp +++ b/src/io/network/server.hpp @@ -2,47 +2,42 @@ #include "io/network/stream_reader.hpp" -namespace io -{ +namespace io { template <class Derived> -class Server : public EventListener<Derived> -{ -public: - Server(Socket &&socket) - : socket(std::forward<Socket>(socket)), - logger(logging::log->logger("io::Server")) - { - event.data.fd = this->socket; +class Server : public EventListener<Derived> { + public: + Server(Socket &&socket) + : socket(std::forward<Socket>(socket)), + logger(logging::log->logger("io::Server")) { + event.data.fd = this->socket; - // TODO: EPOLLET is hard to use -> figure out how should EPOLLET be used - // event.events = EPOLLIN | EPOLLET; - event.events = EPOLLIN; + // TODO: EPOLLET is hard to use -> figure out how should EPOLLET be used + // event.events = EPOLLIN | EPOLLET; + event.events = EPOLLIN; - this->listener.add(this->socket, &event); - } + this->listener.add(this->socket, &event); + } - void on_close_event(Epoll::Event &event) { ::close(event.data.fd); } + void on_close_event(Epoll::Event &event) { ::close(event.data.fd); } - void on_error_event(Epoll::Event &event) { ::close(event.data.fd); } + void on_error_event(Epoll::Event &event) { ::close(event.data.fd); } - void on_data_event(Epoll::Event &event) - { - if (UNLIKELY(socket != event.data.fd)) return; + void on_data_event(Epoll::Event &event) { + if (UNLIKELY(socket != event.data.fd)) return; - this->derived().on_connect(); - } + this->derived().on_connect(); + } - template <class... Args> - void on_exception_event(Epoll::Event &event, Args &&... args) - { - // TODO: Do something about it - logger.warn("epoll exception"); - } + template <class... Args> + void on_exception_event(Epoll::Event &event, Args &&... args) { + // TODO: Do something about it + logger.warn("epoll exception"); + } -protected: - Epoll::Event event; - Socket socket; - Logger logger; + protected: + Epoll::Event event; + Socket socket; + Logger logger; }; } diff --git a/src/io/network/socket.hpp b/src/io/network/socket.hpp index c5e49d8d8..b474994f1 100644 --- a/src/io/network/socket.hpp +++ b/src/io/network/socket.hpp @@ -1,17 +1,17 @@ #pragma once -#include <stdexcept> -#include <cstring> -#include <cstdio> #include <cassert> +#include <cstdio> +#include <cstring> +#include <stdexcept> -#include <sys/types.h> -#include <sys/socket.h> -#include <netdb.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/epoll.h> #include <errno.h> +#include <fcntl.h> +#include <netdb.h> +#include <sys/epoll.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <unistd.h> #include "io/network/addrinfo.hpp" #include "utils/likely.hpp" @@ -20,179 +20,139 @@ #include <iostream> -namespace io -{ +namespace io { -class Socket -{ -protected: - Socket(int family, int socket_type, int protocol) - { - socket = ::socket(family, socket_type, protocol); - } +class Socket { + protected: + Socket(int family, int socket_type, int protocol) { + socket = ::socket(family, socket_type, protocol); + } -public: - using byte = uint8_t; + public: + using byte = uint8_t; - Socket(int socket = -1) : socket(socket) {} + Socket(int socket = -1) : socket(socket) {} - Socket(const Socket&) = delete; + Socket(const Socket&) = delete; - Socket(Socket&& other) - { - *this = std::forward<Socket>(other); - } + Socket(Socket&& other) { *this = std::forward<Socket>(other); } - ~Socket() - { - if(socket == -1) - return; + ~Socket() { + if (socket == -1) return; #ifndef NDEBUG - logging::debug("DELETING SOCKET"); + logging::debug("DELETING SOCKET"); #endif - ::close(socket); + ::close(socket); + } + + void close() { + ::close(socket); + socket = -1; + } + + Socket& operator=(Socket&& other) { + this->socket = other.socket; + other.socket = -1; + return *this; + } + + bool is_open() { return socket != -1; } + + static Socket connect(const std::string& addr, const std::string& port) { + return connect(addr.c_str(), port.c_str()); + } + + static Socket connect(const char* addr, const char* port) { + auto info = AddrInfo::get(addr, port); + + for (struct addrinfo* it = info; it != nullptr; it = it->ai_next) { + auto s = Socket(it->ai_family, it->ai_socktype, it->ai_protocol); + + if (!s.is_open()) continue; + + if (::connect(s, it->ai_addr, it->ai_addrlen) == 0) return s; } - void close() - { - ::close(socket); - socket = -1; + throw NetworkError("Unable to connect to socket"); + } + + static Socket bind(const std::string& addr, const std::string& port) { + return bind(addr.c_str(), port.c_str()); + } + + static Socket bind(const char* addr, const char* port) { + auto info = AddrInfo::get(addr, port); + + for (struct addrinfo* it = info; it != nullptr; it = it->ai_next) { + auto s = Socket(it->ai_family, it->ai_socktype, it->ai_protocol); + + if (!s.is_open()) continue; + + int on = 1; + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) continue; + + if (::bind(s, it->ai_addr, it->ai_addrlen) == 0) return s; } - Socket& operator=(Socket&& other) - { - this->socket = other.socket; - other.socket = -1; - return *this; - } + throw NetworkError("Unable to bind to socket"); + } - bool is_open() - { - return socket != -1; - } + void set_non_blocking() { + auto flags = fcntl(socket, F_GETFL, 0); - static Socket connect(const std::string& addr, const std::string& port) - { - return connect(addr.c_str(), port.c_str()); - } + if (UNLIKELY(flags == -1)) + throw NetworkError("Cannot read flags from socket"); - static Socket connect(const char* addr, const char* port) - { - auto info = AddrInfo::get(addr, port); + flags |= O_NONBLOCK; - for(struct addrinfo* it = info; it != nullptr; it = it->ai_next) - { - auto s = Socket(it->ai_family, it->ai_socktype, it->ai_protocol); + auto status = fcntl(socket, F_SETFL, flags); - if(!s.is_open()) - continue; + if (UNLIKELY(status == -1)) + throw NetworkError("Cannot set NON_BLOCK flag to socket"); + } - if(::connect(s, it->ai_addr, it->ai_addrlen) == 0) - return s; - } + void listen(int backlog) { + auto status = ::listen(socket, backlog); - throw NetworkError("Unable to connect to socket"); - } + if (UNLIKELY(status == -1)) throw NetworkError("Cannot listen on socket"); + } - static Socket bind(const std::string& addr, const std::string& port) - { - return bind(addr.c_str(), port.c_str()); - } + Socket accept(struct sockaddr* addr, socklen_t* len) { + return Socket(::accept(socket, addr, len)); + } - static Socket bind(const char* addr, const char* port) - { - auto info = AddrInfo::get(addr, port); + operator int() { return socket; } - for(struct addrinfo* it = info; it != nullptr; it = it->ai_next) - { - auto s = Socket(it->ai_family, it->ai_socktype, it->ai_protocol); + int id() const { return socket; } - if(!s.is_open()) - continue; + int write(const std::string& str) { return write(str.c_str(), str.size()); } - int on = 1; - if(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) - continue; + int write(const char* data, size_t len) { + return write(reinterpret_cast<const byte*>(data), len); + } - if(::bind(s, it->ai_addr, it->ai_addrlen) == 0) - return s; - } - - throw NetworkError("Unable to bind to socket"); - } - - void set_non_blocking() - { - auto flags = fcntl(socket, F_GETFL, 0); - - if(UNLIKELY(flags == -1)) - throw NetworkError("Cannot read flags from socket"); - - flags |= O_NONBLOCK; - - auto status = fcntl(socket, F_SETFL, flags); - - if(UNLIKELY(status == -1)) - throw NetworkError("Cannot set NON_BLOCK flag to socket"); - } - - void listen(int backlog) - { - auto status = ::listen(socket, backlog); - - if(UNLIKELY(status == -1)) - throw NetworkError("Cannot listen on socket"); - } - - Socket accept(struct sockaddr* addr, socklen_t* len) - { - return Socket(::accept(socket, addr, len)); - } - - operator int() { return socket; } - - int id() const - { - return socket; - } - - int write(const std::string& str) - { - return write(str.c_str(), str.size()); - } - - int write(const char* data, size_t len) - { - return write(reinterpret_cast<const byte*>(data), len); - } - - int write(const byte* data, size_t len) - { - // TODO: use logger + int write(const byte* data, size_t len) { +// TODO: use logger #ifndef NDEBUG - std::stringstream stream; + std::stringstream stream; - for(size_t i = 0; i < len; ++i) - stream << fmt::format("{:02X} ", static_cast<byte>(data[i])); + for (size_t i = 0; i < len; ++i) + stream << fmt::format("{:02X} ", static_cast<byte>(data[i])); - auto str = stream.str(); + auto str = stream.str(); - logging::debug("[Write {}B] {}", len, str); + logging::debug("[Write {}B] {}", len, str); #endif - return ::write(socket, data, len); - } + return ::write(socket, data, len); + } - int read(void* buffer, size_t len) - { - return ::read(socket, buffer, len); - } + int read(void* buffer, size_t len) { return ::read(socket, buffer, len); } -protected: - Logger logger; - int socket; + protected: + Logger logger; + int socket; }; - } diff --git a/src/io/network/stream_listener.hpp b/src/io/network/stream_listener.hpp index 9b0be8dee..525fd8a13 100644 --- a/src/io/network/stream_listener.hpp +++ b/src/io/network/stream_listener.hpp @@ -2,47 +2,39 @@ #include "io/network/event_listener.hpp" -namespace io -{ +namespace io { template <class Derived, class Stream, size_t max_events = 64, int wait_timeout = -1> -class StreamListener : public EventListener<Derived, max_events, wait_timeout> -{ -public: - using EventListener<Derived, max_events, wait_timeout>::EventListener; +class StreamListener : public EventListener<Derived, max_events, wait_timeout> { + public: + using EventListener<Derived, max_events, wait_timeout>::EventListener; - void add(Stream &stream) - { - // add the stream to the event listener - this->listener.add(stream.socket, &stream.event); - } + void add(Stream &stream) { + // add the stream to the event listener + this->listener.add(stream.socket, &stream.event); + } - void on_close_event(Epoll::Event &event) - { - this->derived().on_close(to_stream(event)); - } + void on_close_event(Epoll::Event &event) { + this->derived().on_close(to_stream(event)); + } - void on_error_event(Epoll::Event &event) - { - this->derived().on_error(to_stream(event)); - } + void on_error_event(Epoll::Event &event) { + this->derived().on_error(to_stream(event)); + } - void on_data_event(Epoll::Event &event) - { - this->derived().on_data(to_stream(event)); - } + void on_data_event(Epoll::Event &event) { + this->derived().on_data(to_stream(event)); + } - template <class... Args> - void on_exception_event(Epoll::Event &event, Args &&... args) - { - this->derived().on_exception(to_stream(event), args...); - } + template <class... Args> + void on_exception_event(Epoll::Event &event, Args &&... args) { + this->derived().on_exception(to_stream(event), args...); + } -private: - Stream &to_stream(Epoll::Event &event) - { - return *reinterpret_cast<Stream *>(event.data.ptr); - } + private: + Stream &to_stream(Epoll::Event &event) { + return *reinterpret_cast<Stream *>(event.data.ptr); + } }; } diff --git a/src/io/network/stream_reader.hpp b/src/io/network/stream_reader.hpp index 8e2035256..7e5eac34f 100644 --- a/src/io/network/stream_reader.hpp +++ b/src/io/network/stream_reader.hpp @@ -3,93 +3,82 @@ #include "io/network/stream_listener.hpp" #include "memory/literals.hpp" -namespace io -{ +namespace io { using namespace memory::literals; template <class Derived, class Stream> -class StreamReader : public StreamListener<Derived, Stream> -{ -public: - struct Buffer - { - char* ptr; - size_t len; - }; +class StreamReader : public StreamListener<Derived, Stream> { + public: + struct Buffer { + char* ptr; + size_t len; + }; - StreamReader(uint32_t flags = 0) : StreamListener<Derived, Stream>(flags), + StreamReader(uint32_t flags = 0) + : StreamListener<Derived, Stream>(flags), logger(logging::log->logger("io::StreamReader")) {} - bool accept(Socket& socket) - { - logger.trace("accept"); + bool accept(Socket& socket) { + logger.trace("accept"); - // accept a connection from a socket - auto s = socket.accept(nullptr, nullptr); + // accept a connection from a socket + auto s = socket.accept(nullptr, nullptr); - if(!s.is_open()) - return false; + if (!s.is_open()) return false; - // make the recieved socket non blocking - s.set_non_blocking(); + // make the recieved socket non blocking + s.set_non_blocking(); - auto& stream = this->derived().on_connect(std::move(s)); + auto& stream = this->derived().on_connect(std::move(s)); - // we want to listen to an incoming event which is edge triggered and - // we also want to listen on the hangup event - stream.event.events = EPOLLIN | EPOLLET | EPOLLRDHUP; + // we want to listen to an incoming event which is edge triggered and + // we also want to listen on the hangup event + stream.event.events = EPOLLIN | EPOLLET | EPOLLRDHUP; - // add the connection to the event listener - this->add(stream); + // add the connection to the event listener + this->add(stream); - return true; - } + return true; + } - void on_data(Stream& stream) - { - logger.trace("on data"); + void on_data(Stream& stream) { + logger.trace("on data"); - while(true) - { - if(UNLIKELY(!stream.alive())) - { - stream.close(); - break; - } + while (true) { + if (UNLIKELY(!stream.alive())) { + stream.close(); + break; + } - // allocate the buffer to fill the data - auto buf = this->derived().on_alloc(stream); + // allocate the buffer to fill the data + auto buf = this->derived().on_alloc(stream); - // read from the buffer at most buf.len bytes - buf.len = stream.socket.read(buf.ptr, buf.len); + // read from the buffer at most buf.len bytes + buf.len = stream.socket.read(buf.ptr, buf.len); - // check for read errors - if(buf.len == -1) - { - // this means we have read all available data - if(LIKELY(errno == EAGAIN)) - { - break; - } - - // some other error occurred, check errno - this->derived().on_error(stream); - break; - } - - // end of file, the client has closed the connection - if(UNLIKELY(buf.len == 0)) - { - stream.close(); - break; - } - - this->derived().on_read(stream, buf); + // check for read errors + if (buf.len == -1) { + // this means we have read all available data + if (LIKELY(errno == EAGAIN)) { + break; } + + // some other error occurred, check errno + this->derived().on_error(stream); + break; + } + + // end of file, the client has closed the connection + if (UNLIKELY(buf.len == 0)) { + stream.close(); + break; + } + + this->derived().on_read(stream, buf); } + } -private: - Logger logger; + private: + Logger logger; }; - } diff --git a/src/io/network/tcp/stream.hpp b/src/io/network/tcp/stream.hpp index 1317884a6..209e718f7 100644 --- a/src/io/network/tcp/stream.hpp +++ b/src/io/network/tcp/stream.hpp @@ -3,33 +3,27 @@ #include "io/network/epoll.hpp" #include "io/network/socket.hpp" -namespace io -{ -namespace tcp -{ +namespace io { +namespace tcp { template <class Socket> -class Stream -{ -public: - Stream(Socket&& socket) : socket(std::move(socket)) - { - // save this to epoll event data baton to access later - event.data.ptr = this; - } +class Stream { + public: + Stream(Socket&& socket) : socket(std::move(socket)) { + // save this to epoll event data baton to access later + event.data.ptr = this; + } - Stream(Stream&& stream) - { - socket = std::move(stream.socket); - event = stream.event; - event.data.ptr = this; - } + Stream(Stream&& stream) { + socket = std::move(stream.socket); + event = stream.event; + event.data.ptr = this; + } - int id() const { return socket.id(); } + int id() const { return socket.id(); } - Socket socket; - Epoll::Event event; + Socket socket; + Epoll::Event event; }; - } } diff --git a/src/io/network/test.cpp b/src/io/network/test.cpp index a69ab52a8..7c8191232 100644 --- a/src/io/network/test.cpp +++ b/src/io/network/test.cpp @@ -1,5 +1,5 @@ -#include <iostream> #include <signal.h> +#include <iostream> #include <thread> #include <vector> @@ -26,114 +26,101 @@ std::atomic<bool> alive{true}; void exiting() { LOG_DEBUG("Exiting..."); } -void sigint_handler(int) -{ - - exiting(); - std::exit(0); +void sigint_handler(int) { + exiting(); + std::exit(0); } #define MAXEVENTS 64 -int main(void) -{ - // std::atexit(exiting); - signal(SIGINT, sigint_handler); +int main(void) { + // std::atexit(exiting); + signal(SIGINT, sigint_handler); - for (size_t i = 0; i < workers.size(); ++i) - { - auto &w = workers[i]; + for (size_t i = 0; i < workers.size(); ++i) { + auto &w = workers[i]; - threads[i] = std::thread([i, &w]() { - while (alive) - { - LOG_DEBUG("waiting for events on thread " << i); - w.wait_and_process_events(); - } - }); - } + threads[i] = std::thread([i, &w]() { + while (alive) { + LOG_DEBUG("waiting for events on thread " << i); + w.wait_and_process_events(); + } + }); + } - /* size_t WORKERS = std::thread::hardware_concurrency(); */ + /* size_t WORKERS = std::thread::hardware_concurrency(); */ - /* std::vector<io::Worker> workers; */ - /* workers.resize(WORKERS); */ + /* std::vector<io::Worker> workers; */ + /* workers.resize(WORKERS); */ - /* for(size_t i = 0; i < WORKERS; ++i) */ - /* { */ - /* workers.push_back(std::move(io::Worker())); */ - /* workers.back().start(); */ - /* } */ + /* for(size_t i = 0; i < WORKERS; ++i) */ + /* { */ + /* workers.push_back(std::move(io::Worker())); */ + /* workers.back().start(); */ + /* } */ - int idx = 0; + int idx = 0; - auto socket = io::Socket::bind("0.0.0.0", "7474"); - socket.set_non_blocking(); - socket.listen(1024); + auto socket = io::Socket::bind("0.0.0.0", "7474"); + socket.set_non_blocking(); + socket.listen(1024); - int efd, s; - struct epoll_event event; - struct epoll_event *events; + int efd, s; + struct epoll_event event; + struct epoll_event *events; - efd = epoll_create1(0); - if (efd == -1) - { - perror("epoll_create"); - abort(); - } + efd = epoll_create1(0); + if (efd == -1) { + perror("epoll_create"); + abort(); + } - event.data.fd = socket; - event.events = EPOLLIN | EPOLLET; - s = epoll_ctl(efd, EPOLL_CTL_ADD, socket, &event); - if (s == -1) - { - perror("epoll_ctl"); - abort(); - } + event.data.fd = socket; + event.events = EPOLLIN | EPOLLET; + s = epoll_ctl(efd, EPOLL_CTL_ADD, socket, &event); + if (s == -1) { + perror("epoll_ctl"); + abort(); + } - /* Buffer where events are returned */ - events = static_cast<struct epoll_event *>(calloc(MAXEVENTS, sizeof event)); + /* Buffer where events are returned */ + events = static_cast<struct epoll_event *>(calloc(MAXEVENTS, sizeof event)); - /* The event loop */ - while (1) - { - int n, i; + /* The event loop */ + while (1) { + int n, i; - LOG_DEBUG("acceptor waiting for events"); - n = epoll_wait(efd, events, MAXEVENTS, -1); + LOG_DEBUG("acceptor waiting for events"); + n = epoll_wait(efd, events, MAXEVENTS, -1); - LOG_DEBUG("acceptor recieved " << n << " connection requests"); + LOG_DEBUG("acceptor recieved " << n << " connection requests"); - for (i = 0; i < n; i++) - { - if ((events[i].events & EPOLLERR) || - (events[i].events & EPOLLHUP) || - (!(events[i].events & EPOLLIN))) - { - /* An error has occured on this fd, or the socket is not - ready for reading (why were we notified then?) */ - fprintf(stderr, "epoll error\n"); - close(events[i].data.fd); - continue; - } + for (i = 0; i < n; i++) { + if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || + (!(events[i].events & EPOLLIN))) { + /* An error has occured on this fd, or the socket is not + ready for reading (why were we notified then?) */ + fprintf(stderr, "epoll error\n"); + close(events[i].data.fd); + continue; + } - else if (socket == events[i].data.fd) - { - /* We have a notification on the listening socket, which - means one or more incoming connections. */ - while (true) - { - LOG_DEBUG("trying to accept connection on thread " << idx); - if (!workers[idx].accept(socket)) break; + else if (socket == events[i].data.fd) { + /* We have a notification on the listening socket, which + means one or more incoming connections. */ + while (true) { + LOG_DEBUG("trying to accept connection on thread " << idx); + if (!workers[idx].accept(socket)) break; - LOG_DEBUG("Accepted a new connection on thread " << idx); - idx = (idx + 1) % workers.size(); - break; - } - } + LOG_DEBUG("Accepted a new connection on thread " << idx); + idx = (idx + 1) % workers.size(); + break; } + } } + } - free(events); + free(events); - return 0; + return 0; } diff --git a/src/io/network/tls.cpp b/src/io/network/tls.cpp index 921d56c4b..1a31db356 100644 --- a/src/io/network/tls.cpp +++ b/src/io/network/tls.cpp @@ -1,55 +1,42 @@ #include "io/network/tls.hpp" #include "io/network/tls_error.hpp" -namespace io -{ +namespace io { -Tls::Context::Context() -{ - auto method = SSLv23_server_method(); - ctx = SSL_CTX_new(method); - - if(!ctx) - { - ERR_print_errors_fp(stderr); - throw io::TlsError("Unable to create TLS context"); - } - - SSL_CTX_set_ecdh_auto(ctx, 1); -} - -Tls::Context::~Context() -{ - SSL_CTX_free(ctx); -} - -Tls::Context& Tls::Context::cert(const std::string& path) -{ - if(SSL_CTX_use_certificate_file(ctx, path.c_str(), SSL_FILETYPE_PEM) >= 0) - return *this; +Tls::Context::Context() { + auto method = SSLv23_server_method(); + ctx = SSL_CTX_new(method); + if (!ctx) { ERR_print_errors_fp(stderr); - throw TlsError("Error Loading cert '{}'", path); + throw io::TlsError("Unable to create TLS context"); + } + + SSL_CTX_set_ecdh_auto(ctx, 1); } -Tls::Context& Tls::Context::key(const std::string& path) -{ - if(SSL_CTX_use_PrivateKey_file(ctx, path.c_str(), SSL_FILETYPE_PEM) >= 0) - return *this; +Tls::Context::~Context() { SSL_CTX_free(ctx); } - ERR_print_errors_fp(stderr); - throw TlsError("Error Loading private key '{}'", path); +Tls::Context& Tls::Context::cert(const std::string& path) { + if (SSL_CTX_use_certificate_file(ctx, path.c_str(), SSL_FILETYPE_PEM) >= 0) + return *this; + + ERR_print_errors_fp(stderr); + throw TlsError("Error Loading cert '{}'", path); } -void Tls::initialize() -{ - SSL_load_error_strings(); - OpenSSL_add_ssl_algorithms(); +Tls::Context& Tls::Context::key(const std::string& path) { + if (SSL_CTX_use_PrivateKey_file(ctx, path.c_str(), SSL_FILETYPE_PEM) >= 0) + return *this; + + ERR_print_errors_fp(stderr); + throw TlsError("Error Loading private key '{}'", path); } -void Tls::cleanup() -{ - EVP_cleanup(); +void Tls::initialize() { + SSL_load_error_strings(); + OpenSSL_add_ssl_algorithms(); } +void Tls::cleanup() { EVP_cleanup(); } } diff --git a/src/io/network/tls.hpp b/src/io/network/tls.hpp index bd0de8fdc..0f3a0fca2 100644 --- a/src/io/network/tls.hpp +++ b/src/io/network/tls.hpp @@ -2,32 +2,28 @@ #include <string> -#include <openssl/ssl.h> #include <openssl/err.h> +#include <openssl/ssl.h> -namespace io -{ +namespace io { -class Tls -{ -public: - class Context - { - public: - Context(); - ~Context(); +class Tls { + public: + class Context { + public: + Context(); + ~Context(); - Context& cert(const std::string& path); - Context& key(const std::string& path); + Context& cert(const std::string& path); + Context& key(const std::string& path); - operator SSL_CTX*() const { return ctx; } + operator SSL_CTX*() const { return ctx; } - private: - SSL_CTX* ctx; - }; + private: + SSL_CTX* ctx; + }; - static void initialize(); - static void cleanup(); + static void initialize(); + static void cleanup(); }; - } diff --git a/src/io/network/tls_error.hpp b/src/io/network/tls_error.hpp index 53440a728..3976db347 100644 --- a/src/io/network/tls_error.hpp +++ b/src/io/network/tls_error.hpp @@ -2,13 +2,10 @@ #include "utils/exceptions/basic_exception.hpp" -namespace io -{ +namespace io { -class TlsError : public BasicException -{ -public: - using BasicException::BasicException; +class TlsError : public BasicException { + public: + using BasicException::BasicException; }; - } diff --git a/src/logging/default.cpp b/src/logging/default.cpp index efffa027c..62a695bd7 100644 --- a/src/logging/default.cpp +++ b/src/logging/default.cpp @@ -5,30 +5,22 @@ #include "logging/streams/stdout.hpp" -namespace logging -{ +namespace logging { // per object log source // TODO: discussion std::unique_ptr<Log> log; -void init_async() -{ - log = std::make_unique<AsyncLog>(); -} +void init_async() { log = std::make_unique<AsyncLog>(); } -void init_sync() -{ - log = std::make_unique<SyncLog>(); -} +void init_sync() { log = std::make_unique<SyncLog>(); } // "global" DEBUG logger std::unique_ptr<Log> debug_log = std::make_unique<SyncLog>(); -Logger init_debug_logger() -{ - debug_log->pipe(std::make_unique<Stdout>()); - return debug_log->logger("DEBUG"); +Logger init_debug_logger() { + debug_log->pipe(std::make_unique<Stdout>()); + return debug_log->logger("DEBUG"); } Logger debug_logger = init_debug_logger(); @@ -36,12 +28,10 @@ Logger debug_logger = init_debug_logger(); // "global" INFO logger std::unique_ptr<Log> info_log = std::make_unique<SyncLog>(); -Logger init_info_logger() -{ - info_log->pipe(std::make_unique<Stdout>()); - return info_log->logger("INFO"); +Logger init_info_logger() { + info_log->pipe(std::make_unique<Stdout>()); + return info_log->logger("INFO"); } Logger info_logger = init_info_logger(); - } diff --git a/src/logging/default.hpp b/src/logging/default.hpp index 31344446b..985e20e53 100644 --- a/src/logging/default.hpp +++ b/src/logging/default.hpp @@ -3,28 +3,24 @@ #include "logging/log.hpp" #include "logging/logger.hpp" -namespace logging -{ +namespace logging { extern std::unique_ptr<Log> log; extern Logger debug_logger; template <class... Args> -void debug(Args&&... args) -{ - debug_logger.debug(std::forward<Args>(args)...); +void debug(Args&&... args) { + debug_logger.debug(std::forward<Args>(args)...); } extern Logger info_logger; template <class... Args> -void info(Args&&... args) -{ - info_logger.info(std::forward<Args>(args)...); +void info(Args&&... args) { + info_logger.info(std::forward<Args>(args)...); } void init_async(); void init_sync(); - } diff --git a/src/logging/levels.cpp b/src/logging/levels.cpp index 48955fe9b..9c3863c43 100644 --- a/src/logging/levels.cpp +++ b/src/logging/levels.cpp @@ -2,6 +2,6 @@ std::string Trace::text = "TRACE"; std::string Debug::text = "DEBUG"; -std::string Info::text = "INFO"; -std::string Warn::text = "WARN"; +std::string Info::text = "INFO"; +std::string Warn::text = "WARN"; std::string Error::text = "ERROR"; diff --git a/src/logging/levels.hpp b/src/logging/levels.hpp index c163309dd..d65c24929 100644 --- a/src/logging/levels.hpp +++ b/src/logging/levels.hpp @@ -2,32 +2,27 @@ #include <string> -struct Trace -{ - static std::string text; - static constexpr unsigned level = 0; +struct Trace { + static std::string text; + static constexpr unsigned level = 0; }; -struct Debug -{ - static std::string text; - static constexpr unsigned level = 10; +struct Debug { + static std::string text; + static constexpr unsigned level = 10; }; -struct Info -{ - static std::string text; - static constexpr unsigned level = 20; +struct Info { + static std::string text; + static constexpr unsigned level = 20; }; -struct Warn -{ - static std::string text; - static constexpr unsigned level = 30; +struct Warn { + static std::string text; + static constexpr unsigned level = 30; }; -struct Error -{ - static std::string text; - static constexpr unsigned level = 40; +struct Error { + static std::string text; + static constexpr unsigned level = 40; }; diff --git a/src/logging/log.cpp b/src/logging/log.cpp index 28e55f70f..3ab46e0a6 100644 --- a/src/logging/log.cpp +++ b/src/logging/log.cpp @@ -4,12 +4,11 @@ #include "logging/logger.hpp" #include "utils/assert.hpp" -Logger Log::logger(const std::string &name) -{ - // TODO: once when properties are refactored enable this - // runtime_assert(this != nullptr, - // "This shouldn't be null. This method is " - // "called before the log object is created. " - // "E.g. static variables before main method."); - return Logger(this, name); +Logger Log::logger(const std::string &name) { + // TODO: once when properties are refactored enable this + // runtime_assert(this != nullptr, + // "This shouldn't be null. This method is " + // "called before the log object is created. " + // "E.g. static variables before main method."); + return Logger(this, name); } diff --git a/src/logging/log.hpp b/src/logging/log.hpp index 909764ef1..4dc5daba8 100644 --- a/src/logging/log.hpp +++ b/src/logging/log.hpp @@ -1,66 +1,60 @@ #pragma once -#include <vector> #include <string> +#include <vector> #include "utils/datetime/timestamp.hpp" class Logger; -class Log -{ -public: - using uptr = std::unique_ptr<Log>; +class Log { + public: + using uptr = std::unique_ptr<Log>; - class Record - { - public: - using uptr = std::unique_ptr<Record>; + class Record { + public: + using uptr = std::unique_ptr<Record>; - Record() = default; - virtual ~Record() = default; + Record() = default; + virtual ~Record() = default; - virtual const Timestamp& when() const = 0; - virtual const std::string& where() const = 0; + virtual const Timestamp& when() const = 0; + virtual const std::string& where() const = 0; - virtual unsigned level() const = 0; - virtual const std::string& level_str() const = 0; + virtual unsigned level() const = 0; + virtual const std::string& level_str() const = 0; - virtual const std::string& text() const = 0; - }; + virtual const std::string& text() const = 0; + }; - class Stream - { - public: - using uptr = std::unique_ptr<Stream>; + class Stream { + public: + using uptr = std::unique_ptr<Stream>; - Stream() = default; - virtual ~Stream() = default; + Stream() = default; + virtual ~Stream() = default; - virtual void emit(const Record&) = 0; - }; + virtual void emit(const Record&) = 0; + }; - virtual ~Log() = default; + virtual ~Log() = default; - Logger logger(const std::string& name); + Logger logger(const std::string& name); - void pipe(Stream::uptr&& stream) - { - streams.emplace_back(std::forward<Stream::uptr>(stream)); - } + void pipe(Stream::uptr&& stream) { + streams.emplace_back(std::forward<Stream::uptr>(stream)); + } - virtual std::string type() = 0; + virtual std::string type() = 0; -protected: - friend class Logger; + protected: + friend class Logger; - virtual void emit(Record::uptr record) = 0; + virtual void emit(Record::uptr record) = 0; - void dispatch(const Record& record) - { - for(auto& stream : streams) - stream->emit(record); - } + void dispatch(const Record& record) { + for (auto& stream : streams) stream->emit(record); + } - std::vector<Stream::uptr> streams; + std::vector<Stream::uptr> streams; }; diff --git a/src/logging/loggable.hpp b/src/logging/loggable.hpp index 9f3233741..572e89897 100644 --- a/src/logging/loggable.hpp +++ b/src/logging/loggable.hpp @@ -8,22 +8,18 @@ * @brief Base class that could be used in all classed which need a logging * functionality. */ -class Loggable -{ -public: - /** - * Sets logger name. - */ - Loggable(const std::string &name) - : logger(logging::log->logger(name)) - { - } +class Loggable { + public: + /** + * Sets logger name. + */ + Loggable(const std::string &name) : logger(logging::log->logger(name)) {} - virtual ~Loggable() {} + virtual ~Loggable() {} -protected: - /** - * Logger instance that can be used only from derived classes. - */ - Logger logger; + protected: + /** + * Logger instance that can be used only from derived classes. + */ + Logger logger; }; diff --git a/src/logging/logger.hpp b/src/logging/logger.hpp index ff2b0f9fd..59f0e862a 100644 --- a/src/logging/logger.hpp +++ b/src/logging/logger.hpp @@ -2,112 +2,88 @@ #include <fmt/format.h> -#include "logging/log.hpp" #include "logging/levels.hpp" +#include "logging/log.hpp" #include "utils/assert.hpp" -class Logger -{ - template <class Level> - class Message : public Log::Record - { - public: - Message(Timestamp timestamp, std::string location, std::string message) - : timestamp(timestamp), location(location), message(message) {} +class Logger { + template <class Level> + class Message : public Log::Record { + public: + Message(Timestamp timestamp, std::string location, std::string message) + : timestamp(timestamp), location(location), message(message) {} - const Timestamp& when() const override - { - return timestamp; - } + const Timestamp& when() const override { return timestamp; } - const std::string& where() const override - { - return location; - } + const std::string& where() const override { return location; } - unsigned level() const override - { - return Level::level; - } + unsigned level() const override { return Level::level; } - const std::string& level_str() const override - { - return Level::text; - } + const std::string& level_str() const override { return Level::text; } - const std::string& text() const override - { - return message; - } + const std::string& text() const override { return message; } - private: - Timestamp timestamp; - std::string location; - std::string message; - }; + private: + Timestamp timestamp; + std::string location; + std::string message; + }; -public: - Logger() = default; + public: + Logger() = default; - Logger(Log* log, const std::string& name) : log(log), name(name) {} + Logger(Log* log, const std::string& name) : log(log), name(name) {} - template <class Level, class... Args> - void emit(Args&&... args) - { - runtime_assert(log != nullptr, "Log object has to be defined."); + template <class Level, class... Args> + void emit(Args&&... args) { + runtime_assert(log != nullptr, "Log object has to be defined."); - auto message = std::make_unique<Message<Level>>( - Timestamp::now(), name, fmt::format(std::forward<Args>(args)...) - ); + auto message = std::make_unique<Message<Level>>( + Timestamp::now(), name, fmt::format(std::forward<Args>(args)...)); - log->emit(std::move(message)); - } + log->emit(std::move(message)); + } - template <class... Args> - void trace(Args&&... args) - { + template <class... Args> + void trace(Args&&... args) { #ifndef NDEBUG #ifndef LOG_NO_TRACE - emit<Trace>(std::forward<Args>(args)...); + emit<Trace>(std::forward<Args>(args)...); #endif #endif - } + } - template <class... Args> - void debug(Args&&... args) - { + template <class... Args> + void debug(Args&&... args) { #ifndef NDEBUG #ifndef LOG_NO_DEBUG - emit<Debug>(std::forward<Args>(args)...); + emit<Debug>(std::forward<Args>(args)...); #endif #endif - } + } - template <class... Args> - void info(Args&&... args) - { + template <class... Args> + void info(Args&&... args) { #ifndef LOG_NO_INFO - emit<Info>(std::forward<Args>(args)...); + emit<Info>(std::forward<Args>(args)...); #endif - } + } - template <class... Args> - void warn(Args&&... args) - { + template <class... Args> + void warn(Args&&... args) { #ifndef LOG_NO_WARN - emit<Warn>(std::forward<Args>(args)...); + emit<Warn>(std::forward<Args>(args)...); #endif - } + } - template <class... Args> - void error(Args&&... args) - { + template <class... Args> + void error(Args&&... args) { #ifndef LOG_NO_ERROR - emit<Error>(std::forward<Args>(args)...); + emit<Error>(std::forward<Args>(args)...); #endif - } + } -private: - Log* log; - std::string name; + private: + Log* log; + std::string name; }; diff --git a/src/logging/logs/async_log.cpp b/src/logging/logs/async_log.cpp index df3d9c2d9..f34e56988 100644 --- a/src/logging/logs/async_log.cpp +++ b/src/logging/logs/async_log.cpp @@ -1,38 +1,27 @@ #include "logging/logs/async_log.hpp" -AsyncLog::~AsyncLog() -{ - alive.store(false); - worker.join(); +AsyncLog::~AsyncLog() { + alive.store(false); + worker.join(); } -void AsyncLog::emit(Record::uptr record) -{ - records.push(std::move(record)); -} +void AsyncLog::emit(Record::uptr record) { records.push(std::move(record)); } -std::string AsyncLog::type() -{ - return "AsyncLog"; -} +std::string AsyncLog::type() { return "AsyncLog"; } -void AsyncLog::work() -{ - using namespace std::chrono_literals; +void AsyncLog::work() { + using namespace std::chrono_literals; - while(true) - { - auto record = records.pop(); + while (true) { + auto record = records.pop(); - if(record != nullptr) - { - dispatch(*record); - continue; - } - - if(!alive) - return; - - std::this_thread::sleep_for(10ms); + if (record != nullptr) { + dispatch(*record); + continue; } + + if (!alive) return; + + std::this_thread::sleep_for(10ms); + } } diff --git a/src/logging/logs/async_log.hpp b/src/logging/logs/async_log.hpp index 1d8db0d35..2e5212974 100644 --- a/src/logging/logs/async_log.hpp +++ b/src/logging/logs/async_log.hpp @@ -2,22 +2,21 @@ #include <thread> -#include "logging/log.hpp" #include "data_structures/queue/mpsc_queue.hpp" +#include "logging/log.hpp" -class AsyncLog : public Log -{ -public: - ~AsyncLog(); +class AsyncLog : public Log { + public: + ~AsyncLog(); -protected: - void emit(Record::uptr) override; - std::string type() override; + protected: + void emit(Record::uptr) override; + std::string type() override; -private: - lockfree::MpscQueue<Record> records; - std::atomic<bool> alive {true}; - std::thread worker {[this]() { work(); }}; + private: + lockfree::MpscQueue<Record> records; + std::atomic<bool> alive{true}; + std::thread worker{[this]() { work(); }}; - void work(); + void work(); }; diff --git a/src/logging/logs/sync_log.cpp b/src/logging/logs/sync_log.cpp index 7a43b8845..8780cff1f 100644 --- a/src/logging/logs/sync_log.cpp +++ b/src/logging/logs/sync_log.cpp @@ -1,12 +1,8 @@ #include "logging/logs/sync_log.hpp" -void SyncLog::emit(Record::uptr record) -{ - auto guard = this->acquire_unique(); - dispatch(*record); +void SyncLog::emit(Record::uptr record) { + auto guard = this->acquire_unique(); + dispatch(*record); } -std::string SyncLog::type() -{ - return "SyncLog"; -} +std::string SyncLog::type() { return "SyncLog"; } diff --git a/src/logging/logs/sync_log.hpp b/src/logging/logs/sync_log.hpp index 15a1d6a00..7e8dba1d6 100644 --- a/src/logging/logs/sync_log.hpp +++ b/src/logging/logs/sync_log.hpp @@ -1,12 +1,11 @@ #pragma once #include "logging/log.hpp" -#include "threading/sync/lockable.hpp" #include "threading/sync/futex.hpp" +#include "threading/sync/lockable.hpp" -class SyncLog : public Log, Lockable<Futex> -{ -protected: - void emit(Record::uptr) override; - std::string type() override; +class SyncLog : public Log, Lockable<Futex> { + protected: + void emit(Record::uptr) override; + std::string type() override; }; diff --git a/src/logging/streams/format.hpp b/src/logging/streams/format.hpp index bd0d18c40..6f59deaf3 100644 --- a/src/logging/streams/format.hpp +++ b/src/logging/streams/format.hpp @@ -6,25 +6,20 @@ #include "logging/log.hpp" // TODO: in c++17 replace with logging::format -namespace logging -{ - namespace format - { - static const std::string out = "{} {:<5} [{}] {}\n"; - static const std::string err = out; +namespace logging { +namespace format { +static const std::string out = "{} {:<5} [{}] {}\n"; +static const std::string err = out; - // TODO: configurable formats - } - - class Formatter - { - public: - static std::string format(const std::string &format, - const Log::Record &record) - { - return fmt::format(format, static_cast<std::string>(record.when()), - record.level_str(), record.where(), - record.text()); - } - }; +// TODO: configurable formats +} + +class Formatter { + public: + static std::string format(const std::string &format, + const Log::Record &record) { + return fmt::format(format, static_cast<std::string>(record.when()), + record.level_str(), record.where(), record.text()); + } +}; } diff --git a/src/logging/streams/stderr.cpp b/src/logging/streams/stderr.cpp index 5fd354036..ddb30051e 100644 --- a/src/logging/streams/stderr.cpp +++ b/src/logging/streams/stderr.cpp @@ -3,7 +3,6 @@ #include <iostream> #include "logging/streams/format.hpp" -void Stderr::emit(const Log::Record& record) -{ - std::cerr << logging::Formatter::format(logging::format::err, record); +void Stderr::emit(const Log::Record& record) { + std::cerr << logging::Formatter::format(logging::format::err, record); } diff --git a/src/logging/streams/stderr.hpp b/src/logging/streams/stderr.hpp index a392e666e..c2723e2b2 100644 --- a/src/logging/streams/stderr.hpp +++ b/src/logging/streams/stderr.hpp @@ -2,8 +2,7 @@ #include "logging/log.hpp" -class Stderr : public Log::Stream -{ -public: - void emit(const Log::Record&) override; +class Stderr : public Log::Stream { + public: + void emit(const Log::Record&) override; }; diff --git a/src/logging/streams/stdout.cpp b/src/logging/streams/stdout.cpp index 999b9122c..565980f5b 100644 --- a/src/logging/streams/stdout.cpp +++ b/src/logging/streams/stdout.cpp @@ -3,7 +3,6 @@ #include <iostream> #include "logging/streams/format.hpp" -void Stdout::emit(const Log::Record& record) -{ - std::cout << logging::Formatter::format(logging::format::out, record); +void Stdout::emit(const Log::Record& record) { + std::cout << logging::Formatter::format(logging::format::out, record); } diff --git a/src/logging/streams/stdout.hpp b/src/logging/streams/stdout.hpp index 74397c6c7..ec7a89360 100644 --- a/src/logging/streams/stdout.hpp +++ b/src/logging/streams/stdout.hpp @@ -2,8 +2,7 @@ #include "logging/log.hpp" -class Stdout : public Log::Stream -{ -public: - void emit(const Log::Record&) override; +class Stdout : public Log::Stream { + public: + void emit(const Log::Record&) override; }; diff --git a/src/memory/deferred_recycler.hpp b/src/memory/deferred_recycler.hpp index f8b3c4b8d..2d8590eac 100644 --- a/src/memory/deferred_recycler.hpp +++ b/src/memory/deferred_recycler.hpp @@ -3,27 +3,23 @@ #include "recycler.hpp" template <class T, class Allocator> -class DeferredRecycler : Recycler<T, Allocator> -{ -public: - using Recycler<T, Allocator>::acquire; +class DeferredRecycler : Recycler<T, Allocator> { + public: + using Recycler<T, Allocator>::acquire; - void recycle(T* item) - { - auto guard = this->acquire_unique(); - dirty.push_back(item); - } + void recycle(T* item) { + auto guard = this->acquire_unique(); + dirty.push_back(item); + } - void clean() - { - auto guard = this->acquire_unique(); + void clean() { + auto guard = this->acquire_unique(); - for(auto item : dirty) - this->recycle_or_delete(item); + for (auto item : dirty) this->recycle_or_delete(item); - dirty.clear(); - } + dirty.clear(); + } -private: - std::queue<T*> dirty; + private: + std::queue<T*> dirty; }; diff --git a/src/memory/freelist.hpp b/src/memory/freelist.hpp index d425282dd..5dbf2add9 100644 --- a/src/memory/freelist.hpp +++ b/src/memory/freelist.hpp @@ -6,22 +6,17 @@ #include "threading/sync/spinlock.hpp" template <class T, class lock_t = SpinLock> -class FreeList : Lockable<lock_t> -{ -public: - void swap(std::vector<T *> &dst) { std::swap(data, dst); } +class FreeList : Lockable<lock_t> { + public: + void swap(std::vector<T *> &dst) { std::swap(data, dst); } - void add(T *element) - { - auto lock = this->acquire_unique(); - data.emplace_back(element); - } + void add(T *element) { + auto lock = this->acquire_unique(); + data.emplace_back(element); + } - size_t size() const - { - return data.size(); - } + size_t size() const { return data.size(); } -private: - std::vector<T *> data; + private: + std::vector<T *> data; }; diff --git a/src/memory/hp.hpp b/src/memory/hp.hpp index f9c101e51..c3adc1023 100644 --- a/src/memory/hp.hpp +++ b/src/memory/hp.hpp @@ -1,148 +1,123 @@ #pragma once +#include <unistd.h> #include <atomic> #include <cassert> -#include <unistd.h> #include <iostream> -namespace memory -{ +namespace memory { constexpr const size_t HP_SIZE = 128; -class HP -{ -public: - // this object can't be copied or moved - HP(HP&) = delete; - HP(HP&&) = delete; +class HP { + public: + // this object can't be copied or moved + HP(HP&) = delete; + HP(HP&&) = delete; - // grabs a singleton instance - static HP& get() - { - static HP hp; - return hp; + // grabs a singleton instance + static HP& get() { + static HP hp; + return hp; + } + + class reference { + friend class HP; + + public: + reference(reference&) = delete; + + // this type shouldn't be copyable to avoid calling its destructor + // multiple times, but should be movable + reference(reference&& other) { + this->idx = other.idx; + + // set the index to a negative number to indicate that this + // index has been moved and that you should not free its + // hazard pointer + other.idx = -1; + } + // hazard pointer is cleared once reference goes out of scope + ~reference() { + // TODO: remove + // std::cout << "reference destructor called: "; + // std::cout << this->idx; + // std::cout << std::endl; + + // check if this reference was moved during its lifetime + if (idx < 0) return; + + auto& hp = HP::get(); + hp.clear(*this); } - class reference - { - friend class HP; - public: - reference(reference&) = delete; + reference& operator=(reference&& other) { return *this; } - // this type shouldn't be copyable to avoid calling its destructor - // multiple times, but should be movable - reference(reference&& other) - { - this->idx = other.idx; + private: + reference(int64_t idx) : idx(idx) {} + int64_t idx; + }; - // set the index to a negative number to indicate that this - // index has been moved and that you should not free its - // hazard pointer - other.idx = -1; - } - // hazard pointer is cleared once reference goes out of scope - ~reference() - { - // TODO: remove - // std::cout << "reference destructor called: "; - // std::cout << this->idx; - // std::cout << std::endl; + friend class reference; - // check if this reference was moved during its lifetime - if(idx < 0) - return; + template <class T> + reference insert(T* ptr) { + auto p = reinterpret_cast<uintptr_t>(ptr); - auto& hp = HP::get(); - hp.clear(*this); - } + while (true) { + // try to find a free spot in the hazard pointer list + for (size_t i = 0; i < HP_SIZE; ++i) { + auto hazard = ptr_list[i].load(); - reference& operator=(reference&& other) - { - return *this; - } + // if this spot isn't free, continue searching + if (hazard != 0) continue; - private: - reference(int64_t idx) : idx(idx) {} - int64_t idx; - }; + // try to take this spot, if we fail, then another thread has + // just taken it. continue searching for a new one + if (!ptr_list[i].compare_exchange_strong(hazard, p)) continue; - friend class reference; + // found a free spot! return a reference to this spot so it + // can be cleared later + return reference(i); + } - template <class T> - reference insert(T* ptr) - { - auto p = reinterpret_cast<uintptr_t>(ptr); + // we didn't find any free spots, sleep for a while and try again + // from the beginning, some other thread might have freed a spot + // while we were traversing the lsit. + usleep(250); + } + } - while(true) - { - // try to find a free spot in the hazard pointer list - for(size_t i = 0; i < HP_SIZE; ++i) - { - auto hazard = ptr_list[i].load(); + bool find(uintptr_t hptr) { + for (size_t i = 0; i < HP_SIZE; ++i) { + auto& hptr_i = ptr_list[i]; - // if this spot isn't free, continue searching - if(hazard != 0) - continue; + if (hptr_i != hptr) continue; - // try to take this spot, if we fail, then another thread has - // just taken it. continue searching for a new one - if(!ptr_list[i].compare_exchange_strong(hazard, p)) - continue; + if (hptr_i.load() == 1) return true; - // found a free spot! return a reference to this spot so it - // can be cleared later - return reference(i); - } - - // we didn't find any free spots, sleep for a while and try again - // from the beginning, some other thread might have freed a spot - // while we were traversing the lsit. - usleep(250); - } + if (hptr_i.load() == 0) return false; } - bool find(uintptr_t hptr) - { - for (size_t i = 0; i < HP_SIZE; ++i) { - auto& hptr_i = ptr_list[i]; + return false; + } - if (hptr_i != hptr) - continue; - - if (hptr_i.load() == 1) - return true; - - if (hptr_i.load() == 0) - return false; - } - - return false; + friend std::ostream& operator<<(std::ostream& os, const HP& hp) { + os << "Hazard pointers: "; + for (size_t i = 0; i < HP_SIZE; ++i) { + auto& hptr_i = hp.ptr_list[i]; + os << hptr_i.load() << " "; } + return os << std::endl; + } - friend std::ostream& operator<<(std::ostream& os, const HP& hp) - { - os << "Hazard pointers: "; - for (size_t i = 0; i < HP_SIZE; ++i) { - auto& hptr_i = hp.ptr_list[i]; - os << hptr_i.load() << " "; - } - return os << std::endl; - } + private: + HP() { + for (size_t i = 0; i < HP_SIZE; ++i) ptr_list[i].store(0); + } -private: - HP() - { - for(size_t i = 0; i < HP_SIZE; ++i) - ptr_list[i].store(0); - } + void clear(reference& ref) { ptr_list[ref.idx].store(0); } - void clear(reference& ref) - { - ptr_list[ref.idx].store(0); - } - - std::atomic<uintptr_t> ptr_list[HP_SIZE]; + std::atomic<uintptr_t> ptr_list[HP_SIZE]; }; - } diff --git a/src/memory/lazy_gc.hpp b/src/memory/lazy_gc.hpp index 6e14c34cc..8c239400b 100644 --- a/src/memory/lazy_gc.hpp +++ b/src/memory/lazy_gc.hpp @@ -8,19 +8,17 @@ #include "utils/crtp.hpp" template <class Derived, class lock_t = SpinLock> -class LazyGC : public Crtp<Derived>, public Lockable<lock_t> -{ -public: - // add_ref method should be called by a thread - // when the thread has to do something over - // object which has to be lazy cleaned when - // the thread finish it job - void add_ref() - { - auto lock = this->acquire_unique(); - ++count; - } +class LazyGC : public Crtp<Derived>, public Lockable<lock_t> { + public: + // add_ref method should be called by a thread + // when the thread has to do something over + // object which has to be lazy cleaned when + // the thread finish it job + void add_ref() { + auto lock = this->acquire_unique(); + ++count; + } -protected: - size_t count{0}; + protected: + size_t count{0}; }; diff --git a/src/memory/literals.hpp b/src/memory/literals.hpp index 3e65c746b..5d802ec6c 100644 --- a/src/memory/literals.hpp +++ b/src/memory/literals.hpp @@ -2,25 +2,19 @@ #include <cstdint> -namespace memory -{ -namespace literals -{ +namespace memory { +namespace literals { -constexpr unsigned long long operator"" _GB(unsigned long long gb) -{ - return 1024 * 1024 * 1024 * gb; +constexpr unsigned long long operator"" _GB(unsigned long long gb) { + return 1024 * 1024 * 1024 * gb; } -constexpr unsigned long long operator"" _MB(unsigned long long mb) -{ - return 1024 * 1024 * mb; -} - -constexpr unsigned long long operator"" _kB(unsigned long long kb) -{ - return 1024 * kb; +constexpr unsigned long long operator"" _MB(unsigned long long mb) { + return 1024 * 1024 * mb; } +constexpr unsigned long long operator"" _kB(unsigned long long kb) { + return 1024 * kb; +} } } diff --git a/src/memory/memory.hpp b/src/memory/memory.hpp index 2ba87c8f1..58d3a5934 100644 --- a/src/memory/memory.hpp +++ b/src/memory/memory.hpp @@ -3,53 +3,39 @@ #include <atomic> #include <mutex> +#include "storage/model/edge.hpp" #include "storage/model/record.hpp" #include "storage/model/vertex.hpp" -#include "storage/model/edge.hpp" // TODO implement the memory engine using the allocator style allocation to // make this class non-dependent on the memory allocation strategy // TODO implement real recycling of vertices and edges to improve performance -class MemoryEngine -{ -public: - - template <class T, - typename... Args> - T* create(Args&&... args) - { - return new T(std::forward<Args>(args)...); - } +class MemoryEngine { + public: + template <class T, typename... Args> + T* create(Args&&... args) { + return new T(std::forward<Args>(args)...); + } - template<class T> - T* allocate() - { - return static_cast<T*>(malloc(sizeof(T))); - } + template <class T> + T* allocate() { + return static_cast<T*>(malloc(sizeof(T))); + } - template <class T> - void recycle(Record<T>* record) - { - recycle(&record->derived()); - } + template <class T> + void recycle(Record<T>* record) { + recycle(&record->derived()); + } - void recycle(Vertex* v) - { - delete v; - } + void recycle(Vertex* v) { delete v; } - void recycle(Edge* e) - { - delete e; - } + void recycle(Edge* e) { delete e; } -private: - - std::unique_lock<SpinLock> acquire() - { - return std::unique_lock<SpinLock>(lock); - } + private: + std::unique_lock<SpinLock> acquire() { + return std::unique_lock<SpinLock>(lock); + } - SpinLock lock; + SpinLock lock; }; diff --git a/src/memory/recycler.hpp b/src/memory/recycler.hpp index 1d4c174b6..96c281e68 100644 --- a/src/memory/recycler.hpp +++ b/src/memory/recycler.hpp @@ -6,41 +6,36 @@ #include "threading/sync/lockable.hpp" #include "threading/sync/spinlock.hpp" -template <class T, class Allocator=std::allocator<T>> -class Recycler : public Lockable<SpinLock> -{ - static constexpr size_t default_max_reserved = 100; +template <class T, class Allocator = std::allocator<T>> +class Recycler : public Lockable<SpinLock> { + static constexpr size_t default_max_reserved = 100; -public: - Recycler() = default; - Recycler(size_t max_reserved) : max_reserved(max_reserved) {} + public: + Recycler() = default; + Recycler(size_t max_reserved) : max_reserved(max_reserved) {} - template <class... Args> - T* acquire(Args&&... args) - { - auto guard = acquire_unique(); - return fetch_or_create(std::forward<Args>(args)...); - } + template <class... Args> + T* acquire(Args&&... args) { + auto guard = acquire_unique(); + return fetch_or_create(std::forward<Args>(args)...); + } - void release(T* item) - { - auto guard = acquire_unique(); - return recycle_or_delete(item); - } + void release(T* item) { + auto guard = acquire_unique(); + return recycle_or_delete(item); + } -protected: - Allocator alloc; - size_t max_reserved {default_max_reserved}; - std::queue<T*> items; + protected: + Allocator alloc; + size_t max_reserved{default_max_reserved}; + std::queue<T*> items; - template <class... Args> - T* fetch_or_create(Args&&... args) - { - return new T(std::forward<Args>(args)...); // todo refactor :D - } + template <class... Args> + T* fetch_or_create(Args&&... args) { + return new T(std::forward<Args>(args)...); // todo refactor :D + } - void recycle_or_delete(T* item) - { - delete item; // todo refactor :D - } + void recycle_or_delete(T* item) { + delete item; // todo refactor :D + } }; diff --git a/src/mvcc/cre_exp.hpp b/src/mvcc/cre_exp.hpp index 7e9cbc1dc..c46916f93 100644 --- a/src/mvcc/cre_exp.hpp +++ b/src/mvcc/cre_exp.hpp @@ -2,38 +2,31 @@ #include <atomic> -namespace mvcc -{ +namespace mvcc { template <class T> -class CreExp -{ -public: - CreExp() = default; - CreExp(T cre, T exp) : cre_(cre), exp_(exp) {} +class CreExp { + public: + CreExp() = default; + CreExp(T cre, T exp) : cre_(cre), exp_(exp) {} - T cre(std::memory_order order = std::memory_order_seq_cst) const - { - return cre_.load(order); - } + T cre(std::memory_order order = std::memory_order_seq_cst) const { + return cre_.load(order); + } - void cre(T value, std::memory_order order = std::memory_order_seq_cst) - { - cre_.store(value, order); - } + void cre(T value, std::memory_order order = std::memory_order_seq_cst) { + cre_.store(value, order); + } - T exp(std::memory_order order = std::memory_order_seq_cst) const - { - return exp_.load(order); - } + T exp(std::memory_order order = std::memory_order_seq_cst) const { + return exp_.load(order); + } - void exp(T value, std::memory_order order = std::memory_order_seq_cst) - { - exp_.store(value, order); - } + void exp(T value, std::memory_order order = std::memory_order_seq_cst) { + exp_.store(value, order); + } -private: - std::atomic<T> cre_ {0}, exp_ {0}; + private: + std::atomic<T> cre_{0}, exp_{0}; }; - } diff --git a/src/mvcc/hints.hpp b/src/mvcc/hints.hpp index e95a4ecb2..e13335361 100644 --- a/src/mvcc/hints.hpp +++ b/src/mvcc/hints.hpp @@ -1,102 +1,87 @@ #pragma once -#include <atomic> #include <unistd.h> +#include <atomic> #include "transactions/commit_log.hpp" -namespace mvcc -{ +namespace mvcc { // known committed and known aborted for both cre and exp // this hints are used to quickly check the commit/abort status of the // transaction that created this record. if these are not set, one should // consult the commit log to find the status and update the status here // more info https://wiki.postgresql.org/wiki/Hint_Bits -class Hints -{ -public: - union HintBits; +class Hints { + public: + union HintBits; -private: - enum Flags : uint8_t - { - CRE_CMT = 0x01, // __01 - CRE_ABT = 0x02, // __10 - EXP_CMT = 0x04, // 01__ - EXP_ABT = 0x08 // 10__ + private: + enum Flags : uint8_t { + CRE_CMT = 0x01, // __01 + CRE_ABT = 0x02, // __10 + EXP_CMT = 0x04, // 01__ + EXP_ABT = 0x08 // 10__ + }; + + template <Flags COMMITTED, Flags ABORTED> + class TxHints { + using type = TxHints<COMMITTED, ABORTED>; + + public: + TxHints(std::atomic<uint8_t> &bits) : bits(bits) {} + + struct Value { + bool is_committed() const { return bits & COMMITTED; } + + bool is_aborted() const { return bits & ABORTED; } + + bool is_unknown() const { return !(is_committed() || is_aborted()); } + + uint8_t bits; }; - template <Flags COMMITTED, Flags ABORTED> - class TxHints - { - using type = TxHints<COMMITTED, ABORTED>; - - public: - TxHints(std::atomic<uint8_t> &bits) : bits(bits) {} - - struct Value - { - bool is_committed() const { return bits & COMMITTED; } - - bool is_aborted() const { return bits & ABORTED; } - - bool is_unknown() const - { - return !(is_committed() || is_aborted()); - } - - uint8_t bits; - }; - - Value load(std::memory_order order = std::memory_order_seq_cst) - { - return Value{bits.load(order)}; - } - - void set_committed(std::memory_order order = std::memory_order_seq_cst) - { - bits.fetch_or(COMMITTED, order); - } - - void set_aborted(std::memory_order order = std::memory_order_seq_cst) - { - bits.fetch_or(ABORTED, order); - } - - private: - std::atomic<uint8_t> &bits; - }; - - struct Cre : public TxHints<CRE_CMT, CRE_ABT> - { - using TxHints::TxHints; - }; - - struct Exp : public TxHints<EXP_CMT, EXP_ABT> - { - using TxHints::TxHints; - }; - -public: - Hints() : cre(bits), exp(bits) { assert(bits.is_lock_free()); } - - union HintBits - { - uint8_t bits; - - Cre::Value cre; - Exp::Value exp; - }; - - HintBits load(std::memory_order order = std::memory_order_seq_cst) - { - return HintBits{bits.load(order)}; + Value load(std::memory_order order = std::memory_order_seq_cst) { + return Value{bits.load(order)}; } - Cre cre; - Exp exp; + void set_committed(std::memory_order order = std::memory_order_seq_cst) { + bits.fetch_or(COMMITTED, order); + } - std::atomic<uint8_t> bits{0}; + void set_aborted(std::memory_order order = std::memory_order_seq_cst) { + bits.fetch_or(ABORTED, order); + } + + private: + std::atomic<uint8_t> &bits; + }; + + struct Cre : public TxHints<CRE_CMT, CRE_ABT> { + using TxHints::TxHints; + }; + + struct Exp : public TxHints<EXP_CMT, EXP_ABT> { + using TxHints::TxHints; + }; + + public: + Hints() : cre(bits), exp(bits) { assert(bits.is_lock_free()); } + + union HintBits { + uint8_t bits; + + Cre::Value cre; + Exp::Value exp; + }; + + HintBits load(std::memory_order order = std::memory_order_seq_cst) { + return HintBits{bits.load(order)}; + } + + Cre cre; + Exp exp; + + std::atomic<uint8_t> bits{0}; }; } diff --git a/src/mvcc/id.cpp b/src/mvcc/id.cpp index 1049d97e3..9f32d5186 100644 --- a/src/mvcc/id.cpp +++ b/src/mvcc/id.cpp @@ -2,22 +2,12 @@ Id::Id(uint64_t id) : id(id) {} -bool operator<(const Id& a, const Id& b) -{ - return a.id < b.id; +bool operator<(const Id& a, const Id& b) { return a.id < b.id; } + +bool operator==(const Id& a, const Id& b) { return a.id == b.id; } + +std::ostream& operator<<(std::ostream& stream, const Id& id) { + return stream << id.id; } -bool operator==(const Id& a, const Id& b) -{ - return a.id == b.id; -} - -std::ostream& operator<<(std::ostream& stream, const Id& id) -{ - return stream << id.id; -} - -Id::operator uint64_t() const -{ - return id; -} +Id::operator uint64_t() const { return id; } diff --git a/src/mvcc/id.hpp b/src/mvcc/id.hpp index be530bcad..4d58d8230 100644 --- a/src/mvcc/id.hpp +++ b/src/mvcc/id.hpp @@ -1,25 +1,24 @@ #pragma once -#include <ostream> #include <stdint.h> +#include <ostream> #include "utils/total_ordering.hpp" -class Id : public TotalOrdering<Id> -{ -public: - Id() = default; +class Id : public TotalOrdering<Id> { + public: + Id() = default; - Id(uint64_t id); + Id(uint64_t id); - friend bool operator<(const Id& a, const Id& b); + friend bool operator<(const Id& a, const Id& b); - friend bool operator==(const Id& a, const Id& b); + friend bool operator==(const Id& a, const Id& b); - friend std::ostream& operator<<(std::ostream& stream, const Id& id); + friend std::ostream& operator<<(std::ostream& stream, const Id& id); - operator uint64_t() const; + operator uint64_t() const; -private: - uint64_t id {0}; + private: + uint64_t id{0}; }; diff --git a/src/mvcc/mvcc_error.hpp b/src/mvcc/mvcc_error.hpp index 58e433219..08be4cb52 100644 --- a/src/mvcc/mvcc_error.hpp +++ b/src/mvcc/mvcc_error.hpp @@ -2,13 +2,10 @@ #include <stdexcept> -namespace mvcc -{ +namespace mvcc { -class MvccError : public std::runtime_error -{ -public: - using runtime_error::runtime_error; +class MvccError : public std::runtime_error { + public: + using runtime_error::runtime_error; }; - } diff --git a/src/mvcc/record.hpp b/src/mvcc/record.hpp index 2d6bd440f..6f7911662 100644 --- a/src/mvcc/record.hpp +++ b/src/mvcc/record.hpp @@ -16,14 +16,11 @@ // the mvcc implementation used here is very much like postgresql's // more info: https://momjian.us/main/writings/pgsql/mvcc.pdf -namespace mvcc -{ +namespace mvcc { template <class T> -class Record : public Version<T> -{ -public: - +class Record : public Version<T> { + public: Record() = default; // The copy constructor ignores tx, cmd, hints and super because @@ -35,130 +32,120 @@ public: // like it was in Dominik's implementation Record(const Record &other) {} - // tx.cre is the id of the transaction that created the record - // and tx.exp is the id of the transaction that deleted the record - // these values are used to determine the visibility of the record - // to the current transaction - CreExp<Id> tx; + // tx.cre is the id of the transaction that created the record + // and tx.exp is the id of the transaction that deleted the record + // these values are used to determine the visibility of the record + // to the current transaction + CreExp<Id> tx; - // cmd.cre is the id of the command in this transaction that created the - // record and cmd.exp is the id of the command in this transaction that - // deleted the record. these values are used to determine the visibility - // of the record to the current command in the running transaction - CreExp<uint8_t> cmd; + // cmd.cre is the id of the command in this transaction that created the + // record and cmd.exp is the id of the command in this transaction that + // deleted the record. these values are used to determine the visibility + // of the record to the current command in the running transaction + CreExp<uint8_t> cmd; - Hints hints; + Hints hints; - // NOTE: Wasn't used. - // this lock is used by write queries when they update or delete records - // RecordLock lock; + // NOTE: Wasn't used. + // this lock is used by write queries when they update or delete records + // RecordLock lock; - // check if this record is visible to the transaction t - bool visible(const tx::TransactionRead &t) - { - // TODO check if the record was created by a transaction that has been - // aborted. one might implement this by checking the hints in mvcc - // anc/or consulting the commit log + // check if this record is visible to the transaction t + bool visible(const tx::TransactionRead &t) { + // TODO check if the record was created by a transaction that has been + // aborted. one might implement this by checking the hints in mvcc + // anc/or consulting the commit log - // Mike Olson says 17 march 1993: the tests in this routine are correct; - // if you think they're not, you're wrong, and you should think about it - // again. i know, it happened to me. + // Mike Olson says 17 march 1993: the tests in this routine are correct; + // if you think they're not, you're wrong, and you should think about it + // again. i know, it happened to me. - return ((tx.cre() == t.id && // inserted by the current transaction - cmd.cre() <= t.cid && // before this command, and - (tx.exp() == Id(0) || // the row has not been deleted, or - (tx.exp() == t.id && // it was deleted by the current - // transaction - cmd.exp() >= t.cid))) // but not before this command, - || // or - (cre_committed(tx.cre(), t) && // the record was inserted by a - // committed transaction, and - (tx.exp() == Id(0) || // the record has not been deleted, or - (tx.exp() == t.id && // the row is being deleted by this - // transaction - cmd.exp() >= t.cid) || // but it's not deleted "yet", or - (tx.exp() != t.id && // the row was deleted by another - // transaction - !exp_committed(tx.exp(), t) // that has not been committed - )))); - } + return ((tx.cre() == t.id && // inserted by the current transaction + cmd.cre() <= t.cid && // before this command, and + (tx.exp() == Id(0) || // the row has not been deleted, or + (tx.exp() == t.id && // it was deleted by the current + // transaction + cmd.exp() >= t.cid))) // but not before this command, + || // or + (cre_committed(tx.cre(), t) && // the record was inserted by a + // committed transaction, and + (tx.exp() == Id(0) || // the record has not been deleted, or + (tx.exp() == t.id && // the row is being deleted by this + // transaction + cmd.exp() >= t.cid) || // but it's not deleted "yet", or + (tx.exp() != t.id && // the row was deleted by another + // transaction + !exp_committed(tx.exp(), t) // that has not been committed + )))); + } - void mark_created(const tx::TransactionRead &t) - { - tx.cre(t.id); - cmd.cre(t.cid); - } + void mark_created(const tx::TransactionRead &t) { + tx.cre(t.id); + cmd.cre(t.cid); + } - void mark_deleted(const tx::TransactionRead &t) - { - tx.exp(t.id); - cmd.exp(t.cid); - } + void mark_deleted(const tx::TransactionRead &t) { + tx.exp(t.id); + cmd.exp(t.cid); + } - bool exp_committed(const Id &id, const tx::TransactionRead &t) - { - return committed(hints.exp, id, t); - } + bool exp_committed(const Id &id, const tx::TransactionRead &t) { + return committed(hints.exp, id, t); + } - bool exp_committed(const tx::TransactionRead &t) - { - return committed(hints.exp, tx.exp(), t); - } + bool exp_committed(const tx::TransactionRead &t) { + return committed(hints.exp, tx.exp(), t); + } - bool cre_committed(const Id &id, const tx::TransactionRead &t) - { - return committed(hints.cre, id, t); - } + bool cre_committed(const Id &id, const tx::TransactionRead &t) { + return committed(hints.cre, id, t); + } - bool cre_committed(const tx::TransactionRead &t) - { - return committed(hints.cre, tx.cre(), t); - } + bool cre_committed(const tx::TransactionRead &t) { + return committed(hints.cre, tx.cre(), t); + } - // True if record was deleted before id. - bool is_deleted_before(const Id &id) - { - return tx.exp() != Id(0) && tx.exp() < id; - } + // True if record was deleted before id. + bool is_deleted_before(const Id &id) { + return tx.exp() != Id(0) && tx.exp() < id; + } - // TODO: Test this - // True if this record is visible for write. - bool is_visible_write(const tx::TransactionRead &t) - { - return (tx.cre() == t.id && // inserted by the current transaction - cmd.cre() <= t.cid && // before this command, and - (tx.exp() == Id(0) || // the row has not been deleted, or - (tx.exp() == t.id && // it was deleted by the current - // transaction - cmd.exp() >= t.cid))); // but not before this command, - } + // TODO: Test this + // True if this record is visible for write. + bool is_visible_write(const tx::TransactionRead &t) { + return (tx.cre() == t.id && // inserted by the current transaction + cmd.cre() <= t.cid && // before this command, and + (tx.exp() == Id(0) || // the row has not been deleted, or + (tx.exp() == t.id && // it was deleted by the current + // transaction + cmd.exp() >= t.cid))); // but not before this command, + } -protected: - template <class U> - bool committed(U &hints, const Id &id, const tx::TransactionRead &t) - { - // you certainly can't see the transaction with id greater than yours - // as that means it started after this transaction and if it committed, - // it committed after this transaction had started. - if (id > t.id) return false; + protected: + template <class U> + bool committed(U &hints, const Id &id, const tx::TransactionRead &t) { + // you certainly can't see the transaction with id greater than yours + // as that means it started after this transaction and if it committed, + // it committed after this transaction had started. + if (id > t.id) return false; - // The creating transaction is still in progress (examine snapshot) - if (t.in_snapshot(id)) return false; + // The creating transaction is still in progress (examine snapshot) + if (t.in_snapshot(id)) return false; - auto hint_bits = hints.load(); + auto hint_bits = hints.load(); - // TODO: Validate if this position is valid for next if. - // if hints are set, return if xid is committed - if (!hint_bits.is_unknown()) return hint_bits.is_committed(); + // TODO: Validate if this position is valid for next if. + // if hints are set, return if xid is committed + if (!hint_bits.is_unknown()) return hint_bits.is_committed(); - // if hints are not set: - // - you are the first one to check since it ended, consult commit log - auto info = t.engine.clog.fetch_info(id); + // if hints are not set: + // - you are the first one to check since it ended, consult commit log + auto info = t.engine.clog.fetch_info(id); - if (info.is_committed()) return hints.set_committed(), true; + if (info.is_committed()) return hints.set_committed(), true; - assert(info.is_aborted()); - return hints.set_aborted(), false; - } + assert(info.is_aborted()); + return hints.set_aborted(), false; + } }; } diff --git a/src/mvcc/serialization_error.hpp b/src/mvcc/serialization_error.hpp index dc14a81ef..aa9cf26e4 100644 --- a/src/mvcc/serialization_error.hpp +++ b/src/mvcc/serialization_error.hpp @@ -2,14 +2,13 @@ #include <stdexcept> -class SerializationError : public std::runtime_error -{ - static constexpr const char* default_message = "Can't serialize due to\ +class SerializationError : public std::runtime_error { + static constexpr const char* default_message = + "Can't serialize due to\ concurrent operation(s)"; -public: - SerializationError() : runtime_error(default_message) {} + public: + SerializationError() : runtime_error(default_message) {} - SerializationError(const std::string& message) - : runtime_error(message) {} + SerializationError(const std::string& message) : runtime_error(message) {} }; diff --git a/src/mvcc/version.hpp b/src/mvcc/version.hpp index 9039a2ffb..28ce5b9cf 100644 --- a/src/mvcc/version.hpp +++ b/src/mvcc/version.hpp @@ -2,43 +2,37 @@ #include <atomic> -namespace mvcc -{ +namespace mvcc { template <class T> -class Version -{ -public: - Version() = default; - Version(T *older) : older(older) {} +class Version { + public: + Version() = default; + Version(T *older) : older(older) {} - ~Version() { delete older.load(std::memory_order_seq_cst); } + ~Version() { delete older.load(std::memory_order_seq_cst); } - // return a pointer to an older version stored in this record - T *next(std::memory_order order = std::memory_order_seq_cst) - { - return older.load(order); - } + // return a pointer to an older version stored in this record + T *next(std::memory_order order = std::memory_order_seq_cst) { + return older.load(order); + } - const T *next(std::memory_order order = std::memory_order_seq_cst) const - { - return older.load(order); - } + const T *next(std::memory_order order = std::memory_order_seq_cst) const { + return older.load(order); + } - // set the older version of this record - void next(T *value, std::memory_order order = std::memory_order_seq_cst) - { - older.store(value, order); - } + // set the older version of this record + void next(T *value, std::memory_order order = std::memory_order_seq_cst) { + older.store(value, order); + } - // sets if as expected - bool cas(T *expected, T *set, - std::memory_order order = std::memory_order_seq_cst) - { - return older.compare_exchange_strong(expected, set, order); - } + // sets if as expected + bool cas(T *expected, T *set, + std::memory_order order = std::memory_order_seq_cst) { + return older.compare_exchange_strong(expected, set, order); + } -private: - std::atomic<T *> older{nullptr}; + private: + std::atomic<T *> older{nullptr}; }; } diff --git a/src/mvcc/version_list.hpp b/src/mvcc/version_list.hpp index bba92333c..1be2ec867 100644 --- a/src/mvcc/version_list.hpp +++ b/src/mvcc/version_list.hpp @@ -9,197 +9,197 @@ namespace mvcc { - template<class T> - class VersionList { - // TODO what is this Accessor? Dead code? - friend class Accessor; +template <class T> +class VersionList { + // TODO what is this Accessor? Dead code? + friend class Accessor; - public: - using uptr = std::unique_ptr<VersionList<T>>; - using item_t = T; + public: + using uptr = std::unique_ptr<VersionList<T>>; + using item_t = T; - VersionList() = default; + VersionList() = default; - VersionList(const VersionList &) = delete; + VersionList(const VersionList &) = delete; - /* @brief Move constructs the version list - * Note: use only at the beginning of the "other's" lifecycle since this - * constructor doesn't move the RecordLock, but only the head pointer - */ - VersionList(VersionList &&other) { - this->head = other.head.load(); - other.head = nullptr; + /* @brief Move constructs the version list + * Note: use only at the beginning of the "other's" lifecycle since this + * constructor doesn't move the RecordLock, but only the head pointer + */ + VersionList(VersionList &&other) { + this->head = other.head.load(); + other.head = nullptr; + } + + ~VersionList() { delete head.load(); } + + friend std::ostream &operator<<(std::ostream &stream, + const VersionList<T> &vlist) { + stream << "VersionList" << std::endl; + + auto record = vlist.head.load(); + + while (record != nullptr) { + stream << "-- " << *record << std::endl; + record = record->next(); } - ~VersionList() { delete head.load(); } + return stream; + } - friend std::ostream &operator<<(std::ostream &stream, - const VersionList<T> &vlist) { - stream << "VersionList" << std::endl; + auto gc_lock_acquire() { return std::unique_lock<RecordLock>(lock); } - auto record = vlist.head.load(); + // Frees all records which are deleted by transaction older than given id. + // EXPECTS THAT THERE IS NO ACTIVE TRANSACTION WITH ID LESS THAN GIVEN ID. + // EXPECTS THAT THERE WON'T BE SIMULATAIUS CALLS FROM DIFFERENT THREADS OF + // THIS METHOD. + // True if this whole version list isn't needed any more. There is still + // possibilty that someone is reading it at this moment but he cant change + // it or get anything from it. + // TODO: Validate this method + bool gc_deleted(const Id &id) { + auto r = head.load(std::memory_order_seq_cst); + T *bef = nullptr; - while (record != nullptr) { - stream << "-- " << *record << std::endl; - record = record->next(); + // nullptr + // | + // [v1] ... + // | + // [v2] <------+ + // | | + // [v3] <------+ + // | | Jump backwards until you find a first old deleted + // [VerList] ----+ version, or you reach the end of the list + // + while (r != nullptr && !r->is_deleted_before(id)) { + bef = r; + r = r->next(std::memory_order_seq_cst); + } + + if (bef == nullptr) { + // if r==nullptr he is needed and it is expecting insert. + // if r!=nullptr vertex has been explicitly deleted. It can't be + // updated because for update, visible record is needed and at this + // point whe know that there is no visible record for any + // transaction. Also it cant be inserted because head isn't nullptr. + // Remove also requires visible record. Find wont return any record + // because none is visible. + return r != nullptr; + } else { + if (r != nullptr) { + // Bef is possible visible to some transaction but r is not and + // the implementation of this version list guarantees that + // record r and older records aren't accessed. + bef->next(nullptr, std::memory_order_seq_cst); + delete r; // THIS IS ISSUE IF MULTIPLE THREADS TRY TO DO THIS } - return stream; + return false; } + } - auto gc_lock_acquire() { return std::unique_lock<RecordLock>(lock); } + void vacuum() {} - // Frees all records which are deleted by transaction older than given id. - // EXPECTS THAT THERE IS NO ACTIVE TRANSACTION WITH ID LESS THAN GIVEN ID. - // EXPECTS THAT THERE WON'T BE SIMULATAIUS CALLS FROM DIFFERENT THREADS OF - // THIS METHOD. - // True if this whole version list isn't needed any more. There is still - // possibilty that someone is reading it at this moment but he cant change - // it or get anything from it. - // TODO: Validate this method - bool gc_deleted(const Id &id) { - auto r = head.load(std::memory_order_seq_cst); - T *bef = nullptr; + T *find(const tx::TransactionRead &t) const { + auto r = head.load(std::memory_order_seq_cst); - // nullptr - // | - // [v1] ... - // | - // [v2] <------+ - // | | - // [v3] <------+ - // | | Jump backwards until you find a first old deleted - // [VerList] ----+ version, or you reach the end of the list - // - while (r != nullptr && !r->is_deleted_before(id)) { - bef = r; - r = r->next(std::memory_order_seq_cst); - } + // nullptr + // | + // [v1] ... + // | + // [v2] <------+ + // | | + // [v3] <------+ + // | | Jump backwards until you find a first visible + // [VerList] ----+ version, or you reach the end of the list + // + while (r != nullptr && !r->visible(t)) + r = r->next(std::memory_order_seq_cst); - if (bef == nullptr) { - // if r==nullptr he is needed and it is expecting insert. - // if r!=nullptr vertex has been explicitly deleted. It can't be - // updated because for update, visible record is needed and at this - // point whe know that there is no visible record for any - // transaction. Also it cant be inserted because head isn't nullptr. - // Remove also requires visible record. Find wont return any record - // because none is visible. - return r != nullptr; - } else { - if (r != nullptr) { - // Bef is possible visible to some transaction but r is not and - // the implementation of this version list guarantees that - // record r and older records aren't accessed. - bef->next(nullptr, std::memory_order_seq_cst); - delete r; // THIS IS ISSUE IF MULTIPLE THREADS TRY TO DO THIS - } + return r; + } - return false; - } - } + /** + * @Args forwarded to the constructor of T + */ + template <typename... Args> + T *insert(tx::Transaction &t, Args &&... args) { + assert(head == nullptr); - void vacuum() {} + // create a first version of the record + // TODO replace 'new' with something better + auto v1 = new T(std::forward<Args>(args)...); - T *find(const tx::TransactionRead &t) const { - auto r = head.load(std::memory_order_seq_cst); + // mark the record as created by the transaction t + v1->mark_created(t); - // nullptr - // | - // [v1] ... - // | - // [v2] <------+ - // | | - // [v3] <------+ - // | | Jump backwards until you find a first visible - // [VerList] ----+ version, or you reach the end of the list - // - while (r != nullptr && !r->visible(t)) - r = r->next(std::memory_order_seq_cst); + head.store(v1, std::memory_order_seq_cst); - return r; - } + return v1; + } - /** - * @Args forwarded to the constructor of T - */ - template <typename... Args> - T *insert(tx::Transaction &t, Args&&... args) { - assert(head == nullptr); + T *update(tx::Transaction &t) { + assert(head != nullptr); + auto record = find(t); - // create a first version of the record - // TODO replace 'new' with something better - auto v1 = new T(std::forward<Args>(args)...); + // check if we found any visible records + if (!record) return nullptr; - // mark the record as created by the transaction t - v1->mark_created(t); + return update(record, t); + } - head.store(v1, std::memory_order_seq_cst); + T *update(T *record, tx::Transaction &t) { + assert(record != nullptr); + lock_and_validate(record, t); - return v1; - } + // It could be done with unique_ptr but while this could mean memory + // leak on exception, unique_ptr could mean use after free. Memory + // leak is less dangerous. + auto updated = new T(*record); - T *update(tx::Transaction &t) { - assert(head != nullptr); - auto record = find(t); + updated->mark_created(t); + record->mark_deleted(t); - // check if we found any visible records - if (!record) return nullptr; + updated->next(record, std::memory_order_seq_cst); + head.store(updated, std::memory_order_seq_cst); - return update(record, t); - } + return updated; + } - T *update(T *record, tx::Transaction &t) { - assert(record != nullptr); - lock_and_validate(record, t); + bool remove(tx::Transaction &t) { + assert(head != nullptr); + auto record = find(t); - // It could be done with unique_ptr but while this could mean memory - // leak on exception, unique_ptr could mean use after free. Memory - // leak is less dangerous. - auto updated = new T(*record); + if (!record) return false; - updated->mark_created(t); - record->mark_deleted(t); + // TODO: Is this lock and validate necessary + lock_and_validate(record, t); + return remove(record, t), true; + } - updated->next(record, std::memory_order_seq_cst); - head.store(updated, std::memory_order_seq_cst); + void remove(T *record, tx::Transaction &t) { + assert(record != nullptr); + lock_and_validate(record, t); + record->mark_deleted(t); + } - return updated; - } + private: + void lock_and_validate(T *record, tx::Transaction &t) { + assert(record != nullptr); - bool remove(tx::Transaction &t) { - assert(head != nullptr); - auto record = find(t); + // take a lock on this node + t.take_lock(lock); - if (!record) return false; + // if the record hasn't been deleted yet or the deleting transaction + // has aborted, it's ok to modify it + if (!record->tx.exp() || !record->exp_committed(t)) return; - // TODO: Is this lock and validate necessary - lock_and_validate(record, t); - return remove(record, t), true; - } + // if it committed, then we have a serialization conflict + assert(record->hints.load().exp.is_committed()); + throw SerializationError(); + } - void remove(T *record, tx::Transaction &t) { - assert(record != nullptr); - lock_and_validate(record, t); - record->mark_deleted(t); - } - - private: - void lock_and_validate(T *record, tx::Transaction &t) { - assert(record != nullptr); - - // take a lock on this node - t.take_lock(lock); - - // if the record hasn't been deleted yet or the deleting transaction - // has aborted, it's ok to modify it - if (!record->tx.exp() || !record->exp_committed(t)) return; - - // if it committed, then we have a serialization conflict - assert(record->hints.load().exp.is_committed()); - throw SerializationError(); - } - - std::atomic<T *> head{nullptr}; - RecordLock lock; - }; + std::atomic<T *> head{nullptr}; + RecordLock lock; +}; } diff --git a/src/query/backend/cpp/generator.hpp b/src/query/backend/cpp/generator.hpp index 18557fb3f..9cc80f878 100644 --- a/src/query/backend/cpp/generator.hpp +++ b/src/query/backend/cpp/generator.hpp @@ -14,11 +14,11 @@ class Generator { public: /** * Generates cpp code inside file on the path. - * + * * @tparam Ast type of AST structure */ template <typename Ast> - void generate_plan(const Ast &ast, const std::string &query, + void generate_plan(const Ast &ast, const std::string &query, const uint64_t stripped_hash, const fs::path &path) { throw std::runtime_error("TODO: implementation"); } diff --git a/src/query/engine.hpp b/src/query/engine.hpp index 59c300d4f..d2c4b704d 100644 --- a/src/query/engine.hpp +++ b/src/query/engine.hpp @@ -7,12 +7,12 @@ namespace fs = std::experimental::filesystem; #include "data_structures/concurrent/concurrent_map.hpp" #include "database/graph_db.hpp" #include "logging/loggable.hpp" +#include "query/backend/cpp/generator.hpp" #include "query/exception/query_engine.hpp" #include "query/frontend/opencypher/parser.hpp" -#include "query/backend/cpp/generator.hpp" #include "query/plan_compiler.hpp" -#include "query/plan_interface.hpp" #include "query/plan_generator.hpp" +#include "query/plan_interface.hpp" #include "query/preprocessor.hpp" #include "utils/dynamic_lib.hpp" @@ -193,6 +193,7 @@ class QueryEngine : public Loggable { QueryPreprocessor preprocessor; PlanCompiler plan_compiler; - PlanGenerator<frontend::opencypher::Parser, backend::cpp::Generator> plan_generator; + PlanGenerator<frontend::opencypher::Parser, backend::cpp::Generator> + plan_generator; ConcurrentMap<HashType, std::unique_ptr<QueryPlanLib>> query_plans; }; diff --git a/src/query/exception/cpp_code_generator.hpp b/src/query/exception/cpp_code_generator.hpp index 7f61c8628..638060c7e 100644 --- a/src/query/exception/cpp_code_generator.hpp +++ b/src/query/exception/cpp_code_generator.hpp @@ -2,8 +2,7 @@ #include "utils/exceptions/basic_exception.hpp" -class CppCodeGeneratorException : public BasicException -{ -public: - using BasicException::BasicException; +class CppCodeGeneratorException : public BasicException { + public: + using BasicException::BasicException; }; diff --git a/src/query/exception/decoder_exception.hpp b/src/query/exception/decoder_exception.hpp index 86458f2ef..28c940c4c 100644 --- a/src/query/exception/decoder_exception.hpp +++ b/src/query/exception/decoder_exception.hpp @@ -2,8 +2,7 @@ #include "utils/exceptions/basic_exception.hpp" -class DecoderException : public BasicException -{ -public: - using BasicException::BasicException; +class DecoderException : public BasicException { + public: + using BasicException::BasicException; }; diff --git a/src/query/exception/plan_compilation.hpp b/src/query/exception/plan_compilation.hpp index e722a21e5..9b1cf8a56 100644 --- a/src/query/exception/plan_compilation.hpp +++ b/src/query/exception/plan_compilation.hpp @@ -2,8 +2,7 @@ #include "utils/exceptions/basic_exception.hpp" -class PlanCompilationException : public BasicException -{ -public: - using BasicException::BasicException; +class PlanCompilationException : public BasicException { + public: + using BasicException::BasicException; }; diff --git a/src/query/exception/plan_execution.hpp b/src/query/exception/plan_execution.hpp index 58b9f7531..1cd9f467b 100644 --- a/src/query/exception/plan_execution.hpp +++ b/src/query/exception/plan_execution.hpp @@ -2,8 +2,7 @@ #include "utils/exceptions/basic_exception.hpp" -class PlanExecutionException : public BasicException -{ -public: - using BasicException::BasicException; +class PlanExecutionException : public BasicException { + public: + using BasicException::BasicException; }; diff --git a/src/query/exception/query_engine.hpp b/src/query/exception/query_engine.hpp index 150051fc3..f3a7bbf36 100644 --- a/src/query/exception/query_engine.hpp +++ b/src/query/exception/query_engine.hpp @@ -2,8 +2,7 @@ #include "utils/exceptions/basic_exception.hpp" -class QueryEngineException : public BasicException -{ -public: - using BasicException::BasicException; +class QueryEngineException : public BasicException { + public: + using BasicException::BasicException; }; diff --git a/src/query/frontend/opencypher/generated/CypherBaseListener.cpp b/src/query/frontend/opencypher/generated/CypherBaseListener.cpp index 69698edef..884d3d3b6 100644 --- a/src/query/frontend/opencypher/generated/CypherBaseListener.cpp +++ b/src/query/frontend/opencypher/generated/CypherBaseListener.cpp @@ -1,9 +1,8 @@ -// Generated from /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 by ANTLR 4.6 - +// Generated from +// /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 +// by ANTLR 4.6 #include "CypherBaseListener.h" - using namespace antlrcpptest; - diff --git a/src/query/frontend/opencypher/generated/CypherBaseVisitor.cpp b/src/query/frontend/opencypher/generated/CypherBaseVisitor.cpp index f0de270b2..cd90d7fd3 100644 --- a/src/query/frontend/opencypher/generated/CypherBaseVisitor.cpp +++ b/src/query/frontend/opencypher/generated/CypherBaseVisitor.cpp @@ -1,9 +1,8 @@ -// Generated from /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 by ANTLR 4.6 - +// Generated from +// /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 +// by ANTLR 4.6 #include "CypherBaseVisitor.h" - using namespace antlrcpptest; - diff --git a/src/query/frontend/opencypher/generated/CypherLexer.cpp b/src/query/frontend/opencypher/generated/CypherLexer.cpp index bc38e7c41..49a5b90fc 100644 --- a/src/query/frontend/opencypher/generated/CypherLexer.cpp +++ b/src/query/frontend/opencypher/generated/CypherLexer.cpp @@ -1,25 +1,22 @@ -// Generated from /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 by ANTLR 4.6 - +// Generated from +// /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 +// by ANTLR 4.6 #include "CypherLexer.h" - using namespace antlr4; using namespace antlrcpptest; -CypherLexer::CypherLexer(CharStream *input) : Lexer(input) { - _interpreter = new atn::LexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache); +CypherLexer::CypherLexer(CharStream* input) : Lexer(input) { + _interpreter = new atn::LexerATNSimulator(this, _atn, _decisionToDFA, + _sharedContextCache); } -CypherLexer::~CypherLexer() { - delete _interpreter; -} +CypherLexer::~CypherLexer() { delete _interpreter; } -std::string CypherLexer::getGrammarFileName() const { - return "Cypher.g4"; -} +std::string CypherLexer::getGrammarFileName() const { return "Cypher.g4"; } const std::vector<std::string>& CypherLexer::getRuleNames() const { return _ruleNames; @@ -33,20 +30,13 @@ const std::vector<std::string>& CypherLexer::getTokenNames() const { return _tokenNames; } -dfa::Vocabulary& CypherLexer::getVocabulary() const { - return _vocabulary; -} +dfa::Vocabulary& CypherLexer::getVocabulary() const { return _vocabulary; } const std::vector<uint16_t> CypherLexer::getSerializedATN() const { return _serializedATN; } -const atn::ATN& CypherLexer::getATN() const { - return _atn; -} - - - +const atn::ATN& CypherLexer::getATN() const { return _atn; } // Static vars and initialization. std::vector<dfa::DFA> CypherLexer::_decisionToDFA; @@ -56,869 +46,1331 @@ atn::PredictionContextCache CypherLexer::_sharedContextCache; atn::ATN CypherLexer::_atn; std::vector<uint16_t> CypherLexer::_serializedATN; -std::vector<std::string> CypherLexer::_ruleNames = { - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", - "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", - "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", - "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", - "T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48", - "StringLiteral", "EscapedChar", "HexInteger", "DecimalInteger", "OctalInteger", - "HexLetter", "HexDigit", "Digit", "NonZeroDigit", "NonZeroOctDigit", "OctDigit", - "ZeroDigit", "ExponentDecimalReal", "RegularDecimalReal", "UNION", "ALL", - "OPTIONAL", "MATCH", "UNWIND", "AS", "MERGE", "ON", "CREATE", "SET", "DETACH", - "DELETE", "REMOVE", "WITH", "DISTINCT", "RETURN", "ORDER", "BY", "L_SKIP", - "LIMIT", "ASCENDING", "ASC", "DESCENDING", "DESC", "WHERE", "OR", "XOR", - "AND", "NOT", "IN", "STARTS", "ENDS", "CONTAINS", "IS", "CYPHERNULL", - "COUNT", "FILTER", "EXTRACT", "ANY", "NONE", "SINGLE", "TRUE", "FALSE", - "UnescapedSymbolicName", "IdentifierStart", "IdentifierPart", "EscapedSymbolicName", - "SP", "WHITESPACE", "Comment", "L_0X", "FF", "EscapedSymbolicName_0", - "RS", "ID_Continue", "Comment_1", "StringLiteral_1", "Comment_3", "Comment_2", - "GS", "FS", "CR", "Sc", "SPACE", "TAB", "StringLiteral_0", "LF", "VT", - "US", "ID_Start" -}; +std::vector<std::string> CypherLexer::_ruleNames = {"T__0", + "T__1", + "T__2", + "T__3", + "T__4", + "T__5", + "T__6", + "T__7", + "T__8", + "T__9", + "T__10", + "T__11", + "T__12", + "T__13", + "T__14", + "T__15", + "T__16", + "T__17", + "T__18", + "T__19", + "T__20", + "T__21", + "T__22", + "T__23", + "T__24", + "T__25", + "T__26", + "T__27", + "T__28", + "T__29", + "T__30", + "T__31", + "T__32", + "T__33", + "T__34", + "T__35", + "T__36", + "T__37", + "T__38", + "T__39", + "T__40", + "T__41", + "T__42", + "T__43", + "T__44", + "T__45", + "T__46", + "T__47", + "T__48", + "StringLiteral", + "EscapedChar", + "HexInteger", + "DecimalInteger", + "OctalInteger", + "HexLetter", + "HexDigit", + "Digit", + "NonZeroDigit", + "NonZeroOctDigit", + "OctDigit", + "ZeroDigit", + "ExponentDecimalReal", + "RegularDecimalReal", + "UNION", + "ALL", + "OPTIONAL", + "MATCH", + "UNWIND", + "AS", + "MERGE", + "ON", + "CREATE", + "SET", + "DETACH", + "DELETE", + "REMOVE", + "WITH", + "DISTINCT", + "RETURN", + "ORDER", + "BY", + "L_SKIP", + "LIMIT", + "ASCENDING", + "ASC", + "DESCENDING", + "DESC", + "WHERE", + "OR", + "XOR", + "AND", + "NOT", + "IN", + "STARTS", + "ENDS", + "CONTAINS", + "IS", + "CYPHERNULL", + "COUNT", + "FILTER", + "EXTRACT", + "ANY", + "NONE", + "SINGLE", + "TRUE", + "FALSE", + "UnescapedSymbolicName", + "IdentifierStart", + "IdentifierPart", + "EscapedSymbolicName", + "SP", + "WHITESPACE", + "Comment", + "L_0X", + "FF", + "EscapedSymbolicName_0", + "RS", + "ID_Continue", + "Comment_1", + "StringLiteral_1", + "Comment_3", + "Comment_2", + "GS", + "FS", + "CR", + "Sc", + "SPACE", + "TAB", + "StringLiteral_0", + "LF", + "VT", + "US", + "ID_Start"}; -std::vector<std::string> CypherLexer::_modeNames = { - "DEFAULT_MODE" -}; +std::vector<std::string> CypherLexer::_modeNames = {"DEFAULT_MODE"}; std::vector<std::string> CypherLexer::_literalNames = { - "", "';'", "','", "'='", "'+='", "'*'", "'('", "')'", "'['", "'?'", "']'", - "':'", "'|'", "'..'", "'+'", "'-'", "'/'", "'%'", "'^'", "'=~'", "'<>'", - "'!='", "'<'", "'>'", "'<='", "'>='", "'.'", "'!'", "'{'", "'}'", "'$'", - "'⟨'", "'〈'", "'﹤'", "'<'", "'⟩'", "'〉'", "'﹥'", "'>'", "''", "'‐'", - "'‑'", "'‒'", "'–'", "'—'", "'―'", "'−'", "'﹘'", "'﹣'", "'-'", "", "", - "", "", "", "", "", "", "", "", "", "'0'" -}; + "", "';'", "','", "'='", "'+='", "'*'", "'('", "')'", "'['", + "'?'", "']'", "':'", "'|'", "'..'", "'+'", "'-'", "'/'", "'%'", + "'^'", "'=~'", "'<>'", "'!='", "'<'", "'>'", "'<='", "'>='", "'.'", + "'!'", "'{'", "'}'", "'$'", "'⟨'", "'〈'", "'﹤'", "'<'", "'⟩'", + "'〉'", "'﹥'", "'>'", "''", "'‐'", "'‑'", "'‒'", "'–'", "'—'", + "'―'", "'−'", "'﹘'", "'﹣'", "'-'", "", "", "", "", + "", "", "", "", "", "", "", "'0'"}; -std::vector<std::string> CypherLexer::_symbolicNames = { - "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", "", "", "", "", "StringLiteral", - "EscapedChar", "HexInteger", "DecimalInteger", "OctalInteger", "HexLetter", - "HexDigit", "Digit", "NonZeroDigit", "NonZeroOctDigit", "OctDigit", "ZeroDigit", - "ExponentDecimalReal", "RegularDecimalReal", "UNION", "ALL", "OPTIONAL", - "MATCH", "UNWIND", "AS", "MERGE", "ON", "CREATE", "SET", "DETACH", "DELETE", - "REMOVE", "WITH", "DISTINCT", "RETURN", "ORDER", "BY", "L_SKIP", "LIMIT", - "ASCENDING", "ASC", "DESCENDING", "DESC", "WHERE", "OR", "XOR", "AND", - "NOT", "IN", "STARTS", "ENDS", "CONTAINS", "IS", "CYPHERNULL", "COUNT", - "FILTER", "EXTRACT", "ANY", "NONE", "SINGLE", "TRUE", "FALSE", "UnescapedSymbolicName", - "IdentifierStart", "IdentifierPart", "EscapedSymbolicName", "SP", "WHITESPACE", - "Comment", "L_0X" -}; +std::vector<std::string> CypherLexer::_symbolicNames = {"", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "StringLiteral", + "EscapedChar", + "HexInteger", + "DecimalInteger", + "OctalInteger", + "HexLetter", + "HexDigit", + "Digit", + "NonZeroDigit", + "NonZeroOctDigit", + "OctDigit", + "ZeroDigit", + "ExponentDecimalReal", + "RegularDecimalReal", + "UNION", + "ALL", + "OPTIONAL", + "MATCH", + "UNWIND", + "AS", + "MERGE", + "ON", + "CREATE", + "SET", + "DETACH", + "DELETE", + "REMOVE", + "WITH", + "DISTINCT", + "RETURN", + "ORDER", + "BY", + "L_SKIP", + "LIMIT", + "ASCENDING", + "ASC", + "DESCENDING", + "DESC", + "WHERE", + "OR", + "XOR", + "AND", + "NOT", + "IN", + "STARTS", + "ENDS", + "CONTAINS", + "IS", + "CYPHERNULL", + "COUNT", + "FILTER", + "EXTRACT", + "ANY", + "NONE", + "SINGLE", + "TRUE", + "FALSE", + "UnescapedSymbolicName", + "IdentifierStart", + "IdentifierPart", + "EscapedSymbolicName", + "SP", + "WHITESPACE", + "Comment", + "L_0X"}; dfa::Vocabulary CypherLexer::_vocabulary(_literalNames, _symbolicNames); std::vector<std::string> CypherLexer::_tokenNames; CypherLexer::Initializer::Initializer() { - // This code could be in a static initializer lambda, but VS doesn't allow access to private class members from there. - for (size_t i = 0; i < _symbolicNames.size(); ++i) { - std::string name = _vocabulary.getLiteralName(i); - if (name.empty()) { - name = _vocabulary.getSymbolicName(i); - } + // This code could be in a static initializer lambda, but VS doesn't allow + // access to private class members from there. + for (size_t i = 0; i < _symbolicNames.size(); ++i) { + std::string name = _vocabulary.getLiteralName(i); + if (name.empty()) { + name = _vocabulary.getSymbolicName(i); + } - if (name.empty()) { - _tokenNames.push_back("<INVALID>"); - } else { + if (name.empty()) { + _tokenNames.push_back("<INVALID>"); + } else { _tokenNames.push_back(name); } - } + } _serializedATN = { - 0x3, 0x430, 0xd6d1, 0x8206, 0xad2d, 0x4417, 0xaef1, 0x8d80, 0xaadd, - 0x2, 0x74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 0x3, 0x7e, 0x3, 0x7f, 0x3, 0x7f, - 0x3, 0x80, 0x3, 0x80, 0x3, 0x81, 0x3, 0x81, 0x3, 0x82, 0x3, 0x82, 0x3, - 0x83, 0x3, 0x83, 0x3, 0x84, 0x3, 0x84, 0x3, 0x85, 0x3, 0x85, 0x3, 0x86, - 0x3, 0x86, 0x2, 0x2, 0x87, 0x3, 0x3, 0x5, 0x4, 0x7, 0x5, 0x9, 0x6, 0xb, - 0x7, 0xd, 0x8, 0xf, 0x9, 0x11, 0xa, 0x13, 0xb, 0x15, 0xc, 0x17, 0xd, - 0x19, 0xe, 0x1b, 0xf, 0x1d, 0x10, 0x1f, 0x11, 0x21, 0x12, 0x23, 0x13, - 0x25, 0x14, 0x27, 0x15, 0x29, 0x16, 0x2b, 0x17, 0x2d, 0x18, 0x2f, 0x19, - 0x31, 0x1a, 0x33, 0x1b, 0x35, 0x1c, 0x37, 0x1d, 0x39, 0x1e, 0x3b, 0x1f, - 0x3d, 0x20, 0x3f, 0x21, 0x41, 0x22, 0x43, 0x23, 0x45, 0x24, 0x47, 0x25, - 0x49, 0x26, 0x4b, 0x27, 0x4d, 0x28, 0x4f, 0x29, 0x51, 0x2a, 0x53, 0x2b, - 0x55, 0x2c, 0x57, 0x2d, 0x59, 0x2e, 0x5b, 0x2f, 0x5d, 0x30, 0x5f, 0x31, - 0x61, 0x32, 0x63, 0x33, 0x65, 0x34, 0x67, 0x35, 0x69, 0x36, 0x6b, 0x37, - 0x6d, 0x38, 0x6f, 0x39, 0x71, 0x3a, 0x73, 0x3b, 0x75, 0x3c, 0x77, 0x3d, - 0x79, 0x3e, 0x7b, 0x3f, 0x7d, 0x40, 0x7f, 0x41, 0x81, 0x42, 0x83, 0x43, - 0x85, 0x44, 0x87, 0x45, 0x89, 0x46, 0x8b, 0x47, 0x8d, 0x48, 0x8f, 0x49, - 0x91, 0x4a, 0x93, 0x4b, 0x95, 0x4c, 0x97, 0x4d, 0x99, 0x4e, 0x9b, 0x4f, - 0x9d, 0x50, 0x9f, 0x51, 0xa1, 0x52, 0xa3, 0x53, 0xa5, 0x54, 0xa7, 0x55, - 0xa9, 0x56, 0xab, 0x57, 0xad, 0x58, 0xaf, 0x59, 0xb1, 0x5a, 0xb3, 0x5b, - 0xb5, 0x5c, 0xb7, 0x5d, 0xb9, 0x5e, 0xbb, 0x5f, 0xbd, 0x60, 0xbf, 0x61, - 0xc1, 0x62, 0xc3, 0x63, 0xc5, 0x64, 0xc7, 0x65, 0xc9, 0x66, 0xcb, 0x67, - 0xcd, 0x68, 0xcf, 0x69, 0xd1, 0x6a, 0xd3, 0x6b, 0xd5, 0x6c, 0xd7, 0x6d, - 0xd9, 0x6e, 0xdb, 0x6f, 0xdd, 0x70, 0xdf, 0x71, 0xe1, 0x72, 0xe3, 0x73, - 0xe5, 0x74, 0xe7, 0x2, 0xe9, 0x2, 0xeb, 0x2, 0xed, 0x2, 0xef, 0x2, 0xf1, - 0x2, 0xf3, 0x2, 0xf5, 0x2, 0xf7, 0x2, 0xf9, 0x2, 0xfb, 0x2, 0xfd, 0x2, - 0xff, 0x2, 0x101, 0x2, 0x103, 0x2, 0x105, 0x2, 0x107, 0x2, 0x109, 0x2, - 0x10b, 0x2, 0x3, 0x2, 0x30, 0x11, 0x2, 0x24, 0x24, 0x27, 0x27, 0x29, - 0x29, 0x44, 0x44, 0x48, 0x48, 0x50, 0x50, 0x54, 0x54, 0x56, 0x56, 0x5e, - 0x5e, 0x61, 0x61, 0x64, 0x64, 0x68, 0x68, 0x70, 0x70, 0x74, 0x74, 0x76, - 0x76, 0x4, 0x2, 0x57, 0x57, 0x77, 0x77, 0x4, 0x2, 0x43, 0x48, 0x63, - 0x68, 0x4, 0x2, 0x47, 0x47, 0x67, 0x67, 0x4, 0x2, 0x50, 0x50, 0x70, - 0x70, 0x4, 0x2, 0x4b, 0x4b, 0x6b, 0x6b, 0x4, 0x2, 0x51, 0x51, 0x71, - 0x71, 0x4, 0x2, 0x43, 0x43, 0x63, 0x63, 0x4, 0x2, 0x4e, 0x4e, 0x6e, - 0x6e, 0x4, 0x2, 0x52, 0x52, 0x72, 0x72, 0x4, 0x2, 0x56, 0x56, 0x76, - 0x76, 0x4, 0x2, 0x4f, 0x4f, 0x6f, 0x6f, 0x4, 0x2, 0x45, 0x45, 0x65, - 0x65, 0x4, 0x2, 0x4a, 0x4a, 0x6a, 0x6a, 0x4, 0x2, 0x59, 0x59, 0x79, - 0x79, 0x4, 0x2, 0x46, 0x46, 0x66, 0x66, 0x4, 0x2, 0x55, 0x55, 0x75, - 0x75, 0x4, 0x2, 0x54, 0x54, 0x74, 0x74, 0x4, 0x2, 0x49, 0x49, 0x69, - 0x69, 0x4, 0x2, 0x58, 0x58, 0x78, 0x78, 0x4, 0x2, 0x44, 0x44, 0x64, - 0x64, 0x4, 0x2, 0x5b, 0x5b, 0x7b, 0x7b, 0x4, 0x2, 0x4d, 0x4d, 0x6d, - 0x6d, 0x4, 0x2, 0x5a, 0x5a, 0x7a, 0x7a, 0x4, 0x2, 0x48, 0x48, 0x68, - 0x68, 0x8, 0x2, 0x61, 0x61, 0x2041, 0x2042, 0x2056, 0x2056, 0xfe35, - 0xfe36, 0xfe4f, 0xfe51, 0xff41, 0xff41, 0xa, 0x2, 0xa2, 0xa2, 0x1682, - 0x1682, 0x1810, 0x1810, 0x2002, 0x200c, 0x202a, 0x202b, 0x2031, 0x2031, - 0x2061, 0x2061, 0x3002, 0x3002, 0x3, 0x2, 0xe, 0xe, 0x4, 0x2, 0x2, 0x61, - 0x63, 0x1, 0x3, 0x2, 0x20, 0x20, 0x1af, 0x2, 0x32, 0x3b, 0x43, 0x5c, - 0x61, 0x61, 0x63, 0x7c, 0xac, 0xac, 0xb7, 0xb7, 0xb9, 0xb9, 0xbc, 0xbc, - 0xc2, 0xd8, 0xda, 0xf8, 0xfa, 0x2c3, 0x2c8, 0x2d3, 0x2e2, 0x2e6, 0x2ee, - 0x2ee, 0x2f0, 0x2f0, 0x302, 0x376, 0x378, 0x379, 0x37c, 0x37f, 0x388, - 0x38c, 0x38e, 0x38e, 0x390, 0x3a3, 0x3a5, 0x3f7, 0x3f9, 0x483, 0x485, - 0x489, 0x48c, 0x529, 0x533, 0x558, 0x55b, 0x55b, 0x563, 0x589, 0x593, - 0x5bf, 0x5c1, 0x5c1, 0x5c3, 0x5c4, 0x5c6, 0x5c7, 0x5c9, 0x5c9, 0x5d2, - 0x5ec, 0x5f2, 0x5f4, 0x612, 0x61c, 0x622, 0x66b, 0x670, 0x6d5, 0x6d7, - 0x6de, 0x6e1, 0x6ea, 0x6ec, 0x6fe, 0x701, 0x701, 0x712, 0x74c, 0x74f, - 0x7b3, 0x7c2, 0x7f7, 0x7fc, 0x7fc, 0x802, 0x82f, 0x842, 0x85d, 0x8a2, - 0x8a2, 0x8a4, 0x8ae, 0x8e6, 0x900, 0x902, 0x965, 0x968, 0x971, 0x973, - 0x979, 0x97b, 0x981, 0x983, 0x985, 0x987, 0x98e, 0x991, 0x992, 0x995, - 0x9aa, 0x9ac, 0x9b2, 0x9b4, 0x9b4, 0x9b8, 0x9bb, 0x9be, 0x9c6, 0x9c9, - 0x9ca, 0x9cd, 0x9d0, 0x9d9, 0x9d9, 0x9de, 0x9df, 0x9e1, 0x9e5, 0x9e8, - 0x9f3, 0xa03, 0xa05, 0xa07, 0xa0c, 0xa11, 0xa12, 0xa15, 0xa2a, 0xa2c, - 0xa32, 0xa34, 0xa35, 0xa37, 0xa38, 0xa3a, 0xa3b, 0xa3e, 0xa3e, 0xa40, - 0xa44, 0xa49, 0xa4a, 0xa4d, 0xa4f, 0xa53, 0xa53, 0xa5b, 0xa5e, 0xa60, - 0xa60, 0xa68, 0xa77, 0xa83, 0xa85, 0xa87, 0xa8f, 0xa91, 0xa93, 0xa95, - 0xaaa, 0xaac, 0xab2, 0xab4, 0xab5, 0xab7, 0xabb, 0xabe, 0xac7, 0xac9, - 0xacb, 0xacd, 0xacf, 0xad2, 0xad2, 0xae2, 0xae5, 0xae8, 0xaf1, 0xb03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, 0xde1, 0xdf4, 0xdf5, 0xe03, - 0xe3c, 0xe42, 0xe50, 0xe52, 0xe5b, 0xe83, 0xe84, 0xe86, 0xe86, 0xe89, - 0xe8a, 0xe8c, 0xe8c, 0xe8f, 0xe8f, 0xe96, 0xe99, 0xe9b, 0xea1, 0xea3, - 0xea5, 0xea7, 0xea7, 0xea9, 0xea9, 0xeac, 0xead, 0xeaf, 0xebb, 0xebd, - 0xebf, 0xec2, 0xec6, 0xec8, 0xec8, 0xeca, 0xecf, 0xed2, 0xedb, 0xede, - 0xee1, 0xf02, 0xf02, 0xf1a, 0xf1b, 0xf22, 0xf2b, 0xf37, 0xf37, 0xf39, - 0xf39, 0xf3b, 0xf3b, 0xf40, 0xf49, 0xf4b, 0xf6e, 0xf73, 0xf86, 0xf88, - 0xf99, 0xf9b, 0xfbe, 0xfc8, 0xfc8, 0x1002, 0x104b, 0x1052, 0x109f, 0x10a2, - 0x10c7, 0x10c9, 0x10c9, 0x10cf, 0x10cf, 0x10d2, 0x10fc, 0x10fe, 0x124a, - 0x124c, 0x124f, 0x1252, 0x1258, 0x125a, 0x125a, 0x125c, 0x125f, 0x1262, - 0x128a, 0x128c, 0x128f, 0x1292, 0x12b2, 0x12b4, 0x12b7, 0x12ba, 0x12c0, - 0x12c2, 0x12c2, 0x12c4, 0x12c7, 0x12ca, 0x12d8, 0x12da, 0x1312, 0x1314, - 0x1317, 0x131a, 0x135c, 0x135f, 0x1361, 0x136b, 0x1373, 0x1382, 0x1391, - 0x13a2, 0x13f6, 0x1403, 0x166e, 0x1671, 0x1681, 0x1683, 0x169c, 0x16a2, - 0x16ec, 0x16f0, 0x16f2, 0x1702, 0x170e, 0x1710, 0x1716, 0x1722, 0x1736, - 0x1742, 0x1755, 0x1762, 0x176e, 0x1770, 0x1772, 0x1774, 0x1775, 0x1782, - 0x17d5, 0x17d9, 0x17d9, 0x17de, 0x17df, 0x17e2, 0x17eb, 0x180d, 0x180f, - 0x1812, 0x181b, 0x1822, 0x1879, 0x1882, 0x18ac, 0x18b2, 0x18f7, 0x1902, - 0x191e, 0x1922, 0x192d, 0x1932, 0x193d, 0x1948, 0x196f, 0x1972, 0x1976, - 0x1982, 0x19ad, 0x19b2, 0x19cb, 0x19d2, 0x19dc, 0x1a02, 0x1a1d, 0x1a22, - 0x1a60, 0x1a62, 0x1a7e, 0x1a81, 0x1a8b, 0x1a92, 0x1a9b, 0x1aa9, 0x1aa9, - 0x1b02, 0x1b4d, 0x1b52, 0x1b5b, 0x1b6d, 0x1b75, 0x1b82, 0x1bf5, 0x1c02, - 0x1c39, 0x1c42, 0x1c4b, 0x1c4f, 0x1c7f, 0x1cd2, 0x1cd4, 0x1cd6, 0x1cf8, - 0x1d02, 0x1de8, 0x1dfe, 0x1f17, 0x1f1a, 0x1f1f, 0x1f22, 0x1f47, 0x1f4a, - 0x1f4f, 0x1f52, 0x1f59, 0x1f5b, 0x1f5b, 0x1f5d, 0x1f5d, 0x1f5f, 0x1f5f, - 0x1f61, 0x1f7f, 0x1f82, 0x1fb6, 0x1fb8, 0x1fbe, 0x1fc0, 0x1fc0, 0x1fc4, - 0x1fc6, 0x1fc8, 0x1fce, 0x1fd2, 0x1fd5, 0x1fd8, 0x1fdd, 0x1fe2, 0x1fee, - 0x1ff4, 0x1ff6, 0x1ff8, 0x1ffe, 0x2041, 0x2042, 0x2056, 0x2056, 0x2073, - 0x2073, 0x2081, 0x2081, 0x2092, 0x209e, 0x20d2, 0x20de, 0x20e3, 0x20e3, - 0x20e7, 0x20f2, 0x2104, 0x2104, 0x2109, 0x2109, 0x210c, 0x2115, 0x2117, - 0x2117, 0x211a, 0x211f, 0x2126, 0x2126, 0x2128, 0x2128, 0x212a, 0x212a, - 0x212c, 0x213b, 0x213e, 0x2141, 0x2147, 0x214b, 0x2150, 0x2150, 0x2162, - 0x218a, 0x2c02, 0x2c30, 0x2c32, 0x2c60, 0x2c62, 0x2ce6, 0x2ced, 0x2cf5, - 0x2d02, 0x2d27, 0x2d29, 0x2d29, 0x2d2f, 0x2d2f, 0x2d32, 0x2d69, 0x2d71, - 0x2d71, 0x2d81, 0x2d98, 0x2da2, 0x2da8, 0x2daa, 0x2db0, 0x2db2, 0x2db8, - 0x2dba, 0x2dc0, 0x2dc2, 0x2dc8, 0x2dca, 0x2dd0, 0x2dd2, 0x2dd8, 0x2dda, - 0x2de0, 0x2de2, 0x2e01, 0x3007, 0x3009, 0x3023, 0x3031, 0x3033, 0x3037, - 0x303a, 0x303e, 0x3043, 0x3098, 0x309b, 0x30a1, 0x30a3, 0x30fc, 0x30fe, - 0x3101, 0x3107, 0x312f, 0x3133, 0x3190, 0x31a2, 0x31bc, 0x31f2, 0x3201, - 0x3402, 0x4db7, 0x4e02, 0x9fce, 0xa002, 0xa48e, 0xa4d2, 0xa4ff, 0xa502, - 0xa60e, 0xa612, 0xa62d, 0xa642, 0xa671, 0xa676, 0xa67f, 0xa681, 0xa699, - 0xa6a1, 0xa6f3, 0xa719, 0xa721, 0xa724, 0xa78a, 0xa78d, 0xa790, 0xa792, - 0xa795, 0xa7a2, 0xa7ac, 0xa7fa, 0xa829, 0xa842, 0xa875, 0xa882, 0xa8c6, - 0xa8d2, 0xa8db, 0xa8e2, 0xa8f9, 0xa8fd, 0xa8fd, 0xa902, 0xa92f, 0xa932, - 0xa955, 0xa962, 0xa97e, 0xa982, 0xa9c2, 0xa9d1, 0xa9db, 0xaa02, 0xaa38, - 0xaa42, 0xaa4f, 0xaa52, 0xaa5b, 0xaa62, 0xaa78, 0xaa7c, 0xaa7d, 0xaa82, - 0xaac4, 0xaadd, 0xaadf, 0xaae2, 0xaaf1, 0xaaf4, 0xaaf8, 0xab03, 0xab08, - 0xab0b, 0xab10, 0xab13, 0xab18, 0xab22, 0xab28, 0xab2a, 0xab30, 0xabc2, - 0xabec, 0xabee, 0xabef, 0xabf2, 0xabfb, 0xac02, 0xd7a5, 0xd7b2, 0xd7c8, - 0xd7cd, 0xd7fd, 0xf902, 0xfa6f, 0xfa72, 0xfadb, 0xfb02, 0xfb08, 0xfb15, - 0xfb19, 0xfb1f, 0xfb2a, 0xfb2c, 0xfb38, 0xfb3a, 0xfb3e, 0xfb40, 0xfb40, - 0xfb42, 0xfb43, 0xfb45, 0xfb46, 0xfb48, 0xfbb3, 0xfbd5, 0xfd3f, 0xfd52, - 0xfd91, 0xfd94, 0xfdc9, 0xfdf2, 0xfdfd, 0xfe02, 0xfe11, 0xfe22, 0xfe28, - 0xfe35, 0xfe36, 0xfe4f, 0xfe51, 0xfe72, 0xfe76, 0xfe78, 0xfefe, 0xff12, - 0xff1b, 0xff23, 0xff3c, 0xff41, 0xff41, 0xff43, 0xff5c, 0xff68, 0xffc0, - 0xffc4, 0xffc9, 0xffcc, 0xffd1, 0xffd4, 0xffd9, 0xffdc, 0xffde, 0x4, - 0x2, 0x2, 0x2b, 0x2d, 0x1, 0x5, 0x2, 0x2, 0x28, 0x2a, 0x5d, 0x5f, 0x1, - 0x5, 0x2, 0x2, 0xb, 0xd, 0xe, 0x10, 0x1, 0x4, 0x2, 0x2, 0x30, 0x32, - 0x1, 0x3, 0x2, 0x1f, 0x1f, 0x3, 0x2, 0x1e, 0x1e, 0x3, 0x2, 0xf, 0xf, - 0x13, 0x2, 0x26, 0x26, 0xa4, 0xa7, 0x591, 0x591, 0x60d, 0x60d, 0x9f4, - 0x9f5, 0x9fd, 0x9fd, 0xaf3, 0xaf3, 0xbfb, 0xbfb, 0xe41, 0xe41, 0x17dd, - 0x17dd, 0x20a2, 0x20bc, 0xa83a, 0xa83a, 0xfdfe, 0xfdfe, 0xfe6b, 0xfe6b, - 0xff06, 0xff06, 0xffe2, 0xffe3, 0xffe7, 0xffe8, 0x3, 0x2, 0x22, 0x22, - 0x3, 0x2, 0xb, 0xb, 0x5, 0x2, 0x2, 0x23, 0x25, 0x5d, 0x5f, 0x1, 0x3, - 0x2, 0xc, 0xc, 0x3, 0x2, 0xd, 0xd, 0x3, 0x2, 0x21, 0x21, 0x174, 0x2, - 0x43, 0x5c, 0x63, 0x7c, 0xac, 0xac, 0xb7, 0xb7, 0xbc, 0xbc, 0xc2, 0xd8, - 0xda, 0xf8, 0xfa, 0x2c3, 0x2c8, 0x2d3, 0x2e2, 0x2e6, 0x2ee, 0x2ee, 0x2f0, - 0x2f0, 0x372, 0x376, 0x378, 0x379, 0x37c, 0x37f, 0x388, 0x388, 0x38a, - 0x38c, 0x38e, 0x38e, 0x390, 0x3a3, 0x3a5, 0x3f7, 0x3f9, 0x483, 0x48c, - 0x529, 0x533, 0x558, 0x55b, 0x55b, 0x563, 0x589, 0x5d2, 0x5ec, 0x5f2, - 0x5f4, 0x622, 0x64c, 0x670, 0x671, 0x673, 0x6d5, 0x6d7, 0x6d7, 0x6e7, - 0x6e8, 0x6f0, 0x6f1, 0x6fc, 0x6fe, 0x701, 0x701, 0x712, 0x712, 0x714, - 0x731, 0x74f, 0x7a7, 0x7b3, 0x7b3, 0x7cc, 0x7ec, 0x7f6, 0x7f7, 0x7fc, - 0x7fc, 0x802, 0x817, 0x81c, 0x81c, 0x826, 0x826, 0x82a, 0x82a, 0x842, - 0x85a, 0x8a2, 0x8a2, 0x8a4, 0x8ae, 0x906, 0x93b, 0x93f, 0x93f, 0x952, - 0x952, 0x95a, 0x963, 0x973, 0x979, 0x97b, 0x981, 0x987, 0x98e, 0x991, - 0x992, 0x995, 0x9aa, 0x9ac, 0x9b2, 0x9b4, 0x9b4, 0x9b8, 0x9bb, 0x9bf, - 0x9bf, 0x9d0, 0x9d0, 0x9de, 0x9df, 0x9e1, 0x9e3, 0x9f2, 0x9f3, 0xa07, - 0xa0c, 0xa11, 0xa12, 0xa15, 0xa2a, 0xa2c, 0xa32, 0xa34, 0xa35, 0xa37, - 0xa38, 0xa3a, 0xa3b, 0xa5b, 0xa5e, 0xa60, 0xa60, 0xa74, 0xa76, 0xa87, - 0xa8f, 0xa91, 0xa93, 0xa95, 0xaaa, 0xaac, 0xab2, 0xab4, 0xab5, 0xab7, - 0xabb, 0xabf, 0xabf, 0xad2, 0xad2, 0xae2, 0xae3, 0xb07, 0xb0e, 0xb11, - 0xb12, 0xb15, 0xb2a, 0xb2c, 0xb32, 0xb34, 0xb35, 0xb37, 0xb3b, 0xb3f, - 0xb3f, 0xb5e, 0xb5f, 0xb61, 0xb63, 0xb73, 0xb73, 0xb85, 0xb85, 0xb87, - 0xb8c, 0xb90, 0xb92, 0xb94, 0xb97, 0xb9b, 0xb9c, 0xb9e, 0xb9e, 0xba0, - 0xba1, 0xba5, 0xba6, 0xbaa, 0xbac, 0xbb0, 0xbbb, 0xbd2, 0xbd2, 0xc07, - 0xc0e, 0xc10, 0xc12, 0xc14, 0xc2a, 0xc2c, 0xc35, 0xc37, 0xc3b, 0xc3f, - 0xc3f, 0xc5a, 0xc5b, 0xc62, 0xc63, 0xc87, 0xc8e, 0xc90, 0xc92, 0xc94, - 0xcaa, 0xcac, 0xcb5, 0xcb7, 0xcbb, 0xcbf, 0xcbf, 0xce0, 0xce0, 0xce2, - 0xce3, 0xcf3, 0xcf4, 0xd07, 0xd0e, 0xd10, 0xd12, 0xd14, 0xd3c, 0xd3f, - 0xd3f, 0xd50, 0xd50, 0xd62, 0xd63, 0xd7c, 0xd81, 0xd87, 0xd98, 0xd9c, - 0xdb3, 0xdb5, 0xdbd, 0xdbf, 0xdbf, 0xdc2, 0xdc8, 0xe03, 0xe32, 0xe34, - 0xe35, 0xe42, 0xe48, 0xe83, 0xe84, 0xe86, 0xe86, 0xe89, 0xe8a, 0xe8c, - 0xe8c, 0xe8f, 0xe8f, 0xe96, 0xe99, 0xe9b, 0xea1, 0xea3, 0xea5, 0xea7, - 0xea7, 0xea9, 0xea9, 0xeac, 0xead, 0xeaf, 0xeb2, 0xeb4, 0xeb5, 0xebf, - 0xebf, 0xec2, 0xec6, 0xec8, 0xec8, 0xede, 0xee1, 0xf02, 0xf02, 0xf42, - 0xf49, 0xf4b, 0xf6e, 0xf8a, 0xf8e, 0x1002, 0x102c, 0x1041, 0x1041, 0x1052, - 0x1057, 0x105c, 0x105f, 0x1063, 0x1063, 0x1067, 0x1068, 0x1070, 0x1072, - 0x1077, 0x1083, 0x1090, 0x1090, 0x10a2, 0x10c7, 0x10c9, 0x10c9, 0x10cf, - 0x10cf, 0x10d2, 0x10fc, 0x10fe, 0x124a, 0x124c, 0x124f, 0x1252, 0x1258, - 0x125a, 0x125a, 0x125c, 0x125f, 0x1262, 0x128a, 0x128c, 0x128f, 0x1292, - 0x12b2, 0x12b4, 0x12b7, 0x12ba, 0x12c0, 0x12c2, 0x12c2, 0x12c4, 0x12c7, - 0x12ca, 0x12d8, 0x12da, 0x1312, 0x1314, 0x1317, 0x131a, 0x135c, 0x1382, - 0x1391, 0x13a2, 0x13f6, 0x1403, 0x166e, 0x1671, 0x1681, 0x1683, 0x169c, - 0x16a2, 0x16ec, 0x16f0, 0x16f2, 0x1702, 0x170e, 0x1710, 0x1713, 0x1722, - 0x1733, 0x1742, 0x1753, 0x1762, 0x176e, 0x1770, 0x1772, 0x1782, 0x17b5, - 0x17d9, 0x17d9, 0x17de, 0x17de, 0x1822, 0x1879, 0x1882, 0x18aa, 0x18ac, - 0x18ac, 0x18b2, 0x18f7, 0x1902, 0x191e, 0x1952, 0x196f, 0x1972, 0x1976, - 0x1982, 0x19ad, 0x19c3, 0x19c9, 0x1a02, 0x1a18, 0x1a22, 0x1a56, 0x1aa9, - 0x1aa9, 0x1b07, 0x1b35, 0x1b47, 0x1b4d, 0x1b85, 0x1ba2, 0x1bb0, 0x1bb1, - 0x1bbc, 0x1be7, 0x1c02, 0x1c25, 0x1c4f, 0x1c51, 0x1c5c, 0x1c7f, 0x1ceb, - 0x1cee, 0x1cf0, 0x1cf3, 0x1cf7, 0x1cf8, 0x1d02, 0x1dc1, 0x1e02, 0x1f17, - 0x1f1a, 0x1f1f, 0x1f22, 0x1f47, 0x1f4a, 0x1f4f, 0x1f52, 0x1f59, 0x1f5b, - 0x1f5b, 0x1f5d, 0x1f5d, 0x1f5f, 0x1f5f, 0x1f61, 0x1f7f, 0x1f82, 0x1fb6, - 0x1fb8, 0x1fbe, 0x1fc0, 0x1fc0, 0x1fc4, 0x1fc6, 0x1fc8, 0x1fce, 0x1fd2, - 0x1fd5, 0x1fd8, 0x1fdd, 0x1fe2, 0x1fee, 0x1ff4, 0x1ff6, 0x1ff8, 0x1ffe, - 0x2073, 0x2073, 0x2081, 0x2081, 0x2092, 0x209e, 0x2104, 0x2104, 0x2109, - 0x2109, 0x210c, 0x2115, 0x2117, 0x2117, 0x211a, 0x211f, 0x2126, 0x2126, - 0x2128, 0x2128, 0x212a, 0x212a, 0x212c, 0x213b, 0x213e, 0x2141, 0x2147, - 0x214b, 0x2150, 0x2150, 0x2162, 0x218a, 0x2c02, 0x2c30, 0x2c32, 0x2c60, - 0x2c62, 0x2ce6, 0x2ced, 0x2cf0, 0x2cf4, 0x2cf5, 0x2d02, 0x2d27, 0x2d29, - 0x2d29, 0x2d2f, 0x2d2f, 0x2d32, 0x2d69, 0x2d71, 0x2d71, 0x2d82, 0x2d98, - 0x2da2, 0x2da8, 0x2daa, 0x2db0, 0x2db2, 0x2db8, 0x2dba, 0x2dc0, 0x2dc2, - 0x2dc8, 0x2dca, 0x2dd0, 0x2dd2, 0x2dd8, 0x2dda, 0x2de0, 0x3007, 0x3009, - 0x3023, 0x302b, 0x3033, 0x3037, 0x303a, 0x303e, 0x3043, 0x3098, 0x309d, - 0x30a1, 0x30a3, 0x30fc, 0x30fe, 0x3101, 0x3107, 0x312f, 0x3133, 0x3190, - 0x31a2, 0x31bc, 0x31f2, 0x3201, 0x3402, 0x4db7, 0x4e02, 0x9fce, 0xa002, - 0xa48e, 0xa4d2, 0xa4ff, 0xa502, 0xa60e, 0xa612, 0xa621, 0xa62c, 0xa62d, - 0xa642, 0xa670, 0xa681, 0xa699, 0xa6a2, 0xa6f1, 0xa719, 0xa721, 0xa724, - 0xa78a, 0xa78d, 0xa790, 0xa792, 0xa795, 0xa7a2, 0xa7ac, 0xa7fa, 0xa803, - 0xa805, 0xa807, 0xa809, 0xa80c, 0xa80e, 0xa824, 0xa842, 0xa875, 0xa884, - 0xa8b5, 0xa8f4, 0xa8f9, 0xa8fd, 0xa8fd, 0xa90c, 0xa927, 0xa932, 0xa948, - 0xa962, 0xa97e, 0xa986, 0xa9b4, 0xa9d1, 0xa9d1, 0xaa02, 0xaa2a, 0xaa42, - 0xaa44, 0xaa46, 0xaa4d, 0xaa62, 0xaa78, 0xaa7c, 0xaa7c, 0xaa82, 0xaab1, - 0xaab3, 0xaab3, 0xaab7, 0xaab8, 0xaabb, 0xaabf, 0xaac2, 0xaac2, 0xaac4, - 0xaac4, 0xaadd, 0xaadf, 0xaae2, 0xaaec, 0xaaf4, 0xaaf6, 0xab03, 0xab08, - 0xab0b, 0xab10, 0xab13, 0xab18, 0xab22, 0xab28, 0xab2a, 0xab30, 0xabc2, - 0xabe4, 0xac02, 0xd7a5, 0xd7b2, 0xd7c8, 0xd7cd, 0xd7fd, 0xf902, 0xfa6f, - 0xfa72, 0xfadb, 0xfb02, 0xfb08, 0xfb15, 0xfb19, 0xfb1f, 0xfb1f, 0xfb21, - 0xfb2a, 0xfb2c, 0xfb38, 0xfb3a, 0xfb3e, 0xfb40, 0xfb40, 0xfb42, 0xfb43, - 0xfb45, 0xfb46, 0xfb48, 0xfbb3, 0xfbd5, 0xfd3f, 0xfd52, 0xfd91, 0xfd94, - 0xfdc9, 0xfdf2, 0xfdfd, 0xfe72, 0xfe76, 0xfe78, 0xfefe, 0xff23, 0xff3c, - 0xff43, 0xff5c, 0xff68, 0xffc0, 0xffc4, 0xffc9, 0xffcc, 0xffd1, 0xffd4, - 0xffd9, 0xffdc, 0xffde, 0x37e, 0x2, 0x3, 0x3, 0x2, 0x2, 0x2, 0x2, 0x5, - 0x3, 0x2, 0x2, 0x2, 0x2, 0x7, 0x3, 0x2, 0x2, 0x2, 0x2, 0x9, 0x3, 0x2, - 0x2, 0x2, 0x2, 0xb, 0x3, 0x2, 0x2, 0x2, 0x2, 0xd, 0x3, 0x2, 0x2, 0x2,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, 0x2, 0x2, 0x121, 0x16, 0x3, 0x2, 0x2, 0x2, 0x122, - 0x123, 0x7, 0x3c, 0x2, 0x2, 0x123, 0x18, 0x3, 0x2, 0x2, 0x2, 0x124, - 0x125, 0x7, 0x7e, 0x2, 0x2, 0x125, 0x1a, 0x3, 0x2, 0x2, 0x2, 0x126, - 0x127, 0x7, 0x30, 0x2, 0x2, 0x127, 0x128, 0x7, 0x30, 0x2, 0x2, 0x128, - 0x1c, 0x3, 0x2, 0x2, 0x2, 0x129, 0x12a, 0x7, 0x2d, 0x2, 0x2, 0x12a, - 0x1e, 0x3, 0x2, 0x2, 0x2, 0x12b, 0x12c, 0x7, 0x2f, 0x2, 0x2, 0x12c, - 0x20, 0x3, 0x2, 0x2, 0x2, 0x12d, 0x12e, 0x7, 0x31, 0x2, 0x2, 0x12e, - 0x22, 0x3, 0x2, 0x2, 0x2, 0x12f, 0x130, 0x7, 0x27, 0x2, 0x2, 0x130, - 0x24, 0x3, 0x2, 0x2, 0x2, 0x131, 0x132, 0x7, 0x60, 0x2, 0x2, 0x132, - 0x26, 0x3, 0x2, 0x2, 0x2, 0x133, 0x134, 0x7, 0x3f, 0x2, 0x2, 0x134, - 0x135, 0x7, 0x80, 0x2, 0x2, 0x135, 0x28, 0x3, 0x2, 0x2, 0x2, 0x136, - 0x137, 0x7, 0x3e, 0x2, 0x2, 0x137, 0x138, 0x7, 0x40, 0x2, 0x2, 0x138, - 0x2a, 0x3, 0x2, 0x2, 0x2, 0x139, 0x13a, 0x7, 0x23, 0x2, 0x2, 0x13a, - 0x13b, 0x7, 0x3f, 0x2, 0x2, 0x13b, 0x2c, 0x3, 0x2, 0x2, 0x2, 0x13c, - 0x13d, 0x7, 0x3e, 0x2, 0x2, 0x13d, 0x2e, 0x3, 0x2, 0x2, 0x2, 0x13e, - 0x13f, 0x7, 0x40, 0x2, 0x2, 0x13f, 0x30, 0x3, 0x2, 0x2, 0x2, 0x140, - 0x141, 0x7, 0x3e, 0x2, 0x2, 0x141, 0x142, 0x7, 0x3f, 0x2, 0x2, 0x142, - 0x32, 0x3, 0x2, 0x2, 0x2, 0x143, 0x144, 0x7, 0x40, 0x2, 0x2, 0x144, - 0x145, 0x7, 0x3f, 0x2, 0x2, 0x145, 0x34, 0x3, 0x2, 0x2, 0x2, 0x146, - 0x147, 0x7, 0x30, 0x2, 0x2, 0x147, 0x36, 0x3, 0x2, 0x2, 0x2, 0x148, - 0x149, 0x7, 0x23, 0x2, 0x2, 0x149, 0x38, 0x3, 0x2, 0x2, 0x2, 0x14a, - 0x14b, 0x7, 0x7d, 0x2, 0x2, 0x14b, 0x3a, 0x3, 0x2, 0x2, 0x2, 0x14c, - 0x14d, 0x7, 0x7f, 0x2, 0x2, 0x14d, 0x3c, 0x3, 0x2, 0x2, 0x2, 0x14e, - 0x14f, 0x7, 0x26, 0x2, 0x2, 0x14f, 0x3e, 0x3, 0x2, 0x2, 0x2, 0x150, - 0x151, 0x7, 0x27ea, 0x2, 0x2, 0x151, 0x40, 0x3, 0x2, 0x2, 0x2, 0x152, - 0x153, 0x7, 0x300a, 0x2, 0x2, 0x153, 0x42, 0x3, 0x2, 0x2, 0x2, 0x154, - 0x155, 0x7, 0xfe66, 0x2, 0x2, 0x155, 0x44, 0x3, 0x2, 0x2, 0x2, 0x156, - 0x157, 0x7, 0xff1e, 0x2, 0x2, 0x157, 0x46, 0x3, 0x2, 0x2, 0x2, 0x158, - 0x159, 0x7, 0x27eb, 0x2, 0x2, 0x159, 0x48, 0x3, 0x2, 0x2, 0x2, 0x15a, - 0x15b, 0x7, 0x300b, 0x2, 0x2, 0x15b, 0x4a, 0x3, 0x2, 0x2, 0x2, 0x15c, - 0x15d, 0x7, 0xfe67, 0x2, 0x2, 0x15d, 0x4c, 0x3, 0x2, 0x2, 0x2, 0x15e, - 0x15f, 0x7, 0xff20, 0x2, 0x2, 0x15f, 0x4e, 0x3, 0x2, 0x2, 0x2, 0x160, - 0x161, 0x7, 0xaf, 0x2, 0x2, 0x161, 0x50, 0x3, 0x2, 0x2, 0x2, 0x162, - 0x163, 0x7, 0x2012, 0x2, 0x2, 0x163, 0x52, 0x3, 0x2, 0x2, 0x2, 0x164, - 0x165, 0x7, 0x2013, 0x2, 0x2, 0x165, 0x54, 0x3, 0x2, 0x2, 0x2, 0x166, - 0x167, 0x7, 0x2014, 0x2, 0x2, 0x167, 0x56, 0x3, 0x2, 0x2, 0x2, 0x168, - 0x169, 0x7, 0x2015, 0x2, 0x2, 0x169, 0x58, 0x3, 0x2, 0x2, 0x2, 0x16a, - 0x16b, 0x7, 0x2016, 0x2, 0x2, 0x16b, 0x5a, 0x3, 0x2, 0x2, 0x2, 0x16c, - 0x16d, 0x7, 0x2017, 0x2, 0x2, 0x16d, 0x5c, 0x3, 0x2, 0x2, 0x2, 0x16e, - 0x16f, 0x7, 0x2214, 0x2, 0x2, 0x16f, 0x5e, 0x3, 0x2, 0x2, 0x2, 0x170, - 0x171, 0x7, 0xfe5a, 0x2, 0x2, 0x171, 0x60, 0x3, 0x2, 0x2, 0x2, 0x172, - 0x173, 0x7, 0xfe65, 0x2, 0x2, 0x173, 0x62, 0x3, 0x2, 0x2, 0x2, 0x174, - 0x175, 0x7, 0xff0f, 0x2, 0x2, 0x175, 0x64, 0x3, 0x2, 0x2, 0x2, 0x176, - 0x17b, 0x7, 0x24, 0x2, 0x2, 0x177, 0x17a, 0x5, 0x103, 0x82, 0x2, 0x178, - 0x17a, 0x5, 0x67, 0x34, 0x2, 0x179, 0x177, 0x3, 0x2, 0x2, 0x2, 0x179, - 0x178, 0x3, 0x2, 0x2, 0x2, 0x17a, 0x17d, 0x3, 0x2, 0x2, 0x2, 0x17b, - 0x179, 0x3, 0x2, 0x2, 0x2, 0x17b, 0x17c, 0x3, 0x2, 0x2, 0x2, 0x17c, - 0x17e, 0x3, 0x2, 0x2, 0x2, 0x17d, 0x17b, 0x3, 0x2, 0x2, 0x2, 0x17e, - 0x189, 0x7, 0x24, 0x2, 0x2, 0x17f, 0x184, 0x7, 0x29, 0x2, 0x2, 0x180, - 0x183, 0x5, 0xf1, 0x79, 0x2, 0x181, 0x183, 0x5, 0x67, 0x34, 0x2, 0x182, - 0x180, 0x3, 0x2, 0x2, 0x2, 0x182, 0x181, 0x3, 0x2, 0x2, 0x2, 0x183, - 0x186, 0x3, 0x2, 0x2, 0x2, 0x184, 0x182, 0x3, 0x2, 0x2, 0x2, 0x184, - 0x185, 0x3, 0x2, 0x2, 0x2, 0x185, 0x187, 0x3, 0x2, 0x2, 0x2, 0x186, - 0x184, 0x3, 0x2, 0x2, 0x2, 0x187, 0x189, 0x7, 0x29, 0x2, 0x2, 0x188, - 0x176, 0x3, 0x2, 0x2, 0x2, 0x188, 0x17f, 0x3, 0x2, 0x2, 0x2, 0x189, - 0x66, 0x3, 0x2, 0x2, 0x2, 0x18a, 0x19c, 0x7, 0x5e, 0x2, 0x2, 0x18b, - 0x19d, 0x9, 0x2, 0x2, 0x2, 0x18c, 0x18d, 0x9, 0x3, 0x2, 0x2, 0x18d, - 0x18e, 0x5, 0x71, 0x39, 0x2, 0x18e, 0x18f, 0x5, 0x71, 0x39, 0x2, 0x18f, - 0x190, 0x5, 0x71, 0x39, 0x2, 0x190, 0x191, 0x5, 0x71, 0x39, 0x2, 0x191, - 0x19d, 0x3, 0x2, 0x2, 0x2, 0x192, 0x193, 0x9, 0x3, 0x2, 0x2, 0x193, - 0x194, 0x5, 0x71, 0x39, 0x2, 0x194, 0x195, 0x5, 0x71, 0x39, 0x2, 0x195, - 0x196, 0x5, 0x71, 0x39, 0x2, 0x196, 0x197, 0x5, 0x71, 0x39, 0x2, 0x197, - 0x198, 0x5, 0x71, 0x39, 0x2, 0x198, 0x199, 0x5, 0x71, 0x39, 0x2, 0x199, - 0x19a, 0x5, 0x71, 0x39, 0x2, 0x19a, 0x19b, 0x5, 0x71, 0x39, 0x2, 0x19b, - 0x19d, 0x3, 0x2, 0x2, 0x2, 0x19c, 0x18b, 0x3, 0x2, 0x2, 0x2, 0x19c, - 0x18c,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0x2, 0x2, 0x201, 0x202, 0x9, 0xa, 0x2, 0x2, 0x202, 0x203, 0x9, - 0xa, 0x2, 0x2, 0x203, 0x84, 0x3, 0x2, 0x2, 0x2, 0x204, 0x205, 0x9, 0x8, - 0x2, 0x2, 0x205, 0x206, 0x9, 0xb, 0x2, 0x2, 0x206, 0x207, 0x9, 0xc, - 0x2, 0x2, 0x207, 0x208, 0x9, 0x7, 0x2, 0x2, 0x208, 0x209, 0x9, 0x8, - 0x2, 0x2, 0x209, 0x20a, 0x9, 0x6, 0x2, 0x2, 0x20a, 0x20b, 0x9, 0x9, - 0x2, 0x2, 0x20b, 0x20c, 0x9, 0xa, 0x2, 0x2, 0x20c, 0x86, 0x3, 0x2, 0x2, - 0x2, 0x20d, 0x20e, 0x9, 0xd, 0x2, 0x2, 0x20e, 0x20f, 0x9, 0x9, 0x2, - 0x2, 0x20f, 0x210, 0x9, 0xc, 0x2, 0x2, 0x210, 0x211, 0x9, 0xe, 0x2, - 0x2, 0x211, 0x212, 0x9, 0xf, 0x2, 0x2, 0x212, 0x88, 0x3, 0x2, 0x2, 0x2, - 0x213, 0x214, 0x9, 0x3, 0x2, 0x2, 0x214, 0x215, 0x9, 0x6, 0x2, 0x2, - 0x215, 0x216, 0x9, 0x10, 0x2, 0x2, 0x216, 0x217, 0x9, 0x7, 0x2, 0x2, - 0x217, 0x218, 0x9, 0x6, 0x2, 0x2, 0x218, 0x219, 0x9, 0x11, 0x2, 0x2, - 0x219, 0x8a, 0x3, 0x2, 0x2, 0x2, 0x21a, 0x21b, 0x9, 0x9, 0x2, 0x2, 0x21b, - 0x21c, 0x9, 0x12, 0x2, 0x2, 0x21c, 0x8c, 0x3, 0x2, 0x2, 0x2, 0x21d, - 0x21e, 0x9, 0xd, 0x2, 0x2, 0x21e, 0x21f, 0x9, 0x5, 0x2, 0x2, 0x21f, - 0x220, 0x9, 0x13, 0x2, 0x2, 0x220, 0x221, 0x9, 0x14, 0x2, 0x2, 0x221, - 0x222, 0x9, 0x5, 0x2, 0x2, 0x222, 0x8e, 0x3, 0x2, 0x2, 0x2, 0x223, 0x224, - 0x9, 0x8, 0x2, 0x2, 0x224, 0x225, 0x9, 0x6, 0x2, 0x2, 0x225, 0x90, 0x3, - 0x2, 0x2, 0x2, 0x226, 0x227, 0x9, 0xe, 0x2, 0x2, 0x227, 0x228, 0x9, - 0x13, 0x2, 0x2, 0x228, 0x229, 0x9, 0x5, 0x2, 0x2, 0x229, 0x22a, 0x9, - 0x9, 0x2, 0x2, 0x22a, 0x22b, 0x9, 0xc, 0x2, 0x2, 0x22b, 0x22c, 0x9, - 0x5, 0x2, 0x2, 0x22c, 0x92, 0x3, 0x2, 0x2, 0x2, 0x22d, 0x22e, 0x9, 0x12, - 0x2, 0x2, 0x22e, 0x22f, 0x9, 0x5, 0x2, 0x2, 0x22f, 0x230, 0x9, 0xc, - 0x2, 0x2, 0x230, 0x94, 0x3, 0x2, 0x2, 0x2, 0x231, 0x232, 0x9, 0x11, - 0x2, 0x2, 0x232, 0x233, 0x9, 0x5, 0x2, 0x2, 0x233, 0x234, 0x9, 0xc, - 0x2, 0x2, 0x234, 0x235, 0x9, 0x9, 0x2, 0x2, 0x235, 0x236, 0x9, 0xe, - 0x2, 0x2, 0x236, 0x237, 0x9, 0xf, 0x2, 0x2, 0x237, 0x96, 0x3, 0x2, 0x2, - 0x2, 0x238, 0x239, 0x9, 0x11, 0x2, 0x2, 0x239, 0x23a, 0x9, 0x5, 0x2, - 0x2, 0x23a, 0x23b, 0x9, 0xa, 0x2, 0x2, 0x23b, 0x23c, 0x9, 0x5, 0x2, - 0x2, 0x23c, 0x23d, 0x9, 0xc, 0x2, 0x2, 0x23d, 0x23e, 0x9, 0x5, 0x2, - 0x2, 0x23e, 0x98, 0x3, 0x2, 0x2, 0x2, 0x23f, 0x240, 0x9, 0x13, 0x2, - 0x2, 0x240, 0x241, 0x9, 0x5, 0x2, 0x2, 0x241, 0x242, 0x9, 0xd, 0x2, - 0x2, 0x242, 0x243, 0x9, 0x8, 0x2, 0x2, 0x243, 0x244, 0x9, 0x15, 0x2, - 0x2, 0x244, 0x245, 0x9, 0x5, 0x2, 0x2, 0x245, 0x9a, 0x3, 0x2, 0x2, 0x2, - 0x246, 0x247, 0x9, 0x10, 0x2, 0x2, 0x247, 0x248, 0x9, 0x7, 0x2, 0x2, - 0x248, 0x249, 0x9, 0xc, 0x2, 0x2, 0x249, 0x24a, 0x9, 0xf, 0x2, 0x2, - 0x24a, 0x9c, 0x3, 0x2, 0x2, 0x2, 0x24b, 0x24c, 0x9, 0x11, 0x2, 0x2, - 0x24c, 0x24d, 0x9, 0x7, 0x2, 0x2, 0x24d, 0x24e, 0x9, 0x12, 0x2, 0x2, - 0x24e, 0x24f, 0x9, 0xc, 0x2, 0x2, 0x24f, 0x250, 0x9, 0x7, 0x2, 0x2, - 0x250, 0x251, 0x9, 0x6, 0x2, 0x2, 0x251, 0x252, 0x9, 0xe, 0x2, 0x2, - 0x252, 0x253, 0x9, 0xc, 0x2, 0x2, 0x253, 0x9e, 0x3, 0x2, 0x2, 0x2, 0x254, - 0x255, 0x9, 0x13, 0x2, 0x2, 0x255, 0x256, 0x9, 0x5, 0x2, 0x2, 0x256, - 0x257, 0x9, 0xc, 0x2, 0x2, 0x257, 0x258, 0x9, 0x3, 0x2, 0x2, 0x258, - 0x259, 0x9, 0x13, 0x2, 0x2, 0x259, 0x25a, 0x9, 0x6, 0x2, 0x2, 0x25a, - 0xa0, 0x3, 0x2, 0x2, 0x2, 0x25b, 0x25c, 0x9, 0x8, 0x2, 0x2, 0x25c, 0x25d, - 0x9, 0x13, 0x2, 0x2, 0x25d, 0x25e, 0x9, 0x11, 0x2, 0x2, 0x25e, 0x25f, - 0x9, 0x5, 0x2, 0x2, 0x25f, 0x260, 0x9, 0x13, 0x2, 0x2, 0x260, 0xa2, - 0x3, 0x2, 0x2, 0x2, 0x261, 0x262, 0x9, 0x16, 0x2, 0x2, 0x262, 0x263, - 0x9, 0x17, 0x2, 0x2, 0x263, 0xa4, 0x3, 0x2, 0x2, 0x2, 0x264, 0x265, - 0x9, 0x12, 0x2, 0x2, 0x265, 0x266, 0x9, 0x18, 0x2, 0x2, 0x266, 0x267, - 0x9, 0x7, 0x2, 0x2, 0x267, 0x268, 0x9, 0xb, 0x2, 0x2, 0x268, 0xa6, 0x3, - 0x2, 0x2, 0x2, 0x269, 0x26a, 0x9, 0xa, 0x2, 0x2, 0x26a, 0x26b, 0x9, - 0x7, 0x2, 0x2, 0x26b, 0x26c, 0x9, 0xd, 0x2, 0x2, 0x26c, 0x26d, 0x9, - 0x7, 0x2, 0x2, 0x26d, 0x26e, 0x9, 0xc, 0x2, 0x2, 0x26e, 0xa8, 0x3, 0x2, - 0x2, 0x2, 0x26f, 0x270, 0x9, 0x9, 0x2, 0x2, 0x270, 0x271, 0x9, 0x12, - 0x2, 0x2, 0x271, 0x272, 0x9, 0xe, 0x2, 0x2, 0x272, 0x273, 0x9, 0x5, - 0x2, 0x2, 0x273, 0x274, 0x9, 0x6, 0x2, 0x2, 0x274, 0x275, 0x9, 0x11, - 0x2, 0x2, 0x275, 0x276, 0x9, 0x7, 0x2, 0x2, 0x276, 0x277, 0x9, 0x6, - 0x2, 0x2, 0x277, 0x278, 0x9, 0x14, 0x2, 0x2, 0x278, 0xaa, 0x3, 0x2, - 0x2, 0x2, 0x279, 0x27a, 0x9, 0x9, 0x2, 0x2, 0x27a, 0x27b, 0x9, 0x12, - 0x2, 0x2, 0x27b, 0x27c, 0x9, 0xe, 0x2, 0x2, 0x27c, 0xac, 0x3, 0x2, 0x2, - 0x2, 0x27d, 0x27e, 0x9, 0x11, 0x2, 0x2, 0x27e, 0x27f, 0x9, 0x5, 0x2, - 0x2, 0x27f, 0x280, 0x9, 0x12, 0x2, 0x2, 0x280, 0x281, 0x9, 0xe, 0x2, - 0x2, 0x281, 0x282, 0x9, 0x5, 0x2, 0x2, 0x282, 0x283, 0x9, 0x6, 0x2, - 0x2, 0x283, 0x284, 0x9, 0x11, 0x2, 0x2, 0x284, 0x285, 0x9, 0x7, 0x2, - 0x2, 0x285, 0x286, 0x9, 0x6, 0x2, 0x2, 0x286, 0x287, 0x9, 0x14, 0x2, - 0x2, 0x287, 0xae, 0x3, 0x2, 0x2, 0x2, 0x288, 0x289, 0x9, 0x11, 0x2, - 0x2, 0x289, 0x28a, 0x9, 0x5, 0x2, 0x2, 0x28a, 0x28b, 0x9, 0x12, 0x2, - 0x2, 0x28b, 0x28c, 0x9, 0xe, 0x2, 0x2, 0x28c, 0xb0, 0x3, 0x2, 0x2, 0x2, - 0x28d, 0x28e, 0x9, 0x10, 0x2, 0x2, 0x28e, 0x28f, 0x9, 0xf, 0x2, 0x2, - 0x28f, 0x290, 0x9, 0x5, 0x2, 0x2, 0x290, 0x291, 0x9, 0x13, 0x2, 0x2, - 0x291, 0x292, 0x9, 0x5, 0x2, 0x2, 0x292, 0xb2, 0x3, 0x2, 0x2, 0x2, 0x293, - 0x294, 0x9, 0x8, 0x2, 0x2, 0x294, 0x295, 0x9, 0x13, 0x2, 0x2, 0x295, - 0xb4, 0x3, 0x2, 0x2, 0x2, 0x296, 0x297, 0x9, 0x19, 0x2, 0x2, 0x297, - 0x298, 0x9, 0x8, 0x2, 0x2, 0x298, 0x299, 0x9, 0x13, 0x2, 0x2, 0x299, - 0xb6, 0x3, 0x2, 0x2, 0x2, 0x29a, 0x29b, 0x9, 0x9, 0x2, 0x2, 0x29b, 0x29c, - 0x9, 0x6, 0x2, 0x2, 0x29c, 0x29d, 0x9, 0x11, 0x2, 0x2, 0x29d, 0xb8, - 0x3, 0x2, 0x2, 0x2, 0x29e, 0x29f, 0x9, 0x6, 0x2, 0x2, 0x29f, 0x2a0, - 0x9, 0x8, 0x2, 0x2, 0x2a0, 0x2a1, 0x9, 0xc, 0x2, 0x2, 0x2a1, 0xba, 0x3, - 0x2, 0x2, 0x2, 0x2a2, 0x2a3, 0x9, 0x7, 0x2, 0x2, 0x2a3, 0x2a4, 0x9, - 0x6, 0x2, 0x2,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2, 0x2, 0x2, 0x2fc, 0xda, 0x3, 0x2, 0x2, 0x2, 0x2fd, - 0x300, 0x5, 0xed, 0x77, 0x2, 0x2fe, 0x300, 0x5, 0xfd, 0x7f, 0x2, 0x2ff, - 0x2fd, 0x3, 0x2, 0x2, 0x2, 0x2ff, 0x2fe, 0x3, 0x2, 0x2, 0x2, 0x300, - 0xdc, 0x3, 0x2, 0x2, 0x2, 0x301, 0x305, 0x7, 0x62, 0x2, 0x2, 0x302, - 0x304, 0x5, 0xe9, 0x75, 0x2, 0x303, 0x302, 0x3, 0x2, 0x2, 0x2, 0x304, - 0x307, 0x3, 0x2, 0x2, 0x2, 0x305, 0x303, 0x3, 0x2, 0x2, 0x2, 0x305, - 0x306, 0x3, 0x2, 0x2, 0x2, 0x306, 0x308, 0x3, 0x2, 0x2, 0x2, 0x307, - 0x305, 0x3, 0x2, 0x2, 0x2, 0x308, 0x30a, 0x7, 0x62, 0x2, 0x2, 0x309, - 0x301, 0x3, 0x2, 0x2, 0x2, 0x30a, 0x30b, 0x3, 0x2, 0x2, 0x2, 0x30b, - 0x309, 0x3, 0x2, 0x2, 0x2, 0x30b, 0x30c, 0x3, 0x2, 0x2, 0x2, 0x30c, - 0xde, 0x3, 0x2, 0x2, 0x2, 0x30d, 0x30f, 0x5, 0xe1, 0x71, 0x2, 0x30e, - 0x30d, 0x3, 0x2, 0x2, 0x2, 0x30f, 0x310, 0x3, 0x2, 0x2, 0x2, 0x310, - 0x30e, 0x3, 0x2, 0x2, 0x2, 0x310, 0x311, 0x3, 0x2, 0x2, 0x2, 0x311, - 0xe0, 0x3, 0x2, 0x2, 0x2, 0x312, 0x31f, 0x5, 0xff, 0x80, 0x2, 0x313, - 0x31f, 0x5, 0x101, 0x81, 0x2, 0x314, 0x31f, 0x5, 0x105, 0x83, 0x2, 0x315, - 0x31f, 0x5, 0x107, 0x84, 0x2, 0x316, 0x31f, 0x5, 0xe7, 0x74, 0x2, 0x317, - 0x31f, 0x5, 0xfb, 0x7e, 0x2, 0x318, 0x31f, 0x5, 0xf9, 0x7d, 0x2, 0x319, - 0x31f, 0x5, 0xf7, 0x7c, 0x2, 0x31a, 0x31f, 0x5, 0xeb, 0x76, 0x2, 0x31b, - 0x31f, 0x5, 0x109, 0x85, 0x2, 0x31c, 0x31f, 0x9, 0x1c, 0x2, 0x2, 0x31d, - 0x31f, 0x5, 0xe3, 0x72, 0x2, 0x31e, 0x312, 0x3, 0x2, 0x2, 0x2, 0x31e, - 0x313, 0x3, 0x2, 0x2, 0x2, 0x31e, 0x314, 0x3, 0x2, 0x2, 0x2, 0x31e, - 0x315, 0x3, 0x2, 0x2, 0x2, 0x31e, 0x316, 0x3, 0x2, 0x2, 0x2, 0x31e, - 0x317, 0x3, 0x2, 0x2, 0x2, 0x31e, 0x318, 0x3, 0x2, 0x2, 0x2, 0x31e, - 0x319, 0x3, 0x2, 0x2, 0x2, 0x31e, 0x31a, 0x3, 0x2, 0x2, 0x2, 0x31e, - 0x31b, 0x3, 0x2, 0x2, 0x2, 0x31e, 0x31c, 0x3, 0x2, 0x2, 0x2, 0x31e, - 0x31d, 0x3, 0x2, 0x2, 0x2, 0x31f, 0xe2, 0x3, 0x2, 0x2, 0x2, 0x320, 0x321, - 0x7, 0x31, 0x2, 0x2, 0x321, 0x322, 0x7, 0x2c, 0x2, 0x2, 0x322, 0x328, - 0x3, 0x2, 0x2, 0x2, 0x323, 0x327, 0x5, 0xef, 0x78, 0x2, 0x324, 0x325, - 0x7, 0x2c, 0x2, 0x2, 0x325, 0x327, 0x5, 0xf5, 0x7b, 0x2, 0x326, 0x323, - 0x3, 0x2, 0x2, 0x2, 0x326, 0x324, 0x3, 0x2, 0x2, 0x2, 0x327, 0x32a, - 0x3, 0x2, 0x2, 0x2, 0x328, 0x326, 0x3, 0x2, 0x2, 0x2, 0x328, 0x329, - 0x3, 0x2, 0x2, 0x2, 0x329, 0x32b, 0x3, 0x2, 0x2, 0x2, 0x32a, 0x328, - 0x3, 0x2, 0x2, 0x2, 0x32b, 0x32c, 0x7, 0x2c, 0x2, 0x2, 0x32c, 0x339, - 0x7, 0x31, 0x2, 0x2, 0x32d, 0x32e, 0x7, 0x31, 0x2, 0x2, 0x32e, 0x32f, - 0x7, 0x31, 0x2, 0x2, 0x32f, 0x330, 0x3, 0x2, 0x2, 0x2, 0x330, 0x332, - 0x5, 0xf3, 0x7a, 0x2, 0x331, 0x333, 0x5, 0xfb, 0x7e, 0x2, 0x332, 0x331, - 0x3, 0x2, 0x2, 0x2, 0x332, 0x333, 0x3, 0x2, 0x2, 0x2, 0x333, 0x336, - 0x3, 0x2, 0x2, 0x2, 0x334, 0x337, 0x5, 0x105, 0x83, 0x2, 0x335, 0x337, - 0x7, 0x2, 0x2, 0x3, 0x336, 0x334, 0x3, 0x2, 0x2, 0x2, 0x336, 0x335, - 0x3, 0x2, 0x2, 0x2, 0x337, 0x339, 0x3, 0x2, 0x2, 0x2, 0x338, 0x320, - 0x3, 0x2, 0x2, 0x2, 0x338, 0x32d, 0x3, 0x2, 0x2, 0x2, 0x339, 0xe4, 0x3, - 0x2, 0x2, 0x2, 0x33a, 0x33b, 0x4, 0x32, 0x32, 0x2, 0x33b, 0x33c, 0x9, - 0x19, 0x2, 0x2, 0x33c, 0xe6, 0x3, 0x2, 0x2, 0x2, 0x33d, 0x33e, 0x9, - 0x1d, 0x2, 0x2, 0x33e, 0xe8, 0x3, 0x2, 0x2, 0x2, 0x33f, 0x340, 0x9, - 0x1e, 0x2, 0x2, 0x340, 0xea, 0x3, 0x2, 0x2, 0x2, 0x341, 0x342, 0x9, - 0x1f, 0x2, 0x2, 0x342, 0xec, 0x3, 0x2, 0x2, 0x2, 0x343, 0x344, 0x9, - 0x20, 0x2, 0x2, 0x344, 0xee, 0x3, 0x2, 0x2, 0x2, 0x345, 0x346, 0x9, - 0x21, 0x2, 0x2, 0x346, 0xf0, 0x3, 0x2, 0x2, 0x2, 0x347, 0x348, 0x9, - 0x22, 0x2, 0x2, 0x348, 0xf2, 0x3, 0x2, 0x2, 0x2, 0x349, 0x34a, 0x9, - 0x23, 0x2, 0x2, 0x34a, 0xf4, 0x3, 0x2, 0x2, 0x2, 0x34b, 0x34c, 0x9, - 0x24, 0x2, 0x2, 0x34c, 0xf6, 0x3, 0x2, 0x2, 0x2, 0x34d, 0x34e, 0x9, - 0x25, 0x2, 0x2, 0x34e, 0xf8, 0x3, 0x2, 0x2, 0x2, 0x34f, 0x350, 0x9, - 0x26, 0x2, 0x2, 0x350, 0xfa, 0x3, 0x2, 0x2, 0x2, 0x351, 0x352, 0x9, - 0x27, 0x2, 0x2, 0x352, 0xfc, 0x3, 0x2, 0x2, 0x2, 0x353, 0x354, 0x9, - 0x28, 0x2, 0x2, 0x354, 0xfe, 0x3, 0x2, 0x2, 0x2, 0x355, 0x356, 0x9, - 0x29, 0x2, 0x2, 0x356, 0x100, 0x3, 0x2, 0x2, 0x2, 0x357, 0x358, 0x9, - 0x2a, 0x2, 0x2, 0x358, 0x102, 0x3, 0x2, 0x2, 0x2, 0x359, 0x35a, 0x9, - 0x2b, 0x2, 0x2, 0x35a, 0x104, 0x3, 0x2, 0x2, 0x2, 0x35b, 0x35c, 0x9, - 0x2c, 0x2, 0x2, 0x35c, 0x106, 0x3, 0x2, 0x2, 0x2, 0x35d, 0x35e, 0x9, - 0x2d, 0x2, 0x2, 0x35e, 0x108, 0x3, 0x2, 0x2, 0x2, 0x35f, 0x360, 0x9, - 0x2e, 0x2, 0x2, 0x360, 0x10a, 0x3, 0x2, 0x2, 0x2, 0x361, 0x362, 0x9, - 0x2f, 0x2, 0x2, 0x362, 0x10c, 0x3, 0x2, 0x2, 0x2, 0x28, 0x2, 0x179, - 0x17b, 0x182, 0x184, 0x188, 0x19c, 0x1a2, 0x1a9, 0x1ac, 0x1b2, 0x1b5, - 0x1b9, 0x1bd, 0x1c1, 0x1c7, 0x1ce, 0x1d3, 0x1d9, 0x1df, 0x1e1, 0x1e4, - 0x1e7, 0x1ec, 0x1f1, 0x1f8, 0x2f6, 0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 0x3, 0x75, 0x3, 0x76, 0x3, + 0x76, 0x3, 0x77, 0x3, 0x77, 0x3, 0x78, 0x3, 0x78, + 0x3, 0x79, 0x3, 0x79, 0x3, 0x7a, 0x3, 0x7a, 0x3, + 0x7b, 0x3, 0x7b, 0x3, 0x7c, 0x3, 0x7c, 0x3, 0x7d, + 0x3, 0x7d, 0x3, 0x7e, 0x3, 0x7e, 0x3, 0x7f, 0x3, + 0x7f, 0x3, 0x80, 0x3, 0x80, 0x3, 0x81, 0x3, 0x81, + 0x3, 0x82, 0x3, 0x82, 0x3, 0x83, 0x3, 0x83, 0x3, + 0x84, 0x3, 0x84, 0x3, 0x85, 0x3, 0x85, 0x3, 0x86, + 0x3, 0x86, 0x2, 0x2, 0x87, 0x3, 0x3, 0x5, 0x4, + 0x7, 0x5, 0x9, 0x6, 0xb, 0x7, 0xd, 0x8, 0xf, + 0x9, 0x11, 0xa, 0x13, 0xb, 0x15, 0xc, 0x17, 0xd, + 0x19, 0xe, 0x1b, 0xf, 0x1d, 0x10, 0x1f, 0x11, 0x21, + 0x12, 0x23, 0x13, 0x25, 0x14, 0x27, 0x15, 0x29, 0x16, + 0x2b, 0x17, 0x2d, 0x18, 0x2f, 0x19, 0x31, 0x1a, 0x33, + 0x1b, 0x35, 0x1c, 0x37, 0x1d, 0x39, 0x1e, 0x3b, 0x1f, + 0x3d, 0x20, 0x3f, 0x21, 0x41, 0x22, 0x43, 0x23, 0x45, + 0x24, 0x47, 0x25, 0x49, 0x26, 0x4b, 0x27, 0x4d, 0x28, + 0x4f, 0x29, 0x51, 0x2a, 0x53, 0x2b, 0x55, 0x2c, 0x57, + 0x2d, 0x59, 0x2e, 0x5b, 0x2f, 0x5d, 0x30, 0x5f, 0x31, + 0x61, 0x32, 0x63, 0x33, 0x65, 0x34, 0x67, 0x35, 0x69, + 0x36, 0x6b, 0x37, 0x6d, 0x38, 0x6f, 0x39, 0x71, 0x3a, + 0x73, 0x3b, 0x75, 0x3c, 0x77, 0x3d, 0x79, 0x3e, 0x7b, + 0x3f, 0x7d, 0x40, 0x7f, 0x41, 0x81, 0x42, 0x83, 0x43, + 0x85, 0x44, 0x87, 0x45, 0x89, 0x46, 0x8b, 0x47, 0x8d, + 0x48, 0x8f, 0x49, 0x91, 0x4a, 0x93, 0x4b, 0x95, 0x4c, + 0x97, 0x4d, 0x99, 0x4e, 0x9b, 0x4f, 0x9d, 0x50, 0x9f, + 0x51, 0xa1, 0x52, 0xa3, 0x53, 0xa5, 0x54, 0xa7, 0x55, + 0xa9, 0x56, 0xab, 0x57, 0xad, 0x58, 0xaf, 0x59, 0xb1, + 0x5a, 0xb3, 0x5b, 0xb5, 0x5c, 0xb7, 0x5d, 0xb9, 0x5e, + 0xbb, 0x5f, 0xbd, 0x60, 0xbf, 0x61, 0xc1, 0x62, 0xc3, + 0x63, 0xc5, 0x64, 0xc7, 0x65, 0xc9, 0x66, 0xcb, 0x67, + 0xcd, 0x68, 0xcf, 0x69, 0xd1, 0x6a, 0xd3, 0x6b, 0xd5, + 0x6c, 0xd7, 0x6d, 0xd9, 0x6e, 0xdb, 0x6f, 0xdd, 0x70, + 0xdf, 0x71, 0xe1, 0x72, 0xe3, 0x73, 0xe5, 0x74, 0xe7, + 0x2, 0xe9, 0x2, 0xeb, 0x2, 0xed, 0x2, 0xef, 0x2, + 0xf1, 0x2, 0xf3, 0x2, 0xf5, 0x2, 0xf7, 0x2, 0xf9, + 0x2, 0xfb, 0x2, 0xfd, 0x2, 0xff, 0x2, 0x101, 0x2, + 0x103, 0x2, 0x105, 0x2, 0x107, 0x2, 0x109, 0x2, 0x10b, + 0x2, 0x3, 0x2, 0x30, 0x11, 0x2, 0x24, 0x24, 0x27, + 0x27, 0x29, 0x29, 0x44, 0x44, 0x48, 0x48, 0x50, 0x50, + 0x54, 0x54, 0x56, 0x56, 0x5e, 0x5e, 0x61, 0x61, 0x64, + 0x64, 0x68, 0x68, 0x70, 0x70, 0x74, 0x74, 0x76, 0x76, + 0x4, 0x2, 0x57, 0x57, 0x77, 0x77, 0x4, 0x2, 0x43, + 0x48, 0x63, 0x68, 0x4, 0x2, 0x47, 0x47, 0x67, 0x67, + 0x4, 0x2, 0x50, 0x50, 0x70, 0x70, 0x4, 0x2, 0x4b, + 0x4b, 0x6b, 0x6b, 0x4, 0x2, 0x51, 0x51, 0x71, 0x71, + 0x4, 0x2, 0x43, 0x43, 0x63, 0x63, 0x4, 0x2, 0x4e, + 0x4e, 0x6e, 0x6e, 0x4, 0x2, 0x52, 0x52, 0x72, 0x72, + 0x4, 0x2, 0x56, 0x56, 0x76, 0x76, 0x4, 0x2, 0x4f, + 0x4f, 0x6f, 0x6f, 0x4, 0x2, 0x45, 0x45, 0x65, 0x65, + 0x4, 0x2, 0x4a, 0x4a, 0x6a, 0x6a, 0x4, 0x2, 0x59, + 0x59, 0x79, 0x79, 0x4, 0x2, 0x46, 0x46, 0x66, 0x66, + 0x4, 0x2, 0x55, 0x55, 0x75, 0x75, 0x4, 0x2, 0x54, + 0x54, 0x74, 0x74, 0x4, 0x2, 0x49, 0x49, 0x69, 0x69, + 0x4, 0x2, 0x58, 0x58, 0x78, 0x78, 0x4, 0x2, 0x44, + 0x44, 0x64, 0x64, 0x4, 0x2, 0x5b, 0x5b, 0x7b, 0x7b, + 0x4, 0x2, 0x4d, 0x4d, 0x6d, 0x6d, 0x4, 0x2, 0x5a, + 0x5a, 0x7a, 0x7a, 0x4, 0x2, 0x48, 0x48, 0x68, 0x68, + 0x8, 0x2, 0x61, 0x61, 0x2041, 0x2042, 0x2056, 0x2056, 0xfe35, + 0xfe36, 0xfe4f, 0xfe51, 0xff41, 0xff41, 0xa, 0x2, 0xa2, 0xa2, + 0x1682, 0x1682, 0x1810, 0x1810, 0x2002, 0x200c, 0x202a, 0x202b, 0x2031, + 0x2031, 0x2061, 0x2061, 0x3002, 0x3002, 0x3, 0x2, 0xe, 0xe, + 0x4, 0x2, 0x2, 0x61, 0x63, 0x1, 0x3, 0x2, 0x20, + 0x20, 0x1af, 0x2, 0x32, 0x3b, 0x43, 0x5c, 0x61, 0x61, + 0x63, 0x7c, 0xac, 0xac, 0xb7, 0xb7, 0xb9, 0xb9, 0xbc, + 0xbc, 0xc2, 0xd8, 0xda, 0xf8, 0xfa, 0x2c3, 0x2c8, 0x2d3, + 0x2e2, 0x2e6, 0x2ee, 0x2ee, 0x2f0, 0x2f0, 0x302, 0x376, 0x378, + 0x379, 0x37c, 0x37f, 0x388, 0x38c, 0x38e, 0x38e, 0x390, 0x3a3, + 0x3a5, 0x3f7, 0x3f9, 0x483, 0x485, 0x489, 0x48c, 0x529, 0x533, + 0x558, 0x55b, 0x55b, 0x563, 0x589, 0x593, 0x5bf, 0x5c1, 0x5c1, + 0x5c3, 0x5c4, 0x5c6, 0x5c7, 0x5c9, 0x5c9, 0x5d2, 0x5ec, 0x5f2, + 0x5f4, 0x612, 0x61c, 0x622, 0x66b, 0x670, 0x6d5, 0x6d7, 0x6de, + 0x6e1, 0x6ea, 0x6ec, 0x6fe, 0x701, 0x701, 0x712, 0x74c, 0x74f, + 0x7b3, 0x7c2, 0x7f7, 0x7fc, 0x7fc, 0x802, 0x82f, 0x842, 0x85d, + 0x8a2, 0x8a2, 0x8a4, 0x8ae, 0x8e6, 0x900, 0x902, 0x965, 0x968, + 0x971, 0x973, 0x979, 0x97b, 0x981, 0x983, 0x985, 0x987, 0x98e, + 0x991, 0x992, 0x995, 0x9aa, 0x9ac, 0x9b2, 0x9b4, 0x9b4, 0x9b8, + 0x9bb, 0x9be, 0x9c6, 0x9c9, 0x9ca, 0x9cd, 0x9d0, 0x9d9, 0x9d9, + 0x9de, 0x9df, 0x9e1, 0x9e5, 0x9e8, 0x9f3, 0xa03, 0xa05, 0xa07, + 0xa0c, 0xa11, 0xa12, 0xa15, 0xa2a, 0xa2c, 0xa32, 0xa34, 0xa35, + 0xa37, 0xa38, 0xa3a, 0xa3b, 0xa3e, 0xa3e, 0xa40, 0xa44, 0xa49, + 0xa4a, 0xa4d, 0xa4f, 0xa53, 0xa53, 0xa5b, 0xa5e, 0xa60, 0xa60, + 0xa68, 0xa77, 0xa83, 0xa85, 0xa87, 0xa8f, 0xa91, 0xa93, 0xa95, + 0xaaa, 0xaac, 0xab2, 0xab4, 0xab5, 0xab7, 0xabb, 0xabe, 0xac7, + 0xac9, 0xacb, 0xacd, 0xacf, 0xad2, 0xad2, 0xae2, 0xae5, 0xae8, + 0xaf1, 0xb03, 0xb05, 0xb07, 0xb0e, 0xb11, 0xb12, 0xb15, 0xb2a, + 0xb2c, 0xb32, 0xb34, 0xb35, 0xb37, 0xb3b, 0xb3e, 0xb46, 0xb49, + 0xb4a, 0xb4d, 0xb4f, 0xb58, 0xb59, 0xb5e, 0xb5f, 0xb61, 0xb65, + 0xb68, 0xb71, 0xb73, 0xb73, 0xb84, 0xb85, 0xb87, 0xb8c, 0xb90, + 0xb92, 0xb94, 0xb97, 0xb9b, 0xb9c, 0xb9e, 0xb9e, 0xba0, 0xba1, + 0xba5, 0xba6, 0xbaa, 0xbac, 0xbb0, 0xbbb, 0xbc0, 0xbc4, 0xbc8, + 0xbca, 0xbcc, 0xbcf, 0xbd2, 0xbd2, 0xbd9, 0xbd9, 0xbe8, 0xbf1, + 0xc03, 0xc05, 0xc07, 0xc0e, 0xc10, 0xc12, 0xc14, 0xc2a, 0xc2c, + 0xc35, 0xc37, 0xc3b, 0xc3f, 0xc46, 0xc48, 0xc4a, 0xc4c, 0xc4f, + 0xc57, 0xc58, 0xc5a, 0xc5b, 0xc62, 0xc65, 0xc68, 0xc71, 0xc84, + 0xc85, 0xc87, 0xc8e, 0xc90, 0xc92, 0xc94, 0xcaa, 0xcac, 0xcb5, + 0xcb7, 0xcbb, 0xcbe, 0xcc6, 0xcc8, 0xcca, 0xccc, 0xccf, 0xcd7, + 0xcd8, 0xce0, 0xce0, 0xce2, 0xce5, 0xce8, 0xcf1, 0xcf3, 0xcf4, + 0xd04, 0xd05, 0xd07, 0xd0e, 0xd10, 0xd12, 0xd14, 0xd3c, 0xd3f, + 0xd46, 0xd48, 0xd4a, 0xd4c, 0xd50, 0xd59, 0xd59, 0xd62, 0xd65, + 0xd68, 0xd71, 0xd7c, 0xd81, 0xd84, 0xd85, 0xd87, 0xd98, 0xd9c, + 0xdb3, 0xdb5, 0xdbd, 0xdbf, 0xdbf, 0xdc2, 0xdc8, 0xdcc, 0xdcc, + 0xdd1, 0xdd6, 0xdd8, 0xdd8, 0xdda, 0xde1, 0xdf4, 0xdf5, 0xe03, + 0xe3c, 0xe42, 0xe50, 0xe52, 0xe5b, 0xe83, 0xe84, 0xe86, 0xe86, + 0xe89, 0xe8a, 0xe8c, 0xe8c, 0xe8f, 0xe8f, 0xe96, 0xe99, 0xe9b, + 0xea1, 0xea3, 0xea5, 0xea7, 0xea7, 0xea9, 0xea9, 0xeac, 0xead, + 0xeaf, 0xebb, 0xebd, 0xebf, 0xec2, 0xec6, 0xec8, 0xec8, 0xeca, + 0xecf, 0xed2, 0xedb, 0xede, 0xee1, 0xf02, 0xf02, 0xf1a, 0xf1b, + 0xf22, 0xf2b, 0xf37, 0xf37, 0xf39, 0xf39, 0xf3b, 0xf3b, 0xf40, + 0xf49, 0xf4b, 0xf6e, 0xf73, 0xf86, 0xf88, 0xf99, 0xf9b, 0xfbe, + 0xfc8, 0xfc8, 0x1002, 0x104b, 0x1052, 0x109f, 0x10a2, 0x10c7, 0x10c9, + 0x10c9, 0x10cf, 0x10cf, 0x10d2, 0x10fc, 0x10fe, 0x124a, 0x124c, 0x124f, + 0x1252, 0x1258, 0x125a, 0x125a, 0x125c, 0x125f, 0x1262, 0x128a, 0x128c, + 0x128f, 0x1292, 0x12b2, 0x12b4, 0x12b7, 0x12ba, 0x12c0, 0x12c2, 0x12c2, + 0x12c4, 0x12c7, 0x12ca, 0x12d8, 0x12da, 0x1312, 0x1314, 0x1317, 0x131a, + 0x135c, 0x135f, 0x1361, 0x136b, 0x1373, 0x1382, 0x1391, 0x13a2, 0x13f6, + 0x1403, 0x166e, 0x1671, 0x1681, 0x1683, 0x169c, 0x16a2, 0x16ec, 0x16f0, + 0x16f2, 0x1702, 0x170e, 0x1710, 0x1716, 0x1722, 0x1736, 0x1742, 0x1755, + 0x1762, 0x176e, 0x1770, 0x1772, 0x1774, 0x1775, 0x1782, 0x17d5, 0x17d9, + 0x17d9, 0x17de, 0x17df, 0x17e2, 0x17eb, 0x180d, 0x180f, 0x1812, 0x181b, + 0x1822, 0x1879, 0x1882, 0x18ac, 0x18b2, 0x18f7, 0x1902, 0x191e, 0x1922, + 0x192d, 0x1932, 0x193d, 0x1948, 0x196f, 0x1972, 0x1976, 0x1982, 0x19ad, + 0x19b2, 0x19cb, 0x19d2, 0x19dc, 0x1a02, 0x1a1d, 0x1a22, 0x1a60, 0x1a62, + 0x1a7e, 0x1a81, 0x1a8b, 0x1a92, 0x1a9b, 0x1aa9, 0x1aa9, 0x1b02, 0x1b4d, + 0x1b52, 0x1b5b, 0x1b6d, 0x1b75, 0x1b82, 0x1bf5, 0x1c02, 0x1c39, 0x1c42, + 0x1c4b, 0x1c4f, 0x1c7f, 0x1cd2, 0x1cd4, 0x1cd6, 0x1cf8, 0x1d02, 0x1de8, + 0x1dfe, 0x1f17, 0x1f1a, 0x1f1f, 0x1f22, 0x1f47, 0x1f4a, 0x1f4f, 0x1f52, + 0x1f59, 0x1f5b, 0x1f5b, 0x1f5d, 0x1f5d, 0x1f5f, 0x1f5f, 0x1f61, 0x1f7f, + 0x1f82, 0x1fb6, 0x1fb8, 0x1fbe, 0x1fc0, 0x1fc0, 0x1fc4, 0x1fc6, 0x1fc8, + 0x1fce, 0x1fd2, 0x1fd5, 0x1fd8, 0x1fdd, 0x1fe2, 0x1fee, 0x1ff4, 0x1ff6, + 0x1ff8, 0x1ffe, 0x2041, 0x2042, 0x2056, 0x2056, 0x2073, 0x2073, 0x2081, + 0x2081, 0x2092, 0x209e, 0x20d2, 0x20de, 0x20e3, 0x20e3, 0x20e7, 0x20f2, + 0x2104, 0x2104, 0x2109, 0x2109, 0x210c, 0x2115, 0x2117, 0x2117, 0x211a, + 0x211f, 0x2126, 0x2126, 0x2128, 0x2128, 0x212a, 0x212a, 0x212c, 0x213b, + 0x213e, 0x2141, 0x2147, 0x214b, 0x2150, 0x2150, 0x2162, 0x218a, 0x2c02, + 0x2c30, 0x2c32, 0x2c60, 0x2c62, 0x2ce6, 0x2ced, 0x2cf5, 0x2d02, 0x2d27, + 0x2d29, 0x2d29, 0x2d2f, 0x2d2f, 0x2d32, 0x2d69, 0x2d71, 0x2d71, 0x2d81, + 0x2d98, 0x2da2, 0x2da8, 0x2daa, 0x2db0, 0x2db2, 0x2db8, 0x2dba, 0x2dc0, + 0x2dc2, 0x2dc8, 0x2dca, 0x2dd0, 0x2dd2, 0x2dd8, 0x2dda, 0x2de0, 0x2de2, + 0x2e01, 0x3007, 0x3009, 0x3023, 0x3031, 0x3033, 0x3037, 0x303a, 0x303e, + 0x3043, 0x3098, 0x309b, 0x30a1, 0x30a3, 0x30fc, 0x30fe, 0x3101, 0x3107, + 0x312f, 0x3133, 0x3190, 0x31a2, 0x31bc, 0x31f2, 0x3201, 0x3402, 0x4db7, + 0x4e02, 0x9fce, 0xa002, 0xa48e, 0xa4d2, 0xa4ff, 0xa502, 0xa60e, 0xa612, + 0xa62d, 0xa642, 0xa671, 0xa676, 0xa67f, 0xa681, 0xa699, 0xa6a1, 0xa6f3, + 0xa719, 0xa721, 0xa724, 0xa78a, 0xa78d, 0xa790, 0xa792, 0xa795, 0xa7a2, + 0xa7ac, 0xa7fa, 0xa829, 0xa842, 0xa875, 0xa882, 0xa8c6, 0xa8d2, 0xa8db, + 0xa8e2, 0xa8f9, 0xa8fd, 0xa8fd, 0xa902, 0xa92f, 0xa932, 0xa955, 0xa962, + 0xa97e, 0xa982, 0xa9c2, 0xa9d1, 0xa9db, 0xaa02, 0xaa38, 0xaa42, 0xaa4f, + 0xaa52, 0xaa5b, 0xaa62, 0xaa78, 0xaa7c, 0xaa7d, 0xaa82, 0xaac4, 0xaadd, + 0xaadf, 0xaae2, 0xaaf1, 0xaaf4, 0xaaf8, 0xab03, 0xab08, 0xab0b, 0xab10, + 0xab13, 0xab18, 0xab22, 0xab28, 0xab2a, 0xab30, 0xabc2, 0xabec, 0xabee, + 0xabef, 0xabf2, 0xabfb, 0xac02, 0xd7a5, 0xd7b2, 0xd7c8, 0xd7cd, 0xd7fd, + 0xf902, 0xfa6f, 0xfa72, 0xfadb, 0xfb02, 0xfb08, 0xfb15, 0xfb19, 0xfb1f, + 0xfb2a, 0xfb2c, 0xfb38, 0xfb3a, 0xfb3e, 0xfb40, 0xfb40, 0xfb42, 0xfb43, + 0xfb45, 0xfb46, 0xfb48, 0xfbb3, 0xfbd5, 0xfd3f, 0xfd52, 0xfd91, 0xfd94, + 0xfdc9, 0xfdf2, 0xfdfd, 0xfe02, 0xfe11, 0xfe22, 0xfe28, 0xfe35, 0xfe36, + 0xfe4f, 0xfe51, 0xfe72, 0xfe76, 0xfe78, 0xfefe, 0xff12, 0xff1b, 0xff23, + 0xff3c, 0xff41, 0xff41, 0xff43, 0xff5c, 0xff68, 0xffc0, 0xffc4, 0xffc9, + 0xffcc, 0xffd1, 0xffd4, 0xffd9, 0xffdc, 0xffde, 0x4, 0x2, 0x2, + 0x2b, 0x2d, 0x1, 0x5, 0x2, 0x2, 0x28, 0x2a, 0x5d, + 0x5f, 0x1, 0x5, 0x2, 0x2, 0xb, 0xd, 0xe, 0x10, + 0x1, 0x4, 0x2, 0x2, 0x30, 0x32, 0x1, 0x3, 0x2, + 0x1f, 0x1f, 0x3, 0x2, 0x1e, 0x1e, 0x3, 0x2, 0xf, + 0xf, 0x13, 0x2, 0x26, 0x26, 0xa4, 0xa7, 0x591, 0x591, + 0x60d, 0x60d, 0x9f4, 0x9f5, 0x9fd, 0x9fd, 0xaf3, 0xaf3, 0xbfb, + 0xbfb, 0xe41, 0xe41, 0x17dd, 0x17dd, 0x20a2, 0x20bc, 0xa83a, 0xa83a, + 0xfdfe, 0xfdfe, 0xfe6b, 0xfe6b, 0xff06, 0xff06, 0xffe2, 0xffe3, 0xffe7, + 0xffe8, 0x3, 0x2, 0x22, 0x22, 0x3, 0x2, 0xb, 0xb, + 0x5, 0x2, 0x2, 0x23, 0x25, 0x5d, 0x5f, 0x1, 0x3, + 0x2, 0xc, 0xc, 0x3, 0x2, 0xd, 0xd, 0x3, 0x2, + 0x21, 0x21, 0x174, 0x2, 0x43, 0x5c, 0x63, 0x7c, 0xac, + 0xac, 0xb7, 0xb7, 0xbc, 0xbc, 0xc2, 0xd8, 0xda, 0xf8, + 0xfa, 0x2c3, 0x2c8, 0x2d3, 0x2e2, 0x2e6, 0x2ee, 0x2ee, 0x2f0, + 0x2f0, 0x372, 0x376, 0x378, 0x379, 0x37c, 0x37f, 0x388, 0x388, + 0x38a, 0x38c, 0x38e, 0x38e, 0x390, 0x3a3, 0x3a5, 0x3f7, 0x3f9, + 0x483, 0x48c, 0x529, 0x533, 0x558, 0x55b, 0x55b, 0x563, 0x589, + 0x5d2, 0x5ec, 0x5f2, 0x5f4, 0x622, 0x64c, 0x670, 0x671, 0x673, + 0x6d5, 0x6d7, 0x6d7, 0x6e7, 0x6e8, 0x6f0, 0x6f1, 0x6fc, 0x6fe, + 0x701, 0x701, 0x712, 0x712, 0x714, 0x731, 0x74f, 0x7a7, 0x7b3, + 0x7b3, 0x7cc, 0x7ec, 0x7f6, 0x7f7, 0x7fc, 0x7fc, 0x802, 0x817, + 0x81c, 0x81c, 0x826, 0x826, 0x82a, 0x82a, 0x842, 0x85a, 0x8a2, + 0x8a2, 0x8a4, 0x8ae, 0x906, 0x93b, 0x93f, 0x93f, 0x952, 0x952, + 0x95a, 0x963, 0x973, 0x979, 0x97b, 0x981, 0x987, 0x98e, 0x991, + 0x992, 0x995, 0x9aa, 0x9ac, 0x9b2, 0x9b4, 0x9b4, 0x9b8, 0x9bb, + 0x9bf, 0x9bf, 0x9d0, 0x9d0, 0x9de, 0x9df, 0x9e1, 0x9e3, 0x9f2, + 0x9f3, 0xa07, 0xa0c, 0xa11, 0xa12, 0xa15, 0xa2a, 0xa2c, 0xa32, + 0xa34, 0xa35, 0xa37, 0xa38, 0xa3a, 0xa3b, 0xa5b, 0xa5e, 0xa60, + 0xa60, 0xa74, 0xa76, 0xa87, 0xa8f, 0xa91, 0xa93, 0xa95, 0xaaa, + 0xaac, 0xab2, 0xab4, 0xab5, 0xab7, 0xabb, 0xabf, 0xabf, 0xad2, + 0xad2, 0xae2, 0xae3, 0xb07, 0xb0e, 0xb11, 0xb12, 0xb15, 0xb2a, + 0xb2c, 0xb32, 0xb34, 0xb35, 0xb37, 0xb3b, 0xb3f, 0xb3f, 0xb5e, + 0xb5f, 0xb61, 0xb63, 0xb73, 0xb73, 0xb85, 0xb85, 0xb87, 0xb8c, + 0xb90, 0xb92, 0xb94, 0xb97, 0xb9b, 0xb9c, 0xb9e, 0xb9e, 0xba0, + 0xba1, 0xba5, 0xba6, 0xbaa, 0xbac, 0xbb0, 0xbbb, 0xbd2, 0xbd2, + 0xc07, 0xc0e, 0xc10, 0xc12, 0xc14, 0xc2a, 0xc2c, 0xc35, 0xc37, + 0xc3b, 0xc3f, 0xc3f, 0xc5a, 0xc5b, 0xc62, 0xc63, 0xc87, 0xc8e, + 0xc90, 0xc92, 0xc94, 0xcaa, 0xcac, 0xcb5, 0xcb7, 0xcbb, 0xcbf, + 0xcbf, 0xce0, 0xce0, 0xce2, 0xce3, 0xcf3, 0xcf4, 0xd07, 0xd0e, + 0xd10, 0xd12, 0xd14, 0xd3c, 0xd3f, 0xd3f, 0xd50, 0xd50, 0xd62, + 0xd63, 0xd7c, 0xd81, 0xd87, 0xd98, 0xd9c, 0xdb3, 0xdb5, 0xdbd, + 0xdbf, 0xdbf, 0xdc2, 0xdc8, 0xe03, 0xe32, 0xe34, 0xe35, 0xe42, + 0xe48, 0xe83, 0xe84, 0xe86, 0xe86, 0xe89, 0xe8a, 0xe8c, 0xe8c, + 0xe8f, 0xe8f, 0xe96, 0xe99, 0xe9b, 0xea1, 0xea3, 0xea5, 0xea7, + 0xea7, 0xea9, 0xea9, 0xeac, 0xead, 0xeaf, 0xeb2, 0xeb4, 0xeb5, + 0xebf, 0xebf, 0xec2, 0xec6, 0xec8, 0xec8, 0xede, 0xee1, 0xf02, + 0xf02, 0xf42, 0xf49, 0xf4b, 0xf6e, 0xf8a, 0xf8e, 0x1002, 0x102c, + 0x1041, 0x1041, 0x1052, 0x1057, 0x105c, 0x105f, 0x1063, 0x1063, 0x1067, + 0x1068, 0x1070, 0x1072, 0x1077, 0x1083, 0x1090, 0x1090, 0x10a2, 0x10c7, + 0x10c9, 0x10c9, 0x10cf, 0x10cf, 0x10d2, 0x10fc, 0x10fe, 0x124a, 0x124c, + 0x124f, 0x1252, 0x1258, 0x125a, 0x125a, 0x125c, 0x125f, 0x1262, 0x128a, + 0x128c, 0x128f, 0x1292, 0x12b2, 0x12b4, 0x12b7, 0x12ba, 0x12c0, 0x12c2, + 0x12c2, 0x12c4, 0x12c7, 0x12ca, 0x12d8, 0x12da, 0x1312, 0x1314, 0x1317, + 0x131a, 0x135c, 0x1382, 0x1391, 0x13a2, 0x13f6, 0x1403, 0x166e, 0x1671, + 0x1681, 0x1683, 0x169c, 0x16a2, 0x16ec, 0x16f0, 0x16f2, 0x1702, 0x170e, + 0x1710, 0x1713, 0x1722, 0x1733, 0x1742, 0x1753, 0x1762, 0x176e, 0x1770, + 0x1772, 0x1782, 0x17b5, 0x17d9, 0x17d9, 0x17de, 0x17de, 0x1822, 0x1879, + 0x1882, 0x18aa, 0x18ac, 0x18ac, 0x18b2, 0x18f7, 0x1902, 0x191e, 0x1952, + 0x196f, 0x1972, 0x1976, 0x1982, 0x19ad, 0x19c3, 0x19c9, 0x1a02, 0x1a18, + 0x1a22, 0x1a56, 0x1aa9, 0x1aa9, 0x1b07, 0x1b35, 0x1b47, 0x1b4d, 0x1b85, + 0x1ba2, 0x1bb0, 0x1bb1, 0x1bbc, 0x1be7, 0x1c02, 0x1c25, 0x1c4f, 0x1c51, + 0x1c5c, 0x1c7f, 0x1ceb, 0x1cee, 0x1cf0, 0x1cf3, 0x1cf7, 0x1cf8, 0x1d02, + 0x1dc1, 0x1e02, 0x1f17, 0x1f1a, 0x1f1f, 0x1f22, 0x1f47, 0x1f4a, 0x1f4f, + 0x1f52, 0x1f59, 0x1f5b, 0x1f5b, 0x1f5d, 0x1f5d, 0x1f5f, 0x1f5f, 0x1f61, + 0x1f7f, 0x1f82, 0x1fb6, 0x1fb8, 0x1fbe, 0x1fc0, 0x1fc0, 0x1fc4, 0x1fc6, + 0x1fc8, 0x1fce, 0x1fd2, 0x1fd5, 0x1fd8, 0x1fdd, 0x1fe2, 0x1fee, 0x1ff4, + 0x1ff6, 0x1ff8, 0x1ffe, 0x2073, 0x2073, 0x2081, 0x2081, 0x2092, 0x209e, + 0x2104, 0x2104, 0x2109, 0x2109, 0x210c, 0x2115, 0x2117, 0x2117, 0x211a, + 0x211f, 0x2126, 0x2126, 0x2128, 0x2128, 0x212a, 0x212a, 0x212c, 0x213b, + 0x213e, 0x2141, 0x2147, 0x214b, 0x2150, 0x2150, 0x2162, 0x218a, 0x2c02, + 0x2c30, 0x2c32, 0x2c60, 0x2c62, 0x2ce6, 0x2ced, 0x2cf0, 0x2cf4, 0x2cf5, + 0x2d02, 0x2d27, 0x2d29, 0x2d29, 0x2d2f, 0x2d2f, 0x2d32, 0x2d69, 0x2d71, + 0x2d71, 0x2d82, 0x2d98, 0x2da2, 0x2da8, 0x2daa, 0x2db0, 0x2db2, 0x2db8, + 0x2dba, 0x2dc0, 0x2dc2, 0x2dc8, 0x2dca, 0x2dd0, 0x2dd2, 0x2dd8, 0x2dda, + 0x2de0, 0x3007, 0x3009, 0x3023, 0x302b, 0x3033, 0x3037, 0x303a, 0x303e, + 0x3043, 0x3098, 0x309d, 0x30a1, 0x30a3, 0x30fc, 0x30fe, 0x3101, 0x3107, + 0x312f, 0x3133, 0x3190, 0x31a2, 0x31bc, 0x31f2, 0x3201, 0x3402, 0x4db7, + 0x4e02, 0x9fce, 0xa002, 0xa48e, 0xa4d2, 0xa4ff, 0xa502, 0xa60e, 0xa612, + 0xa621, 0xa62c, 0xa62d, 0xa642, 0xa670, 0xa681, 0xa699, 0xa6a2, 0xa6f1, + 0xa719, 0xa721, 0xa724, 0xa78a, 0xa78d, 0xa790, 0xa792, 0xa795, 0xa7a2, + 0xa7ac, 0xa7fa, 0xa803, 0xa805, 0xa807, 0xa809, 0xa80c, 0xa80e, 0xa824, + 0xa842, 0xa875, 0xa884, 0xa8b5, 0xa8f4, 0xa8f9, 0xa8fd, 0xa8fd, 0xa90c, + 0xa927, 0xa932, 0xa948, 0xa962, 0xa97e, 0xa986, 0xa9b4, 0xa9d1, 0xa9d1, + 0xaa02, 0xaa2a, 0xaa42, 0xaa44, 0xaa46, 0xaa4d, 0xaa62, 0xaa78, 0xaa7c, + 0xaa7c, 0xaa82, 0xaab1, 0xaab3, 0xaab3, 0xaab7, 0xaab8, 0xaabb, 0xaabf, + 0xaac2, 0xaac2, 0xaac4, 0xaac4, 0xaadd, 0xaadf, 0xaae2, 0xaaec, 0xaaf4, + 0xaaf6, 0xab03, 0xab08, 0xab0b, 0xab10, 0xab13, 0xab18, 0xab22, 0xab28, + 0xab2a, 0xab30, 0xabc2, 0xabe4, 0xac02, 0xd7a5, 0xd7b2, 0xd7c8, 0xd7cd, + 0xd7fd, 0xf902, 0xfa6f, 0xfa72, 0xfadb, 0xfb02, 0xfb08, 0xfb15, 0xfb19, + 0xfb1f, 0xfb1f, 0xfb21, 0xfb2a, 0xfb2c, 0xfb38, 0xfb3a, 0xfb3e, 0xfb40, + 0xfb40, 0xfb42, 0xfb43, 0xfb45, 0xfb46, 0xfb48, 0xfbb3, 0xfbd5, 0xfd3f, + 0xfd52, 0xfd91, 0xfd94, 0xfdc9, 0xfdf2, 0xfdfd, 0xfe72, 0xfe76, 0xfe78, + 0xfefe, 0xff23, 0xff3c, 0xff43, 0xff5c, 0xff68, 0xffc0, 0xffc4, 0xffc9, + 0xffcc, 0x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0x118, 0x119, + 0x7, 0x2a, 0x2, 0x2, 0x119, 0xe, 0x3, 0x2, 0x2, + 0x2, 0x11a, 0x11b, 0x7, 0x2b, 0x2, 0x2, 0x11b, 0x10, + 0x3, 0x2, 0x2, 0x2, 0x11c, 0x11d, 0x7, 0x5d, 0x2, + 0x2, 0x11d, 0x12, 0x3, 0x2, 0x2, 0x2, 0x11e, 0x11f, + 0x7, 0x41, 0x2, 0x2, 0x11f, 0x14, 0x3, 0x2, 0x2, + 0x2, 0x120, 0x121, 0x7, 0x5f, 0x2, 0x2, 0x121, 0x16, + 0x3, 0x2, 0x2, 0x2, 0x122, 0x123, 0x7, 0x3c, 0x2, + 0x2, 0x123, 0x18, 0x3, 0x2, 0x2, 0x2, 0x124, 0x125, + 0x7, 0x7e, 0x2, 0x2, 0x125, 0x1a, 0x3, 0x2, 0x2, + 0x2, 0x126, 0x127, 0x7, 0x30, 0x2, 0x2, 0x127, 0x128, + 0x7, 0x30, 0x2, 0x2, 0x128, 0x1c, 0x3, 0x2, 0x2, + 0x2, 0x129, 0x12a, 0x7, 0x2d, 0x2, 0x2, 0x12a, 0x1e, + 0x3, 0x2, 0x2, 0x2, 0x12b, 0x12c, 0x7, 0x2f, 0x2, + 0x2, 0x12c, 0x20, 0x3, 0x2, 0x2, 0x2, 0x12d, 0x12e, + 0x7, 0x31, 0x2, 0x2, 0x12e, 0x22, 0x3, 0x2, 0x2, + 0x2, 0x12f, 0x130, 0x7, 0x27, 0x2, 0x2, 0x130, 0x24, + 0x3, 0x2, 0x2, 0x2, 0x131, 0x132, 0x7, 0x60, 0x2, + 0x2, 0x132, 0x26, 0x3, 0x2, 0x2, 0x2, 0x133, 0x134, + 0x7, 0x3f, 0x2, 0x2, 0x134, 0x135, 0x7, 0x80, 0x2, + 0x2, 0x135, 0x28, 0x3, 0x2, 0x2, 0x2, 0x136, 0x137, + 0x7, 0x3e, 0x2, 0x2, 0x137, 0x138, 0x7, 0x40, 0x2, + 0x2, 0x138, 0x2a, 0x3, 0x2, 0x2, 0x2, 0x139, 0x13a, + 0x7, 0x23, 0x2, 0x2, 0x13a, 0x13b, 0x7, 0x3f, 0x2, + 0x2, 0x13b, 0x2c, 0x3, 0x2, 0x2, 0x2, 0x13c, 0x13d, + 0x7, 0x3e, 0x2, 0x2, 0x13d, 0x2e, 0x3, 0x2, 0x2, + 0x2, 0x13e, 0x13f, 0x7, 0x40, 0x2, 0x2, 0x13f, 0x30, + 0x3, 0x2, 0x2, 0x2, 0x140, 0x141, 0x7, 0x3e, 0x2, + 0x2, 0x141, 0x142, 0x7, 0x3f, 0x2, 0x2, 0x142, 0x32, + 0x3, 0x2, 0x2, 0x2, 0x143, 0x144, 0x7, 0x40, 0x2, + 0x2, 0x144, 0x145, 0x7, 0x3f, 0x2, 0x2, 0x145, 0x34, + 0x3, 0x2, 0x2, 0x2, 0x146, 0x147, 0x7, 0x30, 0x2, + 0x2, 0x147, 0x36, 0x3, 0x2, 0x2, 0x2, 0x148, 0x149, + 0x7, 0x23, 0x2, 0x2, 0x149, 0x38, 0x3, 0x2, 0x2, + 0x2, 0x14a, 0x14b, 0x7, 0x7d, 0x2, 0x2, 0x14b, 0x3a, + 0x3, 0x2, 0x2, 0x2, 0x14c, 0x14d, 0x7, 0x7f, 0x2, + 0x2, 0x14d, 0x3c, 0x3, 0x2, 0x2, 0x2, 0x14e, 0x14f, + 0x7, 0x26, 0x2, 0x2, 0x14f, 0x3e, 0x3, 0x2, 0x2, + 0x2, 0x150, 0x151, 0x7, 0x27ea, 0x2, 0x2, 0x151, 0x40, + 0x3, 0x2, 0x2, 0x2, 0x152, 0x153, 0x7, 0x300a, 0x2, + 0x2, 0x153, 0x42, 0x3, 0x2, 0x2, 0x2, 0x154, 0x155, + 0x7, 0xfe66, 0x2, 0x2, 0x155, 0x44, 0x3, 0x2, 0x2, + 0x2, 0x156, 0x157, 0x7, 0xff1e, 0x2, 0x2, 0x157, 0x46, + 0x3, 0x2, 0x2, 0x2, 0x158, 0x159, 0x7, 0x27eb, 0x2, + 0x2, 0x159, 0x48, 0x3, 0x2, 0x2, 0x2, 0x15a, 0x15b, + 0x7, 0x300b, 0x2, 0x2, 0x15b, 0x4a, 0x3, 0x2, 0x2, + 0x2, 0x15c, 0x15d, 0x7, 0xfe67, 0x2, 0x2, 0x15d, 0x4c, + 0x3, 0x2, 0x2, 0x2, 0x15e, 0x15f, 0x7, 0xff20, 0x2, + 0x2, 0x15f, 0x4e, 0x3, 0x2, 0x2, 0x2, 0x160, 0x161, + 0x7, 0xaf, 0x2, 0x2, 0x161, 0x50, 0x3, 0x2, 0x2, + 0x2, 0x162, 0x163, 0x7, 0x2012, 0x2, 0x2, 0x163, 0x52, + 0x3, 0x2, 0x2, 0x2, 0x164, 0x165, 0x7, 0x2013, 0x2, + 0x2, 0x165, 0x54, 0x3, 0x2, 0x2, 0x2, 0x166, 0x167, + 0x7, 0x2014, 0x2, 0x2, 0x167, 0x56, 0x3, 0x2, 0x2, + 0x2, 0x168, 0x169, 0x7, 0x2015, 0x2, 0x2, 0x169, 0x58, + 0x3, 0x2, 0x2, 0x2, 0x16a, 0x16b, 0x7, 0x2016, 0x2, + 0x2, 0x16b, 0x5a, 0x3, 0x2, 0x2, 0x2, 0x16c, 0x16d, + 0x7, 0x2017, 0x2, 0x2, 0x16d, 0x5c, 0x3, 0x2, 0x2, + 0x2, 0x16e, 0x16f, 0x7, 0x2214, 0x2, 0x2, 0x16f, 0x5e, + 0x3, 0x2, 0x2, 0x2, 0x170, 0x171, 0x7, 0xfe5a, 0x2, + 0x2, 0x171, 0x60, 0x3, 0x2, 0x2, 0x2, 0x172, 0x173, + 0x7, 0xfe65, 0x2, 0x2, 0x173, 0x62, 0x3, 0x2, 0x2, + 0x2, 0x174, 0x175, 0x7, 0xff0f, 0x2, 0x2, 0x175, 0x64, + 0x3, 0x2, 0x2, 0x2, 0x176, 0x17b, 0x7, 0x24, 0x2, + 0x2, 0x177, 0x17a, 0x5, 0x103, 0x82, 0x2, 0x178, 0x17a, + 0x5, 0x67, 0x34, 0x2, 0x179, 0x177, 0x3, 0x2, 0x2, + 0x2, 0x179, 0x178, 0x3, 0x2, 0x2, 0x2, 0x17a, 0x17d, + 0x3, 0x2, 0x2, 0x2, 0x17b, 0x179, 0x3, 0x2, 0x2, + 0x2, 0x17b, 0x17c, 0x3, 0x2, 0x2, 0x2, 0x17c, 0x17e, + 0x3, 0x2, 0x2, 0x2, 0x17d, 0x17b, 0x3, 0x2, 0x2, + 0x2, 0x17e, 0x189, 0x7, 0x24, 0x2, 0x2, 0x17f, 0x184, + 0x7, 0x29, 0x2, 0x2, 0x180, 0x183, 0x5, 0xf1, 0x79, + 0x2, 0x181, 0x183, 0x5, 0x67, 0x34, 0x2, 0x182, 0x180, + 0x3, 0x2, 0x2, 0x2, 0x182, 0x181, 0x3, 0x2, 0x2, + 0x2, 0x183, 0x186, 0x3, 0x2, 0x2, 0x2, 0x184, 0x182, + 0x3, 0x2, 0x2, 0x2, 0x184, 0x185, 0x3, 0x2, 0x2, + 0x2, 0x185, 0x187, 0x3, 0x2, 0x2, 0x2, 0x186, 0x184, + 0x3, 0x2, 0x2, 0x2, 0x187, 0x189, 0x7, 0x29, 0x2, + 0x2, 0x188, 0x176, 0x3, 0x2, 0x2, 0x2, 0x188, 0x17f, + 0x3, 0x2, 0x2, 0x2, 0x189, 0x66, 0x3, 0x2, 0x2, + 0x2, 0x18a, 0x19c, 0x7, 0x5e, 0x2, 0x2, 0x18b, 0x19d, + 0x9, 0x2, 0x2, 0x2, 0x18c, 0x18d, 0x9, 0x3, 0x2, + 0x2, 0x18d, 0x18e, 0x5, 0x71, 0x39, 0x2, 0x18e, 0x18f, + 0x5, 0x71, 0x39, 0x2, 0x18f, 0x190, 0x5, 0x71, 0x39, + 0x2, 0x190, 0x191, 0x5, 0x71, 0x39, 0x2, 0x191, 0x19d, + 0x3, 0x2, 0x2, 0x2, 0x192, 0x193, 0x9, 0x3, 0x2, + 0x2, 0x193, 0x194, 0x5, 0x71, 0x39, 0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1f6, 0x3, 0x2, 0x2, 0x2, 0x1f8, 0x1f9, + 0x3, 0x2, 0x2, 0x2, 0x1f9, 0x80, 0x3, 0x2, 0x2, + 0x2, 0x1fa, 0x1fb, 0x9, 0x3, 0x2, 0x2, 0x1fb, 0x1fc, + 0x9, 0x6, 0x2, 0x2, 0x1fc, 0x1fd, 0x9, 0x7, 0x2, + 0x2, 0x1fd, 0x1fe, 0x9, 0x8, 0x2, 0x2, 0x1fe, 0x1ff, + 0x9, 0x6, 0x2, 0x2, 0x1ff, 0x82, 0x3, 0x2, 0x2, + 0x2, 0x200, 0x201, 0x9, 0x9, 0x2, 0x2, 0x201, 0x202, + 0x9, 0xa, 0x2, 0x2, 0x202, 0x203, 0x9, 0xa, 0x2, + 0x2, 0x203, 0x84, 0x3, 0x2, 0x2, 0x2, 0x204, 0x205, + 0x9, 0x8, 0x2, 0x2, 0x205, 0x206, 0x9, 0xb, 0x2, + 0x2, 0x206, 0x207, 0x9, 0xc, 0x2, 0x2, 0x207, 0x208, + 0x9, 0x7, 0x2, 0x2, 0x208, 0x209, 0x9, 0x8, 0x2, + 0x2, 0x209, 0x20a, 0x9, 0x6, 0x2, 0x2, 0x20a, 0x20b, + 0x9, 0x9, 0x2, 0x2, 0x20b, 0x20c, 0x9, 0xa, 0x2, + 0x2, 0x20c, 0x86, 0x3, 0x2, 0x2, 0x2, 0x20d, 0x20e, + 0x9, 0xd, 0x2, 0x2, 0x20e, 0x20f, 0x9, 0x9, 0x2, + 0x2, 0x20f, 0x210, 0x9, 0xc, 0x2, 0x2, 0x210, 0x211, + 0x9, 0xe, 0x2, 0x2, 0x211, 0x212, 0x9, 0xf, 0x2, + 0x2, 0x212, 0x88, 0x3, 0x2, 0x2, 0x2, 0x213, 0x214, + 0x9, 0x3, 0x2, 0x2, 0x214, 0x215, 0x9, 0x6, 0x2, + 0x2, 0x215, 0x216, 0x9, 0x10, 0x2, 0x2, 0x216, 0x217, + 0x9, 0x7, 0x2, 0x2, 0x217, 0x218, 0x9, 0x6, 0x2, + 0x2, 0x218, 0x219, 0x9, 0x11, 0x2, 0x2, 0x219, 0x8a, + 0x3, 0x2, 0x2, 0x2, 0x21a, 0x21b, 0x9, 0x9, 0x2, + 0x2, 0x21b, 0x21c, 0x9, 0x12, 0x2, 0x2, 0x21c, 0x8c, + 0x3, 0x2, 0x2, 0x2, 0x21d, 0x21e, 0x9, 0xd, 0x2, + 0x2, 0x21e, 0x21f, 0x9, 0x5, 0x2, 0x2, 0x21f, 0x220, + 0x9, 0x13, 0x2, 0x2, 0x220, 0x221, 0x9, 0x14, 0x2, + 0x2, 0x221, 0x222, 0x9, 0x5, 0x2, 0x2, 0x222, 0x8e, + 0x3, 0x2, 0x2, 0x2, 0x223, 0x224, 0x9, 0x8, 0x2, + 0x2, 0x224, 0x225, 0x9, 0x6, 0x2, 0x2, 0x225, 0x90, + 0x3, 0x2, 0x2, 0x2, 0x226, 0x227, 0x9, 0xe, 0x2, + 0x2, 0x227, 0x228, 0x9, 0x13, 0x2, 0x2, 0x228, 0x229, + 0x9, 0x5, 0x2, 0x2, 0x229, 0x22a, 0x9, 0x9, 0x2, + 0x2, 0x22a, 0x22b, 0x9, 0xc, 0x2, 0x2, 0x22b, 0x22c, + 0x9, 0x5, 0x2, 0x2, 0x22c, 0x92, 0x3, 0x2, 0x2, + 0x2, 0x22d, 0x22e, 0x9, 0x12, 0x2, 0x2, 0x22e, 0x22f, + 0x9, 0x5, 0x2, 0x2, 0x22f, 0x230, 0x9, 0xc, 0x2, + 0x2, 0x230, 0x94, 0x3, 0x2, 0x2, 0x2, 0x231, 0x232, + 0x9, 0x11, 0x2, 0x2, 0x232, 0x233, 0x9, 0x5, 0x2, + 0x2, 0x233, 0x234, 0x9, 0xc, 0x2, 0x2, 0x234, 0x235, + 0x9, 0x9, 0x2, 0x2, 0x235, 0x236, 0x9, 0xe, 0x2, + 0x2, 0x236, 0x237, 0x9, 0xf, 0x2, 0x2, 0x237, 0x96, + 0x3, 0x2, 0x2, 0x2, 0x238, 0x239, 0x9, 0x11, 0x2, + 0x2, 0x239, 0x23a, 0x9, 0x5, 0x2, 0x2, 0x23a, 0x23b, + 0x9, 0xa, 0x2, 0x2, 0x23b, 0x23c, 0x9, 0x5, 0x2, + 0x2, 0x23c, 0x23d, 0x9, 0xc, 0x2, 0x2, 0x23d, 0x23e, + 0x9, 0x5, 0x2, 0x2, 0x23e, 0x98, 0x3, 0x2, 0x2, + 0x2, 0x23f, 0x240, 0x9, 0x13, 0x2, 0x2, 0x240, 0x241, + 0x9, 0x5, 0x2, 0x2, 0x241, 0x242, 0x9, 0xd, 0x2, + 0x2, 0x242, 0x243, 0x9, 0x8, 0x2, 0x2, 0x243, 0x244, + 0x9, 0x15, 0x2, 0x2, 0x244, 0x245, 0x9, 0x5, 0x2, + 0x2, 0x245, 0x9a, 0x3, 0x2, 0x2, 0x2, 0x246, 0x247, + 0x9, 0x10, 0x2, 0x2, 0x247, 0x248, 0x9, 0x7, 0x2, + 0x2, 0x248, 0x249, 0x9, 0xc, 0x2, 0x2, 0x249, 0x24a, + 0x9, 0xf, 0x2, 0x2, 0x24a, 0x9c, 0x3, 0x2, 0x2, + 0x2, 0x24b, 0x24c, 0x9, 0x11, 0x2, 0x2, 0x24c, 0x24d, + 0x9, 0x7, 0x2, 0x2, 0x24d, 0x24e, 0x9, 0x12, 0x2, + 0x2, 0x24e, 0x24f, 0x9, 0xc, 0x2, 0x2, 0x24f, 0x250, + 0x9, 0x7, 0x2, 0x2, 0x250, 0x251, 0x9, 0x6, 0x2, + 0x2, 0x251, 0x252, 0x9, 0xe, 0x2, 0x2, 0x252, 0x253, + 0x9, 0xc, 0x2, 0x2, 0x253, 0x9e, 0x3, 0x2, 0x2, + 0x2, 0x254, 0x255, 0x9, 0x13, 0x2, 0x2, 0x255, 0x256, + 0x9, 0x5, 0x2, 0x2, 0x256, 0x257, 0x9, 0xc, 0x2, + 0x2, 0x257, 0x258, 0x9, 0x3, 0x2, 0x2, 0x258, 0x259, + 0x9, 0x13, 0x2, 0x2, 0x259, 0x25a, 0x9, 0x6, 0x2, + 0x2, 0x25a, 0xa0, 0x3, 0x2, 0x2, 0x2, 0x25b, 0x25c, + 0x9, 0x8, 0x2, 0x2, 0x25c, 0x25d, 0x9, 0x13, 0x2, + 0x2, 0x25d, 0x25e, 0x9, 0x11, 0x2, 0x2, 0x25e, 0x25f, + 0x9, 0x5, 0x2, 0x2, 0x25f, 0x260, 0x9, 0x13, 0x2, + 0x2, 0x260, 0xa2, 0x3, 0x2, 0x2, 0x2, 0x261, 0x262, + 0x9, 0x16, 0x2, 0x2, 0x262, 0x263, 0x9, 0x17, 0x2, + 0x2, 0x263, 0xa4, 0x3, 0x2, 0x2, 0x2, 0x264, 0x265, + 0x9, 0x12, 0x2, 0x2, 0x265, 0x266, 0x9, 0x18, 0x2, + 0x2, 0x266, 0x267, 0x9, 0x7, 0x2, 0x2, 0x267, 0x268, + 0x9, 0xb, 0x2, 0x2, 0x268, 0xa6, 0x3, 0x2, 0x2, + 0x2, 0x269, 0x26a, 0x9, 0xa, 0x2, 0x2, 0x26a, 0x26b, + 0x9, 0x7, 0x2, 0x2, 0x26b, 0x26c, 0x9, 0xd, 0x2, + 0x2, 0x26c, 0x26d, 0x9, 0x7, 0x2, 0x2, 0x26d, 0x26e, + 0x9, 0xc, 0x2, 0x2, 0x26e, 0xa8, 0x3, 0x2, 0x2, + 0x2, 0x26f, 0x270, 0x9, 0x9, 0x2, 0x2, 0x270, 0x271, + 0x9, 0x12, 0x2, 0x2, 0x271, 0x272, 0x9, 0xe, 0x2, + 0x2, 0x272, 0x273, 0x9, 0x5, 0x2, 0x2, 0x273, 0x274, + 0x9, 0x6, 0x2, 0x2, 0x274, 0x275, 0x9, 0x11, 0x2, + 0x2, 0x275, 0x276, 0x9, 0x7, 0x2, 0x2, 0x276, 0x277, + 0x9, 0x6, 0x2, 0x2, 0x277, 0x278, 0x9, 0x14, 0x2, + 0x2, 0x278, 0xaa, 0x3, 0x2, 0x2, 0x2, 0x279, 0x27a, + 0x9, 0x9, 0x2, 0x2, 0x27a, 0x27b, 0x9, 0x12, 0x2, + 0x2, 0x27b, 0x27c, 0x9, 0xe, 0x2, 0x2, 0x27c, 0xac, + 0x3, 0x2, 0x2, 0x2, 0x27d, 0x27e, 0x9, 0x11, 0x2, + 0x2, 0x27e, 0x27f, 0x9, 0x5, 0x2, 0x2, 0x27f, 0x280, + 0x9, 0x12, 0x2, 0x2, 0x280, 0x281, 0x9, 0xe, 0x2, + 0x2, 0x281, 0x282, 0x9, 0x5, 0x2, 0x2, 0x282, 0x283, + 0x9, 0x6, 0x2, 0x2, 0x283, 0x284, 0x9, 0x11, 0x2, + 0x2, 0x284, 0x285, 0x9, 0x7, 0x2, 0x2, 0x285, 0x286, + 0x9, 0x6, 0x2, 0x2, 0x286, 0x287, 0x9, 0x14, 0x2, + 0x2, 0x287, 0xae, 0x3, 0x2, 0x2, 0x2, 0x288, 0x289, + 0x9, 0x11, 0x2, 0x2, 0x289, 0x28a, 0x9, 0x5, 0x2, + 0x2, 0x28a, 0x28b, 0x9, 0x12, 0x2, 0x2, 0x28b, 0x28c, + 0x9, 0xe, 0x2, 0x2, 0x28c, 0xb0, 0x3, 0x2, 0x2, + 0x2, 0x28d, 0x28e, 0x9, 0x10, 0x2, 0x2, 0x28e, 0x28f, + 0x9, 0xf, 0x2, 0x2, 0x28f, 0x290, 0x9, 0x5, 0x2, + 0x2, 0x290, 0x291, 0x9, 0x13, 0x2, 0x2, 0x291, 0x292, + 0x9, 0x5, 0x2, 0x2, 0x292, 0xb2, 0x3, 0x2, 0x2, + 0x2, 0x293, 0x294, 0x9, 0x8, 0x2, 0x2, 0x294, 0x295, + 0x9, 0x13, 0x2, 0x2, 0x295, 0xb4, 0x3, 0x2, 0x2, + 0x2, 0x296, 0x297, 0x9, 0x19, 0x2, 0x2, 0x297, 0x298, + 0x9, 0x8, 0x2, 0x2, 0x298, 0x299, 0x9, 0x13, 0x2, + 0x2, 0x299, 0xb6, 0x3, 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f, + 0x5, 0xe1, 0x71, 0x2, 0x30e, 0x30d, 0x3, 0x2, 0x2, + 0x2, 0x30f, 0x310, 0x3, 0x2, 0x2, 0x2, 0x310, 0x30e, + 0x3, 0x2, 0x2, 0x2, 0x310, 0x311, 0x3, 0x2, 0x2, + 0x2, 0x311, 0xe0, 0x3, 0x2, 0x2, 0x2, 0x312, 0x31f, + 0x5, 0xff, 0x80, 0x2, 0x313, 0x31f, 0x5, 0x101, 0x81, + 0x2, 0x314, 0x31f, 0x5, 0x105, 0x83, 0x2, 0x315, 0x31f, + 0x5, 0x107, 0x84, 0x2, 0x316, 0x31f, 0x5, 0xe7, 0x74, + 0x2, 0x317, 0x31f, 0x5, 0xfb, 0x7e, 0x2, 0x318, 0x31f, + 0x5, 0xf9, 0x7d, 0x2, 0x319, 0x31f, 0x5, 0xf7, 0x7c, + 0x2, 0x31a, 0x31f, 0x5, 0xeb, 0x76, 0x2, 0x31b, 0x31f, + 0x5, 0x109, 0x85, 0x2, 0x31c, 0x31f, 0x9, 0x1c, 0x2, + 0x2, 0x31d, 0x31f, 0x5, 0xe3, 0x72, 0x2, 0x31e, 0x312, + 0x3, 0x2, 0x2, 0x2, 0x31e, 0x313, 0x3, 0x2, 0x2, + 0x2, 0x31e, 0x314, 0x3, 0x2, 0x2, 0x2, 0x31e, 0x315, + 0x3, 0x2, 0x2, 0x2, 0x31e, 0x316, 0x3, 0x2, 0x2, + 0x2, 0x31e, 0x317, 0x3, 0x2, 0x2, 0x2, 0x31e, 0x318, + 0x3, 0x2, 0x2, 0x2, 0x31e, 0x319, 0x3, 0x2, 0x2, + 0x2, 0x31e, 0x31a, 0x3, 0x2, 0x2, 0x2, 0x31e, 0x31b, + 0x3, 0x2, 0x2, 0x2, 0x31e, 0x31c, 0x3, 0x2, 0x2, + 0x2, 0x31e, 0x31d, 0x3, 0x2, 0x2, 0x2, 0x31f, 0xe2, + 0x3, 0x2, 0x2, 0x2, 0x320, 0x321, 0x7, 0x31, 0x2, + 0x2, 0x321, 0x322, 0x7, 0x2c, 0x2, 0x2, 0x322, 0x328, + 0x3, 0x2, 0x2, 0x2, 0x323, 0x327, 0x5, 0xef, 0x78, + 0x2, 0x324, 0x325, 0x7, 0x2c, 0x2, 0x2, 0x325, 0x327, + 0x5, 0xf5, 0x7b, 0x2, 0x326, 0x323, 0x3, 0x2, 0x2, + 0x2, 0x326, 0x324, 0x3, 0x2, 0x2, 0x2, 0x327, 0x32a, + 0x3, 0x2, 0x2, 0x2, 0x328, 0x326, 0x3, 0x2, 0x2, + 0x2, 0x328, 0x329, 0x3, 0x2, 0x2, 0x2, 0x329, 0x32b, + 0x3, 0x2, 0x2, 0x2, 0x32a, 0x328, 0x3, 0x2, 0x2, + 0x2, 0x32b, 0x32c, 0x7, 0x2c, 0x2, 0x2, 0x32c, 0x339, + 0x7, 0x31, 0x2, 0x2, 0x32d, 0x32e, 0x7, 0x31, 0x2, + 0x2, 0x32e, 0x32f, 0x7, 0x31, 0x2, 0x2, 0x32f, 0x330, + 0x3, 0x2, 0x2, 0x2, 0x330, 0x332, 0x5, 0xf3, 0x7a, + 0x2, 0x331, 0x333, 0x5, 0xfb, 0x7e, 0x2, 0x332, 0x331, + 0x3, 0x2, 0x2, 0x2, 0x332, 0x333, 0x3, 0x2, 0x2, + 0x2, 0x333, 0x336, 0x3, 0x2, 0x2, 0x2, 0x334, 0x337, + 0x5, 0x105, 0x83, 0x2, 0x335, 0x337, 0x7, 0x2, 0x2, + 0x3, 0x336, 0x334, 0x3, 0x2, 0x2, 0x2, 0x336, 0x335, + 0x3, 0x2, 0x2, 0x2, 0x337, 0x339, 0x3, 0x2, 0x2, + 0x2, 0x338, 0x320, 0x3, 0x2, 0x2, 0x2, 0x338, 0x32d, + 0x3, 0x2, 0x2, 0x2, 0x339, 0xe4, 0x3, 0x2, 0x2, + 0x2, 0x33a, 0x33b, 0x4, 0x32, 0x32, 0x2, 0x33b, 0x33c, + 0x9, 0x19, 0x2, 0x2, 0x33c, 0xe6, 0x3, 0x2, 0x2, + 0x2, 0x33d, 0x33e, 0x9, 0x1d, 0x2, 0x2, 0x33e, 0xe8, + 0x3, 0x2, 0x2, 0x2, 0x33f, 0x340, 0x9, 0x1e, 0x2, + 0x2, 0x340, 0xea, 0x3, 0x2, 0x2, 0x2, 0x341, 0x342, + 0x9, 0x1f, 0x2, 0x2, 0x342, 0xec, 0x3, 0x2, 0x2, + 0x2, 0x343, 0x344, 0x9, 0x20, 0x2, 0x2, 0x344, 0xee, + 0x3, 0x2, 0x2, 0x2, 0x345, 0x346, 0x9, 0x21, 0x2, + 0x2, 0x346, 0xf0, 0x3, 0x2, 0x2, 0x2, 0x347, 0x348, + 0x9, 0x22, 0x2, 0x2, 0x348, 0xf2, 0x3, 0x2, 0x2, + 0x2, 0x349, 0x34a, 0x9, 0x23, 0x2, 0x2, 0x34a, 0xf4, + 0x3, 0x2, 0x2, 0x2, 0x34b, 0x34c, 0x9, 0x24, 0x2, + 0x2, 0x34c, 0xf6, 0x3, 0x2, 0x2, 0x2, 0x34d, 0x34e, + 0x9, 0x25, 0x2, 0x2, 0x34e, 0xf8, 0x3, 0x2, 0x2, + 0x2, 0x34f, 0x350, 0x9, 0x26, 0x2, 0x2, 0x350, 0xfa, + 0x3, 0x2, 0x2, 0x2, 0x351, 0x352, 0x9, 0x27, 0x2, + 0x2, 0x352, 0xfc, 0x3, 0x2, 0x2, 0x2, 0x353, 0x354, + 0x9, 0x28, 0x2, 0x2, 0x354, 0xfe, 0x3, 0x2, 0x2, + 0x2, 0x355, 0x356, 0x9, 0x29, 0x2, 0x2, 0x356, 0x100, + 0x3, 0x2, 0x2, 0x2, 0x357, 0x358, 0x9, 0x2a, 0x2, + 0x2, 0x358, 0x102, 0x3, 0x2, 0x2, 0x2, 0x359, 0x35a, + 0x9, 0x2b, 0x2, 0x2, 0x35a, 0x104, 0x3, 0x2, 0x2, + 0x2, 0x35b, 0x35c, 0x9, 0x2c, 0x2, 0x2, 0x35c, 0x106, + 0x3, 0x2, 0x2, 0x2, 0x35d, 0x35e, 0x9, 0x2d, 0x2, + 0x2, 0x35e, 0x108, 0x3, 0x2, 0x2, 0x2, 0x35f, 0x360, + 0x9, 0x2e, 0x2, 0x2, 0x360, 0x10a, 0x3, 0x2, 0x2, + 0x2, 0x361, 0x362, 0x9, 0x2f, 0x2, 0x2, 0x362, 0x10c, + 0x3, 0x2, 0x2, 0x2, 0x28, 0x2, 0x179, 0x17b, 0x182, + 0x184, 0x188, 0x19c, 0x1a2, 0x1a9, 0x1ac, 0x1b2, 0x1b5, 0x1b9, + 0x1bd, 0x1c1, 0x1c7, 0x1ce, 0x1d3, 0x1d9, 0x1df, 0x1e1, 0x1e4, + 0x1e7, 0x1ec, 0x1f1, 0x1f8, 0x2f6, 0x2fb, 0x2ff, 0x305, 0x30b, + 0x310, 0x31e, 0x326, 0x328, 0x332, 0x336, 0x338, 0x2, }; atn::ATNDeserializer deserializer; @@ -926,7 +1378,7 @@ CypherLexer::Initializer::Initializer() { size_t count = _atn.getNumberOfDecisions(); _decisionToDFA.reserve(count); - for (size_t i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { _decisionToDFA.emplace_back(_atn.getDecisionState(i), i); } } diff --git a/src/query/frontend/opencypher/generated/CypherListener.cpp b/src/query/frontend/opencypher/generated/CypherListener.cpp index e6cb38e90..252830fce 100644 --- a/src/query/frontend/opencypher/generated/CypherListener.cpp +++ b/src/query/frontend/opencypher/generated/CypherListener.cpp @@ -1,9 +1,8 @@ -// Generated from /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 by ANTLR 4.6 - +// Generated from +// /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 +// by ANTLR 4.6 #include "CypherListener.h" - using namespace antlrcpptest; - diff --git a/src/query/frontend/opencypher/generated/CypherParser.cpp b/src/query/frontend/opencypher/generated/CypherParser.cpp index 6a54e58cb..2242a5b69 100644 --- a/src/query/frontend/opencypher/generated/CypherParser.cpp +++ b/src/query/frontend/opencypher/generated/CypherParser.cpp @@ -1,45 +1,40 @@ -// Generated from /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 by ANTLR 4.6 - +// Generated from +// /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 +// by ANTLR 4.6 #include "CypherListener.h" #include "CypherVisitor.h" #include "CypherParser.h" - using namespace antlrcpp; using namespace antlrcpptest; using namespace antlr4; CypherParser::CypherParser(TokenStream *input) : Parser(input) { - _interpreter = new atn::ParserATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache); + _interpreter = new atn::ParserATNSimulator(this, _atn, _decisionToDFA, + _sharedContextCache); } -CypherParser::~CypherParser() { - delete _interpreter; -} +CypherParser::~CypherParser() { delete _interpreter; } -std::string CypherParser::getGrammarFileName() const { - return "Cypher.g4"; -} +std::string CypherParser::getGrammarFileName() const { return "Cypher.g4"; } -const std::vector<std::string>& CypherParser::getRuleNames() const { +const std::vector<std::string> &CypherParser::getRuleNames() const { return _ruleNames; } -dfa::Vocabulary& CypherParser::getVocabulary() const { - return _vocabulary; -} +dfa::Vocabulary &CypherParser::getVocabulary() const { return _vocabulary; } +//----------------- CypherContext +//------------------------------------------------------------------ -//----------------- CypherContext ------------------------------------------------------------------ +CypherParser::CypherContext::CypherContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::CypherContext::CypherContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} - -CypherParser::StatementContext* CypherParser::CypherContext::statement() { +CypherParser::StatementContext *CypherParser::CypherContext::statement() { return getRuleContext<CypherParser::StatementContext>(0); } @@ -47,43 +42,39 @@ std::vector<tree::TerminalNode *> CypherParser::CypherContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::CypherContext::SP(size_t i) { +tree::TerminalNode *CypherParser::CypherContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::CypherContext::getRuleIndex() const { return CypherParser::RuleCypher; } void CypherParser::CypherContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterCypher(this); + if (parserListener != nullptr) parserListener->enterCypher(this); } void CypherParser::CypherContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitCypher(this); + if (parserListener != nullptr) parserListener->exitCypher(this); } - -antlrcpp::Any CypherParser::CypherContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::CypherContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitCypher(this); else return visitor->visitChildren(this); } -CypherParser::CypherContext* CypherParser::cypher() { - CypherContext *_localctx = _tracker.createInstance<CypherContext>(_ctx, getState()); +CypherParser::CypherContext *CypherParser::cypher() { + CypherContext *_localctx = + _tracker.createInstance<CypherContext>(_ctx, getState()); enterRule(_localctx, 0, CypherParser::RuleCypher); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(159); @@ -99,21 +90,21 @@ CypherParser::CypherContext* CypherParser::cypher() { setState(166); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 2, _ctx)) { - case 1: { - setState(163); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 2, _ctx)) { + case 1: { + setState(163); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(162); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(162); + match(CypherParser::SP); + } + setState(165); + match(CypherParser::T__0); + break; } - setState(165); - match(CypherParser::T__0); - break; - } - } setState(169); _errHandler->sync(this); @@ -123,9 +114,8 @@ CypherParser::CypherContext* CypherParser::cypher() { setState(168); match(CypherParser::SP); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -134,55 +124,53 @@ CypherParser::CypherContext* CypherParser::cypher() { return _localctx; } -//----------------- StatementContext ------------------------------------------------------------------ +//----------------- StatementContext +//------------------------------------------------------------------ -CypherParser::StatementContext::StatementContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::StatementContext::StatementContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::QueryContext* CypherParser::StatementContext::query() { +CypherParser::QueryContext *CypherParser::StatementContext::query() { return getRuleContext<CypherParser::QueryContext>(0); } - size_t CypherParser::StatementContext::getRuleIndex() const { return CypherParser::RuleStatement; } -void CypherParser::StatementContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::StatementContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterStatement(this); + if (parserListener != nullptr) parserListener->enterStatement(this); } -void CypherParser::StatementContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::StatementContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitStatement(this); + if (parserListener != nullptr) parserListener->exitStatement(this); } - -antlrcpp::Any CypherParser::StatementContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::StatementContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitStatement(this); else return visitor->visitChildren(this); } -CypherParser::StatementContext* CypherParser::statement() { - StatementContext *_localctx = _tracker.createInstance<StatementContext>(_ctx, getState()); +CypherParser::StatementContext *CypherParser::statement() { + StatementContext *_localctx = + _tracker.createInstance<StatementContext>(_ctx, getState()); enterRule(_localctx, 2, CypherParser::RuleStatement); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(171); query(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -191,55 +179,51 @@ CypherParser::StatementContext* CypherParser::statement() { return _localctx; } -//----------------- QueryContext ------------------------------------------------------------------ +//----------------- QueryContext +//------------------------------------------------------------------ -CypherParser::QueryContext::QueryContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::QueryContext::QueryContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::RegularQueryContext* CypherParser::QueryContext::regularQuery() { +CypherParser::RegularQueryContext *CypherParser::QueryContext::regularQuery() { return getRuleContext<CypherParser::RegularQueryContext>(0); } - size_t CypherParser::QueryContext::getRuleIndex() const { return CypherParser::RuleQuery; } void CypherParser::QueryContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterQuery(this); + if (parserListener != nullptr) parserListener->enterQuery(this); } void CypherParser::QueryContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitQuery(this); + if (parserListener != nullptr) parserListener->exitQuery(this); } - -antlrcpp::Any CypherParser::QueryContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::QueryContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitQuery(this); else return visitor->visitChildren(this); } -CypherParser::QueryContext* CypherParser::query() { - QueryContext *_localctx = _tracker.createInstance<QueryContext>(_ctx, getState()); +CypherParser::QueryContext *CypherParser::query() { + QueryContext *_localctx = + _tracker.createInstance<QueryContext>(_ctx, getState()); enterRule(_localctx, 4, CypherParser::RuleQuery); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(173); regularQuery(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -248,21 +232,25 @@ CypherParser::QueryContext* CypherParser::query() { return _localctx; } -//----------------- RegularQueryContext ------------------------------------------------------------------ +//----------------- RegularQueryContext +//------------------------------------------------------------------ -CypherParser::RegularQueryContext::RegularQueryContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::RegularQueryContext::RegularQueryContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::SingleQueryContext* CypherParser::RegularQueryContext::singleQuery() { +CypherParser::SingleQueryContext * +CypherParser::RegularQueryContext::singleQuery() { return getRuleContext<CypherParser::SingleQueryContext>(0); } -std::vector<CypherParser::CypherUnionContext *> CypherParser::RegularQueryContext::cypherUnion() { +std::vector<CypherParser::CypherUnionContext *> +CypherParser::RegularQueryContext::cypherUnion() { return getRuleContexts<CypherParser::CypherUnionContext>(); } -CypherParser::CypherUnionContext* CypherParser::RegularQueryContext::cypherUnion(size_t i) { +CypherParser::CypherUnionContext * +CypherParser::RegularQueryContext::cypherUnion(size_t i) { return getRuleContext<CypherParser::CypherUnionContext>(i); } @@ -270,43 +258,41 @@ std::vector<tree::TerminalNode *> CypherParser::RegularQueryContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::RegularQueryContext::SP(size_t i) { +tree::TerminalNode *CypherParser::RegularQueryContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::RegularQueryContext::getRuleIndex() const { return CypherParser::RuleRegularQuery; } -void CypherParser::RegularQueryContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::RegularQueryContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterRegularQuery(this); + if (parserListener != nullptr) parserListener->enterRegularQuery(this); } -void CypherParser::RegularQueryContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::RegularQueryContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRegularQuery(this); + if (parserListener != nullptr) parserListener->exitRegularQuery(this); } - -antlrcpp::Any CypherParser::RegularQueryContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RegularQueryContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRegularQuery(this); else return visitor->visitChildren(this); } -CypherParser::RegularQueryContext* CypherParser::regularQuery() { - RegularQueryContext *_localctx = _tracker.createInstance<RegularQueryContext>(_ctx, getState()); +CypherParser::RegularQueryContext *CypherParser::regularQuery() { + RegularQueryContext *_localctx = + _tracker.createInstance<RegularQueryContext>(_ctx, getState()); enterRule(_localctx, 6, CypherParser::RuleRegularQuery); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -314,7 +300,8 @@ CypherParser::RegularQueryContext* CypherParser::regularQuery() { singleQuery(); setState(182); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 5, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 5, + _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(177); @@ -326,15 +313,15 @@ CypherParser::RegularQueryContext* CypherParser::regularQuery() { match(CypherParser::SP); } setState(179); - cypherUnion(); + cypherUnion(); } setState(184); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 5, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 5, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -343,17 +330,20 @@ CypherParser::RegularQueryContext* CypherParser::regularQuery() { return _localctx; } -//----------------- SingleQueryContext ------------------------------------------------------------------ +//----------------- SingleQueryContext +//------------------------------------------------------------------ -CypherParser::SingleQueryContext::SingleQueryContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::SingleQueryContext::SingleQueryContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::ClauseContext *> CypherParser::SingleQueryContext::clause() { +std::vector<CypherParser::ClauseContext *> +CypherParser::SingleQueryContext::clause() { return getRuleContexts<CypherParser::ClauseContext>(); } -CypherParser::ClauseContext* CypherParser::SingleQueryContext::clause(size_t i) { +CypherParser::ClauseContext *CypherParser::SingleQueryContext::clause( + size_t i) { return getRuleContext<CypherParser::ClauseContext>(i); } @@ -361,43 +351,41 @@ std::vector<tree::TerminalNode *> CypherParser::SingleQueryContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::SingleQueryContext::SP(size_t i) { +tree::TerminalNode *CypherParser::SingleQueryContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::SingleQueryContext::getRuleIndex() const { return CypherParser::RuleSingleQuery; } -void CypherParser::SingleQueryContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::SingleQueryContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterSingleQuery(this); + if (parserListener != nullptr) parserListener->enterSingleQuery(this); } -void CypherParser::SingleQueryContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::SingleQueryContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitSingleQuery(this); + if (parserListener != nullptr) parserListener->exitSingleQuery(this); } - -antlrcpp::Any CypherParser::SingleQueryContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::SingleQueryContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitSingleQuery(this); else return visitor->visitChildren(this); } -CypherParser::SingleQueryContext* CypherParser::singleQuery() { - SingleQueryContext *_localctx = _tracker.createInstance<SingleQueryContext>(_ctx, getState()); +CypherParser::SingleQueryContext *CypherParser::singleQuery() { + SingleQueryContext *_localctx = + _tracker.createInstance<SingleQueryContext>(_ctx, getState()); enterRule(_localctx, 8, CypherParser::RuleSingleQuery); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -405,7 +393,8 @@ CypherParser::SingleQueryContext* CypherParser::singleQuery() { clause(); setState(192); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 7, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 7, + _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(187); @@ -417,15 +406,15 @@ CypherParser::SingleQueryContext* CypherParser::singleQuery() { match(CypherParser::SP); } setState(189); - clause(); + clause(); } setState(194); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 7, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 7, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -434,13 +423,14 @@ CypherParser::SingleQueryContext* CypherParser::singleQuery() { return _localctx; } -//----------------- CypherUnionContext ------------------------------------------------------------------ +//----------------- CypherUnionContext +//------------------------------------------------------------------ -CypherParser::CypherUnionContext::CypherUnionContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::CypherUnionContext::CypherUnionContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::CypherUnionContext::UNION() { +tree::TerminalNode *CypherParser::CypherUnionContext::UNION() { return getToken(CypherParser::UNION, 0); } @@ -448,97 +438,95 @@ std::vector<tree::TerminalNode *> CypherParser::CypherUnionContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::CypherUnionContext::SP(size_t i) { +tree::TerminalNode *CypherParser::CypherUnionContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -tree::TerminalNode* CypherParser::CypherUnionContext::ALL() { +tree::TerminalNode *CypherParser::CypherUnionContext::ALL() { return getToken(CypherParser::ALL, 0); } -CypherParser::SingleQueryContext* CypherParser::CypherUnionContext::singleQuery() { +CypherParser::SingleQueryContext * +CypherParser::CypherUnionContext::singleQuery() { return getRuleContext<CypherParser::SingleQueryContext>(0); } - size_t CypherParser::CypherUnionContext::getRuleIndex() const { return CypherParser::RuleCypherUnion; } -void CypherParser::CypherUnionContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::CypherUnionContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterCypherUnion(this); + if (parserListener != nullptr) parserListener->enterCypherUnion(this); } -void CypherParser::CypherUnionContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::CypherUnionContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitCypherUnion(this); + if (parserListener != nullptr) parserListener->exitCypherUnion(this); } - -antlrcpp::Any CypherParser::CypherUnionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::CypherUnionContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitCypherUnion(this); else return visitor->visitChildren(this); } -CypherParser::CypherUnionContext* CypherParser::cypherUnion() { - CypherUnionContext *_localctx = _tracker.createInstance<CypherUnionContext>(_ctx, getState()); +CypherParser::CypherUnionContext *CypherParser::cypherUnion() { + CypherUnionContext *_localctx = + _tracker.createInstance<CypherUnionContext>(_ctx, getState()); enterRule(_localctx, 10, CypherParser::RuleCypherUnion); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(207); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 10, _ctx)) { - case 1: { - enterOuterAlt(_localctx, 1); - setState(195); - match(CypherParser::UNION); - setState(196); - match(CypherParser::SP); - setState(197); - match(CypherParser::ALL); - setState(199); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(198); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 10, _ctx)) { + case 1: { + enterOuterAlt(_localctx, 1); + setState(195); + match(CypherParser::UNION); + setState(196); match(CypherParser::SP); + setState(197); + match(CypherParser::ALL); + setState(199); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(198); + match(CypherParser::SP); + } + setState(201); + singleQuery(); + break; } - setState(201); - singleQuery(); - break; - } - case 2: { - enterOuterAlt(_localctx, 2); - setState(202); - match(CypherParser::UNION); - setState(204); - _errHandler->sync(this); + case 2: { + enterOuterAlt(_localctx, 2); + setState(202); + match(CypherParser::UNION); + setState(204); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(203); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(203); + match(CypherParser::SP); + } + setState(206); + singleQuery(); + break; } - setState(206); - singleQuery(); - break; } - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -547,80 +535,77 @@ CypherParser::CypherUnionContext* CypherParser::cypherUnion() { return _localctx; } -//----------------- ClauseContext ------------------------------------------------------------------ +//----------------- ClauseContext +//------------------------------------------------------------------ -CypherParser::ClauseContext::ClauseContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::ClauseContext::ClauseContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::CypherMatchContext* CypherParser::ClauseContext::cypherMatch() { +CypherParser::CypherMatchContext *CypherParser::ClauseContext::cypherMatch() { return getRuleContext<CypherParser::CypherMatchContext>(0); } -CypherParser::UnwindContext* CypherParser::ClauseContext::unwind() { +CypherParser::UnwindContext *CypherParser::ClauseContext::unwind() { return getRuleContext<CypherParser::UnwindContext>(0); } -CypherParser::MergeContext* CypherParser::ClauseContext::merge() { +CypherParser::MergeContext *CypherParser::ClauseContext::merge() { return getRuleContext<CypherParser::MergeContext>(0); } -CypherParser::CreateContext* CypherParser::ClauseContext::create() { +CypherParser::CreateContext *CypherParser::ClauseContext::create() { return getRuleContext<CypherParser::CreateContext>(0); } -CypherParser::SetContext* CypherParser::ClauseContext::set() { +CypherParser::SetContext *CypherParser::ClauseContext::set() { return getRuleContext<CypherParser::SetContext>(0); } -CypherParser::CypherDeleteContext* CypherParser::ClauseContext::cypherDelete() { +CypherParser::CypherDeleteContext *CypherParser::ClauseContext::cypherDelete() { return getRuleContext<CypherParser::CypherDeleteContext>(0); } -CypherParser::RemoveContext* CypherParser::ClauseContext::remove() { +CypherParser::RemoveContext *CypherParser::ClauseContext::remove() { return getRuleContext<CypherParser::RemoveContext>(0); } -CypherParser::WithContext* CypherParser::ClauseContext::with() { +CypherParser::WithContext *CypherParser::ClauseContext::with() { return getRuleContext<CypherParser::WithContext>(0); } -CypherParser::CypherReturnContext* CypherParser::ClauseContext::cypherReturn() { +CypherParser::CypherReturnContext *CypherParser::ClauseContext::cypherReturn() { return getRuleContext<CypherParser::CypherReturnContext>(0); } - size_t CypherParser::ClauseContext::getRuleIndex() const { return CypherParser::RuleClause; } void CypherParser::ClauseContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterClause(this); + if (parserListener != nullptr) parserListener->enterClause(this); } void CypherParser::ClauseContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitClause(this); + if (parserListener != nullptr) parserListener->exitClause(this); } - -antlrcpp::Any CypherParser::ClauseContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::ClauseContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitClause(this); else return visitor->visitChildren(this); } -CypherParser::ClauseContext* CypherParser::clause() { - ClauseContext *_localctx = _tracker.createInstance<ClauseContext>(_ctx, getState()); +CypherParser::ClauseContext *CypherParser::clause() { + ClauseContext *_localctx = + _tracker.createInstance<ClauseContext>(_ctx, getState()); enterRule(_localctx, 12, CypherParser::RuleClause); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(218); _errHandler->sync(this); @@ -690,12 +675,11 @@ CypherParser::ClauseContext* CypherParser::clause() { break; } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -704,21 +688,22 @@ CypherParser::ClauseContext* CypherParser::clause() { return _localctx; } -//----------------- CypherMatchContext ------------------------------------------------------------------ +//----------------- CypherMatchContext +//------------------------------------------------------------------ -CypherParser::CypherMatchContext::CypherMatchContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::CypherMatchContext::CypherMatchContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::CypherMatchContext::MATCH() { +tree::TerminalNode *CypherParser::CypherMatchContext::MATCH() { return getToken(CypherParser::MATCH, 0); } -CypherParser::PatternContext* CypherParser::CypherMatchContext::pattern() { +CypherParser::PatternContext *CypherParser::CypherMatchContext::pattern() { return getRuleContext<CypherParser::PatternContext>(0); } -tree::TerminalNode* CypherParser::CypherMatchContext::OPTIONAL() { +tree::TerminalNode *CypherParser::CypherMatchContext::OPTIONAL() { return getToken(CypherParser::OPTIONAL, 0); } @@ -726,47 +711,45 @@ std::vector<tree::TerminalNode *> CypherParser::CypherMatchContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::CypherMatchContext::SP(size_t i) { +tree::TerminalNode *CypherParser::CypherMatchContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -CypherParser::WhereContext* CypherParser::CypherMatchContext::where() { +CypherParser::WhereContext *CypherParser::CypherMatchContext::where() { return getRuleContext<CypherParser::WhereContext>(0); } - size_t CypherParser::CypherMatchContext::getRuleIndex() const { return CypherParser::RuleCypherMatch; } -void CypherParser::CypherMatchContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::CypherMatchContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterCypherMatch(this); + if (parserListener != nullptr) parserListener->enterCypherMatch(this); } -void CypherParser::CypherMatchContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::CypherMatchContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitCypherMatch(this); + if (parserListener != nullptr) parserListener->exitCypherMatch(this); } - -antlrcpp::Any CypherParser::CypherMatchContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::CypherMatchContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitCypherMatch(this); else return visitor->visitChildren(this); } -CypherParser::CypherMatchContext* CypherParser::cypherMatch() { - CypherMatchContext *_localctx = _tracker.createInstance<CypherMatchContext>(_ctx, getState()); +CypherParser::CypherMatchContext *CypherParser::cypherMatch() { + CypherMatchContext *_localctx = + _tracker.createInstance<CypherMatchContext>(_ctx, getState()); enterRule(_localctx, 14, CypherParser::RuleCypherMatch); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(222); @@ -794,25 +777,24 @@ CypherParser::CypherMatchContext* CypherParser::cypherMatch() { setState(233); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 15, _ctx)) { - case 1: { - setState(230); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 15, _ctx)) { + case 1: { + setState(230); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(229); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(229); + match(CypherParser::SP); + } + setState(232); + where(); + break; } - setState(232); - where(); - break; } - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -821,17 +803,18 @@ CypherParser::CypherMatchContext* CypherParser::cypherMatch() { return _localctx; } -//----------------- UnwindContext ------------------------------------------------------------------ +//----------------- UnwindContext +//------------------------------------------------------------------ -CypherParser::UnwindContext::UnwindContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::UnwindContext::UnwindContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::UnwindContext::UNWIND() { +tree::TerminalNode *CypherParser::UnwindContext::UNWIND() { return getToken(CypherParser::UNWIND, 0); } -CypherParser::ExpressionContext* CypherParser::UnwindContext::expression() { +CypherParser::ExpressionContext *CypherParser::UnwindContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } @@ -839,51 +822,47 @@ std::vector<tree::TerminalNode *> CypherParser::UnwindContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::UnwindContext::SP(size_t i) { +tree::TerminalNode *CypherParser::UnwindContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -tree::TerminalNode* CypherParser::UnwindContext::AS() { +tree::TerminalNode *CypherParser::UnwindContext::AS() { return getToken(CypherParser::AS, 0); } -CypherParser::VariableContext* CypherParser::UnwindContext::variable() { +CypherParser::VariableContext *CypherParser::UnwindContext::variable() { return getRuleContext<CypherParser::VariableContext>(0); } - size_t CypherParser::UnwindContext::getRuleIndex() const { return CypherParser::RuleUnwind; } void CypherParser::UnwindContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterUnwind(this); + if (parserListener != nullptr) parserListener->enterUnwind(this); } void CypherParser::UnwindContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitUnwind(this); + if (parserListener != nullptr) parserListener->exitUnwind(this); } - -antlrcpp::Any CypherParser::UnwindContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::UnwindContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitUnwind(this); else return visitor->visitChildren(this); } -CypherParser::UnwindContext* CypherParser::unwind() { - UnwindContext *_localctx = _tracker.createInstance<UnwindContext>(_ctx, getState()); +CypherParser::UnwindContext *CypherParser::unwind() { + UnwindContext *_localctx = + _tracker.createInstance<UnwindContext>(_ctx, getState()); enterRule(_localctx, 16, CypherParser::RuleUnwind); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(235); @@ -906,9 +885,8 @@ CypherParser::UnwindContext* CypherParser::unwind() { match(CypherParser::SP); setState(243); variable(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -917,17 +895,18 @@ CypherParser::UnwindContext* CypherParser::unwind() { return _localctx; } -//----------------- MergeContext ------------------------------------------------------------------ +//----------------- MergeContext +//------------------------------------------------------------------ -CypherParser::MergeContext::MergeContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::MergeContext::MergeContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::MergeContext::MERGE() { +tree::TerminalNode *CypherParser::MergeContext::MERGE() { return getToken(CypherParser::MERGE, 0); } -CypherParser::PatternPartContext* CypherParser::MergeContext::patternPart() { +CypherParser::PatternPartContext *CypherParser::MergeContext::patternPart() { return getRuleContext<CypherParser::PatternPartContext>(0); } @@ -935,51 +914,49 @@ std::vector<tree::TerminalNode *> CypherParser::MergeContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::MergeContext::SP(size_t i) { +tree::TerminalNode *CypherParser::MergeContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -std::vector<CypherParser::MergeActionContext *> CypherParser::MergeContext::mergeAction() { +std::vector<CypherParser::MergeActionContext *> +CypherParser::MergeContext::mergeAction() { return getRuleContexts<CypherParser::MergeActionContext>(); } -CypherParser::MergeActionContext* CypherParser::MergeContext::mergeAction(size_t i) { +CypherParser::MergeActionContext *CypherParser::MergeContext::mergeAction( + size_t i) { return getRuleContext<CypherParser::MergeActionContext>(i); } - size_t CypherParser::MergeContext::getRuleIndex() const { return CypherParser::RuleMerge; } void CypherParser::MergeContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterMerge(this); + if (parserListener != nullptr) parserListener->enterMerge(this); } void CypherParser::MergeContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitMerge(this); + if (parserListener != nullptr) parserListener->exitMerge(this); } - -antlrcpp::Any CypherParser::MergeContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::MergeContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitMerge(this); else return visitor->visitChildren(this); } -CypherParser::MergeContext* CypherParser::merge() { - MergeContext *_localctx = _tracker.createInstance<MergeContext>(_ctx, getState()); +CypherParser::MergeContext *CypherParser::merge() { + MergeContext *_localctx = + _tracker.createInstance<MergeContext>(_ctx, getState()); enterRule(_localctx, 18, CypherParser::RuleMerge); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -997,21 +974,22 @@ CypherParser::MergeContext* CypherParser::merge() { patternPart(); setState(254); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 18, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 18, + _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(250); match(CypherParser::SP); setState(251); - mergeAction(); + mergeAction(); } setState(256); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 18, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 18, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1020,13 +998,14 @@ CypherParser::MergeContext* CypherParser::merge() { return _localctx; } -//----------------- MergeActionContext ------------------------------------------------------------------ +//----------------- MergeActionContext +//------------------------------------------------------------------ -CypherParser::MergeActionContext::MergeActionContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::MergeActionContext::MergeActionContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::MergeActionContext::ON() { +tree::TerminalNode *CypherParser::MergeActionContext::ON() { return getToken(CypherParser::ON, 0); } @@ -1034,92 +1013,89 @@ std::vector<tree::TerminalNode *> CypherParser::MergeActionContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::MergeActionContext::SP(size_t i) { +tree::TerminalNode *CypherParser::MergeActionContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -tree::TerminalNode* CypherParser::MergeActionContext::MATCH() { +tree::TerminalNode *CypherParser::MergeActionContext::MATCH() { return getToken(CypherParser::MATCH, 0); } -CypherParser::SetContext* CypherParser::MergeActionContext::set() { +CypherParser::SetContext *CypherParser::MergeActionContext::set() { return getRuleContext<CypherParser::SetContext>(0); } -tree::TerminalNode* CypherParser::MergeActionContext::CREATE() { +tree::TerminalNode *CypherParser::MergeActionContext::CREATE() { return getToken(CypherParser::CREATE, 0); } - size_t CypherParser::MergeActionContext::getRuleIndex() const { return CypherParser::RuleMergeAction; } -void CypherParser::MergeActionContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::MergeActionContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterMergeAction(this); + if (parserListener != nullptr) parserListener->enterMergeAction(this); } -void CypherParser::MergeActionContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::MergeActionContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitMergeAction(this); + if (parserListener != nullptr) parserListener->exitMergeAction(this); } - -antlrcpp::Any CypherParser::MergeActionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::MergeActionContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitMergeAction(this); else return visitor->visitChildren(this); } -CypherParser::MergeActionContext* CypherParser::mergeAction() { - MergeActionContext *_localctx = _tracker.createInstance<MergeActionContext>(_ctx, getState()); +CypherParser::MergeActionContext *CypherParser::mergeAction() { + MergeActionContext *_localctx = + _tracker.createInstance<MergeActionContext>(_ctx, getState()); enterRule(_localctx, 20, CypherParser::RuleMergeAction); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(267); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 19, _ctx)) { - case 1: { - enterOuterAlt(_localctx, 1); - setState(257); - match(CypherParser::ON); - setState(258); - match(CypherParser::SP); - setState(259); - match(CypherParser::MATCH); - setState(260); - match(CypherParser::SP); - setState(261); - set(); - break; + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 19, _ctx)) { + case 1: { + enterOuterAlt(_localctx, 1); + setState(257); + match(CypherParser::ON); + setState(258); + match(CypherParser::SP); + setState(259); + match(CypherParser::MATCH); + setState(260); + match(CypherParser::SP); + setState(261); + set(); + break; + } + + case 2: { + enterOuterAlt(_localctx, 2); + setState(262); + match(CypherParser::ON); + setState(263); + match(CypherParser::SP); + setState(264); + match(CypherParser::CREATE); + setState(265); + match(CypherParser::SP); + setState(266); + set(); + break; + } } - case 2: { - enterOuterAlt(_localctx, 2); - setState(262); - match(CypherParser::ON); - setState(263); - match(CypherParser::SP); - setState(264); - match(CypherParser::CREATE); - setState(265); - match(CypherParser::SP); - setState(266); - set(); - break; - } - - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1128,57 +1104,54 @@ CypherParser::MergeActionContext* CypherParser::mergeAction() { return _localctx; } -//----------------- CreateContext ------------------------------------------------------------------ +//----------------- CreateContext +//------------------------------------------------------------------ -CypherParser::CreateContext::CreateContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::CreateContext::CreateContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::CreateContext::CREATE() { +tree::TerminalNode *CypherParser::CreateContext::CREATE() { return getToken(CypherParser::CREATE, 0); } -CypherParser::PatternContext* CypherParser::CreateContext::pattern() { +CypherParser::PatternContext *CypherParser::CreateContext::pattern() { return getRuleContext<CypherParser::PatternContext>(0); } -tree::TerminalNode* CypherParser::CreateContext::SP() { +tree::TerminalNode *CypherParser::CreateContext::SP() { return getToken(CypherParser::SP, 0); } - size_t CypherParser::CreateContext::getRuleIndex() const { return CypherParser::RuleCreate; } void CypherParser::CreateContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterCreate(this); + if (parserListener != nullptr) parserListener->enterCreate(this); } void CypherParser::CreateContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitCreate(this); + if (parserListener != nullptr) parserListener->exitCreate(this); } - -antlrcpp::Any CypherParser::CreateContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::CreateContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitCreate(this); else return visitor->visitChildren(this); } -CypherParser::CreateContext* CypherParser::create() { - CreateContext *_localctx = _tracker.createInstance<CreateContext>(_ctx, getState()); +CypherParser::CreateContext *CypherParser::create() { + CreateContext *_localctx = + _tracker.createInstance<CreateContext>(_ctx, getState()); enterRule(_localctx, 22, CypherParser::RuleCreate); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(269); @@ -1193,9 +1166,8 @@ CypherParser::CreateContext* CypherParser::create() { } setState(273); pattern(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1204,57 +1176,54 @@ CypherParser::CreateContext* CypherParser::create() { return _localctx; } -//----------------- SetContext ------------------------------------------------------------------ +//----------------- SetContext +//------------------------------------------------------------------ -CypherParser::SetContext::SetContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::SetContext::SetContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::SetContext::SET() { +tree::TerminalNode *CypherParser::SetContext::SET() { return getToken(CypherParser::SET, 0); } -std::vector<CypherParser::SetItemContext *> CypherParser::SetContext::setItem() { +std::vector<CypherParser::SetItemContext *> +CypherParser::SetContext::setItem() { return getRuleContexts<CypherParser::SetItemContext>(); } -CypherParser::SetItemContext* CypherParser::SetContext::setItem(size_t i) { +CypherParser::SetItemContext *CypherParser::SetContext::setItem(size_t i) { return getRuleContext<CypherParser::SetItemContext>(i); } - size_t CypherParser::SetContext::getRuleIndex() const { return CypherParser::RuleSet; } void CypherParser::SetContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterSet(this); + if (parserListener != nullptr) parserListener->enterSet(this); } void CypherParser::SetContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitSet(this); + if (parserListener != nullptr) parserListener->exitSet(this); } - -antlrcpp::Any CypherParser::SetContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::SetContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitSet(this); else return visitor->visitChildren(this); } -CypherParser::SetContext* CypherParser::set() { +CypherParser::SetContext *CypherParser::set() { SetContext *_localctx = _tracker.createInstance<SetContext>(_ctx, getState()); enterRule(_localctx, 24, CypherParser::RuleSet); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(275); @@ -1273,9 +1242,8 @@ CypherParser::SetContext* CypherParser::set() { _errHandler->sync(this); _la = _input->LA(1); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1284,110 +1252,108 @@ CypherParser::SetContext* CypherParser::set() { return _localctx; } -//----------------- SetItemContext ------------------------------------------------------------------ +//----------------- SetItemContext +//------------------------------------------------------------------ -CypherParser::SetItemContext::SetItemContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::SetItemContext::SetItemContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::PropertyExpressionContext* CypherParser::SetItemContext::propertyExpression() { +CypherParser::PropertyExpressionContext * +CypherParser::SetItemContext::propertyExpression() { return getRuleContext<CypherParser::PropertyExpressionContext>(0); } -CypherParser::ExpressionContext* CypherParser::SetItemContext::expression() { +CypherParser::ExpressionContext *CypherParser::SetItemContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } -CypherParser::VariableContext* CypherParser::SetItemContext::variable() { +CypherParser::VariableContext *CypherParser::SetItemContext::variable() { return getRuleContext<CypherParser::VariableContext>(0); } -CypherParser::NodeLabelsContext* CypherParser::SetItemContext::nodeLabels() { +CypherParser::NodeLabelsContext *CypherParser::SetItemContext::nodeLabels() { return getRuleContext<CypherParser::NodeLabelsContext>(0); } - size_t CypherParser::SetItemContext::getRuleIndex() const { return CypherParser::RuleSetItem; } -void CypherParser::SetItemContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::SetItemContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterSetItem(this); + if (parserListener != nullptr) parserListener->enterSetItem(this); } void CypherParser::SetItemContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitSetItem(this); + if (parserListener != nullptr) parserListener->exitSetItem(this); } - -antlrcpp::Any CypherParser::SetItemContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::SetItemContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitSetItem(this); else return visitor->visitChildren(this); } -CypherParser::SetItemContext* CypherParser::setItem() { - SetItemContext *_localctx = _tracker.createInstance<SetItemContext>(_ctx, getState()); +CypherParser::SetItemContext *CypherParser::setItem() { + SetItemContext *_localctx = + _tracker.createInstance<SetItemContext>(_ctx, getState()); enterRule(_localctx, 26, CypherParser::RuleSetItem); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(299); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 22, _ctx)) { - case 1: { - enterOuterAlt(_localctx, 1); - setState(284); - propertyExpression(); - setState(285); - match(CypherParser::T__2); - setState(286); - expression(); - break; + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 22, _ctx)) { + case 1: { + enterOuterAlt(_localctx, 1); + setState(284); + propertyExpression(); + setState(285); + match(CypherParser::T__2); + setState(286); + expression(); + break; + } + + case 2: { + enterOuterAlt(_localctx, 2); + setState(288); + variable(); + setState(289); + match(CypherParser::T__2); + setState(290); + expression(); + break; + } + + case 3: { + enterOuterAlt(_localctx, 3); + setState(292); + variable(); + setState(293); + match(CypherParser::T__3); + setState(294); + expression(); + break; + } + + case 4: { + enterOuterAlt(_localctx, 4); + setState(296); + variable(); + setState(297); + nodeLabels(); + break; + } } - case 2: { - enterOuterAlt(_localctx, 2); - setState(288); - variable(); - setState(289); - match(CypherParser::T__2); - setState(290); - expression(); - break; - } - - case 3: { - enterOuterAlt(_localctx, 3); - setState(292); - variable(); - setState(293); - match(CypherParser::T__3); - setState(294); - expression(); - break; - } - - case 4: { - enterOuterAlt(_localctx, 4); - setState(296); - variable(); - setState(297); - nodeLabels(); - break; - } - - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1396,25 +1362,28 @@ CypherParser::SetItemContext* CypherParser::setItem() { return _localctx; } -//----------------- CypherDeleteContext ------------------------------------------------------------------ +//----------------- CypherDeleteContext +//------------------------------------------------------------------ -CypherParser::CypherDeleteContext::CypherDeleteContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::CypherDeleteContext::CypherDeleteContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::CypherDeleteContext::DELETE() { +tree::TerminalNode *CypherParser::CypherDeleteContext::DELETE() { return getToken(CypherParser::DELETE, 0); } -std::vector<CypherParser::ExpressionContext *> CypherParser::CypherDeleteContext::expression() { +std::vector<CypherParser::ExpressionContext *> +CypherParser::CypherDeleteContext::expression() { return getRuleContexts<CypherParser::ExpressionContext>(); } -CypherParser::ExpressionContext* CypherParser::CypherDeleteContext::expression(size_t i) { +CypherParser::ExpressionContext *CypherParser::CypherDeleteContext::expression( + size_t i) { return getRuleContext<CypherParser::ExpressionContext>(i); } -tree::TerminalNode* CypherParser::CypherDeleteContext::DETACH() { +tree::TerminalNode *CypherParser::CypherDeleteContext::DETACH() { return getToken(CypherParser::DETACH, 0); } @@ -1422,43 +1391,41 @@ std::vector<tree::TerminalNode *> CypherParser::CypherDeleteContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::CypherDeleteContext::SP(size_t i) { +tree::TerminalNode *CypherParser::CypherDeleteContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::CypherDeleteContext::getRuleIndex() const { return CypherParser::RuleCypherDelete; } -void CypherParser::CypherDeleteContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::CypherDeleteContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterCypherDelete(this); + if (parserListener != nullptr) parserListener->enterCypherDelete(this); } -void CypherParser::CypherDeleteContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::CypherDeleteContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitCypherDelete(this); + if (parserListener != nullptr) parserListener->exitCypherDelete(this); } - -antlrcpp::Any CypherParser::CypherDeleteContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::CypherDeleteContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitCypherDelete(this); else return visitor->visitChildren(this); } -CypherParser::CypherDeleteContext* CypherParser::cypherDelete() { - CypherDeleteContext *_localctx = _tracker.createInstance<CypherDeleteContext>(_ctx, getState()); +CypherParser::CypherDeleteContext *CypherParser::cypherDelete() { + CypherDeleteContext *_localctx = + _tracker.createInstance<CypherDeleteContext>(_ctx, getState()); enterRule(_localctx, 28, CypherParser::RuleCypherDelete); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -1486,7 +1453,8 @@ CypherParser::CypherDeleteContext* CypherParser::cypherDelete() { expression(); setState(320); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 27, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 27, + _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(311); @@ -1508,15 +1476,15 @@ CypherParser::CypherDeleteContext* CypherParser::cypherDelete() { match(CypherParser::SP); } setState(317); - expression(); + expression(); } setState(322); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 27, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 27, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1525,13 +1493,14 @@ CypherParser::CypherDeleteContext* CypherParser::cypherDelete() { return _localctx; } -//----------------- RemoveContext ------------------------------------------------------------------ +//----------------- RemoveContext +//------------------------------------------------------------------ -CypherParser::RemoveContext::RemoveContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::RemoveContext::RemoveContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::RemoveContext::REMOVE() { +tree::TerminalNode *CypherParser::RemoveContext::REMOVE() { return getToken(CypherParser::REMOVE, 0); } @@ -1539,51 +1508,49 @@ std::vector<tree::TerminalNode *> CypherParser::RemoveContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::RemoveContext::SP(size_t i) { +tree::TerminalNode *CypherParser::RemoveContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -std::vector<CypherParser::RemoveItemContext *> CypherParser::RemoveContext::removeItem() { +std::vector<CypherParser::RemoveItemContext *> +CypherParser::RemoveContext::removeItem() { return getRuleContexts<CypherParser::RemoveItemContext>(); } -CypherParser::RemoveItemContext* CypherParser::RemoveContext::removeItem(size_t i) { +CypherParser::RemoveItemContext *CypherParser::RemoveContext::removeItem( + size_t i) { return getRuleContext<CypherParser::RemoveItemContext>(i); } - size_t CypherParser::RemoveContext::getRuleIndex() const { return CypherParser::RuleRemove; } void CypherParser::RemoveContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterRemove(this); + if (parserListener != nullptr) parserListener->enterRemove(this); } void CypherParser::RemoveContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRemove(this); + if (parserListener != nullptr) parserListener->exitRemove(this); } - -antlrcpp::Any CypherParser::RemoveContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RemoveContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRemove(this); else return visitor->visitChildren(this); } -CypherParser::RemoveContext* CypherParser::remove() { - RemoveContext *_localctx = _tracker.createInstance<RemoveContext>(_ctx, getState()); +CypherParser::RemoveContext *CypherParser::remove() { + RemoveContext *_localctx = + _tracker.createInstance<RemoveContext>(_ctx, getState()); enterRule(_localctx, 30, CypherParser::RuleRemove); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -1595,7 +1562,8 @@ CypherParser::RemoveContext* CypherParser::remove() { removeItem(); setState(336); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 30, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 30, + _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(327); @@ -1617,15 +1585,15 @@ CypherParser::RemoveContext* CypherParser::remove() { match(CypherParser::SP); } setState(333); - removeItem(); + removeItem(); } setState(338); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 30, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 30, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1634,80 +1602,79 @@ CypherParser::RemoveContext* CypherParser::remove() { return _localctx; } -//----------------- RemoveItemContext ------------------------------------------------------------------ +//----------------- RemoveItemContext +//------------------------------------------------------------------ -CypherParser::RemoveItemContext::RemoveItemContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::RemoveItemContext::RemoveItemContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::VariableContext* CypherParser::RemoveItemContext::variable() { +CypherParser::VariableContext *CypherParser::RemoveItemContext::variable() { return getRuleContext<CypherParser::VariableContext>(0); } -CypherParser::NodeLabelsContext* CypherParser::RemoveItemContext::nodeLabels() { +CypherParser::NodeLabelsContext *CypherParser::RemoveItemContext::nodeLabels() { return getRuleContext<CypherParser::NodeLabelsContext>(0); } -CypherParser::PropertyExpressionContext* CypherParser::RemoveItemContext::propertyExpression() { +CypherParser::PropertyExpressionContext * +CypherParser::RemoveItemContext::propertyExpression() { return getRuleContext<CypherParser::PropertyExpressionContext>(0); } - size_t CypherParser::RemoveItemContext::getRuleIndex() const { return CypherParser::RuleRemoveItem; } -void CypherParser::RemoveItemContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::RemoveItemContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterRemoveItem(this); + if (parserListener != nullptr) parserListener->enterRemoveItem(this); } -void CypherParser::RemoveItemContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::RemoveItemContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRemoveItem(this); + if (parserListener != nullptr) parserListener->exitRemoveItem(this); } - -antlrcpp::Any CypherParser::RemoveItemContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RemoveItemContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRemoveItem(this); else return visitor->visitChildren(this); } -CypherParser::RemoveItemContext* CypherParser::removeItem() { - RemoveItemContext *_localctx = _tracker.createInstance<RemoveItemContext>(_ctx, getState()); +CypherParser::RemoveItemContext *CypherParser::removeItem() { + RemoveItemContext *_localctx = + _tracker.createInstance<RemoveItemContext>(_ctx, getState()); enterRule(_localctx, 32, CypherParser::RuleRemoveItem); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(343); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 31, _ctx)) { - case 1: { - enterOuterAlt(_localctx, 1); - setState(339); - variable(); - setState(340); - nodeLabels(); - break; + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 31, _ctx)) { + case 1: { + enterOuterAlt(_localctx, 1); + setState(339); + variable(); + setState(340); + nodeLabels(); + break; + } + + case 2: { + enterOuterAlt(_localctx, 2); + setState(342); + propertyExpression(); + break; + } } - case 2: { - enterOuterAlt(_localctx, 2); - setState(342); - propertyExpression(); - break; - } - - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1716,13 +1683,14 @@ CypherParser::RemoveItemContext* CypherParser::removeItem() { return _localctx; } -//----------------- WithContext ------------------------------------------------------------------ +//----------------- WithContext +//------------------------------------------------------------------ -CypherParser::WithContext::WithContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::WithContext::WithContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::WithContext::WITH() { +tree::TerminalNode *CypherParser::WithContext::WITH() { return getToken(CypherParser::WITH, 0); } @@ -1730,55 +1698,51 @@ std::vector<tree::TerminalNode *> CypherParser::WithContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::WithContext::SP(size_t i) { +tree::TerminalNode *CypherParser::WithContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -CypherParser::ReturnBodyContext* CypherParser::WithContext::returnBody() { +CypherParser::ReturnBodyContext *CypherParser::WithContext::returnBody() { return getRuleContext<CypherParser::ReturnBodyContext>(0); } -tree::TerminalNode* CypherParser::WithContext::DISTINCT() { +tree::TerminalNode *CypherParser::WithContext::DISTINCT() { return getToken(CypherParser::DISTINCT, 0); } -CypherParser::WhereContext* CypherParser::WithContext::where() { +CypherParser::WhereContext *CypherParser::WithContext::where() { return getRuleContext<CypherParser::WhereContext>(0); } - size_t CypherParser::WithContext::getRuleIndex() const { return CypherParser::RuleWith; } void CypherParser::WithContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterWith(this); + if (parserListener != nullptr) parserListener->enterWith(this); } void CypherParser::WithContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitWith(this); + if (parserListener != nullptr) parserListener->exitWith(this); } - -antlrcpp::Any CypherParser::WithContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::WithContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitWith(this); else return visitor->visitChildren(this); } -CypherParser::WithContext* CypherParser::with() { - WithContext *_localctx = _tracker.createInstance<WithContext>(_ctx, getState()); +CypherParser::WithContext *CypherParser::with() { + WithContext *_localctx = + _tracker.createInstance<WithContext>(_ctx, getState()); enterRule(_localctx, 34, CypherParser::RuleWith); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(345); @@ -1786,21 +1750,21 @@ CypherParser::WithContext* CypherParser::with() { setState(350); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 33, _ctx)) { - case 1: { - setState(347); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 33, _ctx)) { + case 1: { + setState(347); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(346); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(346); + match(CypherParser::SP); + } + setState(349); + match(CypherParser::DISTINCT); + break; } - setState(349); - match(CypherParser::DISTINCT); - break; - } - } setState(352); match(CypherParser::SP); @@ -1809,25 +1773,24 @@ CypherParser::WithContext* CypherParser::with() { setState(358); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 35, _ctx)) { - case 1: { - setState(355); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 35, _ctx)) { + case 1: { + setState(355); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(354); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(354); + match(CypherParser::SP); + } + setState(357); + where(); + break; } - setState(357); - where(); - break; } - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1836,13 +1799,14 @@ CypherParser::WithContext* CypherParser::with() { return _localctx; } -//----------------- CypherReturnContext ------------------------------------------------------------------ +//----------------- CypherReturnContext +//------------------------------------------------------------------ -CypherParser::CypherReturnContext::CypherReturnContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::CypherReturnContext::CypherReturnContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::CypherReturnContext::RETURN() { +tree::TerminalNode *CypherParser::CypherReturnContext::RETURN() { return getToken(CypherParser::RETURN, 0); } @@ -1850,51 +1814,50 @@ std::vector<tree::TerminalNode *> CypherParser::CypherReturnContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::CypherReturnContext::SP(size_t i) { +tree::TerminalNode *CypherParser::CypherReturnContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -CypherParser::ReturnBodyContext* CypherParser::CypherReturnContext::returnBody() { +CypherParser::ReturnBodyContext * +CypherParser::CypherReturnContext::returnBody() { return getRuleContext<CypherParser::ReturnBodyContext>(0); } -tree::TerminalNode* CypherParser::CypherReturnContext::DISTINCT() { +tree::TerminalNode *CypherParser::CypherReturnContext::DISTINCT() { return getToken(CypherParser::DISTINCT, 0); } - size_t CypherParser::CypherReturnContext::getRuleIndex() const { return CypherParser::RuleCypherReturn; } -void CypherParser::CypherReturnContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::CypherReturnContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterCypherReturn(this); + if (parserListener != nullptr) parserListener->enterCypherReturn(this); } -void CypherParser::CypherReturnContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::CypherReturnContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitCypherReturn(this); + if (parserListener != nullptr) parserListener->exitCypherReturn(this); } - -antlrcpp::Any CypherParser::CypherReturnContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::CypherReturnContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitCypherReturn(this); else return visitor->visitChildren(this); } -CypherParser::CypherReturnContext* CypherParser::cypherReturn() { - CypherReturnContext *_localctx = _tracker.createInstance<CypherReturnContext>(_ctx, getState()); +CypherParser::CypherReturnContext *CypherParser::cypherReturn() { + CypherReturnContext *_localctx = + _tracker.createInstance<CypherReturnContext>(_ctx, getState()); enterRule(_localctx, 36, CypherParser::RuleCypherReturn); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(360); @@ -1902,29 +1865,28 @@ CypherParser::CypherReturnContext* CypherParser::cypherReturn() { setState(365); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 37, _ctx)) { - case 1: { - setState(362); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 37, _ctx)) { + case 1: { + setState(362); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(361); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(361); + match(CypherParser::SP); + } + setState(364); + match(CypherParser::DISTINCT); + break; } - setState(364); - match(CypherParser::DISTINCT); - break; - } - } setState(367); match(CypherParser::SP); setState(368); returnBody(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -1933,13 +1895,15 @@ CypherParser::CypherReturnContext* CypherParser::cypherReturn() { return _localctx; } -//----------------- ReturnBodyContext ------------------------------------------------------------------ +//----------------- ReturnBodyContext +//------------------------------------------------------------------ -CypherParser::ReturnBodyContext::ReturnBodyContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::ReturnBodyContext::ReturnBodyContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::ReturnItemsContext* CypherParser::ReturnBodyContext::returnItems() { +CypherParser::ReturnItemsContext * +CypherParser::ReturnBodyContext::returnItems() { return getRuleContext<CypherParser::ReturnItemsContext>(0); } @@ -1947,54 +1911,52 @@ std::vector<tree::TerminalNode *> CypherParser::ReturnBodyContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::ReturnBodyContext::SP(size_t i) { +tree::TerminalNode *CypherParser::ReturnBodyContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -CypherParser::OrderContext* CypherParser::ReturnBodyContext::order() { +CypherParser::OrderContext *CypherParser::ReturnBodyContext::order() { return getRuleContext<CypherParser::OrderContext>(0); } -CypherParser::SkipContext* CypherParser::ReturnBodyContext::skip() { +CypherParser::SkipContext *CypherParser::ReturnBodyContext::skip() { return getRuleContext<CypherParser::SkipContext>(0); } -CypherParser::LimitContext* CypherParser::ReturnBodyContext::limit() { +CypherParser::LimitContext *CypherParser::ReturnBodyContext::limit() { return getRuleContext<CypherParser::LimitContext>(0); } - size_t CypherParser::ReturnBodyContext::getRuleIndex() const { return CypherParser::RuleReturnBody; } -void CypherParser::ReturnBodyContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::ReturnBodyContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterReturnBody(this); + if (parserListener != nullptr) parserListener->enterReturnBody(this); } -void CypherParser::ReturnBodyContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::ReturnBodyContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitReturnBody(this); + if (parserListener != nullptr) parserListener->exitReturnBody(this); } - -antlrcpp::Any CypherParser::ReturnBodyContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::ReturnBodyContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitReturnBody(this); else return visitor->visitChildren(this); } -CypherParser::ReturnBodyContext* CypherParser::returnBody() { - ReturnBodyContext *_localctx = _tracker.createInstance<ReturnBodyContext>(_ctx, getState()); +CypherParser::ReturnBodyContext *CypherParser::returnBody() { + ReturnBodyContext *_localctx = + _tracker.createInstance<ReturnBodyContext>(_ctx, getState()); enterRule(_localctx, 38, CypherParser::RuleReturnBody); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(370); @@ -2002,45 +1964,44 @@ CypherParser::ReturnBodyContext* CypherParser::returnBody() { setState(373); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 38, _ctx)) { - case 1: { - setState(371); - match(CypherParser::SP); - setState(372); - order(); - break; - } - + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 38, _ctx)) { + case 1: { + setState(371); + match(CypherParser::SP); + setState(372); + order(); + break; + } } setState(377); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 39, _ctx)) { - case 1: { - setState(375); - match(CypherParser::SP); - setState(376); - skip(); - break; - } - + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 39, _ctx)) { + case 1: { + setState(375); + match(CypherParser::SP); + setState(376); + skip(); + break; + } } setState(381); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 40, _ctx)) { - case 1: { - setState(379); - match(CypherParser::SP); - setState(380); - limit(); - break; + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 40, _ctx)) { + case 1: { + setState(379); + match(CypherParser::SP); + setState(380); + limit(); + break; + } } - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -2049,17 +2010,20 @@ CypherParser::ReturnBodyContext* CypherParser::returnBody() { return _localctx; } -//----------------- ReturnItemsContext ------------------------------------------------------------------ +//----------------- ReturnItemsContext +//------------------------------------------------------------------ -CypherParser::ReturnItemsContext::ReturnItemsContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::ReturnItemsContext::ReturnItemsContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::ReturnItemContext *> CypherParser::ReturnItemsContext::returnItem() { +std::vector<CypherParser::ReturnItemContext *> +CypherParser::ReturnItemsContext::returnItem() { return getRuleContexts<CypherParser::ReturnItemContext>(); } -CypherParser::ReturnItemContext* CypherParser::ReturnItemsContext::returnItem(size_t i) { +CypherParser::ReturnItemContext *CypherParser::ReturnItemsContext::returnItem( + size_t i) { return getRuleContext<CypherParser::ReturnItemContext>(i); } @@ -2067,43 +2031,41 @@ std::vector<tree::TerminalNode *> CypherParser::ReturnItemsContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::ReturnItemsContext::SP(size_t i) { +tree::TerminalNode *CypherParser::ReturnItemsContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::ReturnItemsContext::getRuleIndex() const { return CypherParser::RuleReturnItems; } -void CypherParser::ReturnItemsContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::ReturnItemsContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterReturnItems(this); + if (parserListener != nullptr) parserListener->enterReturnItems(this); } -void CypherParser::ReturnItemsContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::ReturnItemsContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitReturnItems(this); + if (parserListener != nullptr) parserListener->exitReturnItems(this); } - -antlrcpp::Any CypherParser::ReturnItemsContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::ReturnItemsContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitReturnItems(this); else return visitor->visitChildren(this); } -CypherParser::ReturnItemsContext* CypherParser::returnItems() { - ReturnItemsContext *_localctx = _tracker.createInstance<ReturnItemsContext>(_ctx, getState()); +CypherParser::ReturnItemsContext *CypherParser::returnItems() { + ReturnItemsContext *_localctx = + _tracker.createInstance<ReturnItemsContext>(_ctx, getState()); enterRule(_localctx, 40, CypherParser::RuleReturnItems); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; setState(411); @@ -2115,7 +2077,8 @@ CypherParser::ReturnItemsContext* CypherParser::returnItems() { match(CypherParser::T__4); setState(394); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 43, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 43, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(385); @@ -2137,11 +2100,12 @@ CypherParser::ReturnItemsContext* CypherParser::returnItems() { match(CypherParser::SP); } setState(391); - returnItem(); + returnItem(); } setState(396); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 43, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 43, _ctx); } break; } @@ -2209,7 +2173,8 @@ CypherParser::ReturnItemsContext* CypherParser::returnItems() { returnItem(); setState(408); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 46, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 46, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(399); @@ -2231,21 +2196,21 @@ CypherParser::ReturnItemsContext* CypherParser::returnItems() { match(CypherParser::SP); } setState(405); - returnItem(); + returnItem(); } setState(410); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 46, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 46, _ctx); } break; } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -2254,13 +2219,14 @@ CypherParser::ReturnItemsContext* CypherParser::returnItems() { return _localctx; } -//----------------- ReturnItemContext ------------------------------------------------------------------ +//----------------- ReturnItemContext +//------------------------------------------------------------------ -CypherParser::ReturnItemContext::ReturnItemContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::ReturnItemContext::ReturnItemContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::ExpressionContext* CypherParser::ReturnItemContext::expression() { +CypherParser::ExpressionContext *CypherParser::ReturnItemContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } @@ -2268,80 +2234,77 @@ std::vector<tree::TerminalNode *> CypherParser::ReturnItemContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::ReturnItemContext::SP(size_t i) { +tree::TerminalNode *CypherParser::ReturnItemContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -tree::TerminalNode* CypherParser::ReturnItemContext::AS() { +tree::TerminalNode *CypherParser::ReturnItemContext::AS() { return getToken(CypherParser::AS, 0); } -CypherParser::VariableContext* CypherParser::ReturnItemContext::variable() { +CypherParser::VariableContext *CypherParser::ReturnItemContext::variable() { return getRuleContext<CypherParser::VariableContext>(0); } - size_t CypherParser::ReturnItemContext::getRuleIndex() const { return CypherParser::RuleReturnItem; } -void CypherParser::ReturnItemContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::ReturnItemContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterReturnItem(this); + if (parserListener != nullptr) parserListener->enterReturnItem(this); } -void CypherParser::ReturnItemContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::ReturnItemContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitReturnItem(this); + if (parserListener != nullptr) parserListener->exitReturnItem(this); } - -antlrcpp::Any CypherParser::ReturnItemContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::ReturnItemContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitReturnItem(this); else return visitor->visitChildren(this); } -CypherParser::ReturnItemContext* CypherParser::returnItem() { - ReturnItemContext *_localctx = _tracker.createInstance<ReturnItemContext>(_ctx, getState()); +CypherParser::ReturnItemContext *CypherParser::returnItem() { + ReturnItemContext *_localctx = + _tracker.createInstance<ReturnItemContext>(_ctx, getState()); enterRule(_localctx, 42, CypherParser::RuleReturnItem); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(420); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 48, _ctx)) { - case 1: { - enterOuterAlt(_localctx, 1); - setState(413); - expression(); - setState(414); - match(CypherParser::SP); - setState(415); - match(CypherParser::AS); - setState(416); - match(CypherParser::SP); - setState(417); - variable(); - break; + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 48, _ctx)) { + case 1: { + enterOuterAlt(_localctx, 1); + setState(413); + expression(); + setState(414); + match(CypherParser::SP); + setState(415); + match(CypherParser::AS); + setState(416); + match(CypherParser::SP); + setState(417); + variable(); + break; + } + + case 2: { + enterOuterAlt(_localctx, 2); + setState(419); + expression(); + break; + } } - case 2: { - enterOuterAlt(_localctx, 2); - setState(419); - expression(); - break; - } - - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -2350,13 +2313,14 @@ CypherParser::ReturnItemContext* CypherParser::returnItem() { return _localctx; } -//----------------- OrderContext ------------------------------------------------------------------ +//----------------- OrderContext +//------------------------------------------------------------------ -CypherParser::OrderContext::OrderContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::OrderContext::OrderContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::OrderContext::ORDER() { +tree::TerminalNode *CypherParser::OrderContext::ORDER() { return getToken(CypherParser::ORDER, 0); } @@ -2364,55 +2328,52 @@ std::vector<tree::TerminalNode *> CypherParser::OrderContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::OrderContext::SP(size_t i) { +tree::TerminalNode *CypherParser::OrderContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -tree::TerminalNode* CypherParser::OrderContext::BY() { +tree::TerminalNode *CypherParser::OrderContext::BY() { return getToken(CypherParser::BY, 0); } -std::vector<CypherParser::SortItemContext *> CypherParser::OrderContext::sortItem() { +std::vector<CypherParser::SortItemContext *> +CypherParser::OrderContext::sortItem() { return getRuleContexts<CypherParser::SortItemContext>(); } -CypherParser::SortItemContext* CypherParser::OrderContext::sortItem(size_t i) { +CypherParser::SortItemContext *CypherParser::OrderContext::sortItem(size_t i) { return getRuleContext<CypherParser::SortItemContext>(i); } - size_t CypherParser::OrderContext::getRuleIndex() const { return CypherParser::RuleOrder; } void CypherParser::OrderContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterOrder(this); + if (parserListener != nullptr) parserListener->enterOrder(this); } void CypherParser::OrderContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitOrder(this); + if (parserListener != nullptr) parserListener->exitOrder(this); } - -antlrcpp::Any CypherParser::OrderContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::OrderContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitOrder(this); else return visitor->visitChildren(this); } -CypherParser::OrderContext* CypherParser::order() { - OrderContext *_localctx = _tracker.createInstance<OrderContext>(_ctx, getState()); +CypherParser::OrderContext *CypherParser::order() { + OrderContext *_localctx = + _tracker.createInstance<OrderContext>(_ctx, getState()); enterRule(_localctx, 44, CypherParser::RuleOrder); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(422); @@ -2445,9 +2406,8 @@ CypherParser::OrderContext* CypherParser::order() { _errHandler->sync(this); _la = _input->LA(1); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -2456,56 +2416,53 @@ CypherParser::OrderContext* CypherParser::order() { return _localctx; } -//----------------- SkipContext ------------------------------------------------------------------ +//----------------- SkipContext +//------------------------------------------------------------------ -CypherParser::SkipContext::SkipContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::SkipContext::SkipContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::SkipContext::L_SKIP() { +tree::TerminalNode *CypherParser::SkipContext::L_SKIP() { return getToken(CypherParser::L_SKIP, 0); } -tree::TerminalNode* CypherParser::SkipContext::SP() { +tree::TerminalNode *CypherParser::SkipContext::SP() { return getToken(CypherParser::SP, 0); } -CypherParser::ExpressionContext* CypherParser::SkipContext::expression() { +CypherParser::ExpressionContext *CypherParser::SkipContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } - size_t CypherParser::SkipContext::getRuleIndex() const { return CypherParser::RuleSkip; } void CypherParser::SkipContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterSkip(this); + if (parserListener != nullptr) parserListener->enterSkip(this); } void CypherParser::SkipContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitSkip(this); + if (parserListener != nullptr) parserListener->exitSkip(this); } - -antlrcpp::Any CypherParser::SkipContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::SkipContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitSkip(this); else return visitor->visitChildren(this); } -CypherParser::SkipContext* CypherParser::skip() { - SkipContext *_localctx = _tracker.createInstance<SkipContext>(_ctx, getState()); +CypherParser::SkipContext *CypherParser::skip() { + SkipContext *_localctx = + _tracker.createInstance<SkipContext>(_ctx, getState()); enterRule(_localctx, 46, CypherParser::RuleSkip); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(437); @@ -2514,9 +2471,8 @@ CypherParser::SkipContext* CypherParser::skip() { match(CypherParser::SP); setState(439); expression(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -2525,56 +2481,53 @@ CypherParser::SkipContext* CypherParser::skip() { return _localctx; } -//----------------- LimitContext ------------------------------------------------------------------ +//----------------- LimitContext +//------------------------------------------------------------------ -CypherParser::LimitContext::LimitContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::LimitContext::LimitContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::LimitContext::LIMIT() { +tree::TerminalNode *CypherParser::LimitContext::LIMIT() { return getToken(CypherParser::LIMIT, 0); } -tree::TerminalNode* CypherParser::LimitContext::SP() { +tree::TerminalNode *CypherParser::LimitContext::SP() { return getToken(CypherParser::SP, 0); } -CypherParser::ExpressionContext* CypherParser::LimitContext::expression() { +CypherParser::ExpressionContext *CypherParser::LimitContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } - size_t CypherParser::LimitContext::getRuleIndex() const { return CypherParser::RuleLimit; } void CypherParser::LimitContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterLimit(this); + if (parserListener != nullptr) parserListener->enterLimit(this); } void CypherParser::LimitContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitLimit(this); + if (parserListener != nullptr) parserListener->exitLimit(this); } - -antlrcpp::Any CypherParser::LimitContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::LimitContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitLimit(this); else return visitor->visitChildren(this); } -CypherParser::LimitContext* CypherParser::limit() { - LimitContext *_localctx = _tracker.createInstance<LimitContext>(_ctx, getState()); +CypherParser::LimitContext *CypherParser::limit() { + LimitContext *_localctx = + _tracker.createInstance<LimitContext>(_ctx, getState()); enterRule(_localctx, 48, CypherParser::RuleLimit); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(441); @@ -2583,9 +2536,8 @@ CypherParser::LimitContext* CypherParser::limit() { match(CypherParser::SP); setState(443); expression(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -2594,69 +2546,68 @@ CypherParser::LimitContext* CypherParser::limit() { return _localctx; } -//----------------- SortItemContext ------------------------------------------------------------------ +//----------------- SortItemContext +//------------------------------------------------------------------ -CypherParser::SortItemContext::SortItemContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::SortItemContext::SortItemContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::ExpressionContext* CypherParser::SortItemContext::expression() { +CypherParser::ExpressionContext *CypherParser::SortItemContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } -tree::TerminalNode* CypherParser::SortItemContext::ASCENDING() { +tree::TerminalNode *CypherParser::SortItemContext::ASCENDING() { return getToken(CypherParser::ASCENDING, 0); } -tree::TerminalNode* CypherParser::SortItemContext::ASC() { +tree::TerminalNode *CypherParser::SortItemContext::ASC() { return getToken(CypherParser::ASC, 0); } -tree::TerminalNode* CypherParser::SortItemContext::DESCENDING() { +tree::TerminalNode *CypherParser::SortItemContext::DESCENDING() { return getToken(CypherParser::DESCENDING, 0); } -tree::TerminalNode* CypherParser::SortItemContext::DESC() { +tree::TerminalNode *CypherParser::SortItemContext::DESC() { return getToken(CypherParser::DESC, 0); } -tree::TerminalNode* CypherParser::SortItemContext::SP() { +tree::TerminalNode *CypherParser::SortItemContext::SP() { return getToken(CypherParser::SP, 0); } - size_t CypherParser::SortItemContext::getRuleIndex() const { return CypherParser::RuleSortItem; } -void CypherParser::SortItemContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::SortItemContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterSortItem(this); + if (parserListener != nullptr) parserListener->enterSortItem(this); } -void CypherParser::SortItemContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::SortItemContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitSortItem(this); + if (parserListener != nullptr) parserListener->exitSortItem(this); } - -antlrcpp::Any CypherParser::SortItemContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::SortItemContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitSortItem(this); else return visitor->visitChildren(this); } -CypherParser::SortItemContext* CypherParser::sortItem() { - SortItemContext *_localctx = _tracker.createInstance<SortItemContext>(_ctx, getState()); +CypherParser::SortItemContext *CypherParser::sortItem() { + SortItemContext *_localctx = + _tracker.createInstance<SortItemContext>(_ctx, getState()); enterRule(_localctx, 50, CypherParser::RuleSortItem); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(445); @@ -2664,36 +2615,35 @@ CypherParser::SortItemContext* CypherParser::sortItem() { setState(450); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 52, _ctx)) { - case 1: { - setState(447); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 52, _ctx)) { + case 1: { + setState(447); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(446); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(446); + match(CypherParser::SP); + } + setState(449); + _la = _input->LA(1); + if (!(((((_la - 84) & ~0x3fULL) == 0) && + ((1ULL << (_la - 84)) & + ((1ULL << (CypherParser::ASCENDING - 84)) | + (1ULL << (CypherParser::ASC - 84)) | + (1ULL << (CypherParser::DESCENDING - 84)) | + (1ULL << (CypherParser::DESC - 84)))) != 0))) { + _errHandler->recoverInline(this); + } else { + _errHandler->reportMatch(this); + consume(); + } + break; } - setState(449); - _la = _input->LA(1); - if (!(((((_la - 84) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 84)) & ((1ULL << (CypherParser::ASCENDING - 84)) - | (1ULL << (CypherParser::ASC - 84)) - | (1ULL << (CypherParser::DESCENDING - 84)) - | (1ULL << (CypherParser::DESC - 84)))) != 0))) { - _errHandler->recoverInline(this); - } - else { - _errHandler->reportMatch(this); - consume(); - } - break; } - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -2702,56 +2652,53 @@ CypherParser::SortItemContext* CypherParser::sortItem() { return _localctx; } -//----------------- WhereContext ------------------------------------------------------------------ +//----------------- WhereContext +//------------------------------------------------------------------ -CypherParser::WhereContext::WhereContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::WhereContext::WhereContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::WhereContext::WHERE() { +tree::TerminalNode *CypherParser::WhereContext::WHERE() { return getToken(CypherParser::WHERE, 0); } -tree::TerminalNode* CypherParser::WhereContext::SP() { +tree::TerminalNode *CypherParser::WhereContext::SP() { return getToken(CypherParser::SP, 0); } -CypherParser::ExpressionContext* CypherParser::WhereContext::expression() { +CypherParser::ExpressionContext *CypherParser::WhereContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } - size_t CypherParser::WhereContext::getRuleIndex() const { return CypherParser::RuleWhere; } void CypherParser::WhereContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterWhere(this); + if (parserListener != nullptr) parserListener->enterWhere(this); } void CypherParser::WhereContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitWhere(this); + if (parserListener != nullptr) parserListener->exitWhere(this); } - -antlrcpp::Any CypherParser::WhereContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::WhereContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitWhere(this); else return visitor->visitChildren(this); } -CypherParser::WhereContext* CypherParser::where() { - WhereContext *_localctx = _tracker.createInstance<WhereContext>(_ctx, getState()); +CypherParser::WhereContext *CypherParser::where() { + WhereContext *_localctx = + _tracker.createInstance<WhereContext>(_ctx, getState()); enterRule(_localctx, 52, CypherParser::RuleWhere); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(452); @@ -2760,9 +2707,8 @@ CypherParser::WhereContext* CypherParser::where() { match(CypherParser::SP); setState(454); expression(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -2771,17 +2717,20 @@ CypherParser::WhereContext* CypherParser::where() { return _localctx; } -//----------------- PatternContext ------------------------------------------------------------------ +//----------------- PatternContext +//------------------------------------------------------------------ -CypherParser::PatternContext::PatternContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::PatternContext::PatternContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::PatternPartContext *> CypherParser::PatternContext::patternPart() { +std::vector<CypherParser::PatternPartContext *> +CypherParser::PatternContext::patternPart() { return getRuleContexts<CypherParser::PatternPartContext>(); } -CypherParser::PatternPartContext* CypherParser::PatternContext::patternPart(size_t i) { +CypherParser::PatternPartContext *CypherParser::PatternContext::patternPart( + size_t i) { return getRuleContext<CypherParser::PatternPartContext>(i); } @@ -2789,43 +2738,40 @@ std::vector<tree::TerminalNode *> CypherParser::PatternContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::PatternContext::SP(size_t i) { +tree::TerminalNode *CypherParser::PatternContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::PatternContext::getRuleIndex() const { return CypherParser::RulePattern; } -void CypherParser::PatternContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::PatternContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterPattern(this); + if (parserListener != nullptr) parserListener->enterPattern(this); } void CypherParser::PatternContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitPattern(this); + if (parserListener != nullptr) parserListener->exitPattern(this); } - -antlrcpp::Any CypherParser::PatternContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::PatternContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitPattern(this); else return visitor->visitChildren(this); } -CypherParser::PatternContext* CypherParser::pattern() { - PatternContext *_localctx = _tracker.createInstance<PatternContext>(_ctx, getState()); +CypherParser::PatternContext *CypherParser::pattern() { + PatternContext *_localctx = + _tracker.createInstance<PatternContext>(_ctx, getState()); enterRule(_localctx, 54, CypherParser::RulePattern); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -2833,7 +2779,8 @@ CypherParser::PatternContext* CypherParser::pattern() { patternPart(); setState(467); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 55, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 55, + _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(458); @@ -2855,15 +2802,15 @@ CypherParser::PatternContext* CypherParser::pattern() { match(CypherParser::SP); } setState(464); - patternPart(); + patternPart(); } setState(469); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 55, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 55, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -2872,17 +2819,19 @@ CypherParser::PatternContext* CypherParser::pattern() { return _localctx; } -//----------------- PatternPartContext ------------------------------------------------------------------ +//----------------- PatternPartContext +//------------------------------------------------------------------ -CypherParser::PatternPartContext::PatternPartContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::PatternPartContext::PatternPartContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::VariableContext* CypherParser::PatternPartContext::variable() { +CypherParser::VariableContext *CypherParser::PatternPartContext::variable() { return getRuleContext<CypherParser::VariableContext>(0); } -CypherParser::AnonymousPatternPartContext* CypherParser::PatternPartContext::anonymousPatternPart() { +CypherParser::AnonymousPatternPartContext * +CypherParser::PatternPartContext::anonymousPatternPart() { return getRuleContext<CypherParser::AnonymousPatternPartContext>(0); } @@ -2890,43 +2839,41 @@ std::vector<tree::TerminalNode *> CypherParser::PatternPartContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::PatternPartContext::SP(size_t i) { +tree::TerminalNode *CypherParser::PatternPartContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::PatternPartContext::getRuleIndex() const { return CypherParser::RulePatternPart; } -void CypherParser::PatternPartContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::PatternPartContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterPatternPart(this); + if (parserListener != nullptr) parserListener->enterPatternPart(this); } -void CypherParser::PatternPartContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::PatternPartContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitPatternPart(this); + if (parserListener != nullptr) parserListener->exitPatternPart(this); } - -antlrcpp::Any CypherParser::PatternPartContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::PatternPartContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitPatternPart(this); else return visitor->visitChildren(this); } -CypherParser::PatternPartContext* CypherParser::patternPart() { - PatternPartContext *_localctx = _tracker.createInstance<PatternPartContext>(_ctx, getState()); +CypherParser::PatternPartContext *CypherParser::patternPart() { + PatternPartContext *_localctx = + _tracker.createInstance<PatternPartContext>(_ctx, getState()); enterRule(_localctx, 56, CypherParser::RulePatternPart); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(481); _errHandler->sync(this); @@ -3010,12 +2957,11 @@ CypherParser::PatternPartContext* CypherParser::patternPart() { break; } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -3024,55 +2970,56 @@ CypherParser::PatternPartContext* CypherParser::patternPart() { return _localctx; } -//----------------- AnonymousPatternPartContext ------------------------------------------------------------------ +//----------------- AnonymousPatternPartContext +//------------------------------------------------------------------ -CypherParser::AnonymousPatternPartContext::AnonymousPatternPartContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::AnonymousPatternPartContext::AnonymousPatternPartContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::PatternElementContext* CypherParser::AnonymousPatternPartContext::patternElement() { +CypherParser::PatternElementContext * +CypherParser::AnonymousPatternPartContext::patternElement() { return getRuleContext<CypherParser::PatternElementContext>(0); } - size_t CypherParser::AnonymousPatternPartContext::getRuleIndex() const { return CypherParser::RuleAnonymousPatternPart; } -void CypherParser::AnonymousPatternPartContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::AnonymousPatternPartContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); if (parserListener != nullptr) parserListener->enterAnonymousPatternPart(this); } -void CypherParser::AnonymousPatternPartContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::AnonymousPatternPartContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitAnonymousPatternPart(this); + if (parserListener != nullptr) parserListener->exitAnonymousPatternPart(this); } - -antlrcpp::Any CypherParser::AnonymousPatternPartContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::AnonymousPatternPartContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitAnonymousPatternPart(this); else return visitor->visitChildren(this); } -CypherParser::AnonymousPatternPartContext* CypherParser::anonymousPatternPart() { - AnonymousPatternPartContext *_localctx = _tracker.createInstance<AnonymousPatternPartContext>(_ctx, getState()); +CypherParser::AnonymousPatternPartContext * +CypherParser::anonymousPatternPart() { + AnonymousPatternPartContext *_localctx = + _tracker.createInstance<AnonymousPatternPartContext>(_ctx, getState()); enterRule(_localctx, 58, CypherParser::RuleAnonymousPatternPart); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(483); patternElement(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -3081,21 +3028,25 @@ CypherParser::AnonymousPatternPartContext* CypherParser::anonymousPatternPart() return _localctx; } -//----------------- PatternElementContext ------------------------------------------------------------------ +//----------------- PatternElementContext +//------------------------------------------------------------------ -CypherParser::PatternElementContext::PatternElementContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::PatternElementContext::PatternElementContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::NodePatternContext* CypherParser::PatternElementContext::nodePattern() { +CypherParser::NodePatternContext * +CypherParser::PatternElementContext::nodePattern() { return getRuleContext<CypherParser::NodePatternContext>(0); } -std::vector<CypherParser::PatternElementChainContext *> CypherParser::PatternElementContext::patternElementChain() { +std::vector<CypherParser::PatternElementChainContext *> +CypherParser::PatternElementContext::patternElementChain() { return getRuleContexts<CypherParser::PatternElementChainContext>(); } -CypherParser::PatternElementChainContext* CypherParser::PatternElementContext::patternElementChain(size_t i) { +CypherParser::PatternElementChainContext * +CypherParser::PatternElementContext::patternElementChain(size_t i) { return getRuleContext<CypherParser::PatternElementChainContext>(i); } @@ -3103,94 +3054,94 @@ std::vector<tree::TerminalNode *> CypherParser::PatternElementContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::PatternElementContext::SP(size_t i) { +tree::TerminalNode *CypherParser::PatternElementContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -CypherParser::PatternElementContext* CypherParser::PatternElementContext::patternElement() { +CypherParser::PatternElementContext * +CypherParser::PatternElementContext::patternElement() { return getRuleContext<CypherParser::PatternElementContext>(0); } - size_t CypherParser::PatternElementContext::getRuleIndex() const { return CypherParser::RulePatternElement; } -void CypherParser::PatternElementContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::PatternElementContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterPatternElement(this); + if (parserListener != nullptr) parserListener->enterPatternElement(this); } -void CypherParser::PatternElementContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::PatternElementContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitPatternElement(this); + if (parserListener != nullptr) parserListener->exitPatternElement(this); } - -antlrcpp::Any CypherParser::PatternElementContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::PatternElementContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitPatternElement(this); else return visitor->visitChildren(this); } -CypherParser::PatternElementContext* CypherParser::patternElement() { - PatternElementContext *_localctx = _tracker.createInstance<PatternElementContext>(_ctx, getState()); +CypherParser::PatternElementContext *CypherParser::patternElement() { + PatternElementContext *_localctx = + _tracker.createInstance<PatternElementContext>(_ctx, getState()); enterRule(_localctx, 60, CypherParser::RulePatternElement); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; setState(499); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 61, _ctx)) { - case 1: { - enterOuterAlt(_localctx, 1); - setState(485); - nodePattern(); - setState(492); - _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 60, _ctx); - while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { - if (alt == 1) { - setState(487); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(486); - match(CypherParser::SP); - } - setState(489); - patternElementChain(); - } - setState(494); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 61, _ctx)) { + case 1: { + enterOuterAlt(_localctx, 1); + setState(485); + nodePattern(); + setState(492); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 60, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 60, _ctx); + while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { + if (alt == 1) { + setState(487); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(486); + match(CypherParser::SP); + } + setState(489); + patternElementChain(); + } + setState(494); + _errHandler->sync(this); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 60, _ctx); + } + break; + } + + case 2: { + enterOuterAlt(_localctx, 2); + setState(495); + match(CypherParser::T__5); + setState(496); + patternElement(); + setState(497); + match(CypherParser::T__6); + break; } - break; } - case 2: { - enterOuterAlt(_localctx, 2); - setState(495); - match(CypherParser::T__5); - setState(496); - patternElement(); - setState(497); - match(CypherParser::T__6); - break; - } - - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -3199,65 +3150,66 @@ CypherParser::PatternElementContext* CypherParser::patternElement() { return _localctx; } -//----------------- NodePatternContext ------------------------------------------------------------------ +//----------------- NodePatternContext +//------------------------------------------------------------------ -CypherParser::NodePatternContext::NodePatternContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::NodePatternContext::NodePatternContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} std::vector<tree::TerminalNode *> CypherParser::NodePatternContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::NodePatternContext::SP(size_t i) { +tree::TerminalNode *CypherParser::NodePatternContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -CypherParser::VariableContext* CypherParser::NodePatternContext::variable() { +CypherParser::VariableContext *CypherParser::NodePatternContext::variable() { return getRuleContext<CypherParser::VariableContext>(0); } -CypherParser::NodeLabelsContext* CypherParser::NodePatternContext::nodeLabels() { +CypherParser::NodeLabelsContext * +CypherParser::NodePatternContext::nodeLabels() { return getRuleContext<CypherParser::NodeLabelsContext>(0); } -CypherParser::PropertiesContext* CypherParser::NodePatternContext::properties() { +CypherParser::PropertiesContext * +CypherParser::NodePatternContext::properties() { return getRuleContext<CypherParser::PropertiesContext>(0); } - size_t CypherParser::NodePatternContext::getRuleIndex() const { return CypherParser::RuleNodePattern; } -void CypherParser::NodePatternContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::NodePatternContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterNodePattern(this); + if (parserListener != nullptr) parserListener->enterNodePattern(this); } -void CypherParser::NodePatternContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::NodePatternContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitNodePattern(this); + if (parserListener != nullptr) parserListener->exitNodePattern(this); } - -antlrcpp::Any CypherParser::NodePatternContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::NodePatternContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitNodePattern(this); else return visitor->visitChildren(this); } -CypherParser::NodePatternContext* CypherParser::nodePattern() { - NodePatternContext *_localctx = _tracker.createInstance<NodePatternContext>(_ctx, getState()); +CypherParser::NodePatternContext *CypherParser::nodePattern() { + NodePatternContext *_localctx = + _tracker.createInstance<NodePatternContext>(_ctx, getState()); enterRule(_localctx, 62, CypherParser::RuleNodePattern); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(501); @@ -3274,53 +3226,54 @@ CypherParser::NodePatternContext* CypherParser::nodePattern() { _errHandler->sync(this); _la = _input->LA(1); - if (((((_la - 55) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 55)) & ((1ULL << (CypherParser::HexLetter - 55)) - | (1ULL << (CypherParser::UNION - 55)) - | (1ULL << (CypherParser::ALL - 55)) - | (1ULL << (CypherParser::OPTIONAL - 55)) - | (1ULL << (CypherParser::MATCH - 55)) - | (1ULL << (CypherParser::UNWIND - 55)) - | (1ULL << (CypherParser::AS - 55)) - | (1ULL << (CypherParser::MERGE - 55)) - | (1ULL << (CypherParser::ON - 55)) - | (1ULL << (CypherParser::CREATE - 55)) - | (1ULL << (CypherParser::SET - 55)) - | (1ULL << (CypherParser::DETACH - 55)) - | (1ULL << (CypherParser::DELETE - 55)) - | (1ULL << (CypherParser::REMOVE - 55)) - | (1ULL << (CypherParser::WITH - 55)) - | (1ULL << (CypherParser::DISTINCT - 55)) - | (1ULL << (CypherParser::RETURN - 55)) - | (1ULL << (CypherParser::ORDER - 55)) - | (1ULL << (CypherParser::BY - 55)) - | (1ULL << (CypherParser::L_SKIP - 55)) - | (1ULL << (CypherParser::LIMIT - 55)) - | (1ULL << (CypherParser::ASCENDING - 55)) - | (1ULL << (CypherParser::ASC - 55)) - | (1ULL << (CypherParser::DESCENDING - 55)) - | (1ULL << (CypherParser::DESC - 55)) - | (1ULL << (CypherParser::WHERE - 55)) - | (1ULL << (CypherParser::OR - 55)) - | (1ULL << (CypherParser::XOR - 55)) - | (1ULL << (CypherParser::AND - 55)) - | (1ULL << (CypherParser::NOT - 55)) - | (1ULL << (CypherParser::IN - 55)) - | (1ULL << (CypherParser::STARTS - 55)) - | (1ULL << (CypherParser::ENDS - 55)) - | (1ULL << (CypherParser::CONTAINS - 55)) - | (1ULL << (CypherParser::IS - 55)) - | (1ULL << (CypherParser::CYPHERNULL - 55)) - | (1ULL << (CypherParser::COUNT - 55)) - | (1ULL << (CypherParser::FILTER - 55)) - | (1ULL << (CypherParser::EXTRACT - 55)) - | (1ULL << (CypherParser::ANY - 55)) - | (1ULL << (CypherParser::NONE - 55)) - | (1ULL << (CypherParser::SINGLE - 55)) - | (1ULL << (CypherParser::TRUE - 55)) - | (1ULL << (CypherParser::FALSE - 55)) - | (1ULL << (CypherParser::UnescapedSymbolicName - 55)) - | (1ULL << (CypherParser::EscapedSymbolicName - 55)))) != 0)) { + if (((((_la - 55) & ~0x3fULL) == 0) && + ((1ULL << (_la - 55)) & + ((1ULL << (CypherParser::HexLetter - 55)) | + (1ULL << (CypherParser::UNION - 55)) | + (1ULL << (CypherParser::ALL - 55)) | + (1ULL << (CypherParser::OPTIONAL - 55)) | + (1ULL << (CypherParser::MATCH - 55)) | + (1ULL << (CypherParser::UNWIND - 55)) | + (1ULL << (CypherParser::AS - 55)) | + (1ULL << (CypherParser::MERGE - 55)) | + (1ULL << (CypherParser::ON - 55)) | + (1ULL << (CypherParser::CREATE - 55)) | + (1ULL << (CypherParser::SET - 55)) | + (1ULL << (CypherParser::DETACH - 55)) | + (1ULL << (CypherParser::DELETE - 55)) | + (1ULL << (CypherParser::REMOVE - 55)) | + (1ULL << (CypherParser::WITH - 55)) | + (1ULL << (CypherParser::DISTINCT - 55)) | + (1ULL << (CypherParser::RETURN - 55)) | + (1ULL << (CypherParser::ORDER - 55)) | + (1ULL << (CypherParser::BY - 55)) | + (1ULL << (CypherParser::L_SKIP - 55)) | + (1ULL << (CypherParser::LIMIT - 55)) | + (1ULL << (CypherParser::ASCENDING - 55)) | + (1ULL << (CypherParser::ASC - 55)) | + (1ULL << (CypherParser::DESCENDING - 55)) | + (1ULL << (CypherParser::DESC - 55)) | + (1ULL << (CypherParser::WHERE - 55)) | + (1ULL << (CypherParser::OR - 55)) | + (1ULL << (CypherParser::XOR - 55)) | + (1ULL << (CypherParser::AND - 55)) | + (1ULL << (CypherParser::NOT - 55)) | + (1ULL << (CypherParser::IN - 55)) | + (1ULL << (CypherParser::STARTS - 55)) | + (1ULL << (CypherParser::ENDS - 55)) | + (1ULL << (CypherParser::CONTAINS - 55)) | + (1ULL << (CypherParser::IS - 55)) | + (1ULL << (CypherParser::CYPHERNULL - 55)) | + (1ULL << (CypherParser::COUNT - 55)) | + (1ULL << (CypherParser::FILTER - 55)) | + (1ULL << (CypherParser::EXTRACT - 55)) | + (1ULL << (CypherParser::ANY - 55)) | + (1ULL << (CypherParser::NONE - 55)) | + (1ULL << (CypherParser::SINGLE - 55)) | + (1ULL << (CypherParser::TRUE - 55)) | + (1ULL << (CypherParser::FALSE - 55)) | + (1ULL << (CypherParser::UnescapedSymbolicName - 55)) | + (1ULL << (CypherParser::EscapedSymbolicName - 55)))) != 0)) { setState(505); variable(); setState(507); @@ -3354,7 +3307,7 @@ CypherParser::NodePatternContext* CypherParser::nodePattern() { _la = _input->LA(1); if (_la == CypherParser::T__27 - || _la == CypherParser::T__29) { + || _la == CypherParser::T__29) { setState(517); properties(); setState(519); @@ -3368,9 +3321,8 @@ CypherParser::NodePatternContext* CypherParser::nodePattern() { } setState(523); match(CypherParser::T__6); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -3379,57 +3331,58 @@ CypherParser::NodePatternContext* CypherParser::nodePattern() { return _localctx; } -//----------------- PatternElementChainContext ------------------------------------------------------------------ +//----------------- PatternElementChainContext +//------------------------------------------------------------------ -CypherParser::PatternElementChainContext::PatternElementChainContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::PatternElementChainContext::PatternElementChainContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::RelationshipPatternContext* CypherParser::PatternElementChainContext::relationshipPattern() { +CypherParser::RelationshipPatternContext * +CypherParser::PatternElementChainContext::relationshipPattern() { return getRuleContext<CypherParser::RelationshipPatternContext>(0); } -CypherParser::NodePatternContext* CypherParser::PatternElementChainContext::nodePattern() { +CypherParser::NodePatternContext * +CypherParser::PatternElementChainContext::nodePattern() { return getRuleContext<CypherParser::NodePatternContext>(0); } -tree::TerminalNode* CypherParser::PatternElementChainContext::SP() { +tree::TerminalNode *CypherParser::PatternElementChainContext::SP() { return getToken(CypherParser::SP, 0); } - size_t CypherParser::PatternElementChainContext::getRuleIndex() const { return CypherParser::RulePatternElementChain; } -void CypherParser::PatternElementChainContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::PatternElementChainContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterPatternElementChain(this); + if (parserListener != nullptr) parserListener->enterPatternElementChain(this); } -void CypherParser::PatternElementChainContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::PatternElementChainContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitPatternElementChain(this); + if (parserListener != nullptr) parserListener->exitPatternElementChain(this); } - -antlrcpp::Any CypherParser::PatternElementChainContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::PatternElementChainContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitPatternElementChain(this); else return visitor->visitChildren(this); } -CypherParser::PatternElementChainContext* CypherParser::patternElementChain() { - PatternElementChainContext *_localctx = _tracker.createInstance<PatternElementChainContext>(_ctx, getState()); +CypherParser::PatternElementChainContext *CypherParser::patternElementChain() { + PatternElementChainContext *_localctx = + _tracker.createInstance<PatternElementChainContext>(_ctx, getState()); enterRule(_localctx, 64, CypherParser::RulePatternElementChain); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(525); @@ -3444,9 +3397,8 @@ CypherParser::PatternElementChainContext* CypherParser::patternElementChain() { } setState(529); nodePattern(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -3455,265 +3407,269 @@ CypherParser::PatternElementChainContext* CypherParser::patternElementChain() { return _localctx; } -//----------------- RelationshipPatternContext ------------------------------------------------------------------ +//----------------- RelationshipPatternContext +//------------------------------------------------------------------ -CypherParser::RelationshipPatternContext::RelationshipPatternContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::RelationshipPatternContext::RelationshipPatternContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::LeftArrowHeadContext* CypherParser::RelationshipPatternContext::leftArrowHead() { +CypherParser::LeftArrowHeadContext * +CypherParser::RelationshipPatternContext::leftArrowHead() { return getRuleContext<CypherParser::LeftArrowHeadContext>(0); } -std::vector<CypherParser::DashContext *> CypherParser::RelationshipPatternContext::dash() { +std::vector<CypherParser::DashContext *> +CypherParser::RelationshipPatternContext::dash() { return getRuleContexts<CypherParser::DashContext>(); } -CypherParser::DashContext* CypherParser::RelationshipPatternContext::dash(size_t i) { +CypherParser::DashContext *CypherParser::RelationshipPatternContext::dash( + size_t i) { return getRuleContext<CypherParser::DashContext>(i); } -CypherParser::RightArrowHeadContext* CypherParser::RelationshipPatternContext::rightArrowHead() { +CypherParser::RightArrowHeadContext * +CypherParser::RelationshipPatternContext::rightArrowHead() { return getRuleContext<CypherParser::RightArrowHeadContext>(0); } -std::vector<tree::TerminalNode *> CypherParser::RelationshipPatternContext::SP() { +std::vector<tree::TerminalNode *> +CypherParser::RelationshipPatternContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::RelationshipPatternContext::SP(size_t i) { +tree::TerminalNode *CypherParser::RelationshipPatternContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -CypherParser::RelationshipDetailContext* CypherParser::RelationshipPatternContext::relationshipDetail() { +CypherParser::RelationshipDetailContext * +CypherParser::RelationshipPatternContext::relationshipDetail() { return getRuleContext<CypherParser::RelationshipDetailContext>(0); } - size_t CypherParser::RelationshipPatternContext::getRuleIndex() const { return CypherParser::RuleRelationshipPattern; } -void CypherParser::RelationshipPatternContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::RelationshipPatternContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterRelationshipPattern(this); + if (parserListener != nullptr) parserListener->enterRelationshipPattern(this); } -void CypherParser::RelationshipPatternContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::RelationshipPatternContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRelationshipPattern(this); + if (parserListener != nullptr) parserListener->exitRelationshipPattern(this); } - -antlrcpp::Any CypherParser::RelationshipPatternContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RelationshipPatternContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRelationshipPattern(this); else return visitor->visitChildren(this); } -CypherParser::RelationshipPatternContext* CypherParser::relationshipPattern() { - RelationshipPatternContext *_localctx = _tracker.createInstance<RelationshipPatternContext>(_ctx, getState()); +CypherParser::RelationshipPatternContext *CypherParser::relationshipPattern() { + RelationshipPatternContext *_localctx = + _tracker.createInstance<RelationshipPatternContext>(_ctx, getState()); enterRule(_localctx, 66, CypherParser::RuleRelationshipPattern); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(595); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 86, _ctx)) { - case 1: { - enterOuterAlt(_localctx, 1); - setState(531); - leftArrowHead(); - setState(533); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(532); - match(CypherParser::SP); - } - setState(535); - dash(); - setState(537); - _errHandler->sync(this); - - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 71, _ctx)) { + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 86, _ctx)) { case 1: { - setState(536); - match(CypherParser::SP); + enterOuterAlt(_localctx, 1); + setState(531); + leftArrowHead(); + setState(533); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(532); + match(CypherParser::SP); + } + setState(535); + dash(); + setState(537); + _errHandler->sync(this); + + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 71, _ctx)) { + case 1: { + setState(536); + match(CypherParser::SP); + break; + } + } + setState(540); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::T__7) { + setState(539); + relationshipDetail(); + } + setState(543); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(542); + match(CypherParser::SP); + } + setState(545); + dash(); + setState(547); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(546); + match(CypherParser::SP); + } + setState(549); + rightArrowHead(); break; } - } - setState(540); - _errHandler->sync(this); + case 2: { + enterOuterAlt(_localctx, 2); + setState(551); + leftArrowHead(); + setState(553); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::T__7) { - setState(539); - relationshipDetail(); - } - setState(543); - _errHandler->sync(this); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(552); + match(CypherParser::SP); + } + setState(555); + dash(); + setState(557); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(542); - match(CypherParser::SP); - } - setState(545); - dash(); - setState(547); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 76, _ctx)) { + case 1: { + setState(556); + match(CypherParser::SP); + break; + } + } + setState(560); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(546); - match(CypherParser::SP); - } - setState(549); - rightArrowHead(); - break; - } + _la = _input->LA(1); + if (_la == CypherParser::T__7) { + setState(559); + relationshipDetail(); + } + setState(563); + _errHandler->sync(this); - case 2: { - enterOuterAlt(_localctx, 2); - setState(551); - leftArrowHead(); - setState(553); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(552); - match(CypherParser::SP); - } - setState(555); - dash(); - setState(557); - _errHandler->sync(this); - - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 76, _ctx)) { - case 1: { - setState(556); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(562); + match(CypherParser::SP); + } + setState(565); + dash(); break; } - } - setState(560); - _errHandler->sync(this); + case 3: { + enterOuterAlt(_localctx, 3); + setState(567); + dash(); + setState(569); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::T__7) { - setState(559); - relationshipDetail(); - } - setState(563); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 79, _ctx)) { + case 1: { + setState(568); + match(CypherParser::SP); + break; + } + } + setState(572); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(562); - match(CypherParser::SP); - } - setState(565); - dash(); - break; - } + _la = _input->LA(1); + if (_la == CypherParser::T__7) { + setState(571); + relationshipDetail(); + } + setState(575); + _errHandler->sync(this); - case 3: { - enterOuterAlt(_localctx, 3); - setState(567); - dash(); - setState(569); - _errHandler->sync(this); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(574); + match(CypherParser::SP); + } + setState(577); + dash(); + setState(579); + _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 79, _ctx)) { - case 1: { - setState(568); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(578); + match(CypherParser::SP); + } + setState(581); + rightArrowHead(); break; } - } - setState(572); - _errHandler->sync(this); + case 4: { + enterOuterAlt(_localctx, 4); + setState(583); + dash(); + setState(585); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::T__7) { - setState(571); - relationshipDetail(); - } - setState(575); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 83, _ctx)) { + case 1: { + setState(584); + match(CypherParser::SP); + break; + } + } + setState(588); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(574); - match(CypherParser::SP); - } - setState(577); - dash(); - setState(579); - _errHandler->sync(this); + _la = _input->LA(1); + if (_la == CypherParser::T__7) { + setState(587); + relationshipDetail(); + } + setState(591); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(578); - match(CypherParser::SP); - } - setState(581); - rightArrowHead(); - break; - } - - case 4: { - enterOuterAlt(_localctx, 4); - setState(583); - dash(); - setState(585); - _errHandler->sync(this); - - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 83, _ctx)) { - case 1: { - setState(584); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(590); + match(CypherParser::SP); + } + setState(593); + dash(); break; } - - } - setState(588); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::T__7) { - setState(587); - relationshipDetail(); - } - setState(591); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(590); - match(CypherParser::SP); - } - setState(593); - dash(); - break; } - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -3722,61 +3678,64 @@ CypherParser::RelationshipPatternContext* CypherParser::relationshipPattern() { return _localctx; } -//----------------- RelationshipDetailContext ------------------------------------------------------------------ +//----------------- RelationshipDetailContext +//------------------------------------------------------------------ -CypherParser::RelationshipDetailContext::RelationshipDetailContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::RelationshipDetailContext::RelationshipDetailContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::VariableContext* CypherParser::RelationshipDetailContext::variable() { +CypherParser::VariableContext * +CypherParser::RelationshipDetailContext::variable() { return getRuleContext<CypherParser::VariableContext>(0); } -CypherParser::RelationshipTypesContext* CypherParser::RelationshipDetailContext::relationshipTypes() { +CypherParser::RelationshipTypesContext * +CypherParser::RelationshipDetailContext::relationshipTypes() { return getRuleContext<CypherParser::RelationshipTypesContext>(0); } -CypherParser::RangeLiteralContext* CypherParser::RelationshipDetailContext::rangeLiteral() { +CypherParser::RangeLiteralContext * +CypherParser::RelationshipDetailContext::rangeLiteral() { return getRuleContext<CypherParser::RangeLiteralContext>(0); } -CypherParser::PropertiesContext* CypherParser::RelationshipDetailContext::properties() { +CypherParser::PropertiesContext * +CypherParser::RelationshipDetailContext::properties() { return getRuleContext<CypherParser::PropertiesContext>(0); } - size_t CypherParser::RelationshipDetailContext::getRuleIndex() const { return CypherParser::RuleRelationshipDetail; } -void CypherParser::RelationshipDetailContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::RelationshipDetailContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterRelationshipDetail(this); + if (parserListener != nullptr) parserListener->enterRelationshipDetail(this); } -void CypherParser::RelationshipDetailContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::RelationshipDetailContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRelationshipDetail(this); + if (parserListener != nullptr) parserListener->exitRelationshipDetail(this); } - -antlrcpp::Any CypherParser::RelationshipDetailContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RelationshipDetailContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRelationshipDetail(this); else return visitor->visitChildren(this); } -CypherParser::RelationshipDetailContext* CypherParser::relationshipDetail() { - RelationshipDetailContext *_localctx = _tracker.createInstance<RelationshipDetailContext>(_ctx, getState()); +CypherParser::RelationshipDetailContext *CypherParser::relationshipDetail() { + RelationshipDetailContext *_localctx = + _tracker.createInstance<RelationshipDetailContext>(_ctx, getState()); enterRule(_localctx, 68, CypherParser::RuleRelationshipDetail); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(597); @@ -3785,53 +3744,54 @@ CypherParser::RelationshipDetailContext* CypherParser::relationshipDetail() { _errHandler->sync(this); _la = _input->LA(1); - if (((((_la - 55) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 55)) & ((1ULL << (CypherParser::HexLetter - 55)) - | (1ULL << (CypherParser::UNION - 55)) - | (1ULL << (CypherParser::ALL - 55)) - | (1ULL << (CypherParser::OPTIONAL - 55)) - | (1ULL << (CypherParser::MATCH - 55)) - | (1ULL << (CypherParser::UNWIND - 55)) - | (1ULL << (CypherParser::AS - 55)) - | (1ULL << (CypherParser::MERGE - 55)) - | (1ULL << (CypherParser::ON - 55)) - | (1ULL << (CypherParser::CREATE - 55)) - | (1ULL << (CypherParser::SET - 55)) - | (1ULL << (CypherParser::DETACH - 55)) - | (1ULL << (CypherParser::DELETE - 55)) - | (1ULL << (CypherParser::REMOVE - 55)) - | (1ULL << (CypherParser::WITH - 55)) - | (1ULL << (CypherParser::DISTINCT - 55)) - | (1ULL << (CypherParser::RETURN - 55)) - | (1ULL << (CypherParser::ORDER - 55)) - | (1ULL << (CypherParser::BY - 55)) - | (1ULL << (CypherParser::L_SKIP - 55)) - | (1ULL << (CypherParser::LIMIT - 55)) - | (1ULL << (CypherParser::ASCENDING - 55)) - | (1ULL << (CypherParser::ASC - 55)) - | (1ULL << (CypherParser::DESCENDING - 55)) - | (1ULL << (CypherParser::DESC - 55)) - | (1ULL << (CypherParser::WHERE - 55)) - | (1ULL << (CypherParser::OR - 55)) - | (1ULL << (CypherParser::XOR - 55)) - | (1ULL << (CypherParser::AND - 55)) - | (1ULL << (CypherParser::NOT - 55)) - | (1ULL << (CypherParser::IN - 55)) - | (1ULL << (CypherParser::STARTS - 55)) - | (1ULL << (CypherParser::ENDS - 55)) - | (1ULL << (CypherParser::CONTAINS - 55)) - | (1ULL << (CypherParser::IS - 55)) - | (1ULL << (CypherParser::CYPHERNULL - 55)) - | (1ULL << (CypherParser::COUNT - 55)) - | (1ULL << (CypherParser::FILTER - 55)) - | (1ULL << (CypherParser::EXTRACT - 55)) - | (1ULL << (CypherParser::ANY - 55)) - | (1ULL << (CypherParser::NONE - 55)) - | (1ULL << (CypherParser::SINGLE - 55)) - | (1ULL << (CypherParser::TRUE - 55)) - | (1ULL << (CypherParser::FALSE - 55)) - | (1ULL << (CypherParser::UnescapedSymbolicName - 55)) - | (1ULL << (CypherParser::EscapedSymbolicName - 55)))) != 0)) { + if (((((_la - 55) & ~0x3fULL) == 0) && + ((1ULL << (_la - 55)) & + ((1ULL << (CypherParser::HexLetter - 55)) | + (1ULL << (CypherParser::UNION - 55)) | + (1ULL << (CypherParser::ALL - 55)) | + (1ULL << (CypherParser::OPTIONAL - 55)) | + (1ULL << (CypherParser::MATCH - 55)) | + (1ULL << (CypherParser::UNWIND - 55)) | + (1ULL << (CypherParser::AS - 55)) | + (1ULL << (CypherParser::MERGE - 55)) | + (1ULL << (CypherParser::ON - 55)) | + (1ULL << (CypherParser::CREATE - 55)) | + (1ULL << (CypherParser::SET - 55)) | + (1ULL << (CypherParser::DETACH - 55)) | + (1ULL << (CypherParser::DELETE - 55)) | + (1ULL << (CypherParser::REMOVE - 55)) | + (1ULL << (CypherParser::WITH - 55)) | + (1ULL << (CypherParser::DISTINCT - 55)) | + (1ULL << (CypherParser::RETURN - 55)) | + (1ULL << (CypherParser::ORDER - 55)) | + (1ULL << (CypherParser::BY - 55)) | + (1ULL << (CypherParser::L_SKIP - 55)) | + (1ULL << (CypherParser::LIMIT - 55)) | + (1ULL << (CypherParser::ASCENDING - 55)) | + (1ULL << (CypherParser::ASC - 55)) | + (1ULL << (CypherParser::DESCENDING - 55)) | + (1ULL << (CypherParser::DESC - 55)) | + (1ULL << (CypherParser::WHERE - 55)) | + (1ULL << (CypherParser::OR - 55)) | + (1ULL << (CypherParser::XOR - 55)) | + (1ULL << (CypherParser::AND - 55)) | + (1ULL << (CypherParser::NOT - 55)) | + (1ULL << (CypherParser::IN - 55)) | + (1ULL << (CypherParser::STARTS - 55)) | + (1ULL << (CypherParser::ENDS - 55)) | + (1ULL << (CypherParser::CONTAINS - 55)) | + (1ULL << (CypherParser::IS - 55)) | + (1ULL << (CypherParser::CYPHERNULL - 55)) | + (1ULL << (CypherParser::COUNT - 55)) | + (1ULL << (CypherParser::FILTER - 55)) | + (1ULL << (CypherParser::EXTRACT - 55)) | + (1ULL << (CypherParser::ANY - 55)) | + (1ULL << (CypherParser::NONE - 55)) | + (1ULL << (CypherParser::SINGLE - 55)) | + (1ULL << (CypherParser::TRUE - 55)) | + (1ULL << (CypherParser::FALSE - 55)) | + (1ULL << (CypherParser::UnescapedSymbolicName - 55)) | + (1ULL << (CypherParser::EscapedSymbolicName - 55)))) != 0)) { setState(598); variable(); } @@ -3865,15 +3825,14 @@ CypherParser::RelationshipDetailContext* CypherParser::relationshipDetail() { _la = _input->LA(1); if (_la == CypherParser::T__27 - || _la == CypherParser::T__29) { + || _la == CypherParser::T__29) { setState(610); properties(); } setState(613); match(CypherParser::T__9); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -3882,52 +3841,51 @@ CypherParser::RelationshipDetailContext* CypherParser::relationshipDetail() { return _localctx; } -//----------------- PropertiesContext ------------------------------------------------------------------ +//----------------- PropertiesContext +//------------------------------------------------------------------ -CypherParser::PropertiesContext::PropertiesContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::PropertiesContext::PropertiesContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::MapLiteralContext* CypherParser::PropertiesContext::mapLiteral() { +CypherParser::MapLiteralContext *CypherParser::PropertiesContext::mapLiteral() { return getRuleContext<CypherParser::MapLiteralContext>(0); } -CypherParser::ParameterContext* CypherParser::PropertiesContext::parameter() { +CypherParser::ParameterContext *CypherParser::PropertiesContext::parameter() { return getRuleContext<CypherParser::ParameterContext>(0); } - size_t CypherParser::PropertiesContext::getRuleIndex() const { return CypherParser::RuleProperties; } -void CypherParser::PropertiesContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::PropertiesContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterProperties(this); + if (parserListener != nullptr) parserListener->enterProperties(this); } -void CypherParser::PropertiesContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::PropertiesContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitProperties(this); + if (parserListener != nullptr) parserListener->exitProperties(this); } - -antlrcpp::Any CypherParser::PropertiesContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::PropertiesContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitProperties(this); else return visitor->visitChildren(this); } -CypherParser::PropertiesContext* CypherParser::properties() { - PropertiesContext *_localctx = _tracker.createInstance<PropertiesContext>(_ctx, getState()); +CypherParser::PropertiesContext *CypherParser::properties() { + PropertiesContext *_localctx = + _tracker.createInstance<PropertiesContext>(_ctx, getState()); enterRule(_localctx, 70, CypherParser::RuleProperties); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(617); _errHandler->sync(this); @@ -3946,12 +3904,11 @@ CypherParser::PropertiesContext* CypherParser::properties() { break; } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -3960,17 +3917,20 @@ CypherParser::PropertiesContext* CypherParser::properties() { return _localctx; } -//----------------- RelationshipTypesContext ------------------------------------------------------------------ +//----------------- RelationshipTypesContext +//------------------------------------------------------------------ -CypherParser::RelationshipTypesContext::RelationshipTypesContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::RelationshipTypesContext::RelationshipTypesContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::RelTypeNameContext *> CypherParser::RelationshipTypesContext::relTypeName() { +std::vector<CypherParser::RelTypeNameContext *> +CypherParser::RelationshipTypesContext::relTypeName() { return getRuleContexts<CypherParser::RelTypeNameContext>(); } -CypherParser::RelTypeNameContext* CypherParser::RelationshipTypesContext::relTypeName(size_t i) { +CypherParser::RelTypeNameContext * +CypherParser::RelationshipTypesContext::relTypeName(size_t i) { return getRuleContext<CypherParser::RelTypeNameContext>(i); } @@ -3978,43 +3938,41 @@ std::vector<tree::TerminalNode *> CypherParser::RelationshipTypesContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::RelationshipTypesContext::SP(size_t i) { +tree::TerminalNode *CypherParser::RelationshipTypesContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::RelationshipTypesContext::getRuleIndex() const { return CypherParser::RuleRelationshipTypes; } -void CypherParser::RelationshipTypesContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::RelationshipTypesContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterRelationshipTypes(this); + if (parserListener != nullptr) parserListener->enterRelationshipTypes(this); } -void CypherParser::RelationshipTypesContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::RelationshipTypesContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRelationshipTypes(this); + if (parserListener != nullptr) parserListener->exitRelationshipTypes(this); } - -antlrcpp::Any CypherParser::RelationshipTypesContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RelationshipTypesContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRelationshipTypes(this); else return visitor->visitChildren(this); } -CypherParser::RelationshipTypesContext* CypherParser::relationshipTypes() { - RelationshipTypesContext *_localctx = _tracker.createInstance<RelationshipTypesContext>(_ctx, getState()); +CypherParser::RelationshipTypesContext *CypherParser::relationshipTypes() { + RelationshipTypesContext *_localctx = + _tracker.createInstance<RelationshipTypesContext>(_ctx, getState()); enterRule(_localctx, 72, CypherParser::RuleRelationshipTypes); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(619); @@ -4057,9 +4015,8 @@ CypherParser::RelationshipTypesContext* CypherParser::relationshipTypes() { _errHandler->sync(this); _la = _input->LA(1); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4068,17 +4025,20 @@ CypherParser::RelationshipTypesContext* CypherParser::relationshipTypes() { return _localctx; } -//----------------- NodeLabelsContext ------------------------------------------------------------------ +//----------------- NodeLabelsContext +//------------------------------------------------------------------ -CypherParser::NodeLabelsContext::NodeLabelsContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::NodeLabelsContext::NodeLabelsContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::NodeLabelContext *> CypherParser::NodeLabelsContext::nodeLabel() { +std::vector<CypherParser::NodeLabelContext *> +CypherParser::NodeLabelsContext::nodeLabel() { return getRuleContexts<CypherParser::NodeLabelContext>(); } -CypherParser::NodeLabelContext* CypherParser::NodeLabelsContext::nodeLabel(size_t i) { +CypherParser::NodeLabelContext *CypherParser::NodeLabelsContext::nodeLabel( + size_t i) { return getRuleContext<CypherParser::NodeLabelContext>(i); } @@ -4086,43 +4046,41 @@ std::vector<tree::TerminalNode *> CypherParser::NodeLabelsContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::NodeLabelsContext::SP(size_t i) { +tree::TerminalNode *CypherParser::NodeLabelsContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::NodeLabelsContext::getRuleIndex() const { return CypherParser::RuleNodeLabels; } -void CypherParser::NodeLabelsContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::NodeLabelsContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterNodeLabels(this); + if (parserListener != nullptr) parserListener->enterNodeLabels(this); } -void CypherParser::NodeLabelsContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::NodeLabelsContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitNodeLabels(this); + if (parserListener != nullptr) parserListener->exitNodeLabels(this); } - -antlrcpp::Any CypherParser::NodeLabelsContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::NodeLabelsContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitNodeLabels(this); else return visitor->visitChildren(this); } -CypherParser::NodeLabelsContext* CypherParser::nodeLabels() { - NodeLabelsContext *_localctx = _tracker.createInstance<NodeLabelsContext>(_ctx, getState()); +CypherParser::NodeLabelsContext *CypherParser::nodeLabels() { + NodeLabelsContext *_localctx = + _tracker.createInstance<NodeLabelsContext>(_ctx, getState()); enterRule(_localctx, 74, CypherParser::RuleNodeLabels); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -4130,7 +4088,8 @@ CypherParser::NodeLabelsContext* CypherParser::nodeLabels() { nodeLabel(); setState(644); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 98, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 98, + _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(639); @@ -4142,15 +4101,15 @@ CypherParser::NodeLabelsContext* CypherParser::nodeLabels() { match(CypherParser::SP); } setState(641); - nodeLabel(); + nodeLabel(); } setState(646); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 98, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 98, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4159,57 +4118,55 @@ CypherParser::NodeLabelsContext* CypherParser::nodeLabels() { return _localctx; } -//----------------- NodeLabelContext ------------------------------------------------------------------ +//----------------- NodeLabelContext +//------------------------------------------------------------------ -CypherParser::NodeLabelContext::NodeLabelContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::NodeLabelContext::NodeLabelContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::LabelNameContext* CypherParser::NodeLabelContext::labelName() { +CypherParser::LabelNameContext *CypherParser::NodeLabelContext::labelName() { return getRuleContext<CypherParser::LabelNameContext>(0); } - size_t CypherParser::NodeLabelContext::getRuleIndex() const { return CypherParser::RuleNodeLabel; } -void CypherParser::NodeLabelContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::NodeLabelContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterNodeLabel(this); + if (parserListener != nullptr) parserListener->enterNodeLabel(this); } -void CypherParser::NodeLabelContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::NodeLabelContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitNodeLabel(this); + if (parserListener != nullptr) parserListener->exitNodeLabel(this); } - -antlrcpp::Any CypherParser::NodeLabelContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::NodeLabelContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitNodeLabel(this); else return visitor->visitChildren(this); } -CypherParser::NodeLabelContext* CypherParser::nodeLabel() { - NodeLabelContext *_localctx = _tracker.createInstance<NodeLabelContext>(_ctx, getState()); +CypherParser::NodeLabelContext *CypherParser::nodeLabel() { + NodeLabelContext *_localctx = + _tracker.createInstance<NodeLabelContext>(_ctx, getState()); enterRule(_localctx, 76, CypherParser::RuleNodeLabel); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(647); match(CypherParser::T__10); setState(648); labelName(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4218,61 +4175,62 @@ CypherParser::NodeLabelContext* CypherParser::nodeLabel() { return _localctx; } -//----------------- RangeLiteralContext ------------------------------------------------------------------ +//----------------- RangeLiteralContext +//------------------------------------------------------------------ -CypherParser::RangeLiteralContext::RangeLiteralContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::RangeLiteralContext::RangeLiteralContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} std::vector<tree::TerminalNode *> CypherParser::RangeLiteralContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::RangeLiteralContext::SP(size_t i) { +tree::TerminalNode *CypherParser::RangeLiteralContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -std::vector<CypherParser::IntegerLiteralContext *> CypherParser::RangeLiteralContext::integerLiteral() { +std::vector<CypherParser::IntegerLiteralContext *> +CypherParser::RangeLiteralContext::integerLiteral() { return getRuleContexts<CypherParser::IntegerLiteralContext>(); } -CypherParser::IntegerLiteralContext* CypherParser::RangeLiteralContext::integerLiteral(size_t i) { +CypherParser::IntegerLiteralContext * +CypherParser::RangeLiteralContext::integerLiteral(size_t i) { return getRuleContext<CypherParser::IntegerLiteralContext>(i); } - size_t CypherParser::RangeLiteralContext::getRuleIndex() const { return CypherParser::RuleRangeLiteral; } -void CypherParser::RangeLiteralContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::RangeLiteralContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterRangeLiteral(this); + if (parserListener != nullptr) parserListener->enterRangeLiteral(this); } -void CypherParser::RangeLiteralContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::RangeLiteralContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRangeLiteral(this); + if (parserListener != nullptr) parserListener->exitRangeLiteral(this); } - -antlrcpp::Any CypherParser::RangeLiteralContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RangeLiteralContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRangeLiteral(this); else return visitor->visitChildren(this); } -CypherParser::RangeLiteralContext* CypherParser::rangeLiteral() { - RangeLiteralContext *_localctx = _tracker.createInstance<RangeLiteralContext>(_ctx, getState()); +CypherParser::RangeLiteralContext *CypherParser::rangeLiteral() { + RangeLiteralContext *_localctx = + _tracker.createInstance<RangeLiteralContext>(_ctx, getState()); enterRule(_localctx, 78, CypherParser::RuleRangeLiteral); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(650); @@ -4289,10 +4247,10 @@ CypherParser::RangeLiteralContext* CypherParser::rangeLiteral() { _errHandler->sync(this); _la = _input->LA(1); - if ((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::HexInteger) - | (1ULL << CypherParser::DecimalInteger) - | (1ULL << CypherParser::OctalInteger))) != 0)) { + if ((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & ((1ULL << CypherParser::HexInteger) | + (1ULL << CypherParser::DecimalInteger) | + (1ULL << CypherParser::OctalInteger))) != 0)) { setState(654); integerLiteral(); setState(656); @@ -4323,10 +4281,10 @@ CypherParser::RangeLiteralContext* CypherParser::rangeLiteral() { _errHandler->sync(this); _la = _input->LA(1); - if ((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::HexInteger) - | (1ULL << CypherParser::DecimalInteger) - | (1ULL << CypherParser::OctalInteger))) != 0)) { + if ((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & ((1ULL << CypherParser::HexInteger) | + (1ULL << CypherParser::DecimalInteger) | + (1ULL << CypherParser::OctalInteger))) != 0)) { setState(664); integerLiteral(); setState(666); @@ -4339,9 +4297,8 @@ CypherParser::RangeLiteralContext* CypherParser::rangeLiteral() { } } } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4350,55 +4307,54 @@ CypherParser::RangeLiteralContext* CypherParser::rangeLiteral() { return _localctx; } -//----------------- LabelNameContext ------------------------------------------------------------------ +//----------------- LabelNameContext +//------------------------------------------------------------------ -CypherParser::LabelNameContext::LabelNameContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::LabelNameContext::LabelNameContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::SymbolicNameContext* CypherParser::LabelNameContext::symbolicName() { +CypherParser::SymbolicNameContext * +CypherParser::LabelNameContext::symbolicName() { return getRuleContext<CypherParser::SymbolicNameContext>(0); } - size_t CypherParser::LabelNameContext::getRuleIndex() const { return CypherParser::RuleLabelName; } -void CypherParser::LabelNameContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::LabelNameContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterLabelName(this); + if (parserListener != nullptr) parserListener->enterLabelName(this); } -void CypherParser::LabelNameContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::LabelNameContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitLabelName(this); + if (parserListener != nullptr) parserListener->exitLabelName(this); } - -antlrcpp::Any CypherParser::LabelNameContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::LabelNameContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitLabelName(this); else return visitor->visitChildren(this); } -CypherParser::LabelNameContext* CypherParser::labelName() { - LabelNameContext *_localctx = _tracker.createInstance<LabelNameContext>(_ctx, getState()); +CypherParser::LabelNameContext *CypherParser::labelName() { + LabelNameContext *_localctx = + _tracker.createInstance<LabelNameContext>(_ctx, getState()); enterRule(_localctx, 80, CypherParser::RuleLabelName); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(672); symbolicName(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4407,55 +4363,54 @@ CypherParser::LabelNameContext* CypherParser::labelName() { return _localctx; } -//----------------- RelTypeNameContext ------------------------------------------------------------------ +//----------------- RelTypeNameContext +//------------------------------------------------------------------ -CypherParser::RelTypeNameContext::RelTypeNameContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::RelTypeNameContext::RelTypeNameContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::SymbolicNameContext* CypherParser::RelTypeNameContext::symbolicName() { +CypherParser::SymbolicNameContext * +CypherParser::RelTypeNameContext::symbolicName() { return getRuleContext<CypherParser::SymbolicNameContext>(0); } - size_t CypherParser::RelTypeNameContext::getRuleIndex() const { return CypherParser::RuleRelTypeName; } -void CypherParser::RelTypeNameContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::RelTypeNameContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterRelTypeName(this); + if (parserListener != nullptr) parserListener->enterRelTypeName(this); } -void CypherParser::RelTypeNameContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::RelTypeNameContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRelTypeName(this); + if (parserListener != nullptr) parserListener->exitRelTypeName(this); } - -antlrcpp::Any CypherParser::RelTypeNameContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RelTypeNameContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRelTypeName(this); else return visitor->visitChildren(this); } -CypherParser::RelTypeNameContext* CypherParser::relTypeName() { - RelTypeNameContext *_localctx = _tracker.createInstance<RelTypeNameContext>(_ctx, getState()); +CypherParser::RelTypeNameContext *CypherParser::relTypeName() { + RelTypeNameContext *_localctx = + _tracker.createInstance<RelTypeNameContext>(_ctx, getState()); enterRule(_localctx, 82, CypherParser::RuleRelTypeName); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(674); symbolicName(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4464,55 +4419,54 @@ CypherParser::RelTypeNameContext* CypherParser::relTypeName() { return _localctx; } -//----------------- ExpressionContext ------------------------------------------------------------------ +//----------------- ExpressionContext +//------------------------------------------------------------------ -CypherParser::ExpressionContext::ExpressionContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::ExpressionContext::ExpressionContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::Expression12Context* CypherParser::ExpressionContext::expression12() { +CypherParser::Expression12Context * +CypherParser::ExpressionContext::expression12() { return getRuleContext<CypherParser::Expression12Context>(0); } - size_t CypherParser::ExpressionContext::getRuleIndex() const { return CypherParser::RuleExpression; } -void CypherParser::ExpressionContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::ExpressionContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression(this); + if (parserListener != nullptr) parserListener->enterExpression(this); } -void CypherParser::ExpressionContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::ExpressionContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression(this); + if (parserListener != nullptr) parserListener->exitExpression(this); } - -antlrcpp::Any CypherParser::ExpressionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::ExpressionContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression(this); else return visitor->visitChildren(this); } -CypherParser::ExpressionContext* CypherParser::expression() { - ExpressionContext *_localctx = _tracker.createInstance<ExpressionContext>(_ctx, getState()); +CypherParser::ExpressionContext *CypherParser::expression() { + ExpressionContext *_localctx = + _tracker.createInstance<ExpressionContext>(_ctx, getState()); enterRule(_localctx, 84, CypherParser::RuleExpression); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(676); expression12(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4521,17 +4475,20 @@ CypherParser::ExpressionContext* CypherParser::expression() { return _localctx; } -//----------------- Expression12Context ------------------------------------------------------------------ +//----------------- Expression12Context +//------------------------------------------------------------------ -CypherParser::Expression12Context::Expression12Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression12Context::Expression12Context( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::Expression11Context *> CypherParser::Expression12Context::expression11() { +std::vector<CypherParser::Expression11Context *> +CypherParser::Expression12Context::expression11() { return getRuleContexts<CypherParser::Expression11Context>(); } -CypherParser::Expression11Context* CypherParser::Expression12Context::expression11(size_t i) { +CypherParser::Expression11Context * +CypherParser::Expression12Context::expression11(size_t i) { return getRuleContext<CypherParser::Expression11Context>(i); } @@ -4539,7 +4496,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression12Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression12Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression12Context::SP(size_t i) { return getToken(CypherParser::SP, i); } @@ -4547,42 +4504,40 @@ std::vector<tree::TerminalNode *> CypherParser::Expression12Context::OR() { return getTokens(CypherParser::OR); } -tree::TerminalNode* CypherParser::Expression12Context::OR(size_t i) { +tree::TerminalNode *CypherParser::Expression12Context::OR(size_t i) { return getToken(CypherParser::OR, i); } - size_t CypherParser::Expression12Context::getRuleIndex() const { return CypherParser::RuleExpression12; } -void CypherParser::Expression12Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression12Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression12(this); + if (parserListener != nullptr) parserListener->enterExpression12(this); } -void CypherParser::Expression12Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression12Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression12(this); + if (parserListener != nullptr) parserListener->exitExpression12(this); } - -antlrcpp::Any CypherParser::Expression12Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression12Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression12(this); else return visitor->visitChildren(this); } -CypherParser::Expression12Context* CypherParser::expression12() { - Expression12Context *_localctx = _tracker.createInstance<Expression12Context>(_ctx, getState()); +CypherParser::Expression12Context *CypherParser::expression12() { + Expression12Context *_localctx = + _tracker.createInstance<Expression12Context>(_ctx, getState()); enterRule(_localctx, 86, CypherParser::RuleExpression12); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -4590,7 +4545,8 @@ CypherParser::Expression12Context* CypherParser::expression12() { expression11(); setState(685); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 106, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 106, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(679); @@ -4600,15 +4556,15 @@ CypherParser::Expression12Context* CypherParser::expression12() { setState(681); match(CypherParser::SP); setState(682); - expression11(); + expression11(); } setState(687); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 106, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 106, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4617,17 +4573,20 @@ CypherParser::Expression12Context* CypherParser::expression12() { return _localctx; } -//----------------- Expression11Context ------------------------------------------------------------------ +//----------------- Expression11Context +//------------------------------------------------------------------ -CypherParser::Expression11Context::Expression11Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression11Context::Expression11Context( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::Expression10Context *> CypherParser::Expression11Context::expression10() { +std::vector<CypherParser::Expression10Context *> +CypherParser::Expression11Context::expression10() { return getRuleContexts<CypherParser::Expression10Context>(); } -CypherParser::Expression10Context* CypherParser::Expression11Context::expression10(size_t i) { +CypherParser::Expression10Context * +CypherParser::Expression11Context::expression10(size_t i) { return getRuleContext<CypherParser::Expression10Context>(i); } @@ -4635,7 +4594,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression11Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression11Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression11Context::SP(size_t i) { return getToken(CypherParser::SP, i); } @@ -4643,42 +4602,40 @@ std::vector<tree::TerminalNode *> CypherParser::Expression11Context::XOR() { return getTokens(CypherParser::XOR); } -tree::TerminalNode* CypherParser::Expression11Context::XOR(size_t i) { +tree::TerminalNode *CypherParser::Expression11Context::XOR(size_t i) { return getToken(CypherParser::XOR, i); } - size_t CypherParser::Expression11Context::getRuleIndex() const { return CypherParser::RuleExpression11; } -void CypherParser::Expression11Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression11Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression11(this); + if (parserListener != nullptr) parserListener->enterExpression11(this); } -void CypherParser::Expression11Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression11Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression11(this); + if (parserListener != nullptr) parserListener->exitExpression11(this); } - -antlrcpp::Any CypherParser::Expression11Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression11Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression11(this); else return visitor->visitChildren(this); } -CypherParser::Expression11Context* CypherParser::expression11() { - Expression11Context *_localctx = _tracker.createInstance<Expression11Context>(_ctx, getState()); +CypherParser::Expression11Context *CypherParser::expression11() { + Expression11Context *_localctx = + _tracker.createInstance<Expression11Context>(_ctx, getState()); enterRule(_localctx, 88, CypherParser::RuleExpression11); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -4686,7 +4643,8 @@ CypherParser::Expression11Context* CypherParser::expression11() { expression10(); setState(695); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 107, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 107, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(689); @@ -4696,15 +4654,15 @@ CypherParser::Expression11Context* CypherParser::expression11() { setState(691); match(CypherParser::SP); setState(692); - expression10(); + expression10(); } setState(697); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 107, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 107, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4713,17 +4671,20 @@ CypherParser::Expression11Context* CypherParser::expression11() { return _localctx; } -//----------------- Expression10Context ------------------------------------------------------------------ +//----------------- Expression10Context +//------------------------------------------------------------------ -CypherParser::Expression10Context::Expression10Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression10Context::Expression10Context( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::Expression9Context *> CypherParser::Expression10Context::expression9() { +std::vector<CypherParser::Expression9Context *> +CypherParser::Expression10Context::expression9() { return getRuleContexts<CypherParser::Expression9Context>(); } -CypherParser::Expression9Context* CypherParser::Expression10Context::expression9(size_t i) { +CypherParser::Expression9Context * +CypherParser::Expression10Context::expression9(size_t i) { return getRuleContext<CypherParser::Expression9Context>(i); } @@ -4731,7 +4692,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression10Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression10Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression10Context::SP(size_t i) { return getToken(CypherParser::SP, i); } @@ -4739,42 +4700,40 @@ std::vector<tree::TerminalNode *> CypherParser::Expression10Context::AND() { return getTokens(CypherParser::AND); } -tree::TerminalNode* CypherParser::Expression10Context::AND(size_t i) { +tree::TerminalNode *CypherParser::Expression10Context::AND(size_t i) { return getToken(CypherParser::AND, i); } - size_t CypherParser::Expression10Context::getRuleIndex() const { return CypherParser::RuleExpression10; } -void CypherParser::Expression10Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression10Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression10(this); + if (parserListener != nullptr) parserListener->enterExpression10(this); } -void CypherParser::Expression10Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression10Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression10(this); + if (parserListener != nullptr) parserListener->exitExpression10(this); } - -antlrcpp::Any CypherParser::Expression10Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression10Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression10(this); else return visitor->visitChildren(this); } -CypherParser::Expression10Context* CypherParser::expression10() { - Expression10Context *_localctx = _tracker.createInstance<Expression10Context>(_ctx, getState()); +CypherParser::Expression10Context *CypherParser::expression10() { + Expression10Context *_localctx = + _tracker.createInstance<Expression10Context>(_ctx, getState()); enterRule(_localctx, 90, CypherParser::RuleExpression10); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -4782,7 +4741,8 @@ CypherParser::Expression10Context* CypherParser::expression10() { expression9(); setState(705); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 108, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 108, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(699); @@ -4792,15 +4752,15 @@ CypherParser::Expression10Context* CypherParser::expression10() { setState(701); match(CypherParser::SP); setState(702); - expression9(); + expression9(); } setState(707); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 108, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 108, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4809,13 +4769,15 @@ CypherParser::Expression10Context* CypherParser::expression10() { return _localctx; } -//----------------- Expression9Context ------------------------------------------------------------------ +//----------------- Expression9Context +//------------------------------------------------------------------ -CypherParser::Expression9Context::Expression9Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression9Context::Expression9Context(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::Expression8Context* CypherParser::Expression9Context::expression8() { +CypherParser::Expression8Context * +CypherParser::Expression9Context::expression8() { return getRuleContext<CypherParser::Expression8Context>(0); } @@ -4823,7 +4785,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression9Context::NOT() { return getTokens(CypherParser::NOT); } -tree::TerminalNode* CypherParser::Expression9Context::NOT(size_t i) { +tree::TerminalNode *CypherParser::Expression9Context::NOT(size_t i) { return getToken(CypherParser::NOT, i); } @@ -4831,49 +4793,48 @@ std::vector<tree::TerminalNode *> CypherParser::Expression9Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression9Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression9Context::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::Expression9Context::getRuleIndex() const { return CypherParser::RuleExpression9; } -void CypherParser::Expression9Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression9Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression9(this); + if (parserListener != nullptr) parserListener->enterExpression9(this); } -void CypherParser::Expression9Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression9Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression9(this); + if (parserListener != nullptr) parserListener->exitExpression9(this); } - -antlrcpp::Any CypherParser::Expression9Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression9Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression9(this); else return visitor->visitChildren(this); } -CypherParser::Expression9Context* CypherParser::expression9() { - Expression9Context *_localctx = _tracker.createInstance<Expression9Context>(_ctx, getState()); +CypherParser::Expression9Context *CypherParser::expression9() { + Expression9Context *_localctx = + _tracker.createInstance<Expression9Context>(_ctx, getState()); enterRule(_localctx, 92, CypherParser::RuleExpression9); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); setState(714); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 110, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 110, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(708); @@ -4885,17 +4846,17 @@ CypherParser::Expression9Context* CypherParser::expression9() { if (_la == CypherParser::SP) { setState(709); match(CypherParser::SP); - } + } } setState(716); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 110, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 110, _ctx); } setState(717); expression8(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4904,21 +4865,25 @@ CypherParser::Expression9Context* CypherParser::expression9() { return _localctx; } -//----------------- Expression8Context ------------------------------------------------------------------ +//----------------- Expression8Context +//------------------------------------------------------------------ -CypherParser::Expression8Context::Expression8Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression8Context::Expression8Context(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::Expression7Context* CypherParser::Expression8Context::expression7() { +CypherParser::Expression7Context * +CypherParser::Expression8Context::expression7() { return getRuleContext<CypherParser::Expression7Context>(0); } -std::vector<CypherParser::PartialComparisonExpressionContext *> CypherParser::Expression8Context::partialComparisonExpression() { +std::vector<CypherParser::PartialComparisonExpressionContext *> +CypherParser::Expression8Context::partialComparisonExpression() { return getRuleContexts<CypherParser::PartialComparisonExpressionContext>(); } -CypherParser::PartialComparisonExpressionContext* CypherParser::Expression8Context::partialComparisonExpression(size_t i) { +CypherParser::PartialComparisonExpressionContext * +CypherParser::Expression8Context::partialComparisonExpression(size_t i) { return getRuleContext<CypherParser::PartialComparisonExpressionContext>(i); } @@ -4926,43 +4891,41 @@ std::vector<tree::TerminalNode *> CypherParser::Expression8Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression8Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression8Context::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::Expression8Context::getRuleIndex() const { return CypherParser::RuleExpression8; } -void CypherParser::Expression8Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression8Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression8(this); + if (parserListener != nullptr) parserListener->enterExpression8(this); } -void CypherParser::Expression8Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression8Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression8(this); + if (parserListener != nullptr) parserListener->exitExpression8(this); } - -antlrcpp::Any CypherParser::Expression8Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression8Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression8(this); else return visitor->visitChildren(this); } -CypherParser::Expression8Context* CypherParser::expression8() { - Expression8Context *_localctx = _tracker.createInstance<Expression8Context>(_ctx, getState()); +CypherParser::Expression8Context *CypherParser::expression8() { + Expression8Context *_localctx = + _tracker.createInstance<Expression8Context>(_ctx, getState()); enterRule(_localctx, 94, CypherParser::RuleExpression8); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -4970,7 +4933,8 @@ CypherParser::Expression8Context* CypherParser::expression8() { expression7(); setState(726); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 112, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 112, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(721); @@ -4982,15 +4946,15 @@ CypherParser::Expression8Context* CypherParser::expression8() { match(CypherParser::SP); } setState(723); - partialComparisonExpression(); + partialComparisonExpression(); } setState(728); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 112, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 112, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -4999,17 +4963,20 @@ CypherParser::Expression8Context* CypherParser::expression8() { return _localctx; } -//----------------- Expression7Context ------------------------------------------------------------------ +//----------------- Expression7Context +//------------------------------------------------------------------ -CypherParser::Expression7Context::Expression7Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression7Context::Expression7Context(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::Expression6Context *> CypherParser::Expression7Context::expression6() { +std::vector<CypherParser::Expression6Context *> +CypherParser::Expression7Context::expression6() { return getRuleContexts<CypherParser::Expression6Context>(); } -CypherParser::Expression6Context* CypherParser::Expression7Context::expression6(size_t i) { +CypherParser::Expression6Context *CypherParser::Expression7Context::expression6( + size_t i) { return getRuleContext<CypherParser::Expression6Context>(i); } @@ -5017,43 +4984,41 @@ std::vector<tree::TerminalNode *> CypherParser::Expression7Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression7Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression7Context::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::Expression7Context::getRuleIndex() const { return CypherParser::RuleExpression7; } -void CypherParser::Expression7Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression7Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression7(this); + if (parserListener != nullptr) parserListener->enterExpression7(this); } -void CypherParser::Expression7Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression7Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression7(this); + if (parserListener != nullptr) parserListener->exitExpression7(this); } - -antlrcpp::Any CypherParser::Expression7Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression7Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression7(this); else return visitor->visitChildren(this); } -CypherParser::Expression7Context* CypherParser::expression7() { - Expression7Context *_localctx = _tracker.createInstance<Expression7Context>(_ctx, getState()); +CypherParser::Expression7Context *CypherParser::expression7() { + Expression7Context *_localctx = + _tracker.createInstance<Expression7Context>(_ctx, getState()); enterRule(_localctx, 96, CypherParser::RuleExpression7); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -5061,69 +5026,70 @@ CypherParser::Expression7Context* CypherParser::expression7() { expression6(); setState(748); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 118, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 118, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(746); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 117, _ctx)) { - case 1: { - setState(731); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 117, _ctx)) { + case 1: { + setState(731); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(730); - match(CypherParser::SP); - } - setState(733); - match(CypherParser::T__13); - setState(735); - _errHandler->sync(this); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(730); + match(CypherParser::SP); + } + setState(733); + match(CypherParser::T__13); + setState(735); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(734); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(734); + match(CypherParser::SP); + } + setState(737); + expression6(); + break; + } + + case 2: { + setState(739); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(738); + match(CypherParser::SP); + } + setState(741); + match(CypherParser::T__14); + setState(743); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(742); + match(CypherParser::SP); + } + setState(745); + expression6(); + break; } - setState(737); - expression6(); - break; } - - case 2: { - setState(739); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(738); - match(CypherParser::SP); - } - setState(741); - match(CypherParser::T__14); - setState(743); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(742); - match(CypherParser::SP); - } - setState(745); - expression6(); - break; - } - - } } setState(750); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 118, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 118, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -5132,17 +5098,20 @@ CypherParser::Expression7Context* CypherParser::expression7() { return _localctx; } -//----------------- Expression6Context ------------------------------------------------------------------ +//----------------- Expression6Context +//------------------------------------------------------------------ -CypherParser::Expression6Context::Expression6Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression6Context::Expression6Context(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::Expression5Context *> CypherParser::Expression6Context::expression5() { +std::vector<CypherParser::Expression5Context *> +CypherParser::Expression6Context::expression5() { return getRuleContexts<CypherParser::Expression5Context>(); } -CypherParser::Expression5Context* CypherParser::Expression6Context::expression5(size_t i) { +CypherParser::Expression5Context *CypherParser::Expression6Context::expression5( + size_t i) { return getRuleContext<CypherParser::Expression5Context>(i); } @@ -5150,43 +5119,41 @@ std::vector<tree::TerminalNode *> CypherParser::Expression6Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression6Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression6Context::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::Expression6Context::getRuleIndex() const { return CypherParser::RuleExpression6; } -void CypherParser::Expression6Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression6Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression6(this); + if (parserListener != nullptr) parserListener->enterExpression6(this); } -void CypherParser::Expression6Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression6Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression6(this); + if (parserListener != nullptr) parserListener->exitExpression6(this); } - -antlrcpp::Any CypherParser::Expression6Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression6Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression6(this); else return visitor->visitChildren(this); } -CypherParser::Expression6Context* CypherParser::expression6() { - Expression6Context *_localctx = _tracker.createInstance<Expression6Context>(_ctx, getState()); +CypherParser::Expression6Context *CypherParser::expression6() { + Expression6Context *_localctx = + _tracker.createInstance<Expression6Context>(_ctx, getState()); enterRule(_localctx, 98, CypherParser::RuleExpression6); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -5194,93 +5161,94 @@ CypherParser::Expression6Context* CypherParser::expression6() { expression5(); setState(778); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 126, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 126, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(776); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 125, _ctx)) { - case 1: { - setState(753); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 125, _ctx)) { + case 1: { + setState(753); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(752); - match(CypherParser::SP); - } - setState(755); - match(CypherParser::T__4); - setState(757); - _errHandler->sync(this); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(752); + match(CypherParser::SP); + } + setState(755); + match(CypherParser::T__4); + setState(757); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(756); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(756); + match(CypherParser::SP); + } + setState(759); + expression5(); + break; + } + + case 2: { + setState(761); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(760); + match(CypherParser::SP); + } + setState(763); + match(CypherParser::T__15); + setState(765); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(764); + match(CypherParser::SP); + } + setState(767); + expression5(); + break; + } + + case 3: { + setState(769); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(768); + match(CypherParser::SP); + } + setState(771); + match(CypherParser::T__16); + setState(773); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(772); + match(CypherParser::SP); + } + setState(775); + expression5(); + break; } - setState(759); - expression5(); - break; } - - case 2: { - setState(761); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(760); - match(CypherParser::SP); - } - setState(763); - match(CypherParser::T__15); - setState(765); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(764); - match(CypherParser::SP); - } - setState(767); - expression5(); - break; - } - - case 3: { - setState(769); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(768); - match(CypherParser::SP); - } - setState(771); - match(CypherParser::T__16); - setState(773); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(772); - match(CypherParser::SP); - } - setState(775); - expression5(); - break; - } - - } } setState(780); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 126, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 126, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -5289,17 +5257,20 @@ CypherParser::Expression6Context* CypherParser::expression6() { return _localctx; } -//----------------- Expression5Context ------------------------------------------------------------------ +//----------------- Expression5Context +//------------------------------------------------------------------ -CypherParser::Expression5Context::Expression5Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression5Context::Expression5Context(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::Expression4Context *> CypherParser::Expression5Context::expression4() { +std::vector<CypherParser::Expression4Context *> +CypherParser::Expression5Context::expression4() { return getRuleContexts<CypherParser::Expression4Context>(); } -CypherParser::Expression4Context* CypherParser::Expression5Context::expression4(size_t i) { +CypherParser::Expression4Context *CypherParser::Expression5Context::expression4( + size_t i) { return getRuleContext<CypherParser::Expression4Context>(i); } @@ -5307,43 +5278,41 @@ std::vector<tree::TerminalNode *> CypherParser::Expression5Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression5Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression5Context::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::Expression5Context::getRuleIndex() const { return CypherParser::RuleExpression5; } -void CypherParser::Expression5Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression5Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression5(this); + if (parserListener != nullptr) parserListener->enterExpression5(this); } -void CypherParser::Expression5Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression5Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression5(this); + if (parserListener != nullptr) parserListener->exitExpression5(this); } - -antlrcpp::Any CypherParser::Expression5Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression5Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression5(this); else return visitor->visitChildren(this); } -CypherParser::Expression5Context* CypherParser::expression5() { - Expression5Context *_localctx = _tracker.createInstance<Expression5Context>(_ctx, getState()); +CypherParser::Expression5Context *CypherParser::expression5() { + Expression5Context *_localctx = + _tracker.createInstance<Expression5Context>(_ctx, getState()); enterRule(_localctx, 100, CypherParser::RuleExpression5); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -5351,7 +5320,8 @@ CypherParser::Expression5Context* CypherParser::expression5() { expression4(); setState(792); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 129, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 129, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(783); @@ -5373,15 +5343,15 @@ CypherParser::Expression5Context* CypherParser::expression5() { match(CypherParser::SP); } setState(789); - expression4(); + expression4(); } setState(794); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 129, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 129, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -5390,13 +5360,15 @@ CypherParser::Expression5Context* CypherParser::expression5() { return _localctx; } -//----------------- Expression4Context ------------------------------------------------------------------ +//----------------- Expression4Context +//------------------------------------------------------------------ -CypherParser::Expression4Context::Expression4Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression4Context::Expression4Context(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::Expression3Context* CypherParser::Expression4Context::expression3() { +CypherParser::Expression3Context * +CypherParser::Expression4Context::expression3() { return getRuleContext<CypherParser::Expression3Context>(0); } @@ -5404,43 +5376,41 @@ std::vector<tree::TerminalNode *> CypherParser::Expression4Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression4Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression4Context::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::Expression4Context::getRuleIndex() const { return CypherParser::RuleExpression4; } -void CypherParser::Expression4Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression4Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression4(this); + if (parserListener != nullptr) parserListener->enterExpression4(this); } -void CypherParser::Expression4Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression4Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression4(this); + if (parserListener != nullptr) parserListener->exitExpression4(this); } - -antlrcpp::Any CypherParser::Expression4Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression4Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression4(this); else return visitor->visitChildren(this); } -CypherParser::Expression4Context* CypherParser::expression4() { - Expression4Context *_localctx = _tracker.createInstance<Expression4Context>(_ctx, getState()); +CypherParser::Expression4Context *CypherParser::expression4() { + Expression4Context *_localctx = + _tracker.createInstance<Expression4Context>(_ctx, getState()); enterRule(_localctx, 102, CypherParser::RuleExpression4); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(801); @@ -5448,15 +5418,14 @@ CypherParser::Expression4Context* CypherParser::expression4() { _la = _input->LA(1); while (_la == CypherParser::T__13 - || _la == CypherParser::T__14) { + || _la == CypherParser::T__14) { setState(795); _la = _input->LA(1); if (!(_la == CypherParser::T__13 - || _la == CypherParser::T__14)) { - _errHandler->recoverInline(this); - } - else { + || _la == CypherParser::T__14)) { + _errHandler->recoverInline(this); + } else { _errHandler->reportMatch(this); consume(); } @@ -5474,9 +5443,8 @@ CypherParser::Expression4Context* CypherParser::expression4() { } setState(804); expression3(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -5485,25 +5453,30 @@ CypherParser::Expression4Context* CypherParser::expression4() { return _localctx; } -//----------------- Expression3Context ------------------------------------------------------------------ +//----------------- Expression3Context +//------------------------------------------------------------------ -CypherParser::Expression3Context::Expression3Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression3Context::Expression3Context(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -std::vector<CypherParser::Expression2Context *> CypherParser::Expression3Context::expression2() { +std::vector<CypherParser::Expression2Context *> +CypherParser::Expression3Context::expression2() { return getRuleContexts<CypherParser::Expression2Context>(); } -CypherParser::Expression2Context* CypherParser::Expression3Context::expression2(size_t i) { +CypherParser::Expression2Context *CypherParser::Expression3Context::expression2( + size_t i) { return getRuleContext<CypherParser::Expression2Context>(i); } -std::vector<CypherParser::ExpressionContext *> CypherParser::Expression3Context::expression() { +std::vector<CypherParser::ExpressionContext *> +CypherParser::Expression3Context::expression() { return getRuleContexts<CypherParser::ExpressionContext>(); } -CypherParser::ExpressionContext* CypherParser::Expression3Context::expression(size_t i) { +CypherParser::ExpressionContext *CypherParser::Expression3Context::expression( + size_t i) { return getRuleContext<CypherParser::ExpressionContext>(i); } @@ -5511,7 +5484,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression3Context::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::Expression3Context::SP(size_t i) { +tree::TerminalNode *CypherParser::Expression3Context::SP(size_t i) { return getToken(CypherParser::SP, i); } @@ -5519,15 +5492,16 @@ std::vector<tree::TerminalNode *> CypherParser::Expression3Context::IS() { return getTokens(CypherParser::IS); } -tree::TerminalNode* CypherParser::Expression3Context::IS(size_t i) { +tree::TerminalNode *CypherParser::Expression3Context::IS(size_t i) { return getToken(CypherParser::IS, i); } -std::vector<tree::TerminalNode *> CypherParser::Expression3Context::CYPHERNULL() { +std::vector<tree::TerminalNode *> +CypherParser::Expression3Context::CYPHERNULL() { return getTokens(CypherParser::CYPHERNULL); } -tree::TerminalNode* CypherParser::Expression3Context::CYPHERNULL(size_t i) { +tree::TerminalNode *CypherParser::Expression3Context::CYPHERNULL(size_t i) { return getToken(CypherParser::CYPHERNULL, i); } @@ -5535,7 +5509,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression3Context::NOT() { return getTokens(CypherParser::NOT); } -tree::TerminalNode* CypherParser::Expression3Context::NOT(size_t i) { +tree::TerminalNode *CypherParser::Expression3Context::NOT(size_t i) { return getToken(CypherParser::NOT, i); } @@ -5543,7 +5517,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression3Context::IN() { return getTokens(CypherParser::IN); } -tree::TerminalNode* CypherParser::Expression3Context::IN(size_t i) { +tree::TerminalNode *CypherParser::Expression3Context::IN(size_t i) { return getToken(CypherParser::IN, i); } @@ -5551,7 +5525,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression3Context::STARTS() { return getTokens(CypherParser::STARTS); } -tree::TerminalNode* CypherParser::Expression3Context::STARTS(size_t i) { +tree::TerminalNode *CypherParser::Expression3Context::STARTS(size_t i) { return getToken(CypherParser::STARTS, i); } @@ -5559,7 +5533,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression3Context::WITH() { return getTokens(CypherParser::WITH); } -tree::TerminalNode* CypherParser::Expression3Context::WITH(size_t i) { +tree::TerminalNode *CypherParser::Expression3Context::WITH(size_t i) { return getToken(CypherParser::WITH, i); } @@ -5567,7 +5541,7 @@ std::vector<tree::TerminalNode *> CypherParser::Expression3Context::ENDS() { return getTokens(CypherParser::ENDS); } -tree::TerminalNode* CypherParser::Expression3Context::ENDS(size_t i) { +tree::TerminalNode *CypherParser::Expression3Context::ENDS(size_t i) { return getToken(CypherParser::ENDS, i); } @@ -5575,43 +5549,41 @@ std::vector<tree::TerminalNode *> CypherParser::Expression3Context::CONTAINS() { return getTokens(CypherParser::CONTAINS); } -tree::TerminalNode* CypherParser::Expression3Context::CONTAINS(size_t i) { +tree::TerminalNode *CypherParser::Expression3Context::CONTAINS(size_t i) { return getToken(CypherParser::CONTAINS, i); } - size_t CypherParser::Expression3Context::getRuleIndex() const { return CypherParser::RuleExpression3; } -void CypherParser::Expression3Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression3Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression3(this); + if (parserListener != nullptr) parserListener->enterExpression3(this); } -void CypherParser::Expression3Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression3Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression3(this); + if (parserListener != nullptr) parserListener->exitExpression3(this); } - -antlrcpp::Any CypherParser::Expression3Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression3Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression3(this); else return visitor->visitChildren(this); } -CypherParser::Expression3Context* CypherParser::expression3() { - Expression3Context *_localctx = _tracker.createInstance<Expression3Context>(_ctx, getState()); +CypherParser::Expression3Context *CypherParser::expression3() { + Expression3Context *_localctx = + _tracker.createInstance<Expression3Context>(_ctx, getState()); enterRule(_localctx, 104, CypherParser::RuleExpression3); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -5619,289 +5591,294 @@ CypherParser::Expression3Context* CypherParser::expression3() { expression2(); setState(860); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 140, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 140, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(858); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 139, _ctx)) { - case 1: { - setState(808); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(807); - match(CypherParser::SP); - } - setState(810); - match(CypherParser::T__7); - setState(811); - expression(); - setState(812); - match(CypherParser::T__9); - break; - } - - case 2: { - setState(815); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(814); - match(CypherParser::SP); - } - setState(817); - match(CypherParser::T__7); - setState(819); - _errHandler->sync(this); - - _la = _input->LA(1); - if ((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::T__5) - | (1ULL << CypherParser::T__7) - | (1ULL << CypherParser::T__13) - | (1ULL << CypherParser::T__14) - | (1ULL << CypherParser::T__27) - | (1ULL << CypherParser::T__29) - | (1ULL << CypherParser::StringLiteral) - | (1ULL << CypherParser::HexInteger) - | (1ULL << CypherParser::DecimalInteger) - | (1ULL << CypherParser::OctalInteger) - | (1ULL << CypherParser::HexLetter) - | (1ULL << CypherParser::ExponentDecimalReal) - | (1ULL << CypherParser::RegularDecimalReal))) != 0) || ((((_la - 64) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 64)) & ((1ULL << (CypherParser::UNION - 64)) - | (1ULL << (CypherParser::ALL - 64)) - | (1ULL << (CypherParser::OPTIONAL - 64)) - | (1ULL << (CypherParser::MATCH - 64)) - | (1ULL << (CypherParser::UNWIND - 64)) - | (1ULL << (CypherParser::AS - 64)) - | (1ULL << (CypherParser::MERGE - 64)) - | (1ULL << (CypherParser::ON - 64)) - | (1ULL << (CypherParser::CREATE - 64)) - | (1ULL << (CypherParser::SET - 64)) - | (1ULL << (CypherParser::DETACH - 64)) - | (1ULL << (CypherParser::DELETE - 64)) - | (1ULL << (CypherParser::REMOVE - 64)) - | (1ULL << (CypherParser::WITH - 64)) - | (1ULL << (CypherParser::DISTINCT - 64)) - | (1ULL << (CypherParser::RETURN - 64)) - | (1ULL << (CypherParser::ORDER - 64)) - | (1ULL << (CypherParser::BY - 64)) - | (1ULL << (CypherParser::L_SKIP - 64)) - | (1ULL << (CypherParser::LIMIT - 64)) - | (1ULL << (CypherParser::ASCENDING - 64)) - | (1ULL << (CypherParser::ASC - 64)) - | (1ULL << (CypherParser::DESCENDING - 64)) - | (1ULL << (CypherParser::DESC - 64)) - | (1ULL << (CypherParser::WHERE - 64)) - | (1ULL << (CypherParser::OR - 64)) - | (1ULL << (CypherParser::XOR - 64)) - | (1ULL << (CypherParser::AND - 64)) - | (1ULL << (CypherParser::NOT - 64)) - | (1ULL << (CypherParser::IN - 64)) - | (1ULL << (CypherParser::STARTS - 64)) - | (1ULL << (CypherParser::ENDS - 64)) - | (1ULL << (CypherParser::CONTAINS - 64)) - | (1ULL << (CypherParser::IS - 64)) - | (1ULL << (CypherParser::CYPHERNULL - 64)) - | (1ULL << (CypherParser::COUNT - 64)) - | (1ULL << (CypherParser::FILTER - 64)) - | (1ULL << (CypherParser::EXTRACT - 64)) - | (1ULL << (CypherParser::ANY - 64)) - | (1ULL << (CypherParser::NONE - 64)) - | (1ULL << (CypherParser::SINGLE - 64)) - | (1ULL << (CypherParser::TRUE - 64)) - | (1ULL << (CypherParser::FALSE - 64)) - | (1ULL << (CypherParser::UnescapedSymbolicName - 64)) - | (1ULL << (CypherParser::EscapedSymbolicName - 64)))) != 0)) { - setState(818); - expression(); - } - setState(821); - match(CypherParser::T__12); - setState(823); - _errHandler->sync(this); - - _la = _input->LA(1); - if ((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::T__5) - | (1ULL << CypherParser::T__7) - | (1ULL << CypherParser::T__13) - | (1ULL << CypherParser::T__14) - | (1ULL << CypherParser::T__27) - | (1ULL << CypherParser::T__29) - | (1ULL << CypherParser::StringLiteral) - | (1ULL << CypherParser::HexInteger) - | (1ULL << CypherParser::DecimalInteger) - | (1ULL << CypherParser::OctalInteger) - | (1ULL << CypherParser::HexLetter) - | (1ULL << CypherParser::ExponentDecimalReal) - | (1ULL << CypherParser::RegularDecimalReal))) != 0) || ((((_la - 64) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 64)) & ((1ULL << (CypherParser::UNION - 64)) - | (1ULL << (CypherParser::ALL - 64)) - | (1ULL << (CypherParser::OPTIONAL - 64)) - | (1ULL << (CypherParser::MATCH - 64)) - | (1ULL << (CypherParser::UNWIND - 64)) - | (1ULL << (CypherParser::AS - 64)) - | (1ULL << (CypherParser::MERGE - 64)) - | (1ULL << (CypherParser::ON - 64)) - | (1ULL << (CypherParser::CREATE - 64)) - | (1ULL << (CypherParser::SET - 64)) - | (1ULL << (CypherParser::DETACH - 64)) - | (1ULL << (CypherParser::DELETE - 64)) - | (1ULL << (CypherParser::REMOVE - 64)) - | (1ULL << (CypherParser::WITH - 64)) - | (1ULL << (CypherParser::DISTINCT - 64)) - | (1ULL << (CypherParser::RETURN - 64)) - | (1ULL << (CypherParser::ORDER - 64)) - | (1ULL << (CypherParser::BY - 64)) - | (1ULL << (CypherParser::L_SKIP - 64)) - | (1ULL << (CypherParser::LIMIT - 64)) - | (1ULL << (CypherParser::ASCENDING - 64)) - | (1ULL << (CypherParser::ASC - 64)) - | (1ULL << (CypherParser::DESCENDING - 64)) - | (1ULL << (CypherParser::DESC - 64)) - | (1ULL << (CypherParser::WHERE - 64)) - | (1ULL << (CypherParser::OR - 64)) - | (1ULL << (CypherParser::XOR - 64)) - | (1ULL << (CypherParser::AND - 64)) - | (1ULL << (CypherParser::NOT - 64)) - | (1ULL << (CypherParser::IN - 64)) - | (1ULL << (CypherParser::STARTS - 64)) - | (1ULL << (CypherParser::ENDS - 64)) - | (1ULL << (CypherParser::CONTAINS - 64)) - | (1ULL << (CypherParser::IS - 64)) - | (1ULL << (CypherParser::CYPHERNULL - 64)) - | (1ULL << (CypherParser::COUNT - 64)) - | (1ULL << (CypherParser::FILTER - 64)) - | (1ULL << (CypherParser::EXTRACT - 64)) - | (1ULL << (CypherParser::ANY - 64)) - | (1ULL << (CypherParser::NONE - 64)) - | (1ULL << (CypherParser::SINGLE - 64)) - | (1ULL << (CypherParser::TRUE - 64)) - | (1ULL << (CypherParser::FALSE - 64)) - | (1ULL << (CypherParser::UnescapedSymbolicName - 64)) - | (1ULL << (CypherParser::EscapedSymbolicName - 64)))) != 0)) { - setState(822); - expression(); - } - setState(825); - match(CypherParser::T__9); - break; - } - - case 3: { - setState(842); - _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 137, _ctx)) { + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 139, _ctx)) { case 1: { - setState(827); + setState(808); _errHandler->sync(this); _la = _input->LA(1); if (_la == CypherParser::SP) { - setState(826); + setState(807); match(CypherParser::SP); } - setState(829); - match(CypherParser::T__18); + setState(810); + match(CypherParser::T__7); + setState(811); + expression(); + setState(812); + match(CypherParser::T__9); break; } case 2: { - setState(830); - match(CypherParser::SP); - setState(831); - match(CypherParser::IN); + setState(815); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(814); + match(CypherParser::SP); + } + setState(817); + match(CypherParser::T__7); + setState(819); + _errHandler->sync(this); + + _la = _input->LA(1); + if ((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & + ((1ULL << CypherParser::T__5) | (1ULL << CypherParser::T__7) | + (1ULL << CypherParser::T__13) | + (1ULL << CypherParser::T__14) | + (1ULL << CypherParser::T__27) | + (1ULL << CypherParser::T__29) | + (1ULL << CypherParser::StringLiteral) | + (1ULL << CypherParser::HexInteger) | + (1ULL << CypherParser::DecimalInteger) | + (1ULL << CypherParser::OctalInteger) | + (1ULL << CypherParser::HexLetter) | + (1ULL << CypherParser::ExponentDecimalReal) | + (1ULL << CypherParser::RegularDecimalReal))) != 0) || + ((((_la - 64) & ~0x3fULL) == 0) && + ((1ULL << (_la - 64)) & + ((1ULL << (CypherParser::UNION - 64)) | + (1ULL << (CypherParser::ALL - 64)) | + (1ULL << (CypherParser::OPTIONAL - 64)) | + (1ULL << (CypherParser::MATCH - 64)) | + (1ULL << (CypherParser::UNWIND - 64)) | + (1ULL << (CypherParser::AS - 64)) | + (1ULL << (CypherParser::MERGE - 64)) | + (1ULL << (CypherParser::ON - 64)) | + (1ULL << (CypherParser::CREATE - 64)) | + (1ULL << (CypherParser::SET - 64)) | + (1ULL << (CypherParser::DETACH - 64)) | + (1ULL << (CypherParser::DELETE - 64)) | + (1ULL << (CypherParser::REMOVE - 64)) | + (1ULL << (CypherParser::WITH - 64)) | + (1ULL << (CypherParser::DISTINCT - 64)) | + (1ULL << (CypherParser::RETURN - 64)) | + (1ULL << (CypherParser::ORDER - 64)) | + (1ULL << (CypherParser::BY - 64)) | + (1ULL << (CypherParser::L_SKIP - 64)) | + (1ULL << (CypherParser::LIMIT - 64)) | + (1ULL << (CypherParser::ASCENDING - 64)) | + (1ULL << (CypherParser::ASC - 64)) | + (1ULL << (CypherParser::DESCENDING - 64)) | + (1ULL << (CypherParser::DESC - 64)) | + (1ULL << (CypherParser::WHERE - 64)) | + (1ULL << (CypherParser::OR - 64)) | + (1ULL << (CypherParser::XOR - 64)) | + (1ULL << (CypherParser::AND - 64)) | + (1ULL << (CypherParser::NOT - 64)) | + (1ULL << (CypherParser::IN - 64)) | + (1ULL << (CypherParser::STARTS - 64)) | + (1ULL << (CypherParser::ENDS - 64)) | + (1ULL << (CypherParser::CONTAINS - 64)) | + (1ULL << (CypherParser::IS - 64)) | + (1ULL << (CypherParser::CYPHERNULL - 64)) | + (1ULL << (CypherParser::COUNT - 64)) | + (1ULL << (CypherParser::FILTER - 64)) | + (1ULL << (CypherParser::EXTRACT - 64)) | + (1ULL << (CypherParser::ANY - 64)) | + (1ULL << (CypherParser::NONE - 64)) | + (1ULL << (CypherParser::SINGLE - 64)) | + (1ULL << (CypherParser::TRUE - 64)) | + (1ULL << (CypherParser::FALSE - 64)) | + (1ULL << (CypherParser::UnescapedSymbolicName - 64)) | + (1ULL << (CypherParser::EscapedSymbolicName - 64)))) != 0)) { + setState(818); + expression(); + } + setState(821); + match(CypherParser::T__12); + setState(823); + _errHandler->sync(this); + + _la = _input->LA(1); + if ((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & + ((1ULL << CypherParser::T__5) | (1ULL << CypherParser::T__7) | + (1ULL << CypherParser::T__13) | + (1ULL << CypherParser::T__14) | + (1ULL << CypherParser::T__27) | + (1ULL << CypherParser::T__29) | + (1ULL << CypherParser::StringLiteral) | + (1ULL << CypherParser::HexInteger) | + (1ULL << CypherParser::DecimalInteger) | + (1ULL << CypherParser::OctalInteger) | + (1ULL << CypherParser::HexLetter) | + (1ULL << CypherParser::ExponentDecimalReal) | + (1ULL << CypherParser::RegularDecimalReal))) != 0) || + ((((_la - 64) & ~0x3fULL) == 0) && + ((1ULL << (_la - 64)) & + ((1ULL << (CypherParser::UNION - 64)) | + (1ULL << (CypherParser::ALL - 64)) | + (1ULL << (CypherParser::OPTIONAL - 64)) | + (1ULL << (CypherParser::MATCH - 64)) | + (1ULL << (CypherParser::UNWIND - 64)) | + (1ULL << (CypherParser::AS - 64)) | + (1ULL << (CypherParser::MERGE - 64)) | + (1ULL << (CypherParser::ON - 64)) | + (1ULL << (CypherParser::CREATE - 64)) | + (1ULL << (CypherParser::SET - 64)) | + (1ULL << (CypherParser::DETACH - 64)) | + (1ULL << (CypherParser::DELETE - 64)) | + (1ULL << (CypherParser::REMOVE - 64)) | + (1ULL << (CypherParser::WITH - 64)) | + (1ULL << (CypherParser::DISTINCT - 64)) | + (1ULL << (CypherParser::RETURN - 64)) | + (1ULL << (CypherParser::ORDER - 64)) | + (1ULL << (CypherParser::BY - 64)) | + (1ULL << (CypherParser::L_SKIP - 64)) | + (1ULL << (CypherParser::LIMIT - 64)) | + (1ULL << (CypherParser::ASCENDING - 64)) | + (1ULL << (CypherParser::ASC - 64)) | + (1ULL << (CypherParser::DESCENDING - 64)) | + (1ULL << (CypherParser::DESC - 64)) | + (1ULL << (CypherParser::WHERE - 64)) | + (1ULL << (CypherParser::OR - 64)) | + (1ULL << (CypherParser::XOR - 64)) | + (1ULL << (CypherParser::AND - 64)) | + (1ULL << (CypherParser::NOT - 64)) | + (1ULL << (CypherParser::IN - 64)) | + (1ULL << (CypherParser::STARTS - 64)) | + (1ULL << (CypherParser::ENDS - 64)) | + (1ULL << (CypherParser::CONTAINS - 64)) | + (1ULL << (CypherParser::IS - 64)) | + (1ULL << (CypherParser::CYPHERNULL - 64)) | + (1ULL << (CypherParser::COUNT - 64)) | + (1ULL << (CypherParser::FILTER - 64)) | + (1ULL << (CypherParser::EXTRACT - 64)) | + (1ULL << (CypherParser::ANY - 64)) | + (1ULL << (CypherParser::NONE - 64)) | + (1ULL << (CypherParser::SINGLE - 64)) | + (1ULL << (CypherParser::TRUE - 64)) | + (1ULL << (CypherParser::FALSE - 64)) | + (1ULL << (CypherParser::UnescapedSymbolicName - 64)) | + (1ULL << (CypherParser::EscapedSymbolicName - 64)))) != 0)) { + setState(822); + expression(); + } + setState(825); + match(CypherParser::T__9); break; } case 3: { - setState(832); - match(CypherParser::SP); - setState(833); - match(CypherParser::STARTS); - setState(834); - match(CypherParser::SP); - setState(835); - match(CypherParser::WITH); + setState(842); + _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 137, _ctx)) { + case 1: { + setState(827); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(826); + match(CypherParser::SP); + } + setState(829); + match(CypherParser::T__18); + break; + } + + case 2: { + setState(830); + match(CypherParser::SP); + setState(831); + match(CypherParser::IN); + break; + } + + case 3: { + setState(832); + match(CypherParser::SP); + setState(833); + match(CypherParser::STARTS); + setState(834); + match(CypherParser::SP); + setState(835); + match(CypherParser::WITH); + break; + } + + case 4: { + setState(836); + match(CypherParser::SP); + setState(837); + match(CypherParser::ENDS); + setState(838); + match(CypherParser::SP); + setState(839); + match(CypherParser::WITH); + break; + } + + case 5: { + setState(840); + match(CypherParser::SP); + setState(841); + match(CypherParser::CONTAINS); + break; + } + } + setState(845); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(844); + match(CypherParser::SP); + } + setState(847); + expression2(); break; } case 4: { - setState(836); + setState(848); match(CypherParser::SP); - setState(837); - match(CypherParser::ENDS); - setState(838); + setState(849); + match(CypherParser::IS); + setState(850); match(CypherParser::SP); - setState(839); - match(CypherParser::WITH); + setState(851); + match(CypherParser::CYPHERNULL); break; } case 5: { - setState(840); + setState(852); match(CypherParser::SP); - setState(841); - match(CypherParser::CONTAINS); + setState(853); + match(CypherParser::IS); + setState(854); + match(CypherParser::SP); + setState(855); + match(CypherParser::NOT); + setState(856); + match(CypherParser::SP); + setState(857); + match(CypherParser::CYPHERNULL); break; } - - } - setState(845); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(844); - match(CypherParser::SP); - } - setState(847); - expression2(); - break; } - - case 4: { - setState(848); - match(CypherParser::SP); - setState(849); - match(CypherParser::IS); - setState(850); - match(CypherParser::SP); - setState(851); - match(CypherParser::CYPHERNULL); - break; - } - - case 5: { - setState(852); - match(CypherParser::SP); - setState(853); - match(CypherParser::IS); - setState(854); - match(CypherParser::SP); - setState(855); - match(CypherParser::NOT); - setState(856); - match(CypherParser::SP); - setState(857); - match(CypherParser::CYPHERNULL); - break; - } - - } } setState(862); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 140, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 140, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -5910,64 +5887,67 @@ CypherParser::Expression3Context* CypherParser::expression3() { return _localctx; } -//----------------- Expression2Context ------------------------------------------------------------------ +//----------------- Expression2Context +//------------------------------------------------------------------ -CypherParser::Expression2Context::Expression2Context(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::Expression2Context::Expression2Context(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::AtomContext* CypherParser::Expression2Context::atom() { +CypherParser::AtomContext *CypherParser::Expression2Context::atom() { return getRuleContext<CypherParser::AtomContext>(0); } -std::vector<CypherParser::PropertyLookupContext *> CypherParser::Expression2Context::propertyLookup() { +std::vector<CypherParser::PropertyLookupContext *> +CypherParser::Expression2Context::propertyLookup() { return getRuleContexts<CypherParser::PropertyLookupContext>(); } -CypherParser::PropertyLookupContext* CypherParser::Expression2Context::propertyLookup(size_t i) { +CypherParser::PropertyLookupContext * +CypherParser::Expression2Context::propertyLookup(size_t i) { return getRuleContext<CypherParser::PropertyLookupContext>(i); } -std::vector<CypherParser::NodeLabelsContext *> CypherParser::Expression2Context::nodeLabels() { +std::vector<CypherParser::NodeLabelsContext *> +CypherParser::Expression2Context::nodeLabels() { return getRuleContexts<CypherParser::NodeLabelsContext>(); } -CypherParser::NodeLabelsContext* CypherParser::Expression2Context::nodeLabels(size_t i) { +CypherParser::NodeLabelsContext *CypherParser::Expression2Context::nodeLabels( + size_t i) { return getRuleContext<CypherParser::NodeLabelsContext>(i); } - size_t CypherParser::Expression2Context::getRuleIndex() const { return CypherParser::RuleExpression2; } -void CypherParser::Expression2Context::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression2Context::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterExpression2(this); + if (parserListener != nullptr) parserListener->enterExpression2(this); } -void CypherParser::Expression2Context::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::Expression2Context::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitExpression2(this); + if (parserListener != nullptr) parserListener->exitExpression2(this); } - -antlrcpp::Any CypherParser::Expression2Context::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::Expression2Context::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitExpression2(this); else return visitor->visitChildren(this); } -CypherParser::Expression2Context* CypherParser::expression2() { - Expression2Context *_localctx = _tracker.createInstance<Expression2Context>(_ctx, getState()); +CypherParser::Expression2Context *CypherParser::expression2() { + Expression2Context *_localctx = + _tracker.createInstance<Expression2Context>(_ctx, getState()); enterRule(_localctx, 106, CypherParser::RuleExpression2); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); @@ -5975,7 +5955,8 @@ CypherParser::Expression2Context* CypherParser::expression2() { atom(); setState(868); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 142, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, + 142, _ctx); while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { if (alt == 1) { setState(866); @@ -5994,17 +5975,17 @@ CypherParser::Expression2Context* CypherParser::expression2() { break; } - default: - throw NoViableAltException(this); - } + default: + throw NoViableAltException(this); + } } setState(870); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 142, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 142, _ctx); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -6013,21 +5994,22 @@ CypherParser::Expression2Context* CypherParser::expression2() { return _localctx; } -//----------------- AtomContext ------------------------------------------------------------------ +//----------------- AtomContext +//------------------------------------------------------------------ -CypherParser::AtomContext::AtomContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::AtomContext::AtomContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::LiteralContext* CypherParser::AtomContext::literal() { +CypherParser::LiteralContext *CypherParser::AtomContext::literal() { return getRuleContext<CypherParser::LiteralContext>(0); } -CypherParser::ParameterContext* CypherParser::AtomContext::parameter() { +CypherParser::ParameterContext *CypherParser::AtomContext::parameter() { return getRuleContext<CypherParser::ParameterContext>(0); } -tree::TerminalNode* CypherParser::AtomContext::COUNT() { +tree::TerminalNode *CypherParser::AtomContext::COUNT() { return getToken(CypherParser::COUNT, 0); } @@ -6035,432 +6017,432 @@ std::vector<tree::TerminalNode *> CypherParser::AtomContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::AtomContext::SP(size_t i) { +tree::TerminalNode *CypherParser::AtomContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -CypherParser::ListComprehensionContext* CypherParser::AtomContext::listComprehension() { +CypherParser::ListComprehensionContext * +CypherParser::AtomContext::listComprehension() { return getRuleContext<CypherParser::ListComprehensionContext>(0); } -tree::TerminalNode* CypherParser::AtomContext::FILTER() { +tree::TerminalNode *CypherParser::AtomContext::FILTER() { return getToken(CypherParser::FILTER, 0); } -CypherParser::FilterExpressionContext* CypherParser::AtomContext::filterExpression() { +CypherParser::FilterExpressionContext * +CypherParser::AtomContext::filterExpression() { return getRuleContext<CypherParser::FilterExpressionContext>(0); } -tree::TerminalNode* CypherParser::AtomContext::EXTRACT() { +tree::TerminalNode *CypherParser::AtomContext::EXTRACT() { return getToken(CypherParser::EXTRACT, 0); } -CypherParser::ExpressionContext* CypherParser::AtomContext::expression() { +CypherParser::ExpressionContext *CypherParser::AtomContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } -tree::TerminalNode* CypherParser::AtomContext::ALL() { +tree::TerminalNode *CypherParser::AtomContext::ALL() { return getToken(CypherParser::ALL, 0); } -tree::TerminalNode* CypherParser::AtomContext::ANY() { +tree::TerminalNode *CypherParser::AtomContext::ANY() { return getToken(CypherParser::ANY, 0); } -tree::TerminalNode* CypherParser::AtomContext::NONE() { +tree::TerminalNode *CypherParser::AtomContext::NONE() { return getToken(CypherParser::NONE, 0); } -tree::TerminalNode* CypherParser::AtomContext::SINGLE() { +tree::TerminalNode *CypherParser::AtomContext::SINGLE() { return getToken(CypherParser::SINGLE, 0); } -CypherParser::RelationshipsPatternContext* CypherParser::AtomContext::relationshipsPattern() { +CypherParser::RelationshipsPatternContext * +CypherParser::AtomContext::relationshipsPattern() { return getRuleContext<CypherParser::RelationshipsPatternContext>(0); } -CypherParser::ParenthesizedExpressionContext* CypherParser::AtomContext::parenthesizedExpression() { +CypherParser::ParenthesizedExpressionContext * +CypherParser::AtomContext::parenthesizedExpression() { return getRuleContext<CypherParser::ParenthesizedExpressionContext>(0); } -CypherParser::FunctionInvocationContext* CypherParser::AtomContext::functionInvocation() { +CypherParser::FunctionInvocationContext * +CypherParser::AtomContext::functionInvocation() { return getRuleContext<CypherParser::FunctionInvocationContext>(0); } -CypherParser::VariableContext* CypherParser::AtomContext::variable() { +CypherParser::VariableContext *CypherParser::AtomContext::variable() { return getRuleContext<CypherParser::VariableContext>(0); } - size_t CypherParser::AtomContext::getRuleIndex() const { return CypherParser::RuleAtom; } void CypherParser::AtomContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterAtom(this); + if (parserListener != nullptr) parserListener->enterAtom(this); } void CypherParser::AtomContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitAtom(this); + if (parserListener != nullptr) parserListener->exitAtom(this); } - -antlrcpp::Any CypherParser::AtomContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::AtomContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitAtom(this); else return visitor->visitChildren(this); } -CypherParser::AtomContext* CypherParser::atom() { - AtomContext *_localctx = _tracker.createInstance<AtomContext>(_ctx, getState()); +CypherParser::AtomContext *CypherParser::atom() { + AtomContext *_localctx = + _tracker.createInstance<AtomContext>(_ctx, getState()); enterRule(_localctx, 108, CypherParser::RuleAtom); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(982); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 166, _ctx)) { - case 1: { - enterOuterAlt(_localctx, 1); - setState(871); - literal(); - break; - } - - case 2: { - enterOuterAlt(_localctx, 2); - setState(872); - parameter(); - break; - } - - case 3: { - enterOuterAlt(_localctx, 3); - setState(873); - match(CypherParser::COUNT); - setState(875); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(874); - match(CypherParser::SP); - } - setState(877); - match(CypherParser::T__5); - setState(879); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(878); - match(CypherParser::SP); - } - setState(881); - match(CypherParser::T__4); - setState(883); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(882); - match(CypherParser::SP); - } - setState(885); - match(CypherParser::T__6); - break; - } - - case 4: { - enterOuterAlt(_localctx, 4); - setState(886); - listComprehension(); - break; - } - - case 5: { - enterOuterAlt(_localctx, 5); - setState(887); - match(CypherParser::FILTER); - setState(889); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(888); - match(CypherParser::SP); - } - setState(891); - match(CypherParser::T__5); - setState(893); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(892); - match(CypherParser::SP); - } - setState(895); - filterExpression(); - setState(897); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(896); - match(CypherParser::SP); - } - setState(899); - match(CypherParser::T__6); - break; - } - - case 6: { - enterOuterAlt(_localctx, 6); - setState(901); - match(CypherParser::EXTRACT); - setState(903); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(902); - match(CypherParser::SP); - } - setState(905); - match(CypherParser::T__5); - setState(907); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(906); - match(CypherParser::SP); - } - setState(909); - filterExpression(); - setState(911); - _errHandler->sync(this); - - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 151, _ctx)) { + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 166, _ctx)) { case 1: { - setState(910); - match(CypherParser::SP); + enterOuterAlt(_localctx, 1); + setState(871); + literal(); break; } + case 2: { + enterOuterAlt(_localctx, 2); + setState(872); + parameter(); + break; } - setState(918); - _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::T__11 || _la == CypherParser::SP) { - setState(914); + case 3: { + enterOuterAlt(_localctx, 3); + setState(873); + match(CypherParser::COUNT); + setState(875); _errHandler->sync(this); _la = _input->LA(1); if (_la == CypherParser::SP) { - setState(913); + setState(874); match(CypherParser::SP); } - setState(916); - match(CypherParser::T__11); - setState(917); - expression(); + setState(877); + match(CypherParser::T__5); + setState(879); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(878); + match(CypherParser::SP); + } + setState(881); + match(CypherParser::T__4); + setState(883); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(882); + match(CypherParser::SP); + } + setState(885); + match(CypherParser::T__6); + break; + } + + case 4: { + enterOuterAlt(_localctx, 4); + setState(886); + listComprehension(); + break; + } + + case 5: { + enterOuterAlt(_localctx, 5); + setState(887); + match(CypherParser::FILTER); + setState(889); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(888); + match(CypherParser::SP); + } + setState(891); + match(CypherParser::T__5); + setState(893); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(892); + match(CypherParser::SP); + } + setState(895); + filterExpression(); + setState(897); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(896); + match(CypherParser::SP); + } + setState(899); + match(CypherParser::T__6); + break; + } + + case 6: { + enterOuterAlt(_localctx, 6); + setState(901); + match(CypherParser::EXTRACT); + setState(903); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(902); + match(CypherParser::SP); + } + setState(905); + match(CypherParser::T__5); + setState(907); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(906); + match(CypherParser::SP); + } + setState(909); + filterExpression(); + setState(911); + _errHandler->sync(this); + + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 151, _ctx)) { + case 1: { + setState(910); + match(CypherParser::SP); + break; + } + } + setState(918); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::T__11 || _la == CypherParser::SP) { + setState(914); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(913); + match(CypherParser::SP); + } + setState(916); + match(CypherParser::T__11); + setState(917); + expression(); + } + setState(920); + match(CypherParser::T__6); + break; + } + + case 7: { + enterOuterAlt(_localctx, 7); + setState(922); + match(CypherParser::ALL); + setState(924); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(923); + match(CypherParser::SP); + } + setState(926); + match(CypherParser::T__5); + setState(928); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(927); + match(CypherParser::SP); + } + setState(930); + filterExpression(); + setState(932); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(931); + match(CypherParser::SP); + } + setState(934); + match(CypherParser::T__6); + break; + } + + case 8: { + enterOuterAlt(_localctx, 8); + setState(936); + match(CypherParser::ANY); + setState(938); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(937); + match(CypherParser::SP); + } + setState(940); + match(CypherParser::T__5); + setState(942); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(941); + match(CypherParser::SP); + } + setState(944); + filterExpression(); + setState(946); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(945); + match(CypherParser::SP); + } + setState(948); + match(CypherParser::T__6); + break; + } + + case 9: { + enterOuterAlt(_localctx, 9); + setState(950); + match(CypherParser::NONE); + setState(952); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(951); + match(CypherParser::SP); + } + setState(954); + match(CypherParser::T__5); + setState(956); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(955); + match(CypherParser::SP); + } + setState(958); + filterExpression(); + setState(960); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(959); + match(CypherParser::SP); + } + setState(962); + match(CypherParser::T__6); + break; + } + + case 10: { + enterOuterAlt(_localctx, 10); + setState(964); + match(CypherParser::SINGLE); + setState(966); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(965); + match(CypherParser::SP); + } + setState(968); + match(CypherParser::T__5); + setState(970); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(969); + match(CypherParser::SP); + } + setState(972); + filterExpression(); + setState(974); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(973); + match(CypherParser::SP); + } + setState(976); + match(CypherParser::T__6); + break; + } + + case 11: { + enterOuterAlt(_localctx, 11); + setState(978); + relationshipsPattern(); + break; + } + + case 12: { + enterOuterAlt(_localctx, 12); + setState(979); + parenthesizedExpression(); + break; + } + + case 13: { + enterOuterAlt(_localctx, 13); + setState(980); + functionInvocation(); + break; + } + + case 14: { + enterOuterAlt(_localctx, 14); + setState(981); + variable(); + break; } - setState(920); - match(CypherParser::T__6); - break; } - case 7: { - enterOuterAlt(_localctx, 7); - setState(922); - match(CypherParser::ALL); - setState(924); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(923); - match(CypherParser::SP); - } - setState(926); - match(CypherParser::T__5); - setState(928); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(927); - match(CypherParser::SP); - } - setState(930); - filterExpression(); - setState(932); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(931); - match(CypherParser::SP); - } - setState(934); - match(CypherParser::T__6); - break; - } - - case 8: { - enterOuterAlt(_localctx, 8); - setState(936); - match(CypherParser::ANY); - setState(938); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(937); - match(CypherParser::SP); - } - setState(940); - match(CypherParser::T__5); - setState(942); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(941); - match(CypherParser::SP); - } - setState(944); - filterExpression(); - setState(946); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(945); - match(CypherParser::SP); - } - setState(948); - match(CypherParser::T__6); - break; - } - - case 9: { - enterOuterAlt(_localctx, 9); - setState(950); - match(CypherParser::NONE); - setState(952); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(951); - match(CypherParser::SP); - } - setState(954); - match(CypherParser::T__5); - setState(956); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(955); - match(CypherParser::SP); - } - setState(958); - filterExpression(); - setState(960); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(959); - match(CypherParser::SP); - } - setState(962); - match(CypherParser::T__6); - break; - } - - case 10: { - enterOuterAlt(_localctx, 10); - setState(964); - match(CypherParser::SINGLE); - setState(966); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(965); - match(CypherParser::SP); - } - setState(968); - match(CypherParser::T__5); - setState(970); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(969); - match(CypherParser::SP); - } - setState(972); - filterExpression(); - setState(974); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(973); - match(CypherParser::SP); - } - setState(976); - match(CypherParser::T__6); - break; - } - - case 11: { - enterOuterAlt(_localctx, 11); - setState(978); - relationshipsPattern(); - break; - } - - case 12: { - enterOuterAlt(_localctx, 12); - setState(979); - parenthesizedExpression(); - break; - } - - case 13: { - enterOuterAlt(_localctx, 13); - setState(980); - functionInvocation(); - break; - } - - case 14: { - enterOuterAlt(_localctx, 14); - setState(981); - variable(); - break; - } - - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -6469,68 +6451,68 @@ CypherParser::AtomContext* CypherParser::atom() { return _localctx; } -//----------------- LiteralContext ------------------------------------------------------------------ +//----------------- LiteralContext +//------------------------------------------------------------------ -CypherParser::LiteralContext::LiteralContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::LiteralContext::LiteralContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::NumberLiteralContext* CypherParser::LiteralContext::numberLiteral() { +CypherParser::NumberLiteralContext * +CypherParser::LiteralContext::numberLiteral() { return getRuleContext<CypherParser::NumberLiteralContext>(0); } -tree::TerminalNode* CypherParser::LiteralContext::StringLiteral() { +tree::TerminalNode *CypherParser::LiteralContext::StringLiteral() { return getToken(CypherParser::StringLiteral, 0); } -CypherParser::BooleanLiteralContext* CypherParser::LiteralContext::booleanLiteral() { +CypherParser::BooleanLiteralContext * +CypherParser::LiteralContext::booleanLiteral() { return getRuleContext<CypherParser::BooleanLiteralContext>(0); } -tree::TerminalNode* CypherParser::LiteralContext::CYPHERNULL() { +tree::TerminalNode *CypherParser::LiteralContext::CYPHERNULL() { return getToken(CypherParser::CYPHERNULL, 0); } -CypherParser::MapLiteralContext* CypherParser::LiteralContext::mapLiteral() { +CypherParser::MapLiteralContext *CypherParser::LiteralContext::mapLiteral() { return getRuleContext<CypherParser::MapLiteralContext>(0); } -CypherParser::ListLiteralContext* CypherParser::LiteralContext::listLiteral() { +CypherParser::ListLiteralContext *CypherParser::LiteralContext::listLiteral() { return getRuleContext<CypherParser::ListLiteralContext>(0); } - size_t CypherParser::LiteralContext::getRuleIndex() const { return CypherParser::RuleLiteral; } -void CypherParser::LiteralContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::LiteralContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterLiteral(this); + if (parserListener != nullptr) parserListener->enterLiteral(this); } void CypherParser::LiteralContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitLiteral(this); + if (parserListener != nullptr) parserListener->exitLiteral(this); } - -antlrcpp::Any CypherParser::LiteralContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::LiteralContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitLiteral(this); else return visitor->visitChildren(this); } -CypherParser::LiteralContext* CypherParser::literal() { - LiteralContext *_localctx = _tracker.createInstance<LiteralContext>(_ctx, getState()); +CypherParser::LiteralContext *CypherParser::literal() { + LiteralContext *_localctx = + _tracker.createInstance<LiteralContext>(_ctx, getState()); enterRule(_localctx, 110, CypherParser::RuleLiteral); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(990); _errHandler->sync(this); @@ -6582,12 +6564,11 @@ CypherParser::LiteralContext* CypherParser::literal() { break; } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -6596,69 +6577,66 @@ CypherParser::LiteralContext* CypherParser::literal() { return _localctx; } -//----------------- BooleanLiteralContext ------------------------------------------------------------------ +//----------------- BooleanLiteralContext +//------------------------------------------------------------------ -CypherParser::BooleanLiteralContext::BooleanLiteralContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::BooleanLiteralContext::BooleanLiteralContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::BooleanLiteralContext::TRUE() { +tree::TerminalNode *CypherParser::BooleanLiteralContext::TRUE() { return getToken(CypherParser::TRUE, 0); } -tree::TerminalNode* CypherParser::BooleanLiteralContext::FALSE() { +tree::TerminalNode *CypherParser::BooleanLiteralContext::FALSE() { return getToken(CypherParser::FALSE, 0); } - size_t CypherParser::BooleanLiteralContext::getRuleIndex() const { return CypherParser::RuleBooleanLiteral; } -void CypherParser::BooleanLiteralContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::BooleanLiteralContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterBooleanLiteral(this); + if (parserListener != nullptr) parserListener->enterBooleanLiteral(this); } -void CypherParser::BooleanLiteralContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::BooleanLiteralContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitBooleanLiteral(this); + if (parserListener != nullptr) parserListener->exitBooleanLiteral(this); } - -antlrcpp::Any CypherParser::BooleanLiteralContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::BooleanLiteralContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitBooleanLiteral(this); else return visitor->visitChildren(this); } -CypherParser::BooleanLiteralContext* CypherParser::booleanLiteral() { - BooleanLiteralContext *_localctx = _tracker.createInstance<BooleanLiteralContext>(_ctx, getState()); +CypherParser::BooleanLiteralContext *CypherParser::booleanLiteral() { + BooleanLiteralContext *_localctx = + _tracker.createInstance<BooleanLiteralContext>(_ctx, getState()); enterRule(_localctx, 112, CypherParser::RuleBooleanLiteral); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(992); _la = _input->LA(1); if (!(_la == CypherParser::TRUE - || _la == CypherParser::FALSE)) { - _errHandler->recoverInline(this); - } - else { + || _la == CypherParser::FALSE)) { + _errHandler->recoverInline(this); + } else { _errHandler->reportMatch(this); consume(); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -6667,61 +6645,62 @@ CypherParser::BooleanLiteralContext* CypherParser::booleanLiteral() { return _localctx; } -//----------------- ListLiteralContext ------------------------------------------------------------------ +//----------------- ListLiteralContext +//------------------------------------------------------------------ -CypherParser::ListLiteralContext::ListLiteralContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::ListLiteralContext::ListLiteralContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} std::vector<tree::TerminalNode *> CypherParser::ListLiteralContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::ListLiteralContext::SP(size_t i) { +tree::TerminalNode *CypherParser::ListLiteralContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -std::vector<CypherParser::ExpressionContext *> CypherParser::ListLiteralContext::expression() { +std::vector<CypherParser::ExpressionContext *> +CypherParser::ListLiteralContext::expression() { return getRuleContexts<CypherParser::ExpressionContext>(); } -CypherParser::ExpressionContext* CypherParser::ListLiteralContext::expression(size_t i) { +CypherParser::ExpressionContext *CypherParser::ListLiteralContext::expression( + size_t i) { return getRuleContext<CypherParser::ExpressionContext>(i); } - size_t CypherParser::ListLiteralContext::getRuleIndex() const { return CypherParser::RuleListLiteral; } -void CypherParser::ListLiteralContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::ListLiteralContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterListLiteral(this); + if (parserListener != nullptr) parserListener->enterListLiteral(this); } -void CypherParser::ListLiteralContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::ListLiteralContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitListLiteral(this); + if (parserListener != nullptr) parserListener->exitListLiteral(this); } - -antlrcpp::Any CypherParser::ListLiteralContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::ListLiteralContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitListLiteral(this); else return visitor->visitChildren(this); } -CypherParser::ListLiteralContext* CypherParser::listLiteral() { - ListLiteralContext *_localctx = _tracker.createInstance<ListLiteralContext>(_ctx, getState()); +CypherParser::ListLiteralContext *CypherParser::listLiteral() { + ListLiteralContext *_localctx = + _tracker.createInstance<ListLiteralContext>(_ctx, getState()); enterRule(_localctx, 114, CypherParser::RuleListLiteral); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(994); @@ -6738,65 +6717,65 @@ CypherParser::ListLiteralContext* CypherParser::listLiteral() { _errHandler->sync(this); _la = _input->LA(1); - if ((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::T__5) - | (1ULL << CypherParser::T__7) - | (1ULL << CypherParser::T__13) - | (1ULL << CypherParser::T__14) - | (1ULL << CypherParser::T__27) - | (1ULL << CypherParser::T__29) - | (1ULL << CypherParser::StringLiteral) - | (1ULL << CypherParser::HexInteger) - | (1ULL << CypherParser::DecimalInteger) - | (1ULL << CypherParser::OctalInteger) - | (1ULL << CypherParser::HexLetter) - | (1ULL << CypherParser::ExponentDecimalReal) - | (1ULL << CypherParser::RegularDecimalReal))) != 0) || ((((_la - 64) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 64)) & ((1ULL << (CypherParser::UNION - 64)) - | (1ULL << (CypherParser::ALL - 64)) - | (1ULL << (CypherParser::OPTIONAL - 64)) - | (1ULL << (CypherParser::MATCH - 64)) - | (1ULL << (CypherParser::UNWIND - 64)) - | (1ULL << (CypherParser::AS - 64)) - | (1ULL << (CypherParser::MERGE - 64)) - | (1ULL << (CypherParser::ON - 64)) - | (1ULL << (CypherParser::CREATE - 64)) - | (1ULL << (CypherParser::SET - 64)) - | (1ULL << (CypherParser::DETACH - 64)) - | (1ULL << (CypherParser::DELETE - 64)) - | (1ULL << (CypherParser::REMOVE - 64)) - | (1ULL << (CypherParser::WITH - 64)) - | (1ULL << (CypherParser::DISTINCT - 64)) - | (1ULL << (CypherParser::RETURN - 64)) - | (1ULL << (CypherParser::ORDER - 64)) - | (1ULL << (CypherParser::BY - 64)) - | (1ULL << (CypherParser::L_SKIP - 64)) - | (1ULL << (CypherParser::LIMIT - 64)) - | (1ULL << (CypherParser::ASCENDING - 64)) - | (1ULL << (CypherParser::ASC - 64)) - | (1ULL << (CypherParser::DESCENDING - 64)) - | (1ULL << (CypherParser::DESC - 64)) - | (1ULL << (CypherParser::WHERE - 64)) - | (1ULL << (CypherParser::OR - 64)) - | (1ULL << (CypherParser::XOR - 64)) - | (1ULL << (CypherParser::AND - 64)) - | (1ULL << (CypherParser::NOT - 64)) - | (1ULL << (CypherParser::IN - 64)) - | (1ULL << (CypherParser::STARTS - 64)) - | (1ULL << (CypherParser::ENDS - 64)) - | (1ULL << (CypherParser::CONTAINS - 64)) - | (1ULL << (CypherParser::IS - 64)) - | (1ULL << (CypherParser::CYPHERNULL - 64)) - | (1ULL << (CypherParser::COUNT - 64)) - | (1ULL << (CypherParser::FILTER - 64)) - | (1ULL << (CypherParser::EXTRACT - 64)) - | (1ULL << (CypherParser::ANY - 64)) - | (1ULL << (CypherParser::NONE - 64)) - | (1ULL << (CypherParser::SINGLE - 64)) - | (1ULL << (CypherParser::TRUE - 64)) - | (1ULL << (CypherParser::FALSE - 64)) - | (1ULL << (CypherParser::UnescapedSymbolicName - 64)) - | (1ULL << (CypherParser::EscapedSymbolicName - 64)))) != 0)) { + if ((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & + ((1ULL << CypherParser::T__5) | (1ULL << CypherParser::T__7) | + (1ULL << CypherParser::T__13) | (1ULL << CypherParser::T__14) | + (1ULL << CypherParser::T__27) | (1ULL << CypherParser::T__29) | + (1ULL << CypherParser::StringLiteral) | + (1ULL << CypherParser::HexInteger) | + (1ULL << CypherParser::DecimalInteger) | + (1ULL << CypherParser::OctalInteger) | + (1ULL << CypherParser::HexLetter) | + (1ULL << CypherParser::ExponentDecimalReal) | + (1ULL << CypherParser::RegularDecimalReal))) != 0) || + ((((_la - 64) & ~0x3fULL) == 0) && + ((1ULL << (_la - 64)) & + ((1ULL << (CypherParser::UNION - 64)) | + (1ULL << (CypherParser::ALL - 64)) | + (1ULL << (CypherParser::OPTIONAL - 64)) | + (1ULL << (CypherParser::MATCH - 64)) | + (1ULL << (CypherParser::UNWIND - 64)) | + (1ULL << (CypherParser::AS - 64)) | + (1ULL << (CypherParser::MERGE - 64)) | + (1ULL << (CypherParser::ON - 64)) | + (1ULL << (CypherParser::CREATE - 64)) | + (1ULL << (CypherParser::SET - 64)) | + (1ULL << (CypherParser::DETACH - 64)) | + (1ULL << (CypherParser::DELETE - 64)) | + (1ULL << (CypherParser::REMOVE - 64)) | + (1ULL << (CypherParser::WITH - 64)) | + (1ULL << (CypherParser::DISTINCT - 64)) | + (1ULL << (CypherParser::RETURN - 64)) | + (1ULL << (CypherParser::ORDER - 64)) | + (1ULL << (CypherParser::BY - 64)) | + (1ULL << (CypherParser::L_SKIP - 64)) | + (1ULL << (CypherParser::LIMIT - 64)) | + (1ULL << (CypherParser::ASCENDING - 64)) | + (1ULL << (CypherParser::ASC - 64)) | + (1ULL << (CypherParser::DESCENDING - 64)) | + (1ULL << (CypherParser::DESC - 64)) | + (1ULL << (CypherParser::WHERE - 64)) | + (1ULL << (CypherParser::OR - 64)) | + (1ULL << (CypherParser::XOR - 64)) | + (1ULL << (CypherParser::AND - 64)) | + (1ULL << (CypherParser::NOT - 64)) | + (1ULL << (CypherParser::IN - 64)) | + (1ULL << (CypherParser::STARTS - 64)) | + (1ULL << (CypherParser::ENDS - 64)) | + (1ULL << (CypherParser::CONTAINS - 64)) | + (1ULL << (CypherParser::IS - 64)) | + (1ULL << (CypherParser::CYPHERNULL - 64)) | + (1ULL << (CypherParser::COUNT - 64)) | + (1ULL << (CypherParser::FILTER - 64)) | + (1ULL << (CypherParser::EXTRACT - 64)) | + (1ULL << (CypherParser::ANY - 64)) | + (1ULL << (CypherParser::NONE - 64)) | + (1ULL << (CypherParser::SINGLE - 64)) | + (1ULL << (CypherParser::TRUE - 64)) | + (1ULL << (CypherParser::FALSE - 64)) | + (1ULL << (CypherParser::UnescapedSymbolicName - 64)) | + (1ULL << (CypherParser::EscapedSymbolicName - 64)))) != 0)) { setState(998); expression(); setState(1000); @@ -6838,9 +6817,8 @@ CypherParser::ListLiteralContext* CypherParser::listLiteral() { } setState(1017); match(CypherParser::T__9); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -6849,53 +6827,58 @@ CypherParser::ListLiteralContext* CypherParser::listLiteral() { return _localctx; } -//----------------- PartialComparisonExpressionContext ------------------------------------------------------------------ +//----------------- PartialComparisonExpressionContext +//------------------------------------------------------------------ -CypherParser::PartialComparisonExpressionContext::PartialComparisonExpressionContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::PartialComparisonExpressionContext:: + PartialComparisonExpressionContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::Expression7Context* CypherParser::PartialComparisonExpressionContext::expression7() { +CypherParser::Expression7Context * +CypherParser::PartialComparisonExpressionContext::expression7() { return getRuleContext<CypherParser::Expression7Context>(0); } -tree::TerminalNode* CypherParser::PartialComparisonExpressionContext::SP() { +tree::TerminalNode *CypherParser::PartialComparisonExpressionContext::SP() { return getToken(CypherParser::SP, 0); } - size_t CypherParser::PartialComparisonExpressionContext::getRuleIndex() const { return CypherParser::RulePartialComparisonExpression; } -void CypherParser::PartialComparisonExpressionContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::PartialComparisonExpressionContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); if (parserListener != nullptr) parserListener->enterPartialComparisonExpression(this); } -void CypherParser::PartialComparisonExpressionContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::PartialComparisonExpressionContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); if (parserListener != nullptr) parserListener->exitPartialComparisonExpression(this); } - -antlrcpp::Any CypherParser::PartialComparisonExpressionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::PartialComparisonExpressionContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitPartialComparisonExpression(this); else return visitor->visitChildren(this); } -CypherParser::PartialComparisonExpressionContext* CypherParser::partialComparisonExpression() { - PartialComparisonExpressionContext *_localctx = _tracker.createInstance<PartialComparisonExpressionContext>(_ctx, getState()); +CypherParser::PartialComparisonExpressionContext * +CypherParser::partialComparisonExpression() { + PartialComparisonExpressionContext *_localctx = + _tracker.createInstance<PartialComparisonExpressionContext>(_ctx, + getState()); enterRule(_localctx, 116, CypherParser::RulePartialComparisonExpression); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(1054); _errHandler->sync(this); @@ -7019,12 +7002,11 @@ CypherParser::PartialComparisonExpressionContext* CypherParser::partialCompariso break; } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7033,57 +7015,61 @@ CypherParser::PartialComparisonExpressionContext* CypherParser::partialCompariso return _localctx; } -//----------------- ParenthesizedExpressionContext ------------------------------------------------------------------ +//----------------- ParenthesizedExpressionContext +//------------------------------------------------------------------ -CypherParser::ParenthesizedExpressionContext::ParenthesizedExpressionContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::ParenthesizedExpressionContext::ParenthesizedExpressionContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::ExpressionContext* CypherParser::ParenthesizedExpressionContext::expression() { +CypherParser::ExpressionContext * +CypherParser::ParenthesizedExpressionContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } -std::vector<tree::TerminalNode *> CypherParser::ParenthesizedExpressionContext::SP() { +std::vector<tree::TerminalNode *> +CypherParser::ParenthesizedExpressionContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::ParenthesizedExpressionContext::SP(size_t i) { +tree::TerminalNode *CypherParser::ParenthesizedExpressionContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::ParenthesizedExpressionContext::getRuleIndex() const { return CypherParser::RuleParenthesizedExpression; } -void CypherParser::ParenthesizedExpressionContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::ParenthesizedExpressionContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); if (parserListener != nullptr) parserListener->enterParenthesizedExpression(this); } -void CypherParser::ParenthesizedExpressionContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::ParenthesizedExpressionContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); if (parserListener != nullptr) parserListener->exitParenthesizedExpression(this); } - -antlrcpp::Any CypherParser::ParenthesizedExpressionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::ParenthesizedExpressionContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitParenthesizedExpression(this); else return visitor->visitChildren(this); } -CypherParser::ParenthesizedExpressionContext* CypherParser::parenthesizedExpression() { - ParenthesizedExpressionContext *_localctx = _tracker.createInstance<ParenthesizedExpressionContext>(_ctx, getState()); +CypherParser::ParenthesizedExpressionContext * +CypherParser::parenthesizedExpression() { + ParenthesizedExpressionContext *_localctx = + _tracker.createInstance<ParenthesizedExpressionContext>(_ctx, getState()); enterRule(_localctx, 118, CypherParser::RuleParenthesizedExpression); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1056); @@ -7108,9 +7094,8 @@ CypherParser::ParenthesizedExpressionContext* CypherParser::parenthesizedExpress } setState(1064); match(CypherParser::T__6); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7119,99 +7104,104 @@ CypherParser::ParenthesizedExpressionContext* CypherParser::parenthesizedExpress return _localctx; } -//----------------- RelationshipsPatternContext ------------------------------------------------------------------ +//----------------- RelationshipsPatternContext +//------------------------------------------------------------------ -CypherParser::RelationshipsPatternContext::RelationshipsPatternContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::RelationshipsPatternContext::RelationshipsPatternContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::NodePatternContext* CypherParser::RelationshipsPatternContext::nodePattern() { +CypherParser::NodePatternContext * +CypherParser::RelationshipsPatternContext::nodePattern() { return getRuleContext<CypherParser::NodePatternContext>(0); } -std::vector<CypherParser::PatternElementChainContext *> CypherParser::RelationshipsPatternContext::patternElementChain() { +std::vector<CypherParser::PatternElementChainContext *> +CypherParser::RelationshipsPatternContext::patternElementChain() { return getRuleContexts<CypherParser::PatternElementChainContext>(); } -CypherParser::PatternElementChainContext* CypherParser::RelationshipsPatternContext::patternElementChain(size_t i) { +CypherParser::PatternElementChainContext * +CypherParser::RelationshipsPatternContext::patternElementChain(size_t i) { return getRuleContext<CypherParser::PatternElementChainContext>(i); } -std::vector<tree::TerminalNode *> CypherParser::RelationshipsPatternContext::SP() { +std::vector<tree::TerminalNode *> +CypherParser::RelationshipsPatternContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::RelationshipsPatternContext::SP(size_t i) { +tree::TerminalNode *CypherParser::RelationshipsPatternContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::RelationshipsPatternContext::getRuleIndex() const { return CypherParser::RuleRelationshipsPattern; } -void CypherParser::RelationshipsPatternContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::RelationshipsPatternContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); if (parserListener != nullptr) parserListener->enterRelationshipsPattern(this); } -void CypherParser::RelationshipsPatternContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::RelationshipsPatternContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRelationshipsPattern(this); + if (parserListener != nullptr) parserListener->exitRelationshipsPattern(this); } - -antlrcpp::Any CypherParser::RelationshipsPatternContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RelationshipsPatternContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRelationshipsPattern(this); else return visitor->visitChildren(this); } -CypherParser::RelationshipsPatternContext* CypherParser::relationshipsPattern() { - RelationshipsPatternContext *_localctx = _tracker.createInstance<RelationshipsPatternContext>(_ctx, getState()); +CypherParser::RelationshipsPatternContext * +CypherParser::relationshipsPattern() { + RelationshipsPatternContext *_localctx = + _tracker.createInstance<RelationshipsPatternContext>(_ctx, getState()); enterRule(_localctx, 120, CypherParser::RuleRelationshipsPattern); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); setState(1066); nodePattern(); - setState(1071); + setState(1071); _errHandler->sync(this); alt = 1; do { switch (alt) { case 1: { - setState(1068); - _errHandler->sync(this); + setState(1068); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(1067); - match(CypherParser::SP); - } - setState(1070); - patternElementChain(); - break; - } + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(1067); + match(CypherParser::SP); + } + setState(1070); + patternElementChain(); + break; + } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - setState(1073); + setState(1073); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 185, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 185, _ctx); } while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7220,57 +7210,57 @@ CypherParser::RelationshipsPatternContext* CypherParser::relationshipsPattern() return _localctx; } -//----------------- FilterExpressionContext ------------------------------------------------------------------ +//----------------- FilterExpressionContext +//------------------------------------------------------------------ -CypherParser::FilterExpressionContext::FilterExpressionContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::FilterExpressionContext::FilterExpressionContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::IdInCollContext* CypherParser::FilterExpressionContext::idInColl() { +CypherParser::IdInCollContext * +CypherParser::FilterExpressionContext::idInColl() { return getRuleContext<CypherParser::IdInCollContext>(0); } -CypherParser::WhereContext* CypherParser::FilterExpressionContext::where() { +CypherParser::WhereContext *CypherParser::FilterExpressionContext::where() { return getRuleContext<CypherParser::WhereContext>(0); } -tree::TerminalNode* CypherParser::FilterExpressionContext::SP() { +tree::TerminalNode *CypherParser::FilterExpressionContext::SP() { return getToken(CypherParser::SP, 0); } - size_t CypherParser::FilterExpressionContext::getRuleIndex() const { return CypherParser::RuleFilterExpression; } -void CypherParser::FilterExpressionContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::FilterExpressionContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterFilterExpression(this); + if (parserListener != nullptr) parserListener->enterFilterExpression(this); } -void CypherParser::FilterExpressionContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::FilterExpressionContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitFilterExpression(this); + if (parserListener != nullptr) parserListener->exitFilterExpression(this); } - -antlrcpp::Any CypherParser::FilterExpressionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::FilterExpressionContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitFilterExpression(this); else return visitor->visitChildren(this); } -CypherParser::FilterExpressionContext* CypherParser::filterExpression() { - FilterExpressionContext *_localctx = _tracker.createInstance<FilterExpressionContext>(_ctx, getState()); +CypherParser::FilterExpressionContext *CypherParser::filterExpression() { + FilterExpressionContext *_localctx = + _tracker.createInstance<FilterExpressionContext>(_ctx, getState()); enterRule(_localctx, 122, CypherParser::RuleFilterExpression); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1075); @@ -7278,25 +7268,24 @@ CypherParser::FilterExpressionContext* CypherParser::filterExpression() { setState(1080); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 187, _ctx)) { - case 1: { - setState(1077); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 187, _ctx)) { + case 1: { + setState(1077); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(1076); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(1076); + match(CypherParser::SP); + } + setState(1079); + where(); + break; } - setState(1079); - where(); - break; } - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7305,13 +7294,14 @@ CypherParser::FilterExpressionContext* CypherParser::filterExpression() { return _localctx; } -//----------------- IdInCollContext ------------------------------------------------------------------ +//----------------- IdInCollContext +//------------------------------------------------------------------ -CypherParser::IdInCollContext::IdInCollContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::IdInCollContext::IdInCollContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::VariableContext* CypherParser::IdInCollContext::variable() { +CypherParser::VariableContext *CypherParser::IdInCollContext::variable() { return getRuleContext<CypherParser::VariableContext>(0); } @@ -7319,50 +7309,48 @@ std::vector<tree::TerminalNode *> CypherParser::IdInCollContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::IdInCollContext::SP(size_t i) { +tree::TerminalNode *CypherParser::IdInCollContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -tree::TerminalNode* CypherParser::IdInCollContext::IN() { +tree::TerminalNode *CypherParser::IdInCollContext::IN() { return getToken(CypherParser::IN, 0); } -CypherParser::ExpressionContext* CypherParser::IdInCollContext::expression() { +CypherParser::ExpressionContext *CypherParser::IdInCollContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } - size_t CypherParser::IdInCollContext::getRuleIndex() const { return CypherParser::RuleIdInColl; } -void CypherParser::IdInCollContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::IdInCollContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterIdInColl(this); + if (parserListener != nullptr) parserListener->enterIdInColl(this); } -void CypherParser::IdInCollContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::IdInCollContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitIdInColl(this); + if (parserListener != nullptr) parserListener->exitIdInColl(this); } - -antlrcpp::Any CypherParser::IdInCollContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::IdInCollContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitIdInColl(this); else return visitor->visitChildren(this); } -CypherParser::IdInCollContext* CypherParser::idInColl() { - IdInCollContext *_localctx = _tracker.createInstance<IdInCollContext>(_ctx, getState()); +CypherParser::IdInCollContext *CypherParser::idInColl() { + IdInCollContext *_localctx = + _tracker.createInstance<IdInCollContext>(_ctx, getState()); enterRule(_localctx, 124, CypherParser::RuleIdInColl); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1082); @@ -7375,9 +7363,8 @@ CypherParser::IdInCollContext* CypherParser::idInColl() { match(CypherParser::SP); setState(1086); expression(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7386,69 +7373,72 @@ CypherParser::IdInCollContext* CypherParser::idInColl() { return _localctx; } -//----------------- FunctionInvocationContext ------------------------------------------------------------------ +//----------------- FunctionInvocationContext +//------------------------------------------------------------------ -CypherParser::FunctionInvocationContext::FunctionInvocationContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::FunctionInvocationContext::FunctionInvocationContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::FunctionNameContext* CypherParser::FunctionInvocationContext::functionName() { +CypherParser::FunctionNameContext * +CypherParser::FunctionInvocationContext::functionName() { return getRuleContext<CypherParser::FunctionNameContext>(0); } -std::vector<tree::TerminalNode *> CypherParser::FunctionInvocationContext::SP() { +std::vector<tree::TerminalNode *> +CypherParser::FunctionInvocationContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::FunctionInvocationContext::SP(size_t i) { +tree::TerminalNode *CypherParser::FunctionInvocationContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -tree::TerminalNode* CypherParser::FunctionInvocationContext::DISTINCT() { +tree::TerminalNode *CypherParser::FunctionInvocationContext::DISTINCT() { return getToken(CypherParser::DISTINCT, 0); } -std::vector<CypherParser::ExpressionContext *> CypherParser::FunctionInvocationContext::expression() { +std::vector<CypherParser::ExpressionContext *> +CypherParser::FunctionInvocationContext::expression() { return getRuleContexts<CypherParser::ExpressionContext>(); } -CypherParser::ExpressionContext* CypherParser::FunctionInvocationContext::expression(size_t i) { +CypherParser::ExpressionContext * +CypherParser::FunctionInvocationContext::expression(size_t i) { return getRuleContext<CypherParser::ExpressionContext>(i); } - size_t CypherParser::FunctionInvocationContext::getRuleIndex() const { return CypherParser::RuleFunctionInvocation; } -void CypherParser::FunctionInvocationContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::FunctionInvocationContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterFunctionInvocation(this); + if (parserListener != nullptr) parserListener->enterFunctionInvocation(this); } -void CypherParser::FunctionInvocationContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::FunctionInvocationContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitFunctionInvocation(this); + if (parserListener != nullptr) parserListener->exitFunctionInvocation(this); } - -antlrcpp::Any CypherParser::FunctionInvocationContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::FunctionInvocationContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitFunctionInvocation(this); else return visitor->visitChildren(this); } -CypherParser::FunctionInvocationContext* CypherParser::functionInvocation() { - FunctionInvocationContext *_localctx = _tracker.createInstance<FunctionInvocationContext>(_ctx, getState()); +CypherParser::FunctionInvocationContext *CypherParser::functionInvocation() { + FunctionInvocationContext *_localctx = + _tracker.createInstance<FunctionInvocationContext>(_ctx, getState()); enterRule(_localctx, 126, CypherParser::RuleFunctionInvocation); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1088); @@ -7474,85 +7464,85 @@ CypherParser::FunctionInvocationContext* CypherParser::functionInvocation() { setState(1100); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 191, _ctx)) { - case 1: { - setState(1096); - match(CypherParser::DISTINCT); - setState(1098); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 191, _ctx)) { + case 1: { + setState(1096); + match(CypherParser::DISTINCT); + setState(1098); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(1097); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(1097); + match(CypherParser::SP); + } + break; } - break; - } - } setState(1119); _errHandler->sync(this); _la = _input->LA(1); - if ((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::T__5) - | (1ULL << CypherParser::T__7) - | (1ULL << CypherParser::T__13) - | (1ULL << CypherParser::T__14) - | (1ULL << CypherParser::T__27) - | (1ULL << CypherParser::T__29) - | (1ULL << CypherParser::StringLiteral) - | (1ULL << CypherParser::HexInteger) - | (1ULL << CypherParser::DecimalInteger) - | (1ULL << CypherParser::OctalInteger) - | (1ULL << CypherParser::HexLetter) - | (1ULL << CypherParser::ExponentDecimalReal) - | (1ULL << CypherParser::RegularDecimalReal))) != 0) || ((((_la - 64) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 64)) & ((1ULL << (CypherParser::UNION - 64)) - | (1ULL << (CypherParser::ALL - 64)) - | (1ULL << (CypherParser::OPTIONAL - 64)) - | (1ULL << (CypherParser::MATCH - 64)) - | (1ULL << (CypherParser::UNWIND - 64)) - | (1ULL << (CypherParser::AS - 64)) - | (1ULL << (CypherParser::MERGE - 64)) - | (1ULL << (CypherParser::ON - 64)) - | (1ULL << (CypherParser::CREATE - 64)) - | (1ULL << (CypherParser::SET - 64)) - | (1ULL << (CypherParser::DETACH - 64)) - | (1ULL << (CypherParser::DELETE - 64)) - | (1ULL << (CypherParser::REMOVE - 64)) - | (1ULL << (CypherParser::WITH - 64)) - | (1ULL << (CypherParser::DISTINCT - 64)) - | (1ULL << (CypherParser::RETURN - 64)) - | (1ULL << (CypherParser::ORDER - 64)) - | (1ULL << (CypherParser::BY - 64)) - | (1ULL << (CypherParser::L_SKIP - 64)) - | (1ULL << (CypherParser::LIMIT - 64)) - | (1ULL << (CypherParser::ASCENDING - 64)) - | (1ULL << (CypherParser::ASC - 64)) - | (1ULL << (CypherParser::DESCENDING - 64)) - | (1ULL << (CypherParser::DESC - 64)) - | (1ULL << (CypherParser::WHERE - 64)) - | (1ULL << (CypherParser::OR - 64)) - | (1ULL << (CypherParser::XOR - 64)) - | (1ULL << (CypherParser::AND - 64)) - | (1ULL << (CypherParser::NOT - 64)) - | (1ULL << (CypherParser::IN - 64)) - | (1ULL << (CypherParser::STARTS - 64)) - | (1ULL << (CypherParser::ENDS - 64)) - | (1ULL << (CypherParser::CONTAINS - 64)) - | (1ULL << (CypherParser::IS - 64)) - | (1ULL << (CypherParser::CYPHERNULL - 64)) - | (1ULL << (CypherParser::COUNT - 64)) - | (1ULL << (CypherParser::FILTER - 64)) - | (1ULL << (CypherParser::EXTRACT - 64)) - | (1ULL << (CypherParser::ANY - 64)) - | (1ULL << (CypherParser::NONE - 64)) - | (1ULL << (CypherParser::SINGLE - 64)) - | (1ULL << (CypherParser::TRUE - 64)) - | (1ULL << (CypherParser::FALSE - 64)) - | (1ULL << (CypherParser::UnescapedSymbolicName - 64)) - | (1ULL << (CypherParser::EscapedSymbolicName - 64)))) != 0)) { + if ((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & + ((1ULL << CypherParser::T__5) | (1ULL << CypherParser::T__7) | + (1ULL << CypherParser::T__13) | (1ULL << CypherParser::T__14) | + (1ULL << CypherParser::T__27) | (1ULL << CypherParser::T__29) | + (1ULL << CypherParser::StringLiteral) | + (1ULL << CypherParser::HexInteger) | + (1ULL << CypherParser::DecimalInteger) | + (1ULL << CypherParser::OctalInteger) | + (1ULL << CypherParser::HexLetter) | + (1ULL << CypherParser::ExponentDecimalReal) | + (1ULL << CypherParser::RegularDecimalReal))) != 0) || + ((((_la - 64) & ~0x3fULL) == 0) && + ((1ULL << (_la - 64)) & + ((1ULL << (CypherParser::UNION - 64)) | + (1ULL << (CypherParser::ALL - 64)) | + (1ULL << (CypherParser::OPTIONAL - 64)) | + (1ULL << (CypherParser::MATCH - 64)) | + (1ULL << (CypherParser::UNWIND - 64)) | + (1ULL << (CypherParser::AS - 64)) | + (1ULL << (CypherParser::MERGE - 64)) | + (1ULL << (CypherParser::ON - 64)) | + (1ULL << (CypherParser::CREATE - 64)) | + (1ULL << (CypherParser::SET - 64)) | + (1ULL << (CypherParser::DETACH - 64)) | + (1ULL << (CypherParser::DELETE - 64)) | + (1ULL << (CypherParser::REMOVE - 64)) | + (1ULL << (CypherParser::WITH - 64)) | + (1ULL << (CypherParser::DISTINCT - 64)) | + (1ULL << (CypherParser::RETURN - 64)) | + (1ULL << (CypherParser::ORDER - 64)) | + (1ULL << (CypherParser::BY - 64)) | + (1ULL << (CypherParser::L_SKIP - 64)) | + (1ULL << (CypherParser::LIMIT - 64)) | + (1ULL << (CypherParser::ASCENDING - 64)) | + (1ULL << (CypherParser::ASC - 64)) | + (1ULL << (CypherParser::DESCENDING - 64)) | + (1ULL << (CypherParser::DESC - 64)) | + (1ULL << (CypherParser::WHERE - 64)) | + (1ULL << (CypherParser::OR - 64)) | + (1ULL << (CypherParser::XOR - 64)) | + (1ULL << (CypherParser::AND - 64)) | + (1ULL << (CypherParser::NOT - 64)) | + (1ULL << (CypherParser::IN - 64)) | + (1ULL << (CypherParser::STARTS - 64)) | + (1ULL << (CypherParser::ENDS - 64)) | + (1ULL << (CypherParser::CONTAINS - 64)) | + (1ULL << (CypherParser::IS - 64)) | + (1ULL << (CypherParser::CYPHERNULL - 64)) | + (1ULL << (CypherParser::COUNT - 64)) | + (1ULL << (CypherParser::FILTER - 64)) | + (1ULL << (CypherParser::EXTRACT - 64)) | + (1ULL << (CypherParser::ANY - 64)) | + (1ULL << (CypherParser::NONE - 64)) | + (1ULL << (CypherParser::SINGLE - 64)) | + (1ULL << (CypherParser::TRUE - 64)) | + (1ULL << (CypherParser::FALSE - 64)) | + (1ULL << (CypherParser::UnescapedSymbolicName - 64)) | + (1ULL << (CypherParser::EscapedSymbolicName - 64)))) != 0)) { setState(1102); expression(); setState(1104); @@ -7594,9 +7584,8 @@ CypherParser::FunctionInvocationContext* CypherParser::functionInvocation() { } setState(1121); match(CypherParser::T__6); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7605,74 +7594,72 @@ CypherParser::FunctionInvocationContext* CypherParser::functionInvocation() { return _localctx; } -//----------------- FunctionNameContext ------------------------------------------------------------------ +//----------------- FunctionNameContext +//------------------------------------------------------------------ -CypherParser::FunctionNameContext::FunctionNameContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::FunctionNameContext::FunctionNameContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::FunctionNameContext::UnescapedSymbolicName() { +tree::TerminalNode *CypherParser::FunctionNameContext::UnescapedSymbolicName() { return getToken(CypherParser::UnescapedSymbolicName, 0); } -tree::TerminalNode* CypherParser::FunctionNameContext::EscapedSymbolicName() { +tree::TerminalNode *CypherParser::FunctionNameContext::EscapedSymbolicName() { return getToken(CypherParser::EscapedSymbolicName, 0); } -tree::TerminalNode* CypherParser::FunctionNameContext::COUNT() { +tree::TerminalNode *CypherParser::FunctionNameContext::COUNT() { return getToken(CypherParser::COUNT, 0); } - size_t CypherParser::FunctionNameContext::getRuleIndex() const { return CypherParser::RuleFunctionName; } -void CypherParser::FunctionNameContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::FunctionNameContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterFunctionName(this); + if (parserListener != nullptr) parserListener->enterFunctionName(this); } -void CypherParser::FunctionNameContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::FunctionNameContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitFunctionName(this); + if (parserListener != nullptr) parserListener->exitFunctionName(this); } - -antlrcpp::Any CypherParser::FunctionNameContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::FunctionNameContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitFunctionName(this); else return visitor->visitChildren(this); } -CypherParser::FunctionNameContext* CypherParser::functionName() { - FunctionNameContext *_localctx = _tracker.createInstance<FunctionNameContext>(_ctx, getState()); +CypherParser::FunctionNameContext *CypherParser::functionName() { + FunctionNameContext *_localctx = + _tracker.createInstance<FunctionNameContext>(_ctx, getState()); enterRule(_localctx, 128, CypherParser::RuleFunctionName); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1123); _la = _input->LA(1); - if (!(((((_la - 99) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 99)) & ((1ULL << (CypherParser::COUNT - 99)) - | (1ULL << (CypherParser::UnescapedSymbolicName - 99)) - | (1ULL << (CypherParser::EscapedSymbolicName - 99)))) != 0))) { - _errHandler->recoverInline(this); - } - else { + if (!(((((_la - 99) & ~0x3fULL) == 0) && + ((1ULL << (_la - 99)) & + ((1ULL << (CypherParser::COUNT - 99)) | + (1ULL << (CypherParser::UnescapedSymbolicName - 99)) | + (1ULL << (CypherParser::EscapedSymbolicName - 99)))) != 0))) { + _errHandler->recoverInline(this); + } else { _errHandler->reportMatch(this); consume(); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7681,13 +7668,15 @@ CypherParser::FunctionNameContext* CypherParser::functionName() { return _localctx; } -//----------------- ListComprehensionContext ------------------------------------------------------------------ +//----------------- ListComprehensionContext +//------------------------------------------------------------------ -CypherParser::ListComprehensionContext::ListComprehensionContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::ListComprehensionContext::ListComprehensionContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::FilterExpressionContext* CypherParser::ListComprehensionContext::filterExpression() { +CypherParser::FilterExpressionContext * +CypherParser::ListComprehensionContext::filterExpression() { return getRuleContext<CypherParser::FilterExpressionContext>(0); } @@ -7695,47 +7684,46 @@ std::vector<tree::TerminalNode *> CypherParser::ListComprehensionContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::ListComprehensionContext::SP(size_t i) { +tree::TerminalNode *CypherParser::ListComprehensionContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -CypherParser::ExpressionContext* CypherParser::ListComprehensionContext::expression() { +CypherParser::ExpressionContext * +CypherParser::ListComprehensionContext::expression() { return getRuleContext<CypherParser::ExpressionContext>(0); } - size_t CypherParser::ListComprehensionContext::getRuleIndex() const { return CypherParser::RuleListComprehension; } -void CypherParser::ListComprehensionContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::ListComprehensionContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterListComprehension(this); + if (parserListener != nullptr) parserListener->enterListComprehension(this); } -void CypherParser::ListComprehensionContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::ListComprehensionContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitListComprehension(this); + if (parserListener != nullptr) parserListener->exitListComprehension(this); } - -antlrcpp::Any CypherParser::ListComprehensionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::ListComprehensionContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitListComprehension(this); else return visitor->visitChildren(this); } -CypherParser::ListComprehensionContext* CypherParser::listComprehension() { - ListComprehensionContext *_localctx = _tracker.createInstance<ListComprehensionContext>(_ctx, getState()); +CypherParser::ListComprehensionContext *CypherParser::listComprehension() { + ListComprehensionContext *_localctx = + _tracker.createInstance<ListComprehensionContext>(_ctx, getState()); enterRule(_localctx, 130, CypherParser::RuleListComprehension); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1125); @@ -7753,31 +7741,31 @@ CypherParser::ListComprehensionContext* CypherParser::listComprehension() { setState(1138); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 200, _ctx)) { - case 1: { - setState(1131); - _errHandler->sync(this); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 200, _ctx)) { + case 1: { + setState(1131); + _errHandler->sync(this); - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(1130); - match(CypherParser::SP); + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(1130); + match(CypherParser::SP); + } + setState(1133); + match(CypherParser::T__11); + setState(1135); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == CypherParser::SP) { + setState(1134); + match(CypherParser::SP); + } + setState(1137); + expression(); + break; } - setState(1133); - match(CypherParser::T__11); - setState(1135); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == CypherParser::SP) { - setState(1134); - match(CypherParser::SP); - } - setState(1137); - expression(); - break; - } - } setState(1141); _errHandler->sync(this); @@ -7789,9 +7777,8 @@ CypherParser::ListComprehensionContext* CypherParser::listComprehension() { } setState(1143); match(CypherParser::T__9); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7800,13 +7787,15 @@ CypherParser::ListComprehensionContext* CypherParser::listComprehension() { return _localctx; } -//----------------- PropertyLookupContext ------------------------------------------------------------------ +//----------------- PropertyLookupContext +//------------------------------------------------------------------ -CypherParser::PropertyLookupContext::PropertyLookupContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::PropertyLookupContext::PropertyLookupContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::PropertyKeyNameContext* CypherParser::PropertyLookupContext::propertyKeyName() { +CypherParser::PropertyKeyNameContext * +CypherParser::PropertyLookupContext::propertyKeyName() { return getRuleContext<CypherParser::PropertyKeyNameContext>(0); } @@ -7814,43 +7803,41 @@ std::vector<tree::TerminalNode *> CypherParser::PropertyLookupContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::PropertyLookupContext::SP(size_t i) { +tree::TerminalNode *CypherParser::PropertyLookupContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::PropertyLookupContext::getRuleIndex() const { return CypherParser::RulePropertyLookup; } -void CypherParser::PropertyLookupContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::PropertyLookupContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterPropertyLookup(this); + if (parserListener != nullptr) parserListener->enterPropertyLookup(this); } -void CypherParser::PropertyLookupContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::PropertyLookupContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitPropertyLookup(this); + if (parserListener != nullptr) parserListener->exitPropertyLookup(this); } - -antlrcpp::Any CypherParser::PropertyLookupContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::PropertyLookupContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitPropertyLookup(this); else return visitor->visitChildren(this); } -CypherParser::PropertyLookupContext* CypherParser::propertyLookup() { - PropertyLookupContext *_localctx = _tracker.createInstance<PropertyLookupContext>(_ctx, getState()); +CypherParser::PropertyLookupContext *CypherParser::propertyLookup() { + PropertyLookupContext *_localctx = + _tracker.createInstance<PropertyLookupContext>(_ctx, getState()); enterRule(_localctx, 132, CypherParser::RulePropertyLookup); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1146); @@ -7873,34 +7860,32 @@ CypherParser::PropertyLookupContext* CypherParser::propertyLookup() { } setState(1156); _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 204, _ctx)) { - case 1: { - setState(1152); - propertyKeyName(); - setState(1153); - _la = _input->LA(1); - if (!(_la == CypherParser::T__8 + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 204, _ctx)) { + case 1: { + setState(1152); + propertyKeyName(); + setState(1153); + _la = _input->LA(1); + if (!(_la == CypherParser::T__8 - || _la == CypherParser::T__26)) { - _errHandler->recoverInline(this); + || _la == CypherParser::T__26)) { + _errHandler->recoverInline(this); + } else { + _errHandler->reportMatch(this); + consume(); + } + break; } - else { - _errHandler->reportMatch(this); - consume(); + + case 2: { + setState(1155); + propertyKeyName(); + break; } - break; } - case 2: { - setState(1155); - propertyKeyName(); - break; - } - - } - - } - catch (RecognitionException &e) { + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7909,55 +7894,54 @@ CypherParser::PropertyLookupContext* CypherParser::propertyLookup() { return _localctx; } -//----------------- VariableContext ------------------------------------------------------------------ +//----------------- VariableContext +//------------------------------------------------------------------ -CypherParser::VariableContext::VariableContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::VariableContext::VariableContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::SymbolicNameContext* CypherParser::VariableContext::symbolicName() { +CypherParser::SymbolicNameContext * +CypherParser::VariableContext::symbolicName() { return getRuleContext<CypherParser::SymbolicNameContext>(0); } - size_t CypherParser::VariableContext::getRuleIndex() const { return CypherParser::RuleVariable; } -void CypherParser::VariableContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::VariableContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterVariable(this); + if (parserListener != nullptr) parserListener->enterVariable(this); } -void CypherParser::VariableContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::VariableContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitVariable(this); + if (parserListener != nullptr) parserListener->exitVariable(this); } - -antlrcpp::Any CypherParser::VariableContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::VariableContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitVariable(this); else return visitor->visitChildren(this); } -CypherParser::VariableContext* CypherParser::variable() { - VariableContext *_localctx = _tracker.createInstance<VariableContext>(_ctx, getState()); +CypherParser::VariableContext *CypherParser::variable() { + VariableContext *_localctx = + _tracker.createInstance<VariableContext>(_ctx, getState()); enterRule(_localctx, 134, CypherParser::RuleVariable); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1158); symbolicName(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -7966,52 +7950,53 @@ CypherParser::VariableContext* CypherParser::variable() { return _localctx; } -//----------------- NumberLiteralContext ------------------------------------------------------------------ +//----------------- NumberLiteralContext +//------------------------------------------------------------------ -CypherParser::NumberLiteralContext::NumberLiteralContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::NumberLiteralContext::NumberLiteralContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::DoubleLiteralContext* CypherParser::NumberLiteralContext::doubleLiteral() { +CypherParser::DoubleLiteralContext * +CypherParser::NumberLiteralContext::doubleLiteral() { return getRuleContext<CypherParser::DoubleLiteralContext>(0); } -CypherParser::IntegerLiteralContext* CypherParser::NumberLiteralContext::integerLiteral() { +CypherParser::IntegerLiteralContext * +CypherParser::NumberLiteralContext::integerLiteral() { return getRuleContext<CypherParser::IntegerLiteralContext>(0); } - size_t CypherParser::NumberLiteralContext::getRuleIndex() const { return CypherParser::RuleNumberLiteral; } -void CypherParser::NumberLiteralContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::NumberLiteralContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterNumberLiteral(this); + if (parserListener != nullptr) parserListener->enterNumberLiteral(this); } -void CypherParser::NumberLiteralContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::NumberLiteralContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitNumberLiteral(this); + if (parserListener != nullptr) parserListener->exitNumberLiteral(this); } - -antlrcpp::Any CypherParser::NumberLiteralContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::NumberLiteralContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitNumberLiteral(this); else return visitor->visitChildren(this); } -CypherParser::NumberLiteralContext* CypherParser::numberLiteral() { - NumberLiteralContext *_localctx = _tracker.createInstance<NumberLiteralContext>(_ctx, getState()); +CypherParser::NumberLiteralContext *CypherParser::numberLiteral() { + NumberLiteralContext *_localctx = + _tracker.createInstance<NumberLiteralContext>(_ctx, getState()); enterRule(_localctx, 136, CypherParser::RuleNumberLiteral); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { setState(1162); _errHandler->sync(this); @@ -8033,12 +8018,11 @@ CypherParser::NumberLiteralContext* CypherParser::numberLiteral() { break; } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -8047,69 +8031,72 @@ CypherParser::NumberLiteralContext* CypherParser::numberLiteral() { return _localctx; } -//----------------- MapLiteralContext ------------------------------------------------------------------ +//----------------- MapLiteralContext +//------------------------------------------------------------------ -CypherParser::MapLiteralContext::MapLiteralContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::MapLiteralContext::MapLiteralContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} std::vector<tree::TerminalNode *> CypherParser::MapLiteralContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::MapLiteralContext::SP(size_t i) { +tree::TerminalNode *CypherParser::MapLiteralContext::SP(size_t i) { return getToken(CypherParser::SP, i); } -std::vector<CypherParser::PropertyKeyNameContext *> CypherParser::MapLiteralContext::propertyKeyName() { +std::vector<CypherParser::PropertyKeyNameContext *> +CypherParser::MapLiteralContext::propertyKeyName() { return getRuleContexts<CypherParser::PropertyKeyNameContext>(); } -CypherParser::PropertyKeyNameContext* CypherParser::MapLiteralContext::propertyKeyName(size_t i) { +CypherParser::PropertyKeyNameContext * +CypherParser::MapLiteralContext::propertyKeyName(size_t i) { return getRuleContext<CypherParser::PropertyKeyNameContext>(i); } -std::vector<CypherParser::ExpressionContext *> CypherParser::MapLiteralContext::expression() { +std::vector<CypherParser::ExpressionContext *> +CypherParser::MapLiteralContext::expression() { return getRuleContexts<CypherParser::ExpressionContext>(); } -CypherParser::ExpressionContext* CypherParser::MapLiteralContext::expression(size_t i) { +CypherParser::ExpressionContext *CypherParser::MapLiteralContext::expression( + size_t i) { return getRuleContext<CypherParser::ExpressionContext>(i); } - size_t CypherParser::MapLiteralContext::getRuleIndex() const { return CypherParser::RuleMapLiteral; } -void CypherParser::MapLiteralContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::MapLiteralContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterMapLiteral(this); + if (parserListener != nullptr) parserListener->enterMapLiteral(this); } -void CypherParser::MapLiteralContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::MapLiteralContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitMapLiteral(this); + if (parserListener != nullptr) parserListener->exitMapLiteral(this); } - -antlrcpp::Any CypherParser::MapLiteralContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::MapLiteralContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitMapLiteral(this); else return visitor->visitChildren(this); } -CypherParser::MapLiteralContext* CypherParser::mapLiteral() { - MapLiteralContext *_localctx = _tracker.createInstance<MapLiteralContext>(_ctx, getState()); +CypherParser::MapLiteralContext *CypherParser::mapLiteral() { + MapLiteralContext *_localctx = + _tracker.createInstance<MapLiteralContext>(_ctx, getState()); enterRule(_localctx, 138, CypherParser::RuleMapLiteral); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1164); @@ -8126,53 +8113,54 @@ CypherParser::MapLiteralContext* CypherParser::mapLiteral() { _errHandler->sync(this); _la = _input->LA(1); - if (((((_la - 55) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 55)) & ((1ULL << (CypherParser::HexLetter - 55)) - | (1ULL << (CypherParser::UNION - 55)) - | (1ULL << (CypherParser::ALL - 55)) - | (1ULL << (CypherParser::OPTIONAL - 55)) - | (1ULL << (CypherParser::MATCH - 55)) - | (1ULL << (CypherParser::UNWIND - 55)) - | (1ULL << (CypherParser::AS - 55)) - | (1ULL << (CypherParser::MERGE - 55)) - | (1ULL << (CypherParser::ON - 55)) - | (1ULL << (CypherParser::CREATE - 55)) - | (1ULL << (CypherParser::SET - 55)) - | (1ULL << (CypherParser::DETACH - 55)) - | (1ULL << (CypherParser::DELETE - 55)) - | (1ULL << (CypherParser::REMOVE - 55)) - | (1ULL << (CypherParser::WITH - 55)) - | (1ULL << (CypherParser::DISTINCT - 55)) - | (1ULL << (CypherParser::RETURN - 55)) - | (1ULL << (CypherParser::ORDER - 55)) - | (1ULL << (CypherParser::BY - 55)) - | (1ULL << (CypherParser::L_SKIP - 55)) - | (1ULL << (CypherParser::LIMIT - 55)) - | (1ULL << (CypherParser::ASCENDING - 55)) - | (1ULL << (CypherParser::ASC - 55)) - | (1ULL << (CypherParser::DESCENDING - 55)) - | (1ULL << (CypherParser::DESC - 55)) - | (1ULL << (CypherParser::WHERE - 55)) - | (1ULL << (CypherParser::OR - 55)) - | (1ULL << (CypherParser::XOR - 55)) - | (1ULL << (CypherParser::AND - 55)) - | (1ULL << (CypherParser::NOT - 55)) - | (1ULL << (CypherParser::IN - 55)) - | (1ULL << (CypherParser::STARTS - 55)) - | (1ULL << (CypherParser::ENDS - 55)) - | (1ULL << (CypherParser::CONTAINS - 55)) - | (1ULL << (CypherParser::IS - 55)) - | (1ULL << (CypherParser::CYPHERNULL - 55)) - | (1ULL << (CypherParser::COUNT - 55)) - | (1ULL << (CypherParser::FILTER - 55)) - | (1ULL << (CypherParser::EXTRACT - 55)) - | (1ULL << (CypherParser::ANY - 55)) - | (1ULL << (CypherParser::NONE - 55)) - | (1ULL << (CypherParser::SINGLE - 55)) - | (1ULL << (CypherParser::TRUE - 55)) - | (1ULL << (CypherParser::FALSE - 55)) - | (1ULL << (CypherParser::UnescapedSymbolicName - 55)) - | (1ULL << (CypherParser::EscapedSymbolicName - 55)))) != 0)) { + if (((((_la - 55) & ~0x3fULL) == 0) && + ((1ULL << (_la - 55)) & + ((1ULL << (CypherParser::HexLetter - 55)) | + (1ULL << (CypherParser::UNION - 55)) | + (1ULL << (CypherParser::ALL - 55)) | + (1ULL << (CypherParser::OPTIONAL - 55)) | + (1ULL << (CypherParser::MATCH - 55)) | + (1ULL << (CypherParser::UNWIND - 55)) | + (1ULL << (CypherParser::AS - 55)) | + (1ULL << (CypherParser::MERGE - 55)) | + (1ULL << (CypherParser::ON - 55)) | + (1ULL << (CypherParser::CREATE - 55)) | + (1ULL << (CypherParser::SET - 55)) | + (1ULL << (CypherParser::DETACH - 55)) | + (1ULL << (CypherParser::DELETE - 55)) | + (1ULL << (CypherParser::REMOVE - 55)) | + (1ULL << (CypherParser::WITH - 55)) | + (1ULL << (CypherParser::DISTINCT - 55)) | + (1ULL << (CypherParser::RETURN - 55)) | + (1ULL << (CypherParser::ORDER - 55)) | + (1ULL << (CypherParser::BY - 55)) | + (1ULL << (CypherParser::L_SKIP - 55)) | + (1ULL << (CypherParser::LIMIT - 55)) | + (1ULL << (CypherParser::ASCENDING - 55)) | + (1ULL << (CypherParser::ASC - 55)) | + (1ULL << (CypherParser::DESCENDING - 55)) | + (1ULL << (CypherParser::DESC - 55)) | + (1ULL << (CypherParser::WHERE - 55)) | + (1ULL << (CypherParser::OR - 55)) | + (1ULL << (CypherParser::XOR - 55)) | + (1ULL << (CypherParser::AND - 55)) | + (1ULL << (CypherParser::NOT - 55)) | + (1ULL << (CypherParser::IN - 55)) | + (1ULL << (CypherParser::STARTS - 55)) | + (1ULL << (CypherParser::ENDS - 55)) | + (1ULL << (CypherParser::CONTAINS - 55)) | + (1ULL << (CypherParser::IS - 55)) | + (1ULL << (CypherParser::CYPHERNULL - 55)) | + (1ULL << (CypherParser::COUNT - 55)) | + (1ULL << (CypherParser::FILTER - 55)) | + (1ULL << (CypherParser::EXTRACT - 55)) | + (1ULL << (CypherParser::ANY - 55)) | + (1ULL << (CypherParser::NONE - 55)) | + (1ULL << (CypherParser::SINGLE - 55)) | + (1ULL << (CypherParser::TRUE - 55)) | + (1ULL << (CypherParser::FALSE - 55)) | + (1ULL << (CypherParser::UnescapedSymbolicName - 55)) | + (1ULL << (CypherParser::EscapedSymbolicName - 55)))) != 0)) { setState(1168); propertyKeyName(); setState(1170); @@ -8254,9 +8242,8 @@ CypherParser::MapLiteralContext* CypherParser::mapLiteral() { } setState(1203); match(CypherParser::T__28); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -8265,52 +8252,52 @@ CypherParser::MapLiteralContext* CypherParser::mapLiteral() { return _localctx; } -//----------------- ParameterContext ------------------------------------------------------------------ +//----------------- ParameterContext +//------------------------------------------------------------------ -CypherParser::ParameterContext::ParameterContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::ParameterContext::ParameterContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::SymbolicNameContext* CypherParser::ParameterContext::symbolicName() { +CypherParser::SymbolicNameContext * +CypherParser::ParameterContext::symbolicName() { return getRuleContext<CypherParser::SymbolicNameContext>(0); } -tree::TerminalNode* CypherParser::ParameterContext::DecimalInteger() { +tree::TerminalNode *CypherParser::ParameterContext::DecimalInteger() { return getToken(CypherParser::DecimalInteger, 0); } - size_t CypherParser::ParameterContext::getRuleIndex() const { return CypherParser::RuleParameter; } -void CypherParser::ParameterContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::ParameterContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterParameter(this); + if (parserListener != nullptr) parserListener->enterParameter(this); } -void CypherParser::ParameterContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::ParameterContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitParameter(this); + if (parserListener != nullptr) parserListener->exitParameter(this); } - -antlrcpp::Any CypherParser::ParameterContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::ParameterContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitParameter(this); else return visitor->visitChildren(this); } -CypherParser::ParameterContext* CypherParser::parameter() { - ParameterContext *_localctx = _tracker.createInstance<ParameterContext>(_ctx, getState()); +CypherParser::ParameterContext *CypherParser::parameter() { + ParameterContext *_localctx = + _tracker.createInstance<ParameterContext>(_ctx, getState()); enterRule(_localctx, 140, CypherParser::RuleParameter); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1205); @@ -8375,12 +8362,11 @@ CypherParser::ParameterContext* CypherParser::parameter() { break; } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -8389,101 +8375,103 @@ CypherParser::ParameterContext* CypherParser::parameter() { return _localctx; } -//----------------- PropertyExpressionContext ------------------------------------------------------------------ +//----------------- PropertyExpressionContext +//------------------------------------------------------------------ -CypherParser::PropertyExpressionContext::PropertyExpressionContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::PropertyExpressionContext::PropertyExpressionContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::AtomContext* CypherParser::PropertyExpressionContext::atom() { +CypherParser::AtomContext *CypherParser::PropertyExpressionContext::atom() { return getRuleContext<CypherParser::AtomContext>(0); } -std::vector<CypherParser::PropertyLookupContext *> CypherParser::PropertyExpressionContext::propertyLookup() { +std::vector<CypherParser::PropertyLookupContext *> +CypherParser::PropertyExpressionContext::propertyLookup() { return getRuleContexts<CypherParser::PropertyLookupContext>(); } -CypherParser::PropertyLookupContext* CypherParser::PropertyExpressionContext::propertyLookup(size_t i) { +CypherParser::PropertyLookupContext * +CypherParser::PropertyExpressionContext::propertyLookup(size_t i) { return getRuleContext<CypherParser::PropertyLookupContext>(i); } -std::vector<tree::TerminalNode *> CypherParser::PropertyExpressionContext::SP() { +std::vector<tree::TerminalNode *> +CypherParser::PropertyExpressionContext::SP() { return getTokens(CypherParser::SP); } -tree::TerminalNode* CypherParser::PropertyExpressionContext::SP(size_t i) { +tree::TerminalNode *CypherParser::PropertyExpressionContext::SP(size_t i) { return getToken(CypherParser::SP, i); } - size_t CypherParser::PropertyExpressionContext::getRuleIndex() const { return CypherParser::RulePropertyExpression; } -void CypherParser::PropertyExpressionContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::PropertyExpressionContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterPropertyExpression(this); + if (parserListener != nullptr) parserListener->enterPropertyExpression(this); } -void CypherParser::PropertyExpressionContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::PropertyExpressionContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitPropertyExpression(this); + if (parserListener != nullptr) parserListener->exitPropertyExpression(this); } - -antlrcpp::Any CypherParser::PropertyExpressionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::PropertyExpressionContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitPropertyExpression(this); else return visitor->visitChildren(this); } -CypherParser::PropertyExpressionContext* CypherParser::propertyExpression() { - PropertyExpressionContext *_localctx = _tracker.createInstance<PropertyExpressionContext>(_ctx, getState()); +CypherParser::PropertyExpressionContext *CypherParser::propertyExpression() { + PropertyExpressionContext *_localctx = + _tracker.createInstance<PropertyExpressionContext>(_ctx, getState()); enterRule(_localctx, 142, CypherParser::RulePropertyExpression); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { size_t alt; enterOuterAlt(_localctx, 1); setState(1210); atom(); - setState(1215); + setState(1215); _errHandler->sync(this); alt = 1; do { switch (alt) { case 1: { - setState(1212); - _errHandler->sync(this); + setState(1212); + _errHandler->sync(this); - switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 217, _ctx)) { - case 1: { - setState(1211); - match(CypherParser::SP); - break; - } - - } - setState(1214); - propertyLookup(); + switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 217, _ctx)) { + case 1: { + setState(1211); + match(CypherParser::SP); break; } + } + setState(1214); + propertyLookup(); + break; + } - default: - throw NoViableAltException(this); + default: + throw NoViableAltException(this); } - setState(1217); + setState(1217); _errHandler->sync(this); - alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 218, _ctx); + alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict( + _input, 218, _ctx); } while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -8492,55 +8480,54 @@ CypherParser::PropertyExpressionContext* CypherParser::propertyExpression() { return _localctx; } -//----------------- PropertyKeyNameContext ------------------------------------------------------------------ +//----------------- PropertyKeyNameContext +//------------------------------------------------------------------ -CypherParser::PropertyKeyNameContext::PropertyKeyNameContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::PropertyKeyNameContext::PropertyKeyNameContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -CypherParser::SymbolicNameContext* CypherParser::PropertyKeyNameContext::symbolicName() { +CypherParser::SymbolicNameContext * +CypherParser::PropertyKeyNameContext::symbolicName() { return getRuleContext<CypherParser::SymbolicNameContext>(0); } - size_t CypherParser::PropertyKeyNameContext::getRuleIndex() const { return CypherParser::RulePropertyKeyName; } -void CypherParser::PropertyKeyNameContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::PropertyKeyNameContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterPropertyKeyName(this); + if (parserListener != nullptr) parserListener->enterPropertyKeyName(this); } -void CypherParser::PropertyKeyNameContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::PropertyKeyNameContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitPropertyKeyName(this); + if (parserListener != nullptr) parserListener->exitPropertyKeyName(this); } - -antlrcpp::Any CypherParser::PropertyKeyNameContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::PropertyKeyNameContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitPropertyKeyName(this); else return visitor->visitChildren(this); } -CypherParser::PropertyKeyNameContext* CypherParser::propertyKeyName() { - PropertyKeyNameContext *_localctx = _tracker.createInstance<PropertyKeyNameContext>(_ctx, getState()); +CypherParser::PropertyKeyNameContext *CypherParser::propertyKeyName() { + PropertyKeyNameContext *_localctx = + _tracker.createInstance<PropertyKeyNameContext>(_ctx, getState()); enterRule(_localctx, 144, CypherParser::RulePropertyKeyName); - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1219); symbolicName(); - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -8549,74 +8536,71 @@ CypherParser::PropertyKeyNameContext* CypherParser::propertyKeyName() { return _localctx; } -//----------------- IntegerLiteralContext ------------------------------------------------------------------ +//----------------- IntegerLiteralContext +//------------------------------------------------------------------ -CypherParser::IntegerLiteralContext::IntegerLiteralContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::IntegerLiteralContext::IntegerLiteralContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::IntegerLiteralContext::HexInteger() { +tree::TerminalNode *CypherParser::IntegerLiteralContext::HexInteger() { return getToken(CypherParser::HexInteger, 0); } -tree::TerminalNode* CypherParser::IntegerLiteralContext::OctalInteger() { +tree::TerminalNode *CypherParser::IntegerLiteralContext::OctalInteger() { return getToken(CypherParser::OctalInteger, 0); } -tree::TerminalNode* CypherParser::IntegerLiteralContext::DecimalInteger() { +tree::TerminalNode *CypherParser::IntegerLiteralContext::DecimalInteger() { return getToken(CypherParser::DecimalInteger, 0); } - size_t CypherParser::IntegerLiteralContext::getRuleIndex() const { return CypherParser::RuleIntegerLiteral; } -void CypherParser::IntegerLiteralContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::IntegerLiteralContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterIntegerLiteral(this); + if (parserListener != nullptr) parserListener->enterIntegerLiteral(this); } -void CypherParser::IntegerLiteralContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::IntegerLiteralContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitIntegerLiteral(this); + if (parserListener != nullptr) parserListener->exitIntegerLiteral(this); } - -antlrcpp::Any CypherParser::IntegerLiteralContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::IntegerLiteralContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitIntegerLiteral(this); else return visitor->visitChildren(this); } -CypherParser::IntegerLiteralContext* CypherParser::integerLiteral() { - IntegerLiteralContext *_localctx = _tracker.createInstance<IntegerLiteralContext>(_ctx, getState()); +CypherParser::IntegerLiteralContext *CypherParser::integerLiteral() { + IntegerLiteralContext *_localctx = + _tracker.createInstance<IntegerLiteralContext>(_ctx, getState()); enterRule(_localctx, 146, CypherParser::RuleIntegerLiteral); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1221); _la = _input->LA(1); - if (!((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::HexInteger) - | (1ULL << CypherParser::DecimalInteger) - | (1ULL << CypherParser::OctalInteger))) != 0))) { - _errHandler->recoverInline(this); - } - else { + if (!((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & ((1ULL << CypherParser::HexInteger) | + (1ULL << CypherParser::DecimalInteger) | + (1ULL << CypherParser::OctalInteger))) != 0))) { + _errHandler->recoverInline(this); + } else { _errHandler->reportMatch(this); consume(); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -8625,69 +8609,66 @@ CypherParser::IntegerLiteralContext* CypherParser::integerLiteral() { return _localctx; } -//----------------- DoubleLiteralContext ------------------------------------------------------------------ +//----------------- DoubleLiteralContext +//------------------------------------------------------------------ -CypherParser::DoubleLiteralContext::DoubleLiteralContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::DoubleLiteralContext::DoubleLiteralContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::DoubleLiteralContext::ExponentDecimalReal() { +tree::TerminalNode *CypherParser::DoubleLiteralContext::ExponentDecimalReal() { return getToken(CypherParser::ExponentDecimalReal, 0); } -tree::TerminalNode* CypherParser::DoubleLiteralContext::RegularDecimalReal() { +tree::TerminalNode *CypherParser::DoubleLiteralContext::RegularDecimalReal() { return getToken(CypherParser::RegularDecimalReal, 0); } - size_t CypherParser::DoubleLiteralContext::getRuleIndex() const { return CypherParser::RuleDoubleLiteral; } -void CypherParser::DoubleLiteralContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::DoubleLiteralContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterDoubleLiteral(this); + if (parserListener != nullptr) parserListener->enterDoubleLiteral(this); } -void CypherParser::DoubleLiteralContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::DoubleLiteralContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitDoubleLiteral(this); + if (parserListener != nullptr) parserListener->exitDoubleLiteral(this); } - -antlrcpp::Any CypherParser::DoubleLiteralContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::DoubleLiteralContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitDoubleLiteral(this); else return visitor->visitChildren(this); } -CypherParser::DoubleLiteralContext* CypherParser::doubleLiteral() { - DoubleLiteralContext *_localctx = _tracker.createInstance<DoubleLiteralContext>(_ctx, getState()); +CypherParser::DoubleLiteralContext *CypherParser::doubleLiteral() { + DoubleLiteralContext *_localctx = + _tracker.createInstance<DoubleLiteralContext>(_ctx, getState()); enterRule(_localctx, 148, CypherParser::RuleDoubleLiteral); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1223); _la = _input->LA(1); if (!(_la == CypherParser::ExponentDecimalReal - || _la == CypherParser::RegularDecimalReal)) { - _errHandler->recoverInline(this); - } - else { + || _la == CypherParser::RegularDecimalReal)) { + _errHandler->recoverInline(this); + } else { _errHandler->reportMatch(this); consume(); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -8696,289 +8677,287 @@ CypherParser::DoubleLiteralContext* CypherParser::doubleLiteral() { return _localctx; } -//----------------- SymbolicNameContext ------------------------------------------------------------------ +//----------------- SymbolicNameContext +//------------------------------------------------------------------ -CypherParser::SymbolicNameContext::SymbolicNameContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +CypherParser::SymbolicNameContext::SymbolicNameContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode* CypherParser::SymbolicNameContext::UnescapedSymbolicName() { +tree::TerminalNode *CypherParser::SymbolicNameContext::UnescapedSymbolicName() { return getToken(CypherParser::UnescapedSymbolicName, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::EscapedSymbolicName() { +tree::TerminalNode *CypherParser::SymbolicNameContext::EscapedSymbolicName() { return getToken(CypherParser::EscapedSymbolicName, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::UNION() { +tree::TerminalNode *CypherParser::SymbolicNameContext::UNION() { return getToken(CypherParser::UNION, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::ALL() { +tree::TerminalNode *CypherParser::SymbolicNameContext::ALL() { return getToken(CypherParser::ALL, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::OPTIONAL() { +tree::TerminalNode *CypherParser::SymbolicNameContext::OPTIONAL() { return getToken(CypherParser::OPTIONAL, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::MATCH() { +tree::TerminalNode *CypherParser::SymbolicNameContext::MATCH() { return getToken(CypherParser::MATCH, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::UNWIND() { +tree::TerminalNode *CypherParser::SymbolicNameContext::UNWIND() { return getToken(CypherParser::UNWIND, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::AS() { +tree::TerminalNode *CypherParser::SymbolicNameContext::AS() { return getToken(CypherParser::AS, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::MERGE() { +tree::TerminalNode *CypherParser::SymbolicNameContext::MERGE() { return getToken(CypherParser::MERGE, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::ON() { +tree::TerminalNode *CypherParser::SymbolicNameContext::ON() { return getToken(CypherParser::ON, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::CREATE() { +tree::TerminalNode *CypherParser::SymbolicNameContext::CREATE() { return getToken(CypherParser::CREATE, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::SET() { +tree::TerminalNode *CypherParser::SymbolicNameContext::SET() { return getToken(CypherParser::SET, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::DETACH() { +tree::TerminalNode *CypherParser::SymbolicNameContext::DETACH() { return getToken(CypherParser::DETACH, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::DELETE() { +tree::TerminalNode *CypherParser::SymbolicNameContext::DELETE() { return getToken(CypherParser::DELETE, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::REMOVE() { +tree::TerminalNode *CypherParser::SymbolicNameContext::REMOVE() { return getToken(CypherParser::REMOVE, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::WITH() { +tree::TerminalNode *CypherParser::SymbolicNameContext::WITH() { return getToken(CypherParser::WITH, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::DISTINCT() { +tree::TerminalNode *CypherParser::SymbolicNameContext::DISTINCT() { return getToken(CypherParser::DISTINCT, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::RETURN() { +tree::TerminalNode *CypherParser::SymbolicNameContext::RETURN() { return getToken(CypherParser::RETURN, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::ORDER() { +tree::TerminalNode *CypherParser::SymbolicNameContext::ORDER() { return getToken(CypherParser::ORDER, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::BY() { +tree::TerminalNode *CypherParser::SymbolicNameContext::BY() { return getToken(CypherParser::BY, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::L_SKIP() { +tree::TerminalNode *CypherParser::SymbolicNameContext::L_SKIP() { return getToken(CypherParser::L_SKIP, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::LIMIT() { +tree::TerminalNode *CypherParser::SymbolicNameContext::LIMIT() { return getToken(CypherParser::LIMIT, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::ASCENDING() { +tree::TerminalNode *CypherParser::SymbolicNameContext::ASCENDING() { return getToken(CypherParser::ASCENDING, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::ASC() { +tree::TerminalNode *CypherParser::SymbolicNameContext::ASC() { return getToken(CypherParser::ASC, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::DESCENDING() { +tree::TerminalNode *CypherParser::SymbolicNameContext::DESCENDING() { return getToken(CypherParser::DESCENDING, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::DESC() { +tree::TerminalNode *CypherParser::SymbolicNameContext::DESC() { return getToken(CypherParser::DESC, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::WHERE() { +tree::TerminalNode *CypherParser::SymbolicNameContext::WHERE() { return getToken(CypherParser::WHERE, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::OR() { +tree::TerminalNode *CypherParser::SymbolicNameContext::OR() { return getToken(CypherParser::OR, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::XOR() { +tree::TerminalNode *CypherParser::SymbolicNameContext::XOR() { return getToken(CypherParser::XOR, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::AND() { +tree::TerminalNode *CypherParser::SymbolicNameContext::AND() { return getToken(CypherParser::AND, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::NOT() { +tree::TerminalNode *CypherParser::SymbolicNameContext::NOT() { return getToken(CypherParser::NOT, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::IN() { +tree::TerminalNode *CypherParser::SymbolicNameContext::IN() { return getToken(CypherParser::IN, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::STARTS() { +tree::TerminalNode *CypherParser::SymbolicNameContext::STARTS() { return getToken(CypherParser::STARTS, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::ENDS() { +tree::TerminalNode *CypherParser::SymbolicNameContext::ENDS() { return getToken(CypherParser::ENDS, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::CONTAINS() { +tree::TerminalNode *CypherParser::SymbolicNameContext::CONTAINS() { return getToken(CypherParser::CONTAINS, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::IS() { +tree::TerminalNode *CypherParser::SymbolicNameContext::IS() { return getToken(CypherParser::IS, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::CYPHERNULL() { +tree::TerminalNode *CypherParser::SymbolicNameContext::CYPHERNULL() { return getToken(CypherParser::CYPHERNULL, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::COUNT() { +tree::TerminalNode *CypherParser::SymbolicNameContext::COUNT() { return getToken(CypherParser::COUNT, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::FILTER() { +tree::TerminalNode *CypherParser::SymbolicNameContext::FILTER() { return getToken(CypherParser::FILTER, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::EXTRACT() { +tree::TerminalNode *CypherParser::SymbolicNameContext::EXTRACT() { return getToken(CypherParser::EXTRACT, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::ANY() { +tree::TerminalNode *CypherParser::SymbolicNameContext::ANY() { return getToken(CypherParser::ANY, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::NONE() { +tree::TerminalNode *CypherParser::SymbolicNameContext::NONE() { return getToken(CypherParser::NONE, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::SINGLE() { +tree::TerminalNode *CypherParser::SymbolicNameContext::SINGLE() { return getToken(CypherParser::SINGLE, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::TRUE() { +tree::TerminalNode *CypherParser::SymbolicNameContext::TRUE() { return getToken(CypherParser::TRUE, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::FALSE() { +tree::TerminalNode *CypherParser::SymbolicNameContext::FALSE() { return getToken(CypherParser::FALSE, 0); } -tree::TerminalNode* CypherParser::SymbolicNameContext::HexLetter() { +tree::TerminalNode *CypherParser::SymbolicNameContext::HexLetter() { return getToken(CypherParser::HexLetter, 0); } - size_t CypherParser::SymbolicNameContext::getRuleIndex() const { return CypherParser::RuleSymbolicName; } -void CypherParser::SymbolicNameContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::SymbolicNameContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterSymbolicName(this); + if (parserListener != nullptr) parserListener->enterSymbolicName(this); } -void CypherParser::SymbolicNameContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::SymbolicNameContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitSymbolicName(this); + if (parserListener != nullptr) parserListener->exitSymbolicName(this); } - -antlrcpp::Any CypherParser::SymbolicNameContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::SymbolicNameContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitSymbolicName(this); else return visitor->visitChildren(this); } -CypherParser::SymbolicNameContext* CypherParser::symbolicName() { - SymbolicNameContext *_localctx = _tracker.createInstance<SymbolicNameContext>(_ctx, getState()); +CypherParser::SymbolicNameContext *CypherParser::symbolicName() { + SymbolicNameContext *_localctx = + _tracker.createInstance<SymbolicNameContext>(_ctx, getState()); enterRule(_localctx, 150, CypherParser::RuleSymbolicName); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1225); _la = _input->LA(1); - if (!(((((_la - 55) & ~ 0x3fULL) == 0) && - ((1ULL << (_la - 55)) & ((1ULL << (CypherParser::HexLetter - 55)) - | (1ULL << (CypherParser::UNION - 55)) - | (1ULL << (CypherParser::ALL - 55)) - | (1ULL << (CypherParser::OPTIONAL - 55)) - | (1ULL << (CypherParser::MATCH - 55)) - | (1ULL << (CypherParser::UNWIND - 55)) - | (1ULL << (CypherParser::AS - 55)) - | (1ULL << (CypherParser::MERGE - 55)) - | (1ULL << (CypherParser::ON - 55)) - | (1ULL << (CypherParser::CREATE - 55)) - | (1ULL << (CypherParser::SET - 55)) - | (1ULL << (CypherParser::DETACH - 55)) - | (1ULL << (CypherParser::DELETE - 55)) - | (1ULL << (CypherParser::REMOVE - 55)) - | (1ULL << (CypherParser::WITH - 55)) - | (1ULL << (CypherParser::DISTINCT - 55)) - | (1ULL << (CypherParser::RETURN - 55)) - | (1ULL << (CypherParser::ORDER - 55)) - | (1ULL << (CypherParser::BY - 55)) - | (1ULL << (CypherParser::L_SKIP - 55)) - | (1ULL << (CypherParser::LIMIT - 55)) - | (1ULL << (CypherParser::ASCENDING - 55)) - | (1ULL << (CypherParser::ASC - 55)) - | (1ULL << (CypherParser::DESCENDING - 55)) - | (1ULL << (CypherParser::DESC - 55)) - | (1ULL << (CypherParser::WHERE - 55)) - | (1ULL << (CypherParser::OR - 55)) - | (1ULL << (CypherParser::XOR - 55)) - | (1ULL << (CypherParser::AND - 55)) - | (1ULL << (CypherParser::NOT - 55)) - | (1ULL << (CypherParser::IN - 55)) - | (1ULL << (CypherParser::STARTS - 55)) - | (1ULL << (CypherParser::ENDS - 55)) - | (1ULL << (CypherParser::CONTAINS - 55)) - | (1ULL << (CypherParser::IS - 55)) - | (1ULL << (CypherParser::CYPHERNULL - 55)) - | (1ULL << (CypherParser::COUNT - 55)) - | (1ULL << (CypherParser::FILTER - 55)) - | (1ULL << (CypherParser::EXTRACT - 55)) - | (1ULL << (CypherParser::ANY - 55)) - | (1ULL << (CypherParser::NONE - 55)) - | (1ULL << (CypherParser::SINGLE - 55)) - | (1ULL << (CypherParser::TRUE - 55)) - | (1ULL << (CypherParser::FALSE - 55)) - | (1ULL << (CypherParser::UnescapedSymbolicName - 55)) - | (1ULL << (CypherParser::EscapedSymbolicName - 55)))) != 0))) { - _errHandler->recoverInline(this); - } - else { + if (!(((((_la - 55) & ~0x3fULL) == 0) && + ((1ULL << (_la - 55)) & + ((1ULL << (CypherParser::HexLetter - 55)) | + (1ULL << (CypherParser::UNION - 55)) | + (1ULL << (CypherParser::ALL - 55)) | + (1ULL << (CypherParser::OPTIONAL - 55)) | + (1ULL << (CypherParser::MATCH - 55)) | + (1ULL << (CypherParser::UNWIND - 55)) | + (1ULL << (CypherParser::AS - 55)) | + (1ULL << (CypherParser::MERGE - 55)) | + (1ULL << (CypherParser::ON - 55)) | + (1ULL << (CypherParser::CREATE - 55)) | + (1ULL << (CypherParser::SET - 55)) | + (1ULL << (CypherParser::DETACH - 55)) | + (1ULL << (CypherParser::DELETE - 55)) | + (1ULL << (CypherParser::REMOVE - 55)) | + (1ULL << (CypherParser::WITH - 55)) | + (1ULL << (CypherParser::DISTINCT - 55)) | + (1ULL << (CypherParser::RETURN - 55)) | + (1ULL << (CypherParser::ORDER - 55)) | + (1ULL << (CypherParser::BY - 55)) | + (1ULL << (CypherParser::L_SKIP - 55)) | + (1ULL << (CypherParser::LIMIT - 55)) | + (1ULL << (CypherParser::ASCENDING - 55)) | + (1ULL << (CypherParser::ASC - 55)) | + (1ULL << (CypherParser::DESCENDING - 55)) | + (1ULL << (CypherParser::DESC - 55)) | + (1ULL << (CypherParser::WHERE - 55)) | + (1ULL << (CypherParser::OR - 55)) | + (1ULL << (CypherParser::XOR - 55)) | + (1ULL << (CypherParser::AND - 55)) | + (1ULL << (CypherParser::NOT - 55)) | + (1ULL << (CypherParser::IN - 55)) | + (1ULL << (CypherParser::STARTS - 55)) | + (1ULL << (CypherParser::ENDS - 55)) | + (1ULL << (CypherParser::CONTAINS - 55)) | + (1ULL << (CypherParser::IS - 55)) | + (1ULL << (CypherParser::CYPHERNULL - 55)) | + (1ULL << (CypherParser::COUNT - 55)) | + (1ULL << (CypherParser::FILTER - 55)) | + (1ULL << (CypherParser::EXTRACT - 55)) | + (1ULL << (CypherParser::ANY - 55)) | + (1ULL << (CypherParser::NONE - 55)) | + (1ULL << (CypherParser::SINGLE - 55)) | + (1ULL << (CypherParser::TRUE - 55)) | + (1ULL << (CypherParser::FALSE - 55)) | + (1ULL << (CypherParser::UnescapedSymbolicName - 55)) | + (1ULL << (CypherParser::EscapedSymbolicName - 55)))) != 0))) { + _errHandler->recoverInline(this); + } else { _errHandler->reportMatch(this); consume(); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -8987,64 +8966,60 @@ CypherParser::SymbolicNameContext* CypherParser::symbolicName() { return _localctx; } -//----------------- LeftArrowHeadContext ------------------------------------------------------------------ - -CypherParser::LeftArrowHeadContext::LeftArrowHeadContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +//----------------- LeftArrowHeadContext +//------------------------------------------------------------------ +CypherParser::LeftArrowHeadContext::LeftArrowHeadContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} size_t CypherParser::LeftArrowHeadContext::getRuleIndex() const { return CypherParser::RuleLeftArrowHead; } -void CypherParser::LeftArrowHeadContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::LeftArrowHeadContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterLeftArrowHead(this); + if (parserListener != nullptr) parserListener->enterLeftArrowHead(this); } -void CypherParser::LeftArrowHeadContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::LeftArrowHeadContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitLeftArrowHead(this); + if (parserListener != nullptr) parserListener->exitLeftArrowHead(this); } - -antlrcpp::Any CypherParser::LeftArrowHeadContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::LeftArrowHeadContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitLeftArrowHead(this); else return visitor->visitChildren(this); } -CypherParser::LeftArrowHeadContext* CypherParser::leftArrowHead() { - LeftArrowHeadContext *_localctx = _tracker.createInstance<LeftArrowHeadContext>(_ctx, getState()); +CypherParser::LeftArrowHeadContext *CypherParser::leftArrowHead() { + LeftArrowHeadContext *_localctx = + _tracker.createInstance<LeftArrowHeadContext>(_ctx, getState()); enterRule(_localctx, 152, CypherParser::RuleLeftArrowHead); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1227); _la = _input->LA(1); - if (!((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::T__21) - | (1ULL << CypherParser::T__30) - | (1ULL << CypherParser::T__31) - | (1ULL << CypherParser::T__32) - | (1ULL << CypherParser::T__33))) != 0))) { - _errHandler->recoverInline(this); - } - else { + if (!((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & + ((1ULL << CypherParser::T__21) | (1ULL << CypherParser::T__30) | + (1ULL << CypherParser::T__31) | (1ULL << CypherParser::T__32) | + (1ULL << CypherParser::T__33))) != 0))) { + _errHandler->recoverInline(this); + } else { _errHandler->reportMatch(this); consume(); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -9053,64 +9028,60 @@ CypherParser::LeftArrowHeadContext* CypherParser::leftArrowHead() { return _localctx; } -//----------------- RightArrowHeadContext ------------------------------------------------------------------ - -CypherParser::RightArrowHeadContext::RightArrowHeadContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +//----------------- RightArrowHeadContext +//------------------------------------------------------------------ +CypherParser::RightArrowHeadContext::RightArrowHeadContext( + ParserRuleContext *parent, size_t invokingState) + : ParserRuleContext(parent, invokingState) {} size_t CypherParser::RightArrowHeadContext::getRuleIndex() const { return CypherParser::RuleRightArrowHead; } -void CypherParser::RightArrowHeadContext::enterRule(tree::ParseTreeListener *listener) { +void CypherParser::RightArrowHeadContext::enterRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterRightArrowHead(this); + if (parserListener != nullptr) parserListener->enterRightArrowHead(this); } -void CypherParser::RightArrowHeadContext::exitRule(tree::ParseTreeListener *listener) { +void CypherParser::RightArrowHeadContext::exitRule( + tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitRightArrowHead(this); + if (parserListener != nullptr) parserListener->exitRightArrowHead(this); } - -antlrcpp::Any CypherParser::RightArrowHeadContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::RightArrowHeadContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitRightArrowHead(this); else return visitor->visitChildren(this); } -CypherParser::RightArrowHeadContext* CypherParser::rightArrowHead() { - RightArrowHeadContext *_localctx = _tracker.createInstance<RightArrowHeadContext>(_ctx, getState()); +CypherParser::RightArrowHeadContext *CypherParser::rightArrowHead() { + RightArrowHeadContext *_localctx = + _tracker.createInstance<RightArrowHeadContext>(_ctx, getState()); enterRule(_localctx, 154, CypherParser::RuleRightArrowHead); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1229); _la = _input->LA(1); - if (!((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::T__22) - | (1ULL << CypherParser::T__34) - | (1ULL << CypherParser::T__35) - | (1ULL << CypherParser::T__36) - | (1ULL << CypherParser::T__37))) != 0))) { - _errHandler->recoverInline(this); - } - else { + if (!((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & + ((1ULL << CypherParser::T__22) | (1ULL << CypherParser::T__34) | + (1ULL << CypherParser::T__35) | (1ULL << CypherParser::T__36) | + (1ULL << CypherParser::T__37))) != 0))) { + _errHandler->recoverInline(this); + } else { _errHandler->reportMatch(this); consume(); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -9119,12 +9090,12 @@ CypherParser::RightArrowHeadContext* CypherParser::rightArrowHead() { return _localctx; } -//----------------- DashContext ------------------------------------------------------------------ - -CypherParser::DashContext::DashContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { -} +//----------------- DashContext +//------------------------------------------------------------------ +CypherParser::DashContext::DashContext(ParserRuleContext *parent, + size_t invokingState) + : ParserRuleContext(parent, invokingState) {} size_t CypherParser::DashContext::getRuleIndex() const { return CypherParser::RuleDash; @@ -9132,58 +9103,49 @@ size_t CypherParser::DashContext::getRuleIndex() const { void CypherParser::DashContext::enterRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->enterDash(this); + if (parserListener != nullptr) parserListener->enterDash(this); } void CypherParser::DashContext::exitRule(tree::ParseTreeListener *listener) { auto parserListener = dynamic_cast<CypherListener *>(listener); - if (parserListener != nullptr) - parserListener->exitDash(this); + if (parserListener != nullptr) parserListener->exitDash(this); } - -antlrcpp::Any CypherParser::DashContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast<CypherVisitor*>(visitor)) +antlrcpp::Any CypherParser::DashContext::accept( + tree::ParseTreeVisitor *visitor) { + if (auto parserVisitor = dynamic_cast<CypherVisitor *>(visitor)) return parserVisitor->visitDash(this); else return visitor->visitChildren(this); } -CypherParser::DashContext* CypherParser::dash() { - DashContext *_localctx = _tracker.createInstance<DashContext>(_ctx, getState()); +CypherParser::DashContext *CypherParser::dash() { + DashContext *_localctx = + _tracker.createInstance<DashContext>(_ctx, getState()); enterRule(_localctx, 156, CypherParser::RuleDash); size_t _la = 0; - auto onExit = finally([=] { - exitRule(); - }); + auto onExit = finally([=] { exitRule(); }); try { enterOuterAlt(_localctx, 1); setState(1231); _la = _input->LA(1); - if (!((((_la & ~ 0x3fULL) == 0) && - ((1ULL << _la) & ((1ULL << CypherParser::T__14) - | (1ULL << CypherParser::T__38) - | (1ULL << CypherParser::T__39) - | (1ULL << CypherParser::T__40) - | (1ULL << CypherParser::T__41) - | (1ULL << CypherParser::T__42) - | (1ULL << CypherParser::T__43) - | (1ULL << CypherParser::T__44) - | (1ULL << CypherParser::T__45) - | (1ULL << CypherParser::T__46) - | (1ULL << CypherParser::T__47) - | (1ULL << CypherParser::T__48))) != 0))) { - _errHandler->recoverInline(this); - } - else { + if (!((((_la & ~0x3fULL) == 0) && + ((1ULL << _la) & + ((1ULL << CypherParser::T__14) | (1ULL << CypherParser::T__38) | + (1ULL << CypherParser::T__39) | (1ULL << CypherParser::T__40) | + (1ULL << CypherParser::T__41) | (1ULL << CypherParser::T__42) | + (1ULL << CypherParser::T__43) | (1ULL << CypherParser::T__44) | + (1ULL << CypherParser::T__45) | (1ULL << CypherParser::T__46) | + (1ULL << CypherParser::T__47) | (1ULL << CypherParser::T__48))) != + 0))) { + _errHandler->recoverInline(this); + } else { _errHandler->reportMatch(this); consume(); } - - } - catch (RecognitionException &e) { + + } catch (RecognitionException &e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -9201,1008 +9163,1516 @@ atn::ATN CypherParser::_atn; std::vector<uint16_t> CypherParser::_serializedATN; std::vector<std::string> CypherParser::_ruleNames = { - "cypher", "statement", "query", "regularQuery", "singleQuery", "cypherUnion", - "clause", "cypherMatch", "unwind", "merge", "mergeAction", "create", "set", - "setItem", "cypherDelete", "remove", "removeItem", "with", "cypherReturn", - "returnBody", "returnItems", "returnItem", "order", "skip", "limit", "sortItem", - "where", "pattern", "patternPart", "anonymousPatternPart", "patternElement", - "nodePattern", "patternElementChain", "relationshipPattern", "relationshipDetail", - "properties", "relationshipTypes", "nodeLabels", "nodeLabel", "rangeLiteral", - "labelName", "relTypeName", "expression", "expression12", "expression11", - "expression10", "expression9", "expression8", "expression7", "expression6", - "expression5", "expression4", "expression3", "expression2", "atom", "literal", - "booleanLiteral", "listLiteral", "partialComparisonExpression", "parenthesizedExpression", - "relationshipsPattern", "filterExpression", "idInColl", "functionInvocation", - "functionName", "listComprehension", "propertyLookup", "variable", "numberLiteral", - "mapLiteral", "parameter", "propertyExpression", "propertyKeyName", "integerLiteral", - "doubleLiteral", "symbolicName", "leftArrowHead", "rightArrowHead", "dash" -}; + "cypher", + "statement", + "query", + "regularQuery", + "singleQuery", + "cypherUnion", + "clause", + "cypherMatch", + "unwind", + "merge", + "mergeAction", + "create", + "set", + "setItem", + "cypherDelete", + "remove", + "removeItem", + "with", + "cypherReturn", + "returnBody", + "returnItems", + "returnItem", + "order", + "skip", + "limit", + "sortItem", + "where", + "pattern", + "patternPart", + "anonymousPatternPart", + "patternElement", + "nodePattern", + "patternElementChain", + "relationshipPattern", + "relationshipDetail", + "properties", + "relationshipTypes", + "nodeLabels", + "nodeLabel", + "rangeLiteral", + "labelName", + "relTypeName", + "expression", + "expression12", + "expression11", + "expression10", + "expression9", + "expression8", + "expression7", + "expression6", + "expression5", + "expression4", + "expression3", + "expression2", + "atom", + "literal", + "booleanLiteral", + "listLiteral", + "partialComparisonExpression", + "parenthesizedExpression", + "relationshipsPattern", + "filterExpression", + "idInColl", + "functionInvocation", + "functionName", + "listComprehension", + "propertyLookup", + "variable", + "numberLiteral", + "mapLiteral", + "parameter", + "propertyExpression", + "propertyKeyName", + "integerLiteral", + "doubleLiteral", + "symbolicName", + "leftArrowHead", + "rightArrowHead", + "dash"}; std::vector<std::string> CypherParser::_literalNames = { - "", "';'", "','", "'='", "'+='", "'*'", "'('", "')'", "'['", "'?'", "']'", - "':'", "'|'", "'..'", "'+'", "'-'", "'/'", "'%'", "'^'", "'=~'", "'<>'", - "'!='", "'<'", "'>'", "'<='", "'>='", "'.'", "'!'", "'{'", "'}'", "'$'", - "'⟨'", "'〈'", "'﹤'", "'<'", "'⟩'", "'〉'", "'﹥'", "'>'", "''", "'‐'", - "'‑'", "'‒'", "'–'", "'—'", "'―'", "'−'", "'﹘'", "'﹣'", "'-'", "", "", - "", "", "", "", "", "", "", "", "", "'0'" -}; + "", "';'", "','", "'='", "'+='", "'*'", "'('", "')'", "'['", + "'?'", "']'", "':'", "'|'", "'..'", "'+'", "'-'", "'/'", "'%'", + "'^'", "'=~'", "'<>'", "'!='", "'<'", "'>'", "'<='", "'>='", "'.'", + "'!'", "'{'", "'}'", "'$'", "'⟨'", "'〈'", "'﹤'", "'<'", "'⟩'", + "'〉'", "'﹥'", "'>'", "''", "'‐'", "'‑'", "'‒'", "'–'", "'—'", + "'―'", "'−'", "'﹘'", "'﹣'", "'-'", "", "", "", "", + "", "", "", "", "", "", "", "'0'"}; std::vector<std::string> CypherParser::_symbolicNames = { - "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", "", "", "", "", "StringLiteral", - "EscapedChar", "HexInteger", "DecimalInteger", "OctalInteger", "HexLetter", - "HexDigit", "Digit", "NonZeroDigit", "NonZeroOctDigit", "OctDigit", "ZeroDigit", - "ExponentDecimalReal", "RegularDecimalReal", "UNION", "ALL", "OPTIONAL", - "MATCH", "UNWIND", "AS", "MERGE", "ON", "CREATE", "SET", "DETACH", "DELETE", - "REMOVE", "WITH", "DISTINCT", "RETURN", "ORDER", "BY", "L_SKIP", "LIMIT", - "ASCENDING", "ASC", "DESCENDING", "DESC", "WHERE", "OR", "XOR", "AND", - "NOT", "IN", "STARTS", "ENDS", "CONTAINS", "IS", "CYPHERNULL", "COUNT", - "FILTER", "EXTRACT", "ANY", "NONE", "SINGLE", "TRUE", "FALSE", "UnescapedSymbolicName", - "IdentifierStart", "IdentifierPart", "EscapedSymbolicName", "SP", "WHITESPACE", - "Comment", "L_0X" -}; + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "StringLiteral", + "EscapedChar", + "HexInteger", + "DecimalInteger", + "OctalInteger", + "HexLetter", + "HexDigit", + "Digit", + "NonZeroDigit", + "NonZeroOctDigit", + "OctDigit", + "ZeroDigit", + "ExponentDecimalReal", + "RegularDecimalReal", + "UNION", + "ALL", + "OPTIONAL", + "MATCH", + "UNWIND", + "AS", + "MERGE", + "ON", + "CREATE", + "SET", + "DETACH", + "DELETE", + "REMOVE", + "WITH", + "DISTINCT", + "RETURN", + "ORDER", + "BY", + "L_SKIP", + "LIMIT", + "ASCENDING", + "ASC", + "DESCENDING", + "DESC", + "WHERE", + "OR", + "XOR", + "AND", + "NOT", + "IN", + "STARTS", + "ENDS", + "CONTAINS", + "IS", + "CYPHERNULL", + "COUNT", + "FILTER", + "EXTRACT", + "ANY", + "NONE", + "SINGLE", + "TRUE", + "FALSE", + "UnescapedSymbolicName", + "IdentifierStart", + "IdentifierPart", + "EscapedSymbolicName", + "SP", + "WHITESPACE", + "Comment", + "L_0X"}; dfa::Vocabulary CypherParser::_vocabulary(_literalNames, _symbolicNames); std::vector<std::string> CypherParser::_tokenNames; CypherParser::Initializer::Initializer() { - for (size_t i = 0; i < _symbolicNames.size(); ++i) { - std::string name = _vocabulary.getLiteralName(i); - if (name.empty()) { - name = _vocabulary.getSymbolicName(i); - } + for (size_t i = 0; i < _symbolicNames.size(); ++i) { + std::string name = _vocabulary.getLiteralName(i); + if (name.empty()) { + name = _vocabulary.getSymbolicName(i); + } - if (name.empty()) { - _tokenNames.push_back("<INVALID>"); - } else { + if (name.empty()) { + _tokenNames.push_back("<INVALID>"); + } else { _tokenNames.push_back(name); } - } + } _serializedATN = { - 0x3, 0x430, 0xd6d1, 0x8206, 0xad2d, 0x4417, 0xaef1, 0x8d80, 0xaadd, - 0x3, 0x74, 0x4d4, 0x4, 0x2, 0x9, 0x2, 0x4, 0x3, 0x9, 0x3, 0x4, 0x4, - 0x9, 0x4, 0x4, 0x5, 0x9, 0x5, 0x4, 0x6, 0x9, 0x6, 0x4, 0x7, 0x9, 0x7, - 0x4, 0x8, 0x9, 0x8, 0x4, 0x9, 0x9, 0x9, 0x4, 0xa, 0x9, 0xa, 0x4, 0xb, - 0x9, 0xb, 0x4, 0xc, 0x9, 0xc, 0x4, 0xd, 0x9, 0xd, 0x4, 0xe, 0x9, 0xe, - 0x4, 0xf, 0x9, 0xf, 0x4, 0x10, 0x9, 0x10, 0x4, 0x11, 0x9, 0x11, 0x4, - 0x12, 0x9, 0x12, 0x4, 0x13, 0x9, 0x13, 0x4, 0x14, 0x9, 0x14, 0x4, 0x15, - 0x9, 0x15, 0x4, 0x16, 0x9, 0x16, 0x4, 0x17, 0x9, 0x17, 0x4, 0x18, 0x9, - 0x18, 0x4, 0x19, 0x9, 0x19, 0x4, 0x1a, 0x9, 0x1a, 0x4, 0x1b, 0x9, 0x1b, - 0x4, 0x1c, 0x9, 0x1c, 0x4, 0x1d, 0x9, 0x1d, 0x4, 0x1e, 0x9, 0x1e, 0x4, - 0x1f, 0x9, 0x1f, 0x4, 0x20, 0x9, 0x20, 0x4, 0x21, 0x9, 0x21, 0x4, 0x22, - 0x9, 0x22, 0x4, 0x23, 0x9, 0x23, 0x4, 0x24, 0x9, 0x24, 0x4, 0x25, 0x9, - 0x25, 0x4, 0x26, 0x9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 0x13, 0x161, 0xa, 0x13, - 0x3, 0x13, 0x3, 0x13, 0x3, 0x13, 0x5, 0x13, 0x166, 0xa, 0x13, 0x3, 0x13, - 0x5, 0x13, 0x169, 0xa, 0x13, 0x3, 0x14, 0x3, 0x14, 0x5, 0x14, 0x16d, - 0xa, 0x14, 0x3, 0x14, 0x5, 0x14, 0x170, 0xa, 0x14, 0x3, 0x14, 0x3, 0x14, - 0x3, 0x14, 0x3, 0x15, 0x3, 0x15, 0x3, 0x15, 0x5, 0x15, 0x178, 0xa, 0x15, - 0x3, 0x15, 0x3, 0x15, 0x5, 0x15, 0x17c, 0xa, 0x15, 0x3, 0x15, 0x3, 0x15, - 0x5, 0x15, 0x180, 0xa, 0x15, 0x3, 0x16, 0x3, 0x16, 0x5, 0x16, 0x184, - 0xa, 0x16, 0x3, 0x16, 0x3, 0x16, 0x5, 0x16, 0x188, 0xa, 0x16, 0x3, 0x16, - 0x7, 0x16, 0x18b, 0xa, 0x16, 0xc, 0x16, 0xe, 0x16, 0x18e, 0xb, 0x16, - 0x3, 0x16, 0x3, 0x16, 0x5, 0x16, 0x192, 0xa, 0x16, 0x3, 0x16, 0x3, 0x16, - 0x5, 0x16, 0x196, 0xa, 0x16, 0x3, 0x16, 0x7, 0x16, 0x199, 0xa, 0x16, - 0xc, 0x16, 0xe, 0x16, 0x19c, 0xb, 0x16, 0x5, 0x16, 0x19e, 0xa, 0x16, - 0x3, 0x17, 0x3, 0x17, 0x3, 0x17, 0x3, 0x17, 0x3, 0x17, 0x3, 0x17, 0x3, - 0x17, 0x5, 0x17, 0x1a7, 0xa, 0x17, 0x3, 0x18, 0x3, 0x18, 0x3, 0x18, - 0x3, 0x18, 0x3, 0x18, 0x3, 0x18, 0x3, 0x18, 0x5, 0x18, 0x1b0, 0xa, 0x18, - 0x3, 0x18, 0x7, 0x18, 0x1b3, 0xa, 0x18, 0xc, 0x18, 0xe, 0x18, 0x1b6, - 0xb, 0x18, 0x3, 0x19, 0x3, 0x19, 0x3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, 0x3, 0x21, 0x3, 0x21, 0x3, 0x22, 0x3, 0x22, - 0x5, 0x22, 0x212, 0xa, 0x22, 0x3, 0x22, 0x3, 0x22, 0x3, 0x23, 0x3, 0x23, - 0x5, 0x23, 0x218, 0xa, 0x23, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, 0x21c, - 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, 0x21f, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, - 0x222, 0xa, 0x23, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, 0x226, 0xa, 0x23, - 0x3, 0x23, 0x3, 0x23, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, 0x22c, 0xa, 0x23, - 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, 0x230, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, - 0x233, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, 0x236, 0xa, 0x23, 0x3, 0x23, - 0x3, 0x23, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, 0x23c, 0xa, 0x23, 0x3, 0x23, - 0x5, 0x23, 0x23f, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, 0x242, 0xa, 0x23, - 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, 0x246, 0xa, 0x23, 0x3, 0x23, 0x3, 0x23, - 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, 0x24c, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, - 0x24f, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, 0x252, 0xa, 0x23, 0x3, 0x23, - 0x3, 0x23, 0x5, 0x23, 0x256, 0xa, 0x23, 0x3, 0x24, 0x3, 0x24, 0x5, 0x24, - 0x25a, 0xa, 0x24, 0x3, 0x24, 0x5, 0x24, 0x25d, 0xa, 0x24, 0x3, 0x24, - 0x5, 0x24, 0x260, 0xa, 0x24, 0x3, 0x24, 0x5, 0x24, 0x263, 0xa, 0x24, - 0x3, 0x24, 0x5, 0x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, 0x34, 0x312, 0xa, 0x34, 0x3, 0x34, 0x3, 0x34, 0x5, 0x34, 0x316, - 0xa, 0x34, 0x3, 0x34, 0x7, 0x34, 0x319, 0xa, 0x34, 0xc, 0x34, 0xe, 0x34, - 0x31c, 0xb, 0x34, 0x3, 0x35, 0x3, 0x35, 0x5, 0x35, 0x320, 0xa, 0x35, - 0x7, 0x35, 0x322, 0xa, 0x35, 0xc, 0x35, 0xe, 0x35, 0x325, 0xb, 0x35, - 0x3, 0x35, 0x3, 0x35, 0x3, 0x36, 0x3, 0x36, 0x5, 0x36, 0x32b, 0xa, 0x36, - 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x5, 0x36, 0x332, - 0xa, 0x36, 0x3, 0x36, 0x3, 0x36, 0x5, 0x36, 0x336, 0xa, 0x36, 0x3, 0x36, - 0x3, 0x36, 0x5, 0x36, 0x33a, 0xa, 0x36, 0x3, 0x36, 0x3, 0x36, 0x5, 0x36, - 0x33e, 0xa, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, - 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, - 0x36, 0x3, 0x36, 0x5, 0x36, 0x34d, 0xa, 0x36, 0x3, 0x36, 0x5, 0x36, - 0x350, 0xa, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, - 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x7, - 0x36, 0x35d, 0xa, 0x36, 0xc, 0x36, 0xe, 0x36, 0x360, 0xb, 0x36, 0x3, - 0x37, 0x3, 0x37, 0x3, 0x37, 0x7, 0x37, 0x365, 0xa, 0x37, 0xc, 0x37, - 0xe, 0x37, 0x368, 0xb, 0x37, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, - 0x5, 0x38, 0x36e, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x372, - 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x376, 0xa, 0x38, 0x3, 0x38, - 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x37c, 0xa, 0x38, 0x3, 0x38, - 0x3, 0x38, 0x5, 0x38, 0x380, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, - 0x384, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, - 0x38a, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x38e, 0xa, 0x38, - 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x392, 0xa, 0x38, 0x3, 0x38, 0x5, 0x38, - 0x395, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x399, 0xa, 0x38, - 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x39f, 0xa, 0x38, - 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x3a3, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, - 0x5, 0x38, 0x3a7, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, - 0x5, 0x38, 0x3ad, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x3b1, - 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x3b5, 0xa, 0x38, 0x3, 0x38, - 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x3bb, 0xa, 0x38, 0x3, 0x38, - 0x3, 0x38, 0x5, 0x38, 0x3bf, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, - 0x3c3, 0xa, 0x38, 0x3, 0x38, 0x3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x3, 0x43, 0x3, 0x43, 0x5, 0x43, 0x472, - 0xa, 0x43, 0x3, 0x43, 0x5, 0x43, 0x475, 0xa, 0x43, 0x3, 0x43, 0x5, 0x43, - 0x478, 0xa, 0x43, 0x3, 0x43, 0x3, 0x43, 0x3, 0x44, 0x5, 0x44, 0x47d, - 0xa, 0x44, 0x3, 0x44, 0x3, 0x44, 0x5, 0x44, 0x481, 0xa, 0x44, 0x3, 0x44, - 0x3, 0x44, 0x3, 0x44, 0x3, 0x44, 0x5, 0x44, 0x487, 0xa, 0x44, 0x3, 0x45, - 0x3, 0x45, 0x3, 0x46, 0x3, 0x46, 0x5, 0x46, 0x48d, 0xa, 0x46, 0x3, 0x47, - 0x3, 0x47, 0x5, 0x47, 0x491, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, 0x47, - 0x495, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, 0x47, 0x499, 0xa, 0x47, - 0x3, 0x47, 0x3, 0x47, 0x5, 0x47, 0x49d, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, - 0x5, 0x47, 0x4a1, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, 0x47, 0x4a5, - 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, 0x47, 0x4a9, 0xa, 0x47, 0x3, 0x47, - 0x3, 0x47, 0x5, 0x47, 0x4ad, 0xa, 0x47, 0x7, 0x47, 0x4af, 0xa, 0x47, - 0xc, 0x47, 0xe, 0x47, 0x4b2, 0xb, 0x47, 0x5, 0x47, 0x4b4, 0xa, 0x47, - 0x3, 0x47, 0x3, 0x47, 0x3, 0x48, 0x3, 0x48, 0x3, 0x48, 0x5, 0x48, 0x4bb, - 0xa, 0x48, 0x3, 0x49, 0x3, 0x49, 0x5, 0x49, 0x4bf, 0xa, 0x49, 0x3, 0x49, - 0x6, 0x49, 0x4c2, 0xa, 0x49, 0xd, 0x49, 0xe, 0x49, 0x4c3, 0x3, 0x4a, - 0x3,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 0x2, 0xfb, 0x100, - 0x5, 0x3a, 0x1e, 0x2, 0xfc, 0xfd, 0x7, 0x71, 0x2, 0x2, 0xfd, 0xff, 0x5, - 0x16, 0xc, 0x2, 0xfe, 0xfc, 0x3, 0x2, 0x2, 0x2, 0xff, 0x102, 0x3, 0x2, - 0x2, 0x2, 0x100, 0xfe, 0x3, 0x2, 0x2, 0x2, 0x100, 0x101, 0x3, 0x2, 0x2, - 0x2, 0x101, 0x15, 0x3, 0x2, 0x2, 0x2, 0x102, 0x100, 0x3, 0x2, 0x2, 0x2, - 0x103, 0x104, 0x7, 0x49, 0x2, 0x2, 0x104, 0x105, 0x7, 0x71, 0x2, 0x2, - 0x105, 0x106, 0x7, 0x45, 0x2, 0x2, 0x106, 0x107, 0x7, 0x71, 0x2, 0x2, - 0x107, 0x10e, 0x5, 0x1a, 0xe, 0x2, 0x108, 0x109, 0x7, 0x49, 0x2, 0x2, - 0x109, 0x10a, 0x7, 0x71, 0x2, 0x2, 0x10a, 0x10b, 0x7, 0x4a, 0x2, 0x2, - 0x10b, 0x10c, 0x7, 0x71, 0x2, 0x2, 0x10c, 0x10e, 0x5, 0x1a, 0xe, 0x2, - 0x10d, 0x103, 0x3, 0x2, 0x2, 0x2, 0x10d, 0x108, 0x3, 0x2, 0x2, 0x2, - 0x10e, 0x17, 0x3, 0x2, 0x2, 0x2, 0x10f, 0x111, 0x7, 0x4a, 0x2, 0x2, - 0x110, 0x112, 0x7, 0x71, 0x2, 0x2, 0x111, 0x110, 0x3, 0x2, 0x2, 0x2, - 0x111, 0x112, 0x3, 0x2, 0x2, 0x2, 0x112, 0x113, 0x3, 0x2, 0x2, 0x2, - 0x113, 0x114, 0x5, 0x38, 0x1d, 0x2, 0x114, 0x19, 0x3, 0x2, 0x2, 0x2, - 0x115, 0x116, 0x7, 0x4b, 0x2, 0x2, 0x116, 0x11b, 0x5, 0x1c, 0xf, 0x2, - 0x117, 0x118, 0x7, 0x4, 0x2, 0x2, 0x118, 0x11a, 0x5, 0x1c, 0xf, 0x2, - 0x119, 0x117, 0x3, 0x2, 0x2, 0x2, 0x11a, 0x11d, 0x3, 0x2, 0x2, 0x2, - 0x11b, 0x119, 0x3, 0x2, 0x2, 0x2, 0x11b, 0x11c, 0x3, 0x2, 0x2, 0x2, - 0x11c, 0x1b, 0x3, 0x2, 0x2, 0x2, 0x11d, 0x11b, 0x3, 0x2, 0x2, 0x2, 0x11e, - 0x11f, 0x5, 0x90, 0x49, 0x2, 0x11f, 0x120, 0x7, 0x5, 0x2, 0x2, 0x120, - 0x121, 0x5, 0x56, 0x2c, 0x2, 0x121, 0x12e, 0x3, 0x2, 0x2, 0x2, 0x122, - 0x123, 0x5, 0x88, 0x45, 0x2, 0x123, 0x124, 0x7, 0x5, 0x2, 0x2, 0x124, - 0x125, 0x5, 0x56, 0x2c, 0x2, 0x125, 0x12e, 0x3, 0x2, 0x2, 0x2, 0x126, - 0x127, 0x5, 0x88, 0x45, 0x2, 0x127, 0x128, 0x7, 0x6, 0x2, 0x2, 0x128, - 0x129, 0x5, 0x56, 0x2c, 0x2, 0x129, 0x12e, 0x3, 0x2, 0x2, 0x2, 0x12a, - 0x12b, 0x5, 0x88, 0x45, 0x2, 0x12b, 0x12c, 0x5, 0x4c, 0x27, 0x2, 0x12c, - 0x12e, 0x3, 0x2, 0x2, 0x2, 0x12d, 0x11e, 0x3, 0x2, 0x2, 0x2, 0x12d, - 0x122, 0x3, 0x2, 0x2, 0x2, 0x12d, 0x126, 0x3, 0x2, 0x2, 0x2, 0x12d, - 0x12a, 0x3, 0x2, 0x2, 0x2, 0x12e, 0x1d, 0x3, 0x2, 0x2, 0x2, 0x12f, 0x130, - 0x7, 0x4c, 0x2, 0x2, 0x130, 0x132, 0x7, 0x71, 0x2, 0x2, 0x131, 0x12f, - 0x3, 0x2, 0x2, 0x2, 0x131, 0x132, 0x3, 0x2, 0x2, 0x2, 0x132, 0x133, - 0x3, 0x2, 0x2, 0x2, 0x133, 0x135, 0x7, 0x4d, 0x2, 0x2, 0x134, 0x136, - 0x7, 0x71, 0x2, 0x2, 0x135, 0x134, 0x3, 0x2, 0x2, 0x2, 0x135, 0x136, - 0x3, 0x2, 0x2, 0x2, 0x136, 0x137, 0x3, 0x2, 0x2, 0x2, 0x137, 0x142, - 0x5, 0x56, 0x2c, 0x2, 0x138, 0x13a, 0x7, 0x71, 0x2, 0x2, 0x139, 0x138, - 0x3, 0x2, 0x2, 0x2, 0x139, 0x13a, 0x3, 0x2, 0x2, 0x2, 0x13a, 0x13b, - 0x3, 0x2, 0x2, 0x2, 0x13b, 0x13d, 0x7, 0x4, 0x2, 0x2, 0x13c, 0x13e, - 0x7, 0x71, 0x2, 0x2, 0x13d, 0x13c, 0x3, 0x2, 0x2, 0x2, 0x13d, 0x13e, - 0x3, 0x2, 0x2, 0x2, 0x13e, 0x13f, 0x3, 0x2, 0x2, 0x2, 0x13f, 0x141, - 0x5, 0x56, 0x2c, 0x2, 0x140, 0x139, 0x3, 0x2, 0x2, 0x2, 0x141, 0x144, - 0x3, 0x2, 0x2, 0x2, 0x142, 0x140, 0x3, 0x2, 0x2, 0x2, 0x142, 0x143, - 0x3, 0x2, 0x2, 0x2, 0x143, 0x1f, 0x3, 0x2, 0x2, 0x2, 0x144, 0x142, 0x3, - 0x2, 0x2, 0x2, 0x145, 0x146, 0x7, 0x4e, 0x2, 0x2, 0x146, 0x147, 0x7, - 0x71, 0x2, 0x2, 0x147, 0x152, 0x5, 0x22, 0x12, 0x2, 0x148, 0x14a, 0x7, - 0x71, 0x2, 0x2, 0x149, 0x148, 0x3, 0x2, 0x2, 0x2, 0x149, 0x14a, 0x3, - 0x2, 0x2, 0x2, 0x14a, 0x14b, 0x3, 0x2, 0x2, 0x2, 0x14b, 0x14d, 0x7, - 0x4, 0x2, 0x2, 0x14c, 0x14e, 0x7, 0x71, 0x2, 0x2, 0x14d, 0x14c, 0x3, - 0x2, 0x2, 0x2, 0x14d, 0x14e, 0x3, 0x2, 0x2, 0x2, 0x14e, 0x14f, 0x3, - 0x2, 0x2, 0x2, 0x14f, 0x151, 0x5, 0x22, 0x12, 0x2, 0x150, 0x149, 0x3, - 0x2, 0x2, 0x2, 0x151, 0x154, 0x3, 0x2, 0x2, 0x2, 0x152, 0x150, 0x3, - 0x2, 0x2, 0x2, 0x152, 0x153, 0x3, 0x2, 0x2, 0x2, 0x153, 0x21, 0x3, 0x2, - 0x2, 0x2, 0x154, 0x152, 0x3, 0x2, 0x2, 0x2, 0x155, 0x156, 0x5, 0x88, - 0x45, 0x2, 0x156, 0x157, 0x5, 0x4c, 0x27, 0x2, 0x157, 0x15a, 0x3, 0x2, - 0x2, 0x2, 0x158, 0x15a, 0x5, 0x90, 0x49, 0x2, 0x159, 0x155, 0x3, 0x2, - 0x2, 0x2, 0x159, 0x158, 0x3, 0x2, 0x2, 0x2, 0x15a, 0x23, 0x3, 0x2, 0x2, - 0x2, 0x15b, 0x160, 0x7, 0x4f, 0x2, 0x2, 0x15c, 0x15e, 0x7, 0x71, 0x2, - 0x2, 0x15d, 0x15c, 0x3, 0x2, 0x2, 0x2, 0x15d, 0x15e, 0x3, 0x2, 0x2, - 0x2, 0x15e, 0x15f, 0x3, 0x2, 0x2, 0x2, 0x15f, 0x161, 0x7, 0x50, 0x2, - 0x2, 0x160, 0x15d, 0x3, 0x2, 0x2, 0x2, 0x160, 0x161, 0x3, 0x2, 0x2, - 0x2, 0x161, 0x162, 0x3, 0x2, 0x2, 0x2, 0x162, 0x163, 0x7, 0x71, 0x2, - 0x2, 0x163, 0x168, 0x5, 0x28, 0x15, 0x2, 0x164, 0x166, 0x7, 0x71, 0x2, - 0x2, 0x165, 0x164, 0x3, 0x2, 0x2, 0x2, 0x165, 0x166, 0x3, 0x2, 0x2, - 0x2, 0x166, 0x167, 0x3, 0x2, 0x2, 0x2, 0x167, 0x169, 0x5, 0x36, 0x1c, - 0x2, 0x168, 0x165, 0x3, 0x2, 0x2, 0x2, 0x168, 0x169, 0x3, 0x2, 0x2, - 0x2, 0x169, 0x25, 0x3, 0x2, 0x2, 0x2, 0x16a, 0x16f, 0x7, 0x51, 0x2, - 0x2, 0x16b, 0x16d, 0x7, 0x71, 0x2, 0x2, 0x16c, 0x16b, 0x3, 0x2, 0x2, - 0x2, 0x16c, 0x16d, 0x3, 0x2, 0x2, 0x2, 0x16d, 0x16e, 0x3, 0x2, 0x2, - 0x2, 0x16e, 0x170, 0x7, 0x50, 0x2, 0x2, 0x16f, 0x16c, 0x3, 0x2, 0x2, - 0x2, 0x16f, 0x170, 0x3, 0x2, 0x2, 0x2, 0x170, 0x171, 0x3, 0x2, 0x2, - 0x2, 0x171, 0x172, 0x7, 0x71, 0x2, 0x2, 0x172, 0x173, 0x5, 0x28, 0x15, - 0x2, 0x173, 0x27, 0x3, 0x2, 0x2, 0x2, 0x174, 0x177, 0x5, 0x2a, 0x16, - 0x2, 0x175, 0x176, 0x7, 0x71, 0x2, 0x2, 0x176, 0x178, 0x5, 0x2e, 0x18, - 0x2, 0x177, 0x175, 0x3, 0x2, 0x2, 0x2, 0x177, 0x178, 0x3, 0x2, 0x2, - 0x2, 0x178, 0x17b, 0x3, 0x2, 0x2, 0x2, 0x179, 0x17a, 0x7, 0x71, 0x2, - 0x2, 0x17a, 0x17c, 0x5, 0x30, 0x19, 0x2, 0x17b, 0x179, 0x3, 0x2, 0x2, - 0x2, 0x17b, 0x17c, 0x3, 0x2, 0x2, 0x2, 0x17c, 0x17f, 0x3, 0x2, 0x2, - 0x2, 0x17d, 0x17e, 0x7, 0x71, 0x2, 0x2, 0x17e, 0x180, 0x5, 0x32, 0x1a, - 0x2, 0x17f, 0x17d, 0x3, 0x2, 0x2, 0x2, 0x17f, 0x180, 0x3, 0x2, 0x2, - 0x2, 0x180, 0x29, 0x3, 0x2, 0x2, 0x2, 0x181, 0x18c, 0x7, 0x7, 0x2, 0x2, - 0x182, 0x184, 0x7, 0x71, 0x2, 0x2, 0x183, 0x182, 0x3, 0x2, 0x2, 0x2, - 0x183, 0x184, 0x3, 0x2, 0x2, 0x2, 0x184, 0x185, 0x3, 0x2, 0x2, 0x2, - 0x185, 0x187, 0x7, 0x4, 0x2, 0x2, 0x186, 0x188, 0x7, 0x71, 0x2, 0x2, - 0x187, 0x186, 0x3, 0x2, 0x2, 0x2, 0x187, 0x188, 0x3, 0x2, 0x2, 0x2, - 0x188, 0x189, 0x3, 0x2, 0x2, 0x2, 0x189, 0x18b, 0x5, 0x2c, 0x17, 0x2, - 0x18a, 0x183, 0x3, 0x2, 0x2, 0x2, 0x18b, 0x18e, 0x3, 0x2, 0x2, 0x2, - 0x18c, 0x18a, 0x3, 0x2, 0x2, 0x2, 0x18c, 0x18d, 0x3, 0x2, 0x2, 0x2, - 0x18d, 0x19e, 0x3, 0x2, 0x2, 0x2, 0x18e, 0x18c, 0x3, 0x2, 0x2, 0x2, - 0x18f, 0x19a, 0x5, 0x2c, 0x17, 0x2, 0x190, 0x192, 0x7, 0x71, 0x2, 0x2, - 0x191, 0x190, 0x3, 0x2, 0x2, 0x2, 0x191, 0x192, 0x3, 0x2, 0x2, 0x2, - 0x192, 0x193, 0x3, 0x2, 0x2, 0x2, 0x193, 0x195, 0x7, 0x4, 0x2, 0x2, - 0x194, 0x196, 0x7, 0x71, 0x2, 0x2, 0x195, 0x194, 0x3, 0x2, 0x2, 0x2, - 0x195, 0x196, 0x3, 0x2, 0x2, 0x2, 0x196, 0x197, 0x3, 0x2, 0x2, 0x2, - 0x197, 0x199, 0x5, 0x2c, 0x17, 0x2, 0x198, 0x191, 0x3, 0x2, 0x2, 0x2, - 0x199, 0x19c, 0x3, 0x2, 0x2, 0x2, 0x19a, 0x198, 0x3, 0x2, 0x2, 0x2, - 0x19a, 0x19b, 0x3, 0x2, 0x2, 0x2, 0x19b, 0x19e, 0x3, 0x2, 0x2, 0x2, - 0x19c, 0x19a, 0x3, 0x2, 0x2, 0x2, 0x19d, 0x181, 0x3, 0x2, 0x2, 0x2, - 0x19d, 0x18f, 0x3, 0x2, 0x2, 0x2, 0x19e, 0x2b,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206, 0x3, 0x2, 0x2, 0x2, 0x205, 0x201, 0x3, 0x2, 0x2, 0x2, 0x205, - 0x206, 0x3, 0x2, 0x2, 0x2, 0x206, 0x20b, 0x3, 0x2, 0x2, 0x2, 0x207, - 0x209, 0x5, 0x48, 0x25, 0x2, 0x208, 0x20a, 0x7, 0x71, 0x2, 0x2, 0x209, - 0x208, 0x3, 0x2, 0x2, 0x2, 0x209, 0x20a, 0x3, 0x2, 0x2, 0x2, 0x20a, - 0x20c, 0x3, 0x2, 0x2, 0x2, 0x20b, 0x207, 0x3, 0x2, 0x2, 0x2, 0x20b, - 0x20c, 0x3, 0x2, 0x2, 0x2, 0x20c, 0x20d, 0x3, 0x2, 0x2, 0x2, 0x20d, - 0x20e, 0x7, 0x9, 0x2, 0x2, 0x20e, 0x41, 0x3, 0x2, 0x2, 0x2, 0x20f, 0x211, - 0x5, 0x44, 0x23, 0x2, 0x210, 0x212, 0x7, 0x71, 0x2, 0x2, 0x211, 0x210, - 0x3, 0x2, 0x2, 0x2, 0x211, 0x212, 0x3, 0x2, 0x2, 0x2, 0x212, 0x213, - 0x3, 0x2, 0x2, 0x2, 0x213, 0x214, 0x5, 0x40, 0x21, 0x2, 0x214, 0x43, - 0x3, 0x2, 0x2, 0x2, 0x215, 0x217, 0x5, 0x9a, 0x4e, 0x2, 0x216, 0x218, - 0x7, 0x71, 0x2, 0x2, 0x217, 0x216, 0x3, 0x2, 0x2, 0x2, 0x217, 0x218, - 0x3, 0x2, 0x2, 0x2, 0x218, 0x219, 0x3, 0x2, 0x2, 0x2, 0x219, 0x21b, - 0x5, 0x9e, 0x50, 0x2, 0x21a, 0x21c, 0x7, 0x71, 0x2, 0x2, 0x21b, 0x21a, - 0x3, 0x2, 0x2, 0x2, 0x21b, 0x21c, 0x3, 0x2, 0x2, 0x2, 0x21c, 0x21e, - 0x3, 0x2, 0x2, 0x2, 0x21d, 0x21f, 0x5, 0x46, 0x24, 0x2, 0x21e, 0x21d, - 0x3, 0x2, 0x2, 0x2, 0x21e, 0x21f, 0x3, 0x2, 0x2, 0x2, 0x21f, 0x221, - 0x3, 0x2, 0x2, 0x2, 0x220, 0x222, 0x7, 0x71, 0x2, 0x2, 0x221, 0x220, - 0x3, 0x2, 0x2, 0x2, 0x221, 0x222, 0x3, 0x2, 0x2, 0x2, 0x222, 0x223, - 0x3, 0x2, 0x2, 0x2, 0x223, 0x225, 0x5, 0x9e, 0x50, 0x2, 0x224, 0x226, - 0x7, 0x71, 0x2, 0x2, 0x225, 0x224, 0x3, 0x2, 0x2, 0x2, 0x225, 0x226, - 0x3, 0x2, 0x2, 0x2, 0x226, 0x227, 0x3, 0x2, 0x2, 0x2, 0x227, 0x228, - 0x5, 0x9c, 0x4f, 0x2, 0x228, 0x256, 0x3, 0x2, 0x2, 0x2, 0x229, 0x22b, - 0x5, 0x9a, 0x4e, 0x2, 0x22a, 0x22c, 0x7, 0x71, 0x2, 0x2, 0x22b, 0x22a, - 0x3, 0x2, 0x2, 0x2, 0x22b, 0x22c, 0x3, 0x2, 0x2, 0x2, 0x22c, 0x22d, - 0x3, 0x2, 0x2, 0x2, 0x22d, 0x22f, 0x5, 0x9e, 0x50, 0x2, 0x22e, 0x230, - 0x7, 0x71, 0x2, 0x2, 0x22f, 0x22e, 0x3, 0x2, 0x2, 0x2, 0x22f, 0x230, - 0x3, 0x2, 0x2, 0x2, 0x230, 0x232, 0x3, 0x2, 0x2, 0x2, 0x231, 0x233, - 0x5, 0x46, 0x24, 0x2, 0x232, 0x231, 0x3, 0x2, 0x2, 0x2, 0x232, 0x233, - 0x3, 0x2, 0x2, 0x2, 0x233, 0x235, 0x3, 0x2, 0x2, 0x2, 0x234, 0x236, - 0x7, 0x71, 0x2, 0x2, 0x235, 0x234, 0x3, 0x2, 0x2, 0x2, 0x235, 0x236, - 0x3, 0x2, 0x2, 0x2, 0x236, 0x237, 0x3, 0x2, 0x2, 0x2, 0x237, 0x238, - 0x5, 0x9e, 0x50, 0x2, 0x238, 0x256, 0x3, 0x2, 0x2, 0x2, 0x239, 0x23b, - 0x5, 0x9e, 0x50, 0x2, 0x23a, 0x23c, 0x7, 0x71, 0x2, 0x2, 0x23b, 0x23a, - 0x3, 0x2, 0x2, 0x2, 0x23b, 0x23c, 0x3, 0x2, 0x2, 0x2, 0x23c, 0x23e, - 0x3, 0x2, 0x2, 0x2, 0x23d, 0x23f, 0x5, 0x46, 0x24, 0x2, 0x23e, 0x23d, - 0x3, 0x2, 0x2, 0x2, 0x23e, 0x23f, 0x3, 0x2, 0x2, 0x2, 0x23f, 0x241, - 0x3, 0x2, 0x2, 0x2, 0x240, 0x242, 0x7, 0x71, 0x2, 0x2, 0x241, 0x240, - 0x3, 0x2, 0x2, 0x2, 0x241, 0x242, 0x3, 0x2, 0x2, 0x2, 0x242, 0x243, - 0x3, 0x2, 0x2, 0x2, 0x243, 0x245, 0x5, 0x9e, 0x50, 0x2, 0x244, 0x246, - 0x7, 0x71, 0x2, 0x2, 0x245, 0x244, 0x3, 0x2, 0x2, 0x2, 0x245, 0x246, - 0x3, 0x2, 0x2, 0x2, 0x246, 0x247, 0x3, 0x2, 0x2, 0x2, 0x247, 0x248, - 0x5, 0x9c, 0x4f, 0x2, 0x248, 0x256, 0x3, 0x2, 0x2, 0x2, 0x249, 0x24b, - 0x5, 0x9e, 0x50, 0x2, 0x24a, 0x24c, 0x7, 0x71, 0x2, 0x2, 0x24b, 0x24a, - 0x3, 0x2, 0x2, 0x2, 0x24b, 0x24c, 0x3, 0x2, 0x2, 0x2, 0x24c, 0x24e, - 0x3, 0x2, 0x2, 0x2, 0x24d, 0x24f, 0x5, 0x46, 0x24, 0x2, 0x24e, 0x24d, - 0x3, 0x2, 0x2, 0x2, 0x24e, 0x24f, 0x3, 0x2, 0x2, 0x2, 0x24f, 0x251, - 0x3, 0x2, 0x2, 0x2, 0x250, 0x252, 0x7, 0x71, 0x2, 0x2, 0x251, 0x250, - 0x3, 0x2, 0x2, 0x2, 0x251, 0x252, 0x3, 0x2, 0x2, 0x2, 0x252, 0x253, - 0x3, 0x2, 0x2, 0x2, 0x253, 0x254, 0x5, 0x9e, 0x50, 0x2, 0x254, 0x256, - 0x3, 0x2, 0x2, 0x2, 0x255, 0x215, 0x3, 0x2, 0x2, 0x2, 0x255, 0x229, - 0x3, 0x2, 0x2, 0x2, 0x255, 0x239, 0x3, 0x2, 0x2, 0x2, 0x255, 0x249, - 0x3, 0x2, 0x2, 0x2, 0x256, 0x45, 0x3, 0x2, 0x2, 0x2, 0x257, 0x259, 0x7, - 0xa, 0x2, 0x2, 0x258, 0x25a, 0x5, 0x88, 0x45, 0x2, 0x259, 0x258, 0x3, - 0x2, 0x2, 0x2, 0x259, 0x25a, 0x3, 0x2, 0x2, 0x2, 0x25a, 0x25c, 0x3, - 0x2, 0x2, 0x2, 0x25b, 0x25d, 0x7, 0xb, 0x2, 0x2, 0x25c, 0x25b, 0x3, - 0x2, 0x2, 0x2, 0x25c, 0x25d, 0x3, 0x2, 0x2, 0x2, 0x25d, 0x25f, 0x3, - 0x2, 0x2, 0x2, 0x25e, 0x260, 0x5, 0x4a, 0x26, 0x2, 0x25f, 0x25e, 0x3, - 0x2, 0x2, 0x2, 0x25f, 0x260, 0x3, 0x2, 0x2, 0x2, 0x260, 0x262, 0x3, - 0x2, 0x2, 0x2, 0x261, 0x263, 0x5, 0x50, 0x29, 0x2, 0x262, 0x261, 0x3, - 0x2, 0x2, 0x2, 0x262, 0x263, 0x3, 0x2, 0x2, 0x2, 0x263, 0x265, 0x3, - 0x2, 0x2, 0x2, 0x264, 0x266, 0x5, 0x48, 0x25, 0x2, 0x265, 0x264, 0x3, - 0x2, 0x2, 0x2, 0x265, 0x266, 0x3, 0x2, 0x2, 0x2, 0x266, 0x267, 0x3, - 0x2, 0x2, 0x2, 0x267, 0x268, 0x7, 0xc, 0x2, 0x2, 0x268, 0x47, 0x3, 0x2, - 0x2, 0x2, 0x269, 0x26c, 0x5, 0x8c, 0x47, 0x2, 0x26a, 0x26c, 0x5, 0x8e, - 0x48, 0x2, 0x26b, 0x269, 0x3, 0x2, 0x2, 0x2, 0x26b, 0x26a, 0x3, 0x2, - 0x2, 0x2, 0x26c, 0x49, 0x3, 0x2, 0x2, 0x2, 0x26d, 0x26e, 0x7, 0xd, 0x2, - 0x2, 0x26e, 0x27c, 0x5, 0x54, 0x2b, 0x2, 0x26f, 0x271, 0x7, 0x71, 0x2, - 0x2, 0x270, 0x26f, 0x3, 0x2, 0x2, 0x2, 0x270, 0x271, 0x3, 0x2, 0x2, - 0x2, 0x271, 0x272, 0x3, 0x2, 0x2, 0x2, 0x272, 0x274, 0x7, 0xe, 0x2, - 0x2, 0x273, 0x275, 0x7, 0xd, 0x2, 0x2, 0x274, 0x273, 0x3, 0x2, 0x2, - 0x2, 0x274, 0x275, 0x3, 0x2, 0x2, 0x2, 0x275, 0x277, 0x3, 0x2, 0x2, - 0x2, 0x276, 0x278, 0x7, 0x71, 0x2, 0x2, 0x277, 0x276, 0x3, 0x2, 0x2, - 0x2, 0x277, 0x278, 0x3, 0x2, 0x2, 0x2, 0x278, 0x279, 0x3, 0x2, 0x2, - 0x2, 0x279, 0x27b, 0x5, 0x54, 0x2b, 0x2, 0x27a, 0x270, 0x3, 0x2, 0x2, - 0x2, 0x27b, 0x27e, 0x3, 0x2, 0x2, 0x2, 0x27c, 0x27a, 0x3, 0x2, 0x2, - 0x2, 0x27c, 0x27d, 0x3, 0x2, 0x2, 0x2, 0x27d, 0x4b, 0x3, 0x2, 0x2, 0x2, - 0x27e, 0x27c, 0x3, 0x2, 0x2, 0x2, 0x27f, 0x286, 0x5, 0x4e, 0x28, 0x2, - 0x280, 0x282, 0x7, 0x71, 0x2, 0x2, 0x281, 0x280, 0x3, 0x2, 0x2, 0x2, - 0x281, 0x282, 0x3, 0x2, 0x2, 0x2, 0x282, 0x283, 0x3, 0x2, 0x2, 0x2, - 0x283, 0x285, 0x5, 0x4e, 0x28, 0x2, 0x284, 0x281, 0x3, 0x2, 0x2, 0x2, - 0x285, 0x288, 0x3, 0x2, 0x2, 0x2, 0x286, 0x284, 0x3, 0x2, 0x2, 0x2, - 0x286, 0x287, 0x3, 0x2, 0x2, 0x2, 0x287, 0x4d, 0x3, 0x2, 0x2, 0x2, 0x288, - 0x286, 0x3, 0x2, 0x2, 0x2, 0x289, 0x28a, 0x7, 0xd, 0x2, 0x2, 0x28a, - 0x28b, 0x5, 0x52, 0x2a, 0x2, 0x28b, 0x4f, 0x3, 0x2, 0x2, 0x2, 0x28c, - 0x28e, 0x7, 0x7, 0x2, 0x2, 0x28d, 0x28f, 0x7, 0x71, 0x2, 0x2, 0x28e, - 0x28d, 0x3, 0x2, 0x2, 0x2, 0x28e, 0x28f, 0x3, 0x2, 0x2, 0x2, 0x28f, - 0x294, 0x3, 0x2, 0x2, 0x2, 0x290, 0x292, 0x5, 0x94, 0x4b, 0x2, 0x291, - 0x293, 0x7, 0x71, 0x2, 0x2, 0x292, 0x291, 0x3, 0x2, 0x2, 0x2, 0x292, - 0x293, 0x3, 0x2, 0x2, 0x2, 0x293, 0x295, 0x3, 0x2, 0x2, 0x2, 0x294, - 0x290, 0x3, 0x2, 0x2, 0x2, 0x294, 0x295, 0x3, 0x2, 0x2, 0x2, 0x295, - 0x2a0, 0x3, 0x2, 0x2, 0x2, 0x296, 0x298, 0x7, 0xf, 0x2, 0x2, 0x297, - 0x299, 0x7, 0x71, 0x2, 0x2, 0x298, 0x297, 0x3, 0x2, 0x2, 0x2, 0x298, - 0x299, 0x3, 0x2, 0x2, 0x2, 0x299, 0x29e, 0x3, 0x2, 0x2, 0x2, 0x29a, - 0x29c, 0x5, 0x94, 0x4b, 0x2, 0x29b, 0x29d, 0x7, 0x71, 0x2, 0x2, 0x29c, - 0x29b, 0x3, 0x2, 0x2, 0x2, 0x29c, 0x29d, 0x3, 0x2, 0x2, 0x2, 0x29d, - 0x29f, 0x3, 0x2, 0x2, 0x2, 0x29e, 0x29a, 0x3, 0x2, 0x2, 0x2, 0x29e, - 0x29f, 0x3, 0x2, 0x2, 0x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0x2, - 0x304, 0x305, 0x3, 0x2, 0x2, 0x2, 0x305, 0x307, 0x7, 0x13, 0x2, 0x2, - 0x306, 0x308, 0x7, 0x71, 0x2, 0x2, 0x307, 0x306, 0x3, 0x2, 0x2, 0x2, - 0x307, 0x308, 0x3, 0x2, 0x2, 0x2, 0x308, 0x309, 0x3, 0x2, 0x2, 0x2, - 0x309, 0x30b, 0x5, 0x66, 0x34, 0x2, 0x30a, 0x2f3, 0x3, 0x2, 0x2, 0x2, - 0x30a, 0x2fb, 0x3, 0x2, 0x2, 0x2, 0x30a, 0x303, 0x3, 0x2, 0x2, 0x2, - 0x30b, 0x30e, 0x3, 0x2, 0x2, 0x2, 0x30c, 0x30a, 0x3, 0x2, 0x2, 0x2, - 0x30c, 0x30d, 0x3, 0x2, 0x2, 0x2, 0x30d, 0x65, 0x3, 0x2, 0x2, 0x2, 0x30e, - 0x30c, 0x3, 0x2, 0x2, 0x2, 0x30f, 0x31a, 0x5, 0x68, 0x35, 0x2, 0x310, - 0x312, 0x7, 0x71, 0x2, 0x2, 0x311, 0x310, 0x3, 0x2, 0x2, 0x2, 0x311, - 0x312, 0x3, 0x2, 0x2, 0x2, 0x312, 0x313, 0x3, 0x2, 0x2, 0x2, 0x313, - 0x315, 0x7, 0x14, 0x2, 0x2, 0x314, 0x316, 0x7, 0x71, 0x2, 0x2, 0x315, - 0x314, 0x3, 0x2, 0x2, 0x2, 0x315, 0x316, 0x3, 0x2, 0x2, 0x2, 0x316, - 0x317, 0x3, 0x2, 0x2, 0x2, 0x317, 0x319, 0x5, 0x68, 0x35, 0x2, 0x318, - 0x311, 0x3, 0x2, 0x2, 0x2, 0x319, 0x31c, 0x3, 0x2, 0x2, 0x2, 0x31a, - 0x318, 0x3, 0x2, 0x2, 0x2, 0x31a, 0x31b, 0x3, 0x2, 0x2, 0x2, 0x31b, - 0x67, 0x3, 0x2, 0x2, 0x2, 0x31c, 0x31a, 0x3, 0x2, 0x2, 0x2, 0x31d, 0x31f, - 0x9, 0x3, 0x2, 0x2, 0x31e, 0x320, 0x7, 0x71, 0x2, 0x2, 0x31f, 0x31e, - 0x3, 0x2, 0x2, 0x2, 0x31f, 0x320, 0x3, 0x2, 0x2, 0x2, 0x320, 0x322, - 0x3, 0x2, 0x2, 0x2, 0x321, 0x31d, 0x3, 0x2, 0x2, 0x2, 0x322, 0x325, - 0x3, 0x2, 0x2, 0x2, 0x323, 0x321, 0x3, 0x2, 0x2, 0x2, 0x323, 0x324, - 0x3, 0x2, 0x2, 0x2, 0x324, 0x326, 0x3, 0x2, 0x2, 0x2, 0x325, 0x323, - 0x3, 0x2, 0x2, 0x2, 0x326, 0x327, 0x5, 0x6a, 0x36, 0x2, 0x327, 0x69, - 0x3, 0x2, 0x2, 0x2, 0x328, 0x35e, 0x5, 0x6c, 0x37, 0x2, 0x329, 0x32b, - 0x7, 0x71, 0x2, 0x2, 0x32a, 0x329, 0x3, 0x2, 0x2, 0x2, 0x32a, 0x32b, - 0x3, 0x2, 0x2, 0x2, 0x32b, 0x32c, 0x3, 0x2, 0x2, 0x2, 0x32c, 0x32d, - 0x7, 0xa, 0x2, 0x2, 0x32d, 0x32e, 0x5, 0x56, 0x2c, 0x2, 0x32e, 0x32f, - 0x7, 0xc, 0x2, 0x2, 0x32f, 0x35d, 0x3, 0x2, 0x2, 0x2, 0x330, 0x332, - 0x7, 0x71, 0x2, 0x2, 0x331, 0x330, 0x3, 0x2, 0x2, 0x2, 0x331, 0x332, - 0x3, 0x2, 0x2, 0x2, 0x332, 0x333, 0x3, 0x2, 0x2, 0x2, 0x333, 0x335, - 0x7, 0xa, 0x2, 0x2, 0x334, 0x336, 0x5, 0x56, 0x2c, 0x2, 0x335, 0x334, - 0x3, 0x2, 0x2, 0x2, 0x335, 0x336, 0x3, 0x2, 0x2, 0x2, 0x336, 0x337, - 0x3, 0x2, 0x2, 0x2, 0x337, 0x339, 0x7, 0xf, 0x2, 0x2, 0x338, 0x33a, - 0x5, 0x56, 0x2c, 0x2, 0x339, 0x338, 0x3, 0x2, 0x2, 0x2, 0x339, 0x33a, - 0x3, 0x2, 0x2, 0x2, 0x33a, 0x33b, 0x3, 0x2, 0x2, 0x2, 0x33b, 0x35d, - 0x7, 0xc, 0x2, 0x2, 0x33c, 0x33e, 0x7, 0x71, 0x2, 0x2, 0x33d, 0x33c, - 0x3, 0x2, 0x2, 0x2, 0x33d, 0x33e, 0x3, 0x2, 0x2, 0x2, 0x33e, 0x33f, - 0x3, 0x2, 0x2, 0x2, 0x33f, 0x34d, 0x7, 0x15, 0x2, 0x2, 0x340, 0x341, - 0x7, 0x71, 0x2, 0x2, 0x341, 0x34d, 0x7, 0x5f, 0x2, 0x2, 0x342, 0x343, - 0x7, 0x71, 0x2, 0x2, 0x343, 0x344, 0x7, 0x60, 0x2, 0x2, 0x344, 0x345, - 0x7, 0x71, 0x2, 0x2, 0x345, 0x34d, 0x7, 0x4f, 0x2, 0x2, 0x346, 0x347, - 0x7, 0x71, 0x2, 0x2, 0x347, 0x348, 0x7, 0x61, 0x2, 0x2, 0x348, 0x349, - 0x7, 0x71, 0x2, 0x2, 0x349, 0x34d, 0x7, 0x4f, 0x2, 0x2, 0x34a, 0x34b, - 0x7, 0x71, 0x2, 0x2, 0x34b, 0x34d, 0x7, 0x62, 0x2, 0x2, 0x34c, 0x33d, - 0x3, 0x2, 0x2, 0x2, 0x34c, 0x340, 0x3, 0x2, 0x2, 0x2, 0x34c, 0x342, - 0x3, 0x2, 0x2, 0x2, 0x34c, 0x346, 0x3, 0x2, 0x2, 0x2, 0x34c, 0x34a, - 0x3, 0x2, 0x2, 0x2, 0x34d, 0x34f, 0x3, 0x2, 0x2, 0x2, 0x34e, 0x350, - 0x7, 0x71, 0x2, 0x2, 0x34f, 0x34e, 0x3, 0x2, 0x2, 0x2, 0x34f, 0x350, - 0x3, 0x2, 0x2, 0x2, 0x350, 0x351, 0x3, 0x2, 0x2, 0x2, 0x351, 0x35d, - 0x5, 0x6c, 0x37, 0x2, 0x352, 0x353, 0x7, 0x71, 0x2, 0x2, 0x353, 0x354, - 0x7, 0x63, 0x2, 0x2, 0x354, 0x355, 0x7, 0x71, 0x2, 0x2, 0x355, 0x35d, - 0x7, 0x64, 0x2, 0x2, 0x356, 0x357, 0x7, 0x71, 0x2, 0x2, 0x357, 0x358, - 0x7, 0x63, 0x2, 0x2, 0x358, 0x359, 0x7, 0x71, 0x2, 0x2, 0x359, 0x35a, - 0x7, 0x5e, 0x2, 0x2, 0x35a, 0x35b, 0x7, 0x71, 0x2, 0x2, 0x35b, 0x35d, - 0x7, 0x64, 0x2, 0x2, 0x35c, 0x32a, 0x3, 0x2, 0x2, 0x2, 0x35c, 0x331, - 0x3, 0x2, 0x2, 0x2, 0x35c, 0x34c, 0x3, 0x2, 0x2, 0x2, 0x35c, 0x352, - 0x3, 0x2, 0x2, 0x2, 0x35c, 0x356, 0x3, 0x2, 0x2, 0x2, 0x35d, 0x360, - 0x3, 0x2, 0x2, 0x2, 0x35e, 0x35c, 0x3, 0x2, 0x2, 0x2, 0x35e, 0x35f, - 0x3, 0x2, 0x2, 0x2, 0x35f, 0x6b, 0x3, 0x2, 0x2, 0x2, 0x360, 0x35e, 0x3, - 0x2, 0x2, 0x2, 0x361, 0x366, 0x5, 0x6e, 0x38, 0x2, 0x362, 0x365, 0x5, - 0x86, 0x44, 0x2, 0x363, 0x365, 0x5, 0x4c, 0x27, 0x2, 0x364, 0x362, 0x3, - 0x2, 0x2, 0x2, 0x364, 0x363, 0x3, 0x2, 0x2, 0x2, 0x365, 0x368, 0x3, - 0x2, 0x2, 0x2, 0x366, 0x364, 0x3, 0x2, 0x2, 0x2, 0x366, 0x367, 0x3, - 0x2, 0x2, 0x2, 0x367, 0x6d, 0x3, 0x2, 0x2, 0x2, 0x368, 0x366, 0x3, 0x2, - 0x2, 0x2, 0x369, 0x3d9, 0x5, 0x70, 0x39, 0x2, 0x36a, 0x3d9, 0x5, 0x8e, - 0x48, 0x2, 0x36b, 0x36d, 0x7, 0x65, 0x2, 0x2, 0x36c, 0x36e, 0x7, 0x71, - 0x2, 0x2, 0x36d, 0x36c, 0x3, 0x2, 0x2, 0x2, 0x36d, 0x36e, 0x3, 0x2, - 0x2, 0x2, 0x36e, 0x36f, 0x3, 0x2, 0x2, 0x2, 0x36f, 0x371, 0x7, 0x8, - 0x2, 0x2, 0x370, 0x372, 0x7, 0x71, 0x2, 0x2, 0x371, 0x370, 0x3, 0x2, - 0x2, 0x2, 0x371, 0x372, 0x3, 0x2, 0x2, 0x2, 0x372, 0x373, 0x3, 0x2, - 0x2, 0x2, 0x373, 0x375, 0x7, 0x7, 0x2, 0x2, 0x374, 0x376, 0x7, 0x71, - 0x2, 0x2, 0x375, 0x374, 0x3, 0x2, 0x2, 0x2, 0x375, 0x376, 0x3, 0x2, - 0x2, 0x2, 0x376, 0x377, 0x3, 0x2, 0x2, 0x2, 0x377, 0x3d9, 0x7, 0x9, - 0x2, 0x2, 0x378, 0x3d9, 0x5, 0x84, 0x43, 0x2, 0x379, 0x37b, 0x7, 0x66, - 0x2, 0x2, 0x37a, 0x37c, 0x7, 0x71, 0x2, 0x2, 0x37b, 0x37a, 0x3, 0x2, - 0x2, 0x2, 0x37b, 0x37c, 0x3, 0x2, 0x2, 0x2, 0x37c, 0x37d, 0x3, 0x2, - 0x2, 0x2, 0x37d, 0x37f, 0x7, 0x8, 0x2, 0x2, 0x37e, 0x380, 0x7, 0x71, - 0x2, 0x2, 0x37f, 0x37e, 0x3, 0x2, 0x2, 0x2, 0x37f, 0x380, 0x3, 0x2, - 0x2, 0x2, 0x380, 0x381, 0x3, 0x2, 0x2, 0x2, 0x381, 0x383, 0x5, 0x7c, - 0x3f, 0x2, 0x382, 0x384, 0x7, 0x71, 0x2, 0x2, 0x383, 0x382, 0x3, 0x2, - 0x2, 0x2, 0x383, 0x384, 0x3, 0x2, 0x2, 0x2, 0x384, 0x385, 0x3, 0x2, - 0x2, 0x2, 0x385, 0x386, 0x7, 0x9, 0x2, 0x2, 0x386, 0x3d9, 0x3, 0x2, - 0x2, 0x2, 0x387, 0x389, 0x7, 0x67, 0x2, 0x2, 0x388, 0x38a, 0x7, 0x71, - 0x2, 0x2, 0x389, 0x388, 0x3, 0x2, 0x2, 0x2, 0x389, 0x38a, 0x3, 0x2, - 0x2, 0x2, 0x38a, 0x38b, 0x3, 0x2, 0x2, 0x2, 0x38b, 0x38d, 0x7, 0x8, - 0x2, 0x2, 0x38c, 0x38e, 0x7, 0x71, 0x2, 0x2, 0x38d, 0x38c, 0x3, 0x2, - 0x2, 0x2, 0x38d, 0x38e, 0x3, 0x2, 0x2, 0x2, 0x38e, 0x38f, 0x3, 0x2, - 0x2, 0x2, 0x38f, 0x391, 0x5, 0x7c, 0x3f, 0x2, 0x390, 0x392, 0x7, 0x71, - 0x2, 0x2, 0x391, 0x390, 0x3, 0x2, 0x2, 0x2, 0x391, 0x392, 0x3, 0x2, - 0x2, 0x2, 0x392, 0x398, 0x3, 0x2, 0x2, 0x2, 0x393, 0x395, 0x7, 0x71, - 0x2, 0x2, 0x394, 0x393, 0x3, 0x2, 0x2, 0x2, 0x394, 0x395, 0x3, 0x2, - 0x2, 0x2, 0x395, 0x396, 0x3, 0x2, 0x2, 0x2, 0x396, 0x397, 0x7, 0xe, - 0x2, 0x2, 0x397, 0x399, 0x5, 0x56, 0x2c, 0x2, 0x398, 0x394, 0x3, 0x2, - 0x2, 0x2, 0x398, 0x399, 0x3, 0x2, 0x2, 0x2, 0x399, 0x39a, 0x3, 0x2, - 0x2, 0x2, 0x39a, 0x39b, 0x7, 0x9, 0x2, 0x2, 0x39b, 0x3d9, 0x3, 0x2, - 0x2, 0x2, 0x39c, 0x39e, 0x7, 0x43, 0x2, 0x2, 0x39d, 0x39f, 0x7, 0x71, - 0x2, 0x2, 0x39e, 0x39d, 0x3, 0x2, 0x2, 0x2, 0x39e, 0x39f, 0x3, 0x2, - 0x2, 0x2, 0x39f, 0x3a0, 0x3, 0x2, 0x2, 0x2, 0x3a0, 0x3a2, 0x7, 0x8, - 0x2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62, 0x32, 0x2, 0x411, 0x413, 0x7, 0x19, 0x2, 0x2, 0x412, - 0x414, 0x7, 0x71, 0x2, 0x2, 0x413, 0x412, 0x3, 0x2, 0x2, 0x2, 0x413, - 0x414, 0x3, 0x2, 0x2, 0x2, 0x414, 0x415, 0x3, 0x2, 0x2, 0x2, 0x415, - 0x421, 0x5, 0x62, 0x32, 0x2, 0x416, 0x418, 0x7, 0x1a, 0x2, 0x2, 0x417, - 0x419, 0x7, 0x71, 0x2, 0x2, 0x418, 0x417, 0x3, 0x2, 0x2, 0x2, 0x418, - 0x419, 0x3, 0x2, 0x2, 0x2, 0x419, 0x41a, 0x3, 0x2, 0x2, 0x2, 0x41a, - 0x421, 0x5, 0x62, 0x32, 0x2, 0x41b, 0x41d, 0x7, 0x1b, 0x2, 0x2, 0x41c, - 0x41e, 0x7, 0x71, 0x2, 0x2, 0x41d, 0x41c, 0x3, 0x2, 0x2, 0x2, 0x41d, - 0x41e, 0x3, 0x2, 0x2, 0x2, 0x41e, 0x41f, 0x3, 0x2, 0x2, 0x2, 0x41f, - 0x421, 0x5, 0x62, 0x32, 0x2, 0x420, 0x3fd, 0x3, 0x2, 0x2, 0x2, 0x420, - 0x402, 0x3, 0x2, 0x2, 0x2, 0x420, 0x407, 0x3, 0x2, 0x2, 0x2, 0x420, - 0x40c, 0x3, 0x2, 0x2, 0x2, 0x420, 0x411, 0x3, 0x2, 0x2, 0x2, 0x420, - 0x416, 0x3, 0x2, 0x2, 0x2, 0x420, 0x41b, 0x3, 0x2, 0x2, 0x2, 0x421, - 0x77, 0x3, 0x2, 0x2, 0x2, 0x422, 0x424, 0x7, 0x8, 0x2, 0x2, 0x423, 0x425, - 0x7, 0x71, 0x2, 0x2, 0x424, 0x423, 0x3, 0x2, 0x2, 0x2, 0x424, 0x425, - 0x3, 0x2, 0x2, 0x2, 0x425, 0x426, 0x3, 0x2, 0x2, 0x2, 0x426, 0x428, - 0x5, 0x56, 0x2c, 0x2, 0x427, 0x429, 0x7, 0x71, 0x2, 0x2, 0x428, 0x427, - 0x3, 0x2, 0x2, 0x2, 0x428, 0x429, 0x3, 0x2, 0x2, 0x2, 0x429, 0x42a, - 0x3, 0x2, 0x2, 0x2, 0x42a, 0x42b, 0x7, 0x9, 0x2, 0x2, 0x42b, 0x79, 0x3, - 0x2, 0x2, 0x2, 0x42c, 0x431, 0x5, 0x40, 0x21, 0x2, 0x42d, 0x42f, 0x7, - 0x71, 0x2, 0x2, 0x42e, 0x42d, 0x3, 0x2, 0x2, 0x2, 0x42e, 0x42f, 0x3, - 0x2, 0x2, 0x2, 0x42f, 0x430, 0x3, 0x2, 0x2, 0x2, 0x430, 0x432, 0x5, - 0x42, 0x22, 0x2, 0x431, 0x42e, 0x3, 0x2, 0x2, 0x2, 0x432, 0x433, 0x3, - 0x2, 0x2, 0x2, 0x433, 0x431, 0x3, 0x2, 0x2, 0x2, 0x433, 0x434, 0x3, - 0x2, 0x2, 0x2, 0x434, 0x7b, 0x3, 0x2, 0x2, 0x2, 0x435, 0x43a, 0x5, 0x7e, - 0x40, 0x2, 0x436, 0x438, 0x7, 0x71, 0x2, 0x2, 0x437, 0x436, 0x3, 0x2, - 0x2, 0x2, 0x437, 0x438, 0x3, 0x2, 0x2, 0x2, 0x438, 0x439, 0x3, 0x2, - 0x2, 0x2, 0x439, 0x43b, 0x5, 0x36, 0x1c, 0x2, 0x43a, 0x437, 0x3, 0x2, - 0x2, 0x2, 0x43a, 0x43b, 0x3, 0x2, 0x2, 0x2, 0x43b, 0x7d, 0x3, 0x2, 0x2, - 0x2, 0x43c, 0x43d, 0x5, 0x88, 0x45, 0x2, 0x43d, 0x43e, 0x7, 0x71, 0x2, - 0x2, 0x43e, 0x43f, 0x7, 0x5f, 0x2, 0x2, 0x43f, 0x440, 0x7, 0x71, 0x2, - 0x2, 0x440, 0x441, 0x5, 0x56, 0x2c, 0x2, 0x441, 0x7f, 0x3, 0x2, 0x2, - 0x2, 0x442, 0x444, 0x5, 0x82, 0x42, 0x2, 0x443, 0x445, 0x7, 0x71, 0x2, - 0x2, 0x444, 0x443, 0x3, 0x2, 0x2, 0x2, 0x444, 0x445, 0x3, 0x2, 0x2, - 0x2, 0x445, 0x446, 0x3, 0x2, 0x2, 0x2, 0x446, 0x448, 0x7, 0x8, 0x2, - 0x2, 0x447, 0x449, 0x7, 0x71, 0x2, 0x2, 0x448, 0x447, 0x3, 0x2, 0x2, - 0x2, 0x448, 0x449, 0x3, 0x2, 0x2, 0x2, 0x449, 0x44e, 0x3, 0x2, 0x2, - 0x2, 0x44a, 0x44c, 0x7, 0x50, 0x2, 0x2, 0x44b, 0x44d, 0x7, 0x71, 0x2, - 0x2, 0x44c, 0x44b, 0x3, 0x2, 0x2, 0x2, 0x44c, 0x44d, 0x3, 0x2, 0x2, - 0x2, 0x44d, 0x44f, 0x3, 0x2, 0x2, 0x2, 0x44e, 0x44a, 0x3, 0x2, 0x2, - 0x2, 0x44e, 0x44f, 0x3, 0x2, 0x2, 0x2, 0x44f, 0x461, 0x3, 0x2, 0x2, - 0x2, 0x450, 0x452, 0x5, 0x56, 0x2c, 0x2, 0x451, 0x453, 0x7, 0x71, 0x2, - 0x2, 0x452, 0x451, 0x3, 0x2, 0x2, 0x2, 0x452, 0x453, 0x3, 0x2, 0x2, - 0x2, 0x453, 0x45e, 0x3, 0x2, 0x2, 0x2, 0x454, 0x456, 0x7, 0x4, 0x2, - 0x2, 0x455, 0x457, 0x7, 0x71, 0x2, 0x2, 0x456, 0x455, 0x3, 0x2, 0x2, - 0x2, 0x456, 0x457, 0x3, 0x2, 0x2, 0x2, 0x457, 0x458, 0x3, 0x2, 0x2, - 0x2, 0x458, 0x45a, 0x5, 0x56, 0x2c, 0x2, 0x459, 0x45b, 0x7, 0x71, 0x2, - 0x2, 0x45a, 0x459, 0x3, 0x2, 0x2, 0x2, 0x45a, 0x45b, 0x3, 0x2, 0x2, - 0x2, 0x45b, 0x45d, 0x3, 0x2, 0x2, 0x2, 0x45c, 0x454, 0x3, 0x2, 0x2, - 0x2, 0x45d, 0x460, 0x3, 0x2, 0x2, 0x2, 0x45e, 0x45c, 0x3, 0x2, 0x2, - 0x2, 0x45e, 0x45f, 0x3, 0x2, 0x2, 0x2, 0x45f, 0x462, 0x3, 0x2, 0x2, - 0x2, 0x460, 0x45e, 0x3, 0x2, 0x2, 0x2, 0x461, 0x450, 0x3, 0x2, 0x2, - 0x2, 0x461, 0x462, 0x3, 0x2, 0x2, 0x2, 0x462, 0x463, 0x3, 0x2, 0x2, - 0x2, 0x463, 0x464, 0x7, 0x9, 0x2, 0x2, 0x464, 0x81, 0x3, 0x2, 0x2, 0x2, - 0x465, 0x466, 0x9, 0x5, 0x2, 0x2, 0x466, 0x83, 0x3, 0x2, 0x2, 0x2, 0x467, - 0x469, 0x7, 0xa, 0x2, 0x2, 0x468, 0x46a, 0x7, 0x71, 0x2, 0x2, 0x469, - 0x468, 0x3, 0x2, 0x2, 0x2, 0x469, 0x46a, 0x3, 0x2, 0x2, 0x2, 0x46a, - 0x46b, 0x3, 0x2, 0x2, 0x2, 0x46b, 0x474, 0x5, 0x7c, 0x3f, 0x2, 0x46c, - 0x46e, 0x7, 0x71, 0x2, 0x2, 0x46d, 0x46c, 0x3, 0x2, 0x2, 0x2, 0x46d, - 0x46e, 0x3, 0x2, 0x2, 0x2, 0x46e, 0x46f, 0x3, 0x2, 0x2, 0x2, 0x46f, - 0x471, 0x7, 0xe, 0x2, 0x2, 0x470, 0x472, 0x7, 0x71, 0x2, 0x2, 0x471, - 0x470, 0x3, 0x2, 0x2, 0x2, 0x471, 0x472, 0x3, 0x2, 0x2, 0x2, 0x472, - 0x473, 0x3, 0x2, 0x2, 0x2, 0x473, 0x475, 0x5, 0x56, 0x2c, 0x2, 0x474, - 0x46d, 0x3, 0x2, 0x2, 0x2, 0x474, 0x475, 0x3, 0x2, 0x2, 0x2, 0x475, - 0x477, 0x3, 0x2, 0x2, 0x2, 0x476, 0x478, 0x7, 0x71, 0x2, 0x2, 0x477, - 0x476, 0x3, 0x2, 0x2, 0x2, 0x477, 0x478, 0x3, 0x2, 0x2, 0x2, 0x478, - 0x479, 0x3, 0x2, 0x2, 0x2, 0x479, 0x47a, 0x7, 0xc, 0x2, 0x2, 0x47a, - 0x85, 0x3, 0x2, 0x2, 0x2, 0x47b, 0x47d, 0x7, 0x71, 0x2, 0x2, 0x47c, - 0x47b, 0x3, 0x2, 0x2, 0x2, 0x47c, 0x47d, 0x3, 0x2, 0x2, 0x2, 0x47d, - 0x47e, 0x3, 0x2, 0x2, 0x2, 0x47e, 0x480, 0x7, 0x1c, 0x2, 0x2, 0x47f, - 0x481, 0x7, 0x71, 0x2, 0x2, 0x480, 0x47f, 0x3, 0x2, 0x2, 0x2, 0x480, - 0x481, 0x3, 0x2, 0x2, 0x2, 0x481, 0x486, 0x3, 0x2, 0x2, 0x2, 0x482, - 0x483, 0x5, 0x92, 0x4a, 0x2, 0x483, 0x484, 0x9, 0x6, 0x2, 0x2, 0x484, - 0x487, 0x3, 0x2, 0x2, 0x2, 0x485, 0x487, 0x5, 0x92, 0x4a, 0x2, 0x486, - 0x482, 0x3, 0x2, 0x2, 0x2, 0x486, 0x485, 0x3, 0x2, 0x2, 0x2, 0x487, - 0x87, 0x3, 0x2, 0x2, 0x2, 0x488, 0x489, 0x5, 0x98, 0x4d, 0x2, 0x489, - 0x89, 0x3, 0x2, 0x2, 0x2, 0x48a, 0x48d, 0x5, 0x96, 0x4c, 0x2, 0x48b, - 0x48d, 0x5, 0x94, 0x4b, 0x2, 0x48c, 0x48a, 0x3, 0x2, 0x2, 0x2, 0x48c, - 0x48b, 0x3, 0x2, 0x2, 0x2, 0x48d, 0x8b, 0x3, 0x2, 0x2, 0x2, 0x48e, 0x490, - 0x7, 0x1e, 0x2, 0x2, 0x48f, 0x491, 0x7, 0x71, 0x2, 0x2, 0x490, 0x48f, - 0x3, 0x2, 0x2, 0x2, 0x490, 0x491, 0x3, 0x2, 0x2, 0x2, 0x491, 0x4b3, - 0x3, 0x2, 0x2, 0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 0x23e, 0x241, 0x245, 0x24b, 0x24e, 0x251, 0x255, 0x259, 0x25c, 0x25f, - 0x262, 0x265, 0x26b, 0x270, 0x274, 0x277, 0x27c, 0x281, 0x286, 0x28e, - 0x292, 0x294, 0x298, 0x29c, 0x29e, 0x2a0, 0x2af, 0x2b9, 0x2c3, 0x2c8, - 0x2cc, 0x2d3, 0x2d8, 0x2dd, 0x2e1, 0x2e5, 0x2e9, 0x2ec, 0x2ee, 0x2f3, - 0x2f7, 0x2fb, 0x2ff, 0x303, 0x307, 0x30a, 0x30c, 0x311, 0x315, 0x31a, - 0x31f, 0x323, 0x32a, 0x331, 0x335, 0x339, 0x33d, 0x34c, 0x34f, 0x35c, - 0x35e, 0x364, 0x366, 0x36d, 0x371, 0x375, 0x37b, 0x37f, 0x383, 0x389, - 0x38d, 0x391, 0x394, 0x398, 0x39e, 0x3a2, 0x3a6, 0x3ac, 0x3b0, 0x3b4, - 0x3ba, 0x3be, 0x3c2, 0x3c8, 0x3cc, 0x3d0, 0x3d8, 0x3e0, 0x3e6, 0x3ea, - 0x3ee, 0x3f2, 0x3f6, 0x3f9, 0x3ff, 0x404, 0x409, 0x40e, 0x413, 0x418, - 0x41d, 0x420, 0x424, 0x428, 0x42e, 0x433, 0x437, 0x43a, 0x444, 0x448, - 0x44c, 0x44e, 0x452, 0x456, 0x45a, 0x45e, 0x461, 0x469, 0x46d, 0x471, - 0x474, 0x477, 0x47c, 0x480, 0x486, 0x48c, 0x490, 0x494, 0x498, 0x49c, - 0x4a0, 0x4a4, 0x4a8, 0x4ac, 0x4b0, 0x4b3, 0x4ba, 0x4be, 0x4c3, + 0x3, 0x430, 0xd6d1, 0x8206, 0xad2d, 0x4417, 0xaef1, 0x8d80, 0xaadd, + 0x3, 0x74, 0x4d4, 0x4, 0x2, 0x9, 0x2, 0x4, 0x3, + 0x9, 0x3, 0x4, 0x4, 0x9, 0x4, 0x4, 0x5, 0x9, + 0x5, 0x4, 0x6, 0x9, 0x6, 0x4, 0x7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f, 0x3, 0xf, 0x3, 0xf, 0x3, 0xf, 0x3, 0xf, + 0x3, 0xf, 0x3, 0xf, 0x3, 0xf, 0x5, 0xf, 0x12e, + 0xa, 0xf, 0x3, 0x10, 0x3, 0x10, 0x5, 0x10, 0x132, + 0xa, 0x10, 0x3, 0x10, 0x3, 0x10, 0x5, 0x10, 0x136, + 0xa, 0x10, 0x3, 0x10, 0x3, 0x10, 0x5, 0x10, 0x13a, + 0xa, 0x10, 0x3, 0x10, 0x3, 0x10, 0x5, 0x10, 0x13e, + 0xa, 0x10, 0x3, 0x10, 0x7, 0x10, 0x141, 0xa, 0x10, + 0xc, 0x10, 0xe, 0x10, 0x144, 0xb, 0x10, 0x3, 0x11, + 0x3, 0x11, 0x3, 0x11, 0x3, 0x11, 0x5, 0x11, 0x14a, + 0xa, 0x11, 0x3, 0x11, 0x3, 0x11, 0x5, 0x11, 0x14e, + 0xa, 0x11, 0x3, 0x11, 0x7, 0x11, 0x151, 0xa, 0x11, + 0xc, 0x11, 0xe, 0x11, 0x154, 0xb, 0x11, 0x3, 0x12, + 0x3, 0x12, 0x3, 0x12, 0x3, 0x12, 0x5, 0x12, 0x15a, + 0xa, 0x12, 0x3, 0x13, 0x3, 0x13, 0x5, 0x13, 0x15e, + 0xa, 0x13, 0x3, 0x13, 0x5, 0x13, 0x161, 0xa, 0x13, + 0x3, 0x13, 0x3, 0x13, 0x3, 0x13, 0x5, 0x13, 0x166, + 0xa, 0x13, 0x3, 0x13, 0x5, 0x13, 0x169, 0xa, 0x13, + 0x3, 0x14, 0x3, 0x14, 0x5, 0x14, 0x16d, 0xa, 0x14, + 0x3, 0x14, 0x5, 0x14, 0x170, 0xa, 0x14, 0x3, 0x14, + 0x3, 0x14, 0x3, 0x14, 0x3, 0x15, 0x3, 0x15, 0x3, + 0x15, 0x5, 0x15, 0x178, 0xa, 0x15, 0x3, 0x15, 0x3, + 0x15, 0x5, 0x15, 0x17c, 0xa, 0x15, 0x3, 0x15, 0x3, + 0x15, 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0xc, 0x1d, 0xe, 0x1d, 0x1d7, 0xb, + 0x1d, 0x3, 0x1e, 0x3, 0x1e, 0x5, 0x1e, 0x1db, 0xa, + 0x1e, 0x3, 0x1e, 0x3, 0x1e, 0x5, 0x1e, 0x1df, 0xa, + 0x1e, 0x3, 0x1e, 0x3, 0x1e, 0x3, 0x1e, 0x5, 0x1e, + 0x1e4, 0xa, 0x1e, 0x3, 0x1f, 0x3, 0x1f, 0x3, 0x20, + 0x3, 0x20, 0x5, 0x20, 0x1ea, 0xa, 0x20, 0x3, 0x20, + 0x7, 0x20, 0x1ed, 0xa, 0x20, 0xc, 0x20, 0xe, 0x20, + 0x1f0, 0xb, 0x20, 0x3, 0x20, 0x3, 0x20, 0x3, 0x20, + 0x3, 0x20, 0x5, 0x20, 0x1f6, 0xa, 0x20, 0x3, 0x21, + 0x3, 0x21, 0x5, 0x21, 0x1fa, 0xa, 0x21, 0x3, 0x21, + 0x3, 0x21, 0x5, 0x21, 0x1fe, 0xa, 0x21, 0x5, 0x21, + 0x200, 0xa, 0x21, 0x3, 0x21, 0x3, 0x21, 0x5, 0x21, + 0x204, 0xa, 0x21, 0x5, 0x21, 0x206, 0xa, 0x21, 0x3, + 0x21, 0x3, 0x21, 0x5, 0x21, 0x20a, 0xa, 0x21, 0x5, + 0x21, 0x20c, 0xa, 0x21, 0x3, 0x21, 0x3, 0x21, 0x3, + 0x22, 0x3, 0x22, 0x5, 0x22, 0x212, 0xa, 0x22, 0x3, + 0x22, 0x3, 0x22, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, + 0x218, 0xa, 0x23, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, + 0x21c, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, 0x21f, 0xa, + 0x23, 0x3, 0x23, 0x5, 0x23, 0x222, 0xa, 0x23, 0x3, + 0x23, 0x3, 0x23, 0x5, 0x23, 0x226, 0xa, 0x23, 0x3, + 0x23, 0x3, 0x23, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, + 0x22c, 0xa, 0x23, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, + 0x230, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, 0x233, 0xa, + 0x23, 0x3, 0x23, 0x5, 0x23, 0x236, 0xa, 0x23, 0x3, + 0x23, 0x3, 0x23, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, + 0x23c, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, 0x23f, 0xa, + 0x23, 0x3, 0x23, 0x5, 0x23, 0x242, 0xa, 0x23, 0x3, + 0x23, 0x3, 0x23, 0x5, 0x23, 0x246, 0xa, 0x23, 0x3, + 0x23, 0x3, 0x23, 0x3, 0x23, 0x3, 0x23, 0x5, 0x23, + 0x24c, 0xa, 0x23, 0x3, 0x23, 0x5, 0x23, 0x24f, 0xa, + 0x23, 0x3, 0x23, 0x5, 0x23, 0x252, 0xa, 0x23, 0x3, + 0x23, 0x3, 0x23, 0x5, 0x23, 0x256, 0xa, 0x23, 0x3, + 0x24, 0x3, 0x24, 0x5, 0x24, 0x25a, 0xa, 0x24, 0x3, + 0x24, 0x5, 0x24, 0x25d, 0xa, 0x24, 0x3, 0x24, 0x5, + 0x24, 0x260, 0xa, 0x24, 0x3, 0x24, 0x5, 0x24, 0x263, + 0xa, 0x24, 0x3, 0x24, 0x5, 0x24, 0x266, 0xa, 0x24, + 0x3, 0x24, 0x3, 0x24, 0x3, 0x25, 0x3, 0x25, 0x5, + 0x25, 0x26c, 0xa, 0x25, 0x3, 0x26, 0x3, 0x26, 0x3, + 0x26, 0x5, 0x26, 0x271, 0xa, 0x26, 0x3, 0x26, 0x3, + 0x26, 0x5, 0x26, 0x275, 0xa, 0x26, 0x3, 0x26, 0x5, + 0x26, 0x278, 0xa, 0x26, 0x3, 0x26, 0x7, 0x26, 0x27b, + 0xa, 0x26, 0xc, 0x26, 0xe, 0x26, 0x27e, 0xb, 0x26, + 0x3, 0x27, 0x3, 0x27, 0x5, 0x27, 0x282, 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31, 0x2d7, 0xa, + 0x31, 0xc, 0x31, 0xe, 0x31, 0x2da, 0xb, 0x31, 0x3, + 0x32, 0x3, 0x32, 0x5, 0x32, 0x2de, 0xa, 0x32, 0x3, + 0x32, 0x3, 0x32, 0x5, 0x32, 0x2e2, 0xa, 0x32, 0x3, + 0x32, 0x3, 0x32, 0x5, 0x32, 0x2e6, 0xa, 0x32, 0x3, + 0x32, 0x3, 0x32, 0x5, 0x32, 0x2ea, 0xa, 0x32, 0x3, + 0x32, 0x7, 0x32, 0x2ed, 0xa, 0x32, 0xc, 0x32, 0xe, + 0x32, 0x2f0, 0xb, 0x32, 0x3, 0x33, 0x3, 0x33, 0x5, + 0x33, 0x2f4, 0xa, 0x33, 0x3, 0x33, 0x3, 0x33, 0x5, + 0x33, 0x2f8, 0xa, 0x33, 0x3, 0x33, 0x3, 0x33, 0x5, + 0x33, 0x2fc, 0xa, 0x33, 0x3, 0x33, 0x3, 0x33, 0x5, + 0x33, 0x300, 0xa, 0x33, 0x3, 0x33, 0x3, 0x33, 0x5, + 0x33, 0x304, 0xa, 0x33, 0x3, 0x33, 0x3, 0x33, 0x5, + 0x33, 0x308, 0xa, 0x33, 0x3, 0x33, 0x7, 0x33, 0x30b, + 0xa, 0x33, 0xc, 0x33, 0xe, 0x33, 0x30e, 0xb, 0x33, + 0x3, 0x34, 0x3, 0x34, 0x5, 0x34, 0x312, 0xa, 0x34, + 0x3, 0x34, 0x3, 0x34, 0x5, 0x34, 0x316, 0xa, 0x34, + 0x3, 0x34, 0x7, 0x34, 0x319, 0xa, 0x34, 0xc, 0x34, + 0xe, 0x34, 0x31c, 0xb, 0x34, 0x3, 0x35, 0x3, 0x35, + 0x5, 0x35, 0x320, 0xa, 0x35, 0x7, 0x35, 0x322, 0xa, + 0x35, 0xc, 0x35, 0xe, 0x35, 0x325, 0xb, 0x35, 0x3, + 0x35, 0x3, 0x35, 0x3, 0x36, 0x3, 0x36, 0x5, 0x36, + 0x32b, 0xa, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, + 0x3, 0x36, 0x3, 0x36, 0x5, 0x36, 0x332, 0xa, 0x36, + 0x3, 0x36, 0x3, 0x36, 0x5, 0x36, 0x336, 0xa, 0x36, + 0x3, 0x36, 0x3, 0x36, 0x5, 0x36, 0x33a, 0xa, 0x36, + 0x3, 0x36, 0x3, 0x36, 0x5, 0x36, 0x33e, 0xa, 0x36, + 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, + 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, + 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x5, + 0x36, 0x34d, 0xa, 0x36, 0x3, 0x36, 0x5, 0x36, 0x350, + 0xa, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, + 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, + 0x3, 0x36, 0x3, 0x36, 0x3, 0x36, 0x7, 0x36, 0x35d, + 0xa, 0x36, 0xc, 0x36, 0xe, 0x36, 0x360, 0xb, 0x36, + 0x3, 0x37, 0x3, 0x37, 0x3, 0x37, 0x7, 0x37, 0x365, + 0xa, 0x37, 0xc, 0x37, 0xe, 0x37, 0x368, 0xb, 0x37, + 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, + 0x38, 0x36e, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, + 0x38, 0x372, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, + 0x38, 0x376, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, + 0x38, 0x3, 0x38, 0x5, 0x38, 0x37c, 0xa, 0x38, 0x3, + 0x38, 0x3, 0x38, 0x5, 0x38, 0x380, 0xa, 0x38, 0x3, + 0x38, 0x3, 0x38, 0x5, 0x38, 0x384, 0xa, 0x38, 0x3, + 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, + 0x38a, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, + 0x38e, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, + 0x392, 0xa, 0x38, 0x3, 0x38, 0x5, 0x38, 0x395, 0xa, + 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x399, 0xa, + 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, + 0x5, 0x38, 0x39f, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, + 0x5, 0x38, 0x3a3, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, + 0x5, 0x38, 0x3a7, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, + 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x3ad, 0xa, 0x38, + 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x3b1, 0xa, 0x38, + 0x3, 0x38, 0x3, 0x38, 0x5, 0x38, 0x3b5, 0xa, 0x38, + 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, + 0x38, 0x3bb, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, + 0x38, 0x3bf, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x5, + 0x38, 0x3c3, 0xa, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, + 0x38, 0x3, 0x38, 0x5, 0x38, 0x3c9, 0xa, 0x38, 0x3, + 0x38, 0x3, 0x38, 0x5, 0x38, 0x3cd, 0xa, 0x38, 0x3, + 0x38, 0x3, 0x38, 0x5, 0x38, 0x3d1, 0xa, 0x38, 0x3, + 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, 0x3, 0x38, + 0x3, 0x38, 0x5, 0x38, 0x3d9, 0xa, 0x38, 0x3, 0x39, + 0x3, 0x39, 0x3, 0x39, 0x3, 0x39, 0x3, 0x39, 0x3, + 0x39, 0x5, 0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x3e, 0x432, 0xa, 0x3e, 0xd, 0x3e, + 0xe, 0x3e, 0x433, 0x3, 0x3f, 0x3, 0x3f, 0x5, 0x3f, + 0x438, 0xa, 0x3f, 0x3, 0x3f, 0x5, 0x3f, 0x43b, 0xa, + 0x3f, 0x3, 0x40, 0x3, 0x40, 0x3, 0x40, 0x3, 0x40, + 0x3, 0x40, 0x3, 0x40, 0x3, 0x41, 0x3, 0x41, 0x5, + 0x41, 0x445, 0xa, 0x41, 0x3, 0x41, 0x3, 0x41, 0x5, + 0x41, 0x449, 0xa, 0x41, 0x3, 0x41, 0x3, 0x41, 0x5, + 0x41, 0x44d, 0xa, 0x41, 0x5, 0x41, 0x44f, 0xa, 0x41, + 0x3, 0x41, 0x3, 0x41, 0x5, 0x41, 0x453, 0xa, 0x41, + 0x3, 0x41, 0x3, 0x41, 0x5, 0x41, 0x457, 0xa, 0x41, + 0x3, 0x41, 0x3, 0x41, 0x5, 0x41, 0x45b, 0xa, 0x41, + 0x7, 0x41, 0x45d, 0xa, 0x41, 0xc, 0x41, 0xe, 0x41, + 0x460, 0xb, 0x41, 0x5, 0x41, 0x462, 0xa, 0x41, 0x3, + 0x41, 0x3, 0x41, 0x3, 0x42, 0x3, 0x42, 0x3, 0x43, + 0x3, 0x43, 0x5, 0x43, 0x46a, 0xa, 0x43, 0x3, 0x43, + 0x3, 0x43, 0x5, 0x43, 0x46e, 0xa, 0x43, 0x3, 0x43, + 0x3, 0x43, 0x5, 0x43, 0x472, 0xa, 0x43, 0x3, 0x43, + 0x5, 0x43, 0x475, 0xa, 0x43, 0x3, 0x43, 0x5, 0x43, + 0x478, 0xa, 0x43, 0x3, 0x43, 0x3, 0x43, 0x3, 0x44, + 0x5, 0x44, 0x47d, 0xa, 0x44, 0x3, 0x44, 0x3, 0x44, + 0x5, 0x44, 0x481, 0xa, 0x44, 0x3, 0x44, 0x3, 0x44, + 0x3, 0x44, 0x3, 0x44, 0x5, 0x44, 0x487, 0xa, 0x44, + 0x3, 0x45, 0x3, 0x45, 0x3, 0x46, 0x3, 0x46, 0x5, + 0x46, 0x48d, 0xa, 0x46, 0x3, 0x47, 0x3, 0x47, 0x5, + 0x47, 0x491, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, + 0x47, 0x495, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, + 0x47, 0x499, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, + 0x47, 0x49d, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, + 0x47, 0x4a1, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, + 0x47, 0x4a5, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, + 0x47, 0x4a9, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x5, + 0x47, 0x4ad, 0xa, 0x47, 0x7, 0x47, 0x4af, 0xa, 0x47, + 0xc, 0x47, 0xe, 0x47, 0x4b2, 0xb, 0x47, 0x5, 0x47, + 0x4b4, 0xa, 0x47, 0x3, 0x47, 0x3, 0x47, 0x3, 0x48, + 0x3, 0x48, 0x3, 0x48, 0x5, 0x48, 0x4bb, 0xa, 0x48, + 0x3, 0x49, 0x3, 0x49, 0x5, 0x49, 0x4bf, 0xa, 0x49, + 0x3, 0x49, 0x6, 0x49, 0x4c2, 0xa, 0x49, 0xd, 0x49, + 0xe, 0x49, 0x4c3, 0x3, 0x4a, 0x3, 0x4a, 0x3, 0x4b, + 0x3, 0x4b, 0x3, 0x4c, 0x3, 0x4c, 0x3, 0x4d, 0x3, + 0x4d, 0x3, 0x4e, 0x3, 0x4e, 0x3, 0x4f, 0x3, 0x4f, + 0x3, 0x50, 0x3, 0x50, 0x3, 0x50, 0x2, 0x2, 0x51, + 0x2, 0x4, 0x6, 0x8, 0xa, 0xc, 0xe, 0x10, 0x12, + 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, 0x20, 0x22, 0x24, + 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0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 0x2, 0x2, + 0x2, 0x102, 0x100, 0x3, 0x2, 0x2, 0x2, 0x103, 0x104, + 0x7, 0x49, 0x2, 0x2, 0x104, 0x105, 0x7, 0x71, 0x2, + 0x2, 0x105, 0x106, 0x7, 0x45, 0x2, 0x2, 0x106, 0x107, + 0x7, 0x71, 0x2, 0x2, 0x107, 0x10e, 0x5, 0x1a, 0xe, + 0x2, 0x108, 0x109, 0x7, 0x49, 0x2, 0x2, 0x109, 0x10a, + 0x7, 0x71, 0x2, 0x2, 0x10a, 0x10b, 0x7, 0x4a, 0x2, + 0x2, 0x10b, 0x10c, 0x7, 0x71, 0x2, 0x2, 0x10c, 0x10e, + 0x5, 0x1a, 0xe, 0x2, 0x10d, 0x103, 0x3, 0x2, 0x2, + 0x2, 0x10d, 0x108, 0x3, 0x2, 0x2, 0x2, 0x10e, 0x17, + 0x3, 0x2, 0x2, 0x2, 0x10f, 0x111, 0x7, 0x4a, 0x2, + 0x2, 0x110, 0x112, 0x7, 0x71, 0x2, 0x2, 0x111, 0x110, + 0x3, 0x2, 0x2, 0x2, 0x111, 0x112, 0x3, 0x2, 0x2, + 0x2, 0x112, 0x113, 0x3, 0x2, 0x2, 0x2, 0x113, 0x114, + 0x5, 0x38, 0x1d, 0x2, 0x114, 0x19, 0x3, 0x2, 0x2, + 0x2, 0x115, 0x116, 0x7, 0x4b, 0x2, 0x2, 0x116, 0x11b, + 0x5, 0x1c, 0xf, 0x2, 0x117, 0x118, 0x7, 0x4, 0x2, + 0x2, 0x118, 0x11a, 0x5, 0x1c, 0xf, 0x2, 0x119, 0x117, + 0x3, 0x2, 0x2, 0x2, 0x11a, 0x11d, 0x3, 0x2, 0x2, + 0x2, 0x11b, 0x119, 0x3, 0x2, 0x2, 0x2, 0x11b, 0x11c, + 0x3, 0x2, 0x2, 0x2, 0x11c, 0x1b, 0x3, 0x2, 0x2, + 0x2, 0x11d, 0x11b, 0x3, 0x2, 0x2, 0x2, 0x11e, 0x11f, + 0x5, 0x90, 0x49, 0x2, 0x11f, 0x120, 0x7, 0x5, 0x2, + 0x2, 0x120, 0x121, 0x5, 0x56, 0x2c, 0x2, 0x121, 0x12e, + 0x3, 0x2, 0x2, 0x2, 0x122, 0x123, 0x5, 0x88, 0x45, + 0x2, 0x123, 0x124, 0x7, 0x5, 0x2, 0x2, 0x124, 0x125, + 0x5, 0x56, 0x2c, 0x2, 0x125, 0x12e, 0x3, 0x2, 0x2, + 0x2, 0x126, 0x127, 0x5, 0x88, 0x45, 0x2, 0x127, 0x128, + 0x7, 0x6, 0x2, 0x2, 0x128, 0x129, 0x5, 0x56, 0x2c, + 0x2, 0x129, 0x12e, 0x3, 0x2, 0x2, 0x2, 0x12a, 0x12b, + 0x5, 0x88, 0x45, 0x2, 0x12b, 0x12c, 0x5, 0x4c, 0x27, + 0x2, 0x12c, 0x12e, 0x3, 0x2, 0x2, 0x2, 0x12d, 0x11e, + 0x3, 0x2, 0x2, 0x2, 0x12d, 0x122, 0x3, 0x2, 0x2, + 0x2, 0x12d, 0x126, 0x3, 0x2, 0x2, 0x2, 0x12d, 0x12a, + 0x3, 0x2, 0x2, 0x2, 0x12e, 0x1d, 0x3, 0x2, 0x2, + 0x2, 0x12f, 0x130, 0x7, 0x4c, 0x2, 0x2, 0x130, 0x132, + 0x7, 0x71, 0x2, 0x2, 0x131, 0x12f, 0x3, 0x2, 0x2, + 0x2, 0x131, 0x132, 0x3, 0x2, 0x2, 0x2, 0x132, 0x133, + 0x3, 0x2, 0x2, 0x2, 0x133, 0x135, 0x7, 0x4d, 0x2, + 0x2, 0x134, 0x136, 0x7, 0x71, 0x2, 0x2, 0x135, 0x134, + 0x3, 0x2, 0x2, 0x2, 0x135, 0x136, 0x3, 0x2, 0x2, + 0x2, 0x136, 0x137, 0x3, 0x2, 0x2, 0x2, 0x137, 0x142, + 0x5, 0x56, 0x2c, 0x2, 0x138, 0x13a, 0x7, 0x71, 0x2, + 0x2, 0x139, 0x138, 0x3, 0x2, 0x2, 0x2, 0x139, 0x13a, + 0x3, 0x2, 0x2, 0x2, 0x13a, 0x13b, 0x3, 0x2, 0x2, + 0x2, 0x13b, 0x13d, 0x7, 0x4, 0x2, 0x2, 0x13c, 0x13e, + 0x7, 0x71, 0x2, 0x2, 0x13d, 0x13c, 0x3, 0x2, 0x2, + 0x2, 0x13d, 0x13e, 0x3, 0x2, 0x2, 0x2, 0x13e, 0x13f, + 0x3, 0x2, 0x2, 0x2, 0x13f, 0x141, 0x5, 0x56, 0x2c, + 0x2, 0x140, 0x139, 0x3, 0x2, 0x2, 0x2, 0x141, 0x144, + 0x3, 0x2, 0x2, 0x2, 0x142, 0x140, 0x3, 0x2, 0x2, + 0x2, 0x142, 0x143, 0x3, 0x2, 0x2, 0x2, 0x143, 0x1f, + 0x3, 0x2, 0x2, 0x2, 0x144, 0x142, 0x3, 0x2, 0x2, + 0x2, 0x145, 0x146, 0x7, 0x4e, 0x2, 0x2, 0x146, 0x147, + 0x7, 0x71, 0x2, 0x2, 0x147, 0x152, 0x5, 0x22, 0x12, + 0x2, 0x148, 0x14a, 0x7, 0x71, 0x2, 0x2, 0x149, 0x148, + 0x3, 0x2, 0x2, 0x2, 0x149, 0x14a, 0x3, 0x2, 0x2, + 0x2, 0x14a, 0x14b, 0x3, 0x2, 0x2, 0x2, 0x14b, 0x14d, + 0x7, 0x4, 0x2, 0x2, 0x14c, 0x14e, 0x7, 0x71, 0x2, + 0x2, 0x14d, 0x14c, 0x3, 0x2, 0x2, 0x2, 0x14d, 0x14e, + 0x3, 0x2, 0x2, 0x2, 0x14e, 0x14f, 0x3, 0x2, 0x2, + 0x2, 0x14f, 0x151, 0x5, 0x22, 0x12, 0x2, 0x150, 0x149, + 0x3, 0x2, 0x2, 0x2, 0x151, 0x154, 0x3, 0x2, 0x2, + 0x2, 0x152, 0x150, 0x3, 0x2, 0x2, 0x2, 0x152, 0x153, + 0x3, 0x2, 0x2, 0x2, 0x153, 0x21, 0x3, 0x2, 0x2, + 0x2, 0x154, 0x152, 0x3, 0x2, 0x2, 0x2, 0x155, 0x156, + 0x5, 0x88, 0x45, 0x2, 0x156, 0x157, 0x5, 0x4c, 0x27, + 0x2, 0x157, 0x15a, 0x3, 0x2, 0x2, 0x2, 0x158, 0x15a, + 0x5, 0x90, 0x49, 0x2, 0x159, 0x155, 0x3, 0x2, 0x2, + 0x2, 0x159, 0x158, 0x3, 0x2, 0x2, 0x2, 0x15a, 0x23, + 0x3, 0x2, 0x2, 0x2, 0x15b, 0x160, 0x7, 0x4f, 0x2, + 0x2, 0x15c, 0x15e, 0x7, 0x71, 0x2, 0x2, 0x15d, 0x15c, + 0x3, 0x2, 0x2, 0x2, 0x15d, 0x15e, 0x3, 0x2, 0x2, + 0x2, 0x15e, 0x15f, 0x3, 0x2, 0x2, 0x2, 0x15f, 0x161, + 0x7, 0x50, 0x2, 0x2, 0x160, 0x15d, 0x3, 0x2, 0x2, + 0x2, 0x160, 0x161, 0x3, 0x2, 0x2, 0x2, 0x161, 0x162, + 0x3, 0x2, 0x2, 0x2, 0x162, 0x163, 0x7, 0x71, 0x2, + 0x2, 0x163, 0x168, 0x5, 0x28, 0x15, 0x2, 0x164, 0x166, + 0x7, 0x71, 0x2, 0x2, 0x165, 0x164, 0x3, 0x2, 0x2, + 0x2, 0x165, 0x166, 0x3, 0x2, 0x2, 0x2, 0x166, 0x167, + 0x3, 0x2, 0x2, 0x2, 0x167, 0x169, 0x5, 0x36, 0x1c, + 0x2, 0x168, 0x165, 0x3, 0x2, 0x2, 0x2, 0x168, 0x169, + 0x3, 0x2, 0x2, 0x2, 0x169, 0x25, 0x3, 0x2, 0x2, + 0x2, 0x16a, 0x16f, 0x7, 0x51, 0x2, 0x2, 0x16b, 0x16d, + 0x7, 0x71, 0x2, 0x2, 0x16c, 0x16b, 0x3, 0x2, 0x2, + 0x2, 0x16c, 0x16d, 0x3, 0x2, 0x2, 0x2, 0x16d, 0x16e, + 0x3, 0x2, 0x2, 0x2, 0x16e, 0x170, 0x7, 0x50, 0x2, + 0x2, 0x16f, 0x16c, 0x3, 0x2, 0x2, 0x2, 0x16f, 0x170, + 0x3, 0x2, 0x2, 0x2, 0x170, 0x171, 0x3, 0x2, 0x2, + 0x2, 0x171, 0x172, 0x7, 0x71, 0x2, 0x2, 0x172, 0x173, + 0x5, 0x28, 0x15, 0x2, 0x173, 0x27, 0x3, 0x2, 0x2, + 0x2, 0x174, 0x177, 0x5, 0x2a, 0x16, 0x2, 0x175, 0x176, + 0x7, 0x71, 0x2, 0x2, 0x176, 0x178, 0x5, 0x2e, 0x18, + 0x2, 0x177, 0x175, 0x3, 0x2, 0x2, 0x2, 0x177, 0x178, + 0x3, 0x2, 0x2, 0x2, 0x178, 0x17b, 0x3, 0x2, 0x2, + 0x2, 0x179, 0x17a, 0x7, 0x71, 0x2, 0x2, 0x17a, 0x17c, + 0x5, 0x30, 0x19, 0x2, 0x17b, 0x179, 0x3, 0x2, 0x2, + 0x2, 0x17b, 0x17c, 0x3, 0x2, 0x2, 0x2, 0x17c, 0x17f, + 0x3, 0x2, 0x2, 0x2, 0x17d, 0x17e, 0x7, 0x71, 0x2, + 0x2, 0x17e, 0x180, 0x5, 0x32, 0x1a, 0x2, 0x17f, 0x17d, + 0x3, 0x2, 0x2, 0x2, 0x17f, 0x180, 0x3, 0x2, 0x2, + 0x2, 0x180, 0x29, 0x3, 0x2, 0x2, 0x2, 0x181, 0x18c, + 0x7, 0x7, 0x2, 0x2, 0x182, 0x184, 0x7, 0x71, 0x2, + 0x2, 0x183, 0x182, 0x3, 0x2, 0x2, 0x2, 0x183, 0x184, + 0x3, 0x2, 0x2, 0x2, 0x184, 0x185, 0x3, 0x2, 0x2, + 0x2, 0x185, 0x187, 0x7, 0x4, 0x2, 0x2, 0x186, 0x188, + 0x7, 0x71, 0x2, 0x2, 0x187, 0x186, 0x3, 0x2, 0x2, + 0x2, 0x187, 0x188, 0x3, 0x2, 0x2, 0x2, 0x188, 0x189, + 0x3, 0x2, 0x2, 0x2, 0x189, 0x18b, 0x5, 0x2c, 0x17, + 0x2, 0x18a, 0x183, 0x3, 0x2, 0x2, 0x2, 0x18b, 0x18e, + 0x3, 0x2, 0x2, 0x2, 0x18c, 0x18a, 0x3, 0x2, 0x2, + 0x2, 0x18c, 0x18d, 0x3, 0x2, 0x2, 0x2, 0x18d, 0x19e, + 0x3, 0x2, 0x2, 0x2, 0x18e, 0x18c, 0x3, 0x2, 0x2, + 0x2, 0x18f, 0x19a, 0x5, 0x2c, 0x17, 0x2, 0x190, 0x192, + 0x7, 0x71, 0x2, 0x2, 0x191, 0x190, 0x3, 0x2, 0x2, + 0x2, 0x191, 0x192, 0x3, 0x2, 0x2, 0x2, 0x192, 0x193, + 0x3, 0x2, 0x2, 0x2, 0x193, 0x195, 0x7, 0x4, 0x2, + 0x2, 0x194, 0x196, 0x7, 0x71, 0x2, 0x2, 0x195, 0x194, + 0x3, 0x2, 0x2, 0x2, 0x195, 0x196, 0x3, 0x2, 0x2, + 0x2, 0x196, 0x197, 0x3, 0x2, 0x2, 0x2, 0x197, 0x199, + 0x5, 0x2c, 0x17, 0x2, 0x198, 0x191, 0x3, 0x2, 0x2, + 0x2, 0x199, 0x19c, 0x3, 0x2, 0x2, 0x2, 0x19a, 0x198, + 0x3, 0x2, 0x2, 0x2, 0x19a, 0x19b, 0x3, 0x2, 0x2, + 0x2, 0x19b, 0x19e, 0x3, 0x2, 0x2, 0x2, 0x19c, 0x19a, + 0x3, 0x2, 0x2, 0x2, 0x19d, 0x181, 0x3, 0x2, 0x2, + 0x2, 0x19d, 0x18f, 0x3, 0x2, 0x2, 0x2, 0x19e, 0x2b, + 0x3, 0x2, 0x2, 0x2, 0x19f, 0x1a0, 0x5, 0x56, 0x2c, + 0x2, 0x1a0, 0x1a1, 0x7, 0x71, 0x2, 0x2, 0x1a1, 0x1a2, + 0x7, 0x47, 0x2, 0x2, 0x1a2, 0x1a3, 0x7, 0x71, 0x2, + 0x2, 0x1a3, 0x1a4, 0x5, 0x88, 0x45, 0x2, 0x1a4, 0x1a7, + 0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x3, 0x2, 0x2, 0x2, 0x209, 0x20a, 0x3, 0x2, 0x2, + 0x2, 0x20a, 0x20c, 0x3, 0x2, 0x2, 0x2, 0x20b, 0x207, + 0x3, 0x2, 0x2, 0x2, 0x20b, 0x20c, 0x3, 0x2, 0x2, + 0x2, 0x20c, 0x20d, 0x3, 0x2, 0x2, 0x2, 0x20d, 0x20e, + 0x7, 0x9, 0x2, 0x2, 0x20e, 0x41, 0x3, 0x2, 0x2, + 0x2, 0x20f, 0x211, 0x5, 0x44, 0x23, 0x2, 0x210, 0x212, + 0x7, 0x71, 0x2, 0x2, 0x211, 0x210, 0x3, 0x2, 0x2, + 0x2, 0x211, 0x212, 0x3, 0x2, 0x2, 0x2, 0x212, 0x213, + 0x3, 0x2, 0x2, 0x2, 0x213, 0x214, 0x5, 0x40, 0x21, + 0x2, 0x214, 0x43, 0x3, 0x2, 0x2, 0x2, 0x215, 0x217, + 0x5, 0x9a, 0x4e, 0x2, 0x216, 0x218, 0x7, 0x71, 0x2, + 0x2, 0x217, 0x216, 0x3, 0x2, 0x2, 0x2, 0x217, 0x218, + 0x3, 0x2, 0x2, 0x2, 0x218, 0x219, 0x3, 0x2, 0x2, + 0x2, 0x219, 0x21b, 0x5, 0x9e, 0x50, 0x2, 0x21a, 0x21c, + 0x7, 0x71, 0x2, 0x2, 0x21b, 0x21a, 0x3, 0x2, 0x2, + 0x2, 0x21b, 0x21c, 0x3, 0x2, 0x2, 0x2, 0x21c, 0x21e, + 0x3, 0x2, 0x2, 0x2, 0x21d, 0x21f, 0x5, 0x46, 0x24, + 0x2, 0x21e, 0x21d, 0x3, 0x2, 0x2, 0x2, 0x21e, 0x21f, + 0x3, 0x2, 0x2, 0x2, 0x21f, 0x221, 0x3, 0x2, 0x2, + 0x2, 0x220, 0x222, 0x7, 0x71, 0x2, 0x2, 0x221, 0x220, + 0x3, 0x2, 0x2, 0x2, 0x221, 0x222, 0x3, 0x2, 0x2, + 0x2, 0x222, 0x223, 0x3, 0x2, 0x2, 0x2, 0x223, 0x225, + 0x5, 0x9e, 0x50, 0x2, 0x224, 0x226, 0x7, 0x71, 0x2, + 0x2, 0x225, 0x224, 0x3, 0x2, 0x2, 0x2, 0x225, 0x226, + 0x3, 0x2, 0x2, 0x2, 0x226, 0x227, 0x3, 0x2, 0x2, + 0x2, 0x227, 0x228, 0x5, 0x9c, 0x4f, 0x2, 0x228, 0x256, + 0x3, 0x2, 0x2, 0x2, 0x229, 0x22b, 0x5, 0x9a, 0x4e, + 0x2, 0x22a, 0x22c, 0x7, 0x71, 0x2, 0x2, 0x22b, 0x22a, + 0x3, 0x2, 0x2, 0x2, 0x22b, 0x22c, 0x3, 0x2, 0x2, + 0x2, 0x22c, 0x22d, 0x3, 0x2, 0x2, 0x2, 0x22d, 0x22f, + 0x5, 0x9e, 0x50, 0x2, 0x22e, 0x230, 0x7, 0x71, 0x2, + 0x2, 0x22f, 0x22e, 0x3, 0x2, 0x2, 0x2, 0x22f, 0x230, + 0x3, 0x2, 0x2, 0x2, 0x230, 0x232, 0x3, 0x2, 0x2, + 0x2, 0x231, 0x233, 0x5, 0x46, 0x24, 0x2, 0x232, 0x231, + 0x3, 0x2, 0x2, 0x2, 0x232, 0x233, 0x3, 0x2, 0x2, + 0x2, 0x233, 0x235, 0x3, 0x2, 0x2, 0x2, 0x234, 0x236, + 0x7, 0x71, 0x2, 0x2, 0x235, 0x234, 0x3, 0x2, 0x2, + 0x2, 0x235, 0x236, 0x3, 0x2, 0x2, 0x2, 0x236, 0x237, + 0x3, 0x2, 0x2, 0x2, 0x237, 0x238, 0x5, 0x9e, 0x50, + 0x2, 0x238, 0x256, 0x3, 0x2, 0x2, 0x2, 0x239, 0x23b, + 0x5, 0x9e, 0x50, 0x2, 0x23a, 0x23c, 0x7, 0x71, 0x2, + 0x2, 0x23b, 0x23a, 0x3, 0x2, 0x2, 0x2, 0x23b, 0x23c, + 0x3, 0x2, 0x2, 0x2, 0x23c, 0x23e, 0x3, 0x2, 0x2, + 0x2, 0x23d, 0x23f, 0x5, 0x46, 0x24, 0x2, 0x23e, 0x23d, + 0x3, 0x2, 0x2, 0x2, 0x23e, 0x23f, 0x3, 0x2, 0x2, + 0x2, 0x23f, 0x241, 0x3, 0x2, 0x2, 0x2, 0x240, 0x242, + 0x7, 0x71, 0x2, 0x2, 0x241, 0x240, 0x3, 0x2, 0x2, + 0x2, 0x241, 0x242, 0x3, 0x2, 0x2, 0x2, 0x242, 0x243, + 0x3, 0x2, 0x2, 0x2, 0x243, 0x245, 0x5, 0x9e, 0x50, + 0x2, 0x244, 0x246, 0x7, 0x71, 0x2, 0x2, 0x245, 0x244, + 0x3, 0x2, 0x2, 0x2, 0x245, 0x246, 0x3, 0x2, 0x2, + 0x2, 0x246, 0x247, 0x3, 0x2, 0x2, 0x2, 0x247, 0x248, + 0x5, 0x9c, 0x4f, 0x2, 0x248, 0x256, 0x3, 0x2, 0x2, + 0x2, 0x249, 0x24b, 0x5, 0x9e, 0x50, 0x2, 0x24a, 0x24c, + 0x7, 0x71, 0x2, 0x2, 0x24b, 0x24a, 0x3, 0x2, 0x2, + 0x2, 0x24b, 0x24c, 0x3, 0x2, 0x2, 0x2, 0x24c, 0x24e, + 0x3, 0x2, 0x2, 0x2, 0x24d, 0x24f, 0x5, 0x46, 0x24, + 0x2, 0x24e, 0x24d, 0x3, 0x2, 0x2, 0x2, 0x24e, 0x24f, + 0x3, 0x2, 0x2, 0x2, 0x24f, 0x251, 0x3, 0x2, 0x2, + 0x2, 0x250, 0x252, 0x7, 0x71, 0x2, 0x2, 0x251, 0x250, + 0x3, 0x2, 0x2, 0x2, 0x251, 0x252, 0x3, 0x2, 0x2, + 0x2, 0x252, 0x253, 0x3, 0x2, 0x2, 0x2, 0x253, 0x254, + 0x5, 0x9e, 0x50, 0x2, 0x254, 0x256, 0x3, 0x2, 0x2, + 0x2, 0x255, 0x215, 0x3, 0x2, 0x2, 0x2, 0x255, 0x229, + 0x3, 0x2, 0x2, 0x2, 0x255, 0x239, 0x3, 0x2, 0x2, + 0x2, 0x255, 0x249, 0x3, 0x2, 0x2, 0x2, 0x256, 0x45, + 0x3, 0x2, 0x2, 0x2, 0x257, 0x259, 0x7, 0xa, 0x2, + 0x2, 0x258, 0x25a, 0x5, 0x88, 0x45, 0x2, 0x259, 0x258, + 0x3, 0x2, 0x2, 0x2, 0x259, 0x25a, 0x3, 0x2, 0x2, + 0x2, 0x25a, 0x25c, 0x3, 0x2, 0x2, 0x2, 0x25b, 0x25d, + 0x7, 0xb, 0x2, 0x2, 0x25c, 0x25b, 0x3, 0x2, 0x2, + 0x2, 0x25c, 0x25d, 0x3, 0x2, 0x2, 0x2, 0x25d, 0x25f, + 0x3, 0x2, 0x2, 0x2, 0x25e, 0x260, 0x5, 0x4a, 0x26, + 0x2, 0x25f, 0x25e, 0x3, 0x2, 0x2, 0x2, 0x25f, 0x260, + 0x3, 0x2, 0x2, 0x2, 0x260, 0x262, 0x3, 0x2, 0x2, + 0x2, 0x261, 0x263, 0x5, 0x50, 0x29, 0x2, 0x262, 0x261, + 0x3, 0x2, 0x2, 0x2, 0x262, 0x263, 0x3, 0x2, 0x2, + 0x2, 0x263, 0x265, 0x3, 0x2, 0x2, 0x2, 0x264, 0x266, + 0x5, 0x48, 0x25, 0x2, 0x265, 0x264, 0x3, 0x2, 0x2, + 0x2, 0x265, 0x266, 0x3, 0x2, 0x2, 0x2, 0x266, 0x267, + 0x3, 0x2, 0x2, 0x2, 0x267, 0x268, 0x7, 0xc, 0x2, + 0x2, 0x268, 0x47, 0x3, 0x2, 0x2, 0x2, 0x269, 0x26c, + 0x5, 0x8c, 0x47, 0x2, 0x26a, 0x26c, 0x5, 0x8e, 0x48, + 0x2, 0x26b, 0x269, 0x3, 0x2, 0x2, 0x2, 0x26b, 0x26a, + 0x3, 0x2, 0x2, 0x2, 0x26c, 0x49, 0x3, 0x2, 0x2, + 0x2, 0x26d, 0x26e, 0x7, 0xd, 0x2, 0x2, 0x26e, 0x27c, + 0x5, 0x54, 0x2b, 0x2, 0x26f, 0x271, 0x7, 0x71, 0x2, + 0x2, 0x270, 0x26f, 0x3, 0x2, 0x2, 0x2, 0x270, 0x271, + 0x3, 0x2, 0x2, 0x2, 0x271, 0x272, 0x3, 0x2, 0x2, + 0x2, 0x272, 0x274, 0x7, 0xe, 0x2, 0x2, 0x273, 0x275, + 0x7, 0xd, 0x2, 0x2, 0x274, 0x273, 0x3, 0x2, 0x2, + 0x2, 0x274, 0x275, 0x3, 0x2, 0x2, 0x2, 0x275, 0x277, + 0x3, 0x2, 0x2, 0x2, 0x276, 0x278, 0x7, 0x71, 0x2, + 0x2, 0x277, 0x276, 0x3, 0x2, 0x2, 0x2, 0x277, 0x278, + 0x3, 0x2, 0x2, 0x2, 0x278, 0x279, 0x3, 0x2, 0x2, + 0x2, 0x279, 0x27b, 0x5, 0x54, 0x2b, 0x2, 0x27a, 0x270, + 0x3, 0x2, 0x2, 0x2, 0x27b, 0x27e, 0x3, 0x2, 0x2, + 0x2, 0x27c, 0x27a, 0x3, 0x2, 0x2, 0x2, 0x27c, 0x27d, + 0x3, 0x2, 0x2, 0x2, 0x27d, 0x4b, 0x3, 0x2, 0x2, + 0x2, 0x27e, 0x27c, 0x3, 0x2, 0x2, 0x2, 0x27f, 0x286, + 0x5, 0x4e, 0x28, 0x2, 0x280, 0x282, 0x7, 0x71, 0x2, + 0x2, 0x281, 0x280, 0x3, 0x2, 0x2, 0x2, 0x281, 0x282, + 0x3, 0x2, 0x2, 0x2, 0x282, 0x283, 0x3, 0x2, 0x2, + 0x2, 0x283, 0x285, 0x5, 0x4e, 0x28, 0x2, 0x284, 0x281, + 0x3, 0x2, 0x2, 0x2, 0x285, 0x288, 0x3, 0x2, 0x2, + 0x2, 0x286, 0x284, 0x3, 0x2, 0x2, 0x2, 0x286, 0x287, + 0x3, 0x2, 0x2, 0x2, 0x287, 0x4d, 0x3, 0x2, 0x2, + 0x2, 0x288, 0x286, 0x3, 0x2, 0x2, 0x2, 0x289, 0x28a, + 0x7, 0xd, 0x2, 0x2, 0x28a, 0x28b, 0x5, 0x52, 0x2a, + 0x2, 0x28b, 0x4f, 0x3, 0x2, 0x2, 0x2, 0x28c, 0x28e, + 0x7, 0x7, 0x2, 0x2, 0x28d, 0x28f, 0x7, 0x71, 0x2, + 0x2, 0x28e, 0x28d, 0x3, 0x2, 0x2, 0x2, 0x28e, 0x28f, + 0x3, 0x2, 0x2, 0x2, 0x28f, 0x294, 0x3, 0x2, 0x2, + 0x2, 0x290, 0x292, 0x5, 0x94, 0x4b, 0x2, 0x291, 0x293, + 0x7, 0x71, 0x2, 0x2, 0x292, 0x291, 0x3, 0x2, 0x2, + 0x2, 0x292, 0x293, 0x3, 0x2, 0x2, 0x2, 0x293, 0x295, + 0x3, 0x2, 0x2, 0x2, 0x294, 0x290, 0x3, 0x2, 0x2, + 0x2, 0x294, 0x295, 0x3, 0x2, 0x2, 0x2, 0x295, 0x2a0, + 0x3, 0x2, 0x2, 0x2, 0x296, 0x298, 0x7, 0xf, 0x2, + 0x2, 0x297, 0x299, 0x7, 0x71, 0x2, 0x2, 0x298, 0x297, + 0x3, 0x2, 0x2, 0x2, 0x298, 0x299, 0x3, 0x2, 0x2, + 0x2, 0x299, 0x29e, 0x3, 0x2, 0x2, 0x2, 0x29a, 0x29c, + 0x5, 0x94, 0x4b, 0x2, 0x29b, 0x29d, 0x7, 0x71, 0x2, + 0x2, 0x29c, 0x29b, 0x3, 0x2, 0x2, 0x2, 0x29c, 0x29d, + 0x3, 0x2, 0x2, 0x2, 0x29d, 0x29f, 0x3, 0x2, 0x2, + 0x2, 0x29e, 0x29a, 0x3, 0x2, 0x2, 0x2, 0x29e, 0x29f, + 0x3, 0x2, 0x2, 0x2, 0x29f, 0x2a1, 0x3, 0x2, 0x2, + 0x2, 0x2a0, 0x296, 0x3, 0x2, 0x2, 0x2, 0x2a0, 0x2a1, + 0x3, 0x2, 0x2, 0x2, 0x2a1, 0x51, 0x3, 0x2, 0x2, + 0x2, 0x2a2, 0x2a3, 0x5, 0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, 0x3, 0x2, 0x2, 0x2, 0x308, 0x309, + 0x3, 0x2, 0x2, 0x2, 0x309, 0x30b, 0x5, 0x66, 0x34, + 0x2, 0x30a, 0x2f3, 0x3, 0x2, 0x2, 0x2, 0x30a, 0x2fb, + 0x3, 0x2, 0x2, 0x2, 0x30a, 0x303, 0x3, 0x2, 0x2, + 0x2, 0x30b, 0x30e, 0x3, 0x2, 0x2, 0x2, 0x30c, 0x30a, + 0x3, 0x2, 0x2, 0x2, 0x30c, 0x30d, 0x3, 0x2, 0x2, + 0x2, 0x30d, 0x65, 0x3, 0x2, 0x2, 0x2, 0x30e, 0x30c, + 0x3, 0x2, 0x2, 0x2, 0x30f, 0x31a, 0x5, 0x68, 0x35, + 0x2, 0x310, 0x312, 0x7, 0x71, 0x2, 0x2, 0x311, 0x310, + 0x3, 0x2, 0x2, 0x2, 0x311, 0x312, 0x3, 0x2, 0x2, + 0x2, 0x312, 0x313, 0x3, 0x2, 0x2, 0x2, 0x313, 0x315, + 0x7, 0x14, 0x2, 0x2, 0x314, 0x316, 0x7, 0x71, 0x2, + 0x2, 0x315, 0x314, 0x3, 0x2, 0x2, 0x2, 0x315, 0x316, + 0x3, 0x2, 0x2, 0x2, 0x316, 0x317, 0x3, 0x2, 0x2, + 0x2, 0x317, 0x319, 0x5, 0x68, 0x35, 0x2, 0x318, 0x311, + 0x3, 0x2, 0x2, 0x2, 0x319, 0x31c, 0x3, 0x2, 0x2, + 0x2, 0x31a, 0x318, 0x3, 0x2, 0x2, 0x2, 0x31a, 0x31b, + 0x3, 0x2, 0x2, 0x2, 0x31b, 0x67, 0x3, 0x2, 0x2, + 0x2, 0x31c, 0x31a, 0x3, 0x2, 0x2, 0x2, 0x31d, 0x31f, + 0x9, 0x3, 0x2, 0x2, 0x31e, 0x320, 0x7, 0x71, 0x2, + 0x2, 0x31f, 0x31e, 0x3, 0x2, 0x2, 0x2, 0x31f, 0x320, + 0x3, 0x2, 0x2, 0x2, 0x320, 0x322, 0x3, 0x2, 0x2, + 0x2, 0x321, 0x31d, 0x3, 0x2, 0x2, 0x2, 0x322, 0x325, + 0x3, 0x2, 0x2, 0x2, 0x323, 0x321, 0x3, 0x2, 0x2, + 0x2, 0x323, 0x324, 0x3, 0x2, 0x2, 0x2, 0x324, 0x326, + 0x3, 0x2, 0x2, 0x2, 0x325, 0x323, 0x3, 0x2, 0x2, + 0x2, 0x326, 0x327, 0x5, 0x6a, 0x36, 0x2, 0x327, 0x69, + 0x3, 0x2, 0x2, 0x2, 0x328, 0x35e, 0x5, 0x6c, 0x37, + 0x2, 0x329, 0x32b, 0x7, 0x71, 0x2, 0x2, 0x32a, 0x329, + 0x3, 0x2, 0x2, 0x2, 0x32a, 0x32b, 0x3, 0x2, 0x2, + 0x2, 0x32b, 0x32c, 0x3, 0x2, 0x2, 0x2, 0x32c, 0x32d, + 0x7, 0xa, 0x2, 0x2, 0x32d, 0x32e, 0x5, 0x56, 0x2c, + 0x2, 0x32e, 0x32f, 0x7, 0xc, 0x2, 0x2, 0x32f, 0x35d, + 0x3, 0x2, 0x2, 0x2, 0x330, 0x332, 0x7, 0x71, 0x2, + 0x2, 0x331, 0x330, 0x3, 0x2, 0x2, 0x2, 0x331, 0x332, + 0x3, 0x2, 0x2, 0x2, 0x332, 0x333, 0x3, 0x2, 0x2, + 0x2, 0x333, 0x335, 0x7, 0xa, 0x2, 0x2, 0x334, 0x336, + 0x5, 0x56, 0x2c, 0x2, 0x335, 0x334, 0x3, 0x2, 0x2, + 0x2, 0x335, 0x336, 0x3, 0x2, 0x2, 0x2, 0x336, 0x337, + 0x3, 0x2, 0x2, 0x2, 0x337, 0x339, 0x7, 0xf, 0x2, + 0x2, 0x338, 0x33a, 0x5, 0x56, 0x2c, 0x2, 0x339, 0x338, + 0x3, 0x2, 0x2, 0x2, 0x339, 0x33a, 0x3, 0x2, 0x2, + 0x2, 0x33a, 0x33b, 0x3, 0x2, 0x2, 0x2, 0x33b, 0x35d, + 0x7, 0xc, 0x2, 0x2, 0x33c, 0x33e, 0x7, 0x71, 0x2, + 0x2, 0x33d, 0x33c, 0x3, 0x2, 0x2, 0x2, 0x33d, 0x33e, + 0x3, 0x2, 0x2, 0x2, 0x33e, 0x33f, 0x3, 0x2, 0x2, + 0x2, 0x33f, 0x34d, 0x7, 0x15, 0x2, 0x2, 0x340, 0x341, + 0x7, 0x71, 0x2, 0x2, 0x341, 0x34d, 0x7, 0x5f, 0x2, + 0x2, 0x342, 0x343, 0x7, 0x71, 0x2, 0x2, 0x343, 0x344, + 0x7, 0x60, 0x2, 0x2, 0x344, 0x345, 0x7, 0x71, 0x2, + 0x2, 0x345, 0x34d, 0x7, 0x4f, 0x2, 0x2, 0x346, 0x347, + 0x7, 0x71, 0x2, 0x2, 0x347, 0x348, 0x7, 0x61, 0x2, + 0x2, 0x348, 0x349, 0x7, 0x71, 0x2, 0x2, 0x349, 0x34d, + 0x7, 0x4f, 0x2, 0x2, 0x34a, 0x34b, 0x7, 0x71, 0x2, + 0x2, 0x34b, 0x34d, 0x7, 0x62, 0x2, 0x2, 0x34c, 0x33d, + 0x3, 0x2, 0x2, 0x2, 0x34c, 0x340, 0x3, 0x2, 0x2, + 0x2, 0x34c, 0x342, 0x3, 0x2, 0x2, 0x2, 0x34c, 0x346, + 0x3, 0x2, 0x2, 0x2, 0x34c, 0x34a, 0x3, 0x2, 0x2, + 0x2, 0x34d, 0x34f, 0x3, 0x2, 0x2, 0x2, 0x34e, 0x350, + 0x7, 0x71, 0x2, 0x2, 0x34f, 0x34e, 0x3, 0x2, 0x2, + 0x2, 0x34f, 0x350, 0x3, 0x2, 0x2, 0x2, 0x350, 0x351, + 0x3, 0x2, 0x2, 0x2, 0x351, 0x35d, 0x5, 0x6c, 0x37, + 0x2, 0x352, 0x353, 0x7, 0x71, 0x2, 0x2, 0x353, 0x354, + 0x7, 0x63, 0x2, 0x2, 0x354, 0x355, 0x7, 0x71, 0x2, + 0x2, 0x355, 0x35d, 0x7, 0x64, 0x2, 0x2, 0x356, 0x357, + 0x7, 0x71, 0x2, 0x2, 0x357, 0x358, 0x7, 0x63, 0x2, + 0x2, 0x358, 0x359, 0x7, 0x71, 0x2, 0x2, 0x359, 0x35a, + 0x7, 0x5e, 0x2, 0x2, 0x35a, 0x35b, 0x7, 0x71, 0x2, + 0x2, 0x35b, 0x35d, 0x7, 0x64, 0x2, 0x2, 0x35c, 0x32a, + 0x3, 0x2, 0x2, 0x2, 0x35c, 0x331, 0x3, 0x2, 0x2, + 0x2, 0x35c, 0x34c, 0x3, 0x2, 0x2, 0x2, 0x35c, 0x352, + 0x3, 0x2, 0x2, 0x2, 0x35c, 0x356, 0x3, 0x2, 0x2, + 0x2, 0x35d, 0x360, 0x3, 0x2, 0x2, 0x2, 0x35e, 0x35c, + 0x3, 0x2, 0x2, 0x2, 0x35e, 0x35f, 0x3, 0x2, 0x2, + 0x2, 0x35f, 0x6b, 0x3, 0x2, 0x2, 0x2, 0x360, 0x35e, + 0x3, 0x2, 0x2, 0x2, 0x361, 0x366, 0x5, 0x6e, 0x38, + 0x2, 0x362, 0x365, 0x5, 0x86, 0x44, 0x2, 0x363, 0x365, + 0x5, 0x4c, 0x27, 0x2, 0x364, 0x362, 0x3, 0x2, 0x2, + 0x2, 0x364, 0x363, 0x3, 0x2, 0x2, 0x2, 0x365, 0x368, + 0x3, 0x2, 0x2, 0x2, 0x366, 0x364, 0x3, 0x2, 0x2, + 0x2, 0x366, 0x367, 0x3, 0x2, 0x2, 0x2, 0x367, 0x6d, + 0x3, 0x2, 0x2, 0x2, 0x368, 0x366, 0x3, 0x2, 0x2, + 0x2, 0x369, 0x3d9, 0x5, 0x70, 0x39, 0x2, 0x36a, 0x3d9, + 0x5, 0x8e, 0x48, 0x2, 0x36b, 0x36d, 0x7, 0x65, 0x2, + 0x2, 0x36c, 0x36e, 0x7, 0x71, 0x2, 0x2, 0x36d, 0x36c, + 0x3, 0x2, 0x2, 0x2, 0x36d, 0x36e, 0x3, 0x2, 0x2, + 0x2, 0x36e, 0x36f, 0x3, 0x2, 0x2, 0x2, 0x36f, 0x371, + 0x7, 0x8, 0x2, 0x2, 0x370, 0x372, 0x7, 0x71, 0x2, + 0x2, 0x371, 0x370, 0x3, 0x2, 0x2, 0x2, 0x371, 0x372, + 0x3, 0x2, 0x2, 0x2, 0x372, 0x373, 0x3, 0x2, 0x2, + 0x2, 0x373, 0x375, 0x7, 0x7, 0x2, 0x2, 0x374, 0x376, + 0x7, 0x71, 0x2, 0x2, 0x375, 0x374, 0x3, 0x2, 0x2, + 0x2, 0x375, 0x376, 0x3, 0x2, 0x2, 0x2, 0x376, 0x377, + 0x3, 0x2, 0x2, 0x2, 0x377, 0x3d9, 0x7, 0x9, 0x2, + 0x2, 0x378, 0x3d9, 0x5, 0x84, 0x43, 0x2, 0x379, 0x37b, + 0x7, 0x66, 0x2, 0x2, 0x37a, 0x37c, 0x7, 0x71, 0x2, + 0x2, 0x37b, 0x37a, 0x3, 0x2, 0x2, 0x2, 0x37b, 0x37c, + 0x3, 0x2, 0x2, 0x2, 0x37c, 0x37d, 0x3, 0x2, 0x2, + 0x2, 0x37d, 0x37f, 0x7, 0x8, 0x2, 0x2, 0x37e, 0x380, + 0x7, 0x71, 0x2, 0x2, 0x37f, 0x37e, 0x3, 0x2, 0x2, + 0x2, 0x37f, 0x380, 0x3, 0x2, 0x2, 0x2, 0x380, 0x381, + 0x3, 0x2, 0x2, 0x2, 0x381, 0x383, 0x5, 0x7c, 0x3f, + 0x2, 0x382, 0x384, 0x7, 0x71, 0x2, 0x2, 0x383, 0x382, + 0x3, 0x2, 0x2, 0x2, 0x383, 0x384, 0x3, 0x2, 0x2, + 0x2, 0x384, 0x385, 0x3, 0x2, 0x2, 0x2, 0x385, 0x386, + 0x7, 0x9, 0x2, 0x2, 0x386, 0x3d9, 0x3, 0x2, 0x2, + 0x2, 0x387, 0x389, 0x7, 0x67, 0x2, 0x2, 0x388, 0x38a, + 0x7, 0x71, 0x2, 0x2, 0x389, 0x388, 0x3, 0x2, 0x2, + 0x2, 0x389, 0x38a, 0x3, 0x2, 0x2, 0x2, 0x38a, 0x38b, + 0x3, 0x2, 0x2, 0x2, 0x38b, 0x38d, 0x7, 0x8, 0x2, + 0x2, 0x38c, 0x38e, 0x7, 0x71, 0x2, 0x2, 0x38d, 0x38c, + 0x3, 0x2, 0x2, 0x2, 0x38d, 0x38e, 0x3, 0x2, 0x2, + 0x2, 0x38e, 0x38f, 0x3, 0x2, 0x2, 0x2, 0x38f, 0x391, + 0x5, 0x7c, 0x3f, 0x2, 0x390, 0x392, 0x7, 0x71, 0x2, + 0x2, 0x391, 0x390, 0x3, 0x2, 0x2, 0x2, 0x391, 0x392, + 0x3, 0x2, 0x2, 0x2, 0x392, 0x398, 0x3, 0x2, 0x2, + 0x2, 0x393, 0x395, 0x7, 0x71, 0x2, 0x2, 0x394, 0x393, + 0x3, 0x2, 0x2, 0x2, 0x394, 0x395, 0x3, 0x2, 0x2, + 0x2, 0x395, 0x396, 0x3, 0x2, 0x2, 0x2, 0x396, 0x397, + 0x7, 0xe, 0x2, 0x2, 0x397, 0x399, 0x5, 0x56, 0x2c, + 0x2, 0x398, 0x394, 0x3, 0x2, 0x2, 0x2, 0x398, 0x399, + 0x3, 0x2, 0x2, 0x2, 0x399, 0x39a, 0x3, 0x2, 0x2, + 0x2, 0x39a, 0x39b, 0x7, 0x9, 0x2, 0x2, 0x39b, 0x3d9, + 0x3, 0x2, 0x2, 0x2, 0x39c, 0x39e, 0x7, 0x43, 0x2, + 0x2, 0x39d, 0x39f, 0x7, 0x71, 0x2, 0x2, 0x39e, 0x39d, + 0x3, 0x2, 0x2, 0x2, 0x39e, 0x39f, 0x3, 0x2, 0x2, + 0x2, 0x39f, 0x3a0, 0x3, 0x2, 0x2, 0x2, 0x3a0, 0x3a2, + 0x7, 0x8, 0x2, 0x2, 0x3a1, 0x3a3, 0x7, 0x71, 0x2, + 0x2, 0x3a2, 0x3a1, 0x3, 0x2, 0x2, 0x2, 0x3a2, 0x3a3, + 0x3, 0x2, 0x2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3f6, 0x3, 0x2, 0x2, 0x2, 0x3f9, 0x3e8, + 0x3, 0x2, 0x2, 0x2, 0x3f9, 0x3fa, 0x3, 0x2, 0x2, + 0x2, 0x3fa, 0x3fb, 0x3, 0x2, 0x2, 0x2, 0x3fb, 0x3fc, + 0x7, 0xc, 0x2, 0x2, 0x3fc, 0x75, 0x3, 0x2, 0x2, + 0x2, 0x3fd, 0x3ff, 0x7, 0x5, 0x2, 0x2, 0x3fe, 0x400, + 0x7, 0x71, 0x2, 0x2, 0x3ff, 0x3fe, 0x3, 0x2, 0x2, + 0x2, 0x3ff, 0x400, 0x3, 0x2, 0x2, 0x2, 0x400, 0x401, + 0x3, 0x2, 0x2, 0x2, 0x401, 0x421, 0x5, 0x62, 0x32, + 0x2, 0x402, 0x404, 0x7, 0x16, 0x2, 0x2, 0x403, 0x405, + 0x7, 0x71, 0x2, 0x2, 0x404, 0x403, 0x3, 0x2, 0x2, + 0x2, 0x404, 0x405, 0x3, 0x2, 0x2, 0x2, 0x405, 0x406, + 0x3, 0x2, 0x2, 0x2, 0x406, 0x421, 0x5, 0x62, 0x32, + 0x2, 0x407, 0x409, 0x7, 0x17, 0x2, 0x2, 0x408, 0x40a, + 0x7, 0x71, 0x2, 0x2, 0x409, 0x408, 0x3, 0x2, 0x2, + 0x2, 0x409, 0x40a, 0x3, 0x2, 0x2, 0x2, 0x40a, 0x40b, + 0x3, 0x2, 0x2, 0x2, 0x40b, 0x421, 0x5, 0x62, 0x32, + 0x2, 0x40c, 0x40e, 0x7, 0x18, 0x2, 0x2, 0x40d, 0x40f, + 0x7, 0x71, 0x2, 0x2, 0x40e, 0x40d, 0x3, 0x2, 0x2, + 0x2, 0x40e, 0x40f, 0x3, 0x2, 0x2, 0x2, 0x40f, 0x410, + 0x3, 0x2, 0x2, 0x2, 0x410, 0x421, 0x5, 0x62, 0x32, + 0x2, 0x411, 0x413, 0x7, 0x19, 0x2, 0x2, 0x412, 0x414, + 0x7, 0x71, 0x2, 0x2, 0x413, 0x412, 0x3, 0x2, 0x2, + 0x2, 0x413, 0x414, 0x3, 0x2, 0x2, 0x2, 0x414, 0x415, + 0x3, 0x2, 0x2, 0x2, 0x415, 0x421, 0x5, 0x62, 0x32, + 0x2, 0x416, 0x418, 0x7, 0x1a, 0x2, 0x2, 0x417, 0x419, + 0x7, 0x71, 0x2, 0x2, 0x418, 0x417, 0x3, 0x2, 0x2, + 0x2, 0x418, 0x419, 0x3, 0x2, 0x2, 0x2, 0x419, 0x41a, + 0x3, 0x2, 0x2, 0x2, 0x41a, 0x421, 0x5, 0x62, 0x32, + 0x2, 0x41b, 0x41d, 0x7, 0x1b, 0x2, 0x2, 0x41c, 0x41e, + 0x7, 0x71, 0x2, 0x2, 0x41d, 0x41c, 0x3, 0x2, 0x2, + 0x2, 0x41d, 0x41e, 0x3, 0x2, 0x2, 0x2, 0x41e, 0x41f, + 0x3, 0x2, 0x2, 0x2, 0x41f, 0x421, 0x5, 0x62, 0x32, + 0x2, 0x420, 0x3fd, 0x3, 0x2, 0x2, 0x2, 0x420, 0x402, + 0x3, 0x2, 0x2, 0x2, 0x420, 0x407, 0x3, 0x2, 0x2, + 0x2, 0x420, 0x40c, 0x3, 0x2, 0x2, 0x2, 0x420, 0x411, + 0x3, 0x2, 0x2, 0x2, 0x420, 0x416, 0x3, 0x2, 0x2, + 0x2, 0x420, 0x41b, 0x3, 0x2, 0x2, 0x2, 0x421, 0x77, + 0x3, 0x2, 0x2, 0x2, 0x422, 0x424, 0x7, 0x8, 0x2, + 0x2, 0x423, 0x425, 0x7, 0x71, 0x2, 0x2, 0x424, 0x423, + 0x3, 0x2, 0x2, 0x2, 0x424, 0x425, 0x3, 0x2, 0x2, + 0x2, 0x425, 0x426, 0x3, 0x2, 0x2, 0x2, 0x426, 0x428, + 0x5, 0x56, 0x2c, 0x2, 0x427, 0x429, 0x7, 0x71, 0x2, + 0x2, 0x428, 0x427, 0x3, 0x2, 0x2, 0x2, 0x428, 0x429, + 0x3, 0x2, 0x2, 0x2, 0x429, 0x42a, 0x3, 0x2, 0x2, + 0x2, 0x42a, 0x42b, 0x7, 0x9, 0x2, 0x2, 0x42b, 0x79, + 0x3, 0x2, 0x2, 0x2, 0x42c, 0x431, 0x5, 0x40, 0x21, + 0x2, 0x42d, 0x42f, 0x7, 0x71, 0x2, 0x2, 0x42e, 0x42d, + 0x3, 0x2, 0x2, 0x2, 0x42e, 0x42f, 0x3, 0x2, 0x2, + 0x2, 0x42f, 0x430, 0x3, 0x2, 0x2, 0x2, 0x430, 0x432, + 0x5, 0x42, 0x22, 0x2, 0x431, 0x42e, 0x3, 0x2, 0x2, + 0x2, 0x432, 0x433, 0x3, 0x2, 0x2, 0x2, 0x433, 0x431, + 0x3, 0x2, 0x2, 0x2, 0x433, 0x434, 0x3, 0x2, 0x2, + 0x2, 0x434, 0x7b, 0x3, 0x2, 0x2, 0x2, 0x435, 0x43a, + 0x5, 0x7e, 0x40, 0x2, 0x436, 0x438, 0x7, 0x71, 0x2, + 0x2, 0x437, 0x436, 0x3, 0x2, 0x2, 0x2, 0x437, 0x438, + 0x3, 0x2, 0x2, 0x2, 0x438, 0x439, 0x3, 0x2, 0x2, + 0x2, 0x439, 0x43b, 0x5, 0x36, 0x1c, 0x2, 0x43a, 0x437, + 0x3, 0x2, 0x2, 0x2, 0x43a, 0x43b, 0x3, 0x2, 0x2, + 0x2, 0x43b, 0x7d, 0x3, 0x2, 0x2, 0x2, 0x43c, 0x43d, + 0x5, 0x88, 0x45, 0x2, 0x43d, 0x43e, 0x7, 0x71, 0x2, + 0x2, 0x43e, 0x43f, 0x7, 0x5f, 0x2, 0x2, 0x43f, 0x440, + 0x7, 0x71, 0x2, 0x2, 0x440, 0x441, 0x5, 0x56, 0x2c, + 0x2, 0x441, 0x7f, 0x3, 0x2, 0x2, 0x2, 0x442, 0x444, + 0x5, 0x82, 0x42, 0x2, 0x443, 0x445, 0x7, 0x71, 0x2, + 0x2, 0x444, 0x443, 0x3, 0x2, 0x2, 0x2, 0x444, 0x445, + 0x3, 0x2, 0x2, 0x2, 0x445, 0x446, 0x3, 0x2, 0x2, + 0x2, 0x446, 0x448, 0x7, 0x8, 0x2, 0x2, 0x447, 0x449, + 0x7, 0x71, 0x2, 0x2, 0x448, 0x447, 0x3, 0x2, 0x2, + 0x2, 0x448, 0x449, 0x3, 0x2, 0x2, 0x2, 0x449, 0x44e, + 0x3, 0x2, 0x2, 0x2, 0x44a, 0x44c, 0x7, 0x50, 0x2, + 0x2, 0x44b, 0x44d, 0x7, 0x71, 0x2, 0x2, 0x44c, 0x44b, + 0x3, 0x2, 0x2, 0x2, 0x44c, 0x44d, 0x3, 0x2, 0x2, + 0x2, 0x44d, 0x44f, 0x3, 0x2, 0x2, 0x2, 0x44e, 0x44a, + 0x3, 0x2, 0x2, 0x2, 0x44e, 0x44f, 0x3, 0x2, 0x2, + 0x2, 0x44f, 0x461, 0x3, 0x2, 0x2, 0x2, 0x450, 0x452, + 0x5, 0x56, 0x2c, 0x2, 0x451, 0x453, 0x7, 0x71, 0x2, + 0x2, 0x452, 0x451, 0x3, 0x2, 0x2, 0x2, 0x452, 0x453, + 0x3, 0x2, 0x2, 0x2, 0x453, 0x45e, 0x3, 0x2, 0x2, + 0x2, 0x454, 0x456, 0x7, 0x4, 0x2, 0x2, 0x455, 0x457, + 0x7, 0x71, 0x2, 0x2, 0x456, 0x455, 0x3, 0x2, 0x2, + 0x2, 0x456, 0x457, 0x3, 0x2, 0x2, 0x2, 0x457, 0x458, + 0x3, 0x2, 0x2, 0x2, 0x458, 0x45a, 0x5, 0x56, 0x2c, + 0x2, 0x459, 0x45b, 0x7, 0x71, 0x2, 0x2, 0x45a, 0x459, + 0x3, 0x2, 0x2, 0x2, 0x45a, 0x45b, 0x3, 0x2, 0x2, + 0x2, 0x45b, 0x45d, 0x3, 0x2, 0x2, 0x2, 0x45c, 0x454, + 0x3, 0x2, 0x2, 0x2, 0x45d, 0x460, 0x3, 0x2, 0x2, + 0x2, 0x45e, 0x45c, 0x3, 0x2, 0x2, 0x2, 0x45e, 0x45f, + 0x3, 0x2, 0x2, 0x2, 0x45f, 0x462, 0x3, 0x2, 0x2, + 0x2, 0x460, 0x45e, 0x3, 0x2, 0x2, 0x2, 0x461, 0x450, + 0x3, 0x2, 0x2, 0x2, 0x461, 0x462, 0x3, 0x2, 0x2, + 0x2, 0x462, 0x463, 0x3, 0x2, 0x2, 0x2, 0x463, 0x464, + 0x7, 0x9, 0x2, 0x2, 0x464, 0x81, 0x3, 0x2, 0x2, + 0x2, 0x465, 0x466, 0x9, 0x5, 0x2, 0x2, 0x466, 0x83, + 0x3, 0x2, 0x2, 0x2, 0x467, 0x469, 0x7, 0xa, 0x2, + 0x2, 0x468, 0x46a, 0x7, 0x71, 0x2, 0x2, 0x469, 0x468, + 0x3, 0x2, 0x2, 0x2, 0x469, 0x46a, 0x3, 0x2, 0x2, + 0x2, 0x46a, 0x46b, 0x3, 0x2, 0x2, 0x2, 0x46b, 0x474, + 0x5, 0x7c, 0x3f, 0x2, 0x46c, 0x46e, 0x7, 0x71, 0x2, + 0x2, 0x46d, 0x46c, 0x3, 0x2, 0x2, 0x2, 0x46d, 0x46e, + 0x3, 0x2, 0x2, 0x2, 0x46e, 0x46f, 0x3, 0x2, 0x2, + 0x2, 0x46f, 0x471, 0x7, 0xe, 0x2, 0x2, 0x470, 0x472, + 0x7, 0x71, 0x2, 0x2, 0x471, 0x470, 0x3, 0x2, 0x2, + 0x2, 0x471, 0x472, 0x3, 0x2, 0x2, 0x2, 0x472, 0x473, + 0x3, 0x2, 0x2, 0x2, 0x473, 0x475, 0x5, 0x56, 0x2c, + 0x2, 0x474, 0x46d, 0x3, 0x2, 0x2, 0x2, 0x474, 0x475, + 0x3, 0x2, 0x2, 0x2, 0x475, 0x477, 0x3, 0x2, 0x2, + 0x2, 0x476, 0x478, 0x7, 0x71, 0x2, 0x2, 0x477, 0x476, + 0x3, 0x2, 0x2, 0x2, 0x477, 0x478, 0x3, 0x2, 0x2, + 0x2, 0x478, 0x479, 0x3, 0x2, 0x2, 0x2, 0x479, 0x47a, + 0x7, 0xc, 0x2, 0x2, 0x47a, 0x85, 0x3, 0x2, 0x2, + 0x2, 0x47b, 0x47d, 0x7, 0x71, 0x2, 0x2, 0x47c, 0x47b, + 0x3, 0x2, 0x2, 0x2, 0x47c, 0x47d, 0x3, 0x2, 0x2, + 0x2, 0x47d, 0x47e, 0x3, 0x2, 0x2, 0x2, 0x47e, 0x480, + 0x7, 0x1c, 0x2, 0x2, 0x47f, 0x481, 0x7, 0x71, 0x2, + 0x2, 0x480, 0x47f, 0x3, 0x2, 0x2, 0x2, 0x480, 0x481, + 0x3, 0x2, 0x2, 0x2, 0x481, 0x486, 0x3, 0x2, 0x2, + 0x2, 0x482, 0x483, 0x5, 0x92, 0x4a, 0x2, 0x483, 0x484, + 0x9, 0x6, 0x2, 0x2, 0x484, 0x487, 0x3, 0x2, 0x2, + 0x2, 0x485, 0x487, 0x5, 0x92, 0x4a, 0x2, 0x486, 0x482, + 0x3, 0x2, 0x2, 0x2, 0x486, 0x485, 0x3, 0x2, 0x2, + 0x2, 0x487, 0x87, 0x3, 0x2, 0x2, 0x2, 0x488, 0x489, + 0x5, 0x98, 0x4d, 0x2, 0x489, 0x89, 0x3, 0x2, 0x2, + 0x2, 0x48a, 0x48d, 0x5, 0x96, 0x4c, 0x2, 0x48b, 0x48d, + 0x5, 0x94, 0x4b, 0x2, 0x48c, 0x48a, 0x3, 0x2, 0x2, + 0x2, 0x48c, 0x48b, 0x3, 0x2, 0x2, 0x2, 0x48d, 0x8b, + 0x3, 0x2, 0x2, 0x2, 0x48e, 0x490, 0x7, 0x1e, 0x2, + 0x2, 0x48f, 0x491, 0x7, 0x71, 0x2, 0x2, 0x490, 0x48f, + 0x3, 0x2, 0x2, 0x2, 0x490, 0x491, 0x3, 0x2, 0x2, + 0x2, 0x491, 0x4b3, 0x3, 0x2, 0x2, 0x2, 0x492, 0x494, + 0x5, 0x92, 0x4a, 0x2, 0x493, 0x495, 0x7, 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 0x4c4, 0x91, 0x3, 0x2, 0x2, 0x2, 0x4c5, 0x4c6, + 0x5, 0x98, 0x4d, 0x2, 0x4c6, 0x93, 0x3, 0x2, 0x2, + 0x2, 0x4c7, 0x4c8, 0x9, 0x7, 0x2, 0x2, 0x4c8, 0x95, + 0x3, 0x2, 0x2, 0x2, 0x4c9, 0x4ca, 0x9, 0x8, 0x2, + 0x2, 0x4ca, 0x97, 0x3, 0x2, 0x2, 0x2, 0x4cb, 0x4cc, + 0x9, 0x9, 0x2, 0x2, 0x4cc, 0x99, 0x3, 0x2, 0x2, + 0x2, 0x4cd, 0x4ce, 0x9, 0xa, 0x2, 0x2, 0x4ce, 0x9b, + 0x3, 0x2, 0x2, 0x2, 0x4cf, 0x4d0, 0x9, 0xb, 0x2, + 0x2, 0x4d0, 0x9d, 0x3, 0x2, 0x2, 0x2, 0x4d1, 0x4d2, + 0x9, 0xc, 0x2, 0x2, 0x4d2, 0x9f, 0x3, 0x2, 0x2, + 0x2, 0xdd, 0xa1, 0xa5, 0xa8, 0xab, 0xb3, 0xb8, 0xbd, + 0xc2, 0xc9, 0xce, 0xd1, 0xdc, 0xe0, 0xe4, 0xe8, 0xeb, + 0xef, 0xf9, 0x100, 0x10d, 0x111, 0x11b, 0x12d, 0x131, 0x135, + 0x139, 0x13d, 0x142, 0x149, 0x14d, 0x152, 0x159, 0x15d, 0x160, + 0x165, 0x168, 0x16c, 0x16f, 0x177, 0x17b, 0x17f, 0x183, 0x187, + 0x18c, 0x191, 0x195, 0x19a, 0x19d, 0x1a6, 0x1af, 0x1b4, 0x1c1, + 0x1c4, 0x1cc, 0x1d0, 0x1d5, 0x1da, 0x1de, 0x1e3, 0x1e9, 0x1ee, + 0x1f5, 0x1f9, 0x1fd, 0x1ff, 0x203, 0x205, 0x209, 0x20b, 0x211, + 0x217, 0x21b, 0x21e, 0x221, 0x225, 0x22b, 0x22f, 0x232, 0x235, + 0x23b, 0x23e, 0x241, 0x245, 0x24b, 0x24e, 0x251, 0x255, 0x259, + 0x25c, 0x25f, 0x262, 0x265, 0x26b, 0x270, 0x274, 0x277, 0x27c, + 0x281, 0x286, 0x28e, 0x292, 0x294, 0x298, 0x29c, 0x29e, 0x2a0, + 0x2af, 0x2b9, 0x2c3, 0x2c8, 0x2cc, 0x2d3, 0x2d8, 0x2dd, 0x2e1, + 0x2e5, 0x2e9, 0x2ec, 0x2ee, 0x2f3, 0x2f7, 0x2fb, 0x2ff, 0x303, + 0x307, 0x30a, 0x30c, 0x311, 0x315, 0x31a, 0x31f, 0x323, 0x32a, + 0x331, 0x335, 0x339, 0x33d, 0x34c, 0x34f, 0x35c, 0x35e, 0x364, + 0x366, 0x36d, 0x371, 0x375, 0x37b, 0x37f, 0x383, 0x389, 0x38d, + 0x391, 0x394, 0x398, 0x39e, 0x3a2, 0x3a6, 0x3ac, 0x3b0, 0x3b4, + 0x3ba, 0x3be, 0x3c2, 0x3c8, 0x3cc, 0x3d0, 0x3d8, 0x3e0, 0x3e6, + 0x3ea, 0x3ee, 0x3f2, 0x3f6, 0x3f9, 0x3ff, 0x404, 0x409, 0x40e, + 0x413, 0x418, 0x41d, 0x420, 0x424, 0x428, 0x42e, 0x433, 0x437, + 0x43a, 0x444, 0x448, 0x44c, 0x44e, 0x452, 0x456, 0x45a, 0x45e, + 0x461, 0x469, 0x46d, 0x471, 0x474, 0x477, 0x47c, 0x480, 0x486, + 0x48c, 0x490, 0x494, 0x498, 0x49c, 0x4a0, 0x4a4, 0x4a8, 0x4ac, + 0x4b0, 0x4b3, 0x4ba, 0x4be, 0x4c3, }; atn::ATNDeserializer deserializer; @@ -10210,7 +10680,7 @@ CypherParser::Initializer::Initializer() { size_t count = _atn.getNumberOfDecisions(); _decisionToDFA.reserve(count); - for (size_t i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { _decisionToDFA.emplace_back(_atn.getDecisionState(i), i); } } diff --git a/src/query/frontend/opencypher/generated/CypherVisitor.cpp b/src/query/frontend/opencypher/generated/CypherVisitor.cpp index 0b56ca8fd..7cf88770c 100644 --- a/src/query/frontend/opencypher/generated/CypherVisitor.cpp +++ b/src/query/frontend/opencypher/generated/CypherVisitor.cpp @@ -1,9 +1,8 @@ -// Generated from /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 by ANTLR 4.6 - +// Generated from +// /home/buda/Workspace/code/memgraph/memgraph/src/query/frontend/opencypher/grammar/Cypher.g4 +// by ANTLR 4.6 #include "CypherVisitor.h" - using namespace antlrcpptest; - diff --git a/src/query/stripper.hpp b/src/query/stripper.hpp index d932a2d9e..2c3b888f3 100644 --- a/src/query/stripper.hpp +++ b/src/query/stripper.hpp @@ -40,9 +40,10 @@ class QueryStripper : public Loggable { * Strips the input query (openCypher query). * * @param query input query - * @param separator char that is added between all literals in the stripped query - * because after stripping compiler frontend will use the stripped query to - * AST and literals have to be separated + * @param separator char that is added between all literals in the stripped + * query because after stripping compiler frontend will use the stripped + * query to AST and literals have to be separated + * * @return stripped query, stripped arguments and stripped query hash as a * single object of class StrippedQuery */ diff --git a/src/serialization/graph_decoder.hpp b/src/serialization/graph_decoder.hpp index 13439ffe1..7d2130e0a 100644 --- a/src/serialization/graph_decoder.hpp +++ b/src/serialization/graph_decoder.hpp @@ -11,37 +11,36 @@ // // // End goal would be to enforce these rules during compile time. -class GraphDecoder -{ -public: - // Starts reading vertex. - Id vertex_start(); +class GraphDecoder { + public: + // Starts reading vertex. + Id vertex_start(); - // Returns number of stored labels. - size_t label_count(); + // Returns number of stored labels. + size_t label_count(); - // Wiil read label into given storage. - std::string const &label(); + // Wiil read label into given storage. + std::string const &label(); - // Ends reading vertex - void vertex_end() {} + // Ends reading vertex + void vertex_end() {} - // Starts reading edge. Return from to ids of connected vertices. - std::pair<Id, Id> edge_start(); + // Starts reading edge. Return from to ids of connected vertices. + std::pair<Id, Id> edge_start(); - // Reads edge_type into given storage. - std::string const &edge_type(); + // Reads edge_type into given storage. + std::string const &edge_type(); - // Ends reading edge. - void edge_end() {} + // Ends reading edge. + void edge_end() {} - // Returns number of stored propertys. - size_t property_count(); + // Returns number of stored propertys. + size_t property_count(); - // Reads property name into given storage. - std::string const &property_name(); + // Reads property name into given storage. + std::string const &property_name(); - // Reads property and calls T::handle for that property . - template <class T> - T property(); + // Reads property and calls T::handle for that property . + template <class T> + T property(); }; diff --git a/src/serialization/graph_encoder.hpp b/src/serialization/graph_encoder.hpp index 589b036f9..c7374ecf9 100644 --- a/src/serialization/graph_encoder.hpp +++ b/src/serialization/graph_encoder.hpp @@ -24,59 +24,58 @@ // 1 end_edge // // End goal would be to enforce these rules during compile time. -class GraphEncoder -{ -public: - // Starts writing vertex with given id. - void start_vertex(Id id) {} +class GraphEncoder { + public: + // Starts writing vertex with given id. + void start_vertex(Id id) {} - // Number of following label calls. - void label_count(size_t n); + // Number of following label calls. + void label_count(size_t n); - // Label of currently started vertex. - void label(std::string const &l) {} + // Label of currently started vertex. + void label(std::string const &l) {} - // Ends writing vertex - void end_vertex() {} + // Ends writing vertex + void end_vertex() {} - // Starts writing edge from vertex to vertex - void start_edge(Id from, Id to) {} + // Starts writing edge from vertex to vertex + void start_edge(Id from, Id to) {} - // Type of currently started edge - void edge_type(std::string const &et) {} + // Type of currently started edge + void edge_type(std::string const &et) {} - // Ends writing edge - void end_edge() {} + // Ends writing edge + void end_edge() {} - // Number of following paired property_name,handle calls. - void property_count(size_t n); + // Number of following paired property_name,handle calls. + void property_count(size_t n); - // Property family name of next property for currently started element. - void property_name(std::string const &name) {} + // Property family name of next property for currently started element. + void property_name(std::string const &name) {} - void handle(const Void &v) {} + void handle(const Void &v) {} - void handle(const bool &prop) {} + void handle(const bool &prop) {} - void handle(const float &prop) {} + void handle(const float &prop) {} - void handle(const double &prop) {} + void handle(const double &prop) {} - void handle(const int32_t &prop) {} + void handle(const int32_t &prop) {} - void handle(const int64_t &prop) {} + void handle(const int64_t &prop) {} - void handle(const std::string &value) {} + void handle(const std::string &value) {} - void handle(const ArrayStore<bool> &) {} + void handle(const ArrayStore<bool> &) {} - void handle(const ArrayStore<int32_t> &) {} + void handle(const ArrayStore<int32_t> &) {} - void handle(const ArrayStore<int64_t> &) {} + void handle(const ArrayStore<int64_t> &) {} - void handle(const ArrayStore<float> &) {} + void handle(const ArrayStore<float> &) {} - void handle(const ArrayStore<double> &) {} + void handle(const ArrayStore<double> &) {} - void handle(const ArrayStore<std::string> &) {} + void handle(const ArrayStore<std::string> &) {} }; diff --git a/src/serialization/serialization.hpp b/src/serialization/serialization.hpp index db71cd651..888423a1e 100644 --- a/src/serialization/serialization.hpp +++ b/src/serialization/serialization.hpp @@ -6,108 +6,102 @@ #include "storage/label/label.hpp" #include "storage/vertex_accessor.hpp" -namespace serialization -{ +namespace serialization { // Serializes Vertex to given writer which implements GraphEncoder. template <class W> -void serialize_vertex(VertexAccessor const &v, W &writer) -{ - // Serialize vertex id - writer.start_vertex(v.id()); +void serialize_vertex(VertexAccessor const &v, W &writer) { + // Serialize vertex id + writer.start_vertex(v.id()); - // Serialize labels - auto const &labels = v.labels(); - writer.label_count(labels.size()); - for (auto &label : labels) { - writer.label(label.get().str()); - } + // Serialize labels + auto const &labels = v.labels(); + writer.label_count(labels.size()); + for (auto &label : labels) { + writer.label(label.get().str()); + } - // Serialize propertys - auto const &propertys = v.properties(); - writer.property_count(propertys.size()); - for (auto &prop : propertys) { - writer.property_name(prop.key.family_name()); - prop.accept_primitive(writer); - } + // Serialize propertys + auto const &propertys = v.properties(); + writer.property_count(propertys.size()); + for (auto &prop : propertys) { + writer.property_name(prop.key.family_name()); + prop.accept_primitive(writer); + } - writer.end_vertex(); + writer.end_vertex(); } // Serializes Edge to given writer which implements GraphEncoder. template <class W> -void serialize_edge(EdgeAccessor const &e, W &writer) -{ - // Serialize to and from vertices ids. - writer.start_edge(e.from().id(), e.to().id()); +void serialize_edge(EdgeAccessor const &e, W &writer) { + // Serialize to and from vertices ids. + writer.start_edge(e.from().id(), e.to().id()); - // Serialize type - writer.edge_type(e.edge_type().str()); + // Serialize type + writer.edge_type(e.edge_type().str()); - // Serialize propertys - auto const &propertys = e.properties(); - writer.property_count(propertys.size()); - for (auto &prop : propertys) { - writer.property_name(prop.key.family_name()); - prop.accept_primitive(writer); - } + // Serialize propertys + auto const &propertys = e.properties(); + writer.property_count(propertys.size()); + for (auto &prop : propertys) { + writer.property_name(prop.key.family_name()); + prop.accept_primitive(writer); + } - writer.end_edge(); + writer.end_edge(); } // Deserializes vertex from reader into database db. Returns Id which vertex had // in the reader and VertexAccessor. template <class D> -std::pair<Id, VertexAccessor> deserialize_vertex(DbAccessor &db, D &reader) -{ - auto v = db.vertex_insert(); - auto old_id = reader.vertex_start(); +std::pair<Id, VertexAccessor> deserialize_vertex(DbAccessor &db, D &reader) { + auto v = db.vertex_insert(); + auto old_id = reader.vertex_start(); - // Deserialize labels - std::string s; - for (auto i = reader.label_count(); i > 0; i--) { - auto &label_key = db.label_find_or_create(reader.label().c_str()); - v.add_label(label_key); - } + // Deserialize labels + std::string s; + for (auto i = reader.label_count(); i > 0; i--) { + auto &label_key = db.label_find_or_create(reader.label().c_str()); + v.add_label(label_key); + } - // Deserialize propertys - for (auto i = reader.property_count(); i > 0; i--) { - auto &family = - db.vertex_property_family_get(reader.property_name().c_str()); - v.set(StoredProperty<TypeGroupVertex>( - family, reader.template property<Property>())); - } + // Deserialize propertys + for (auto i = reader.property_count(); i > 0; i--) { + auto &family = + db.vertex_property_family_get(reader.property_name().c_str()); + v.set(StoredProperty<TypeGroupVertex>( + family, reader.template property<Property>())); + } - reader.vertex_end(); - return std::make_pair(old_id, v); + reader.vertex_end(); + return std::make_pair(old_id, v); } // Deserializes edge from reader into database db. Returns loaded EdgeAccessor. // S - is the storage with at() method for accesing VertexAccessor under thers // deserialization local id returnd from deserialize_vertex. template <class D, class S> -EdgeAccessor deserialize_edge(DbAccessor &db, D &reader, S &store) -{ - auto ids = reader.edge_start(); - // Deserialize from and to ids of vertices. - VertexAccessor &from = store.at(ids.first); - VertexAccessor &to = store.at(ids.second); +EdgeAccessor deserialize_edge(DbAccessor &db, D &reader, S &store) { + auto ids = reader.edge_start(); + // Deserialize from and to ids of vertices. + VertexAccessor &from = store.at(ids.first); + VertexAccessor &to = store.at(ids.second); - auto e = db.edge_insert(from, to); + auto e = db.edge_insert(from, to); - // Deserialize type - auto &edge_type_key = db.type_find_or_create(reader.edge_type().c_str()); - e.edge_type(edge_type_key); + // Deserialize type + auto &edge_type_key = db.type_find_or_create(reader.edge_type().c_str()); + e.edge_type(edge_type_key); - // Deserialize properties - for (auto i = reader.property_count(); i > 0; i--) { - auto &family = - db.edge_property_family_get(reader.property_name().c_str()); - e.set(StoredProperty<TypeGroupEdge>( - family, reader.template property<Property>())); - } + // Deserialize properties + for (auto i = reader.property_count(); i > 0; i--) { + auto &family = db.edge_property_family_get(reader.property_name().c_str()); + e.set(StoredProperty<TypeGroupEdge>(family, + reader.template property<Property>())); + } - reader.edge_end(); - return e; + reader.edge_end(); + return e; } }; diff --git a/src/snapshot/snapshot_decoder.cpp b/src/snapshot/snapshot_decoder.cpp index de548c78a..4a505621c 100644 --- a/src/snapshot/snapshot_decoder.cpp +++ b/src/snapshot/snapshot_decoder.cpp @@ -1,100 +1,89 @@ #include "snapshot/snapshot_decoder.hpp" -SnapshotDecoder::SnapshotDecoder(std::ifstream &snap_file) : decoder(snap_file) -{ -} +SnapshotDecoder::SnapshotDecoder(std::ifstream &snap_file) + : decoder(snap_file) {} // Loads propert names, label names, edge_type names. -void SnapshotDecoder::load_init() -{ - for (auto i = decoder.map_header(); i > 0; i--) { - std::string name; - decoder.string(name); - auto id = decoder.integer(); - property_name_map.insert(std::make_pair(id, std::move(name))); - } +void SnapshotDecoder::load_init() { + for (auto i = decoder.map_header(); i > 0; i--) { + std::string name; + decoder.string(name); + auto id = decoder.integer(); + property_name_map.insert(std::make_pair(id, std::move(name))); + } - for (auto i = decoder.map_header(); i > 0; i--) { - std::string name; - decoder.string(name); - auto id = decoder.integer(); - label_name_map.insert(std::make_pair(id, std::move(name))); - } + for (auto i = decoder.map_header(); i > 0; i--) { + std::string name; + decoder.string(name); + auto id = decoder.integer(); + label_name_map.insert(std::make_pair(id, std::move(name))); + } - for (auto i = decoder.map_header(); i > 0; i--) { - std::string name; - decoder.string(name); - auto id = decoder.integer(); - edge_type_name_map.insert(std::make_pair(id, std::move(name))); - } + for (auto i = decoder.map_header(); i > 0; i--) { + std::string name; + decoder.string(name); + auto id = decoder.integer(); + edge_type_name_map.insert(std::make_pair(id, std::move(name))); + } } // Begins process of reading vertices -void SnapshotDecoder::begin_vertices() -{ - std::string name; - decoder.string(name); - if (name != "vertices") { - throw DecoderException( - "Tryed to start reading vertices on illegal position marked as: " + - name); - } +void SnapshotDecoder::begin_vertices() { + std::string name; + decoder.string(name); + if (name != "vertices") { + throw DecoderException( + "Tryed to start reading vertices on illegal position marked as: " + + name); + } } // True if it is end of vertices -bool SnapshotDecoder::end_vertices() -{ - std::string name; - bool ret = decoder.string_try(name); - if (ret && name != "edges") { - throw DecoderException( - "Tryed to end reading vertices on illegal position marked as: " + - name); - } - return ret; +bool SnapshotDecoder::end_vertices() { + std::string name; + bool ret = decoder.string_try(name); + if (ret && name != "edges") { + throw DecoderException( + "Tryed to end reading vertices on illegal position marked as: " + name); + } + return ret; } // Begins process of loading edges -void SnapshotDecoder::begin_edges() -{ - // EMPTY +void SnapshotDecoder::begin_edges() { + // EMPTY } // True if it is end of edges -bool SnapshotDecoder::end_edges() -{ - std::string name; - bool ret = decoder.string_try(name); - if (ret && name != "indexes") { - throw DecoderException( - "Tryed to end reading edges on illegal position marked as: " + - name); - } - return ret; +bool SnapshotDecoder::end_edges() { + std::string name; + bool ret = decoder.string_try(name); + if (ret && name != "indexes") { + throw DecoderException( + "Tryed to end reading edges on illegal position marked as: " + name); + } + return ret; } // Begins process of reading indexes. -void SnapshotDecoder::start_indexes() -{ - // EMPTY +void SnapshotDecoder::start_indexes() { + // EMPTY } // Loads IndexDefinition. -IndexDefinition SnapshotDecoder::load_index() -{ - return IndexDefinition::deserialize(decoder); +IndexDefinition SnapshotDecoder::load_index() { + return IndexDefinition::deserialize(decoder); } // True if it is end. -bool SnapshotDecoder::end() -{ - std::string name; - bool ret = decoder.string_try(name); - if (ret && name != "end") { - throw DecoderException("Tryed to end on illegal position marked as: " + - name); - } - return ret; +bool SnapshotDecoder::end() { + std::string name; + bool ret = decoder.string_try(name); + if (ret && name != "end") { + throw DecoderException("Tryed to end on illegal position marked as: " + + name); + } + return ret; } // ***************** from GraphDecoder @@ -105,30 +94,26 @@ Id SnapshotDecoder::vertex_start() { return Id(decoder.integer()); } size_t SnapshotDecoder::label_count() { return decoder.list_header(); } // Wiil read label into given storage. -std::string const &SnapshotDecoder::label() -{ - return label_name_map.at(decoder.integer()); +std::string const &SnapshotDecoder::label() { + return label_name_map.at(decoder.integer()); } // Starts reading edge. Return from to ids of connected vertices. -std::pair<Id, Id> SnapshotDecoder::edge_start() -{ - auto from = Id(decoder.integer()); - auto to = Id(decoder.integer()); - return std::make_pair(from, to); +std::pair<Id, Id> SnapshotDecoder::edge_start() { + auto from = Id(decoder.integer()); + auto to = Id(decoder.integer()); + return std::make_pair(from, to); } // Reads edge_type into given storage. -std::string const &SnapshotDecoder::edge_type() -{ - return edge_type_name_map.at(decoder.integer()); +std::string const &SnapshotDecoder::edge_type() { + return edge_type_name_map.at(decoder.integer()); } // Returns number of stored propertys. size_t SnapshotDecoder::property_count() { return decoder.map_header(); } // Reads property name into given storage. -std::string const &SnapshotDecoder::property_name() -{ - return property_name_map.at(decoder.integer()); +std::string const &SnapshotDecoder::property_name() { + return property_name_map.at(decoder.integer()); } diff --git a/src/snapshot/snapshot_decoder.hpp b/src/snapshot/snapshot_decoder.hpp index b6b5b6007..f127f22f6 100644 --- a/src/snapshot/snapshot_decoder.hpp +++ b/src/snapshot/snapshot_decoder.hpp @@ -15,128 +15,127 @@ // Main idea of knowing when something starts and ends is at certain points try // to deserialize string and compare it with logically expected string seted by // the SnapshotEncoder. -class SnapshotDecoder : public GraphDecoder -{ -public: - SnapshotDecoder(std::ifstream &snap_file); +class SnapshotDecoder : public GraphDecoder { + public: + SnapshotDecoder(std::ifstream &snap_file); - // Loads propert names, label names, edge_type names. - void load_init(); + // Loads propert names, label names, edge_type names. + void load_init(); - // Begins process of reading vertices - void begin_vertices(); + // Begins process of reading vertices + void begin_vertices(); - // True if it is end of vertices - bool end_vertices(); + // True if it is end of vertices + bool end_vertices(); - // Begins process of loading edges - void begin_edges(); + // Begins process of loading edges + void begin_edges(); - // True if it is end of edges - bool end_edges(); + // True if it is end of edges + bool end_edges(); - // Begins process of reading indexes. - void start_indexes(); + // Begins process of reading indexes. + void start_indexes(); - // Loads IndexDefinition. - IndexDefinition load_index(); + // Loads IndexDefinition. + IndexDefinition load_index(); - // True if it is end. - bool end(); + // True if it is end. + bool end(); - // ***************** from GraphDecoder - // Starts reading vertex. - Id vertex_start(); + // ***************** from GraphDecoder + // Starts reading vertex. + Id vertex_start(); - // Returns number of stored labels. - size_t label_count(); + // Returns number of stored labels. + size_t label_count(); - // Wiil read label into given storage. - std::string const &label(); + // Wiil read label into given storage. + std::string const &label(); - // Starts reading edge. Return from to ids of connected vertices. - std::pair<Id, Id> edge_start(); + // Starts reading edge. Return from to ids of connected vertices. + std::pair<Id, Id> edge_start(); - // Reads edge_type into given storage. - std::string const &edge_type(); + // Reads edge_type into given storage. + std::string const &edge_type(); - // Returns number of stored propertys. - size_t property_count(); + // Returns number of stored propertys. + size_t property_count(); - // Reads property name into given storage. - std::string const &property_name(); + // Reads property name into given storage. + std::string const &property_name(); - // Reads property and calls T::handle for that property . - template <class T> - T property() - { - if (decoder.is_list()) { - // Whe are deserializing an array. + // Reads property and calls T::handle for that property . + template <class T> + T property() { + if (decoder.is_list()) { + // Whe are deserializing an array. - auto size = decoder.list_header(); - if (decoder.is_bool()) { - ArrayStore<bool> store; - for (auto i = 0; i < size; i++) { - store.push_back(decoder.read_bool()); - } - return T::handle(std::move(store)); - - } else if (decoder.is_integer()) { - ArrayStore<int64_t> store; - for (auto i = 0; i < size; i++) { - store.push_back(decoder.integer()); - } - return T::handle(std::move(store)); - - } else if (decoder.is_double()) { - ArrayStore<double> store; - for (auto i = 0; i < size; i++) { - store.push_back(decoder.read_double()); - } - return T::handle(std::move(store)); - - } else if (decoder.is_string()) { - ArrayStore<std::string> store; - for (auto i = 0; i < size; i++) { - std::string s; - decoder.string(s); - store.push_back(std::move(s)); - } - return T::handle(std::move(store)); - } - } else { - // Whe are deserializing a primitive. - - if (decoder.is_bool()) { - return T::handle(decoder.read_bool()); - - } else if (decoder.is_integer()) { - return T::handle(decoder.integer()); - - } else if (decoder.is_double()) { - return T::handle(decoder.read_double()); - - } else if (decoder.is_string()) { - std::string s; - decoder.string(s); - return T::handle(std::move(s)); - } + auto size = decoder.list_header(); + if (decoder.is_bool()) { + ArrayStore<bool> store; + for (auto i = 0; i < size; i++) { + store.push_back(decoder.read_bool()); } + return T::handle(std::move(store)); - throw DecoderException("Tryed to read property but found " - "unknown type in bolt marked as: ", - decoder.mark()); + } else if (decoder.is_integer()) { + ArrayStore<int64_t> store; + for (auto i = 0; i < size; i++) { + store.push_back(decoder.integer()); + } + return T::handle(std::move(store)); + + } else if (decoder.is_double()) { + ArrayStore<double> store; + for (auto i = 0; i < size; i++) { + store.push_back(decoder.read_double()); + } + return T::handle(std::move(store)); + + } else if (decoder.is_string()) { + ArrayStore<std::string> store; + for (auto i = 0; i < size; i++) { + std::string s; + decoder.string(s); + store.push_back(std::move(s)); + } + return T::handle(std::move(store)); + } + } else { + // Whe are deserializing a primitive. + + if (decoder.is_bool()) { + return T::handle(decoder.read_bool()); + + } else if (decoder.is_integer()) { + return T::handle(decoder.integer()); + + } else if (decoder.is_double()) { + return T::handle(decoder.read_double()); + + } else if (decoder.is_string()) { + std::string s; + decoder.string(s); + return T::handle(std::move(s)); + } } -private: - bolt::StreamedBoltDecoder<std::ifstream> decoder; + throw DecoderException( + "Tryed to read property but found " + "unknown type in bolt marked as: ", + decoder.mark()); + } - // Contains for every property_name here snapshot local id. - std::unordered_map<size_t, std::string> property_name_map; + private: + bolt::StreamedBoltDecoder<std::ifstream> decoder; - // Contains for every label_name here snapshot local id. - std::unordered_map<size_t, std::string> label_name_map; + // Contains for every property_name here snapshot local id. + std::unordered_map<size_t, std::string> property_name_map; - // Contains for every edge_type here snapshot local id. - std::unordered_map<size_t, std::string> edge_type_name_map; + // Contains for every label_name here snapshot local id. + std::unordered_map<size_t, std::string> label_name_map; + + // Contains for every edge_type here snapshot local id. + std::unordered_map<size_t, std::string> edge_type_name_map; }; diff --git a/src/snapshot/snapshot_encoder.cpp b/src/snapshot/snapshot_encoder.cpp index 954b81c5b..daf660a97 100644 --- a/src/snapshot/snapshot_encoder.cpp +++ b/src/snapshot/snapshot_encoder.cpp @@ -1,28 +1,24 @@ #include "snapshot/snapshot_encoder.hpp" -void SnapshotEncoder::property_name_init(std::string const &name) -{ - - if (property_name_map.find(name) == property_name_map.end()) { - auto id = property_name_map.size(); - property_name_map.insert(std::make_pair(name, id)); - } +void SnapshotEncoder::property_name_init(std::string const &name) { + if (property_name_map.find(name) == property_name_map.end()) { + auto id = property_name_map.size(); + property_name_map.insert(std::make_pair(name, id)); + } } -void SnapshotEncoder::label_name_init(std::string const &name) -{ - if (label_name_map.find(name) == label_name_map.end()) { - auto id = label_name_map.size(); - label_name_map.insert(std::make_pair(name, id)); - } +void SnapshotEncoder::label_name_init(std::string const &name) { + if (label_name_map.find(name) == label_name_map.end()) { + auto id = label_name_map.size(); + label_name_map.insert(std::make_pair(name, id)); + } } -void SnapshotEncoder::edge_type_name_init(std::string const &name) -{ - if (edge_type_name_map.find(name) == edge_type_name_map.end()) { - auto id = edge_type_name_map.size(); - edge_type_name_map.insert(std::make_pair(name, id)); - } +void SnapshotEncoder::edge_type_name_init(std::string const &name) { + if (edge_type_name_map.find(name) == edge_type_name_map.end()) { + auto id = edge_type_name_map.size(); + edge_type_name_map.insert(std::make_pair(name, id)); + } } void SnapshotEncoder::end() { encoder.write_string("end"); } @@ -32,34 +28,32 @@ void SnapshotEncoder::end() { encoder.write_string("end"); } void SnapshotEncoder::start_indexes() { encoder.write_string("indexes"); } // Writes index definition -void SnapshotEncoder::index(IndexDefinition const &def) -{ - def.serialize(encoder); +void SnapshotEncoder::index(IndexDefinition const &def) { + def.serialize(encoder); } // ************* VERTEX // Prepares for vertices -void SnapshotEncoder::start_vertices() -{ - encoder.write_map_header(property_name_map.size()); - for (auto p : property_name_map) { - encoder.write_string(p.first); - encoder.write_integer(p.second); - } +void SnapshotEncoder::start_vertices() { + encoder.write_map_header(property_name_map.size()); + for (auto p : property_name_map) { + encoder.write_string(p.first); + encoder.write_integer(p.second); + } - encoder.write_map_header(label_name_map.size()); - for (auto p : label_name_map) { - encoder.write_string(p.first); - encoder.write_integer(p.second); - } + encoder.write_map_header(label_name_map.size()); + for (auto p : label_name_map) { + encoder.write_string(p.first); + encoder.write_integer(p.second); + } - encoder.write_map_header(edge_type_name_map.size()); - for (auto p : edge_type_name_map) { - encoder.write_string(p.first); - encoder.write_integer(p.second); - } + encoder.write_map_header(edge_type_name_map.size()); + for (auto p : edge_type_name_map) { + encoder.write_string(p.first); + encoder.write_integer(p.second); + } - encoder.write_string("vertices"); + encoder.write_string("vertices"); } // Starts writing vertex with given id. @@ -69,9 +63,8 @@ void SnapshotEncoder::start_vertex(Id id) { encoder.write_integer(id); } void SnapshotEncoder::label_count(size_t n) { encoder.write_list_header(n); } // Label of currently started vertex. -void SnapshotEncoder::label(std::string const &l) -{ - encoder.write_integer(label_name_map.at(l)); +void SnapshotEncoder::label(std::string const &l) { + encoder.write_integer(label_name_map.at(l)); } // ************* EDGE @@ -79,24 +72,21 @@ void SnapshotEncoder::label(std::string const &l) void SnapshotEncoder::start_edges() { encoder.write_string("edges"); } // Starts writing edge from vertex to vertex -void SnapshotEncoder::start_edge(Id from, Id to) -{ - encoder.write_integer(from); - encoder.write_integer(to); +void SnapshotEncoder::start_edge(Id from, Id to) { + encoder.write_integer(from); + encoder.write_integer(to); } // Type of currently started edge -void SnapshotEncoder::edge_type(std::string const &et) -{ - encoder.write_integer(edge_type_name_map.at(et)); +void SnapshotEncoder::edge_type(std::string const &et) { + encoder.write_integer(edge_type_name_map.at(et)); } // ******* PROPERTY void SnapshotEncoder::property_count(size_t n) { encoder.write_map_header(n); } -void SnapshotEncoder::property_name(std::string const &name) -{ - encoder.write_integer(property_name_map.at(name)); +void SnapshotEncoder::property_name(std::string const &name) { + encoder.write_integer(property_name_map.at(name)); } void SnapshotEncoder::handle(const Void &v) { encoder.write_null(); } @@ -107,65 +97,56 @@ void SnapshotEncoder::handle(const float &prop) { encoder.write_double(prop); } void SnapshotEncoder::handle(const double &prop) { encoder.write_double(prop); } -void SnapshotEncoder::handle(const int32_t &prop) -{ - encoder.write_integer(prop); +void SnapshotEncoder::handle(const int32_t &prop) { + encoder.write_integer(prop); } -void SnapshotEncoder::handle(const int64_t &prop) -{ - encoder.write_integer(prop); +void SnapshotEncoder::handle(const int64_t &prop) { + encoder.write_integer(prop); } -void SnapshotEncoder::handle(const std::string &value) -{ - encoder.write_string(value); +void SnapshotEncoder::handle(const std::string &value) { + encoder.write_string(value); } -void SnapshotEncoder::handle(const ArrayStore<bool> &a) -{ - encoder.write_list_header(a.size()); - for (auto const &e : a) { - encoder.write_bool(e); - } +void SnapshotEncoder::handle(const ArrayStore<bool> &a) { + encoder.write_list_header(a.size()); + for (auto const &e : a) { + encoder.write_bool(e); + } } -void SnapshotEncoder::handle(const ArrayStore<int32_t> &a) -{ - encoder.write_list_header(a.size()); - for (auto const &e : a) { - encoder.write_integer(e); - } +void SnapshotEncoder::handle(const ArrayStore<int32_t> &a) { + encoder.write_list_header(a.size()); + for (auto const &e : a) { + encoder.write_integer(e); + } } -void SnapshotEncoder::handle(const ArrayStore<int64_t> &a) -{ - encoder.write_list_header(a.size()); - for (auto const &e : a) { - encoder.write_integer(e); - } +void SnapshotEncoder::handle(const ArrayStore<int64_t> &a) { + encoder.write_list_header(a.size()); + for (auto const &e : a) { + encoder.write_integer(e); + } } -void SnapshotEncoder::handle(const ArrayStore<float> &a) -{ - encoder.write_list_header(a.size()); - for (auto const &e : a) { - encoder.write_double(e); - } +void SnapshotEncoder::handle(const ArrayStore<float> &a) { + encoder.write_list_header(a.size()); + for (auto const &e : a) { + encoder.write_double(e); + } } -void SnapshotEncoder::handle(const ArrayStore<double> &a) -{ - encoder.write_list_header(a.size()); - for (auto const &e : a) { - encoder.write_double(e); - } +void SnapshotEncoder::handle(const ArrayStore<double> &a) { + encoder.write_list_header(a.size()); + for (auto const &e : a) { + encoder.write_double(e); + } } -void SnapshotEncoder::handle(const ArrayStore<std::string> &a) -{ - encoder.write_list_header(a.size()); - for (auto const &e : a) { - encoder.write_string(e); - } +void SnapshotEncoder::handle(const ArrayStore<std::string> &a) { + encoder.write_list_header(a.size()); + for (auto const &e : a) { + encoder.write_string(e); + } } diff --git a/src/snapshot/snapshot_encoder.hpp b/src/snapshot/snapshot_encoder.hpp index af2dc8624..d1bb68e0f 100644 --- a/src/snapshot/snapshot_encoder.hpp +++ b/src/snapshot/snapshot_encoder.hpp @@ -22,100 +22,99 @@ // 1 start_indexes // * index // 1 end -class SnapshotEncoder : public GraphEncoder -{ -public: - SnapshotEncoder(std::ofstream &stream) : stream(stream) {} +class SnapshotEncoder : public GraphEncoder { + public: + SnapshotEncoder(std::ofstream &stream) : stream(stream) {} - SnapshotEncoder(SnapshotEncoder const &) = delete; - SnapshotEncoder(SnapshotEncoder &&) = delete; + SnapshotEncoder(SnapshotEncoder const &) = delete; + SnapshotEncoder(SnapshotEncoder &&) = delete; - SnapshotEncoder &operator=(SnapshotEncoder const &) = delete; - SnapshotEncoder &operator=(SnapshotEncoder &&) = delete; + SnapshotEncoder &operator=(SnapshotEncoder const &) = delete; + SnapshotEncoder &operator=(SnapshotEncoder &&) = delete; - // Tells in advance which names will be used. - void property_name_init(std::string const &name); + // Tells in advance which names will be used. + void property_name_init(std::string const &name); - // Tells in advance which labels will be used. - void label_name_init(std::string const &name); + // Tells in advance which labels will be used. + void label_name_init(std::string const &name); - // Tells in advance which edge_type will be used. - void edge_type_name_init(std::string const &name); + // Tells in advance which edge_type will be used. + void edge_type_name_init(std::string const &name); - // Prepares for vertices - void start_vertices(); + // Prepares for vertices + void start_vertices(); - // Prepares for edges - void start_edges(); + // Prepares for edges + void start_edges(); - // Prepares for indexes - void start_indexes(); + // Prepares for indexes + void start_indexes(); - // Writes index definition - void index(IndexDefinition const &); + // Writes index definition + void index(IndexDefinition const &); - // Finishes snapshot - void end(); + // Finishes snapshot + void end(); - // *********************From graph encoder - // Starts writing vertex with given id. - void start_vertex(Id id); + // *********************From graph encoder + // Starts writing vertex with given id. + void start_vertex(Id id); - // Number of following label calls. - void label_count(size_t n); + // Number of following label calls. + void label_count(size_t n); - // Label of currently started vertex. - void label(std::string const &l); + // Label of currently started vertex. + void label(std::string const &l); - // Starts writing edge from vertex to vertex - void start_edge(Id from, Id to); + // Starts writing edge from vertex to vertex + void start_edge(Id from, Id to); - // Type of currently started edge - void edge_type(std::string const &et); + // Type of currently started edge + void edge_type(std::string const &et); - // Number of following paired property_name,handle calls. - void property_count(size_t n); + // Number of following paired property_name,handle calls. + void property_count(size_t n); - // Property family name of next property for currently started element. - void property_name(std::string const &name); + // Property family name of next property for currently started element. + void property_name(std::string const &name); - void handle(const Void &v); + void handle(const Void &v); - void handle(const bool &prop); + void handle(const bool &prop); - void handle(const float &prop); + void handle(const float &prop); - void handle(const double &prop); + void handle(const double &prop); - void handle(const int32_t &prop); + void handle(const int32_t &prop); - void handle(const int64_t &prop); + void handle(const int64_t &prop); - void handle(const std::string &value); + void handle(const std::string &value); - void handle(const ArrayStore<bool> &); + void handle(const ArrayStore<bool> &); - void handle(const ArrayStore<int32_t> &); + void handle(const ArrayStore<int32_t> &); - void handle(const ArrayStore<int64_t> &); + void handle(const ArrayStore<int64_t> &); - void handle(const ArrayStore<float> &); + void handle(const ArrayStore<float> &); - void handle(const ArrayStore<double> &); + void handle(const ArrayStore<double> &); - void handle(const ArrayStore<std::string> &); + void handle(const ArrayStore<std::string> &); -private: - std::ofstream &stream; - StreamWrapper<std::ofstream> wrapped = {stream}; - bolt::BoltEncoder<StreamWrapper<std::ofstream>> encoder = {wrapped}; + private: + std::ofstream &stream; + StreamWrapper<std::ofstream> wrapped = {stream}; + bolt::BoltEncoder<StreamWrapper<std::ofstream>> encoder = {wrapped}; - // Contains for every property_name here snapshot local id. - std::unordered_map<std::string, size_t> property_name_map; + // Contains for every property_name here snapshot local id. + std::unordered_map<std::string, size_t> property_name_map; - // Contains for every label_name here snapshot local id. - std::unordered_map<std::string, size_t> label_name_map; + // Contains for every label_name here snapshot local id. + std::unordered_map<std::string, size_t> label_name_map; - // Contains for every edge_type here snapshot local id. - std::unordered_map<std::string, size_t> edge_type_name_map; + // Contains for every edge_type here snapshot local id. + std::unordered_map<std::string, size_t> edge_type_name_map; }; diff --git a/src/snapshot/snapshot_engine.cpp b/src/snapshot/snapshot_engine.cpp index bba6c7b42..8f2f718fc 100644 --- a/src/snapshot/snapshot_engine.cpp +++ b/src/snapshot/snapshot_engine.cpp @@ -10,330 +10,315 @@ #include "utils/sys.hpp" SnapshotEngine::SnapshotEngine(Db &db) - : snapshot_folder(CONFIG(config::SNAPSHOTS_PATH)), db(db), + : snapshot_folder(CONFIG(config::SNAPSHOTS_PATH)), + db(db), max_retained_snapshots(CONFIG_INTEGER(config::MAX_RETAINED_SNAPSHOTS)), - logger(logging::log->logger("SnapshotEngine db[" + db.name() + "]")) -{ + logger(logging::log->logger("SnapshotEngine db[" + db.name() + "]")) {} + +bool SnapshotEngine::make_snapshot() { + std::lock_guard<std::mutex> lock(guard); + std::time_t now = std::time(nullptr); + if (make_snapshot(now, "full")) { + // Sanpsthot was created so whe should check if some older snapshots + // should be deleted. + clean_snapshots(); + return true; + + } else { + return false; + } } -bool SnapshotEngine::make_snapshot() -{ - std::lock_guard<std::mutex> lock(guard); - std::time_t now = std::time(nullptr); - if (make_snapshot(now, "full")) { - // Sanpsthot was created so whe should check if some older snapshots - // should be deleted. - clean_snapshots(); - return true; +void SnapshotEngine::clean_snapshots() { + logger.info("Started cleaning commit_file"); + // Whe first count the number of snapshots that whe know about in commit + // file. + std::vector<std::string> lines; + { + std::ifstream commit_file(snapshot_commit_file()); + + std::string line; + while (std::getline(commit_file, line)) { + lines.push_back(line); + } + } + + int n = lines.size() - max_retained_snapshots; + if (n > 0) { + // Whe have to much snapshots so whe should delete some. + std::ofstream commit_file(snapshot_commit_file(), std::fstream::trunc); + + // First whw will rewrite commit file to contain only + // max_retained_snapshots newest snapshots. + for (auto i = n; i < lines.size(); i++) { + commit_file << lines[i] << std::endl; + } + + auto res = sys::flush_file_to_disk(commit_file); + if (res == 0) { + // Commit file was succesfully changed so whe can now delete + // snapshots which whe evicted from commit file. + commit_file.close(); + logger.info("Removed {} snapshot from commit_file", n); + + for (auto i = 0; i < n; i++) { + auto res = std::remove(lines[i].c_str()); + if (res == 0) { + logger.info("Succesfully deleted snapshot file \"{}\"", lines[i]); + } else { + logger.error("Error {} occured while deleting snapshot file \"{}\"", + res, lines[i]); + } + } } else { - return false; + logger.error("Error {} occured while flushing commit file", res); } + } + + logger.info("Finished cleaning commit_file"); } -void SnapshotEngine::clean_snapshots() -{ - logger.info("Started cleaning commit_file"); - // Whe first count the number of snapshots that whe know about in commit - // file. - std::vector<std::string> lines; - { - std::ifstream commit_file(snapshot_commit_file()); +bool SnapshotEngine::make_snapshot(std::time_t now, const char *type) { + bool success = false; - std::string line; - while (std::getline(commit_file, line)) { - lines.push_back(line); - } + auto snapshot_file_name = snapshot_file(now, type); + + logger.info("Writing {} snapshot to file \"{}\"", type, snapshot_file_name); + + DbTransaction t(db); + + try { + std::ofstream snapshot_file(snapshot_file_name, + std::fstream::binary | std::fstream::trunc); + + SnapshotEncoder snap(snapshot_file); + + auto old_trans = + tx::TransactionRead(db.tx_engine); // Overenginered for incremental + // snapshot. Can be removed. + + // Everything is ready for creation of snapshot. + snapshot(t, snap, old_trans); + + auto res = sys::flush_file_to_disk(snapshot_file); + if (res == 0) { + // Snapshot was succesfully written to disk. + t.trans.commit(); + success = true; + + } else { + logger.error("Error {} occured while flushing snapshot file", res); + t.trans.abort(); } - int n = lines.size() - max_retained_snapshots; - if (n > 0) { - // Whe have to much snapshots so whe should delete some. - std::ofstream commit_file(snapshot_commit_file(), std::fstream::trunc); + } catch (const std::exception &e) { + logger.error("Exception occured while creating {} snapshot", type); + logger.error("{}", e.what()); - // First whw will rewrite commit file to contain only - // max_retained_snapshots newest snapshots. - for (auto i = n; i < lines.size(); i++) { - commit_file << lines[i] << std::endl; - } + t.trans.abort(); + } - auto res = sys::flush_file_to_disk(commit_file); - if (res == 0) { - // Commit file was succesfully changed so whe can now delete - // snapshots which whe evicted from commit file. - commit_file.close(); - logger.info("Removed {} snapshot from commit_file", n); + if (success) { + // Snapshot was succesfully created but for it to be reachable for + // import whe must add it to the end of commit file. + std::ofstream commit_file(snapshot_commit_file(), std::fstream::app); - for (auto i = 0; i < n; i++) { - auto res = std::remove(lines[i].c_str()); - if (res == 0) { - logger.info("Succesfully deleted snapshot file \"{}\"", - lines[i]); - } else { - logger.error( - "Error {} occured while deleting snapshot file \"{}\"", - res, lines[i]); - } - } + commit_file << snapshot_file_name << std::endl; - } else { - logger.error("Error {} occured while flushing commit file", res); - } + auto res = sys::flush_file_to_disk(commit_file); + if (res == 0) { + commit_file.close(); + snapshoted_no_v.fetch_add(1); + // Snapshot was succesfully commited. + + } else { + logger.error("Error {} occured while flushing commit file", res); } + } - logger.info("Finished cleaning commit_file"); + return success; } -bool SnapshotEngine::make_snapshot(std::time_t now, const char *type) -{ - bool success = false; +bool SnapshotEngine::import() { + std::lock_guard<std::mutex> lock(guard); - auto snapshot_file_name = snapshot_file(now, type); + logger.info("Started import"); + bool success = false; - logger.info("Writing {} snapshot to file \"{}\"", type, snapshot_file_name); + try { + std::ifstream commit_file(snapshot_commit_file()); - DbTransaction t(db); + // Whe first load all known snpashot file names from commit file. + std::vector<std::string> snapshots; + std::string line; + while (std::getline(commit_file, line)) { + snapshots.push_back(line); + } - try { - std::ofstream snapshot_file(snapshot_file_name, - std::fstream::binary | std::fstream::trunc); + while (snapshots.size() > 0) { + logger.info("Importing data from snapshot \"{}\"", snapshots.back()); - SnapshotEncoder snap(snapshot_file); + DbAccessor t(db); - auto old_trans = - tx::TransactionRead(db.tx_engine); // Overenginered for incremental - // snapshot. Can be removed. + try { + std::ifstream snapshot_file(snapshots.back(), std::fstream::binary); + SnapshotDecoder decoder(snapshot_file); - // Everything is ready for creation of snapshot. - snapshot(t, snap, old_trans); - - auto res = sys::flush_file_to_disk(snapshot_file); - if (res == 0) { - // Snapshot was succesfully written to disk. - t.trans.commit(); - success = true; + auto indexes = snapshot_load(t, decoder); + if (t.commit()) { + logger.info("Succesfully imported snapshot \"{}\"", snapshots.back()); + add_indexes(indexes); + success = true; + break; } else { - logger.error("Error {} occured while flushing snapshot file", res); - t.trans.abort(); + logger.info( + "Unuccesfully tryed to import snapshot " + "\"{}\"", + snapshots.back()); } - } catch (const std::exception &e) { - logger.error("Exception occured while creating {} snapshot", type); + } catch (const std::exception &e) { + logger.error("Error occured while importing snapshot \"{}\"", + snapshots.back()); logger.error("{}", e.what()); + t.abort(); + } - t.trans.abort(); + snapshots.pop_back(); + // Whe will try to import older snapashot if such one exist. } - if (success) { - // Snapshot was succesfully created but for it to be reachable for - // import whe must add it to the end of commit file. - std::ofstream commit_file(snapshot_commit_file(), std::fstream::app); + } catch (const std::exception &e) { + logger.error("Error occured while importing snapshot"); + logger.error("{}", e.what()); + } - commit_file << snapshot_file_name << std::endl; + logger.info("Finished import"); - auto res = sys::flush_file_to_disk(commit_file); - if (res == 0) { - commit_file.close(); - snapshoted_no_v.fetch_add(1); - // Snapshot was succesfully commited. - - } else { - logger.error("Error {} occured while flushing commit file", res); - } - } - - return success; -} - -bool SnapshotEngine::import() -{ - std::lock_guard<std::mutex> lock(guard); - - logger.info("Started import"); - bool success = false; - - try { - - std::ifstream commit_file(snapshot_commit_file()); - - // Whe first load all known snpashot file names from commit file. - std::vector<std::string> snapshots; - std::string line; - while (std::getline(commit_file, line)) { - snapshots.push_back(line); - } - - while (snapshots.size() > 0) { - logger.info("Importing data from snapshot \"{}\"", - snapshots.back()); - - DbAccessor t(db); - - try { - std::ifstream snapshot_file(snapshots.back(), - std::fstream::binary); - SnapshotDecoder decoder(snapshot_file); - - auto indexes = snapshot_load(t, decoder); - if (t.commit()) { - logger.info("Succesfully imported snapshot \"{}\"", - snapshots.back()); - add_indexes(indexes); - success = true; - break; - - } else { - logger.info("Unuccesfully tryed to import snapshot " - "\"{}\"", - snapshots.back()); - } - - } catch (const std::exception &e) { - logger.error("Error occured while importing snapshot \"{}\"", - snapshots.back()); - logger.error("{}", e.what()); - t.abort(); - } - - snapshots.pop_back(); - // Whe will try to import older snapashot if such one exist. - } - - } catch (const std::exception &e) { - logger.error("Error occured while importing snapshot"); - logger.error("{}", e.what()); - } - - logger.info("Finished import"); - - return success; + return success; } void SnapshotEngine::snapshot(DbTransaction const &dt, SnapshotEncoder &snap, - tx::TransactionRead const &old_trans) -{ - Db &db = dt.db; - DbAccessor t(db, dt.trans); + tx::TransactionRead const &old_trans) { + Db &db = dt.db; + DbAccessor t(db, dt.trans); - // Anounce property names - for (auto &family : db.graph.vertices.property_family_access()) { - snap.property_name_init(family.first); - } - for (auto &family : db.graph.edges.property_family_access()) { - snap.property_name_init(family.first); - } + // Anounce property names + for (auto &family : db.graph.vertices.property_family_access()) { + snap.property_name_init(family.first); + } + for (auto &family : db.graph.edges.property_family_access()) { + snap.property_name_init(family.first); + } - // Anounce label names - for (auto &labels : db.graph.label_store.access()) { - snap.label_name_init(labels.first.to_string()); - } + // Anounce label names + for (auto &labels : db.graph.label_store.access()) { + snap.label_name_init(labels.first.to_string()); + } - // Anounce edge_type names - for (auto &et : db.graph.edge_type_store.access()) { - snap.edge_type_name_init(et.first.to_string()); - } + // Anounce edge_type names + for (auto &et : db.graph.edge_type_store.access()) { + snap.edge_type_name_init(et.first.to_string()); + } - // Store vertices - snap.start_vertices(); - t.vertex_access() - .fill() - .filter([&](auto va) { return !va.is_visble_to(old_trans); }) - .for_all([&](auto va) { serialization::serialize_vertex(va, snap); }); + // Store vertices + snap.start_vertices(); + t.vertex_access() + .fill() + .filter([&](auto va) { return !va.is_visble_to(old_trans); }) + .for_all([&](auto va) { serialization::serialize_vertex(va, snap); }); - // Store edges - snap.start_edges(); - t.edge_access() - .fill() - .filter([&](auto va) { return !va.is_visble_to(old_trans); }) - .for_all([&](auto ea) { serialization::serialize_edge(ea, snap); }); + // Store edges + snap.start_edges(); + t.edge_access() + .fill() + .filter([&](auto va) { return !va.is_visble_to(old_trans); }) + .for_all([&](auto ea) { serialization::serialize_edge(ea, snap); }); - // Store info on existing indexes. - snap.start_indexes(); - db.indexes().vertex_indexes([&](auto &i) { snap.index(i.definition()); }); - db.indexes().edge_indexes([&](auto &i) { snap.index(i.definition()); }); + // Store info on existing indexes. + snap.start_indexes(); + db.indexes().vertex_indexes([&](auto &i) { snap.index(i.definition()); }); + db.indexes().edge_indexes([&](auto &i) { snap.index(i.definition()); }); - snap.end(); + snap.end(); } -std::vector<IndexDefinition> -SnapshotEngine::snapshot_load(DbAccessor &t, SnapshotDecoder &snap) -{ - std::unordered_map<uint64_t, VertexAccessor> vertices; +std::vector<IndexDefinition> SnapshotEngine::snapshot_load( + DbAccessor &t, SnapshotDecoder &snap) { + std::unordered_map<uint64_t, VertexAccessor> vertices; - // Load names - snap.load_init(); + // Load names + snap.load_init(); - // Load vertices - snap.begin_vertices(); - size_t v_count = 0; - while (!snap.end_vertices()) { - vertices.insert(serialization::deserialize_vertex(t, snap)); - v_count++; - } - logger.info("Loaded {} vertices", v_count); + // Load vertices + snap.begin_vertices(); + size_t v_count = 0; + while (!snap.end_vertices()) { + vertices.insert(serialization::deserialize_vertex(t, snap)); + v_count++; + } + logger.info("Loaded {} vertices", v_count); - // Load edges - snap.begin_edges(); - size_t e_count = 0; - while (!snap.end_edges()) { - serialization::deserialize_edge(t, snap, vertices); - e_count++; - } - logger.info("Loaded {} edges", e_count); + // Load edges + snap.begin_edges(); + size_t e_count = 0; + while (!snap.end_edges()) { + serialization::deserialize_edge(t, snap, vertices); + e_count++; + } + logger.info("Loaded {} edges", e_count); - // Load indexes - snap.start_indexes(); - std::vector<IndexDefinition> indexes; - while (!snap.end()) { - indexes.push_back(snap.load_index()); - } + // Load indexes + snap.start_indexes(); + std::vector<IndexDefinition> indexes; + while (!snap.end()) { + indexes.push_back(snap.load_index()); + } - return indexes; + return indexes; } -void SnapshotEngine::add_indexes(std::vector<IndexDefinition> &v) -{ - logger.info("Adding: {} indexes", v.size()); - for (auto id : v) { - // TODO: It is alright for now to ignore if add_index return false. I am - // not even sure if false should stop snapshot loading. - if (!db.indexes().add_index(id)) { - logger.warn("Failed to add index, but still continuing with " - "loading snapshot"); - } +void SnapshotEngine::add_indexes(std::vector<IndexDefinition> &v) { + logger.info("Adding: {} indexes", v.size()); + for (auto id : v) { + // TODO: It is alright for now to ignore if add_index return false. I am + // not even sure if false should stop snapshot loading. + if (!db.indexes().add_index(id)) { + logger.warn( + "Failed to add index, but still continuing with " + "loading snapshot"); } + } } std::string SnapshotEngine::snapshot_file(std::time_t const &now, - const char *type) -{ - // Current nano time less than second. - auto now_nano = std::chrono::time_point_cast<std::chrono::nanoseconds>( - std::chrono::high_resolution_clock::now()) - .time_since_epoch() - .count() % - (1000 * 1000 * 1000); + const char *type) { + // Current nano time less than second. + auto now_nano = std::chrono::time_point_cast<std::chrono::nanoseconds>( + std::chrono::high_resolution_clock::now()) + .time_since_epoch() + .count() % + (1000 * 1000 * 1000); - return snapshot_db_dir() + "/" + std::to_string(now) + "_" + - std::to_string(now_nano) + "_" + type; + return snapshot_db_dir() + "/" + std::to_string(now) + "_" + + std::to_string(now_nano) + "_" + type; } -std::string SnapshotEngine::snapshot_commit_file() -{ - return snapshot_db_dir() + "/snapshot_commit.txt"; +std::string SnapshotEngine::snapshot_commit_file() { + return snapshot_db_dir() + "/snapshot_commit.txt"; } -std::string SnapshotEngine::snapshot_db_dir() -{ - if (!sys::ensure_directory_exists(snapshot_folder)) { - logger.error("Error while creating directory \"{}\"", snapshot_folder); - } +std::string SnapshotEngine::snapshot_db_dir() { + if (!sys::ensure_directory_exists(snapshot_folder)) { + logger.error("Error while creating directory \"{}\"", snapshot_folder); + } - auto db_path = snapshot_folder + "/" + db.name(); - if (!sys::ensure_directory_exists(db_path)) { - logger.error("Error while creating directory \"{}\"", db_path); - } + auto db_path = snapshot_folder + "/" + db.name(); + if (!sys::ensure_directory_exists(db_path)) { + logger.error("Error while creating directory \"{}\"", db_path); + } - return db_path; + return db_path; } diff --git a/src/snapshot/snapshot_engine.hpp b/src/snapshot/snapshot_engine.hpp index 41a6cba23..ea63b1607 100644 --- a/src/snapshot/snapshot_engine.hpp +++ b/src/snapshot/snapshot_engine.hpp @@ -14,61 +14,59 @@ class DbTransaction; class DbAccessor; // Captures snapshots. Only one per database should exist. -class SnapshotEngine -{ +class SnapshotEngine { + public: + SnapshotEngine(Db &db); -public: - SnapshotEngine(Db &db); + ~SnapshotEngine() = default; - ~SnapshotEngine() = default; + // Returns number of succesffuly created snapshots. + size_t snapshoted_no() { return snapshoted_no_v.load(); } - // Returns number of succesffuly created snapshots. - size_t snapshoted_no() { return snapshoted_no_v.load(); } + // Imports latest snapshot into the databse. Blocks until other calls don't + // end. + bool import(); - // Imports latest snapshot into the databse. Blocks until other calls don't - // end. - bool import(); + // Makes snapshot of given type. Blocks until other calls don't end. + bool make_snapshot(); - // Makes snapshot of given type. Blocks until other calls don't end. - bool make_snapshot(); + private: + // Removes excess of snapshots starting with oldest one. + void clean_snapshots(); -private: - // Removes excess of snapshots starting with oldest one. - void clean_snapshots(); + // Makes snapshot of given type + bool make_snapshot(std::time_t now, const char *type); - // Makes snapshot of given type - bool make_snapshot(std::time_t now, const char *type); + // Makes snapshot. It only saves records which have changed since old_trans. + void snapshot(DbTransaction const &dt, SnapshotEncoder &snap, + tx::TransactionRead const &old_trans); - // Makes snapshot. It only saves records which have changed since old_trans. - void snapshot(DbTransaction const &dt, SnapshotEncoder &snap, - tx::TransactionRead const &old_trans); + // Loads snapshot. True if success. Returns indexes which were in snapshot. + std::vector<IndexDefinition> snapshot_load(DbAccessor &t, + SnapshotDecoder &snap); - // Loads snapshot. True if success. Returns indexes which were in snapshot. - std::vector<IndexDefinition> snapshot_load(DbAccessor &t, - SnapshotDecoder &snap); + // Adds indexes. Should be called outside transactions. + void add_indexes(std::vector<IndexDefinition> &v); - // Adds indexes. Should be called outside transactions. - void add_indexes(std::vector<IndexDefinition> &v); + // Will return different name on every call. + std::string snapshot_file(std::time_t const &now, const char *type); - // Will return different name on every call. - std::string snapshot_file(std::time_t const &now, const char *type); + // Returns name of snapshot commit file. + std::string snapshot_commit_file(); - // Returns name of snapshot commit file. - std::string snapshot_commit_file(); + // Path to directory of database. Ensures that all necessary directorys + // exist. + std::string snapshot_db_dir(); - // Path to directory of database. Ensures that all necessary directorys - // exist. - std::string snapshot_db_dir(); + Logger logger; - Logger logger; + Db &db; + std::mutex guard; + const std::string snapshot_folder; - Db &db; - std::mutex guard; - const std::string snapshot_folder; + // Determines how many newest snapshot will be preserved, while the other + // ones will be deleted. + const size_t max_retained_snapshots; - // Determines how many newest snapshot will be preserved, while the other - // ones will be deleted. - const size_t max_retained_snapshots; - - std::atomic<size_t> snapshoted_no_v = {0}; + std::atomic<size_t> snapshoted_no_v = {0}; }; diff --git a/src/snapshot/snapshoter.cpp b/src/snapshot/snapshoter.cpp index a088ff2d8..d8c5ab286 100644 --- a/src/snapshot/snapshoter.cpp +++ b/src/snapshot/snapshoter.cpp @@ -10,58 +10,53 @@ Snapshoter::Snapshoter(ConcurrentMap<std::string, Db> &dbs, size_t snapshot_cycle) - : snapshot_cycle(snapshot_cycle), dbms(dbs) -{ - // Start snapshoter thread. - thread = std::make_unique<Thread>([&]() { - logger = logging::log->logger("Snapshoter"); - logger.info("Started with snapshoot cycle of {} sec", - this->snapshot_cycle); + : snapshot_cycle(snapshot_cycle), dbms(dbs) { + // Start snapshoter thread. + thread = std::make_unique<Thread>([&]() { + logger = logging::log->logger("Snapshoter"); + logger.info("Started with snapshoot cycle of {} sec", this->snapshot_cycle); - try { - run(); - } catch (const std::exception &e) { - logger.error("Irreversible error occured in snapshoter"); - logger.error("{}", e.what()); - } - - logger.info("Shutting down snapshoter"); - }); -} - -Snapshoter::~Snapshoter() -{ - snapshoting.store(false, std::memory_order_release); - thread.get()->join(); -} - -void Snapshoter::run() -{ - std::time_t last_snapshot = std::time(nullptr); - - while (snapshoting.load(std::memory_order_acquire)) { - std::time_t now = std::time(nullptr); - - if (now >= last_snapshot + snapshot_cycle) { - // It's time for snapshot - make_snapshots(); - - last_snapshot = now; - - } else { - // It isn't time for snapshot so i should wait. - std::this_thread::sleep_for(std::chrono::seconds(1)); - } - } -} - -void Snapshoter::make_snapshots() -{ - logger.info("Started snapshoting cycle"); - - for (auto &db : dbms.access()) { - db.second.snap_engine.make_snapshot(); + try { + run(); + } catch (const std::exception &e) { + logger.error("Irreversible error occured in snapshoter"); + logger.error("{}", e.what()); } - logger.info("Finished snapshoting cycle"); + logger.info("Shutting down snapshoter"); + }); +} + +Snapshoter::~Snapshoter() { + snapshoting.store(false, std::memory_order_release); + thread.get()->join(); +} + +void Snapshoter::run() { + std::time_t last_snapshot = std::time(nullptr); + + while (snapshoting.load(std::memory_order_acquire)) { + std::time_t now = std::time(nullptr); + + if (now >= last_snapshot + snapshot_cycle) { + // It's time for snapshot + make_snapshots(); + + last_snapshot = now; + + } else { + // It isn't time for snapshot so i should wait. + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + } +} + +void Snapshoter::make_snapshots() { + logger.info("Started snapshoting cycle"); + + for (auto &db : dbms.access()) { + db.second.snap_engine.make_snapshot(); + } + + logger.info("Finished snapshoting cycle"); } diff --git a/src/snapshot/snapshoter.hpp b/src/snapshot/snapshoter.hpp index 7b110c381..d2931f364 100644 --- a/src/snapshot/snapshoter.hpp +++ b/src/snapshot/snapshoter.hpp @@ -10,26 +10,24 @@ class SnapshotEncoder; class SnapshotDecoder; // Captures snapshots. -class Snapshoter -{ +class Snapshoter { + public: + // How much sec is between snapshots + // snapshot_folder is path to common folder for all snapshots. + Snapshoter(ConcurrentMap<std::string, Db> &dbs, size_t snapshot_cycle); -public: - // How much sec is between snapshots - // snapshot_folder is path to common folder for all snapshots. - Snapshoter(ConcurrentMap<std::string, Db> &dbs, size_t snapshot_cycle); + ~Snapshoter(); - ~Snapshoter(); + private: + void run(); -private: - void run(); + // Makes snapshot of given type + void make_snapshots(); - // Makes snapshot of given type - void make_snapshots(); + Logger logger; - Logger logger; - - const size_t snapshot_cycle; - std::unique_ptr<Thread> thread = {nullptr}; - ConcurrentMap<std::string, Db> &dbms; - std::atomic<bool> snapshoting = {true}; + const size_t snapshot_cycle; + std::unique_ptr<Thread> thread = {nullptr}; + ConcurrentMap<std::string, Db> &dbms; + std::atomic<bool> snapshoting = {true}; }; diff --git a/src/storage/edge.hpp b/src/storage/edge.hpp index 05d6b4f40..0d202f2ae 100644 --- a/src/storage/edge.hpp +++ b/src/storage/edge.hpp @@ -9,10 +9,8 @@ class Vertex; class Edge : public mvcc::Record<Edge> { -public: - - Edge(mvcc::VersionList<Vertex>& from, - mvcc::VersionList<Vertex>& to, + public: + Edge(mvcc::VersionList<Vertex>& from, mvcc::VersionList<Vertex>& to, GraphDb::EdgeType edge_type) : from_(from), to_(to), edge_type_(edge_type) {} diff --git a/src/storage/edge_accessor.cpp b/src/storage/edge_accessor.cpp index 408043f34..39effd683 100644 --- a/src/storage/edge_accessor.cpp +++ b/src/storage/edge_accessor.cpp @@ -5,14 +5,12 @@ void EdgeAccessor::set_edge_type(GraphDb::EdgeType edge_type) { update().edge_type_ = edge_type; } -GraphDb::EdgeType EdgeAccessor::edge_type() const { - return view().edge_type_; -} +GraphDb::EdgeType EdgeAccessor::edge_type() const { return view().edge_type_; } VertexAccessor EdgeAccessor::from() const { return VertexAccessor(view().from_, db_accessor_); } VertexAccessor EdgeAccessor::to() const { -return VertexAccessor(view().to_, db_accessor_); + return VertexAccessor(view().to_, db_accessor_); } diff --git a/src/storage/edge_accessor.hpp b/src/storage/edge_accessor.hpp index ab085c879..ef033edae 100644 --- a/src/storage/edge_accessor.hpp +++ b/src/storage/edge_accessor.hpp @@ -1,10 +1,10 @@ #pragma once +#include "database/graph_db.hpp" #include "storage/edge.hpp" #include "storage/record_accessor.hpp" #include "utils/assert.hpp" #include "utils/reference_wrapper.hpp" -#include "database/graph_db.hpp" // forward declaring the VertexAccessor because it's returned // by some functions @@ -18,7 +18,7 @@ class VertexAccessor; * takes care of MVCC versioning. */ class EdgeAccessor : public RecordAccessor<Edge> { -public: + public: using RecordAccessor::RecordAccessor; /** @@ -44,5 +44,5 @@ public: */ VertexAccessor to() const; -// void remove(); + // void remove(); }; diff --git a/src/storage/garbage/delete_sensitive.hpp b/src/storage/garbage/delete_sensitive.hpp index 973bde9d2..1ba8b136f 100644 --- a/src/storage/garbage/delete_sensitive.hpp +++ b/src/storage/garbage/delete_sensitive.hpp @@ -2,8 +2,7 @@ // Base class for all classes which need to be safely disposed. Main usage is // for garbage class operations. -class DeleteSensitive -{ -public: - virtual ~DeleteSensitive() {} +class DeleteSensitive { + public: + virtual ~DeleteSensitive() {} }; diff --git a/src/storage/garbage/garbage.cpp b/src/storage/garbage/garbage.cpp index 06f245163..442031f69 100644 --- a/src/storage/garbage/garbage.cpp +++ b/src/storage/garbage/garbage.cpp @@ -1,18 +1,16 @@ #include "storage/garbage/garbage.hpp" -void Garbage::dispose(tx::Snapshot<Id> &&snapshot, DeleteSensitive *data) -{ - // If this fails it's better to leak memory than to cause read after free. - gar.begin().push(std::make_pair(snapshot, data)); +void Garbage::dispose(tx::Snapshot<Id> &&snapshot, DeleteSensitive *data) { + // If this fails it's better to leak memory than to cause read after free. + gar.begin().push(std::make_pair(snapshot, data)); } -void Garbage::clean() -{ - for (auto it = gar.begin(); it != gar.end(); it++) { - if (it->first.all_finished(engine) && it.remove()) { - // All transactions who could have seen data are finished and this - // thread successfull removed item from list. - it->second->~DeleteSensitive(); - } +void Garbage::clean() { + for (auto it = gar.begin(); it != gar.end(); it++) { + if (it->first.all_finished(engine) && it.remove()) { + // All transactions who could have seen data are finished and this + // thread successfull removed item from list. + it->second->~DeleteSensitive(); } + } } diff --git a/src/storage/garbage/garbage.hpp b/src/storage/garbage/garbage.hpp index 9ac935385..d1f7999fd 100644 --- a/src/storage/garbage/garbage.hpp +++ b/src/storage/garbage/garbage.hpp @@ -5,27 +5,25 @@ #include "storage/garbage/delete_sensitive.hpp" #include "transactions/snapshot.hpp" -namespace tx -{ +namespace tx { class Engine; } // Collection of delete sensitive data which need to be safely deleted. That // meens that all transactions that may have pointer to it must finish before // the sensitive data can be safely destroyed. -class Garbage -{ -public: - Garbage(tx::Engine &e) : engine(e) {} +class Garbage { + public: + Garbage(tx::Engine &e) : engine(e) {} - // Will safely dispose of data. - void dispose(tx::Snapshot<Id> &&snapshot, DeleteSensitive *data); + // Will safely dispose of data. + void dispose(tx::Snapshot<Id> &&snapshot, DeleteSensitive *data); - // Cleaner thread should call this method every some time. Removes data - // which is safe to be deleted. - void clean(); + // Cleaner thread should call this method every some time. Removes data + // which is safe to be deleted. + void clean(); -private: - ConcurrentList<std::pair<tx::Snapshot<Id>, DeleteSensitive *>> gar; - tx::Engine &engine; + private: + ConcurrentList<std::pair<tx::Snapshot<Id>, DeleteSensitive *>> gar; + tx::Engine &engine; }; diff --git a/src/storage/locking/lock_status.hpp b/src/storage/locking/lock_status.hpp index 508279c24..bbd6de10c 100644 --- a/src/storage/locking/lock_status.hpp +++ b/src/storage/locking/lock_status.hpp @@ -1,7 +1,3 @@ #pragma once -enum class LockStatus -{ - Acquired, - AlreadyHeld -}; +enum class LockStatus { Acquired, AlreadyHeld }; diff --git a/src/storage/locking/record_lock.cpp b/src/storage/locking/record_lock.cpp index 9ca8f2f6a..bc7a56d12 100644 --- a/src/storage/locking/record_lock.cpp +++ b/src/storage/locking/record_lock.cpp @@ -1,27 +1,19 @@ #include "storage/locking/record_lock.hpp" -void RecordLock::lock() -{ - mutex.lock(&timeout); +void RecordLock::lock() { mutex.lock(&timeout); } + +LockStatus RecordLock::lock(const Id& id) { + if (mutex.try_lock()) return owner = id, LockStatus::Acquired; + + if (owner == id) return LockStatus::AlreadyHeld; + + return mutex.lock(&timeout), LockStatus::Acquired; } -LockStatus RecordLock::lock(const Id& id) -{ - if(mutex.try_lock()) - return owner = id, LockStatus::Acquired; - - if(owner == id) - return LockStatus::AlreadyHeld; - - return mutex.lock(&timeout), LockStatus::Acquired; -} - -void RecordLock::unlock() -{ - owner = INVALID; - mutex.unlock(); +void RecordLock::unlock() { + owner = INVALID; + mutex.unlock(); } constexpr struct timespec RecordLock::timeout; constexpr Id RecordLock::INVALID; - diff --git a/src/storage/locking/record_lock.hpp b/src/storage/locking/record_lock.hpp index 840697244..55c14caea 100644 --- a/src/storage/locking/record_lock.hpp +++ b/src/storage/locking/record_lock.hpp @@ -1,20 +1,19 @@ #pragma once -#include "threading/sync/futex.hpp" -#include "storage/locking/lock_status.hpp" #include "mvcc/id.hpp" +#include "storage/locking/lock_status.hpp" +#include "threading/sync/futex.hpp" -class RecordLock -{ - static constexpr struct timespec timeout {20, 0}; - static constexpr Id INVALID = Id(); +class RecordLock { + static constexpr struct timespec timeout { 20, 0 }; + static constexpr Id INVALID = Id(); -public: - LockStatus lock(const Id& id); - void lock(); - void unlock(); + public: + LockStatus lock(const Id& id); + void lock(); + void unlock(); -private: - Futex mutex; - Id owner; + private: + Futex mutex; + Id owner; }; diff --git a/src/storage/record_accessor.cpp b/src/storage/record_accessor.cpp index b00d4b024..e27426c0c 100644 --- a/src/storage/record_accessor.cpp +++ b/src/storage/record_accessor.cpp @@ -2,56 +2,59 @@ #include "storage/edge.hpp" #include "storage/vertex.hpp" -template<typename TRecord> -RecordAccessor<TRecord>::RecordAccessor(mvcc::VersionList<TRecord>& vlist, - GraphDbAccessor& db_accessor) - : vlist_(vlist), record_(vlist_.find(db_accessor.transaction_)), db_accessor_(db_accessor) { +template <typename TRecord> +RecordAccessor<TRecord>::RecordAccessor(mvcc::VersionList<TRecord> &vlist, + GraphDbAccessor &db_accessor) + : vlist_(vlist), + record_(vlist_.find(db_accessor.transaction_)), + db_accessor_(db_accessor) { assert(record_ != nullptr); } -template<typename TRecord> -RecordAccessor<TRecord>::RecordAccessor(mvcc::VersionList<TRecord>& vlist, - TRecord& record, - GraphDbAccessor& db_accessor) +template <typename TRecord> +RecordAccessor<TRecord>::RecordAccessor(mvcc::VersionList<TRecord> &vlist, + TRecord &record, + GraphDbAccessor &db_accessor) : vlist_(vlist), record_(&record), db_accessor_(db_accessor) { assert(record_ != nullptr); } -template<typename TRecord> -const TypedValue &RecordAccessor<TRecord>::PropsAt(GraphDb::Property key) const { +template <typename TRecord> +const TypedValue &RecordAccessor<TRecord>::PropsAt( + GraphDb::Property key) const { return view().properties_.at(key); } - -template<typename TRecord> +template <typename TRecord> size_t RecordAccessor<TRecord>::PropsErase(GraphDb::Property key) { return update().properties_.erase(key); } -template<typename TRecord> -const TypedValueStore<GraphDb::Property> &RecordAccessor<TRecord>::Properties() const { +template <typename TRecord> +const TypedValueStore<GraphDb::Property> &RecordAccessor<TRecord>::Properties() + const { return view().properties_; } -template<typename TRecord> +template <typename TRecord> void RecordAccessor<TRecord>::PropertiesAccept( - std::function<void(const GraphDb::Property key, const TypedValue &prop)> handler, - std::function<void()> finish) const { + std::function<void(const GraphDb::Property key, const TypedValue &prop)> + handler, + std::function<void()> finish) const { view().properties_.Accept(handler, finish); } - -template<typename TRecord> +template <typename TRecord> GraphDbAccessor &RecordAccessor<TRecord>::db_accessor() { return db_accessor_; } -template<typename TRecord> +template <typename TRecord> const GraphDbAccessor &RecordAccessor<TRecord>::db_accessor() const { return db_accessor_; } -template<typename TRecord> +template <typename TRecord> TRecord &RecordAccessor<TRecord>::update() { if (!record_->is_visible_write(db_accessor_.transaction_)) record_ = vlist_.update(db_accessor_.transaction_); @@ -59,11 +62,10 @@ TRecord &RecordAccessor<TRecord>::update() { return *record_; } -template<typename TRecord> +template <typename TRecord> const TRecord &RecordAccessor<TRecord>::view() const { return *record_; } template class RecordAccessor<Vertex>; template class RecordAccessor<Edge>; - diff --git a/src/storage/record_accessor.hpp b/src/storage/record_accessor.hpp index 42afc8f6f..a2cee9cb8 100644 --- a/src/storage/record_accessor.hpp +++ b/src/storage/record_accessor.hpp @@ -1,9 +1,9 @@ #pragma once -#include "mvcc/version_list.hpp" -#include "storage/typed_value.hpp" #include "database/graph_db.hpp" #include "database/graph_db_accessor.hpp" +#include "mvcc/version_list.hpp" +#include "storage/typed_value.hpp" #include "utils/pass_key.hpp" #include "storage/typed_value_store.hpp" @@ -17,11 +17,9 @@ * * @tparam TRecord Type of record (MVCC Version) of the accessor. */ -template<typename TRecord> +template <typename TRecord> class RecordAccessor { - -public: - + public: /** * The GraphDbAccessor is friend to this accessor so it can * operate on it's data (mvcc version-list and the record itself). @@ -36,17 +34,19 @@ public: * @param vlist MVCC record that this accessor wraps. * @param db_accessor The DB accessor that "owns" this record accessor. */ - RecordAccessor(mvcc::VersionList<TRecord>& vlist, GraphDbAccessor& db_accessor); + RecordAccessor(mvcc::VersionList<TRecord>& vlist, + GraphDbAccessor& db_accessor); /** * @param vlist MVCC record that this accessor wraps. - * @param record MVCC version (that is viewable from this db_accessor.transaction) - * of the given record. Slightly more optimal then the constructor that does not + * @param record MVCC version (that is viewable from this + * db_accessor.transaction) + * of the given record. Slightly more optimal then the constructor that does + * not * accept an already found record. * @param db_accessor The DB accessor that "owns" this record accessor. */ - RecordAccessor(mvcc::VersionList<TRecord>& vlist, - TRecord& record, + RecordAccessor(mvcc::VersionList<TRecord>& vlist, TRecord& record, GraphDbAccessor& db_accessor); /** @@ -54,7 +54,7 @@ public: * @param key * @return */ - const TypedValue &PropsAt(GraphDb::Property key) const; + const TypedValue& PropsAt(GraphDb::Property key) const; /** * Sets a value on the record for the given property. @@ -63,7 +63,7 @@ public: * @param key Property key. * @param value The value to set. */ - template<typename TValue> + template <typename TValue> void PropsSet(GraphDb::Property key, TValue value) { update().properties_.set(key, value); } @@ -80,18 +80,22 @@ public: * Returns the properties of this record. * @return */ - const TypedValueStore<GraphDb::Property> &Properties() const; + const TypedValueStore<GraphDb::Property>& Properties() const; - void PropertiesAccept(std::function<void(const GraphDb::Property key, const TypedValue &prop)> handler, - std::function<void()> finish = {}) const; + void PropertiesAccept( + std::function<void(const GraphDb::Property key, const TypedValue& prop)> + handler, + std::function<void()> finish = {}) const; - friend bool operator==(const RecordAccessor &a, const RecordAccessor &b) { - assert(&a.db_accessor_ == &b.db_accessor_); // assume the same db_accessor / transaction + friend bool operator==(const RecordAccessor& a, const RecordAccessor& b) { + assert(&a.db_accessor_ == + &b.db_accessor_); // assume the same db_accessor / transaction return &a.vlist_ == &b.vlist_; } - friend bool operator!=(const RecordAccessor &a, const RecordAccessor &b) { - assert(&a.db_accessor_ == &b.db_accessor_); // assume the same db_accessor / transaction + friend bool operator!=(const RecordAccessor& a, const RecordAccessor& b) { + assert(&a.db_accessor_ == + &b.db_accessor_); // assume the same db_accessor / transaction return !(a == b); } @@ -109,8 +113,7 @@ public: */ const GraphDbAccessor& db_accessor() const; -protected: - + protected: /** * Returns the update-ready version of the record. * @@ -130,17 +133,21 @@ protected: // Immutable, set in the constructor and never changed. GraphDbAccessor& db_accessor_; -private: + private: // The record (edge or vertex) this accessor provides access to. // Immutable, set in the constructor and never changed. mvcc::VersionList<TRecord>& vlist_; - /* The version of the record currently used in this transaction. Defaults to the - * latest viewable version (set in the constructor). After the first update done - * through this accessor a new, editable version, is created for this transaction, + /* The version of the record currently used in this transaction. Defaults to + * the + * latest viewable version (set in the constructor). After the first update + * done + * through this accessor a new, editable version, is created for this + * transaction, * and set as the value of this variable. * - * Stored as a pointer due to it's mutability (the update() function changes it). + * Stored as a pointer due to it's mutability (the update() function changes + * it). */ TRecord* record_; }; diff --git a/src/storage/typed_value.cpp b/src/storage/typed_value.cpp index ecffd3b8b..d86908b90 100644 --- a/src/storage/typed_value.cpp +++ b/src/storage/typed_value.cpp @@ -1,37 +1,41 @@ -#include <memory> -#include <iostream> -#include <cmath> #include <fmt/format.h> +#include <cmath> +#include <iostream> +#include <memory> #include "storage/typed_value.hpp" #include "utils/assert.hpp" // Value extraction template instantiations -template<> +template <> bool TypedValue::Value<bool>() const { - runtime_assert(type_ == TypedValue::Type::Bool, "Incompatible template param and type"); + runtime_assert(type_ == TypedValue::Type::Bool, + "Incompatible template param and type"); return bool_v; } -template<> +template <> std::string TypedValue::Value<std::string>() const { - runtime_assert(type_ == TypedValue::Type::String, "Incompatible template param and type"); + runtime_assert(type_ == TypedValue::Type::String, + "Incompatible template param and type"); return *string_v; } -template<> +template <> int TypedValue::Value<int>() const { - runtime_assert(type_ == TypedValue::Type::Int, "Incompatible template param and type"); + runtime_assert(type_ == TypedValue::Type::Int, + "Incompatible template param and type"); return int_v; } -template<> +template <> float TypedValue::Value<float>() const { - runtime_assert(type_ == TypedValue::Type::Float, "Incompatible template param and type"); + runtime_assert(type_ == TypedValue::Type::Float, + "Incompatible template param and type"); return float_v; } -TypedValue::TypedValue(const TypedValue &other) : type_(other.type_) { +TypedValue::TypedValue(const TypedValue& other) : type_(other.type_) { switch (other.type_) { case TypedValue::Type::Null: return; @@ -41,7 +45,7 @@ TypedValue::TypedValue(const TypedValue &other) : type_(other.type_) { return; case TypedValue::Type::String: - new(&string_v) std::shared_ptr<std::string>(other.string_v); + new (&string_v) std::shared_ptr<std::string>(other.string_v); return; case Type::Int: @@ -56,7 +60,7 @@ TypedValue::TypedValue(const TypedValue &other) : type_(other.type_) { permanent_fail("Unsupported TypedValue::Type"); } -std::ostream &operator<<(std::ostream &os, const TypedValue::Type type) { +std::ostream& operator<<(std::ostream& os, const TypedValue::Type type) { switch (type) { case TypedValue::Type::Null: return os << "null"; @@ -72,7 +76,7 @@ std::ostream &operator<<(std::ostream &os, const TypedValue::Type type) { permanent_fail("Unsupported TypedValue::Type"); } -std::ostream &operator<<(std::ostream &os, const TypedValue &value) { +std::ostream& operator<<(std::ostream& os, const TypedValue& value) { switch (value.type_) { case TypedValue::Type::Null: return os << "Null"; @@ -88,8 +92,7 @@ std::ostream &operator<<(std::ostream &os, const TypedValue &value) { permanent_fail("Unsupported TypedValue::Type"); } -TypedValue &TypedValue::operator=(TypedValue &&other) { - +TypedValue& TypedValue::operator=(TypedValue&& other) { // set the type of this const_cast<Type&>(type_) = other.type_; @@ -116,7 +119,6 @@ TypedValue &TypedValue::operator=(TypedValue &&other) { const TypedValue TypedValue::Null = TypedValue(); TypedValue::~TypedValue() { - switch (type_) { // destructor for primitive types does nothing case Type::Null: @@ -125,7 +127,7 @@ TypedValue::~TypedValue() { case Type::Float: return; - // destructor for shared pointer must release + // destructor for shared pointer must release case Type::String: string_v.~shared_ptr<std::string>(); return; @@ -154,14 +156,17 @@ float ToFloat(const TypedValue& value) { TypedValue operator<(const TypedValue& a, const TypedValue& b) { if (a.type_ == TypedValue::Type::Bool || b.type_ == TypedValue::Type::Bool) - throw TypedValueException("Invalid 'less' operand types({} + {})", a.type_, b.type_); + throw TypedValueException("Invalid 'less' operand types({} + {})", a.type_, + b.type_); if (a.type_ == TypedValue::Type::Null || b.type_ == TypedValue::Type::Null) return TypedValue::Null; - if (a.type_ == TypedValue::Type::String || b.type_ == TypedValue::Type::String) { + if (a.type_ == TypedValue::Type::String || + b.type_ == TypedValue::Type::String) { if (a.type_ != b.type_) - throw TypedValueException("Invalid equality operand types({} + {})", a.type_, b.type_); + throw TypedValueException("Invalid equality operand types({} + {})", + a.type_, b.type_); else return a.Value<std::string>() < b.Value<std::string>(); } @@ -174,29 +179,31 @@ TypedValue operator<(const TypedValue& a, const TypedValue& b) { } TypedValue operator==(const TypedValue& a, const TypedValue& b) { - if (a.type_ == TypedValue::Type::Null || b.type_ == TypedValue::Type::Null) return TypedValue::Null; - if (a.type_ == TypedValue::Type::String || b.type_ == TypedValue::Type::String) { + if (a.type_ == TypedValue::Type::String || + b.type_ == TypedValue::Type::String) { if (a.type_ != b.type_) - throw TypedValueException("Invalid equality operand types({} + {})", a.type_, b.type_); + throw TypedValueException("Invalid equality operand types({} + {})", + a.type_, b.type_); else return a.Value<std::string>() == b.Value<std::string>(); } if (a.type_ == TypedValue::Type::Bool || b.type_ == TypedValue::Type::Bool) { if (a.type_ != b.type_) - throw TypedValueException("Invalid equality operand types({} + {})", a.type_, b.type_); + throw TypedValueException("Invalid equality operand types({} + {})", + a.type_, b.type_); else return a.Value<bool>() == b.Value<bool>(); } // at this point we only have int and float - if (a.type_ == TypedValue::Type::Float || b.type_ == TypedValue::Type::Float){ + if (a.type_ == TypedValue::Type::Float || + b.type_ == TypedValue::Type::Float) { return ToFloat(a) == ToFloat(b); } else return a.Value<int>() == b.Value<int>(); - } TypedValue operator!(const TypedValue& a) { @@ -207,7 +214,8 @@ TypedValue operator!(const TypedValue& a) { return TypedValue(!a.Value<bool>()); default: - throw TypedValueException("Invalid logical not operand type (!{})", a.type_); + throw TypedValueException("Invalid logical not operand type (!{})", + a.type_); } } @@ -217,7 +225,7 @@ TypedValue operator!(const TypedValue& a) { * @param value a value. * @return A string. */ -std::string ValueToString(const TypedValue &value) { +std::string ValueToString(const TypedValue& value) { switch (value.type_) { case TypedValue::Type::String: return value.Value<std::string>(); @@ -232,7 +240,7 @@ std::string ValueToString(const TypedValue &value) { } } -TypedValue operator-(const TypedValue &a) { +TypedValue operator-(const TypedValue& a) { switch (a.type_) { case TypedValue::Type::Null: return TypedValue::Null; @@ -242,7 +250,8 @@ TypedValue operator-(const TypedValue &a) { return -a.Value<float>(); default: - throw TypedValueException("Invalid unary minus operand type (-{})", a.type_); + throw TypedValueException("Invalid unary minus operand type (-{})", + a.type_); } } @@ -260,79 +269,87 @@ TypedValue operator-(const TypedValue &a) { inline void EnsureArithmeticallyOk(const TypedValue& a, const TypedValue& b, bool string_ok, const std::string& op_name) { if (a.type_ == TypedValue::Type::Bool || b.type_ == TypedValue::Type::Bool) - throw TypedValueException("Invalid {} operand types {}, {}", op_name, a.type_, b.type_); + throw TypedValueException("Invalid {} operand types {}, {}", op_name, + a.type_, b.type_); - if (string_ok) - return; + if (string_ok) return; - if (a.type_ == TypedValue::Type::String || b.type_ == TypedValue::Type::String) - throw TypedValueException("Invalid subtraction operands types {}, {}", a.type_, b.type_); + if (a.type_ == TypedValue::Type::String || + b.type_ == TypedValue::Type::String) + throw TypedValueException("Invalid subtraction operands types {}, {}", + a.type_, b.type_); } -TypedValue operator+(const TypedValue& a, const TypedValue& b){ +TypedValue operator+(const TypedValue& a, const TypedValue& b) { EnsureArithmeticallyOk(a, b, true, "addition"); if (a.type_ == TypedValue::Type::Null || b.type_ == TypedValue::Type::Null) return TypedValue::Null; // no more Bool nor Null, summing works on anything from here onward - if (a.type_ == TypedValue::Type::String || b.type_ == TypedValue::Type::String) + if (a.type_ == TypedValue::Type::String || + b.type_ == TypedValue::Type::String) return ValueToString(a) + ValueToString(b); // at this point we only have int and float - if (a.type_ == TypedValue::Type::Float || b.type_ == TypedValue::Type::Float){ + if (a.type_ == TypedValue::Type::Float || + b.type_ == TypedValue::Type::Float) { return ToFloat(a) + ToFloat(b); } else return a.Value<int>() + b.Value<int>(); } -TypedValue operator-(const TypedValue& a, const TypedValue& b){ +TypedValue operator-(const TypedValue& a, const TypedValue& b) { EnsureArithmeticallyOk(a, b, false, "subtraction"); if (a.type_ == TypedValue::Type::Null || b.type_ == TypedValue::Type::Null) return TypedValue::Null; // at this point we only have int and float - if (a.type_ == TypedValue::Type::Float || b.type_ == TypedValue::Type::Float){ + if (a.type_ == TypedValue::Type::Float || + b.type_ == TypedValue::Type::Float) { return ToFloat(a) - ToFloat(b); } else return a.Value<int>() - b.Value<int>(); } -TypedValue operator/(const TypedValue& a, const TypedValue& b){ +TypedValue operator/(const TypedValue& a, const TypedValue& b) { EnsureArithmeticallyOk(a, b, false, "division"); if (a.type_ == TypedValue::Type::Null || b.type_ == TypedValue::Type::Null) return TypedValue::Null; // at this point we only have int and float - if (a.type_ == TypedValue::Type::Float || b.type_ == TypedValue::Type::Float){ + if (a.type_ == TypedValue::Type::Float || + b.type_ == TypedValue::Type::Float) { return ToFloat(a) / ToFloat(b); } else return a.Value<int>() / b.Value<int>(); } -TypedValue operator*(const TypedValue& a, const TypedValue& b){ +TypedValue operator*(const TypedValue& a, const TypedValue& b) { EnsureArithmeticallyOk(a, b, false, "multiplication"); if (a.type_ == TypedValue::Type::Null || b.type_ == TypedValue::Type::Null) return TypedValue::Null; // at this point we only have int and float - if (a.type_ == TypedValue::Type::Float || b.type_ == TypedValue::Type::Float){ + if (a.type_ == TypedValue::Type::Float || + b.type_ == TypedValue::Type::Float) { return ToFloat(a) * ToFloat(b); } else return a.Value<int>() * b.Value<int>(); } -TypedValue operator%(const TypedValue& a, const TypedValue& b){ +TypedValue operator%(const TypedValue& a, const TypedValue& b) { EnsureArithmeticallyOk(a, b, false, "modulo"); if (a.type_ == TypedValue::Type::Null || b.type_ == TypedValue::Type::Null) return TypedValue::Null; // at this point we only have int and float - if (a.type_ == TypedValue::Type::Float || b.type_ == TypedValue::Type::Float){ + if (a.type_ == TypedValue::Type::Float || + b.type_ == TypedValue::Type::Float) { return (float)fmod(ToFloat(a), ToFloat(b)); } else return a.Value<int>() % b.Value<int>(); @@ -343,21 +360,23 @@ inline bool IsLogicallyOk(const TypedValue& a) { } TypedValue operator&&(const TypedValue& a, const TypedValue& b) { - if(IsLogicallyOk(a) && IsLogicallyOk(b)){ + if (IsLogicallyOk(a) && IsLogicallyOk(b)) { if (a.type_ == TypedValue::Type::Null || b.type_ == TypedValue::Type::Null) return TypedValue::Null; else return a.Value<bool>() && b.Value<bool>(); } else - throw TypedValueException("Invalid logical and operand types({} && {})", a.type_, b.type_); + throw TypedValueException("Invalid logical and operand types({} && {})", + a.type_, b.type_); } TypedValue operator||(const TypedValue& a, const TypedValue& b) { - if(IsLogicallyOk(a) && IsLogicallyOk(b)){ + if (IsLogicallyOk(a) && IsLogicallyOk(b)) { if (a.type_ == TypedValue::Type::Null || b.type_ == TypedValue::Type::Null) return TypedValue::Null; else return a.Value<bool>() || b.Value<bool>(); } else - throw TypedValueException("Invalid logical and operand types({} && {})", a.type_, b.type_); + throw TypedValueException("Invalid logical and operand types({} && {})", + a.type_, b.type_); } diff --git a/src/storage/typed_value.hpp b/src/storage/typed_value.hpp index 4a0aaf296..eb35274b8 100644 --- a/src/storage/typed_value.hpp +++ b/src/storage/typed_value.hpp @@ -1,14 +1,14 @@ #pragma once -#include <memory> -#include <string> #include <cassert> #include <iostream> +#include <memory> +#include <string> #include <vector> -#include "utils/underlying_cast.hpp" -#include "utils/total_ordering.hpp" #include "utils/exceptions/basic_exception.hpp" +#include "utils/total_ordering.hpp" +#include "utils/underlying_cast.hpp" /** * Encapsulation of a value and it's type encapsulated in a class that has no @@ -18,21 +18,13 @@ * TypedValue::Type. Each such type corresponds to exactly one C++ type. */ class TypedValue : public TotalOrdering<TypedValue, TypedValue, TypedValue> { - -private: + private: /** Private default constructor, makes Null */ TypedValue() : type_(Type::Null) {} -public: - + public: /** A value type. Each type corresponds to exactly one C++ type */ - enum class Type : unsigned { - Null, - String, - Bool, - Int, - Float - }; + enum class Type : unsigned { Null, String, Bool, Int, Float }; // single static reference to Null, used whenever Null should be returned static const TypedValue Null; @@ -43,7 +35,7 @@ public: TypedValue(float value) : type_(Type::Float) { float_v = value; } /// constructors for non-primitive types (shared pointers) - TypedValue(const std::string &value) : type_(Type::String) { + TypedValue(const std::string& value) : type_(Type::String) { new (&string_v) std::shared_ptr<std::string>(new std::string(value)); } TypedValue(const char* value) : type_(Type::String) { @@ -54,7 +46,7 @@ public: TypedValue& operator=(TypedValue& other); TypedValue& operator=(TypedValue&& other); - TypedValue(const TypedValue& other); + TypedValue(const TypedValue& other); ~TypedValue(); /** @@ -65,7 +57,8 @@ public: * @tparam T Type to interpret the value as. * @return The value as type T. */ - template <typename T> T Value() const; + template <typename T> + T Value() const; friend std::ostream& operator<<(std::ostream& stream, const TypedValue& prop); @@ -74,7 +67,7 @@ public: */ const Type type_; -private: + private: // storage for the value of the property union { bool bool_v; @@ -90,8 +83,7 @@ private: * of incompatible Types. */ class TypedValueException : public BasicException { - -public: + public: using ::BasicException::BasicException; }; @@ -114,4 +106,4 @@ TypedValue operator&&(const TypedValue& a, const TypedValue& b); TypedValue operator||(const TypedValue& a, const TypedValue& b); // stream output -std::ostream &operator<<(std::ostream &os, const TypedValue::Type type); +std::ostream& operator<<(std::ostream& os, const TypedValue::Type type); diff --git a/src/storage/typed_value_store.cpp b/src/storage/typed_value_store.cpp index bc5804c69..0899cd911 100644 --- a/src/storage/typed_value_store.cpp +++ b/src/storage/typed_value_store.cpp @@ -3,17 +3,16 @@ #include "storage/typed_value_store.hpp" template <typename TKey> -const TypedValue& TypedValueStore::at(const TKey &key) const { - for (const auto& kv : props_) - if (kv.first == key) - return kv.second; +const TypedValue &TypedValueStore::at(const TKey &key) const { + for (const auto &kv : props_) + if (kv.first == key) return kv.second; return TypedValue::Null; } -template<typename TKey, typename TValue> +template <typename TKey, typename TValue> void TypedValueStore::set(const TKey &key, const TValue &value) { - for (auto& kv: props_) + for (auto &kv : props_) if (kv.first == key) { kv.second = TypedValue(value); return; @@ -26,7 +25,8 @@ void TypedValueStore::set(const TKey &key, const TValue &value) { // instantiations of the TypedValueStore::set function // instances must be made for all of the supported C++ types -template void TypedValueStore::set<std::string>(const TKey &key, const std::string &value); +template void TypedValueStore::set<std::string>(const TKey &key, + const std::string &value); template void TypedValueStore::set<bool>(const TKey &key, const bool &value); template void TypedValueStore::set<int>(const TKey &key, const int &value); template void TypedValueStore::set<float>(const TKey &key, const float &value); @@ -45,7 +45,9 @@ void TypedValueStore::set(const TKey &key, const char *value) { } size_t TypedValueStore::erase(const TKey &key) const { - auto found = std::find_if(props_.begin(), props_.end(), [&key](std::pair<TKey, TypedValue> &kv){return kv.first == key;}); + auto found = std::find_if( + props_.begin(), props_.end(), + [&key](std::pair<TKey, TypedValue> &kv) { return kv.first == key; }); if (found != props_.end()) { props_.erase(found); return 1; @@ -53,19 +55,14 @@ size_t TypedValueStore::erase(const TKey &key) const { return 0; } -size_t TypedValueStore::size() { - return props_.size(); -} +size_t TypedValueStore::size() { return props_.size(); } -void TypedValueStore::Accept(std::function<void(const TypedValueStore::TKey, const TypedValue &)> handler, - std::function<void()> finish) const { +void TypedValueStore::Accept( + std::function<void(const TypedValueStore::TKey, const TypedValue &)> + handler, + std::function<void()> finish) const { if (handler) - for (const auto& prop : props_) - handler(prop.first, prop.second); - - if (finish) - finish(); + for (const auto &prop : props_) handler(prop.first, prop.second); + if (finish) finish(); } - - diff --git a/src/storage/typed_value_store.hpp b/src/storage/typed_value_store.hpp index 4eacdd894..2efe30eab 100644 --- a/src/storage/typed_value_store.hpp +++ b/src/storage/typed_value_store.hpp @@ -1,8 +1,8 @@ #pragma once +#include <algorithm> #include <map> #include <vector> -#include <algorithm> #include "typed_value.hpp" diff --git a/src/storage/typed_value_utils.hpp b/src/storage/typed_value_utils.hpp index 493c10229..46e9167fb 100644 --- a/src/storage/typed_value_utils.hpp +++ b/src/storage/typed_value_utils.hpp @@ -8,7 +8,6 @@ #include <ostream> #include "storage/typed_value_store.hpp" - /** * Writes all of the values from the given store in JSON format * to the given output stream. @@ -17,11 +16,11 @@ * @param ostream The stream to write to. */ void TypedValuesToJson(const TypedValueStore& store, - std::ostream& ostream=std::cout) { - + std::ostream& ostream = std::cout) { bool first = true; - auto write_key = [&ostream, &first](const TypedValueStore::TKey &key) -> std::ostream& { + auto write_key = [&ostream, + &first](const TypedValueStore::TKey& key) -> std::ostream& { if (first) { ostream << '{'; first = false; diff --git a/src/storage/unique_object_store.hpp b/src/storage/unique_object_store.hpp index 8aae73c11..ec9c0d3a4 100644 --- a/src/storage/unique_object_store.hpp +++ b/src/storage/unique_object_store.hpp @@ -5,10 +5,10 @@ #pragma once -#include <memory> -#include <map> -#include <atomic> #include <stdint.h> +#include <atomic> +#include <map> +#include <memory> #include "data_structures/concurrent/concurrent_map.hpp" @@ -32,8 +32,7 @@ */ template <typename TObject, typename TKey = uint32_t> class UniqueObjectStore { - -public: + public: // Key is the type returned by this class, it's a template param using Key = TKey; @@ -52,13 +51,11 @@ public: * @return Key See above. */ Key GetKey(const TObject &obj) { - auto accessor = storage_.access(); // try to find an existing key auto found = accessor.find(obj); - if (found != accessor.end()) - return found->second; + if (found != accessor.end()) return found->second; // failed to find an existing key, create and insert a new one // return insertion result (either the new key, or an existing one @@ -66,12 +63,13 @@ public: return accessor.insert(obj, next_key_counter_++).first->second; } -private: + private: // maps objects to keys with support for concurrent writes ConcurrentMap<TObject, Key> storage_; // counter of keys that have been generated // note that this is not necessary the count of all keys being used since - // it's possible that Keys were generated and then discarded due to concurrency + // it's possible that Keys were generated and then discarded due to + // concurrency std::atomic<Key> next_key_counter_; }; diff --git a/src/storage/util.hpp b/src/storage/util.hpp index 9ad669f1f..35936aa77 100644 --- a/src/storage/util.hpp +++ b/src/storage/util.hpp @@ -10,15 +10,12 @@ * @param db_accessor A database accessor to create the record accessors with. */ template <typename TAccessor, typename TCollection> -std::vector<TAccessor> make_accessors( - const TCollection &records, - GraphDbAccessor &db_accessor) { - +std::vector<TAccessor> make_accessors(const TCollection &records, + GraphDbAccessor &db_accessor) { std::vector<TAccessor> accessors; accessors.reserve(records.size()); - for (auto record : records) - accessors.emplace_back(*record, db_accessor); + for (auto record : records) accessors.emplace_back(*record, db_accessor); return accessors; } diff --git a/src/storage/vertex.hpp b/src/storage/vertex.hpp index 504ba0205..2c09898e0 100644 --- a/src/storage/vertex.hpp +++ b/src/storage/vertex.hpp @@ -11,8 +11,7 @@ class Edge; class Vertex : public mvcc::Record<Vertex> { - -public: + public: std::vector<mvcc::VersionList<Edge>*> out_; std::vector<mvcc::VersionList<Edge>*> in_; std::vector<GraphDb::Label> labels_; diff --git a/src/storage/vertex_accessor.cpp b/src/storage/vertex_accessor.cpp index 8d129d386..c03fccaba 100644 --- a/src/storage/vertex_accessor.cpp +++ b/src/storage/vertex_accessor.cpp @@ -1,22 +1,17 @@ #include <algorithm> #include "storage/edge_accessor.hpp" -#include "storage/vertex_accessor.hpp" #include "storage/util.hpp" +#include "storage/vertex_accessor.hpp" -size_t VertexAccessor::out_degree() const { - return view().out_.size(); -} +size_t VertexAccessor::out_degree() const { return view().out_.size(); } -size_t VertexAccessor::in_degree() const { - return view().in_.size(); -} +size_t VertexAccessor::in_degree() const { return view().in_.size(); } bool VertexAccessor::add_label(GraphDb::Label label) { auto &labels_view = view().labels_; auto found = std::find(labels_view.begin(), labels_view.end(), label); - if (found!= labels_view.end()) - return false; + if (found != labels_view.end()) return false; // not a duplicate label, add it update().labels_.emplace_back(label); @@ -26,8 +21,7 @@ bool VertexAccessor::add_label(GraphDb::Label label) { size_t VertexAccessor::remove_label(GraphDb::Label label) { auto &labels = update().labels_; auto found = std::find(labels.begin(), labels.end(), label); - if (found == labels.end()) - return 0; + if (found == labels.end()) return 0; std::swap(*found, labels.back()); labels.pop_back(); @@ -39,7 +33,7 @@ bool VertexAccessor::has_label(GraphDb::Label label) const { return std::find(labels.begin(), labels.end(), label) != labels.end(); } -const std::vector<GraphDb::Label>& VertexAccessor::labels() const { +const std::vector<GraphDb::Label> &VertexAccessor::labels() const { return this->view().labels_; } diff --git a/src/storage/vertex_accessor.hpp b/src/storage/vertex_accessor.hpp index db9b702fd..1c1671d01 100644 --- a/src/storage/vertex_accessor.hpp +++ b/src/storage/vertex_accessor.hpp @@ -1,11 +1,11 @@ #pragma once -#include <vector> #include <set> +#include <vector> +#include "database/graph_db.hpp" #include "storage/record_accessor.hpp" #include "storage/vertex.hpp" -#include "database/graph_db.hpp" // forward declaring the EdgeAccessor because it's returned // by some functions @@ -19,7 +19,7 @@ class EdgeAccessor; * takes care of MVCC versioning. */ class VertexAccessor : public RecordAccessor<Vertex> { -public: + public: using RecordAccessor::RecordAccessor; /** diff --git a/src/storage/writer/rapidjson_stringwriter.hpp b/src/storage/writer/rapidjson_stringwriter.hpp index f2fce6785..16b17ef89 100644 --- a/src/storage/writer/rapidjson_stringwriter.hpp +++ b/src/storage/writer/rapidjson_stringwriter.hpp @@ -2,57 +2,38 @@ #include <memory> -#include "rapidjson/writer.h" #include "rapidjson/stringbuffer.h" +#include "rapidjson/writer.h" #include "storage/model/properties/properties.hpp" -class RapidJsonStringWriter -{ -public: - // TODO: clear up naming - using sptr = std::shared_ptr<rapidjson::Writer<rapidjson::StringBuffer>>; +class RapidJsonStringWriter { + public: + // TODO: clear up naming + using sptr = std::shared_ptr<rapidjson::Writer<rapidjson::StringBuffer>>; - RapidJsonStringWriter(const sptr& writer) : - writer(writer) - { - } + RapidJsonStringWriter(const sptr& writer) : writer(writer) {} - void handle(const std::string& key, Property& value, bool first) - { - writer->String(key.c_str()); - value.accept(*this); - } + void handle(const std::string& key, Property& value, bool first) { + writer->String(key.c_str()); + value.accept(*this); + } - void handle(Bool& b) - { - writer->String(b.value() ? "true" : "false"); - } + void handle(Bool& b) { writer->String(b.value() ? "true" : "false"); } - void handle(String& s) - { - writer->String(s.value.c_str()); - } + void handle(String& s) { writer->String(s.value.c_str()); } - void handle(Int32& int32) - { - writer->String(std::to_string(int32.value).c_str()); - } + void handle(Int32& int32) { + writer->String(std::to_string(int32.value).c_str()); + } - void handle(Int64& int64) - { - writer->String(std::to_string(int64.value).c_str()); - } + void handle(Int64& int64) { + writer->String(std::to_string(int64.value).c_str()); + } - void handle(Float& f) - { - writer->String(std::to_string(f.value).c_str()); - } + void handle(Float& f) { writer->String(std::to_string(f.value).c_str()); } - void handle(Double& d) - { - writer->String(std::to_string(d.value).c_str()); - } + void handle(Double& d) { writer->String(std::to_string(d.value).c_str()); } -private: - sptr writer; -}; + private: + sptr writer; +}; diff --git a/src/template_engine/engine.cpp b/src/template_engine/engine.cpp index 0237f67e3..2ff68a701 100644 --- a/src/template_engine/engine.cpp +++ b/src/template_engine/engine.cpp @@ -2,20 +2,17 @@ #include "utils/string/replace.hpp" -namespace template_engine -{ +namespace template_engine { -string render(const string& form, const data& partials) -{ - // TODO more optimal implementation - // another option is something like https://github.com/no1msd/mstch - // but it has to be wrapped - string rendered = form; - for (auto partial : partials) { - string key = "{{" + partial.first + "}}"; - rendered = utils::replace(rendered, key, partial.second); - } - return rendered; +string render(const string& form, const data& partials) { + // TODO more optimal implementation + // another option is something like https://github.com/no1msd/mstch + // but it has to be wrapped + string rendered = form; + for (auto partial : partials) { + string key = "{{" + partial.first + "}}"; + rendered = utils::replace(rendered, key, partial.second); + } + return rendered; } - } diff --git a/src/template_engine/engine.hpp b/src/template_engine/engine.hpp index ec5f3db04..8bcae45b1 100644 --- a/src/template_engine/engine.hpp +++ b/src/template_engine/engine.hpp @@ -3,12 +3,10 @@ #include <string> #include <unordered_map> -namespace template_engine -{ +namespace template_engine { using std::string; using data = std::unordered_map<string, string>; string render(const string& form, const data& partials); - } diff --git a/src/test/allocator.cpp b/src/test/allocator.cpp index f6c2b10b6..1e053d67f 100644 --- a/src/test/allocator.cpp +++ b/src/test/allocator.cpp @@ -2,67 +2,57 @@ #include "utils/memory/allocator.hpp" -TEST_CASE("A block of integers can be allocated") -{ - constexpr int N = 100; +TEST_CASE("A block of integers can be allocated") { + constexpr int N = 100; - fast_allocator<int> a; - - int* xs = a.allocate(N); + fast_allocator<int> a; - for(int i = 0; i < N; ++i) - xs[i] = i; + int* xs = a.allocate(N); - // can we read them back? - for(int i = 0; i < N; ++i) - REQUIRE(xs[i] == i); + for (int i = 0; i < N; ++i) xs[i] = i; - // we should be able to free the memory - a.deallocate(xs, N); + // can we read them back? + for (int i = 0; i < N; ++i) REQUIRE(xs[i] == i); + + // we should be able to free the memory + a.deallocate(xs, N); } -TEST_CASE("Allocator should work with structures") -{ - struct TestObject - { - TestObject(int a, int b, int c, int d) - : a(a), b(b), c(c), d(d) {} +TEST_CASE("Allocator should work with structures") { + struct TestObject { + TestObject(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {} - int a, b, c, d; - }; + int a, b, c, d; + }; - fast_allocator<TestObject> a; + fast_allocator<TestObject> a; - SECTION("Allocate a single object") - { - auto* test = a.allocate(1); - *test = TestObject(1, 2, 3, 4); + SECTION("Allocate a single object") { + auto* test = a.allocate(1); + *test = TestObject(1, 2, 3, 4); - REQUIRE(test->a == 1); - REQUIRE(test->b == 2); - REQUIRE(test->c == 3); - REQUIRE(test->d == 4); - - a.deallocate(test, 1); + REQUIRE(test->a == 1); + REQUIRE(test->b == 2); + REQUIRE(test->c == 3); + REQUIRE(test->d == 4); + + a.deallocate(test, 1); + } + + SECTION("Allocate a block of structures") { + constexpr int N = 8; + auto* tests = a.allocate(N); + + // structures should not overlap! + for (int i = 0; i < N; ++i) tests[i] = TestObject(i, i, i, i); + + for (int i = 0; i < N; ++i) { + REQUIRE(tests[i].a == i); + REQUIRE(tests[i].b == i); + REQUIRE(tests[i].c == i); + REQUIRE(tests[i].d == i); } - SECTION("Allocate a block of structures") - { - constexpr int N = 8; - auto* tests = a.allocate(N); - - // structures should not overlap! - for(int i = 0; i < N; ++i) - tests[i] = TestObject(i, i, i, i); - - for(int i = 0; i < N; ++i) - { - REQUIRE(tests[i].a == i); - REQUIRE(tests[i].b == i); - REQUIRE(tests[i].c == i); - REQUIRE(tests[i].d == i); - } - - a.deallocate(tests, N); - } + a.deallocate(tests, N); + } } diff --git a/src/test/dynamic_bitset.cpp b/src/test/dynamic_bitset.cpp index 0411edc88..68c51bae8 100644 --- a/src/test/dynamic_bitset.cpp +++ b/src/test/dynamic_bitset.cpp @@ -1,18 +1,17 @@ -#include "catch.hpp" #include "data_structures/bitset/dynamic_bitset.hpp" +#include "catch.hpp" -TEST_CASE("Dynamic bitset basic functionality") -{ - DynamicBitset<> db; - db.set(222555, 1); - bool value = db.at(222555, 1); - REQUIRE(value == true); +TEST_CASE("Dynamic bitset basic functionality") { + DynamicBitset<> db; + db.set(222555, 1); + bool value = db.at(222555, 1); + REQUIRE(value == true); - db.set(32, 1); - value = db.at(32, 1); - REQUIRE(value == true); + db.set(32, 1); + value = db.at(32, 1); + REQUIRE(value == true); - db.clear(32, 1); - value = db.at(32, 1); - REQUIRE(value == false); + db.clear(32, 1); + value = db.at(32, 1); + REQUIRE(value == false); } diff --git a/src/threading/hazard_ptr.hpp b/src/threading/hazard_ptr.hpp index 90c734cd9..c420a4a50 100644 --- a/src/threading/hazard_ptr.hpp +++ b/src/threading/hazard_ptr.hpp @@ -1,123 +1,98 @@ #pragma once +#include <unistd.h> #include <atomic> #include <vector> -#include <unistd.h> #include "hazard_store.hpp" -class hazard_ptr -{ - static constexpr size_t EMPTY = -1; - static constexpr uintptr_t NULLPTR = 0; +class hazard_ptr { + static constexpr size_t EMPTY = -1; + static constexpr uintptr_t NULLPTR = 0; -public: - hazard_ptr() = default; + public: + hazard_ptr() = default; - template <class T> - hazard_ptr(const T* ptr) : ptr(reinterpret_cast<uintptr_t>(ptr)) - { - if(ptr == nullptr) - return; + template <class T> + hazard_ptr(const T* ptr) : ptr(reinterpret_cast<uintptr_t>(ptr)) { + if (ptr == nullptr) return; - idx = HazardStore::get().acquire(this->ptr); - } + idx = HazardStore::get().acquire(this->ptr); + } - hazard_ptr(const hazard_ptr&) = delete; + hazard_ptr(const hazard_ptr&) = delete; - hazard_ptr(hazard_ptr&& other) - { - *this = std::move(other); - } + hazard_ptr(hazard_ptr&& other) { *this = std::move(other); } - ~hazard_ptr() - { - reset(); - } + ~hazard_ptr() { reset(); } - void reset() - { - if(idx == EMPTY) - return; + void reset() { + if (idx == EMPTY) return; - HazardStore::get().release(idx); - detach(); - } + HazardStore::get().release(idx); + detach(); + } - hazard_ptr& operator=(hazard_ptr&& other) - { - reset(); + hazard_ptr& operator=(hazard_ptr&& other) { + reset(); - ptr = other.ptr; - idx = other.idx; + ptr = other.ptr; + idx = other.idx; - other.detach(); + other.detach(); - return *this; - } + return *this; + } - uintptr_t get() const - { - return ptr; - } + uintptr_t get() const { return ptr; } - template <class T> - operator T*() const - { - return reinterpret_cast<T*>(ptr); - } + template <class T> + operator T*() const { + return reinterpret_cast<T*>(ptr); + } - friend bool operator==(const hazard_ptr& lhs, uintptr_t rhs) - { - return lhs.ptr == rhs; - } + friend bool operator==(const hazard_ptr& lhs, uintptr_t rhs) { + return lhs.ptr == rhs; + } - friend bool operator==(uintptr_t lhs, const hazard_ptr& rhs) - { - return operator==(rhs, lhs); - } + friend bool operator==(uintptr_t lhs, const hazard_ptr& rhs) { + return operator==(rhs, lhs); + } - template <class T> - friend bool operator==(const hazard_ptr& lhs, const T* const rhs) - { - return lhs.ptr == reinterpret_cast<uintptr_t>(rhs); - } + template <class T> + friend bool operator==(const hazard_ptr& lhs, const T* const rhs) { + return lhs.ptr == reinterpret_cast<uintptr_t>(rhs); + } - template <class T> - friend bool operator==(const T* const lhs, const hazard_ptr& rhs) - { - return operator==(rhs, lhs); - } + template <class T> + friend bool operator==(const T* const lhs, const hazard_ptr& rhs) { + return operator==(rhs, lhs); + } - friend bool operator!=(const hazard_ptr& lhs, uintptr_t rhs) - { - return !operator==(lhs, rhs); - } + friend bool operator!=(const hazard_ptr& lhs, uintptr_t rhs) { + return !operator==(lhs, rhs); + } - friend bool operator!=(uintptr_t lhs, const hazard_ptr& rhs) - { - return operator!=(rhs, lhs); - } + friend bool operator!=(uintptr_t lhs, const hazard_ptr& rhs) { + return operator!=(rhs, lhs); + } - template <class T> - friend bool operator!=(const hazard_ptr& lhs, const T* const rhs) - { - return !operator==(lhs, rhs); - } + template <class T> + friend bool operator!=(const hazard_ptr& lhs, const T* const rhs) { + return !operator==(lhs, rhs); + } - template <class T> - friend bool operator!=(const T* const lhs, const hazard_ptr& rhs) - { - return operator!=(rhs, lhs); - } + template <class T> + friend bool operator!=(const T* const lhs, const hazard_ptr& rhs) { + return operator!=(rhs, lhs); + } -private: - uintptr_t ptr {NULLPTR}; - size_t idx {EMPTY}; + private: + uintptr_t ptr{NULLPTR}; + size_t idx{EMPTY}; - void detach() - { - ptr = NULLPTR; - idx = EMPTY; - } + void detach() { + ptr = NULLPTR; + idx = EMPTY; + } }; diff --git a/src/threading/hazard_store.hpp b/src/threading/hazard_store.hpp index 4e66eeb3f..e8436347b 100644 --- a/src/threading/hazard_store.hpp +++ b/src/threading/hazard_store.hpp @@ -1,93 +1,81 @@ #pragma once -#include <cstdlib> -#include <vector> #include <atomic> #include <cassert> +#include <cstdlib> #include <thread> +#include <vector> #include "id.hpp" -class HazardPointerError : std::runtime_error -{ - using runtime_error::runtime_error; +class HazardPointerError : std::runtime_error { + using runtime_error::runtime_error; }; -class HazardStore -{ - using atomic_hp_t = std::atomic<uintptr_t>; +class HazardStore { + using atomic_hp_t = std::atomic<uintptr_t>; - static constexpr uintptr_t NULLPTR = 0; + static constexpr uintptr_t NULLPTR = 0; - friend class hazard_ptr; + friend class hazard_ptr; - HazardStore(size_t N, size_t K) : N(N), K(K), - ptrs(new atomic_hp_t[N * K]) {} + HazardStore(size_t N, size_t K) : N(N), K(K), ptrs(new atomic_hp_t[N * K]) {} -public: - HazardStore(const HazardStore&) = delete; - HazardStore(HazardStore&&) = delete; + public: + HazardStore(const HazardStore&) = delete; + HazardStore(HazardStore&&) = delete; - HazardStore& operator=(const HazardStore&) = delete; + HazardStore& operator=(const HazardStore&) = delete; - static HazardStore& get() - { - static constexpr size_t N = 16; // number of threds - static constexpr size_t K = 128; // pointers per thread + static HazardStore& get() { + static constexpr size_t N = 16; // number of threds + static constexpr size_t K = 128; // pointers per thread - static HazardStore hp(N, K); - return hp; + static HazardStore hp(N, K); + return hp; + } + + template <class T> + bool scan(T* ptr) { + return scan(reinterpret_cast<uintptr_t>(ptr)); + } + + bool scan(uintptr_t ptr) { + assert(ptr != NULLPTR); + + for (size_t i = 0; i < N * K; ++i) { + auto& hazard = ptrs[i]; + + if (hazard == ptr) return true; } - template <class T> - bool scan(T* ptr) - { - return scan(reinterpret_cast<uintptr_t>(ptr)); + return false; + } + + private: + const size_t N, K; + std::unique_ptr<atomic_hp_t[]> ptrs; + + size_t acquire(uintptr_t ptr) { + assert(ptr != NULLPTR); + auto idx = this_thread::id; + + for (auto i = N * idx; i < N * idx + K; ++i) { + auto& hazard = ptrs[i]; + + if (hazard.load(std::memory_order_relaxed) == NULLPTR) continue; + + // this MUST be seq_cst, otherwise garbage collector might not see + // the hazard pointer even if it is set + hazard.store(ptr, std::memory_order_seq_cst); + return i; } - bool scan(uintptr_t ptr) - { - assert(ptr != NULLPTR); + throw HazardPointerError("Exhausted all hazard pointers"); + } - for(size_t i = 0; i < N * K; ++i) - { - auto& hazard = ptrs[i]; - - if(hazard == ptr) - return true; - } - - return false; - } - -private: - const size_t N, K; - std::unique_ptr<atomic_hp_t[]> ptrs; - - size_t acquire(uintptr_t ptr) - { - assert(ptr != NULLPTR); - auto idx = this_thread::id; - - for(auto i = N * idx; i < N * idx + K; ++i) - { - auto& hazard = ptrs[i]; - - if(hazard.load(std::memory_order_relaxed) == NULLPTR) - continue; - - // this MUST be seq_cst, otherwise garbage collector might not see - // the hazard pointer even if it is set - hazard.store(ptr, std::memory_order_seq_cst); - return i; - } - - throw HazardPointerError("Exhausted all hazard pointers"); - } - - void release(size_t idx) - { - assert(ptrs[idx] != NULLPTR); - ptrs[idx].store(NULLPTR, std::memory_order_release); - } + void release(size_t idx) { + assert(ptrs[idx] != NULLPTR); + ptrs[idx].store(NULLPTR, std::memory_order_release); + } }; diff --git a/src/threading/id.hpp b/src/threading/id.hpp index 216140392..be868480f 100644 --- a/src/threading/id.hpp +++ b/src/threading/id.hpp @@ -1,6 +1,5 @@ #pragma once -namespace this_thread -{ +namespace this_thread { // thread_local unsigned id = 0; }; diff --git a/src/threading/pool.hpp b/src/threading/pool.hpp index 7ee46fd7f..2e55e5b3e 100644 --- a/src/threading/pool.hpp +++ b/src/threading/pool.hpp @@ -1,78 +1,70 @@ #pragma once -#include <mutex> #include <atomic> -#include <future> -#include <queue> #include <condition_variable> +#include <future> +#include <mutex> +#include <queue> #include "threading/sync/lockable.hpp" -class Pool : Lockable<std::mutex> -{ - using task_t = std::function<void()>; -public: - using sptr = std::shared_ptr<Pool>; +class Pool : Lockable<std::mutex> { + using task_t = std::function<void()>; - explicit Pool(size_t n = std::thread::hardware_concurrency()) : alive(true) + public: + using sptr = std::shared_ptr<Pool>; + + explicit Pool(size_t n = std::thread::hardware_concurrency()) : alive(true) { + threads.reserve(n); + + for (size_t i = 0; i < n; ++i) + threads.emplace_back([this]() -> void { loop(); }); + } + + Pool(Pool&) = delete; + Pool(Pool&&) = delete; + + ~Pool() { + alive.store(false, std::memory_order_seq_cst); + cond.notify_all(); + + for (auto& thread : threads) thread.join(); + } + + void run(task_t f) { { - threads.reserve(n); - - for(size_t i = 0; i < n; ++i) - threads.emplace_back([this]()->void { loop(); }); + auto lock = acquire_unique(); + tasks.push(f); } - Pool(Pool&) = delete; - Pool(Pool&&) = delete; + cond.notify_one(); + } - ~Pool() - { - alive.store(false, std::memory_order_seq_cst); - cond.notify_all(); + private: + std::vector<std::thread> threads; + std::queue<task_t> tasks; + std::atomic<bool> alive; - for(auto& thread : threads) - thread.join(); - } - - void run(task_t f) - { - { - auto lock = acquire_unique(); - tasks.push(f); - } - - cond.notify_one(); - } - -private: - std::vector<std::thread> threads; - std::queue<task_t> tasks; - std::atomic<bool> alive; - - std::mutex mutex; - std::condition_variable cond; - - void loop() - { - while(true) - { - task_t task; - - { - auto lock = acquire_unique(); - - cond.wait(lock, [this] { - return !this->alive || !this->tasks.empty(); - }); - - if(!alive && tasks.empty()) - return; - - task = std::move(tasks.front()); - tasks.pop(); - } - - task(); - } + std::mutex mutex; + std::condition_variable cond; + + void loop() { + while (true) { + task_t task; + + { + auto lock = acquire_unique(); + + cond.wait(lock, + [this] { return !this->alive || !this->tasks.empty(); }); + + if (!alive && tasks.empty()) return; + + task = std::move(tasks.front()); + tasks.pop(); + } + + task(); } + } }; diff --git a/src/threading/sync/caslock.hpp b/src/threading/sync/caslock.hpp index 8d9b27668..ad1ac8689 100644 --- a/src/threading/sync/caslock.hpp +++ b/src/threading/sync/caslock.hpp @@ -1,34 +1,23 @@ #pragma once -#include <atomic> #include <unistd.h> +#include <atomic> -class CasLock -{ -public: +class CasLock { + public: + void lock() { + bool locked = false; - void lock() - { - bool locked = false; - - while(!lock_flag.compare_exchange_weak(locked, true, - std::memory_order_release, - std::memory_order_relaxed)) - { - usleep(250); - } + while (!lock_flag.compare_exchange_weak( + locked, true, std::memory_order_release, std::memory_order_relaxed)) { + usleep(250); } + } - void unlock() - { - lock_flag.store(0, std::memory_order_release); - } + void unlock() { lock_flag.store(0, std::memory_order_release); } - bool locked() - { - return lock_flag.load(std::memory_order_relaxed); - } + bool locked() { return lock_flag.load(std::memory_order_relaxed); } -private: - std::atomic<bool> lock_flag; + private: + std::atomic<bool> lock_flag; }; diff --git a/src/threading/sync/futex.hpp b/src/threading/sync/futex.hpp index d4739a94f..d6498a8d4 100644 --- a/src/threading/sync/futex.hpp +++ b/src/threading/sync/futex.hpp @@ -1,163 +1,138 @@ #pragma once -#include <stdint.h> #include <errno.h> +#include <stdint.h> #include <atomic> #include "lock_timeout_error.hpp" #include "utils/cpu_relax.hpp" #include "utils/sys.hpp" -class Futex -{ - using futex_t = uint32_t; - using flag_t = uint8_t; +class Futex { + using futex_t = uint32_t; + using flag_t = uint8_t; - /* @brief Data structure for implementing fast mutexes - * - * This structure is 4B wide, as required for futex system call where - * the last two bytes are used for two flags - contended and locked, - * respectively. Memory layout for the structure looks like this: - * - * all - * |---------------------------------| - * 00000000 00000000 0000000C 0000000L - * |------| |------| - * contended locked - * - * L marks the locked bit - * C marks the contended bit - */ - union mutex_t - { - std::atomic<futex_t> all {0}; + /* @brief Data structure for implementing fast mutexes + * + * This structure is 4B wide, as required for futex system call where + * the last two bytes are used for two flags - contended and locked, + * respectively. Memory layout for the structure looks like this: + * + * all + * |---------------------------------| + * 00000000 00000000 0000000C 0000000L + * |------| |------| + * contended locked + * + * L marks the locked bit + * C marks the contended bit + */ + union mutex_t { + std::atomic<futex_t> all{0}; - struct - { - std::atomic<flag_t> locked; - std::atomic<flag_t> contended; - } state; - }; + struct { + std::atomic<flag_t> locked; + std::atomic<flag_t> contended; + } state; + }; - enum Contention : futex_t - { - UNCONTENDED = 0x0000, - CONTENDED = 0x0100 - }; + enum Contention : futex_t { UNCONTENDED = 0x0000, CONTENDED = 0x0100 }; - enum State : futex_t - { - UNLOCKED = 0x0000, - LOCKED = 0x0001, - UNLOCKED_CONTENDED = UNLOCKED | CONTENDED, // 0x0100 - LOCKED_CONTENDED = LOCKED | CONTENDED // 0x0101 - }; + enum State : futex_t { + UNLOCKED = 0x0000, + LOCKED = 0x0001, + UNLOCKED_CONTENDED = UNLOCKED | CONTENDED, // 0x0100 + LOCKED_CONTENDED = LOCKED | CONTENDED // 0x0101 + }; - static constexpr size_t LOCK_RETRIES = 100; - static constexpr size_t UNLOCK_RETRIES = 200; + static constexpr size_t LOCK_RETRIES = 100; + static constexpr size_t UNLOCK_RETRIES = 200; -public: - Futex() - { - static_assert(sizeof(mutex_t) == sizeof(futex_t), - "Atomic futex should be the same size as non_atomic"); + public: + Futex() { + static_assert(sizeof(mutex_t) == sizeof(futex_t), + "Atomic futex should be the same size as non_atomic"); + } + + bool try_lock() { + // we took the lock if we stored the LOCKED state and previous + // state was UNLOCKED + return mutex.state.locked.exchange(LOCKED, std::memory_order_acquire) == + UNLOCKED; + } + + void lock(const struct timespec* timeout = nullptr) { + // try to fast lock a few times before going to sleep + for (size_t i = 0; i < LOCK_RETRIES; ++i) { + // try to lock and exit if we succeed + if (try_lock()) return; + + // we failed, chill a bit + relax(); } - bool try_lock() - { - // we took the lock if we stored the LOCKED state and previous - // state was UNLOCKED - return mutex.state.locked.exchange(LOCKED, std::memory_order_acquire) - == UNLOCKED; + // the lock is contended, go to sleep. when someone + // wakes you up, try taking the lock again + while (mutex.all.exchange(LOCKED_CONTENDED, std::memory_order_acquire) & + LOCKED) { + // wait in the kernel for someone to wake us up when unlocking + auto status = futex_wait(LOCKED_CONTENDED, timeout); + + // check if we woke up because of a timeout + if (status == -1 && errno == ETIMEDOUT) + throw LockTimeoutError("Lock timeout"); + } + } + + void unlock() { + futex_t state = LOCKED; + + // if we're locked and uncontended, try to unlock the mutex before + // it becomes contended + if (mutex.all.load(std::memory_order_acquire) == LOCKED && + mutex.all.compare_exchange_strong(state, UNLOCKED, + std::memory_order_release, + std::memory_order_relaxed)) + return; + + // we are contended, just release the lock + mutex.state.locked.store(UNLOCKED, std::memory_order_release); + + // spin and hope someone takes a lock so we don't have to wake up + // anyone because that's quite expensive + for (size_t i = 0; i < UNLOCK_RETRIES; ++i) { + // if someone took the lock, we're ok + if (is_locked(std::memory_order_acquire)) return; + + relax(); } - void lock(const struct timespec* timeout = nullptr) - { - // try to fast lock a few times before going to sleep - for(size_t i = 0; i < LOCK_RETRIES; ++i) - { - // try to lock and exit if we succeed - if(try_lock()) - return; + // store that we are becoming uncontended + mutex.state.contended.store(UNCONTENDED, std::memory_order_release); - // we failed, chill a bit - relax(); - } + // we need to wake someone up + futex_wake(LOCKED); + } - // the lock is contended, go to sleep. when someone - // wakes you up, try taking the lock again - while(mutex.all.exchange(LOCKED_CONTENDED, std::memory_order_acquire) - & LOCKED) - { - // wait in the kernel for someone to wake us up when unlocking - auto status = futex_wait(LOCKED_CONTENDED, timeout); + bool is_locked(std::memory_order order = std::memory_order_seq_cst) const { + return mutex.state.locked.load(order); + } - // check if we woke up because of a timeout - if(status == -1 && errno == ETIMEDOUT) - throw LockTimeoutError("Lock timeout"); - } - } + bool is_contended(std::memory_order order = std::memory_order_seq_cst) const { + return mutex.state.contended.load(order); + } - void unlock() - { - futex_t state = LOCKED; + private: + mutex_t mutex; - // if we're locked and uncontended, try to unlock the mutex before - // it becomes contended - if(mutex.all.load(std::memory_order_acquire) == LOCKED && - mutex.all.compare_exchange_strong(state, UNLOCKED, - std::memory_order_release, - std::memory_order_relaxed)) - return; + int futex_wait(int value, const struct timespec* timeout = nullptr) { + return sys::futex(&mutex.all, FUTEX_WAIT_PRIVATE, value, timeout, nullptr, + 0); + } - // we are contended, just release the lock - mutex.state.locked.store(UNLOCKED, std::memory_order_release); + void futex_wake(int value) { + sys::futex(&mutex.all, FUTEX_WAKE_PRIVATE, value, nullptr, nullptr, 0); + } - // spin and hope someone takes a lock so we don't have to wake up - // anyone because that's quite expensive - for(size_t i = 0; i < UNLOCK_RETRIES; ++i) - { - // if someone took the lock, we're ok - if(is_locked(std::memory_order_acquire)) - return; - - relax(); - } - - // store that we are becoming uncontended - mutex.state.contended.store(UNCONTENDED, std::memory_order_release); - - // we need to wake someone up - futex_wake(LOCKED); - } - - bool is_locked(std::memory_order order = std::memory_order_seq_cst) const - { - return mutex.state.locked.load(order); - } - - bool is_contended(std::memory_order order = std::memory_order_seq_cst) const - { - return mutex.state.contended.load(order); - } - -private: - mutex_t mutex; - - int futex_wait(int value, const struct timespec* timeout = nullptr) - { - return sys::futex(&mutex.all, FUTEX_WAIT_PRIVATE, value, - timeout, nullptr, 0); - } - - void futex_wake(int value) - { - sys::futex(&mutex.all, FUTEX_WAKE_PRIVATE, value, nullptr, nullptr, 0); - } - - void relax() - { - cpu_relax(); - } + void relax() { cpu_relax(); } }; - diff --git a/src/threading/sync/lock_timeout_error.hpp b/src/threading/sync/lock_timeout_error.hpp index 9bb3fb78a..5a1d896a4 100644 --- a/src/threading/sync/lock_timeout_error.hpp +++ b/src/threading/sync/lock_timeout_error.hpp @@ -2,8 +2,7 @@ #include <stdexcept> -class LockTimeoutError : public std::runtime_error -{ -public: - using runtime_error::runtime_error; +class LockTimeoutError : public std::runtime_error { + public: + using runtime_error::runtime_error; }; diff --git a/src/threading/sync/timed_spinlock.hpp b/src/threading/sync/timed_spinlock.hpp index 3ccb1669a..9a20bf6a7 100644 --- a/src/threading/sync/timed_spinlock.hpp +++ b/src/threading/sync/timed_spinlock.hpp @@ -6,48 +6,40 @@ #include <unistd.h> -class LockExpiredError : public std::runtime_error -{ - using runtime_error::runtime_error; +class LockExpiredError : public std::runtime_error { + using runtime_error::runtime_error; }; template <size_t microseconds = 250> -class TimedSpinLock -{ -public: - TimedSpinLock(std::chrono::seconds expiration) - : expiration(expiration) {} +class TimedSpinLock { + public: + TimedSpinLock(std::chrono::seconds expiration) : expiration(expiration) {} - TimedSpinLock(std::chrono::milliseconds expiration) - : expiration(expiration) {} + TimedSpinLock(std::chrono::milliseconds expiration) + : expiration(expiration) {} - void lock() - { - using clock = std::chrono::high_resolution_clock; + void lock() { + using clock = std::chrono::high_resolution_clock; - auto start = clock::now(); + auto start = clock::now(); - while(!lock_flag.test_and_set(std::memory_order_acquire)) - { - // how long have we been locked? if we exceeded the expiration - // time, throw an exception and stop being blocked because this - // might be a deadlock! + while (!lock_flag.test_and_set(std::memory_order_acquire)) { + // how long have we been locked? if we exceeded the expiration + // time, throw an exception and stop being blocked because this + // might be a deadlock! - if(clock::now() - start > expiration) - throw LockExpiredError("This lock has expired"); + if (clock::now() - start > expiration) + throw LockExpiredError("This lock has expired"); - usleep(microseconds); - } + usleep(microseconds); } + } - void unlock() - { - lock_flag.clear(std::memory_order_release); - } + void unlock() { lock_flag.clear(std::memory_order_release); } -private: - std::chrono::milliseconds expiration; + private: + std::chrono::milliseconds expiration; - // guaranteed by standard to be lock free! - std::atomic_flag lock_flag = ATOMIC_FLAG_INIT; + // guaranteed by standard to be lock free! + std::atomic_flag lock_flag = ATOMIC_FLAG_INIT; }; diff --git a/src/threading/task.hpp b/src/threading/task.hpp index 4d77c1b37..1a00f27cf 100644 --- a/src/threading/task.hpp +++ b/src/threading/task.hpp @@ -2,77 +2,64 @@ #include <iostream> -#include "pool.hpp" #include "io/uv/uvloop.hpp" +#include "pool.hpp" #include "utils/placeholder.hpp" -class Task -{ - template <class T> - using work_t = std::function<T(void)>; +class Task { + template <class T> + using work_t = std::function<T(void)>; - template <class T> - using after_work_t = std::function<void(T)>; + template <class T> + using after_work_t = std::function<void(T)>; - template <class T> - struct Work - { - - Work(work_t<T> work, after_work_t<T> after_work) - : work(std::move(work)), after_work(std::move(after_work)) - { - req.data = static_cast<void*>(this); - } - - void operator()() - { - result.set(std::move(work())); - } - - work_t<T> work; - after_work_t<T> after_work; - - Placeholder<T> result; - - uv_work_t req; - - static void work_cb(uv_work_t* req) - { - auto& work = *static_cast<Work<T>*>(req->data); - work(); - } - - static void after_work_cb(uv_work_t* req, int) - { - auto work = static_cast<Work<T>*>(req->data); - - work->after_work(std::move(work->result.get())); - - delete work; - } - }; - -public: - using sptr = std::shared_ptr<Task>; - - Task(uv::UvLoop::sptr loop) : loop(loop) {} - - Task(Task&) = delete; - Task(Task&&) = delete; - - template <class F1, class F2> - void run(F1&& work, F2&& after_work) - { - using T = decltype(work()); - - auto w = new Work<T>(std::forward<F1>(work), - std::forward<F2>(after_work)); - - uv_queue_work(*loop, &w->req, - Work<T>::work_cb, - Work<T>::after_work_cb); + template <class T> + struct Work { + Work(work_t<T> work, after_work_t<T> after_work) + : work(std::move(work)), after_work(std::move(after_work)) { + req.data = static_cast<void*>(this); } -private: - uv::UvLoop::sptr loop; + void operator()() { result.set(std::move(work())); } + + work_t<T> work; + after_work_t<T> after_work; + + Placeholder<T> result; + + uv_work_t req; + + static void work_cb(uv_work_t* req) { + auto& work = *static_cast<Work<T>*>(req->data); + work(); + } + + static void after_work_cb(uv_work_t* req, int) { + auto work = static_cast<Work<T>*>(req->data); + + work->after_work(std::move(work->result.get())); + + delete work; + } + }; + + public: + using sptr = std::shared_ptr<Task>; + + Task(uv::UvLoop::sptr loop) : loop(loop) {} + + Task(Task&) = delete; + Task(Task&&) = delete; + + template <class F1, class F2> + void run(F1&& work, F2&& after_work) { + using T = decltype(work()); + + auto w = new Work<T>(std::forward<F1>(work), std::forward<F2>(after_work)); + + uv_queue_work(*loop, &w->req, Work<T>::work_cb, Work<T>::after_work_cb); + } + + private: + uv::UvLoop::sptr loop; }; diff --git a/src/threading/test.cpp b/src/threading/test.cpp index 23a3805ee..c780e2e89 100644 --- a/src/threading/test.cpp +++ b/src/threading/test.cpp @@ -2,20 +2,20 @@ #include "pool.hpp" -int main(void) -{ - auto size = 7; - auto N = 1000000; +int main(void) { + auto size = 7; + auto N = 1000000; - Pool pool(size); + Pool pool(size); - for(int i = 0; i < N; ++i) - pool.run([](int) { - int sum = 0; + for (int i = 0; i < N; ++i) + pool.run( + [](int) { + int sum = 0; - for(int i = 0; i < 2000; ++i) - sum += i % 7; - }, i); + for (int i = 0; i < 2000; ++i) sum += i % 7; + }, + i); - return 0; + return 0; } diff --git a/src/threading/thread.cpp b/src/threading/thread.cpp index aa5705186..fcb4fdf49 100644 --- a/src/threading/thread.cpp +++ b/src/threading/thread.cpp @@ -1,10 +1,9 @@ #include "thread.hpp" -Thread::Thread(Thread &&other) -{ - assert(thread_id == UNINITIALIZED); - thread_id = other.thread_id; - thread = std::move(other.thread); +Thread::Thread(Thread &&other) { + assert(thread_id == UNINITIALIZED); + thread_id = other.thread_id; + thread = std::move(other.thread); } void Thread::join() { return thread.join(); } diff --git a/src/threading/thread.hpp b/src/threading/thread.hpp index 490ae2e5f..f719342ba 100644 --- a/src/threading/thread.hpp +++ b/src/threading/thread.hpp @@ -7,41 +7,37 @@ #include "id.hpp" #include "utils/underlying_cast.hpp" -class Thread -{ - static std::atomic<unsigned> thread_counter; +class Thread { + static std::atomic<unsigned> thread_counter; -public: - static size_t count(std::memory_order order = std::memory_order_seq_cst) - { - return thread_counter.load(order); - } + public: + static size_t count(std::memory_order order = std::memory_order_seq_cst) { + return thread_counter.load(order); + } - static constexpr unsigned UNINITIALIZED = -1; - static constexpr unsigned MAIN_THREAD = 0; + static constexpr unsigned UNINITIALIZED = -1; + static constexpr unsigned MAIN_THREAD = 0; - template <class F> - Thread(F f) - { - thread_id = thread_counter.fetch_add(1, std::memory_order_acq_rel); - thread = std::thread([this, f]() { start_thread(f); }); - } + template <class F> + Thread(F f) { + thread_id = thread_counter.fetch_add(1, std::memory_order_acq_rel); + thread = std::thread([this, f]() { start_thread(f); }); + } - Thread() = default; - Thread(const Thread &) = delete; + Thread() = default; + Thread(const Thread &) = delete; - Thread(Thread &&other); + Thread(Thread &&other); - void join(); + void join(); -private: - unsigned thread_id = UNINITIALIZED; - std::thread thread; + private: + unsigned thread_id = UNINITIALIZED; + std::thread thread; - template <class F, class... Args> - void start_thread(F &&f) - { - // this_thread::id = thread_id; - f(); - } + template <class F, class... Args> + void start_thread(F &&f) { + // this_thread::id = thread_id; + f(); + } }; diff --git a/src/transactions/commit_log.hpp b/src/transactions/commit_log.hpp index cc043ac6a..c0dfecfd4 100644 --- a/src/transactions/commit_log.hpp +++ b/src/transactions/commit_log.hpp @@ -3,54 +3,50 @@ #include "data_structures/bitset/dynamic_bitset.hpp" #include "mvcc/id.hpp" -namespace tx -{ +namespace tx { -class CommitLog -{ -public: - struct Info - { - enum Status - { - ACTIVE = 0, // 00 - COMMITTED = 1, // 01 - ABORTED = 2, // 10 - }; - - bool is_active() const { return flags & ACTIVE; } - - bool is_committed() const { return flags & COMMITTED; } - - bool is_aborted() const { return flags & ABORTED; } - - operator uint8_t() const { return flags; } - - uint8_t flags; +class CommitLog { + public: + struct Info { + enum Status { + ACTIVE = 0, // 00 + COMMITTED = 1, // 01 + ABORTED = 2, // 10 }; - CommitLog() = default; - CommitLog(CommitLog &) = delete; - CommitLog(CommitLog &&) = delete; + bool is_active() const { return flags & ACTIVE; } - CommitLog operator=(CommitLog) = delete; + bool is_committed() const { return flags & COMMITTED; } - Info fetch_info(const Id &id) { return Info{log.at(2 * id, 2)}; } + bool is_aborted() const { return flags & ABORTED; } - bool is_active(const Id &id) { return fetch_info(id).is_active(); } + operator uint8_t() const { return flags; } - bool is_committed(const Id &id) { return fetch_info(id).is_committed(); } + uint8_t flags; + }; - void set_committed(const Id &id) { log.set(2 * id); } + CommitLog() = default; + CommitLog(CommitLog &) = delete; + CommitLog(CommitLog &&) = delete; - bool is_aborted(const Id &id) { return fetch_info(id).is_aborted(); } + CommitLog operator=(CommitLog) = delete; - void set_aborted(const Id &id) { log.set(2 * id + 1); } + Info fetch_info(const Id &id) { return Info{log.at(2 * id, 2)}; } -private: - // TODO: Searching the log will take more and more time the more and more - // transactoins are done. This could be awerted if DynamicBitset is changed - // to point to largest chunk instead of the smallest. - DynamicBitset<uint8_t, 32768> log; + bool is_active(const Id &id) { return fetch_info(id).is_active(); } + + bool is_committed(const Id &id) { return fetch_info(id).is_committed(); } + + void set_committed(const Id &id) { log.set(2 * id); } + + bool is_aborted(const Id &id) { return fetch_info(id).is_aborted(); } + + void set_aborted(const Id &id) { log.set(2 * id + 1); } + + private: + // TODO: Searching the log will take more and more time the more and more + // transactoins are done. This could be awerted if DynamicBitset is changed + // to point to largest chunk instead of the smallest. + DynamicBitset<uint8_t, 32768> log; }; } diff --git a/src/transactions/engine.hpp b/src/transactions/engine.hpp index 0348f80de..266a52e45 100644 --- a/src/transactions/engine.hpp +++ b/src/transactions/engine.hpp @@ -10,126 +10,112 @@ #include "transactions/transaction_store.hpp" #include "utils/counters/simple_counter.hpp" -namespace tx -{ +namespace tx { -class TransactionError : std::runtime_error -{ -public: - using std::runtime_error::runtime_error; +class TransactionError : std::runtime_error { + public: + using std::runtime_error::runtime_error; }; -class Engine : Lockable<SpinLock> -{ -public: - using sptr = std::shared_ptr<Engine>; +class Engine : Lockable<SpinLock> { + public: + using sptr = std::shared_ptr<Engine>; - Engine() : counter(1) {} + Engine() : counter(1) {} - // Begins transaction and runs given functions in same atomic step. - // Functions will be given Transaction& - template <class... F> - Transaction &begin(F... fun) - { - auto guard = this->acquire_unique(); + // Begins transaction and runs given functions in same atomic step. + // Functions will be given Transaction& + template <class... F> + Transaction &begin(F... fun) { + auto guard = this->acquire_unique(); - auto id = Id(counter.next()); - auto t = new Transaction(id, active, *this); + auto id = Id(counter.next()); + auto t = new Transaction(id, active, *this); - active.insert(id); - store.put(id, t); + active.insert(id); + store.put(id, t); - call(*t, fun...); + call(*t, fun...); - return *t; - } + return *t; + } - Transaction &advance(const Id &id) - { - auto guard = this->acquire_unique(); + Transaction &advance(const Id &id) { + auto guard = this->acquire_unique(); - auto *t = store.get(id); + auto *t = store.get(id); - if (t == nullptr) throw TransactionError("transaction does not exist"); + if (t == nullptr) throw TransactionError("transaction does not exist"); - // this is a new command - t->cid++; + // this is a new command + t->cid++; - return *t; - } + return *t; + } - // Returns copy of current snapshot - Snapshot<Id> snapshot() - { - auto guard = this->acquire_unique(); + // Returns copy of current snapshot + Snapshot<Id> snapshot() { + auto guard = this->acquire_unique(); - return active; - } + return active; + } - void commit(const Transaction &t) - { - auto guard = this->acquire_unique(); - clog.set_committed(t.id); + void commit(const Transaction &t) { + auto guard = this->acquire_unique(); + clog.set_committed(t.id); - finalize(t); - } + finalize(t); + } - void abort(const Transaction &t) - { - auto guard = this->acquire_unique(); - clog.set_aborted(t.id); + void abort(const Transaction &t) { + auto guard = this->acquire_unique(); + clog.set_aborted(t.id); - finalize(t); - } + finalize(t); + } - Id last_known_active() - { - auto guard = this->acquire_unique(); - return active.front(); - } + Id last_known_active() { + auto guard = this->acquire_unique(); + return active.front(); + } - // total number of transactions started from the beginning of time - uint64_t count() - { - auto guard = this->acquire_unique(); - return counter.count(); - } + // total number of transactions started from the beginning of time + uint64_t count() { + auto guard = this->acquire_unique(); + return counter.count(); + } - // the number of currently active transactions - size_t size() - { - auto guard = this->acquire_unique(); - return active.size(); - } + // the number of currently active transactions + size_t size() { + auto guard = this->acquire_unique(); + return active.size(); + } - CommitLog clog; + CommitLog clog; -private: - template <class T, class... F> - void call(Transaction &t, T fun, F... funs) - { - call(t, fun); - call(t, funs...); - } + private: + template <class T, class... F> + void call(Transaction &t, T fun, F... funs) { + call(t, fun); + call(t, funs...); + } - template <class T> - void call(Transaction &t, T fun) - { - fun(t); - } + template <class T> + void call(Transaction &t, T fun) { + fun(t); + } - void call(Transaction &t) {} + void call(Transaction &t) {} - void finalize(const Transaction &t) - { - active.remove(t.id); + void finalize(const Transaction &t) { + active.remove(t.id); - // remove transaction from store - store.del(t.id); - } + // remove transaction from store + store.del(t.id); + } - SimpleCounter<uint64_t> counter; - Snapshot<Id> active; - TransactionStore<uint64_t> store; + SimpleCounter<uint64_t> counter; + Snapshot<Id> active; + TransactionStore<uint64_t> store; }; } diff --git a/src/transactions/lock_store.hpp b/src/transactions/lock_store.hpp index eba0a8313..7877a57ed 100644 --- a/src/transactions/lock_store.hpp +++ b/src/transactions/lock_store.hpp @@ -5,55 +5,48 @@ #include <vector> #include "storage/locking/lock_status.hpp" -namespace tx -{ +namespace tx { template <class T> -class LockStore -{ - class LockHolder - { - public: - LockHolder() noexcept = default; +class LockStore { + class LockHolder { + public: + LockHolder() noexcept = default; - template <class... Args> - LockHolder(T *lock, Args &&... args) noexcept : lock(lock) - { - assert(lock != nullptr); - auto status = lock->lock(std::forward<Args>(args)...); - - if (status != LockStatus::Acquired) lock = nullptr; - } - - LockHolder(const LockHolder &) = delete; - LockHolder(LockHolder &&other) noexcept : lock(other.lock) - { - other.lock = nullptr; - } - - ~LockHolder() - { - if (lock != nullptr) lock->unlock(); - } - - bool active() const noexcept { return lock != nullptr; } - - private: - T *lock{nullptr}; - }; - -public: template <class... Args> - void take(T *lock, Args &&... args) - { - auto holder = LockHolder(lock, std::forward<Args>(args)...); + LockHolder(T *lock, Args &&... args) noexcept : lock(lock) { + assert(lock != nullptr); + auto status = lock->lock(std::forward<Args>(args)...); - if (!holder.active()) return; - - locks.emplace_back(LockHolder(lock, std::forward<Args>(args)...)); + if (status != LockStatus::Acquired) lock = nullptr; } -private: - std::vector<LockHolder> locks; + LockHolder(const LockHolder &) = delete; + LockHolder(LockHolder &&other) noexcept : lock(other.lock) { + other.lock = nullptr; + } + + ~LockHolder() { + if (lock != nullptr) lock->unlock(); + } + + bool active() const noexcept { return lock != nullptr; } + + private: + T *lock{nullptr}; + }; + + public: + template <class... Args> + void take(T *lock, Args &&... args) { + auto holder = LockHolder(lock, std::forward<Args>(args)...); + + if (!holder.active()) return; + + locks.emplace_back(LockHolder(lock, std::forward<Args>(args)...)); + } + + private: + std::vector<LockHolder> locks; }; }; diff --git a/src/transactions/snapshot.cpp b/src/transactions/snapshot.cpp index d99f74cd1..d30e02c84 100644 --- a/src/transactions/snapshot.cpp +++ b/src/transactions/snapshot.cpp @@ -3,15 +3,14 @@ #include "transactions/engine.hpp" template <class id_t> -bool tx::Snapshot<id_t>::all_finished(Engine &engine) -{ - for (auto &sid : active) { - if (engine.clog.is_active(sid)) { - return false; - } +bool tx::Snapshot<id_t>::all_finished(Engine &engine) { + for (auto &sid : active) { + if (engine.clog.is_active(sid)) { + return false; } + } - return true; + return true; } template class tx::Snapshot<Id>; diff --git a/src/transactions/snapshot.hpp b/src/transactions/snapshot.hpp index 34e19287b..1919ea791 100644 --- a/src/transactions/snapshot.hpp +++ b/src/transactions/snapshot.hpp @@ -6,66 +6,61 @@ #include "mvcc/id.hpp" #include "utils/option.hpp" -namespace tx -{ +namespace tx { class Engine; template <class id_t> -class Snapshot -{ -public: - Snapshot() = default; +class Snapshot { + public: + Snapshot() = default; - Snapshot(std::vector<id_t> active) : active(std::move(active)) {} + Snapshot(std::vector<id_t> active) : active(std::move(active)) {} - Snapshot(const Snapshot &other) { active = other.active; } + Snapshot(const Snapshot &other) { active = other.active; } - Snapshot(Snapshot &&other) { active = std::move(other.active); } + Snapshot(Snapshot &&other) { active = std::move(other.active); } - // True if all transaction from snapshot have finished. - bool all_finished(Engine &engine); + // True if all transaction from snapshot have finished. + bool all_finished(Engine &engine); - bool is_active(id_t xid) const - { - return std::binary_search(active.begin(), active.end(), xid); - } + bool is_active(id_t xid) const { + return std::binary_search(active.begin(), active.end(), xid); + } - // Return id of oldest transaction. None if there is no transactions in - // snapshot. - Option<Id> oldest_active() - { - auto n = active.size(); - if (n > 0) { - Id min = active[0]; - for (auto i = 1; i < n; i++) { - if (active[i] < min) { - min = active[i]; - } - } - return Option<Id>(min); - - } else { - return Option<Id>(); + // Return id of oldest transaction. None if there is no transactions in + // snapshot. + Option<Id> oldest_active() { + auto n = active.size(); + if (n > 0) { + Id min = active[0]; + for (auto i = 1; i < n; i++) { + if (active[i] < min) { + min = active[i]; } + } + return Option<Id>(min); + + } else { + return Option<Id>(); } + } - void insert(const id_t &id) { active.push_back(id); } + void insert(const id_t &id) { active.push_back(id); } - void remove(const id_t &id) - { - // remove transaction from the active transactions list - auto last = std::remove(active.begin(), active.end(), id); - active.erase(last, active.end()); - } + void remove(const id_t &id) { + // remove transaction from the active transactions list + auto last = std::remove(active.begin(), active.end(), id); + active.erase(last, active.end()); + } - const id_t &front() { return active.front(); } + const id_t &front() { return active.front(); } - const id_t &back() { return active.back(); } + const id_t &back() { return active.back(); } - size_t size() { return active.size(); } + size_t size() { return active.size(); } -private: - std::vector<id_t> active; + private: + std::vector<id_t> active; }; } diff --git a/src/transactions/transaction.cpp b/src/transactions/transaction.cpp index 4c4e89dac..9a003da8b 100644 --- a/src/transactions/transaction.cpp +++ b/src/transactions/transaction.cpp @@ -1,36 +1,31 @@ #include "transactions/transaction.hpp" -#include <chrono> // std::chrono::seconds +#include <chrono> // std::chrono::seconds -#include <thread> // std::this_thread::sleep_for +#include <thread> // std::this_thread::sleep_for #include "transactions/engine.hpp" -namespace tx -{ +namespace tx { Transaction::Transaction(const Id &id, const Snapshot<Id> &snapshot, Engine &engine) - : TransactionRead(id, snapshot, engine) -{ -} + : TransactionRead(id, snapshot, engine) {} // Returns copy of transaction_id -TransactionRead Transaction::transaction_read() -{ - TransactionRead const &t = *this; - return t; +TransactionRead Transaction::transaction_read() { + TransactionRead const &t = *this; + return t; } -void Transaction::wait_for_active() -{ - while (snapshot.size() > 0) { - auto sid = snapshot.back(); - while (engine.clog.fetch_info(sid).is_active()) { - std::this_thread::sleep_for(std::chrono::microseconds(100)); - } - snapshot.remove(sid); +void Transaction::wait_for_active() { + while (snapshot.size() > 0) { + auto sid = snapshot.back(); + while (engine.clog.fetch_info(sid).is_active()) { + std::this_thread::sleep_for(std::chrono::microseconds(100)); } + snapshot.remove(sid); + } } void Transaction::take_lock(RecordLock &lock) { locks.take(&lock, id); } diff --git a/src/transactions/transaction.hpp b/src/transactions/transaction.hpp index ef0a880f8..7228ea19b 100644 --- a/src/transactions/transaction.hpp +++ b/src/transactions/transaction.hpp @@ -11,29 +11,26 @@ #include "transactions/snapshot.hpp" #include "transactions/transaction_read.hpp" -namespace tx -{ +namespace tx { -class Transaction : public TransactionRead -{ +class Transaction : public TransactionRead { + public: + Transaction(const Id &id, const Snapshot<Id> &snapshot, Engine &engine); + Transaction(const Transaction &) = delete; + Transaction(Transaction &&) = default; -public: - Transaction(const Id &id, const Snapshot<Id> &snapshot, Engine &engine); - Transaction(const Transaction &) = delete; - Transaction(Transaction &&) = default; + // Returns copy of transaction_read + TransactionRead transaction_read(); - // Returns copy of transaction_read - TransactionRead transaction_read(); + // Blocks until all transactions from snapshot finish. After this method, + // snapshot will be empty. + void wait_for_active(); - // Blocks until all transactions from snapshot finish. After this method, - // snapshot will be empty. - void wait_for_active(); + void take_lock(RecordLock &lock); + void commit(); + void abort(); - void take_lock(RecordLock &lock); - void commit(); - void abort(); - -private: - LockStore<RecordLock> locks; + private: + LockStore<RecordLock> locks; }; } diff --git a/src/transactions/transaction_read.cpp b/src/transactions/transaction_read.cpp index 6922008b4..468c4370d 100644 --- a/src/transactions/transaction_read.cpp +++ b/src/transactions/transaction_read.cpp @@ -2,38 +2,28 @@ #include "transactions/engine.hpp" -namespace tx -{ +namespace tx { TransactionRead::TransactionRead(Engine &engine) - : TransactionRead(Id(), Snapshot<Id>(), engine) -{ -} + : TransactionRead(Id(), Snapshot<Id>(), engine) {} TransactionRead::TransactionRead(const Id &&id, const Snapshot<Id> &&snapshot, Engine &engine) - : id(id), cid(1), snapshot(std::move(snapshot)), engine(engine) -{ -} + : id(id), cid(1), snapshot(std::move(snapshot)), engine(engine) {} TransactionRead::TransactionRead(const Id &id, const Snapshot<Id> &snapshot, Engine &engine) - : id(id), cid(1), snapshot(snapshot), engine(engine) -{ + : id(id), cid(1), snapshot(snapshot), engine(engine) {} + +bool TransactionRead::all_finished() { + return !engine.clog.is_active(id) && snapshot.all_finished(engine); } -bool TransactionRead::all_finished() -{ - return !engine.clog.is_active(id) && snapshot.all_finished(engine); +bool TransactionRead::in_snapshot(const Id &id) const { + return snapshot.is_active(id); } -bool TransactionRead::in_snapshot(const Id &id) const -{ - return snapshot.is_active(id); -} - -Id TransactionRead::oldest_active() -{ - return snapshot.oldest_active().take_or(Id(id)); +Id TransactionRead::oldest_active() { + return snapshot.oldest_active().take_or(Id(id)); } } diff --git a/src/transactions/transaction_read.hpp b/src/transactions/transaction_read.hpp index 8897f8744..2fbd4ae23 100644 --- a/src/transactions/transaction_read.hpp +++ b/src/transactions/transaction_read.hpp @@ -7,46 +7,43 @@ #include "mvcc/id.hpp" #include "transactions/snapshot.hpp" -namespace tx -{ +namespace tx { class Engine; // Has read only capbilities. // TODO: Not all applicable methods in code have been changed to accept // TransactionRead instead of a Transaction. -class TransactionRead -{ - friend class Engine; +class TransactionRead { + friend class Engine; -public: - TransactionRead(Engine &engine); + public: + TransactionRead(Engine &engine); - TransactionRead(const Id &&id, const Snapshot<Id> &&snapshot, - Engine &engine); + TransactionRead(const Id &&id, const Snapshot<Id> &&snapshot, Engine &engine); - TransactionRead(const Id &id, const Snapshot<Id> &snapshot, Engine &engine); + TransactionRead(const Id &id, const Snapshot<Id> &snapshot, Engine &engine); - // True if this transaction and every transaction from snapshot have - // finished. - bool all_finished(); + // True if this transaction and every transaction from snapshot have + // finished. + bool all_finished(); - // Return id of oldest transaction from snapshot. - Id oldest_active(); + // Return id of oldest transaction from snapshot. + Id oldest_active(); - // True if id is in snapshot. - bool in_snapshot(const Id &id) const; + // True if id is in snapshot. + bool in_snapshot(const Id &id) const; - // index of this transaction - const Id id; + // index of this transaction + const Id id; - // index of the current command in the current transaction; - uint8_t cid; + // index of the current command in the current transaction; + uint8_t cid; - Engine &engine; + Engine &engine; -protected: - // a snapshot of currently active transactions - Snapshot<Id> snapshot; + protected: + // a snapshot of currently active transactions + Snapshot<Id> snapshot; }; } diff --git a/src/transactions/transaction_store.hpp b/src/transactions/transaction_store.hpp index e00014536..71c23c230 100644 --- a/src/transactions/transaction_store.hpp +++ b/src/transactions/transaction_store.hpp @@ -5,31 +5,24 @@ #include "transactions/transaction.hpp" -namespace tx -{ +namespace tx { template <class id_t> -class TransactionStore -{ -public: - Transaction* get(id_t id) const - { - auto it = store.find(id); - return it != store.end() ? it->second.get() : nullptr; - } +class TransactionStore { + public: + Transaction* get(id_t id) const { + auto it = store.find(id); + return it != store.end() ? it->second.get() : nullptr; + } - void put(id_t id, Transaction* transaction) - { - store.emplace(std::make_pair(id, std::unique_ptr<Transaction>(transaction))); - } + void put(id_t id, Transaction* transaction) { + store.emplace( + std::make_pair(id, std::unique_ptr<Transaction>(transaction))); + } - void del(id_t id) - { - store.erase(id); - } + void del(id_t id) { store.erase(id); } -private: - std::map<id_t, std::unique_ptr<Transaction>> store; + private: + std::map<id_t, std::unique_ptr<Transaction>> store; }; - } diff --git a/src/utils/algorithm.hpp b/src/utils/algorithm.hpp index c1a265ec9..b86b0e6d1 100644 --- a/src/utils/algorithm.hpp +++ b/src/utils/algorithm.hpp @@ -17,11 +17,9 @@ */ template <class ForwardIt, class UnaryPredicate, class Action> ForwardIt action_remove_if(ForwardIt first, ForwardIt last, UnaryPredicate p, - Action a) -{ - auto it = std::remove_if(first, last, p); - if (it == last) - return it; - std::for_each(it, last, a); - return it; + Action a) { + auto it = std::remove_if(first, last, p); + if (it == last) return it; + std::for_each(it, last, a); + return it; } diff --git a/src/utils/align.hpp b/src/utils/align.hpp index b900b03ac..6127d83ae 100644 --- a/src/utils/align.hpp +++ b/src/utils/align.hpp @@ -3,7 +3,7 @@ // FROM: A Malloc Tutorial, Marwan Burelle, 2009 // align address x to 4 bytes -#define align_4(x) (((((x) - 1)>>2)<<2)+4) +#define align_4(x) (((((x)-1) >> 2) << 2) + 4) // align address x to 8 bytes -#define align_8(x) (((((x) - 1)>>3)<<3)+8) +#define align_8(x) (((((x)-1) >> 3) << 3) + 8) diff --git a/src/utils/assert.hpp b/src/utils/assert.hpp index 842f183d2..209fba750 100644 --- a/src/utils/assert.hpp +++ b/src/utils/assert.hpp @@ -15,14 +15,14 @@ * file, line) */ #ifdef STACKTRACE_ASSERT_ON -#define __handle_assert_message(message) \ - Stacktrace stacktrace; \ - std::cerr << "ASSERT: " << message << std::endl; \ - std::cerr << stacktrace.dump(); +#define __handle_assert_message(message) \ + Stacktrace stacktrace; \ + std::cerr << "ASSERT: " << message << std::endl; \ + std::cerr << stacktrace.dump(); #else -#define __handle_assert_message(message) \ - std::cerr << "ASSERT: " << message << " In file " << __FILE__ << " #" \ - << __LINE__ << std::endl; +#define __handle_assert_message(message) \ + std::cerr << "ASSERT: " << message << " In file " << __FILE__ << " #" \ + << __LINE__ << std::endl; #endif /** @@ -32,26 +32,25 @@ * a good use-case for this type of assert is during unit testing because * assert has to stay active all the time */ -#define permanent_assert(condition, message) \ - if (!(condition)) \ - { \ - std::ostringstream s; \ - s << message; \ - __handle_assert_message(s.str()); \ - std::exit(EXIT_FAILURE); \ - } +#define permanent_assert(condition, message) \ + if (!(condition)) { \ + std::ostringstream s; \ + s << message; \ + __handle_assert_message(s.str()); \ + std::exit(EXIT_FAILURE); \ + } -#define permanent_fail(message) \ - std::ostringstream s; \ - s << message; \ - __handle_assert_message(s.str()); \ - std::exit(EXIT_FAILURE); \ -/** - * runtime assertion is more like standart C assert but with custom - * define which controls when the assertion will be active - * - * could be used wherever the standard C assert is used but - * the user should not forget about RUNTIME_ASSERT_ON define +#define permanent_fail(message) \ + std::ostringstream s; \ + s << message; \ + __handle_assert_message(s.str()); \ + std::exit(EXIT_FAILURE); \ +/** \ + * runtime assertion is more like standart C assert but with custom \ + * define which controls when the assertion will be active \ + * \ + * could be used wherever the standard C assert is used but \ + * the user should not forget about RUNTIME_ASSERT_ON define \ */ #ifdef RUNTIME_ASSERT_ON #define runtime_assert(condition, message) permanent_assert(condition, message) diff --git a/src/utils/auto_scope.hpp b/src/utils/auto_scope.hpp index e583f0d0a..7fdecc8be 100644 --- a/src/utils/auto_scope.hpp +++ b/src/utils/auto_scope.hpp @@ -2,7 +2,7 @@ #include <utility> -/** +/** * @brief Calls a cleanup function on scope exit * * consider this example: @@ -32,28 +32,26 @@ * @tparam F Lambda which holds a wrapper function around the cleanup code */ template <class F> -class OnScopeExit -{ -public: - OnScopeExit(F& f) : f(f) {} +class OnScopeExit { + public: + OnScopeExit(F& f) : f(f) {} - ~OnScopeExit() - { - // calls the cleanup function - f(); - } + ~OnScopeExit() { + // calls the cleanup function + f(); + } -private: - F& f; + private: + F& f; }; #define TOKEN_PASTEx(x, y) x##y #define TOKEN_PASTE(x, y) TOKEN_PASTEx(x, y) -#define Auto_INTERNAL(Destructor, counter) \ - auto TOKEN_PASTE(auto_func_, counter) = [&]() { Destructor; }; \ - OnScopeExit<decltype(TOKEN_PASTE(auto_func_, counter))> \ - TOKEN_PASTE(auto_, counter)(TOKEN_PASTE(auto_func_, counter)); +#define Auto_INTERNAL(Destructor, counter) \ + auto TOKEN_PASTE(auto_func_, counter) = [&]() { Destructor; }; \ + OnScopeExit<decltype(TOKEN_PASTE(auto_func_, counter))> TOKEN_PASTE( \ + auto_, counter)(TOKEN_PASTE(auto_func_, counter)); #define Auto(Destructor) Auto_INTERNAL(Destructor, __COUNTER__) diff --git a/src/utils/bash_colors.hpp b/src/utils/bash_colors.hpp index 534043f7d..7526819bc 100644 --- a/src/utils/bash_colors.hpp +++ b/src/utils/bash_colors.hpp @@ -1,10 +1,9 @@ #pragma once -namespace bash_color -{ - auto blue = "\033[94m"; - auto green = "\033[92m"; - auto yellow = "\033[93m"; - auto red = "\033[91m"; - auto end = "\033[0m"; +namespace bash_color { +auto blue = "\033[94m"; +auto green = "\033[92m"; +auto yellow = "\033[93m"; +auto red = "\033[91m"; +auto end = "\033[0m"; } diff --git a/src/utils/border.hpp b/src/utils/border.hpp index 18def0fe2..aab835a0f 100644 --- a/src/utils/border.hpp +++ b/src/utils/border.hpp @@ -4,68 +4,56 @@ #include "utils/total_ordering.hpp" // Defines Including as [ and Excluding < for ranges. -enum BorderType -{ - Including = 0, - Excluding = 1, +enum BorderType { + Including = 0, + Excluding = 1, }; // If key is not present he is both the largest and the smallest of the keys. template <class T> -class Border -{ +class Border { + public: + Border() : key(Option<T>()), type(Including) {} + Border(T Tey, BorderType type) : key(Option<T>(std::move(key))), type(type) {} -public: - Border() : key(Option<T>()), type(Including) {} - Border(T Tey, BorderType type) : key(Option<T>(std::move(key))), type(type) - { - } + // Border(Border &other) = default; + Border(Border &other) = default; + Border(Border &&other) = default; - // Border(Border &other) = default; - Border(Border &other) = default; - Border(Border &&other) = default; + Border &operator=(Border &&other) = default; + Border &operator=(Border &other) = default; - Border &operator=(Border &&other) = default; - Border &operator=(Border &other) = default; + friend bool operator<(const Border<T> &a, const T &other) { + return !a.key.is_present() || + (a.type == Excluding && a.key.get() <= other) || + (a.type == Including && a.key.get() < other); + } - friend bool operator<(const Border<T> &a, const T &other) - { - return !a.key.is_present() || - (a.type == Excluding && a.key.get() <= other) || - (a.type == Including && a.key.get() < other); - } + friend bool operator==(const Border<T> &a, const T &other) { + return a.type == Including && a.key.is_present() && a.key.get() == other; + } - friend bool operator==(const Border<T> &a, const T &other) - { - return a.type == Including && a.key.is_present() && - a.key.get() == other; - } + friend bool operator>(const Border<T> &a, const T &other) { + return !a.key.is_present() || + (a.type == Excluding && a.key.get() >= other) || + (a.type == Including && a.key.get() > other); + } - friend bool operator>(const Border<T> &a, const T &other) - { - return !a.key.is_present() || - (a.type == Excluding && a.key.get() >= other) || - (a.type == Including && a.key.get() > other); - } + friend bool operator!=(const Border<T> &a, const T &b) { return !(a == b); } - friend bool operator!=(const Border<T> &a, const T &b) { return !(a == b); } + friend bool operator<=(const Border<T> &a, const T &b) { + return a < b || a == b; + } - friend bool operator<=(const Border<T> &a, const T &b) - { - return a < b || a == b; - } + friend bool operator>=(const Border<T> &a, const T &b) { + return a > b || a == b; + } - friend bool operator>=(const Border<T> &a, const T &b) - { - return a > b || a == b; - } - - Option<T> key; - BorderType type; + Option<T> key; + BorderType type; }; template <class T> -auto make_inf_border() -{ - return Border<T>(); +auto make_inf_border() { + return Border<T>(); } diff --git a/src/utils/bswap.hpp b/src/utils/bswap.hpp index 0e7ee0fef..b26eb9528 100644 --- a/src/utils/bswap.hpp +++ b/src/utils/bswap.hpp @@ -8,38 +8,32 @@ template <class T> inline T bswap(T value); -template<> -inline int16_t bswap<int16_t>(int16_t value) -{ - return __bswap_16(value); +template <> +inline int16_t bswap<int16_t>(int16_t value) { + return __bswap_16(value); } -template<> -inline uint16_t bswap<uint16_t>(uint16_t value) -{ - return __bswap_16(value); +template <> +inline uint16_t bswap<uint16_t>(uint16_t value) { + return __bswap_16(value); } -template<> -inline int32_t bswap<int32_t>(int32_t value) -{ - return __bswap_32(value); +template <> +inline int32_t bswap<int32_t>(int32_t value) { + return __bswap_32(value); } -template<> -inline uint32_t bswap<uint32_t>(uint32_t value) -{ - return __bswap_32(value); +template <> +inline uint32_t bswap<uint32_t>(uint32_t value) { + return __bswap_32(value); } -template<> -inline int64_t bswap<int64_t>(int64_t value) -{ - return __bswap_64(value); +template <> +inline int64_t bswap<int64_t>(int64_t value) { + return __bswap_64(value); } -template<> -inline uint64_t bswap<uint64_t>(uint64_t value) -{ - return __bswap_64(value); +template <> +inline uint64_t bswap<uint64_t>(uint64_t value) { + return __bswap_64(value); } diff --git a/src/utils/buffer.hpp b/src/utils/buffer.hpp index 807f6e2b9..6d9f92e07 100644 --- a/src/utils/buffer.hpp +++ b/src/utils/buffer.hpp @@ -4,41 +4,31 @@ #include "utils/numerics/ceil.hpp" -class Buffer -{ -public: - Buffer(size_t capacity, size_t chunk_size) - : capacity(capacity), chunk_size(chunk_size) {} +class Buffer { + public: + Buffer(size_t capacity, size_t chunk_size) + : capacity(capacity), chunk_size(chunk_size) {} - Buffer& append(const std::string& string) - { - return this->append(string.c_str(), string.size()); + Buffer& append(const std::string& string) { + return this->append(string.c_str(), string.size()); + } + + Buffer& append(const char* string, size_t n) { + auto new_size = size() + n; + + if (capacity < new_size) { + capacity = new_size; + data = static_cast<char*>(realloc(data, new_size)); } - Buffer& append(const char* string, size_t n) - { - auto new_size = size() + n; + size = new_size; + } - if(capacity < new_size) - { - capacity = new_size; - data = static_cast<char*>(realloc(data, new_size)); - } + Buffer& operator<<(const std::string& string) {} - size = new_size; - } + size_t size() const { return str.size(); } - Buffer& operator<<(const std::string& string) - { - - } - - size_t size() const - { - return str.size(); - } - -private: - size_t size_, capacity, chunk_size; - char* data; + private: + size_t size_, capacity, chunk_size; + char* data; }; diff --git a/src/utils/char_str.hpp b/src/utils/char_str.hpp index 6d76952b7..b032b0d13 100644 --- a/src/utils/char_str.hpp +++ b/src/utils/char_str.hpp @@ -3,23 +3,20 @@ #include <cstring> #include "utils/total_ordering.hpp" -class CharStr : public TotalOrdering<CharStr> -{ -public: - CharStr(const char *str) : str(str) {} +class CharStr : public TotalOrdering<CharStr> { + public: + CharStr(const char *str) : str(str) {} - std::string to_string() const { return std::string(str); } + std::string to_string() const { return std::string(str); } - friend bool operator==(const CharStr &lhs, const CharStr &rhs) - { - return strcmp(lhs.str, rhs.str) == 0; - } + friend bool operator==(const CharStr &lhs, const CharStr &rhs) { + return strcmp(lhs.str, rhs.str) == 0; + } - friend bool operator<(const CharStr &lhs, const CharStr &rhs) - { - return strcmp(lhs.str, rhs.str) < 0; - } + friend bool operator<(const CharStr &lhs, const CharStr &rhs) { + return strcmp(lhs.str, rhs.str) < 0; + } -private: - const char *str; + private: + const char *str; }; diff --git a/src/utils/command_line/arguments.hpp b/src/utils/command_line/arguments.hpp index 5fbb69b4b..f8cf5cec3 100644 --- a/src/utils/command_line/arguments.hpp +++ b/src/utils/command_line/arguments.hpp @@ -45,16 +45,14 @@ class ProgramArguments { bool is_valid() { for (const auto &arg : required_arguments_) - if (!arguments_.count(arg)) return false; + if (!arguments_.count(arg)) return false; return true; } - ProgramArguments() { - } + ProgramArguments() {} public: - ~ProgramArguments() { - } + ~ProgramArguments() {} class Argument { private: diff --git a/src/utils/config/config.hpp b/src/utils/config/config.hpp index b36976cd3..6ed7f8ab7 100644 --- a/src/utils/config/config.hpp +++ b/src/utils/config/config.hpp @@ -16,7 +16,7 @@ #include "yaml-cpp/yaml.h" namespace config { - + template <class Definition> class Config { private: @@ -27,7 +27,7 @@ class Config { void load_configuration(std::string path) { try { YAML::Node node = YAML::LoadFile(path); - + for (YAML::const_iterator it = node.begin(); it != node.end(); ++it) { dict[it->first.as<std::string>()] = it->second.as<std::string>(); } @@ -48,7 +48,7 @@ class Config { // default user configuration // fetches user configuration folder - std::string homedir = std::getenv("HOME"); + std::string homedir = std::getenv("HOME"); if ((homedir == "")) { homedir = getpwuid(getuid())->pw_dir; } @@ -72,11 +72,8 @@ class Config { for (const auto& argument : Definition::arguments) { dict[argument] = GET_ARG("--" + argument, dict[argument]).get_string(); } - } - std::string operator[](const char* key) { - return dict[key]; - } + std::string operator[](const char* key) { return dict[key]; } }; } diff --git a/src/utils/counters/atomic_counter.hpp b/src/utils/counters/atomic_counter.hpp index 4278cd023..50ca3f0d5 100644 --- a/src/utils/counters/atomic_counter.hpp +++ b/src/utils/counters/atomic_counter.hpp @@ -5,21 +5,16 @@ template <class T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr> -class AtomicCounter -{ -public: - AtomicCounter(T initial = 0) : counter(initial) {} +class AtomicCounter { + public: + AtomicCounter(T initial = 0) : counter(initial) {} - T next(std::memory_order order = std::memory_order_seq_cst) - { - return counter.fetch_add(1, order); - } + T next(std::memory_order order = std::memory_order_seq_cst) { + return counter.fetch_add(1, order); + } - T operator++() - { - return next(); - } + T operator++() { return next(); } -private: - std::atomic<T> counter; + private: + std::atomic<T> counter; }; diff --git a/src/utils/counters/ring_counter.hpp b/src/utils/counters/ring_counter.hpp index 6cf6d0d96..b3c704be6 100644 --- a/src/utils/counters/ring_counter.hpp +++ b/src/utils/counters/ring_counter.hpp @@ -2,27 +2,23 @@ #include <cstdlib> -class RingCounter -{ -public: - RingCounter(size_t n, size_t initial = 0) - : n(n), counter(initial) {} +class RingCounter { + public: + RingCounter(size_t n, size_t initial = 0) : n(n), counter(initial) {} - size_t operator++() - { - counter = (counter + 1) % n; - return counter; - } + size_t operator++() { + counter = (counter + 1) % n; + return counter; + } - size_t operator++(int) - { - auto value = counter; - ++counter; - return value; - } + size_t operator++(int) { + auto value = counter; + ++counter; + return value; + } - operator size_t() const { return counter; } + operator size_t() const { return counter; } -private: - size_t n, counter; + private: + size_t n, counter; }; diff --git a/src/utils/counters/simple_counter.hpp b/src/utils/counters/simple_counter.hpp index eee8f70c1..622efd177 100644 --- a/src/utils/counters/simple_counter.hpp +++ b/src/utils/counters/simple_counter.hpp @@ -1,21 +1,14 @@ #pragma once template <class T> -class SimpleCounter -{ -public: - SimpleCounter(T initial) : counter(initial) {} +class SimpleCounter { + public: + SimpleCounter(T initial) : counter(initial) {} - T next() - { - return ++counter; - } + T next() { return ++counter; } - T count() - { - return counter; - } + T count() { return counter; } -private: - T counter; + private: + T counter; }; diff --git a/src/utils/cpu_relax.hpp b/src/utils/cpu_relax.hpp index eaf06be34..442af7044 100644 --- a/src/utils/cpu_relax.hpp +++ b/src/utils/cpu_relax.hpp @@ -3,10 +3,9 @@ /* @brief improves contention in spinlocks * hints the processor that we're in a spinlock and not doing much */ -inline void cpu_relax() -{ - // if IBMPower - // HMT_very_low() - // http://stackoverflow.com/questions/5425506/equivalent-of-x86-pause-instruction-for-ppc - asm("PAUSE"); +inline void cpu_relax() { + // if IBMPower + // HMT_very_low() + // http://stackoverflow.com/questions/5425506/equivalent-of-x86-pause-instruction-for-ppc + asm("PAUSE"); } diff --git a/src/utils/crtp.hpp b/src/utils/crtp.hpp index e07ed7426..dd60907ad 100644 --- a/src/utils/crtp.hpp +++ b/src/utils/crtp.hpp @@ -4,15 +4,8 @@ // curiously recurring template pattern template <class Derived> -struct Crtp -{ - Derived& derived() - { - return *static_cast<Derived*>(this); - } +struct Crtp { + Derived& derived() { return *static_cast<Derived*>(this); } - const Derived& derived() const - { - return *static_cast<const Derived*>(this); - } + const Derived& derived() const { return *static_cast<const Derived*>(this); } }; diff --git a/src/utils/datetime/datetime.hpp b/src/utils/datetime/datetime.hpp index 9b63cffd7..3bb283d9a 100644 --- a/src/utils/datetime/datetime.hpp +++ b/src/utils/datetime/datetime.hpp @@ -1,35 +1,27 @@ #pragma once - #include "utils/exceptions/basic_exception.hpp" -class Datetime -{ -public: - Datetime() - { +class Datetime { + public: + Datetime() {} - } + Datetime(std::time_t time_point) { + auto result = gmtime_r(&time_point, &time); - Datetime(std::time_t time_point) - { - auto result = gmtime_r(&time_point, &time); + if (result == nullptr) + throw DatetimeError("Unable to construct from {}", time_point); + } - if(result == nullptr) - throw DatetimeError("Unable to construct from {}", time_point); - } + Datetime(const Datetime&) = default; + Datetime(Datetime&&) = default; - Datetime(const Datetime&) = default; - Datetime(Datetime&&) = default; - - static Datetime now() - { - timespec + static Datetime now() { + timespec return Datetime(); - } + } - -private: - std::tm time; + private: + std::tm time; }; diff --git a/src/utils/datetime/datetime_error.hpp b/src/utils/datetime/datetime_error.hpp index 8a91cca87..2c8bde7ed 100644 --- a/src/utils/datetime/datetime_error.hpp +++ b/src/utils/datetime/datetime_error.hpp @@ -2,9 +2,7 @@ #include "utils/exceptions/basic_exception.hpp" -class DatetimeError : public BasicException -{ -public: - using BasicException::BasicException; +class DatetimeError : public BasicException { + public: + using BasicException::BasicException; }; - diff --git a/src/utils/datetime/timestamp.hpp b/src/utils/datetime/timestamp.hpp index f9287e0ad..0461a3afc 100644 --- a/src/utils/datetime/timestamp.hpp +++ b/src/utils/datetime/timestamp.hpp @@ -10,98 +10,67 @@ #include "utils/datetime/datetime_error.hpp" #include "utils/total_ordering.hpp" -class Timestamp : public TotalOrdering<Timestamp> -{ -public: - Timestamp() : Timestamp(0, 0) {} +class Timestamp : public TotalOrdering<Timestamp> { + public: + Timestamp() : Timestamp(0, 0) {} - Timestamp(std::time_t time, long nsec = 0) : unix_time(time), nsec(nsec) - { - auto result = gmtime_r(&time, &this->time); + Timestamp(std::time_t time, long nsec = 0) : unix_time(time), nsec(nsec) { + auto result = gmtime_r(&time, &this->time); - if(result == nullptr) - throw DatetimeError("Unable to construct from {}", time); - } + if (result == nullptr) + throw DatetimeError("Unable to construct from {}", time); + } - Timestamp(const Timestamp&) = default; - Timestamp(Timestamp&&) = default; + Timestamp(const Timestamp&) = default; + Timestamp(Timestamp&&) = default; - static Timestamp now() - { - timespec time; - clock_gettime(CLOCK_REALTIME, &time); + static Timestamp now() { + timespec time; + clock_gettime(CLOCK_REALTIME, &time); - return {time.tv_sec, time.tv_nsec}; - } + return {time.tv_sec, time.tv_nsec}; + } - long year() const - { - return time.tm_year + 1900; - } + long year() const { return time.tm_year + 1900; } - long month() const - { - return time.tm_mon + 1; - } + long month() const { return time.tm_mon + 1; } - long day() const - { - return time.tm_mday; - } + long day() const { return time.tm_mday; } - long hour() const - { - return time.tm_hour; - } + long hour() const { return time.tm_hour; } - long min() const - { - return time.tm_min; - } + long min() const { return time.tm_min; } - long sec() const - { - return time.tm_sec; - } + long sec() const { return time.tm_sec; } - long subsec() const - { - return nsec / 10000; - } + long subsec() const { return nsec / 10000; } - const std::string to_iso8601() const - { - return fmt::format(fiso8601, year(), month(), day(), hour(), - min(), sec(), subsec()); - } + const std::string to_iso8601() const { + return fmt::format(fiso8601, year(), month(), day(), hour(), min(), sec(), + subsec()); + } - friend std::ostream& operator<<(std::ostream& stream, const Timestamp& ts) - { - return stream << ts.to_iso8601(); - } + friend std::ostream& operator<<(std::ostream& stream, const Timestamp& ts) { + return stream << ts.to_iso8601(); + } - operator std::string() const - { - return to_iso8601(); - } + operator std::string() const { return to_iso8601(); } - constexpr friend bool operator==(const Timestamp& a, const Timestamp& b) - { - return a.unix_time == b.unix_time && a.nsec == b.nsec; - } + constexpr friend bool operator==(const Timestamp& a, const Timestamp& b) { + return a.unix_time == b.unix_time && a.nsec == b.nsec; + } - constexpr friend bool operator<(const Timestamp& a, const Timestamp& b) - { - return a.unix_time < b.unix_time - || (a.unix_time == b.unix_time && a.nsec < b.nsec); - } + constexpr friend bool operator<(const Timestamp& a, const Timestamp& b) { + return a.unix_time < b.unix_time || + (a.unix_time == b.unix_time && a.nsec < b.nsec); + } -private: - std::tm time; + private: + std::tm time; - std::time_t unix_time; - long nsec; + std::time_t unix_time; + long nsec; - static constexpr auto fiso8601 = - "{:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}.{:05d}Z"; + static constexpr auto fiso8601 = + "{:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}.{:05d}Z"; }; diff --git a/src/utils/dynamic_lib.hpp b/src/utils/dynamic_lib.hpp index c4e9ed8aa..7bb29d742 100644 --- a/src/utils/dynamic_lib.hpp +++ b/src/utils/dynamic_lib.hpp @@ -23,100 +23,90 @@ namespace fs = std::experimental::filesystem; * of undelying dynamic object. */ template <typename T> -class DynamicLib : public Loggable -{ -public: - /** - * Initializes dynamic library (loads lib, produce and - * destruct functions) - * - * @param lib_path file system path to dynamic library - */ - DynamicLib(const fs::path &lib_path) - : Loggable("DynamicLib"), lib_path(lib_path), lib_object(nullptr) - { - // load dynamic lib - dynamic_lib = dlopen(lib_path.c_str(), RTLD_NOW); - if (!dynamic_lib) throw std::runtime_error(dlerror()); - dlerror(); /* Clear any existing error */ - logger.trace("dynamic lib at ADDRESS({}) was opened", dynamic_lib); +class DynamicLib : public Loggable { + public: + /** + * Initializes dynamic library (loads lib, produce and + * destruct functions) + * + * @param lib_path file system path to dynamic library + */ + DynamicLib(const fs::path &lib_path) + : Loggable("DynamicLib"), lib_path(lib_path), lib_object(nullptr) { + // load dynamic lib + dynamic_lib = dlopen(lib_path.c_str(), RTLD_NOW); + if (!dynamic_lib) throw std::runtime_error(dlerror()); + dlerror(); /* Clear any existing error */ + logger.trace("dynamic lib at ADDRESS({}) was opened", dynamic_lib); - // load produce method - this->produce_method = - (typename T::ProducePrototype)dlsym(dynamic_lib, "produce"); - const char *dlsym_produce_error = dlerror(); - if (dlsym_produce_error) throw std::runtime_error(dlsym_produce_error); + // load produce method + this->produce_method = + (typename T::ProducePrototype)dlsym(dynamic_lib, "produce"); + const char *dlsym_produce_error = dlerror(); + if (dlsym_produce_error) throw std::runtime_error(dlsym_produce_error); - // load destruct method - this->destruct_method = - (typename T::DestructPrototype)dlsym(dynamic_lib, "destruct"); - const char *dlsym_destruct_error = dlerror(); - if (dlsym_destruct_error) - throw std::runtime_error(dlsym_destruct_error); + // load destruct method + this->destruct_method = + (typename T::DestructPrototype)dlsym(dynamic_lib, "destruct"); + const char *dlsym_destruct_error = dlerror(); + if (dlsym_destruct_error) throw std::runtime_error(dlsym_destruct_error); + } + + // becuase we are dealing with pointers + // and conceptualy there is no need to copy the instance of this class + // the copy constructor and copy assignment operator are deleted + // the same applies to move methods + DynamicLib(const DynamicLib &other) = delete; + DynamicLib &operator=(const DynamicLib &other) = delete; + DynamicLib(DynamicLib &&other) = delete; + DynamicLib &operator=(DynamicLib &&other) = delete; + + /** + * Singleton method. Returns the same instance of underlying class + * for every call. The instance of underlying class is returned by + * extern C produce function. + * + * @return T the instance of lib class + */ + typename T::ObjectPrototype *instance() { + if (lib_object == nullptr) lib_object = this->produce_method(); + return lib_object; + } + + /** + * Clean underlying object and close the lib + */ + ~DynamicLib() { + // first destroy underlying object + if (lib_object != nullptr) { + logger.trace("shared object at ADDRESS({}) will be destroyed", + (void *)lib_object); + this->destruct_method(lib_object); } - // becuase we are dealing with pointers - // and conceptualy there is no need to copy the instance of this class - // the copy constructor and copy assignment operator are deleted - // the same applies to move methods - DynamicLib(const DynamicLib &other) = delete; - DynamicLib &operator=(const DynamicLib &other) = delete; - DynamicLib(DynamicLib &&other) = delete; - DynamicLib &operator=(DynamicLib &&other) = delete; - - /** - * Singleton method. Returns the same instance of underlying class - * for every call. The instance of underlying class is returned by - * extern C produce function. - * - * @return T the instance of lib class - */ - typename T::ObjectPrototype *instance() - { - if (lib_object == nullptr) lib_object = this->produce_method(); - return lib_object; + // then destroy dynamic lib + logger.trace("unloading lib {}", lib_path.c_str()); + if (dynamic_lib != nullptr) { + logger.trace("closing dynamic lib ADDRESS({})", (void *)dynamic_lib); + // // IMPORTANT: weird problem the program SEGFAULT on dlclose + // // TODO: FIX somehow + // // maybe something similar is: + // // + // http://stackoverflow.com/questions/6450828/segmentation-fault-when-using-dlclose-on-android-platform + // // for now it is not crucial so I've created a task for that + // // ! 0 is success + // int closing_status = dlclose(dynamic_lib); + // if (closing_status != 0) + // throw std::runtime_error("dynamic lib closing error"); + } else { + logger.trace("unload lib was called but lib ptr is null"); } + } - /** - * Clean underlying object and close the lib - */ - ~DynamicLib() - { - // first destroy underlying object - if (lib_object != nullptr) - { - logger.trace("shared object at ADDRESS({}) will be destroyed", - (void *)lib_object); - this->destruct_method(lib_object); - } - - // then destroy dynamic lib - logger.trace("unloading lib {}", lib_path.c_str()); - if (dynamic_lib != nullptr) - { - logger.trace("closing dynamic lib ADDRESS({})", - (void *)dynamic_lib); - // // IMPORTANT: weird problem the program SEGFAULT on dlclose - // // TODO: FIX somehow - // // maybe something similar is: - // // - // http://stackoverflow.com/questions/6450828/segmentation-fault-when-using-dlclose-on-android-platform - // // for now it is not crucial so I've created a task for that - // // ! 0 is success - // int closing_status = dlclose(dynamic_lib); - // if (closing_status != 0) - // throw std::runtime_error("dynamic lib closing error"); - } - else - { - logger.trace("unload lib was called but lib ptr is null"); - } - } - -private: - std::string lib_path; - void *dynamic_lib; - typename T::ObjectPrototype *lib_object; - typename T::ProducePrototype produce_method; - typename T::DestructPrototype destruct_method; + private: + std::string lib_path; + void *dynamic_lib; + typename T::ObjectPrototype *lib_object; + typename T::ProducePrototype produce_method; + typename T::DestructPrototype destruct_method; }; diff --git a/src/utils/eq_wrapper.hpp b/src/utils/eq_wrapper.hpp index 3b802e2a0..2a30daee3 100644 --- a/src/utils/eq_wrapper.hpp +++ b/src/utils/eq_wrapper.hpp @@ -1,20 +1,17 @@ #pragma once template <class T> -class EqWrapper -{ -public: - EqWrapper(T t) : t(t) {} +class EqWrapper { + public: + EqWrapper(T t) : t(t) {} - friend bool operator==(const EqWrapper &a, const EqWrapper &b) - { - return a.t == b.t; - } + friend bool operator==(const EqWrapper &a, const EqWrapper &b) { + return a.t == b.t; + } - friend bool operator!=(const EqWrapper &a, const EqWrapper &b) - { - return !(a == b); - } + friend bool operator!=(const EqWrapper &a, const EqWrapper &b) { + return !(a == b); + } - T t; + T t; }; diff --git a/src/utils/exceptions/basic_exception.hpp b/src/utils/exceptions/basic_exception.hpp index 679391e51..130fafa62 100644 --- a/src/utils/exceptions/basic_exception.hpp +++ b/src/utils/exceptions/basic_exception.hpp @@ -7,29 +7,24 @@ #include "utils/auto_scope.hpp" #include "utils/stacktrace/stacktrace.hpp" -class BasicException : public std::exception -{ -public: - BasicException(const std::string &message) noexcept : message_(message) - { - Stacktrace stacktrace; - message_.append(stacktrace.dump()); - } +class BasicException : public std::exception { + public: + BasicException(const std::string &message) noexcept : message_(message) { + Stacktrace stacktrace; + message_.append(stacktrace.dump()); + } - template <class... Args> - BasicException(const std::string &format, Args &&... args) noexcept - : BasicException(fmt::format(format, std::forward<Args>(args)...)) - { - } + template <class... Args> + BasicException(const std::string &format, Args &&... args) noexcept + : BasicException(fmt::format(format, std::forward<Args>(args)...)) {} - template <class... Args> - BasicException(const char* format, Args &&... args) noexcept - : BasicException(fmt::format(std::string(format), std::forward<Args>(args)...)) - { - } + template <class... Args> + BasicException(const char *format, Args &&... args) noexcept + : BasicException(fmt::format(std::string(format), + std::forward<Args>(args)...)) {} - const char *what() const noexcept override { return message_.c_str(); } + const char *what() const noexcept override { return message_.c_str(); } -private: - std::string message_; + private: + std::string message_; }; diff --git a/src/utils/exceptions/non_exaustive_switch.hpp b/src/utils/exceptions/non_exaustive_switch.hpp index 96e914cde..3cd9173aa 100644 --- a/src/utils/exceptions/non_exaustive_switch.hpp +++ b/src/utils/exceptions/non_exaustive_switch.hpp @@ -2,8 +2,7 @@ #include "utils/exceptions/basic_exception.hpp" -class NonExhaustiveSwitch : public BasicException -{ -public: - using BasicException::BasicException; +class NonExhaustiveSwitch : public BasicException { + public: + using BasicException::BasicException; }; diff --git a/src/utils/exceptions/not_yet_implemented.hpp b/src/utils/exceptions/not_yet_implemented.hpp index e4854287d..696919252 100644 --- a/src/utils/exceptions/not_yet_implemented.hpp +++ b/src/utils/exceptions/not_yet_implemented.hpp @@ -2,10 +2,9 @@ #include "utils/exceptions/basic_exception.hpp" -class NotYetImplemented : public BasicException -{ -public: - using BasicException::BasicException; +class NotYetImplemented : public BasicException { + public: + using BasicException::BasicException; - NotYetImplemented() : BasicException("") {} + NotYetImplemented() : BasicException("") {} }; diff --git a/src/utils/exceptions/out_of_memory.hpp b/src/utils/exceptions/out_of_memory.hpp index 96635781b..edf04569b 100644 --- a/src/utils/exceptions/out_of_memory.hpp +++ b/src/utils/exceptions/out_of_memory.hpp @@ -2,8 +2,7 @@ #include "utils/exceptions/basic_exception.hpp" -class OutOfMemory : public BasicException -{ -public: - using BasicException::BasicException; +class OutOfMemory : public BasicException { + public: + using BasicException::BasicException; }; diff --git a/src/utils/file.hpp b/src/utils/file.hpp index 4eca1f58f..5ae9a8b9e 100644 --- a/src/utils/file.hpp +++ b/src/utils/file.hpp @@ -7,8 +7,7 @@ #include <experimental/filesystem> namespace fs = std::experimental::filesystem; -namespace utils -{ +namespace utils { /** * Loads all file paths in the specified directory. Optionally @@ -23,38 +22,35 @@ namespace utils * @return std::vector of paths founded in the directory */ inline auto LoadFilePaths(const fs::path &directory, - const std::string &extension = "") -{ - // result container - std::vector<fs::path> file_paths; + const std::string &extension = "") { + // result container + std::vector<fs::path> file_paths; - for (auto &directory_entry : fs::recursive_directory_iterator(directory)) - { + for (auto &directory_entry : fs::recursive_directory_iterator(directory)) { + auto path = directory_entry.path().string(); - auto path = directory_entry.path().string(); + // skip directories + if (!fs::is_regular_file(directory_entry)) continue; - // skip directories - if (!fs::is_regular_file(directory_entry)) continue; - - // if extension isn't defined then put all file paths from the directory - // to the result set - if (!extension.empty()) { - // skip paths that don't have appropriate extension - auto file_extension = path.substr(path.find_last_of(".") + 1); - if (file_extension != extension) continue; - } - - file_paths.emplace_back(path); - - // skip paths that don't have appropriate extension - auto file_extension = path.substr(path.find_last_of(".") + 1); - if (file_extension != extension) continue; - - // path has the right extension and can be placed in the result - // container - file_paths.emplace_back(path); + // if extension isn't defined then put all file paths from the directory + // to the result set + if (!extension.empty()) { + // skip paths that don't have appropriate extension + auto file_extension = path.substr(path.find_last_of(".") + 1); + if (file_extension != extension) continue; } - return file_paths; + file_paths.emplace_back(path); + + // skip paths that don't have appropriate extension + auto file_extension = path.substr(path.find_last_of(".") + 1); + if (file_extension != extension) continue; + + // path has the right extension and can be placed in the result + // container + file_paths.emplace_back(path); + } + + return file_paths; } } diff --git a/src/utils/fswatcher.hpp b/src/utils/fswatcher.hpp index 2815f961c..64ff1c49f 100644 --- a/src/utils/fswatcher.hpp +++ b/src/utils/fswatcher.hpp @@ -7,14 +7,14 @@ */ #pragma once -#include <atomic> -#include <chrono> #include <errno.h> #include <limits.h> -#include <mutex> #include <sys/inotify.h> -#include <thread> #include <unistd.h> +#include <atomic> +#include <chrono> +#include <mutex> +#include <thread> #include <vector> #include <experimental/filesystem> @@ -27,8 +27,7 @@ namespace fs = std::experimental::filesystem; #include "utils/linux.hpp" #include "utils/underlying_cast.hpp" -namespace utils -{ +namespace utils { using ms = std::chrono::milliseconds; @@ -46,7 +45,7 @@ using os_mask_t = int; /** * inotify buffer length (10 events) */ -using in_event_t = struct inotify_event; +using in_event_t = struct inotify_event; constexpr uint64_t IN_HEADER_SIZE = sizeof(struct inotify_event); /** * The reason why here is 10 is because the memory space for the data @@ -55,35 +54,33 @@ constexpr uint64_t IN_HEADER_SIZE = sizeof(struct inotify_event); * time. */ constexpr uint64_t IN_BUFF_SLOT_LEN = IN_HEADER_SIZE + NAME_MAX + 1; -constexpr uint64_t IN_BUFF_LEN = 10 * IN_BUFF_SLOT_LEN; +constexpr uint64_t IN_BUFF_LEN = 10 * IN_BUFF_SLOT_LEN; /** * File System Event Type - abstraction for underlying event types */ -enum class FSEventType : os_mask_t -{ - Accessed = IN_ACCESS, - MetadataChanged = IN_ATTRIB, - CloseWrite = IN_CLOSE_WRITE, - CloseNowrite = IN_CLOSE_NOWRITE, - Created = IN_CREATE, - Deleted = IN_DELETE, - DeletedSelf = IN_DELETE_SELF, - Modified = IN_MODIFY, - Renamed = IN_MOVE_SELF, - MovedFrom = IN_MOVED_FROM, - MovedTo = IN_MOVED_TO, - Close = IN_CLOSE, - Opened = IN_OPEN, - Ignored = IN_IGNORED, - All = Accessed | MetadataChanged | CloseWrite | CloseNowrite | Created | - Deleted | DeletedSelf | Modified | Renamed | MovedFrom | MovedTo | - Close | Opened | Ignored +enum class FSEventType : os_mask_t { + Accessed = IN_ACCESS, + MetadataChanged = IN_ATTRIB, + CloseWrite = IN_CLOSE_WRITE, + CloseNowrite = IN_CLOSE_NOWRITE, + Created = IN_CREATE, + Deleted = IN_DELETE, + DeletedSelf = IN_DELETE_SELF, + Modified = IN_MODIFY, + Renamed = IN_MOVE_SELF, + MovedFrom = IN_MOVED_FROM, + MovedTo = IN_MOVED_TO, + Close = IN_CLOSE, + Opened = IN_OPEN, + Ignored = IN_IGNORED, + All = Accessed | MetadataChanged | CloseWrite | CloseNowrite | Created | + Deleted | DeletedSelf | Modified | Renamed | MovedFrom | MovedTo | + Close | Opened | Ignored }; -inline FSEventType operator|(FSEventType lhs, FSEventType rhs) -{ - return (FSEventType)(underlying_cast(lhs) | underlying_cast(rhs)); +inline FSEventType operator|(FSEventType lhs, FSEventType rhs) { + return (FSEventType)(underlying_cast(lhs) | underlying_cast(rhs)); } /** @@ -95,17 +92,14 @@ inline FSEventType operator|(FSEventType lhs, FSEventType rhs) * In derived classes the type can represent a set of event types or specific * event. */ -struct FSEventBase -{ - FSEventBase(const fs::path &path, const FSEventType type) - : path(path), type(type) - { - } +struct FSEventBase { + FSEventBase(const fs::path &path, const FSEventType type) + : path(path), type(type) {} - fs::path path; - FSEventType type; + fs::path path; + FSEventType type; - operator os_mask_t() { return underlying_cast(type); } + operator os_mask_t() { return underlying_cast(type); } }; /** @@ -114,14 +108,12 @@ struct FSEventBase * The purpose of this struct is to register new watchers for specific * directory and event type. */ -struct WatchDescriptor : public FSEventBase -{ - WatchDescriptor(const fs::path &directory, const FSEventType type) - : FSEventBase(directory, type) - { - runtime_assert(fs::is_directory(path), - "The path parameter should be directory"); - } +struct WatchDescriptor : public FSEventBase { + WatchDescriptor(const fs::path &directory, const FSEventType type) + : FSEventBase(directory, type) { + runtime_assert(fs::is_directory(path), + "The path parameter should be directory"); + } }; /** @@ -130,22 +122,18 @@ struct WatchDescriptor : public FSEventBase * The purpose of this struct is to carry information about a new fs event. * In this case path is a path to the affected file and type is the event type. */ -struct FSEvent : public FSEventBase -{ - FSEvent(const fs::path &directory, const fs::path &filename, - const FSEventType type) - : FSEventBase(directory / filename, type) - { - } +struct FSEvent : public FSEventBase { + FSEvent(const fs::path &directory, const fs::path &filename, + const FSEventType type) + : FSEventBase(directory / filename, type) {} }; /** * Custom FSWatcher Exception */ -class FSWatcherException : public BasicException -{ -public: - using BasicException::BasicException; +class FSWatcherException : public BasicException { + public: + using BasicException::BasicException; }; /** @@ -159,308 +147,289 @@ public: * parameters: * * interval - time between two checks for the new file system events */ -class FSWatcher : public Loggable -{ +class FSWatcher : public Loggable { + /** + * callback type (the code that will be notified will be notified + * through callback of this type + */ + using callback_t = std::function<void(FSEvent event)>; - /** - * callback type (the code that will be notified will be notified - * through callback of this type - */ - using callback_t = std::function<void(FSEvent event)>; + public: + /** + * Initialize underlying notification system. + */ + FSWatcher(ms check_interval = ms(100)) + : Loggable("FSWatcher"), check_interval_(check_interval) { + logger.debug("Inotify header length: {}", IN_HEADER_SIZE); + logger.debug("Inotify buffer length: {}", IN_BUFF_LEN); + inotify_fd_ = inotify_init(); + if (inotify_fd_ == -1) + throw FSWatcherException("Unable to initialize inotify\n"); + linux_os::set_non_blocking(inotify_fd_); + } -public: - /** - * Initialize underlying notification system. - */ - FSWatcher(ms check_interval = ms(100)) - : Loggable("FSWatcher"), check_interval_(check_interval) - { - logger.debug("Inotify header length: {}", IN_HEADER_SIZE); - logger.debug("Inotify buffer length: {}", IN_BUFF_LEN); - inotify_fd_ = inotify_init(); - if (inotify_fd_ == -1) - throw FSWatcherException("Unable to initialize inotify\n"); - linux_os::set_non_blocking(inotify_fd_); + ~FSWatcher() { + logger.debug("destructor call"); + unwatchAll(); + } + + /* + * copy and move constructors and assignemnt operators are deleted because + * std::atomic can't be copied or moved + */ + FSWatcher(const FSWatcher &other) = delete; + FSWatcher(FSWatcher &&other) = delete; + FSWatcher &operator=(const FSWatcher &) = delete; + FSWatcher &operator=(FSWatcher &&) = delete; + + /** + * Add Watcher + */ + void watch(WatchDescriptor descriptor, callback_t callback) { + stop(); + os_wd_t wd = + inotify_add_watch(inotify_fd_, descriptor.path.c_str(), descriptor); + if (wd == -1) { + switch (errno) { + case EACCES: + throw FSWatcherException( + "Unable to add watcher. Read access " + "to the given file is not permitted."); + case EBADF: + throw FSWatcherException( + "Unable to add watcher. The given " + "file descriptor is not valid."); + case EFAULT: + throw FSWatcherException( + "Unable to add watcher. pathname " + "points outside of the process's " + "accessible address space"); + case EINVAL: + throw FSWatcherException( + "Unable to add watcher. The given event mask contains no " + "valid events; or fd is not an inotify file descriptor."); + case ENAMETOOLONG: + throw FSWatcherException( + "Unable to add watcher. pathname is too long."); + case ENOENT: + throw FSWatcherException( + "Unable to add watcher. A directory " + "component in pathname does not exist " + "or is a dangling symbolic link."); + case ENOMEM: + throw FSWatcherException( + "Unable to add watcher. Insufficient " + "kernel memory was available."); + case ENOSPC: + throw FSWatcherException( + "Unable to add watcher. The user limit on the total number " + "of inotify watches was reached or the kernel failed to " + "allocate a needed resource."); + default: + throw FSWatcherException( + "Unable to add watcher. Unknown Linux API error."); + } } - ~FSWatcher() - { - logger.debug("destructor call"); - unwatchAll(); + // update existing + auto it = std::find_if(entries_.begin(), entries_.end(), + [wd](Entry &entry) { return wd == entry.os_wd; }); + if (it != entries_.end()) { + it->descriptor = descriptor; + it->callback = callback; + } else { + entries_.emplace_back(Entry(wd, descriptor, callback)); } - /* - * copy and move constructors and assignemnt operators are deleted because - * std::atomic can't be copied or moved - */ - FSWatcher(const FSWatcher &other) = delete; - FSWatcher(FSWatcher &&other) = delete; - FSWatcher &operator=(const FSWatcher &) = delete; - FSWatcher &operator=(FSWatcher &&) = delete; + logger.debug("REGISTERED: wd({}) for path({}) and mask ({})", wd, + descriptor.path.c_str(), (os_mask_t)(descriptor)); + start(); + } - /** - * Add Watcher - */ - void watch(WatchDescriptor descriptor, callback_t callback) - { - stop(); - os_wd_t wd = - inotify_add_watch(inotify_fd_, descriptor.path.c_str(), descriptor); - if (wd == -1) - { - switch (errno) - { - case EACCES: - throw FSWatcherException("Unable to add watcher. Read access " - "to the given file is not permitted."); - case EBADF: - throw FSWatcherException("Unable to add watcher. The given " - "file descriptor is not valid."); - case EFAULT: - throw FSWatcherException("Unable to add watcher. pathname " - "points outside of the process's " - "accessible address space"); - case EINVAL: - throw FSWatcherException( - "Unable to add watcher. The given event mask contains no " - "valid events; or fd is not an inotify file descriptor."); - case ENAMETOOLONG: - throw FSWatcherException( - "Unable to add watcher. pathname is too long."); - case ENOENT: - throw FSWatcherException("Unable to add watcher. A directory " - "component in pathname does not exist " - "or is a dangling symbolic link."); - case ENOMEM: - throw FSWatcherException("Unable to add watcher. Insufficient " - "kernel memory was available."); - case ENOSPC: - throw FSWatcherException( - "Unable to add watcher. The user limit on the total number " - "of inotify watches was reached or the kernel failed to " - "allocate a needed resource."); - default: - throw FSWatcherException( - "Unable to add watcher. Unknown Linux API error."); - } + /** + * Remove subscriber on specified path and type. + * + * Time complexity: O(n) (where n is number of entries) + */ + void unwatch(WatchDescriptor descriptor) { + stop(); + + auto it = action_remove_if( + entries_.begin(), entries_.end(), + [&descriptor](Entry entry) { + auto stored_descriptor = entry.descriptor; + if (stored_descriptor.path != descriptor.path) return false; + if (stored_descriptor.type != descriptor.type) return false; + return true; + }, + [this](Entry entry) { remove_underlaying_watcher(entry); }); + + if (it != entries_.end()) entries_.erase(it); + + if (entries_.size() > 0) start(); + } + + /** + * Removes all subscribers and stops the watching process. + */ + void unwatchAll() { + stop(); + + if (entries_.size() <= 0) return; + + entries_.erase(action_remove_if( + entries_.begin(), entries_.end(), [](Entry) { return true; }, + [this](Entry &entry) { remove_underlaying_watcher(entry); })); + } + + /** + * Start the watching process. + */ + void start() { + if (is_running_.load()) return; + + is_running_.store(true); + + // run separate thread + dispatch_thread_ = std::thread([this]() { + + logger.debug("dispatch thread - start"); + + while (is_running_.load()) { + std::this_thread::sleep_for(check_interval_); + + // read file descriptor and process new events + // the read call should be non blocking otherwise + // this thread can easily be blocked forever + auto n = ::read(inotify_fd_, buffer_, IN_BUFF_LEN); + if (n == 0) throw FSWatcherException("read() -> 0."); + if (n == -1) continue; + + logger.info("Read {} bytes from inotify fd", (long)n); + + // process all of the events in buffer returned by read() + for (auto p = buffer_; p < buffer_ + n;) { + // get in_event + auto in_event = reinterpret_cast<in_event_t *>(p); + auto in_event_length = IN_HEADER_SIZE + in_event->len; + + // sometimes inotify system returns event->len that is + // longer then the length of the buffer + // TODO: figure out why (it is not easy) + if (((p - buffer_) + in_event_length) > IN_BUFF_LEN) break; + // here should be an assertion + // runtime_assert(in_event_length <= IN_BUFF_SLOT_LEN, + // "Inotify event length cannot be bigger + // than " + // "Inotify slot length"); + + // skip if in_event is undefined OR is equal to IN_IGNORED + if ((in_event->len == 0 && in_event->mask == 0) || + in_event->mask == IN_IGNORED || + in_event_length == IN_HEADER_SIZE) // skip empty paths + { + p += in_event_length; + continue; + } + + logger.info("LEN: {}, MASK: {}, NAME: {}", in_event_length, + in_event->mask, in_event->name); + + // find our watch descriptor + auto entry = find_if( + entries_.begin(), entries_.end(), + [in_event](Entry &entry) { return entry.os_wd == in_event->wd; }); + auto &descriptor = entry->descriptor; + + // call user's callback + entry->callback(FSEvent(descriptor.path, fs::path(in_event->name), + static_cast<FSEventType>(in_event->mask))); + + // move on + p += in_event_length; } + } - // update existing - auto it = - std::find_if(entries_.begin(), entries_.end(), - [wd](Entry &entry) { return wd == entry.os_wd; }); - if (it != entries_.end()) - { - it->descriptor = descriptor; - it->callback = callback; - } - else - { - entries_.emplace_back(Entry(wd, descriptor, callback)); - } + logger.debug("dispatch thread - finish"); + }); + } - logger.debug("REGISTERED: wd({}) for path({}) and mask ({})", wd, - descriptor.path.c_str(), (os_mask_t)(descriptor)); - start(); + /** + * Stop the watching process. + */ + void stop() { + if (is_running_.load()) { + is_running_.store(false); + dispatch_thread_.join(); } + } - /** - * Remove subscriber on specified path and type. - * - * Time complexity: O(n) (where n is number of entries) - */ - void unwatch(WatchDescriptor descriptor) - { - stop(); + /** + * @return check interval - time between two underlaying check calls + */ + ms check_interval() const { return check_interval_; } - auto it = action_remove_if( - entries_.begin(), entries_.end(), - [&descriptor](Entry entry) { - auto stored_descriptor = entry.descriptor; - if (stored_descriptor.path != descriptor.path) return false; - if (stored_descriptor.type != descriptor.type) return false; - return true; - }, - [this](Entry entry) { remove_underlaying_watcher(entry); }); + /** + * @return number of entries + */ + size_t size() const { return entries_.size(); } - if (it != entries_.end()) entries_.erase(it); + private: + /** + * Internal storage for all subscribers. + * + * <os watch descriptor, API watch descriptor, callback> + */ + struct Entry { + Entry(os_wd_t os_wd, WatchDescriptor descriptor, callback_t callback) + : os_wd(os_wd), descriptor(descriptor), callback(callback) {} - if (entries_.size() > 0) start(); - } + os_wd_t os_wd; + WatchDescriptor descriptor; + callback_t callback; + }; - /** - * Removes all subscribers and stops the watching process. - */ - void unwatchAll() - { - stop(); + /** + * Removes the os specific watch descriptor. + */ + void remove_underlaying_watcher(Entry entry) { + auto status = inotify_rm_watch(inotify_fd_, entry.os_wd); + if (status == -1) + throw FSWatcherException("Unable to remove underlaying watch."); + else + logger.info("UNREGISTER: fd({}), wd({}), status({})", inotify_fd_, + entry.os_wd, status); + } - if (entries_.size() <= 0) return; + /** + * inotify file descriptor + */ + int inotify_fd_; - entries_.erase(action_remove_if( - entries_.begin(), entries_.end(), [](Entry) { return true; }, - [this](Entry &entry) { remove_underlaying_watcher(entry); })); - } + /** + * running flag, has to be atomic because two threads can update and read + * the value + */ + std::atomic<bool> is_running_; - /** - * Start the watching process. - */ - void start() - { - if (is_running_.load()) return; + /** + * interval between the end of events processing and next start of + * processing + */ + ms check_interval_; - is_running_.store(true); + /** + */ + std::vector<Entry> entries_; - // run separate thread - dispatch_thread_ = std::thread([this]() { + /** + * thread for events processing + */ + std::thread dispatch_thread_; - logger.debug("dispatch thread - start"); - - while (is_running_.load()) - { - std::this_thread::sleep_for(check_interval_); - - // read file descriptor and process new events - // the read call should be non blocking otherwise - // this thread can easily be blocked forever - auto n = ::read(inotify_fd_, buffer_, IN_BUFF_LEN); - if (n == 0) throw FSWatcherException("read() -> 0."); - if (n == -1) continue; - - logger.info("Read {} bytes from inotify fd", (long)n); - - // process all of the events in buffer returned by read() - for (auto p = buffer_; p < buffer_ + n;) - { - // get in_event - auto in_event = reinterpret_cast<in_event_t *>(p); - auto in_event_length = IN_HEADER_SIZE + in_event->len; - - // sometimes inotify system returns event->len that is - // longer then the length of the buffer - // TODO: figure out why (it is not easy) - if (((p - buffer_) + in_event_length) > IN_BUFF_LEN) break; - // here should be an assertion - // runtime_assert(in_event_length <= IN_BUFF_SLOT_LEN, - // "Inotify event length cannot be bigger - // than " - // "Inotify slot length"); - - // skip if in_event is undefined OR is equal to IN_IGNORED - if ((in_event->len == 0 && in_event->mask == 0) || - in_event->mask == IN_IGNORED || - in_event_length == IN_HEADER_SIZE) // skip empty paths - { - p += in_event_length; - continue; - } - - logger.info("LEN: {}, MASK: {}, NAME: {}", in_event_length, - in_event->mask, in_event->name); - - // find our watch descriptor - auto entry = find_if(entries_.begin(), entries_.end(), - [in_event](Entry &entry) { - return entry.os_wd == in_event->wd; - }); - auto &descriptor = entry->descriptor; - - // call user's callback - entry->callback( - FSEvent(descriptor.path, fs::path(in_event->name), - static_cast<FSEventType>(in_event->mask))); - - // move on - p += in_event_length; - } - } - - logger.debug("dispatch thread - finish"); - }); - } - - /** - * Stop the watching process. - */ - void stop() - { - if (is_running_.load()) - { - is_running_.store(false); - dispatch_thread_.join(); - } - } - - /** - * @return check interval - time between two underlaying check calls - */ - ms check_interval() const { return check_interval_; } - - /** - * @return number of entries - */ - size_t size() const { return entries_.size(); } - -private: - /** - * Internal storage for all subscribers. - * - * <os watch descriptor, API watch descriptor, callback> - */ - struct Entry - { - Entry(os_wd_t os_wd, WatchDescriptor descriptor, callback_t callback) - : os_wd(os_wd), descriptor(descriptor), callback(callback) - { - } - - os_wd_t os_wd; - WatchDescriptor descriptor; - callback_t callback; - }; - - /** - * Removes the os specific watch descriptor. - */ - void remove_underlaying_watcher(Entry entry) - { - auto status = inotify_rm_watch(inotify_fd_, entry.os_wd); - if (status == -1) - throw FSWatcherException("Unable to remove underlaying watch."); - else - logger.info("UNREGISTER: fd({}), wd({}), status({})", inotify_fd_, - entry.os_wd, status); - } - - /** - * inotify file descriptor - */ - int inotify_fd_; - - /** - * running flag, has to be atomic because two threads can update and read - * the value - */ - std::atomic<bool> is_running_; - - /** - * interval between the end of events processing and next start of - * processing - */ - ms check_interval_; - - /** - */ - std::vector<Entry> entries_; - - /** - * thread for events processing - */ - std::thread dispatch_thread_; - - /** - * buffer for underlying events (inotify dependent) - */ - char *buffer_[IN_BUFF_LEN]; + /** + * buffer for underlying events (inotify dependent) + */ + char *buffer_[IN_BUFF_LEN]; }; } diff --git a/src/utils/handle_write.hpp b/src/utils/handle_write.hpp index f815df959..779e4aa8d 100644 --- a/src/utils/handle_write.hpp +++ b/src/utils/handle_write.hpp @@ -7,10 +7,9 @@ * Writer object defines write format. */ template <typename Destination, typename Writer, typename Source> -Destination handle_write(const Source& source) -{ - Destination destination; - Writer writter(destination); - source.handle(writter); - return destination; +Destination handle_write(const Source& source) { + Destination destination; + Writer writter(destination); + source.handle(writter); + return destination; } diff --git a/src/utils/hashing/fnv.hpp b/src/utils/hashing/fnv.hpp index dd46682c0..49561dbd7 100644 --- a/src/utils/hashing/fnv.hpp +++ b/src/utils/hashing/fnv.hpp @@ -11,15 +11,13 @@ // fnv1a is recommended so use it as a default implementation. also use the // platform specific version of the function -namespace -{ +namespace { #ifdef MEMGRAPH64 template <class T> -uint64_t fnv(const T& data) -{ - return fnv1a64<T>(data); +uint64_t fnv(const T& data) { + return fnv1a64<T>(data); } using HashType = uint64_t; @@ -27,13 +25,11 @@ using HashType = uint64_t; #elif template <class T> -uint32_t fnv(const T& data) -{ - return fnv1a32<T>(data); +uint32_t fnv(const T& data) { + return fnv1a32<T>(data); } using HashType = uint32_t; #endif - } diff --git a/src/utils/hashing/fnv32.hpp b/src/utils/hashing/fnv32.hpp index 784861a16..316f2eb78 100644 --- a/src/utils/hashing/fnv32.hpp +++ b/src/utils/hashing/fnv32.hpp @@ -3,52 +3,46 @@ #include <cstdlib> #include <string> -namespace -{ +namespace { #define OFFSET_BASIS32 2166136261u #define FNV_PRIME32 16777619u -uint32_t fnv32(const unsigned char* const data, size_t n) -{ - uint32_t hash = OFFSET_BASIS32; +uint32_t fnv32(const unsigned char* const data, size_t n) { + uint32_t hash = OFFSET_BASIS32; - for(size_t i = 0; i < n; ++i) - hash = (hash * FNV_PRIME32) xor (uint32_t)data[i]; + for (size_t i = 0; i < n; ++i) + hash = (hash * FNV_PRIME32) xor (uint32_t) data[i]; - return hash; + return hash; } template <class T> -uint32_t fnv32(const T& data) -{ - return fnv32(&data, sizeof(data)); +uint32_t fnv32(const T& data) { + return fnv32(&data, sizeof(data)); } -template<> uint32_t fnv32(const std::string& data) -{ - return fnv32((const unsigned char*)data.c_str(), data.size()); +template <> +uint32_t fnv32(const std::string& data) { + return fnv32((const unsigned char*)data.c_str(), data.size()); } -uint32_t fnv1a32(const unsigned char* const data, size_t n) -{ - uint32_t hash = OFFSET_BASIS32; +uint32_t fnv1a32(const unsigned char* const data, size_t n) { + uint32_t hash = OFFSET_BASIS32; - for(size_t i = 0; i < n; ++i) - hash = (hash xor (uint32_t)data[i]) * FNV_PRIME32; + for (size_t i = 0; i < n; ++i) + hash = (hash xor (uint32_t) data[i]) * FNV_PRIME32; - return hash; + return hash; } template <class T> -uint32_t fnv1a32(const T& data) -{ - return fnv1a32(&data, sizeof(data)); +uint32_t fnv1a32(const T& data) { + return fnv1a32(&data, sizeof(data)); } -template<> uint32_t fnv1a32(const std::string& data) -{ - return fnv1a32((const unsigned char*)data.c_str(), data.size()); +template <> +uint32_t fnv1a32(const std::string& data) { + return fnv1a32((const unsigned char*)data.c_str(), data.size()); } - } diff --git a/src/utils/hashing/fnv64.hpp b/src/utils/hashing/fnv64.hpp index ea741b956..8004c3ee2 100644 --- a/src/utils/hashing/fnv64.hpp +++ b/src/utils/hashing/fnv64.hpp @@ -3,52 +3,46 @@ #include <cstdlib> #include <string> -namespace -{ +namespace { #define OFFSET_BASIS64 14695981039346656037u #define FNV_PRIME64 1099511628211u -uint64_t fnv64(const unsigned char* const data, size_t n) -{ - uint64_t hash = OFFSET_BASIS64; +uint64_t fnv64(const unsigned char* const data, size_t n) { + uint64_t hash = OFFSET_BASIS64; - for(size_t i = 0; i < n; ++i) - hash = (hash * FNV_PRIME64) xor (uint64_t)data[i]; + for (size_t i = 0; i < n; ++i) + hash = (hash * FNV_PRIME64) xor (uint64_t) data[i]; - return hash; + return hash; } template <class T> -uint64_t fnv64(const T& data) -{ - return fnv64(&data, sizeof(data)); +uint64_t fnv64(const T& data) { + return fnv64(&data, sizeof(data)); } -template<> uint64_t fnv64(const std::string& data) -{ - return fnv64((const unsigned char*)data.c_str(), data.size()); +template <> +uint64_t fnv64(const std::string& data) { + return fnv64((const unsigned char*)data.c_str(), data.size()); } -uint64_t fnv1a64(const unsigned char* const data, size_t n) -{ - uint64_t hash = OFFSET_BASIS64; +uint64_t fnv1a64(const unsigned char* const data, size_t n) { + uint64_t hash = OFFSET_BASIS64; - for(size_t i = 0; i < n; ++i) - hash = (hash xor (uint64_t)data[i]) * FNV_PRIME64; + for (size_t i = 0; i < n; ++i) + hash = (hash xor (uint64_t) data[i]) * FNV_PRIME64; - return hash; + return hash; } template <class T> -uint64_t fnv1a64(const T& data) -{ - return fnv1a64(&data, sizeof(data)); +uint64_t fnv1a64(const T& data) { + return fnv1a64(&data, sizeof(data)); } -template<> uint64_t fnv1a64(const std::string& data) -{ - return fnv1a64((const unsigned char*)data.c_str(), data.size()); +template <> +uint64_t fnv1a64(const std::string& data) { + return fnv1a64((const unsigned char*)data.c_str(), data.size()); } - } diff --git a/src/utils/ioc/container.hpp b/src/utils/ioc/container.hpp index a486b8bb0..20634ecf7 100644 --- a/src/utils/ioc/container.hpp +++ b/src/utils/ioc/container.hpp @@ -1,97 +1,81 @@ #pragma once #include <cassert> +#include <map> #include <memory> #include <vector> -#include <map> -namespace ioc -{ +namespace ioc { -class Container -{ - struct Holdable - { - using uptr = std::unique_ptr<Holdable>; +class Container { + struct Holdable { + using uptr = std::unique_ptr<Holdable>; - Holdable() = default; - virtual ~Holdable() = default; - }; + Holdable() = default; + virtual ~Holdable() = default; + }; - template <class T> - struct Item : public Holdable - { - virtual std::shared_ptr<T> get() = 0; - }; + template <class T> + struct Item : public Holdable { + virtual std::shared_ptr<T> get() = 0; + }; - template <class T> - struct Instance : public Item<T> - { - Instance(std::shared_ptr<T> item) : item(std::move(item)) {} - Instance(std::shared_ptr<T>&& item) : item(item) {} + template <class T> + struct Instance : public Item<T> { + Instance(std::shared_ptr<T> item) : item(std::move(item)) {} + Instance(std::shared_ptr<T>&& item) : item(item) {} - std::shared_ptr<T> get() override - { - assert(item != nullptr); - return item; - } - - std::shared_ptr<T> item; - }; - - template <class T> - struct Creator : public Item<T> - { - using func = std::function<std::shared_ptr<T>()>; - - Creator(func&& f) : f(f) {} - - std::shared_ptr<T> get() override - { - return f(); - } - - func f; - }; - -public: - template <class T> - std::shared_ptr<T> resolve() - { - auto it = items.find(key<T>()); - assert(it != items.end()); - - // try to cast Holdable* to Item<T>* - auto item = dynamic_cast<Item<T>*>(it->second.get()); - assert(item != nullptr); - - return item->get(); + std::shared_ptr<T> get() override { + assert(item != nullptr); + return item; } - template <class T, class... Deps, class... Args> - std::shared_ptr<T> singleton(Args&&... args) - { - auto item = std::make_shared<T>(resolve<Deps>()..., args...); - items.emplace(key<T>(), Holdable::uptr(new Instance<T>(item))); - return item; - } + std::shared_ptr<T> item; + }; - template <class T> - void factory(typename Creator<T>::func&& f) - { - items[key<T>()] = std::move(Holdable::uptr( - new Creator<T>(std::forward<typename Creator<T>::func>(f)) - )); - } + template <class T> + struct Creator : public Item<T> { + using func = std::function<std::shared_ptr<T>()>; -private: - std::map<std::string, Holdable::uptr> items; + Creator(func&& f) : f(f) {} - template <class T> - std::string key() - { - return typeid(T).name(); - } + std::shared_ptr<T> get() override { return f(); } + + func f; + }; + + public: + template <class T> + std::shared_ptr<T> resolve() { + auto it = items.find(key<T>()); + assert(it != items.end()); + + // try to cast Holdable* to Item<T>* + auto item = dynamic_cast<Item<T>*>(it->second.get()); + assert(item != nullptr); + + return item->get(); + } + + template <class T, class... Deps, class... Args> + std::shared_ptr<T> singleton(Args&&... args) { + auto item = std::make_shared<T>(resolve<Deps>()..., args...); + items.emplace(key<T>(), Holdable::uptr(new Instance<T>(item))); + return item; + } + + template <class T> + void factory(typename Creator<T>::func&& f) { + items[key<T>()] = std::move(Holdable::uptr( + new Creator<T>(std::forward<typename Creator<T>::func>(f)))); + } + + private: + std::map<std::string, Holdable::uptr> items; + + template <class T> + std::string key() { + return typeid(T).name(); + } }; - } diff --git a/src/utils/iterator/accessor.hpp b/src/utils/iterator/accessor.hpp index 55dbddcc9..a77b94aad 100644 --- a/src/utils/iterator/accessor.hpp +++ b/src/utils/iterator/accessor.hpp @@ -3,33 +3,30 @@ #include "utils/iterator/range_iterator.hpp" #include "utils/option.hpp" -namespace iter -{ +namespace iter { // Class which turns ranged iterator with next() into accessor. // T - type of return value // I - iterator type template <class T, class I> -class OneTimeAccessor -{ -public: - OneTimeAccessor() : it(Option<RangeIterator<T, I>>()) {} - OneTimeAccessor(I &&it) : it(RangeIterator<T, I>(std::move(it))) {} +class OneTimeAccessor { + public: + OneTimeAccessor() : it(Option<RangeIterator<T, I>>()) {} + OneTimeAccessor(I &&it) : it(RangeIterator<T, I>(std::move(it))) {} - RangeIterator<T, I> begin() { return it.take(); } + RangeIterator<T, I> begin() { return it.take(); } - RangeIterator<T, I> end() { return RangeIterator<T, I>(); } + RangeIterator<T, I> end() { return RangeIterator<T, I>(); } -private: - Option<RangeIterator<T, I>> it; + private: + Option<RangeIterator<T, I>> it; }; template <class I> -auto make_one_time_accessor(I &&iter) -{ - // Because function isn't receving or in any way using type T from - // OneTimeAccessor compiler can't deduce it thats way there is decltype in - // construction of OneTimeAccessor. Resoulting type of iter.next().take() is - // T. - return OneTimeAccessor<decltype(iter.next().take()), I>(std::move(iter)); +auto make_one_time_accessor(I &&iter) { + // Because function isn't receving or in any way using type T from + // OneTimeAccessor compiler can't deduce it thats way there is decltype in + // construction of OneTimeAccessor. Resoulting type of iter.next().take() is + // T. + return OneTimeAccessor<decltype(iter.next().take()), I>(std::move(iter)); } } diff --git a/src/utils/iterator/combined.hpp b/src/utils/iterator/combined.hpp index a9b2a6355..bdf5cff90 100644 --- a/src/utils/iterator/combined.hpp +++ b/src/utils/iterator/combined.hpp @@ -3,8 +3,7 @@ #include "utils/iterator/composable.hpp" #include "utils/iterator/iterator_base.hpp" -namespace iter -{ +namespace iter { // Class which Combined two iterators IT1 and IT2. // Both return values T @@ -13,52 +12,44 @@ namespace iter // IT2 - second iterator type template <class T, class IT1, class IT2> class Combined : public IteratorBase<T>, - public Composable<T, Combined<T, IT1, IT2>> -{ + public Composable<T, Combined<T, IT1, IT2>> { + public: + Combined() = delete; -public: - Combined() = delete; + // Combined operation is designed to be used in chained calls which operate + // on a iterator. Combined will in that usecase receive other iterator by + // value and std::move is a optimization for it. + Combined(IT1 &&iter1, IT2 &&iter2) + : iter1(Option<IT1>(std::move(iter1))), + iter2(Option<IT2>(std::move(iter2))) {} - // Combined operation is designed to be used in chained calls which operate - // on a iterator. Combined will in that usecase receive other iterator by - // value and std::move is a optimization for it. - Combined(IT1 &&iter1, IT2 &&iter2) - : iter1(Option<IT1>(std::move(iter1))), - iter2(Option<IT2>(std::move(iter2))) - { + // Return values first from first iterator then from second. + Option<T> next() final { + if (iter1.is_present()) { + auto ret = iter1.get().next(); + if (ret.is_present()) { + return std::move(ret); + } else { + iter1.take(); + } } - // Return values first from first iterator then from second. - Option<T> next() final - { - if (iter1.is_present()) { - auto ret = iter1.get().next(); - if (ret.is_present()) { - return std::move(ret); - } else { - iter1.take(); - } - } + return iter2.next(); + } - return iter2.next(); - } + Count count() final { + return iter1.map_or([](auto &it) { return it.count(); }, 0) + iter2.count(); + } - Count count() final - { - return iter1.map_or([](auto &it) { return it.count(); }, 0) + - iter2.count(); - } - -private: - Option<IT1> iter1; - IT2 iter2; + private: + Option<IT1> iter1; + IT2 iter2; }; template <class IT1, class IT2> -auto make_combined(IT1 &&iter1, IT2 &&iter2) -{ - // Compiler cant deduce type T. decltype is here to help with it. - return Combined<decltype(iter1.next().take()), IT1, IT2>(std::move(iter1), - std::move(iter2)); +auto make_combined(IT1 &&iter1, IT2 &&iter2) { + // Compiler cant deduce type T. decltype is here to help with it. + return Combined<decltype(iter1.next().take()), IT1, IT2>(std::move(iter1), + std::move(iter2)); } } diff --git a/src/utils/iterator/composable.hpp b/src/utils/iterator/composable.hpp index b1a1aac74..d5e82724a 100644 --- a/src/utils/iterator/composable.hpp +++ b/src/utils/iterator/composable.hpp @@ -4,8 +4,7 @@ #include "utils/iterator/count.hpp" #include "utils/option.hpp" -namespace iter -{ +namespace iter { template <class I, class OP> auto make_map(I &&iter, OP &&op); @@ -36,181 +35,156 @@ auto make_combined(IT1 &&iter1, IT2 &&iter2); // Derived - type of derived class // T - return type template <class T, class Derived> -class Composable : public Crtp<Derived> -{ - // Moves self - Derived &&move() { return std::move(this->derived()); } +class Composable : public Crtp<Derived> { + // Moves self + Derived &&move() { return std::move(this->derived()); } -public: - auto virtualize() { return iter::make_virtual(move()); } + public: + auto virtualize() { return iter::make_virtual(move()); } - template <class IT> - auto combine(IT &&it) - { - return iter::make_combined<Derived, IT>(move(), std::move(it)); + template <class IT> + auto combine(IT &&it) { + return iter::make_combined<Derived, IT>(move(), std::move(it)); + } + + template <class OP> + auto map(OP &&op) { + return iter::make_map<Derived, OP>(move(), std::move(op)); + } + + template <class OP> + auto filter(OP &&op) { + return iter::make_filter<Derived, OP>(move(), std::move(op)); + } + + // Replaces every item with item taken from n if it exists. + template <class R> + auto replace(Option<R> &n) { + return iter::make_limited_map<Derived>( + move(), [&](auto v) mutable { return std::move(n); }); + } + + // For all items calls OP. + template <class OP> + void for_all(OP &&op) { + iter::for_all(move(), std::move(op)); + } + + // All items must satisfy given predicate for this function to return true. + // Otherwise stops calling predicate on firts false and returns fasle. + template <class OP> + bool all(OP &&op) { + auto iter = move(); + auto e = iter.next(); + while (e.is_present()) { + if (!op(e.take())) { + return false; + } + e = iter.next(); } + return true; + } - template <class OP> - auto map(OP &&op) - { - return iter::make_map<Derived, OP>(move(), std::move(op)); - } + // !! MEMGRAPH specific composable filters + // TODO: isolate, but it is not trivial because this class + // is a base for other generic classes - template <class OP> - auto filter(OP &&op) - { - return iter::make_filter<Derived, OP>(move(), std::move(op)); - } + // Maps with call to method to() and filters with call to fill. + auto to() { + return map([](auto er) { return er.to(); }).fill(); + } - // Replaces every item with item taken from n if it exists. - template <class R> - auto replace(Option<R> &n) - { - return iter::make_limited_map<Derived>( - move(), [&](auto v) mutable { return std::move(n); }); - } + // Maps with call to method from() and filters with call to fill. + auto from() { + return map([](auto er) { return er.from(); }).fill(); + } - // For all items calls OP. - template <class OP> - void for_all(OP &&op) - { - iter::for_all(move(), std::move(op)); - } + // Combines out iterators into one iterator. + auto out() { + return iter::make_flat_map<Derived>( + move(), [](auto vr) { return vr.out().fill(); }); + } - // All items must satisfy given predicate for this function to return true. - // Otherwise stops calling predicate on firts false and returns fasle. - template <class OP> - bool all(OP &&op) - { - auto iter = move(); - auto e = iter.next(); - while (e.is_present()) { - if (!op(e.take())) { - return false; - } - e = iter.next(); - } - return true; - } + auto in() { + return iter::make_flat_map<Derived>(move(), + [](auto vr) { return vr.in().fill(); }); + } - // !! MEMGRAPH specific composable filters - // TODO: isolate, but it is not trivial because this class - // is a base for other generic classes + // Filters with label on from vertex. + template <class LABEL> + auto from_label(LABEL const &label) { + return filter([&](auto &ra) { + auto va = ra.from(); + return va.fill() && va.has_label(label); + }); + } - // Maps with call to method to() and filters with call to fill. - auto to() - { - return map([](auto er) { return er.to(); }).fill(); - } + // Calls update on values and returns result. + auto update() { + return map([](auto ar) { return ar.update(); }); + } - // Maps with call to method from() and filters with call to fill. - auto from() - { - return map([](auto er) { return er.from(); }).fill(); - } + // Filters with property under given key + template <class KEY> + auto has_property(KEY &key) { + return filter([&](auto &va) { return !va.at(key).is_empty(); }); + } - // Combines out iterators into one iterator. - auto out() - { - return iter::make_flat_map<Derived>( - move(), [](auto vr) { return vr.out().fill(); }); - } + // Filters with property under given key + template <class KEY, class PROP> + auto has_property(KEY &key, PROP const &prop) { + return filter([&](auto &va) { return va.at(key) == prop; }); + } - auto in() - { - return iter::make_flat_map<Derived>( - move(), [](auto vr) { return vr.in().fill(); }); - } + // Copy-s pasing value to t before they are returned. + auto clone_to(Option<const T> &t) { + return iter::make_inspect<Derived>( + move(), [&](auto &v) mutable { t = Option<const T>(v); }); + } - // Filters with label on from vertex. - template <class LABEL> - auto from_label(LABEL const &label) - { - return filter([&](auto &ra) { - auto va = ra.from(); - return va.fill() && va.has_label(label); - }); - } + // auto clone_to(Option<T> &t) + // { + // return iter::make_inspect<Derived>( + // move(), [&](auto &e) mutable { t = Option<T>(e); }); + // } - // Calls update on values and returns result. - auto update() - { - return map([](auto ar) { return ar.update(); }); - } + // Filters with call to method fill() + auto fill() { + return filter([](auto &ra) { return ra.fill(); }); + } - // Filters with property under given key - template <class KEY> - auto has_property(KEY &key) - { - return filter([&](auto &va) { return !va.at(key).is_empty(); }); - } + // Filters with type + template <class TYPE> + auto type(TYPE const &type) { + return filter([&](auto &ra) { return ra.edge_type() == type; }); + } - // Filters with property under given key - template <class KEY, class PROP> - auto has_property(KEY &key, PROP const &prop) - { - return filter([&](auto &va) { return va.at(key) == prop; }); - } + // Filters with label. + template <class LABEL> + auto label(LABEL const &label) { + return filter([&](auto &va) { return va.has_label(label); }); + } - // Copy-s pasing value to t before they are returned. - auto clone_to(Option<const T> &t) - { - return iter::make_inspect<Derived>( - move(), [&](auto &v) mutable { t = Option<const T>(v); }); - } + // Filters out vertices which are connected. + auto isolated() { + return filter([&](auto &element) { return element.isolated(); }); + } - // auto clone_to(Option<T> &t) - // { - // return iter::make_inspect<Derived>( - // move(), [&](auto &e) mutable { t = Option<T>(e); }); - // } - - // Filters with call to method fill() - auto fill() - { - return filter([](auto &ra) { return ra.fill(); }); - } - - // Filters with type - template <class TYPE> - auto type(TYPE const &type) - { - return filter([&](auto &ra) { return ra.edge_type() == type; }); - } - - // Filters with label. - template <class LABEL> - auto label(LABEL const &label) - { - return filter([&](auto &va) { return va.has_label(label); }); - } - - // Filters out vertices which are connected. - auto isolated() - { - return filter([&](auto &element) { return element.isolated(); }); - } - - // filter elements based on properties (all properties have to match) - // TRANSACTION -> transaction - // PROPERTIES -> [(name, property)] - template <class TRANSACTION, class PROPERTIES> - auto properties_filter(TRANSACTION &t, PROPERTIES& properties) - { - return filter([&](auto &element) { - for (auto &name_value : properties) { - auto property_key = t.vertex_property_key( - name_value.first, - name_value.second.key.flags()); - if (!element.properties().contains(property_key)) - return false; - auto vertex_property_value = element.at(property_key); - if (!(vertex_property_value == name_value.second)) - return false; - } - return true; - }); - } + // filter elements based on properties (all properties have to match) + // TRANSACTION -> transaction + // PROPERTIES -> [(name, property)] + template <class TRANSACTION, class PROPERTIES> + auto properties_filter(TRANSACTION &t, PROPERTIES &properties) { + return filter([&](auto &element) { + for (auto &name_value : properties) { + auto property_key = t.vertex_property_key( + name_value.first, name_value.second.key.flags()); + if (!element.properties().contains(property_key)) return false; + auto vertex_property_value = element.at(property_key); + if (!(vertex_property_value == name_value.second)) return false; + } + return true; + }); + } }; - } diff --git a/src/utils/iterator/count.hpp b/src/utils/iterator/count.hpp index 60c5c65eb..ab9ff83d5 100644 --- a/src/utils/iterator/count.hpp +++ b/src/utils/iterator/count.hpp @@ -6,34 +6,29 @@ // Represents number of to be returned elements from iterator. Where acutal // number is probably somwhere in [min,max]. // NOTE: Experimental -class Count : public TotalOrdering<Count> -{ +class Count : public TotalOrdering<Count> { + public: + Count(size_t exact) : min(exact), max(exact) {} -public: - Count(size_t exact) : min(exact), max(exact) {} + Count(size_t min, size_t max) : min(min), max(max) {} - Count(size_t min, size_t max) : min(min), max(max) {} + Count min_zero() const { return Count(0, max); } - Count min_zero() const { return Count(0, max); } + size_t avg() const { return ((max - min) >> 1) + min; } - size_t avg() const { return ((max - min) >> 1) + min; } + friend constexpr bool operator<(const Count &lhs, const Count &rhs) { + return lhs.avg() < rhs.avg(); + } - friend constexpr bool operator<(const Count &lhs, const Count &rhs) - { - return lhs.avg() < rhs.avg(); - } + friend constexpr bool operator==(const Count &lhs, const Count &rhs) { + return lhs.avg() == rhs.avg(); + } - friend constexpr bool operator==(const Count &lhs, const Count &rhs) - { - return lhs.avg() == rhs.avg(); - } + friend Count operator+(const Count &lhs, const Count &rhs) { + return Count(num::saturating_add(lhs.min, rhs.min), + num::saturating_add(lhs.max, rhs.max)); + } - friend Count operator+(const Count &lhs, const Count &rhs) - { - return Count(num::saturating_add(lhs.min, rhs.min), - num::saturating_add(lhs.max, rhs.max)); - } - - size_t min; - size_t max; + size_t min; + size_t max; }; diff --git a/src/utils/iterator/filter.hpp b/src/utils/iterator/filter.hpp index 2c87bbf46..f71062c0b 100644 --- a/src/utils/iterator/filter.hpp +++ b/src/utils/iterator/filter.hpp @@ -3,8 +3,7 @@ #include "utils/iterator/composable.hpp" #include "utils/iterator/iterator_base.hpp" -namespace iter -{ +namespace iter { // Class which filters values T returned by I iterator if OP returns true for // them. @@ -12,44 +11,40 @@ namespace iter // I - iterator type // OP - type of filter function. OP: T& -> bool template <class T, class I, class OP> -class Filter : public IteratorBase<T>, public Composable<T, Filter<T, I, OP>> -{ +class Filter : public IteratorBase<T>, public Composable<T, Filter<T, I, OP>> { + public: + Filter() = delete; -public: - Filter() = delete; + // Filter operation is designed to be used in chained calls which operate on + // a + // iterator. Filter will in that usecase receive other iterator by value and + // std::move is a optimization for it. + Filter(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {} - // Filter operation is designed to be used in chained calls which operate on - // a - // iterator. Filter will in that usecase receive other iterator by value and - // std::move is a optimization for it. - Filter(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {} + // Return values for which filter return true. + Option<T> next() final { + auto item = Option<T>(); + do { + item = iter.next(); + if (!item.is_present()) { + return Option<T>(); + } + } while (!op(item.get())); - // Return values for which filter return true. - Option<T> next() final - { - auto item = Option<T>(); - do { - item = iter.next(); - if (!item.is_present()) { - return Option<T>(); - } - } while (!op(item.get())); + return std::move(item); + } - return std::move(item); - } + Count count() final { return iter.count().min_zero(); } - Count count() final { return iter.count().min_zero(); } - -private: - I iter; - OP op; + private: + I iter; + OP op; }; template <class I, class OP> -auto make_filter(I &&iter, OP &&op) -{ - // Compiler cant deduce type T. decltype is here to help with it. - return Filter<decltype(iter.next().take()), I, OP>(std::move(iter), - std::move(op)); +auto make_filter(I &&iter, OP &&op) { + // Compiler cant deduce type T. decltype is here to help with it. + return Filter<decltype(iter.next().take()), I, OP>(std::move(iter), + std::move(op)); } } diff --git a/src/utils/iterator/flat_map.hpp b/src/utils/iterator/flat_map.hpp index ca5ab98ce..58760ca09 100644 --- a/src/utils/iterator/flat_map.hpp +++ b/src/utils/iterator/flat_map.hpp @@ -3,8 +3,7 @@ #include "utils/iterator/composable.hpp" #include "utils/iterator/iterator_base.hpp" -namespace iter -{ +namespace iter { // Class which maps values returned by I iterator into iterators of type J // ,which @@ -17,66 +16,60 @@ namespace iter // TODO: Split into flat operation and map operation. template <class T, class I, class J, class OP> class FlatMap : public IteratorBase<T>, - public Composable<T, FlatMap<T, I, J, OP>> -{ + public Composable<T, FlatMap<T, I, J, OP>> { + public: + FlatMap() = delete; -public: - FlatMap() = delete; + // FlatMap operation is designed to be used in chained calls which operate + // on a + // iterator. FlatMap will in that usecase receive other iterator by value + // and + // std::move is a optimization for it. + FlatMap(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {} - // FlatMap operation is designed to be used in chained calls which operate - // on a - // iterator. FlatMap will in that usecase receive other iterator by value - // and - // std::move is a optimization for it. - FlatMap(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {} + FlatMap(FlatMap &&m) + : iter(std::move(m.iter)), + op(std::move(m.op)), + sub_iter(std::move(m.sub_iter)) {} - FlatMap(FlatMap &&m) - : iter(std::move(m.iter)), op(std::move(m.op)), - sub_iter(std::move(m.sub_iter)) - { - } + ~FlatMap() final {} - ~FlatMap() final {} + Option<T> next() final { + do { + if (!sub_iter.is_present()) { + auto item = iter.next(); + if (item.is_present()) { + sub_iter = Option<J>(op(item.take())); + } else { + return Option<T>(); + } + } - Option<T> next() final - { - do { - if (!sub_iter.is_present()) { - auto item = iter.next(); - if (item.is_present()) { - sub_iter = Option<J>(op(item.take())); - } else { - return Option<T>(); - } - } + auto item = sub_iter.get().next(); + if (item.is_present()) { + return std::move(item); + } else { + sub_iter.take(); + } + } while (true); + } - auto item = sub_iter.get().next(); - if (item.is_present()) { - return std::move(item); - } else { - sub_iter.take(); - } - } while (true); - } + Count count() final { + // TODO: Correct count, are at least correcter + return iter.count(); + } - Count count() final - { - // TODO: Correct count, are at least correcter - return iter.count(); - } - -private: - I iter; - Option<J> sub_iter; - OP op; + private: + I iter; + Option<J> sub_iter; + OP op; }; template <class I, class OP> -auto make_flat_map(I &&iter, OP &&op) -{ - // Compiler cant deduce type T and J. decltype is here to help with it. - return FlatMap<decltype(op(iter.next().take()).next().take()), I, - decltype(op(iter.next().take())), OP>(std::move(iter), - std::move(op)); +auto make_flat_map(I &&iter, OP &&op) { + // Compiler cant deduce type T and J. decltype is here to help with it. + return FlatMap<decltype(op(iter.next().take()).next().take()), I, + decltype(op(iter.next().take())), OP>(std::move(iter), + std::move(op)); } } diff --git a/src/utils/iterator/for_all.hpp b/src/utils/iterator/for_all.hpp index d68344aff..4a4de5273 100644 --- a/src/utils/iterator/for_all.hpp +++ b/src/utils/iterator/for_all.hpp @@ -4,38 +4,33 @@ #include <memory> #include "utils/option.hpp" -namespace iter -{ +namespace iter { template <class I, class C> -void for_all(I &&iter, C &&consumer) -{ - auto e = iter.next(); - while (e.is_present()) { - consumer(e.take()); - e = iter.next(); - } +void for_all(I &&iter, C &&consumer) { + auto e = iter.next(); + while (e.is_present()) { + consumer(e.take()); + e = iter.next(); + } } template <class I, class C> -void for_all(std::unique_ptr<I> &&iter, C &&consumer) -{ - auto e = iter->next(); - while (e.is_present()) { - consumer(e.take()); - e = iter->next(); - } +void for_all(std::unique_ptr<I> &&iter, C &&consumer) { + auto e = iter->next(); + while (e.is_present()) { + consumer(e.take()); + e = iter->next(); + } } template <class I, class C> -void find(I iter, C &&consumer) -{ - auto e = iter.next(); - while (e.is_present()) { - - if (consumer(e.take())) { - return; - } - e = iter.next(); +void find(I iter, C &&consumer) { + auto e = iter.next(); + while (e.is_present()) { + if (consumer(e.take())) { + return; } + e = iter.next(); + } } } diff --git a/src/utils/iterator/inspect.hpp b/src/utils/iterator/inspect.hpp index 88c7745ae..330c2f169 100644 --- a/src/utils/iterator/inspect.hpp +++ b/src/utils/iterator/inspect.hpp @@ -3,8 +3,7 @@ #include "utils/iterator/composable.hpp" #include "utils/iterator/iterator_base.hpp" -namespace iter -{ +namespace iter { // Class which inspects values returned by I iterator // before passing them as a result. @@ -14,49 +13,42 @@ namespace iter // OP - type of inspector function. OP: T&->void template <class T, class I, class OP> class Inspect : public IteratorBase<T>, - public Composable<T, Inspect<T, I, OP>> -{ -public: - Inspect() = delete; + public Composable<T, Inspect<T, I, OP>> { + public: + Inspect() = delete; - // Inspect operation is designed to be used - // in chained calls which operate on an - // iterator. Inspect will in that usecase - // receive other iterator by value and - // std::move is a optimization for it. - Inspect(I &&iter, OP &&op) : - iter(std::move(iter)), - op(std::move(op)) - {} + // Inspect operation is designed to be used + // in chained calls which operate on an + // iterator. Inspect will in that usecase + // receive other iterator by value and + // std::move is a optimization for it. + Inspect(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {} - Inspect(Inspect &&m) : - iter(std::move(m.iter)), op(std::move(m.op)) {} + Inspect(Inspect &&m) : iter(std::move(m.iter)), op(std::move(m.op)) {} - ~Inspect() final {} + ~Inspect() final {} - Option<T> next() final - { - auto item = iter.next(); - if (item.is_present()) { - op(item.get()); - return std::move(item); - } else { - return Option<T>(); - } + Option<T> next() final { + auto item = iter.next(); + if (item.is_present()) { + op(item.get()); + return std::move(item); + } else { + return Option<T>(); } + } - Count count() final { return iter.count(); } + Count count() final { return iter.count(); } -private: - I iter; - OP op; + private: + I iter; + OP op; }; template <class I, class OP> -auto make_inspect(I &&iter, OP &&op) -{ - // Compiler cant deduce type T. decltype is here to help with it. - return Inspect<decltype(iter.next().take()), I, OP> - (std::move(iter), std::move(op)); +auto make_inspect(I &&iter, OP &&op) { + // Compiler cant deduce type T. decltype is here to help with it. + return Inspect<decltype(iter.next().take()), I, OP>(std::move(iter), + std::move(op)); } } diff --git a/src/utils/iterator/iterator_accessor.hpp b/src/utils/iterator/iterator_accessor.hpp index 32d496102..8fc4c32d1 100644 --- a/src/utils/iterator/iterator_accessor.hpp +++ b/src/utils/iterator/iterator_accessor.hpp @@ -3,8 +3,7 @@ #include "utils/iterator/composable.hpp" #include "utils/iterator/iterator_base.hpp" -namespace iter -{ +namespace iter { // Class which turns accessor int next() based iterator. // T - type of return value @@ -12,70 +11,62 @@ namespace iter // A - accessor type template <class T, class I, class A> class IteratorAccessor : public IteratorBase<T>, - public Composable<T, IteratorAccessor<T, I, A>> -{ -public: - IteratorAccessor() = delete; + public Composable<T, IteratorAccessor<T, I, A>> { + public: + IteratorAccessor() = delete; - IteratorAccessor(A &&acc) - : begin(std::move(acc.begin())), acc(std::forward<A>(acc)), returned(0) - { + IteratorAccessor(A &&acc) + : begin(std::move(acc.begin())), acc(std::forward<A>(acc)), returned(0) {} + + IteratorAccessor(IteratorAccessor &&other) + : begin(std::move(other.begin)), + acc(std::forward<A>(other.acc)), + returned(other.returned) {} + + ~IteratorAccessor() final {} + + // Iter(const Iter &other) = delete; + // Iter(Iter &&other) : + // begin(std::move(other.begin)),end(std::move(other.end)) {}; + + Option<T> next() final { + if (begin != acc.end()) { + auto ret = Option<T>(&(*(begin.operator->()))); + begin++; + returned++; + return ret; + } else { + return Option<T>(); } + } - IteratorAccessor(IteratorAccessor &&other) - : begin(std::move(other.begin)), acc(std::forward<A>(other.acc)), - returned(other.returned) - { + Count count() final { + auto size = acc.size(); + if (size > returned) { + return Count(0); + } else { + return Count(size - returned); } + } - ~IteratorAccessor() final {} - - // Iter(const Iter &other) = delete; - // Iter(Iter &&other) : - // begin(std::move(other.begin)),end(std::move(other.end)) {}; - - Option<T> next() final - { - if (begin != acc.end()) { - auto ret = Option<T>(&(*(begin.operator->()))); - begin++; - returned++; - return ret; - } else { - return Option<T>(); - } - } - - Count count() final - { - auto size = acc.size(); - if (size > returned) { - return Count(0); - } else { - return Count(size - returned); - } - } - -private: - I begin; - A acc; - size_t returned; + private: + I begin; + A acc; + size_t returned; }; // TODO: Join to make functions into one template <class A> -auto make_iter(A &&acc) -{ - // Compiler cant deduce types T and I. decltype are here to help with it. - return IteratorAccessor<decltype(&(*(acc.begin().operator->()))), - decltype(acc.begin()), A>(std::move(acc)); +auto make_iter(A &&acc) { + // Compiler cant deduce types T and I. decltype are here to help with it. + return IteratorAccessor<decltype(&(*(acc.begin().operator->()))), + decltype(acc.begin()), A>(std::move(acc)); } template <class A> -auto make_iter_ref(A &acc) -{ - // Compiler cant deduce types T and I. decltype are here to help with it. - return IteratorAccessor<decltype(&(*(acc.begin().operator->()))), - decltype(acc.begin()), A &>(acc); +auto make_iter_ref(A &acc) { + // Compiler cant deduce types T and I. decltype are here to help with it. + return IteratorAccessor<decltype(&(*(acc.begin().operator->()))), + decltype(acc.begin()), A &>(acc); } } diff --git a/src/utils/iterator/iterator_base.hpp b/src/utils/iterator/iterator_base.hpp index 610126901..3b368c55e 100644 --- a/src/utils/iterator/iterator_base.hpp +++ b/src/utils/iterator/iterator_base.hpp @@ -6,12 +6,11 @@ // Base iterator for next() kind iterator. // T - type of return value template <class T> -class IteratorBase -{ -public: - virtual ~IteratorBase(){}; +class IteratorBase { + public: + virtual ~IteratorBase(){}; - virtual Option<T> next() = 0; + virtual Option<T> next() = 0; - virtual Count count() = 0; + virtual Count count() = 0; }; diff --git a/src/utils/iterator/lambda_iterator.hpp b/src/utils/iterator/lambda_iterator.hpp index 9581e267c..bf1eaa4a2 100644 --- a/src/utils/iterator/lambda_iterator.hpp +++ b/src/utils/iterator/lambda_iterator.hpp @@ -3,54 +3,46 @@ #include "utils/iterator/composable.hpp" #include "utils/iterator/iterator_base.hpp" -namespace iter -{ +namespace iter { // Wraps lambda into interator with next(). // T - type of return value // F - type of wraped lambda template <class T, class F> class LambdaIterator : public IteratorBase<T>, - public Composable<T, LambdaIterator<T, F>> -{ -public: - LambdaIterator(F &&f, size_t count) : func(std::move(f)), _count(count) {} + public Composable<T, LambdaIterator<T, F>> { + public: + LambdaIterator(F &&f, size_t count) : func(std::move(f)), _count(count) {} - LambdaIterator(LambdaIterator &&other) - : func(std::move(other.func)), _count(other._count) - { - } + LambdaIterator(LambdaIterator &&other) + : func(std::move(other.func)), _count(other._count) {} - ~LambdaIterator() final {} + ~LambdaIterator() final {} - Option<T> next() final - { - _count = _count > 0 ? _count - 1 : 0; - return func(); - } + Option<T> next() final { + _count = _count > 0 ? _count - 1 : 0; + return func(); + } - Count count() final { return Count(_count); } + Count count() final { return Count(_count); } -private: - F func; - size_t _count; + private: + F func; + size_t _count; }; // Wraps lambda which returns options as an iterator. template <class F> -auto make_iterator(F &&f) -{ - return make_iterator<F>(std::move(f), ~((size_t)0)); +auto make_iterator(F &&f) { + return make_iterator<F>(std::move(f), ~((size_t)0)); } // Wraps lambda which returns options as an iterator. template <class F> -auto make_iterator(F &&f, size_t count) -{ - // Because function isn't receving or in any way using type T from - // FunctionIterator compiler can't deduce it thats way there is decltype in - // construction of FunctionIterator. Resoulting type of iter.next().take() - // is T. - return LambdaIterator<decltype(f().take()), F>(std::move(f), count); +auto make_iterator(F &&f, size_t count) { + // Because function isn't receving or in any way using type T from + // FunctionIterator compiler can't deduce it thats way there is decltype in + // construction of FunctionIterator. Resoulting type of iter.next().take() + // is T. + return LambdaIterator<decltype(f().take()), F>(std::move(f), count); } - } diff --git a/src/utils/iterator/limited_map.hpp b/src/utils/iterator/limited_map.hpp index 8c1a6c207..3f430981a 100644 --- a/src/utils/iterator/limited_map.hpp +++ b/src/utils/iterator/limited_map.hpp @@ -3,8 +3,7 @@ #include "utils/iterator/composable.hpp" #include "utils/iterator/iterator_base.hpp" -namespace iter -{ +namespace iter { // Class which maps values returned by I iterator into value of type T with OP // function and ends when op returns empty optional. @@ -13,46 +12,41 @@ namespace iter // OP - type of mapper function. OP: V -> Option<T> template <class T, class I, class OP> class LimitedMap : public IteratorBase<T>, - public Composable<T, LimitedMap<T, I, OP>> -{ + public Composable<T, LimitedMap<T, I, OP>> { + public: + LimitedMap() = delete; -public: - LimitedMap() = delete; + // LimitedMap operation is designed to be used in chained calls which + // operate on a + // iterator. LimitedMap will in that usecase receive other iterator by value + // and + // std::move is a optimization for it. + LimitedMap(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {} - // LimitedMap operation is designed to be used in chained calls which - // operate on a - // iterator. LimitedMap will in that usecase receive other iterator by value - // and - // std::move is a optimization for it. - LimitedMap(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {} + LimitedMap(LimitedMap &&m) : iter(std::move(m.iter)), op(std::move(m.op)) {} - LimitedMap(LimitedMap &&m) : iter(std::move(m.iter)), op(std::move(m.op)) {} + ~LimitedMap() final {} - ~LimitedMap() final {} - - Option<T> next() final - { - auto item = iter.next(); - if (item.is_present()) { - return op(item.take()); - } else { - return Option<T>(); - } + Option<T> next() final { + auto item = iter.next(); + if (item.is_present()) { + return op(item.take()); + } else { + return Option<T>(); } + } - Count count() final { return iter.count(); } + Count count() final { return iter.count(); } -private: - I iter; - OP op; + private: + I iter; + OP op; }; template <class I, class OP> -auto make_limited_map(I &&iter, OP &&op) -{ - // Compiler cant deduce type T. decltype is here to help with it. - return LimitedMap<decltype(op(iter.next().take()).take()), I, OP>( - std::move(iter), std::move(op)); +auto make_limited_map(I &&iter, OP &&op) { + // Compiler cant deduce type T. decltype is here to help with it. + return LimitedMap<decltype(op(iter.next().take()).take()), I, OP>( + std::move(iter), std::move(op)); } - } diff --git a/src/utils/iterator/map.hpp b/src/utils/iterator/map.hpp index b38562d57..2a1b7f483 100644 --- a/src/utils/iterator/map.hpp +++ b/src/utils/iterator/map.hpp @@ -3,8 +3,7 @@ #include "utils/iterator/composable.hpp" #include "utils/iterator/iterator_base.hpp" -namespace iter -{ +namespace iter { // Class which maps values returned by I iterator into value of type T with OP // function. @@ -12,44 +11,39 @@ namespace iter // I - iterator type // OP - type of mapper function template <class T, class I, class OP> -class Map : public IteratorBase<T>, public Composable<T, Map<T, I, OP>> -{ +class Map : public IteratorBase<T>, public Composable<T, Map<T, I, OP>> { + public: + Map() = delete; -public: - Map() = delete; + // Map operation is designed to be used in chained calls which operate on a + // iterator. Map will in that usecase receive other iterator by value and + // std::move is a optimization for it. + Map(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {} - // Map operation is designed to be used in chained calls which operate on a - // iterator. Map will in that usecase receive other iterator by value and - // std::move is a optimization for it. - Map(I &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) {} + Map(Map &&m) : iter(std::move(m.iter)), op(std::move(m.op)) {} - Map(Map &&m) : iter(std::move(m.iter)), op(std::move(m.op)) {} + ~Map() final {} - ~Map() final {} - - Option<T> next() final - { - auto item = iter.next(); - if (item.is_present()) { - return Option<T>(op(item.take())); - } else { - return Option<T>(); - } + Option<T> next() final { + auto item = iter.next(); + if (item.is_present()) { + return Option<T>(op(item.take())); + } else { + return Option<T>(); } + } - Count count() final { return iter.count(); } + Count count() final { return iter.count(); } -private: - I iter; - OP op; + private: + I iter; + OP op; }; template <class I, class OP> -auto make_map(I &&iter, OP &&op) -{ - // Compiler cant deduce type T. decltype is here to help with it. - return Map<decltype(op(iter.next().take())), I, OP>(std::move(iter), - std::move(op)); +auto make_map(I &&iter, OP &&op) { + // Compiler cant deduce type T. decltype is here to help with it. + return Map<decltype(op(iter.next().take())), I, OP>(std::move(iter), + std::move(op)); } - } diff --git a/src/utils/iterator/query.hpp b/src/utils/iterator/query.hpp index b6770307a..11f019ba6 100644 --- a/src/utils/iterator/query.hpp +++ b/src/utils/iterator/query.hpp @@ -4,27 +4,20 @@ #include "utils/iterator/iterator.hpp" #include "utils/option.hpp" -namespace query_help -{ +namespace query_help { template <class A> -bool fill(A &a) -{ - return a.fill(); +bool fill(A &a) { + return a.fill(); } - }; // Base iterator for next() kind iterator. // Vertex::Accessor - type of return value template <> -class IteratorBase<Vertex::Accessor> -{ -public: - virtual Option<Vertex::Accessor> next() = 0; +class IteratorBase<Vertex::Accessor> { + public: + virtual Option<Vertex::Accessor> next() = 0; - auto fill() - { - return iter::make_filter(std::move(*this), query_help::fill); - } + auto fill() { return iter::make_filter(std::move(*this), query_help::fill); } }; diff --git a/src/utils/iterator/range_iterator.hpp b/src/utils/iterator/range_iterator.hpp index 6012840b9..e1bf69255 100644 --- a/src/utils/iterator/range_iterator.hpp +++ b/src/utils/iterator/range_iterator.hpp @@ -2,73 +2,61 @@ #include "utils/option.hpp" -namespace iter -{ +namespace iter { // Class which wraps iterator with next() into C++ iterator. // T - type of return value // I - iterator type template <class T, class I> -class RangeIterator -{ +class RangeIterator { + public: + RangeIterator() : iter(Option<I>()), value(Option<T>()){}; -public: - RangeIterator() : iter(Option<I>()), value(Option<T>()){}; + RangeIterator(I &&iter) + : value(iter.next()), iter(Option<I>(std::move(iter))) {} - RangeIterator(I &&iter) - : value(iter.next()), iter(Option<I>(std::move(iter))) - { - } + T &operator*() { + assert(value.is_present()); + return value.get(); + } - T &operator*() - { - assert(value.is_present()); - return value.get(); - } + T *operator->() { + assert(value.is_present()); + return &value.get(); + } - T *operator->() - { - assert(value.is_present()); - return &value.get(); - } + operator T &() { + assert(value.is_present()); + return value.get(); + } - operator T &() - { - assert(value.is_present()); - return value.get(); - } + RangeIterator &operator++() { + assert(iter.is_present()); + value = iter.get().next(); + return (*this); + } - RangeIterator &operator++() - { - assert(iter.is_present()); - value = iter.get().next(); - return (*this); - } + RangeIterator &operator++(int) { return operator++(); } - RangeIterator &operator++(int) { return operator++(); } + friend bool operator==(const RangeIterator &a, const RangeIterator &b) { + return a.value.is_present() == b.value.is_present(); + } - friend bool operator==(const RangeIterator &a, const RangeIterator &b) - { - return a.value.is_present() == b.value.is_present(); - } + friend bool operator!=(const RangeIterator &a, const RangeIterator &b) { + return !(a == b); + } - friend bool operator!=(const RangeIterator &a, const RangeIterator &b) - { - return !(a == b); - } - -private: - Option<I> iter; - Option<T> value; + private: + Option<I> iter; + Option<T> value; }; template <class I> -auto make_range_iterator(I &&iter) -{ - // Because this function isn't receving or in any way using type T from - // RangeIterator, compiler can't deduce it. That is the reason why - // there is decltype in construction of RangeIterator. - // declytype(iter.next().take()) is T. - return RangeIterator<decltype(iter.next().take()), I>(std::move(iter)); +auto make_range_iterator(I &&iter) { + // Because this function isn't receving or in any way using type T from + // RangeIterator, compiler can't deduce it. That is the reason why + // there is decltype in construction of RangeIterator. + // declytype(iter.next().take()) is T. + return RangeIterator<decltype(iter.next().take()), I>(std::move(iter)); } } diff --git a/src/utils/iterator/virtual_iter.hpp b/src/utils/iterator/virtual_iter.hpp index c56a83c4f..a7eefe20e 100644 --- a/src/utils/iterator/virtual_iter.hpp +++ b/src/utils/iterator/virtual_iter.hpp @@ -3,46 +3,40 @@ #include "utils/iterator/composable.hpp" #include "utils/iterator/iterator_base.hpp" -namespace iter -{ +namespace iter { // Class which wraps iterator and hides it's type. It actualy does this by // dynamicly allocating iterator on heap. // T - type of return value template <class T> -class Virtual : public Composable<T, Virtual<T>> -{ +class Virtual : public Composable<T, Virtual<T>> { + public: + Virtual() = delete; -public: - Virtual() = delete; + // Virtual operation is designed to be used in chained calls which operate + // on a + // iterator. Virtual will in that usecase receive other iterator by value + // and + // std::move is a optimization for it. - // Virtual operation is designed to be used in chained calls which operate - // on a - // iterator. Virtual will in that usecase receive other iterator by value - // and - // std::move is a optimization for it. + template <class I> + Virtual(I &&iter) : it(std::make_unique<I>(std::move(iter))) {} - template <class I> - Virtual(I &&iter) : it(std::make_unique<I>(std::move(iter))) - { - } + Virtual(Virtual &&m) : it(std::move(m.it)) {} - Virtual(Virtual &&m) : it(std::move(m.it)) {} + ~Virtual() {} - ~Virtual() {} + Option<T> next() { return it.get()->next(); } - Option<T> next() { return it.get()->next(); } + Count count() { return it.get()->count(); } - Count count() { return it.get()->count(); } - -private: - std::unique_ptr<IteratorBase<T>> it; + private: + std::unique_ptr<IteratorBase<T>> it; }; template <class I> -auto make_virtual(I &&iter) -{ - // Compiler can't deduce type T. decltype is here to help with it. - return Virtual<decltype(iter.next().take())>(std::move(iter)); +auto make_virtual(I &&iter) { + // Compiler can't deduce type T. decltype is here to help with it. + return Virtual<decltype(iter.next().take())>(std::move(iter)); } } diff --git a/src/utils/linux.hpp b/src/utils/linux.hpp index 524b13298..162937ae1 100644 --- a/src/utils/linux.hpp +++ b/src/utils/linux.hpp @@ -12,43 +12,37 @@ // http://stackoverflow.com/questions/5616092/non-blocking-call-for-reading-descriptor // http://stackoverflow.com/questions/2917881/how-to-implement-a-timeout-in-read-function-call -#include <unistd.h> #include <fcntl.h> +#include <unistd.h> #include "utils/exceptions/basic_exception.hpp" #include "utils/exceptions/not_yet_implemented.hpp" #include "utils/likely.hpp" -namespace linux_os -{ - class LinuxException : public BasicException - { - using BasicException::BasicException; - }; +namespace linux_os { +class LinuxException : public BasicException { + using BasicException::BasicException; +}; - /** - * Sets non blocking flag to a file descriptor. - */ - void set_non_blocking(int fd) - { - auto flags = fcntl(fd, F_GETFL, 0); +/** + * Sets non blocking flag to a file descriptor. + */ +void set_non_blocking(int fd) { + auto flags = fcntl(fd, F_GETFL, 0); - if(UNLIKELY(flags == -1)) - throw LinuxException("Cannot read flags from file descriptor."); + if (UNLIKELY(flags == -1)) + throw LinuxException("Cannot read flags from file descriptor."); - flags |= O_NONBLOCK; + flags |= O_NONBLOCK; - auto status = fcntl(fd, F_SETFL, flags); + auto status = fcntl(fd, F_SETFL, flags); - if(UNLIKELY(status == -1)) - throw LinuxException("Can't set NON_BLOCK flag to file descriptor"); - } - - /** - * Reads a file descriptor with timeout. - */ - void tread() - { - throw NotYetImplemented(); - } + if (UNLIKELY(status == -1)) + throw LinuxException("Can't set NON_BLOCK flag to file descriptor"); +} + +/** + * Reads a file descriptor with timeout. + */ +void tread() { throw NotYetImplemented(); } } diff --git a/src/utils/mark_ref.hpp b/src/utils/mark_ref.hpp index f501e9957..20a93dfbf 100644 --- a/src/utils/mark_ref.hpp +++ b/src/utils/mark_ref.hpp @@ -3,36 +3,23 @@ #include <stdint.h> template <class T> -struct MarkRef -{ - MarkRef() = default; - MarkRef(MarkRef&) = default; - MarkRef(MarkRef&&) = default; +struct MarkRef { + MarkRef() = default; + MarkRef(MarkRef&) = default; + MarkRef(MarkRef&&) = default; - bool is_marked() const - { - return ptr & 0x1L; - } + bool is_marked() const { return ptr & 0x1L; } - bool set_mark() - { - return ptr |= 0x1L; - } + bool set_mark() { return ptr |= 0x1L; } - bool clear_mark() - { - return ptr &= ~0x1L; - } + bool clear_mark() { return ptr &= ~0x1L; } - T* get() const - { - return reinterpret_cast<T*>(ptr & ~0x1L); - } + T* get() const { return reinterpret_cast<T*>(ptr & ~0x1L); } - T& operator*() { return *get(); } - T* operator->() { return get(); } + T& operator*() { return *get(); } + T* operator->() { return get(); } - operator T*() { return get(); } + operator T*() { return get(); } - uintptr_t ptr; + uintptr_t ptr; }; diff --git a/src/utils/memory/allocator.hpp b/src/utils/memory/allocator.hpp index d9d0b34a0..d40929f15 100644 --- a/src/utils/memory/allocator.hpp +++ b/src/utils/memory/allocator.hpp @@ -5,44 +5,39 @@ template <class Tp> struct fast_allocator { - typedef Tp value_type; + typedef Tp value_type; - fast_allocator() = default; + fast_allocator() = default; - template <class T> - fast_allocator(const fast_allocator<T>&) {} - - Tp* allocate(std::size_t n); - void deallocate(Tp* p, std::size_t n); + template <class T> + fast_allocator(const fast_allocator<T>&) {} + + Tp* allocate(std::size_t n); + void deallocate(Tp* p, std::size_t n); }; template <class Tp> -Tp* fast_allocator<Tp>::allocate(std::size_t n) -{ - // hopefully we're using jemalloc here! - Tp* mem = static_cast<Tp*>(malloc(n * sizeof(Tp))); +Tp* fast_allocator<Tp>::allocate(std::size_t n) { + // hopefully we're using jemalloc here! + Tp* mem = static_cast<Tp*>(malloc(n * sizeof(Tp))); - if(mem != nullptr) - return mem; + if (mem != nullptr) return mem; - throw std::bad_alloc(); + throw std::bad_alloc(); } template <class Tp> -void fast_allocator<Tp>::deallocate(Tp* p, std::size_t) -{ - // hopefully we're using jemalloc here! - free(p); +void fast_allocator<Tp>::deallocate(Tp* p, std::size_t) { + // hopefully we're using jemalloc here! + free(p); } template <class T, class U> -bool operator==(const fast_allocator<T>&, const fast_allocator<U>&) -{ - return true; +bool operator==(const fast_allocator<T>&, const fast_allocator<U>&) { + return true; } template <class T, class U> -bool operator!=(const fast_allocator<T>& a, const fast_allocator<U>& b) -{ - return !(a == b); +bool operator!=(const fast_allocator<T>& a, const fast_allocator<U>& b) { + return !(a == b); } diff --git a/src/utils/memory/atomic_shared_ptr.hpp b/src/utils/memory/atomic_shared_ptr.hpp index 0a1895787..6197b2e9b 100644 --- a/src/utils/memory/atomic_shared_ptr.hpp +++ b/src/utils/memory/atomic_shared_ptr.hpp @@ -3,24 +3,18 @@ #include <atomic> #include <memory> -template<class T> -class atomic_shared_ptr final -{ -public: - atomic_shared_ptr(std::shared_ptr<T>&& ptr) - : ptr(ptr) {} +template <class T> +class atomic_shared_ptr final { + public: + atomic_shared_ptr(std::shared_ptr<T>&& ptr) : ptr(ptr) {} - std::shared_ptr<T> load() - { - return std::move(std::atomic_load(&ptr)); - } + std::shared_ptr<T> load() { return std::move(std::atomic_load(&ptr)); } - bool compare_exchange_weak(std::shared_ptr<T>& expected, - std::shared_ptr<T> desired) - { - return atomic_compare_exchange_weak(&ptr, &expected, desired); - } + bool compare_exchange_weak(std::shared_ptr<T>& expected, + std::shared_ptr<T> desired) { + return atomic_compare_exchange_weak(&ptr, &expected, desired); + } -private: - std::shared_ptr<T> ptr; + private: + std::shared_ptr<T> ptr; }; diff --git a/src/utils/memory/block_allocator.hpp b/src/utils/memory/block_allocator.hpp index f7eb3791f..cdb7c41d1 100644 --- a/src/utils/memory/block_allocator.hpp +++ b/src/utils/memory/block_allocator.hpp @@ -9,62 +9,48 @@ * the pointers on allocated blocks inside a vector. */ template <size_t block_size> -class BlockAllocator -{ - struct Block - { - Block() { data = malloc(block_size); } +class BlockAllocator { + struct Block { + Block() { data = malloc(block_size); } - Block(void *ptr) { data = ptr; } + Block(void *ptr) { data = ptr; } - void *data; - }; + void *data; + }; -public: - static constexpr size_t size = block_size; + public: + static constexpr size_t size = block_size; - BlockAllocator(size_t capacity = 0) - { - for (size_t i = 0; i < capacity; ++i) - unused_.emplace_back(); - } + BlockAllocator(size_t capacity = 0) { + for (size_t i = 0; i < capacity; ++i) unused_.emplace_back(); + } - ~BlockAllocator() - { - for (auto block : unused_) - free(block.data); - unused_.clear(); - for (auto block : release_) - free(block.data); - release_.clear(); - } + ~BlockAllocator() { + for (auto block : unused_) free(block.data); + unused_.clear(); + for (auto block : release_) free(block.data); + release_.clear(); + } - size_t unused_size() const - { - return unused_.size(); - } + size_t unused_size() const { return unused_.size(); } - size_t release_size() const - { - return release_.size(); - } + size_t release_size() const { return release_.size(); } - // Returns nullptr on no memory. - void *acquire() - { - if (unused_.size() == 0) unused_.emplace_back(); + // Returns nullptr on no memory. + void *acquire() { + if (unused_.size() == 0) unused_.emplace_back(); - auto ptr = unused_.back().data; - Auto(unused_.pop_back()); - return ptr; - } + auto ptr = unused_.back().data; + Auto(unused_.pop_back()); + return ptr; + } - void release(void *ptr) { release_.emplace_back(ptr); } + void release(void *ptr) { release_.emplace_back(ptr); } -private: - // TODO: try implement with just one vector - // but consecutive acquire release calls should work - // TODO: measure first! - std::vector<Block> unused_; - std::vector<Block> release_; + private: + // TODO: try implement with just one vector + // but consecutive acquire release calls should work + // TODO: measure first! + std::vector<Block> unused_; + std::vector<Block> release_; }; diff --git a/src/utils/memory/maker.hpp b/src/utils/memory/maker.hpp index ca8ddfcc1..46e6f6894 100644 --- a/src/utils/memory/maker.hpp +++ b/src/utils/memory/maker.hpp @@ -4,21 +4,16 @@ #include "allocator.hpp" -template <class T, - typename... Args, - class allocator=fast_allocator<T>> -T* makeme(Args... args) -{ - allocator alloc; - T* mem = alloc.allocate(1); - return new (mem) T(args...); +template <class T, typename... Args, class allocator = fast_allocator<T>> +T* makeme(Args... args) { + allocator alloc; + T* mem = alloc.allocate(1); + return new (mem) T(args...); } -template <class T, - class allocator=fast_allocator<T>> -void takeme(T* mem) -{ - allocator alloc; - mem->~T(); - alloc.deallocate(mem, 1); +template <class T, class allocator = fast_allocator<T>> +void takeme(T* mem) { + allocator alloc; + mem->~T(); + alloc.deallocate(mem, 1); } diff --git a/src/utils/memory/stack_allocator.hpp b/src/utils/memory/stack_allocator.hpp index 15623e49d..122cc82c3 100644 --- a/src/utils/memory/stack_allocator.hpp +++ b/src/utils/memory/stack_allocator.hpp @@ -10,109 +10,100 @@ // Useful for allocating memory which can be freed with one call. // Most performant for data which need to be present to the end. -class StackAllocator -{ - static constexpr size_t page_size = 64 * 1024; +class StackAllocator { + static constexpr size_t page_size = 64 * 1024; -public: - ~StackAllocator() { free(); } + public: + ~StackAllocator() { free(); } - // Allocates memory for object of type T. - // Retruns pointer to memory for it. - template <class T> - inline T *allocate() - { - // If size is bigger than pages_size then this do-whil will never end - // until it eats all the memory. - static_assert(sizeof(T) <= page_size, - "Cant allocate objects larger than page_size"); - do - { - // Mask which has log2(alignof(T)) lower bits setted to 0 and the - // rest to 1. - // example: - // alignof(T)==8 => mask=0xfffffffffffffff8; - // This will be calculated in compile time. - size_t mask = ~(((size_t)alignof(T)) - 1); + // Allocates memory for object of type T. + // Retruns pointer to memory for it. + template <class T> + inline T *allocate() { + // If size is bigger than pages_size then this do-whil will never end + // until it eats all the memory. + static_assert(sizeof(T) <= page_size, + "Cant allocate objects larger than page_size"); + do { + // Mask which has log2(alignof(T)) lower bits setted to 0 and the + // rest to 1. + // example: + // alignof(T)==8 => mask=0xfffffffffffffff8; + // This will be calculated in compile time. + size_t mask = ~(((size_t)alignof(T)) - 1); - // aligned contains ptr aligned to alignof(T). - // There are two types of head ptr: - // a) aligned to alignof(T) - // b) not aligned to alignof(T) - // For a) whe want for aligned to be equal to head, and for b) - // aligned shuold be first aligned ptr greater than head. - // - // head - 1 => turns a) into b) now whe only have to get first - // aligned ptr greater than (head - 1). - // - // (head - 1) & mask => will produce first smaller than head ptr - // aligned to alignof(T). - // - // ( (head - 1) & mask ) + alignof(T) => will produce first grater - // or equal than head ptr aligned to alignof(T). - char *aligned = - (char *)(((((size_t)head) - 1) & mask) + alignof(T)); + // aligned contains ptr aligned to alignof(T). + // There are two types of head ptr: + // a) aligned to alignof(T) + // b) not aligned to alignof(T) + // For a) whe want for aligned to be equal to head, and for b) + // aligned shuold be first aligned ptr greater than head. + // + // head - 1 => turns a) into b) now whe only have to get first + // aligned ptr greater than (head - 1). + // + // (head - 1) & mask => will produce first smaller than head ptr + // aligned to alignof(T). + // + // ( (head - 1) & mask ) + alignof(T) => will produce first grater + // or equal than head ptr aligned to alignof(T). + char *aligned = (char *)(((((size_t)head) - 1) & mask) + alignof(T)); - // New head which points to unallocated memory points to first byte - // after space for object T. - char *new_head = aligned + sizeof(T); + // New head which points to unallocated memory points to first byte + // after space for object T. + char *new_head = aligned + sizeof(T); - // If the new_head is greater than end that means that there isn't - // enough space for object T in current block of memory. - if (LIKELY(new_head <= end)) - { + // If the new_head is greater than end that means that there isn't + // enough space for object T in current block of memory. + if (LIKELY(new_head <= end)) { + // All is fine, head can become new_head + head = new_head; - // All is fine, head can become new_head - head = new_head; + // Returns aligned ptr with enough space for object T. + return (T *)aligned; + } - // Returns aligned ptr with enough space for object T. - return (T *)aligned; - } + // There isn't enough free space so whe must allocate more. + void *alloc = blocks.acquire(); - // There isn't enough free space so whe must allocate more. - void *alloc = blocks.acquire(); + // Check if there are memory. If not throw exception rather than + // return nullptr. + if (UNLIKELY(alloc == nullptr)) + throw new OutOfMemory("BlockAllocator returned nullptr"); - // Check if there are memory. If not throw exception rather than - // return nullptr. - if (UNLIKELY(alloc == nullptr)) - throw new OutOfMemory("BlockAllocator returned nullptr"); + // Remember that whee allocated memory so that whe can free-it + // after. + allocated_blocks.push_back(alloc); - // Remember that whee allocated memory so that whe can free-it - // after. - allocated_blocks.push_back(alloc); + // Set new head, the old one isn't needed anymore. + head = (char *)alloc; - // Set new head, the old one isn't needed anymore. - head = (char *)alloc; + // Update end to point to first byte after newly allocated memory. + end = head + page_size; - // Update end to point to first byte after newly allocated memory. - end = head + page_size; + // After allocating new memory lets try again to "allocate" place + // for T. + } while (true); + } - // After allocating new memory lets try again to "allocate" place - // for T. - } while (true); + template <class T, class... Args> + inline T *make(Args &&... args) { + auto ptr = allocate<T>(); + new (ptr) T(std::forward<Args>(args)...); + return ptr; + } + + // Relases all memory. + void free() { + while (allocated_blocks.size()) { + blocks.release(allocated_blocks.back()); + allocated_blocks.pop_back(); } + } - template <class T, class... Args> - inline T *make(Args &&... args) - { - auto ptr = allocate<T>(); - new (ptr) T(std::forward<Args>(args)...); - return ptr; - } - - // Relases all memory. - void free() - { - while (allocated_blocks.size()) - { - blocks.release(allocated_blocks.back()); - allocated_blocks.pop_back(); - } - } - -private: - BlockAllocator<page_size> blocks; - std::vector<void *> allocated_blocks; - char *head = {nullptr}; - char *end = {nullptr}; + private: + BlockAllocator<page_size> blocks; + std::vector<void *> allocated_blocks; + char *head = {nullptr}; + char *end = {nullptr}; }; diff --git a/src/utils/numerics/ceil.hpp b/src/utils/numerics/ceil.hpp index 3a1ee94bc..c8cc0391e 100644 --- a/src/utils/numerics/ceil.hpp +++ b/src/utils/numerics/ceil.hpp @@ -2,16 +2,14 @@ #include <type_traits> -namespace num -{ +namespace num { template <class T, - typename std::enable_if<std::is_integral<T>::value>::type * = nullptr> -T iceil(T x, T y) -{ - // this may seem inefficient, but on x86_64, when you already perform - // division (x / y) the remainder is already computed and therefore x % y - // is basically free! - return x / y + (x % y != 0); + typename std::enable_if<std::is_integral<T>::value>::type* = nullptr> +T iceil(T x, T y) { + // this may seem inefficient, but on x86_64, when you already perform + // division (x / y) the remainder is already computed and therefore x % y + // is basically free! + return x / y + (x % y != 0); } } diff --git a/src/utils/numerics/log2.hpp b/src/utils/numerics/log2.hpp index 90e0a087e..6361f5d17 100644 --- a/src/utils/numerics/log2.hpp +++ b/src/utils/numerics/log2.hpp @@ -2,9 +2,7 @@ #include <cstddef> -namespace utils -{ +namespace utils { constexpr size_t log2(size_t n) { return ((n < 2) ? 0 : 1 + log2(n >> 1)); } - } diff --git a/src/utils/numerics/saturate.cpp b/src/utils/numerics/saturate.cpp index 13a24db2b..e61fd8df0 100644 --- a/src/utils/numerics/saturate.cpp +++ b/src/utils/numerics/saturate.cpp @@ -1,9 +1,8 @@ #include "utils/numerics/saturate.hpp" -std::size_t num::saturating_add(std::size_t a, std::size_t b) -{ - a = a >= size_t_HIGHEST_BIT_SETED ? size_t_HIGHEST_BIT_SETED - 1 : a; - b = b >= size_t_HIGHEST_BIT_SETED ? size_t_HIGHEST_BIT_SETED - 1 : b; +std::size_t num::saturating_add(std::size_t a, std::size_t b) { + a = a >= size_t_HIGHEST_BIT_SETED ? size_t_HIGHEST_BIT_SETED - 1 : a; + b = b >= size_t_HIGHEST_BIT_SETED ? size_t_HIGHEST_BIT_SETED - 1 : b; - return a + b; + return a + b; } diff --git a/src/utils/numerics/saturate.hpp b/src/utils/numerics/saturate.hpp index a5c85fb51..a0cb7d741 100644 --- a/src/utils/numerics/saturate.hpp +++ b/src/utils/numerics/saturate.hpp @@ -2,8 +2,7 @@ #include <type_traits> -namespace num -{ +namespace num { constexpr std::size_t size_t_HIGHEST_BIT_SETED = ((std::size_t)1) << ((sizeof(std::size_t) * 8) - 1); diff --git a/src/utils/option.hpp b/src/utils/option.hpp index 409c9b2b3..9c087419a 100644 --- a/src/utils/option.hpp +++ b/src/utils/option.hpp @@ -1,218 +1,196 @@ #pragma once +#include <ext/aligned_buffer.h> #include <cassert> #include <cstring> -#include <ext/aligned_buffer.h> #include <utility> // Optional object storage. It maybe has and maybe // dosent have objet of type T. template <class T> -class Option -{ -public: - Option() { std::memset(data._M_addr(), 0, sizeof(T)); } +class Option { + public: + Option() { std::memset(data._M_addr(), 0, sizeof(T)); } - Option(T const &item) - { - new (data._M_addr()) T(item); - initialized = true; + Option(T const &item) { + new (data._M_addr()) T(item); + initialized = true; + } + + Option(T &&item) { + new (data._M_addr()) T(std::move(item)); + initialized = true; + } + + Option(const Option &other) { + if (other.initialized) { + new (data._M_addr()) T(other.get()); + initialized = true; + } else { + std::memset(data._M_addr(), 0, sizeof(T)); + } + } + + // Containers from std which have strong exception + // guarantees wont use move constructors and operators + // wihtout noexcept. "Optimized C++,2016 , Kurt + // Guntheroth, page: 142, title: Moving instances into + // std::vector" + Option(Option &&other) noexcept { + if (other.initialized) { + new (data._M_addr()) T(std::move(other.get())); + other.initialized = false; + initialized = true; + } else { + std::memset(data._M_addr(), 0, sizeof(T)); + } + } + + ~Option() { + if (initialized) { + get().~T(); + initialized = false; + } + } + + Option &operator=(const Option &other) { + if (initialized) { + get().~T(); + initialized = false; + } + if (other.initialized) { + new (data._M_addr()) T(other.get()); + initialized = true; } - Option(T &&item) - { - new (data._M_addr()) T(std::move(item)); - initialized = true; + return *this; + } + + Option &operator=(Option &&other) { + if (initialized) { + get().~T(); + initialized = false; } - Option(const Option &other) - { - if (other.initialized) { - new (data._M_addr()) T(other.get()); - initialized = true; - } else { - std::memset(data._M_addr(), 0, sizeof(T)); - } + if (other.initialized) { + new (data._M_addr()) T(std::move(other.get())); + other.initialized = false; + initialized = true; } - // Containers from std which have strong exception - // guarantees wont use move constructors and operators - // wihtout noexcept. "Optimized C++,2016 , Kurt - // Guntheroth, page: 142, title: Moving instances into - // std::vector" - Option(Option &&other) noexcept - { - if (other.initialized) { - new (data._M_addr()) T(std::move(other.get())); - other.initialized = false; - initialized = true; - } else { - std::memset(data._M_addr(), 0, sizeof(T)); - } + return *this; + } + + // True if object i present. + bool is_present() const { return initialized; } + + T &get() noexcept { + assert(initialized); + return *data._M_ptr(); + } + + T &get_or(T &other) { + if (is_present()) { + return get(); + } else { + return other; } + } - ~Option() - { - if (initialized) { - get().~T(); - initialized = false; - } + // Returns ref to object if present else other. + T const &get_or(T const &other) const { + if (is_present()) { + return get(); + } else { + return other; } + } - Option &operator=(const Option &other) - { - if (initialized) { - get().~T(); - initialized = false; - } - if (other.initialized) { - new (data._M_addr()) T(other.get()); - initialized = true; - } + const T &get() const noexcept { + assert(initialized); + return *data._M_ptr(); + } - return *this; + template <class U> + Option<U> map() { + if (is_present()) { + return Option<U>(U(take())); + } else { + return Option<U>(); } + } - Option &operator=(Option &&other) - { - if (initialized) { - get().~T(); - initialized = false; - } - - if (other.initialized) { - new (data._M_addr()) T(std::move(other.get())); - other.initialized = false; - initialized = true; - } - - return *this; + template <class U, class F> + Option<U> map(F f) { + if (is_present()) { + return Option<U>(f(take())); + } else { + return Option<U>(); } + } - // True if object i present. - bool is_present() const { return initialized; } - - T &get() noexcept - { - assert(initialized); - return *data._M_ptr(); + template <class U, class F> + U map_or(F f, U &&def) { + if (is_present()) { + return f(take()); + } else { + return std::move(def); } + } - T &get_or(T &other) - { - if (is_present()) { - return get(); - } else { - return other; - } + template <class U, class F> + U call_or(F f, U &&def) { + if (is_present()) { + return f(get()); + } else { + return std::move(def); } + } - // Returns ref to object if present else other. - T const &get_or(T const &other) const - { - if (is_present()) { - return get(); - } else { - return other; - } + T take() { + assert(initialized); + initialized = false; + return std::move(*data._M_ptr()); + } + + // Takes if it exists otherwise returns given value. + T take_or(T &&value) { + if (initialized) { + initialized = false; + return std::move(*data._M_ptr()); + } else { + return std::move(value); } + } - const T &get() const noexcept - { - assert(initialized); - return *data._M_ptr(); - } + explicit operator bool() const { return initialized; } - template <class U> - Option<U> map() - { - if (is_present()) { - return Option<U>(U(take())); - } else { - return Option<U>(); - } - } - - template <class U, class F> - Option<U> map(F f) - { - if (is_present()) { - return Option<U>(f(take())); - } else { - return Option<U>(); - } - } - - template <class U, class F> - U map_or(F f, U &&def) - { - if (is_present()) { - return f(take()); - } else { - return std::move(def); - } - } - - template <class U, class F> - U call_or(F f, U &&def) - { - if (is_present()) { - return f(get()); - } else { - return std::move(def); - } - } - - T take() - { - assert(initialized); - initialized = false; - return std::move(*data._M_ptr()); - } - - // Takes if it exists otherwise returns given value. - T take_or(T &&value) - { - if (initialized) { - initialized = false; - return std::move(*data._M_ptr()); - } else { - return std::move(value); - } - } - - explicit operator bool() const { return initialized; } - -private: - // Aligned buffer is here to ensure aligment for - // data of type T. It isn't applicable to just put T - // field because the field has to be able to be - // uninitialized to fulfill the semantics of Option class. - __gnu_cxx::__aligned_buffer<T> data; - bool initialized = false; + private: + // Aligned buffer is here to ensure aligment for + // data of type T. It isn't applicable to just put T + // field because the field has to be able to be + // uninitialized to fulfill the semantics of Option class. + __gnu_cxx::__aligned_buffer<T> data; + bool initialized = false; }; template <class T> -auto make_option() -{ - return Option<T>(); +auto make_option() { + return Option<T>(); } template <class T> -auto make_option(T &&data) -{ - return Option<T>(std::move(data)); +auto make_option(T &&data) { + return Option<T>(std::move(data)); } template <class T> -auto make_option_const(const T &&data) -{ - return Option<const T>(std::move(data)); +auto make_option_const(const T &&data) { + return Option<const T>(std::move(data)); } // HELPER FUNCTIONS template <class R> -bool option_fill(Option<R> &o) -{ - return o.is_present() && o.get().fill(); +bool option_fill(Option<R> &o) { + return o.is_present() && o.get().fill(); } diff --git a/src/utils/option_ptr.hpp b/src/utils/option_ptr.hpp index d50aa443f..41c1ca340 100644 --- a/src/utils/option_ptr.hpp +++ b/src/utils/option_ptr.hpp @@ -2,26 +2,23 @@ // Like option just for pointers. More efficent than option. template <class T> -class OptionPtr -{ -public: - OptionPtr() {} - OptionPtr(T *ptr) : ptr(ptr) {} +class OptionPtr { + public: + OptionPtr() {} + OptionPtr(T *ptr) : ptr(ptr) {} - bool is_present() { return ptr != nullptr; } + bool is_present() { return ptr != nullptr; } - T *get() - { - assert(is_present()); - return ptr; - } + T *get() { + assert(is_present()); + return ptr; + } -private: - T *ptr = nullptr; + private: + T *ptr = nullptr; }; template <class T> -auto make_option_ptr(T *t) -{ - return OptionPtr<T>(t); +auto make_option_ptr(T *t) { + return OptionPtr<T>(t); } diff --git a/src/utils/order.hpp b/src/utils/order.hpp index ceb744d16..8d5e63d28 100644 --- a/src/utils/order.hpp +++ b/src/utils/order.hpp @@ -1,9 +1,8 @@ #pragma once // Defines ordering of data -enum Order : uint8_t -{ - None = 0, - Ascending = 1, - Descending = 2, +enum Order : uint8_t { + None = 0, + Ascending = 1, + Descending = 2, }; diff --git a/src/utils/pass_key.hpp b/src/utils/pass_key.hpp index b82d6b203..37a1021a7 100644 --- a/src/utils/pass_key.hpp +++ b/src/utils/pass_key.hpp @@ -6,14 +6,13 @@ // http://arne-mertz.de/2016/10/passkey-idiom/ // http://stackoverflow.com/questions/3217390/clean-c-granular-friend-equivalent-answer-attorney-client-idiom - #pragma once -template<typename T> +template <typename T> class PassKey { friend T; -private: + private: // default constructor has to be manually defined otherwise = default // would allow aggregate initialization to bypass default constructor // both, default and copy constructors have to be user-defined diff --git a/src/utils/random/fast_binomial.hpp b/src/utils/random/fast_binomial.hpp index 8a4819fa7..b752d0a51 100644 --- a/src/utils/random/fast_binomial.hpp +++ b/src/utils/random/fast_binomial.hpp @@ -1,59 +1,55 @@ #pragma once -#include "utils/random/xorshift128plus.hpp" #include "utils/likely.hpp" +#include "utils/random/xorshift128plus.hpp" -template <size_t N, class R=Xorshift128plus> -class FastBinomial -{ - // fast binomial draws coin tosses from a single generated random number - // let's draw a random 4 bit number and count trailing ones - // - // 1 0000 -> 1 = - // 2 0001 -> 2 == 8 x = p = 8/16 = 1/2 - // 3 0010 -> 1 = 4 x == p = 4/16 = 1/4 p_total = 15/16 - // 4 0011 -> 3 === 2 x === p = 2/16 = 1/8 - // 5 0100 -> 1 = 1 x ==== p = 1/16 = 1/16 - // 6 0101 -> 2 == -------------------------- - // 7 0110 -> 1 = 1 x ===== p = 1/16 invalid value, retry! - // 8 0111 -> 4 ==== - // 9 1000 -> 1 = - // 10 1001 -> 2 == - // 11 1010 -> 1 = - // 12 1011 -> 3 === - // 13 1100 -> 1 = - // 14 1101 -> 2 == - // 15 1110 -> 1 = - // ------------------ - // 16 1111 -> 5 ===== +template <size_t N, class R = Xorshift128plus> +class FastBinomial { + // fast binomial draws coin tosses from a single generated random number + // let's draw a random 4 bit number and count trailing ones + // + // 1 0000 -> 1 = + // 2 0001 -> 2 == 8 x = p = 8/16 = 1/2 + // 3 0010 -> 1 = 4 x == p = 4/16 = 1/4 p_total = 15/16 + // 4 0011 -> 3 === 2 x === p = 2/16 = 1/8 + // 5 0100 -> 1 = 1 x ==== p = 1/16 = 1/16 + // 6 0101 -> 2 == -------------------------- + // 7 0110 -> 1 = 1 x ===== p = 1/16 invalid value, retry! + // 8 0111 -> 4 ==== + // 9 1000 -> 1 = + // 10 1001 -> 2 == + // 11 1010 -> 1 = + // 12 1011 -> 3 === + // 13 1100 -> 1 = + // 14 1101 -> 2 == + // 15 1110 -> 1 = + // ------------------ + // 16 1111 -> 5 ===== - static constexpr uint64_t mask = (1ULL << N) - 1; + static constexpr uint64_t mask = (1ULL << N) - 1; -public: - unsigned operator()() - { - while(true) - { - // couting trailing ones is equal to counting trailing zeros - // since the probability for both is 1/2 and we're going to - // count zeros because they are easier to work with + public: + unsigned operator()() { + while (true) { + // couting trailing ones is equal to counting trailing zeros + // since the probability for both is 1/2 and we're going to + // count zeros because they are easier to work with - // generate a random number - auto x = random() & mask; + // generate a random number + auto x = random() & mask; - // if we have all zeros, then we have an invalid case and we - // need to generate again, we have this every (1/2)^N times - // so therefore we could say it's very unlikely to happen for - // large N. e.g. N = 32; p = 2.328 * 10^-10 - if(UNLIKELY(!x)) - continue; + // if we have all zeros, then we have an invalid case and we + // need to generate again, we have this every (1/2)^N times + // so therefore we could say it's very unlikely to happen for + // large N. e.g. N = 32; p = 2.328 * 10^-10 + if (UNLIKELY(!x)) continue; - // ctzl = count trailing zeros from long - // ^ ^ ^ ^ - return __builtin_ctzl(x) + 1; - } + // ctzl = count trailing zeros from long + // ^ ^ ^ ^ + return __builtin_ctzl(x) + 1; } + } -private: - R random; + private: + R random; }; diff --git a/src/utils/random/xorshift128plus.hpp b/src/utils/random/xorshift128plus.hpp index 8788660cd..bcc78f1ba 100644 --- a/src/utils/random/xorshift128plus.hpp +++ b/src/utils/random/xorshift128plus.hpp @@ -10,51 +10,47 @@ * applications with a mild amount of parallelism, otherwise, use a * xorshift1024* generator. */ -struct Xorshift128plus -{ -public: - Xorshift128plus() - { - // use a slow, more complex rnd generator to initialize a fast one - // make sure to call this before requesting any random numbers! +struct Xorshift128plus { + public: + Xorshift128plus() { + // use a slow, more complex rnd generator to initialize a fast one + // make sure to call this before requesting any random numbers! - // NOTE: Valgird complanis to next instruction - std::random_device rd; - std::mt19937_64 gen(rd()); - // std::mt19937_64 gen(time(0)); + // NOTE: Valgird complanis to next instruction + std::random_device rd; + std::mt19937_64 gen(rd()); + // std::mt19937_64 gen(time(0)); - std::uniform_int_distribution<unsigned long long> dist; + std::uniform_int_distribution<unsigned long long> dist; - // the number generated by MT can be full of zeros and xorshift - // doesn't like this so we use MurmurHash3 64bit finalizer to - // make it less biased - s[0] = avalance(dist(gen)); - s[1] = avalance(dist(gen)); - } + // the number generated by MT can be full of zeros and xorshift + // doesn't like this so we use MurmurHash3 64bit finalizer to + // make it less biased + s[0] = avalance(dist(gen)); + s[1] = avalance(dist(gen)); + } - uint64_t operator()() - { - uint64_t s1 = s[0]; - const uint64_t s0 = s[1]; + uint64_t operator()() { + uint64_t s1 = s[0]; + const uint64_t s0 = s[1]; - s[0] = s0; - s1 ^= s1 << 23; + s[0] = s0; + s1 ^= s1 << 23; - return (s[1] = (s1 ^ s0 ^ (s1 >> 17) ^ (s0 >> 26))) + s0; - } + return (s[1] = (s1 ^ s0 ^ (s1 >> 17) ^ (s0 >> 26))) + s0; + } -private: - uint64_t s[2]; + private: + uint64_t s[2]; - uint64_t avalance(uint64_t s) - { - // MurmurHash3 finalizer - s ^= s >> 33; - s *= 0xff51afd7ed558ccd; - s ^= s >> 33; - s *= 0xc4ceb9fe1a85ec53; - s ^= s >> 33; + uint64_t avalance(uint64_t s) { + // MurmurHash3 finalizer + s ^= s >> 33; + s *= 0xff51afd7ed558ccd; + s ^= s >> 33; + s *= 0xc4ceb9fe1a85ec53; + s ^= s >> 33; - return s; - } + return s; + } }; diff --git a/src/utils/reference_wrapper.hpp b/src/utils/reference_wrapper.hpp index 3aaedc04e..1721949f6 100644 --- a/src/utils/reference_wrapper.hpp +++ b/src/utils/reference_wrapper.hpp @@ -10,31 +10,30 @@ // this class should be deleted and replaced with std::reference_wrapper template <class T> -class ReferenceWrapper -{ -public: - // types - typedef T type; +class ReferenceWrapper { + public: + // types + typedef T type; - // construct/copy/destroy - ReferenceWrapper(T &ref) noexcept : _ptr(std::addressof(ref)) {} - ReferenceWrapper(T &&) = delete; - ReferenceWrapper(const ReferenceWrapper &) noexcept = default; + // construct/copy/destroy + ReferenceWrapper(T &ref) noexcept : _ptr(std::addressof(ref)) {} + ReferenceWrapper(T &&) = delete; + ReferenceWrapper(const ReferenceWrapper &) noexcept = default; - // assignment - ReferenceWrapper &operator=(const ReferenceWrapper &x) noexcept = default; + // assignment + ReferenceWrapper &operator=(const ReferenceWrapper &x) noexcept = default; - // access - operator T &() const noexcept { return *_ptr; } - T &get() const noexcept { return *_ptr; } + // access + operator T &() const noexcept { return *_ptr; } + T &get() const noexcept { return *_ptr; } - // template <class... ArgTypes> - // typename std::result_of<T &(ArgTypes &&...)>::type - // operator()(ArgTypes &&... args) const - // { - // return std::invoke(get(), std::forward<ArgTypes>(args)...); - // } + // template <class... ArgTypes> + // typename std::result_of<T &(ArgTypes &&...)>::type + // operator()(ArgTypes &&... args) const + // { + // return std::invoke(get(), std::forward<ArgTypes>(args)...); + // } -private: - T *_ptr; + private: + T *_ptr; }; diff --git a/src/utils/signals/handler.hpp b/src/utils/signals/handler.hpp index c9328b28d..2fef13266 100644 --- a/src/utils/signals/handler.hpp +++ b/src/utils/signals/handler.hpp @@ -10,38 +10,35 @@ using Function = std::function<void()>; // TODO: align bits so signals can be combined // Signal::Terminate | Signal::Interupt -enum class Signal : int -{ - Terminate = SIGTERM, - SegmentationFault = SIGSEGV, - Interupt = SIGINT, - Quit = SIGQUIT, - Abort = SIGABRT, - BusError = SIGBUS, +enum class Signal : int { + Terminate = SIGTERM, + SegmentationFault = SIGSEGV, + Interupt = SIGINT, + Quit = SIGQUIT, + Abort = SIGABRT, + BusError = SIGBUS, }; -class SignalHandler -{ -private: - static std::map<int, std::function<void()>> handlers_; +class SignalHandler { + private: + static std::map<int, std::function<void()>> handlers_; - static void handle(int signal) { handlers_[signal](); } + static void handle(int signal) { handlers_[signal](); } -public: - static void register_handler(Signal signal, Function func) - { - int signal_number = static_cast<int>(signal); - handlers_[signal_number] = func; - std::signal(signal_number, SignalHandler::handle); + public: + static void register_handler(Signal signal, Function func) { + int signal_number = static_cast<int>(signal); + handlers_[signal_number] = func; + std::signal(signal_number, SignalHandler::handle); + } + + // TODO possible changes if signelton needed later + /* + static SignalHandler& instance() { + static SignalHandler instance; + return instance; } - - // TODO possible changes if signelton needed later - /* - static SignalHandler& instance() { - static SignalHandler instance; - return instance; - } - */ + */ }; std::map<int, std::function<void()>> SignalHandler::handlers_ = {}; diff --git a/src/utils/stacktrace/log.hpp b/src/utils/stacktrace/log.hpp index 31f273f4f..5b176f3fb 100644 --- a/src/utils/stacktrace/log.hpp +++ b/src/utils/stacktrace/log.hpp @@ -3,9 +3,8 @@ #include "logging/default.hpp" #include "utils/stacktrace/stacktrace.hpp" -void log_stacktrace(const std::string& title) -{ - Stacktrace stacktrace; - logging::info(title); - logging::info(stacktrace.dump()); +void log_stacktrace(const std::string& title) { + Stacktrace stacktrace; + logging::info(title); + logging::info(stacktrace.dump()); } diff --git a/src/utils/stacktrace/stacktrace.hpp b/src/utils/stacktrace/stacktrace.hpp index e33050def..a29e85af6 100644 --- a/src/utils/stacktrace/stacktrace.hpp +++ b/src/utils/stacktrace/stacktrace.hpp @@ -7,97 +7,87 @@ #include "utils/auto_scope.hpp" -class Stacktrace -{ -public: - class Line - { - public: - Line(const std::string &original) : original(original) {} +class Stacktrace { + public: + class Line { + public: + Line(const std::string &original) : original(original) {} - Line(const std::string &original, const std::string &function, - const std::string &location) - : original(original), function(function), location(location) - { - } + Line(const std::string &original, const std::string &function, + const std::string &location) + : original(original), function(function), location(location) {} - std::string original, function, location; - }; + std::string original, function, location; + }; - static constexpr size_t stacktrace_depth = 128; + static constexpr size_t stacktrace_depth = 128; - Stacktrace() - { - void *addresses[stacktrace_depth]; - auto depth = backtrace(addresses, stacktrace_depth); + Stacktrace() { + void *addresses[stacktrace_depth]; + auto depth = backtrace(addresses, stacktrace_depth); - // will this leak if backtrace_symbols throws? - char **symbols = nullptr; - Auto(free(symbols)); + // will this leak if backtrace_symbols throws? + char **symbols = nullptr; + Auto(free(symbols)); - symbols = backtrace_symbols(addresses, depth); + symbols = backtrace_symbols(addresses, depth); - // skip the first one since it will be Stacktrace::Stacktrace() - for (int i = 1; i < depth; ++i) - lines.emplace_back(format(symbols[i])); + // skip the first one since it will be Stacktrace::Stacktrace() + for (int i = 1; i < depth; ++i) lines.emplace_back(format(symbols[i])); + } + + auto begin() { return lines.begin(); } + auto begin() const { return lines.begin(); } + auto cbegin() const { return lines.cbegin(); } + + auto end() { return lines.end(); } + auto end() const { return lines.end(); } + auto cend() const { return lines.cend(); } + + const Line &operator[](size_t idx) const { return lines[idx]; } + + size_t size() const { return lines.size(); } + + template <class Stream> + void dump(Stream &stream) { + stream << dump(); + } + + std::string dump() { + std::string message; + for (size_t i = 0; i < size(); i++) { + message.append( + fmt::format("at {} ({}) \n", lines[i].function, lines[i].location)); } + return message; + } - auto begin() { return lines.begin(); } - auto begin() const { return lines.begin(); } - auto cbegin() const { return lines.cbegin(); } + private: + std::vector<Line> lines; - auto end() { return lines.end(); } - auto end() const { return lines.end(); } - auto cend() const { return lines.cend(); } + Line format(const std::string &original) { + using namespace abi; + auto line = original; - const Line &operator[](size_t idx) const { return lines[idx]; } + auto begin = line.find('('); + auto end = line.find('+'); - size_t size() const { return lines.size(); } + if (begin == std::string::npos || end == std::string::npos) + return {original}; - template <class Stream> - void dump(Stream &stream) - { - stream << dump(); - } + line[end] = '\0'; - std::string dump() - { - std::string message; - for (size_t i = 0; i < size(); i++) - { - message.append(fmt::format("at {} ({}) \n", lines[i].function, - lines[i].location)); - } - return message; - } + int s; + auto demangled = + __cxa_demangle(line.data() + begin + 1, nullptr, nullptr, &s); -private: - std::vector<Line> lines; + auto location = line.substr(0, begin); - Line format(const std::string &original) - { - using namespace abi; - auto line = original; + auto function = + demangled + ? std::string(demangled) + : fmt::format("{}()", original.substr(begin + 1, end - begin - 1)); - auto begin = line.find('('); - auto end = line.find('+'); - - if (begin == std::string::npos || end == std::string::npos) - return {original}; - - line[end] = '\0'; - - int s; - auto demangled = - __cxa_demangle(line.data() + begin + 1, nullptr, nullptr, &s); - - auto location = line.substr(0, begin); - - auto function = - demangled ? std::string(demangled) - : fmt::format("{}()", original.substr(begin + 1, - end - begin - 1)); - - return {original, function, location}; - } + return {original, function, location}; + } }; diff --git a/src/utils/stream_wrapper.hpp b/src/utils/stream_wrapper.hpp index 1f64bf093..4581ae8c0 100644 --- a/src/utils/stream_wrapper.hpp +++ b/src/utils/stream_wrapper.hpp @@ -3,22 +3,19 @@ // Wraps stream with convinient methods which need only one method: // write (const char* s, n); template <class STREAM> -class StreamWrapper -{ -public: - StreamWrapper() = delete; - StreamWrapper(STREAM &s) : stream(s) {} +class StreamWrapper { + public: + StreamWrapper() = delete; + StreamWrapper(STREAM &s) : stream(s) {} - void write(const unsigned char value) - { - stream.write(reinterpret_cast<const char *>(&value), 1); - } + void write(const unsigned char value) { + stream.write(reinterpret_cast<const char *>(&value), 1); + } - void write(const unsigned char *value, size_t n) - { - stream.write(reinterpret_cast<const char *>(value), n); - } + void write(const unsigned char *value, size_t n) { + stream.write(reinterpret_cast<const char *>(value), n); + } -private: - STREAM &stream; + private: + STREAM &stream; }; diff --git a/src/utils/string/all.hpp b/src/utils/string/all.hpp index 7c8252b79..24cee618f 100644 --- a/src/utils/string/all.hpp +++ b/src/utils/string/all.hpp @@ -1,6 +1,6 @@ #pragma once #include "intercalate.hpp" +#include "linereader.hpp" #include "replace.hpp" #include "split.hpp" -#include "linereader.hpp" diff --git a/src/utils/string/file.hpp b/src/utils/string/file.hpp index 22c19c4c5..3fd1ae509 100644 --- a/src/utils/string/file.hpp +++ b/src/utils/string/file.hpp @@ -13,45 +13,42 @@ #include <experimental/filesystem> namespace fs = std::experimental::filesystem; -namespace utils -{ +namespace utils { /* * Type safe text object. */ -class Text -{ -public: - Text() = default; - explicit Text(const std::string &text) : text_(text) {} +class Text { + public: + Text() = default; + explicit Text(const std::string& text) : text_(text) {} - // text could be huge and copy operationt would be too expensive - Text(const Text& other) = delete; - Text& operator=(const Text& other) = delete; + // text could be huge and copy operationt would be too expensive + Text(const Text& other) = delete; + Text& operator=(const Text& other) = delete; - // the object is movable - Text (Text&& other) = default; - Text& operator=(Text&& other) - { - text_ = std::move(other.text_); - return *this; - } + // the object is movable + Text(Text&& other) = default; + Text& operator=(Text&& other) { + text_ = std::move(other.text_); + return *this; + } - const std::string &str() const { return text_; } + const std::string& str() const { return text_; } -private: - std::string text_; + private: + std::string text_; }; /* * Reads the whole text from a file at the path. */ -Text read_text(const fs::path &path); +Text read_text(const fs::path& path); /* * Reads all the lines from a file at the path. */ -std::vector<std::string> read_lines(const fs::path &path); +std::vector<std::string> read_lines(const fs::path& path); // TODO: lazy implementation of read_lines functionality (line by line) @@ -60,6 +57,5 @@ std::vector<std::string> read_lines(const fs::path &path); /* * Write text in a file at the path. */ -void write(const Text &text, const fs::path &path); - +void write(const Text& text, const fs::path& path); } diff --git a/src/utils/string/intercalate.hpp b/src/utils/string/intercalate.hpp index b575a2064..c6c8aaa60 100644 --- a/src/utils/string/intercalate.hpp +++ b/src/utils/string/intercalate.hpp @@ -3,27 +3,21 @@ #include <sstream> #include <string> -namespace utils -{ +namespace utils { template <typename It> -std::string intercalate(It first, It last, - const std::string& separator) -{ - if(first == last) - return ""; +std::string intercalate(It first, It last, const std::string& separator) { + if (first == last) return ""; - std::stringstream ss; - It second(first); + std::stringstream ss; + It second(first); - // append the first N-1 elements with a separator - for(second++; second != last; ++first, ++second) - ss << *first << separator; + // append the first N-1 elements with a separator + for (second++; second != last; ++first, ++second) ss << *first << separator; - // append the last element - ss << *first; + // append the last element + ss << *first; - return ss.str(); + return ss.str(); } - } diff --git a/src/utils/string/join.hpp b/src/utils/string/join.hpp index 509c080af..b61dd22aa 100644 --- a/src/utils/string/join.hpp +++ b/src/utils/string/join.hpp @@ -1,21 +1,18 @@ #pragma once +#include <iterator> +#include <sstream> #include <string> #include <vector> -#include <sstream> -#include <iterator> -namespace utils -{ +namespace utils { std::string join(const std::vector<std::string>& strings, - const char *separator); + const char* separator); -template<typename... Args> -std::string prints(const Args&... args) -{ - std::vector<std::string> strings = {args...}; - return join(strings, " "); +template <typename... Args> +std::string prints(const Args&... args) { + std::vector<std::string> strings = {args...}; + return join(strings, " "); } - } diff --git a/src/utils/string/linereader.hpp b/src/utils/string/linereader.hpp index e9427a5b2..226261420 100644 --- a/src/utils/string/linereader.hpp +++ b/src/utils/string/linereader.hpp @@ -1,32 +1,27 @@ #pragma once -#include <functional> #include <fstream> +#include <functional> #include <string> -namespace utils -{ +namespace utils { void linereader(std::istream& stream, - std::function<void(const std::string&)> cb) -{ - std::string line; + std::function<void(const std::string&)> cb) { + std::string line; - while(std::getline(stream, line)) - cb(line); + while (std::getline(stream, line)) cb(line); } void linereader(const std::string& filename, - std::function<void(const std::string&)> cb) -{ - std::fstream fs(filename.c_str()); + std::function<void(const std::string&)> cb) { + std::fstream fs(filename.c_str()); - // should this throw an error? figure out how to handle this TODO + // should this throw an error? figure out how to handle this TODO - if(fs.is_open() == false) - throw std::runtime_error("[ERROR] can't open file " + filename); + if (fs.is_open() == false) + throw std::runtime_error("[ERROR] can't open file " + filename); - linereader(fs, cb); + linereader(fs, cb); } - } diff --git a/src/utils/string/replace.hpp b/src/utils/string/replace.hpp index 7c4b98645..ed09a8b7a 100644 --- a/src/utils/string/replace.hpp +++ b/src/utils/string/replace.hpp @@ -2,21 +2,16 @@ #include <string> -namespace utils -{ +namespace utils { // replaces all occurences of <match> in <src> with <replacement> -std::string replace(std::string src, - const std::string& match, - const std::string& replacement) -{ - for(size_t pos = src.find(match); - pos != std::string::npos; - pos = src.find(match, pos + replacement.size())) - src.erase(pos, match.length()).insert(pos, replacement); +std::string replace(std::string src, const std::string& match, + const std::string& replacement) { + for (size_t pos = src.find(match); pos != std::string::npos; + pos = src.find(match, pos + replacement.size())) + src.erase(pos, match.length()).insert(pos, replacement); - return src; + return src; } - } diff --git a/src/utils/string/split.hpp b/src/utils/string/split.hpp index 2ad40d6ea..7851ed9ec 100644 --- a/src/utils/string/split.hpp +++ b/src/utils/string/split.hpp @@ -1,42 +1,35 @@ #pragma once -#include <vector> #include <regex> +#include <vector> -namespace utils -{ +namespace utils { std::vector<std::string> split(const std::string& src, - const std::string& delimiter) -{ - size_t index = 0; - std::vector<std::string> res; - size_t n = src.find(delimiter, index); + const std::string& delimiter) { + size_t index = 0; + std::vector<std::string> res; + size_t n = src.find(delimiter, index); - while(n != std::string::npos) - { - n = src.find(delimiter, index); - res.push_back(src.substr(index, n - index)); - index = n + delimiter.size(); - } + while (n != std::string::npos) { + n = src.find(delimiter, index); + res.push_back(src.substr(index, n - index)); + index = n + delimiter.size(); + } - return res; + return res; } - // doesn't work with gcc even though it's only c++11... // and it's slow as hell compared to the split implementation above // (more powerful though) std::vector<std::string> regex_split(const std::string& input, - const std::string& regex) -{ - auto rgx = std::regex(regex); + const std::string& regex) { + auto rgx = std::regex(regex); - std::sregex_token_iterator last, first - { input.begin(), input.end(), rgx, -1}; - - return { first, last }; -} + std::sregex_token_iterator last, first{input.begin(), input.end(), rgx, -1}; + return {first, last}; +} } diff --git a/src/utils/string/streq.hpp b/src/utils/string/streq.hpp index 071cfaa85..a86cfc421 100644 --- a/src/utils/string/streq.hpp +++ b/src/utils/string/streq.hpp @@ -2,36 +2,28 @@ #include <x86intrin.h> -namespace sse42 -{ -constexpr int strcmp_mode = _SIDD_CMP_EQUAL_EACH - | _SIDD_NEGATIVE_POLARITY; +namespace sse42 { +constexpr int strcmp_mode = _SIDD_CMP_EQUAL_EACH | _SIDD_NEGATIVE_POLARITY; constexpr unsigned CF = 0x1; constexpr unsigned ZF = 0x40; -bool streq(const char* lhs, const char* rhs) -{ - int idx, eflags; +bool streq(const char* lhs, const char* rhs) { + int idx, eflags; - while(true) - { - auto lhs_mm = _mm_loadu_si128((__m128i*)lhs); - auto rhs_mm = _mm_loadu_si128((__m128i*)rhs); + while (true) { + auto lhs_mm = _mm_loadu_si128((__m128i*)lhs); + auto rhs_mm = _mm_loadu_si128((__m128i*)rhs); - idx = _mm_cmpistri(lhs_mm, rhs_mm, strcmp_mode); - eflags = __readeflags(); + idx = _mm_cmpistri(lhs_mm, rhs_mm, strcmp_mode); + eflags = __readeflags(); - if(idx != 0x10) - return false; + if (idx != 0x10) return false; - if((eflags & (ZF | CF)) != 0) - return true; + if ((eflags & (ZF | CF)) != 0) return true; - lhs += 16; - rhs += 16; - } + lhs += 16; + rhs += 16; + } } - } - diff --git a/src/utils/string/transform.hpp b/src/utils/string/transform.hpp index 84f84aab3..21eea998e 100644 --- a/src/utils/string/transform.hpp +++ b/src/utils/string/transform.hpp @@ -1,12 +1,10 @@ #pragma once -#include <string> -#include <locale> #include <algorithm> +#include <locale> +#include <string> -namespace utils -{ +namespace utils { void str_tolower(std::string& s); - } diff --git a/src/utils/string/trim.hpp b/src/utils/string/trim.hpp index 21a72296f..09cb6d341 100644 --- a/src/utils/string/trim.hpp +++ b/src/utils/string/trim.hpp @@ -2,8 +2,7 @@ #include <string> -namespace utils -{ +namespace utils { /** * Removes whitespace characters from the start and from the end of a string. @@ -12,14 +11,12 @@ namespace utils * * @return trimmed string */ -std::string trim(const std::string &str) -{ - size_t first = str.find_first_not_of(' '); - if (std::string::npos == first) - { - return str; - } - size_t last = str.find_last_not_of(' '); - return str.substr(first, (last - first + 1)); +std::string trim(const std::string &str) { + size_t first = str.find_first_not_of(' '); + if (std::string::npos == first) { + return str; + } + size_t last = str.find_last_not_of(' '); + return str.substr(first, (last - first + 1)); } } diff --git a/src/utils/string/weak_string.hpp b/src/utils/string/weak_string.hpp index f3ebdc8a3..1f1e2d2c5 100644 --- a/src/utils/string/weak_string.hpp +++ b/src/utils/string/weak_string.hpp @@ -1,85 +1,62 @@ #pragma once -#include <cstring> #include <cassert> +#include <cstring> #include <string> #include "utils/total_ordering.hpp" #include "utils/total_ordering_with.hpp" -class WeakString -{ -public: - constexpr WeakString() : str(nullptr), len(0) {} +class WeakString { + public: + constexpr WeakString() : str(nullptr), len(0) {} - WeakString(const std::string& str) : str(str.c_str()), len(str.size()) {} + WeakString(const std::string& str) : str(str.c_str()), len(str.size()) {} - WeakString(const char* str) : str(str), len(strlen(str)) {} + WeakString(const char* str) : str(str), len(strlen(str)) {} - constexpr WeakString(const char* str, size_t len) : str(str), len(len) {} + constexpr WeakString(const char* str, size_t len) : str(str), len(len) {} - const char& operator[](size_t idx) const - { - assert(idx < len); - return str[idx]; - } + const char& operator[](size_t idx) const { + assert(idx < len); + return str[idx]; + } - const char& front() const - { - assert(len > 0); - return str[0]; - } + const char& front() const { + assert(len > 0); + return str[0]; + } - const char& back() const - { - assert(len > 0); - return str[len - 1]; - } + const char& back() const { + assert(len > 0); + return str[len - 1]; + } - const char* data() const - { - return str; - } + const char* data() const { return str; } - bool empty() const - { - return len == 0; - } + bool empty() const { return len == 0; } - size_t size() const - { - return len; - } + size_t size() const { return len; } - size_t length() const - { - return size(); - } + size_t length() const { return size(); } - std::string to_string() const - { - return std::string(str, len); - } + std::string to_string() const { return std::string(str, len); } - friend bool operator==(const WeakString& lhs, const WeakString rhs) - { - // oh dear god, make this better with custom iterators - if(lhs.size() != rhs.size()) - return false; + friend bool operator==(const WeakString& lhs, const WeakString rhs) { + // oh dear god, make this better with custom iterators + if (lhs.size() != rhs.size()) return false; - for(size_t i = 0; i < lhs.size(); ++i) - if(lhs[i] != rhs[i]) - return false; + for (size_t i = 0; i < lhs.size(); ++i) + if (lhs[i] != rhs[i]) return false; - return true; - } + return true; + } - friend bool operator!=(const WeakString& lhs, const WeakString& rhs) - { - return !(lhs == rhs); - } + friend bool operator!=(const WeakString& lhs, const WeakString& rhs) { + return !(lhs == rhs); + } -private: - const char* str; - size_t len; + private: + const char* str; + size_t len; }; diff --git a/src/utils/string_buffer.hpp b/src/utils/string_buffer.hpp index f18ad5c3d..73cbdacdb 100644 --- a/src/utils/string_buffer.hpp +++ b/src/utils/string_buffer.hpp @@ -2,53 +2,41 @@ #include <string> -namespace utils -{ +namespace utils { -class StringBuffer -{ -public: - StringBuffer() = default; - ~StringBuffer() = default; +class StringBuffer { + public: + StringBuffer() = default; + ~StringBuffer() = default; - StringBuffer(const StringBuffer &) = delete; - StringBuffer(StringBuffer &&) = default; + StringBuffer(const StringBuffer &) = delete; + StringBuffer(StringBuffer &&) = default; - StringBuffer &operator=(const StringBuffer &) = delete; - StringBuffer &operator=(StringBuffer &&) = default; + StringBuffer &operator=(const StringBuffer &) = delete; + StringBuffer &operator=(StringBuffer &&) = default; - StringBuffer(std::string::size_type count) - { - resize(count); - } + StringBuffer(std::string::size_type count) { resize(count); } - void resize(std::string::size_type count) - { - data.resize(count); - } + void resize(std::string::size_type count) { data.resize(count); } - StringBuffer &operator<<(const std::string &str) - { - data += str; - return *this; - } + StringBuffer &operator<<(const std::string &str) { + data += str; + return *this; + } - StringBuffer &operator<<(const char *str) - { - data += str; - return *this; - } + StringBuffer &operator<<(const char *str) { + data += str; + return *this; + } - StringBuffer &operator<<(char c) - { - data += c; - return *this; - } + StringBuffer &operator<<(char c) { + data += c; + return *this; + } - std::string &str() { return data; } + std::string &str() { return data; } -private: - std::string data; + private: + std::string data; }; - } diff --git a/src/utils/sys.hpp b/src/utils/sys.hpp index 68ac30e6e..59bdaa4d4 100644 --- a/src/utils/sys.hpp +++ b/src/utils/sys.hpp @@ -1,8 +1,6 @@ #pragma once -#include <cassert> #include <errno.h> -#include <fstream> #include <linux/futex.h> #include <stdio.h> #include <sys/stat.h> @@ -10,50 +8,46 @@ #include <sys/time.h> #include <sys/types.h> #include <unistd.h> +#include <cassert> +#include <fstream> -namespace sys -{ +namespace sys { // Code from stackoverflow: // http://stackoverflow.com/questions/676787/how-to-do-fsync-on-an-ofstream // Extracts FILE* from streams in std. -inline int GetFileDescriptor(std::filebuf &filebuf) -{ - class my_filebuf : public std::filebuf - { - public: - int handle() { return _M_file.fd(); } - }; +inline int GetFileDescriptor(std::filebuf &filebuf) { + class my_filebuf : public std::filebuf { + public: + int handle() { return _M_file.fd(); } + }; - return static_cast<my_filebuf &>(filebuf).handle(); + return static_cast<my_filebuf &>(filebuf).handle(); } inline int futex(void *addr1, int op, int val1, const struct timespec *timeout, - void *addr2, int val3) -{ - return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3); + void *addr2, int val3) { + return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3); }; // Ensures that everything written to file will be writen on disk when the // function call returns. !=0 if error occured template <class STREAM> -inline size_t flush_file_to_disk(STREAM &file) -{ - file.flush(); - if (fsync(GetFileDescriptor(*file.rdbuf())) == 0) { - return 0; - } +inline size_t flush_file_to_disk(STREAM &file) { + file.flush(); + if (fsync(GetFileDescriptor(*file.rdbuf())) == 0) { + return 0; + } - return errno; + return errno; }; // True if succesffull -inline bool ensure_directory_exists(std::string const &path) -{ - struct stat st = {0}; +inline bool ensure_directory_exists(std::string const &path) { + struct stat st = {0}; - if (stat(path.c_str(), &st) == -1) { - return mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0; - } - return true; + if (stat(path.c_str(), &st) == -1) { + return mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0; + } + return true; } }; diff --git a/src/utils/sysinfo/memory.hpp b/src/utils/sysinfo/memory.hpp index d635c41f7..74f5450f2 100644 --- a/src/utils/sysinfo/memory.hpp +++ b/src/utils/sysinfo/memory.hpp @@ -7,24 +7,22 @@ #include "sys/sysinfo.h" #include "sys/types.h" -auto total_virtual_memory() -{ - struct sysinfo mem_info; - sysinfo(&mem_info); - long long total_virtual_memory = mem_info.totalram; - total_virtual_memory += mem_info.totalswap; - total_virtual_memory *= mem_info.mem_unit; - return total_virtual_memory; +auto total_virtual_memory() { + struct sysinfo mem_info; + sysinfo(&mem_info); + long long total_virtual_memory = mem_info.totalram; + total_virtual_memory += mem_info.totalswap; + total_virtual_memory *= mem_info.mem_unit; + return total_virtual_memory; } -auto used_virtual_memory() -{ - struct sysinfo mem_info; - sysinfo(&mem_info); - long long virtual_memory_used = mem_info.totalram - mem_info.freeram; - virtual_memory_used += mem_info.totalswap - mem_info.freeswap; - virtual_memory_used *= mem_info.mem_unit; - return virtual_memory_used; +auto used_virtual_memory() { + struct sysinfo mem_info; + sysinfo(&mem_info); + long long virtual_memory_used = mem_info.totalram - mem_info.freeram; + virtual_memory_used += mem_info.totalswap - mem_info.freeswap; + virtual_memory_used *= mem_info.mem_unit; + return virtual_memory_used; } // TODO: OS dependent @@ -32,36 +30,31 @@ auto used_virtual_memory() /** * parses memory line from /proc/self/status */ -auto parse_vm_size(char *line) -{ - // This assumes that a digit will be found and the line ends in " Kb". - auto i = std::strlen(line); - const char *p = line; - while (*p < '0' || *p > '9') - p++; - line[i - 3] = '\0'; - return std::atoll(p); +auto parse_vm_size(char *line) { + // This assumes that a digit will be found and the line ends in " Kb". + auto i = std::strlen(line); + const char *p = line; + while (*p < '0' || *p > '9') p++; + line[i - 3] = '\0'; + return std::atoll(p); } /** * returns VmSize in kB */ -auto vm_size() -{ - std::FILE *file = std::fopen("/proc/self/status", "r"); - auto result = -1LL; - char line[128]; +auto vm_size() { + std::FILE *file = std::fopen("/proc/self/status", "r"); + auto result = -1LL; + char line[128]; - while (fgets(line, 128, file) != NULL) - { - if (strncmp(line, "VmSize:", 7) == 0) - { - result = parse_vm_size(line); - break; - } + while (fgets(line, 128, file) != NULL) { + if (strncmp(line, "VmSize:", 7) == 0) { + result = parse_vm_size(line); + break; } + } - fclose(file); + fclose(file); - return result; + return result; } diff --git a/src/utils/terminate_handler.hpp b/src/utils/terminate_handler.hpp index c24e1a27f..79a2d9481 100644 --- a/src/utils/terminate_handler.hpp +++ b/src/utils/terminate_handler.hpp @@ -7,28 +7,22 @@ #include <iostream> // TODO: log to local file or remote database -void stacktrace(std::ostream &stream) noexcept -{ - Stacktrace stacktrace; - stacktrace.dump(stream); +void stacktrace(std::ostream &stream) noexcept { + Stacktrace stacktrace; + stacktrace.dump(stream); } // TODO: log to local file or remote database -void terminate_handler(std::ostream &stream) noexcept -{ - if (auto exc = std::current_exception()) - { - try - { - std::rethrow_exception(exc); - } - catch (std::exception &ex) - { - stream << ex.what() << std::endl << std::endl; - stacktrace(stream); - } +void terminate_handler(std::ostream &stream) noexcept { + if (auto exc = std::current_exception()) { + try { + std::rethrow_exception(exc); + } catch (std::exception &ex) { + stream << ex.what() << std::endl << std::endl; + stacktrace(stream); } - std::abort(); + } + std::abort(); } void terminate_handler() noexcept { terminate_handler(std::cout); } diff --git a/src/utils/time/timer.hpp b/src/utils/time/timer.hpp index 6a69ab47d..7579ec1c9 100644 --- a/src/utils/time/timer.hpp +++ b/src/utils/time/timer.hpp @@ -9,59 +9,43 @@ #define time_now() std::chrono::high_resolution_clock::now() template <typename DurationUnit = std::chrono::nanoseconds> -auto to_duration(const std::chrono::duration<long, std::nano> &delta) -{ - return std::chrono::duration_cast<DurationUnit>(delta).count(); +auto to_duration(const std::chrono::duration<long, std::nano> &delta) { + return std::chrono::duration_cast<DurationUnit>(delta).count(); } template <typename DurationUnit, typename F, typename... Args> -auto timer(F func, Args &&... args) -{ - auto start_time = time_now(); - func(std::forward<Args>(args)...); - return to_duration<DurationUnit>(time_now() - start_time); +auto timer(F func, Args &&... args) { + auto start_time = time_now(); + func(std::forward<Args>(args)...); + return to_duration<DurationUnit>(time_now() - start_time); } // idea from Optimized C++ Kurt Guntheroth 2016 // TODO: make more modular and easier to use -class Stopwatch -{ -public: - Stopwatch() : start(std::chrono::system_clock::time_point::min()) {} +class Stopwatch { + public: + Stopwatch() : start(std::chrono::system_clock::time_point::min()) {} - void Clear() - { - start = std::chrono::system_clock::time_point::min(); + void Clear() { start = std::chrono::system_clock::time_point::min(); } + + bool IsStarted() const { + return (start != std::chrono::system_clock::time_point::min()); + } + + void Start() { start = std::chrono::system_clock::now(); } + + unsigned long GetMs() { + if (IsStarted()) { + std::chrono::system_clock::duration diff; + diff = std::chrono::system_clock::now() - start; + return (unsigned)(std::chrono::duration_cast<ms>(diff).count()); } - bool IsStarted() const - { - return (start != std::chrono::system_clock::time_point::min()); - } + return 0; + } - void Start() - { - start = std::chrono::system_clock::now(); - } - - unsigned long GetMs() - { - if (IsStarted()) - { - std::chrono::system_clock::duration diff; - diff = std::chrono::system_clock::now() - start; - return (unsigned) (std::chrono::duration_cast<ms>(diff).count()); - } - - return 0; - } - - ~Stopwatch() - { - std::cout << "Time: " << GetMs() << "ms" << std::endl; - } - -private: - std::chrono::system_clock::time_point start; + ~Stopwatch() { std::cout << "Time: " << GetMs() << "ms" << std::endl; } + private: + std::chrono::system_clock::time_point start; }; diff --git a/src/utils/timer/timer.hpp b/src/utils/timer/timer.hpp index 39b10f7b9..cea9ea30d 100644 --- a/src/utils/timer/timer.hpp +++ b/src/utils/timer/timer.hpp @@ -1,10 +1,10 @@ #pragma once -#include <set> -#include <memory> -#include <chrono> -#include <thread> #include <atomic> +#include <chrono> +#include <memory> +#include <set> +#include <thread> #include "logging/default.hpp" @@ -18,26 +18,22 @@ * near future. The handler is function that will be called when counter * becomes zero or smaller than zero. */ -struct Timer -{ - using sptr = std::shared_ptr<Timer>; - using handler_t = std::function<void(void)>; +struct Timer { + using sptr = std::shared_ptr<Timer>; + using handler_t = std::function<void(void)>; - Timer(int64_t counter, handler_t handler): - counter(counter), handler(handler) - { - } + Timer(int64_t counter, handler_t handler) + : counter(counter), handler(handler) {} - bool operator--() - { - if (--counter <= 0) - return true; - else - return false; - } + bool operator--() { + if (--counter <= 0) + return true; + else + return false; + } - int64_t counter; - handler_t handler; + int64_t counter; + handler_t handler; }; /** @@ -50,7 +46,7 @@ struct Timer * the process method. */ -/** +/** * @class TimerSet * * @brief Trivial timer container implementation. @@ -61,129 +57,97 @@ struct Timer * deletion: O(log(n)) * process: O(n) */ -class TimerSet -{ -public: - void add(Timer::sptr timer) - { - timers.insert(timer); - } +class TimerSet { + public: + void add(Timer::sptr timer) { timers.insert(timer); } - void remove(Timer::sptr timer) - { - timers.erase(timer); - } + void remove(Timer::sptr timer) { timers.erase(timer); } - uint64_t size() const - { - return timers.size(); - } + uint64_t size() const { return timers.size(); } - void process() - { - for (auto it = timers.begin(); it != timers.end(); ) { - auto timer = *it; - if (--*timer) { - timer->handler(); - it = timers.erase(it); - continue; - } - ++it; - } + void process() { + for (auto it = timers.begin(); it != timers.end();) { + auto timer = *it; + if (--*timer) { + timer->handler(); + it = timers.erase(it); + continue; + } + ++it; } + } -private: - std::set<std::shared_ptr<Timer>> timers; + private: + std::set<std::shared_ptr<Timer>> timers; }; -/** +/** * @class TimerScheduler * * @brief TimerScheduler is a manager class and its responsibility is to * take care of the time and call the timer_container process method in the * appropriate time. * - * @tparam timer_container_type implements a strategy how the timers + * @tparam timer_container_type implements a strategy how the timers * are processed * @tparam delta_time_type type of a time distance between two events * @tparam delta_time granularity between the two events, default value is 1 */ -template < - typename timer_container_type, - typename delta_time_type, - uint64_t delta_time = 1 -> class TimerScheduler -{ -public: +template <typename timer_container_type, typename delta_time_type, + uint64_t delta_time = 1> +class TimerScheduler { + public: + /** + * Adds a timer. + * + * @param timer shared pointer to the timer object \ref Timer + */ + void add(Timer::sptr timer) { timer_container.add(timer); } - /** - * Adds a timer. - * - * @param timer shared pointer to the timer object \ref Timer - */ - void add(Timer::sptr timer) - { - timer_container.add(timer); - } + /** + * Removes a timer. + * + * @param timer shared pointer to the timer object \ref Timer + */ + void remove(Timer::sptr timer) { timer_container.remove(timer); } - /** - * Removes a timer. - * - * @param timer shared pointer to the timer object \ref Timer - */ - void remove(Timer::sptr timer) - { - timer_container.remove(timer); - } + /** + * Provides the number of pending timers. The exact number has to be + * provided by a timer_container. + * + * @return uint64_t the number of pending timers. + */ + uint64_t size() const { return timer_container.size(); } - /** - * Provides the number of pending timers. The exact number has to be - * provided by a timer_container. - * - * @return uint64_t the number of pending timers. - */ - uint64_t size() const - { - return timer_container.size(); - } + /** + * Runs a separate thread which responsibility is to run the process method + * at the appropriate time (every delta_time from the beginning of + * processing. + */ + void run() { + is_running.store(true); - /** - * Runs a separate thread which responsibility is to run the process method - * at the appropriate time (every delta_time from the beginning of - * processing. - */ - void run() - { - is_running.store(true); + run_thread = std::thread([this]() { + while (is_running.load()) { + std::this_thread::sleep_for(delta_time_type(delta_time)); + timer_container.process(); + logging::info("timer_container.process()"); + } + }); + } - run_thread = std::thread([this]() { - while (is_running.load()) { - std::this_thread::sleep_for(delta_time_type(delta_time)); - timer_container.process(); - logging::info("timer_container.process()"); - } - }); - } + /** + * Stops the whole processing. + */ + void stop() { is_running.store(false); } - /** - * Stops the whole processing. - */ - void stop() - { - is_running.store(false); - } + /** + * Joins the processing thread. + */ + ~TimerScheduler() { run_thread.join(); } - /** - * Joins the processing thread. - */ - ~TimerScheduler() - { - run_thread.join(); - } - - -private: - timer_container_type timer_container; - std::thread run_thread; - std::atomic<bool> is_running; + private: + timer_container_type timer_container; + std::thread run_thread; + std::atomic<bool> is_running; }; diff --git a/src/utils/total_ordering.hpp b/src/utils/total_ordering.hpp index 8dd4ca785..5a54a417d 100644 --- a/src/utils/total_ordering.hpp +++ b/src/utils/total_ordering.hpp @@ -9,7 +9,7 @@ * as first operand. * @tparam TReturn Return type, defaults to bool. */ -template<typename TLhs, typename TRhs=TLhs, typename TReturn=bool> +template <typename TLhs, typename TRhs = TLhs, typename TReturn = bool> struct TotalOrdering { friend constexpr TReturn operator!=(const TLhs &a, const TRhs &b) { return !(a == b); diff --git a/src/utils/total_ordering_with.hpp b/src/utils/total_ordering_with.hpp index 328e421ec..de5bdd0cd 100644 --- a/src/utils/total_ordering_with.hpp +++ b/src/utils/total_ordering_with.hpp @@ -1,45 +1,36 @@ #pragma once template <class Derived, class T> -struct TotalOrderingWith -{ - friend constexpr bool operator!=(const Derived& a, const T& b) - { - return !(a == b); - } +struct TotalOrderingWith { + friend constexpr bool operator!=(const Derived& a, const T& b) { + return !(a == b); + } - friend constexpr bool operator<=(const Derived& a, const T& b) - { - return a < b || a == b; - } + friend constexpr bool operator<=(const Derived& a, const T& b) { + return a < b || a == b; + } - friend constexpr bool operator>(const Derived& a, const T& b) - { - return !(a <= b); - } + friend constexpr bool operator>(const Derived& a, const T& b) { + return !(a <= b); + } - friend constexpr bool operator>=(const Derived& a, const T& b) - { - return !(a < b); - } + friend constexpr bool operator>=(const Derived& a, const T& b) { + return !(a < b); + } - friend constexpr bool operator!=(const T& a, const Derived& b) - { - return !(a == b); - } + friend constexpr bool operator!=(const T& a, const Derived& b) { + return !(a == b); + } - friend constexpr bool operator<=(const T& a, const Derived& b) - { - return a < b || a == b; - } + friend constexpr bool operator<=(const T& a, const Derived& b) { + return a < b || a == b; + } - friend constexpr bool operator>(const T& a, const Derived& b) - { - return !(a <= b); - } + friend constexpr bool operator>(const T& a, const Derived& b) { + return !(a <= b); + } - friend constexpr bool operator>=(const T& a, const Derived& b) - { - return !(a < b); - } + friend constexpr bool operator>=(const T& a, const Derived& b) { + return !(a < b); + } }; diff --git a/src/utils/type_discovery.hpp b/src/utils/type_discovery.hpp index 287de7b16..cba671473 100644 --- a/src/utils/type_discovery.hpp +++ b/src/utils/type_discovery.hpp @@ -2,104 +2,91 @@ // USAGE: // type_name<decltype(variable)>(); -// current solution has been taken from http://stackoverflow.com/questions/81870/is-it-possible-to-print-a-variables-type-in-standard-c +// current solution has been taken from +// http://stackoverflow.com/questions/81870/is-it-possible-to-print-a-variables-type-in-standard-c // TODO: create more appropriate solution #include <cstddef> -#include <stdexcept> #include <cstring> #include <ostream> +#include <stdexcept> #ifndef _MSC_VER -# if __cplusplus < 201103 -# define CONSTEXPR11_TN -# define CONSTEXPR14_TN -# define NOEXCEPT_TN -# elif __cplusplus < 201402 -# define CONSTEXPR11_TN constexpr -# define CONSTEXPR14_TN -# define NOEXCEPT_TN noexcept -# else -# define CONSTEXPR11_TN constexpr -# define CONSTEXPR14_TN constexpr -# define NOEXCEPT_TN noexcept -# endif +#if __cplusplus < 201103 +#define CONSTEXPR11_TN +#define CONSTEXPR14_TN +#define NOEXCEPT_TN +#elif __cplusplus < 201402 +#define CONSTEXPR11_TN constexpr +#define CONSTEXPR14_TN +#define NOEXCEPT_TN noexcept +#else +#define CONSTEXPR11_TN constexpr +#define CONSTEXPR14_TN constexpr +#define NOEXCEPT_TN noexcept +#endif #else // _MSC_VER -# if _MSC_VER < 1900 -# define CONSTEXPR11_TN -# define CONSTEXPR14_TN -# define NOEXCEPT_TN -# elif _MSC_VER < 2000 -# define CONSTEXPR11_TN constexpr -# define CONSTEXPR14_TN -# define NOEXCEPT_TN noexcept -# else -# define CONSTEXPR11_TN constexpr -# define CONSTEXPR14_TN constexpr -# define NOEXCEPT_TN noexcept -# endif +#if _MSC_VER < 1900 +#define CONSTEXPR11_TN +#define CONSTEXPR14_TN +#define NOEXCEPT_TN +#elif _MSC_VER < 2000 +#define CONSTEXPR11_TN constexpr +#define CONSTEXPR14_TN +#define NOEXCEPT_TN noexcept +#else +#define CONSTEXPR11_TN constexpr +#define CONSTEXPR14_TN constexpr +#define NOEXCEPT_TN noexcept +#endif #endif // _MSC_VER -class static_string -{ - const char* const p_; - const std::size_t sz_; +class static_string { + const char* const p_; + const std::size_t sz_; -public: - typedef const char* const_iterator; + public: + typedef const char* const_iterator; - template <std::size_t N> - CONSTEXPR11_TN static_string(const char(&a)[N]) NOEXCEPT_TN - : p_(a) - , sz_(N-1) - {} + template <std::size_t N> + CONSTEXPR11_TN static_string(const char (&a)[N]) NOEXCEPT_TN : p_(a), + sz_(N - 1) {} - CONSTEXPR11_TN static_string(const char* p, std::size_t N) NOEXCEPT_TN - : p_(p) - , sz_(N) - {} + CONSTEXPR11_TN static_string(const char *p, std::size_t N) NOEXCEPT_TN + : p_(p), + sz_(N) {} - CONSTEXPR11_TN const char* data() const NOEXCEPT_TN {return p_;} - CONSTEXPR11_TN std::size_t size() const NOEXCEPT_TN {return sz_;} + CONSTEXPR11_TN const char* data() const NOEXCEPT_TN { return p_; } + CONSTEXPR11_TN std::size_t size() const NOEXCEPT_TN { return sz_; } - CONSTEXPR11_TN const_iterator begin() const NOEXCEPT_TN {return p_;} - CONSTEXPR11_TN const_iterator end() const NOEXCEPT_TN {return p_ + sz_;} + CONSTEXPR11_TN const_iterator begin() const NOEXCEPT_TN { return p_; } + CONSTEXPR11_TN const_iterator end() const NOEXCEPT_TN { return p_ + sz_; } - CONSTEXPR11_TN char operator[](std::size_t n) const - { - return n < sz_ ? p_[n] : throw std::out_of_range("static_string"); - } + CONSTEXPR11_TN char operator[](std::size_t n) const { + return n < sz_ ? p_[n] : throw std::out_of_range("static_string"); + } - std::string to_string() - { - return std::string(p_, sz_); - } + std::string to_string() { return std::string(p_, sz_); } }; -inline -std::ostream& -operator<<(std::ostream& os, static_string const& s) -{ - return os.write(s.data(), s.size()); +inline std::ostream& operator<<(std::ostream& os, static_string const& s) { + return os.write(s.data(), s.size()); } template <class T> -CONSTEXPR14_TN -static_string -type_name() -{ +CONSTEXPR14_TN static_string type_name() { #ifdef __clang__ - static_string p = __PRETTY_FUNCTION__; - return static_string(p.data() + 31, p.size() - 31 - 1); + static_string p = __PRETTY_FUNCTION__; + return static_string(p.data() + 31, p.size() - 31 - 1); #elif defined(__GNUC__) - static_string p = __PRETTY_FUNCTION__; -# if __cplusplus < 201402 - return static_string(p.data() + 36, p.size() - 36 - 1); -# else - return static_string(p.data() + 46, p.size() - 46 - 1); -# endif + static_string p = __PRETTY_FUNCTION__; +#if __cplusplus < 201402 + return static_string(p.data() + 36, p.size() - 36 - 1); +#else + return static_string(p.data() + 46, p.size() - 46 - 1); +#endif #elif defined(_MSC_VER) - static_string p = __FUNCSIG__; - return static_string(p.data() + 38, p.size() - 38 - 7); + static_string p = __FUNCSIG__; + return static_string(p.data() + 38, p.size() - 38 - 7); #endif } diff --git a/src/utils/underlying_cast.hpp b/src/utils/underlying_cast.hpp index 125a9e0a2..fc6cb530b 100644 --- a/src/utils/underlying_cast.hpp +++ b/src/utils/underlying_cast.hpp @@ -4,5 +4,5 @@ template <typename T> constexpr typename std::underlying_type<T>::type underlying_cast(T e) { - return static_cast<typename std::underlying_type<T>::type>(e); + return static_cast<typename std::underlying_type<T>::type>(e); } diff --git a/src/utils/variadic/variadic.hpp b/src/utils/variadic/variadic.hpp index fe01e30b3..3ece9803c 100644 --- a/src/utils/variadic/variadic.hpp +++ b/src/utils/variadic/variadic.hpp @@ -2,22 +2,19 @@ #include <iostream> -namespace utils -{ +namespace utils { /* * Variadic argument print */ -template<class Head> -void print_vargs(std::ostream& s, Head&& head) -{ - s << std::forward<Head>(head); +template <class Head> +void print_vargs(std::ostream& s, Head&& head) { + s << std::forward<Head>(head); } -template<class Head, class ...Tail> -void print_vargs(std::ostream& s, Head&& head, Tail&& ...tail) -{ - s << std::forward<Head>(head); - print_vargs(s, std::forward<Tail>(tail)...); +template <class Head, class... Tail> +void print_vargs(std::ostream& s, Head&& head, Tail&&... tail) { + s << std::forward<Head>(head); + print_vargs(s, std::forward<Tail>(tail)...); } /* @@ -29,30 +26,25 @@ void print_vargs(std::ostream& s, Head&& head, Tail&& ...tail) * * TODO: reimplament with C++17 fold expressions */ -template<class ...Args> -void println(Args&&... args) -{ - print_vargs(std::cout, std::forward<Args>(args)...); - std::cout << std::endl; +template <class... Args> +void println(Args&&... args) { + print_vargs(std::cout, std::forward<Args>(args)...); + std::cout << std::endl; } // value equality with any of variadic argument // example: value == varg[0] OR value == varg[1] OR ... -template<class Value, class Head> -bool _or_vargs(Value&& value, Head&& head) -{ - return value == head; +template <class Value, class Head> +bool _or_vargs(Value&& value, Head&& head) { + return value == head; } -template<class Value, class Head, class ...Tail> -bool _or_vargs(Value&& value, Head&& head, Tail&& ...tail) -{ - return value == head || _or_vargs(std::forward<Value>(value), tail...); +template <class Value, class Head, class... Tail> +bool _or_vargs(Value&& value, Head&& head, Tail&&... tail) { + return value == head || _or_vargs(std::forward<Value>(value), tail...); } -template<class Value, class ...Array> -bool or_vargs(Value&& value, Array&&... array) -{ - return _or_vargs(std::forward<Value>(value), std::forward<Array>(array)...); +template <class Value, class... Array> +bool or_vargs(Value&& value, Array&&... array) { + return _or_vargs(std::forward<Value>(value), std::forward<Array>(array)...); } - } diff --git a/src/utils/visitor/visitable.hpp b/src/utils/visitor/visitable.hpp index 11ca6305b..3ca85ef8a 100644 --- a/src/utils/visitor/visitable.hpp +++ b/src/utils/visitor/visitable.hpp @@ -1,8 +1,7 @@ #pragma once template <class T> -struct Visitable -{ - virtual ~Visitable() = default; - virtual void accept(T& visitor) = 0; +struct Visitable { + virtual ~Visitable() = default; + virtual void accept(T& visitor) = 0; }; diff --git a/src/utils/visitor/visitor.hpp b/src/utils/visitor/visitor.hpp index 0d415a923..ccfe07dbf 100644 --- a/src/utils/visitor/visitor.hpp +++ b/src/utils/visitor/visitor.hpp @@ -1,42 +1,37 @@ #pragma once -namespace detail -{ +namespace detail { template <typename T> struct VisitorBase { - virtual ~VisitorBase() = default; + virtual ~VisitorBase() = default; - virtual void visit(T&) {} - virtual void post_visit(T&) {} + virtual void visit(T&) {} + virtual void post_visit(T&) {} }; -template<typename... T> +template <typename... T> struct RecursiveVisitorBase; template <typename Head, typename... Tail> -struct RecursiveVisitorBase<Head, Tail...> - : VisitorBase<Head>, RecursiveVisitorBase<Tail...> -{ - using VisitorBase<Head>::visit; - using VisitorBase<Head>::post_visit; +struct RecursiveVisitorBase<Head, Tail...> : VisitorBase<Head>, + RecursiveVisitorBase<Tail...> { + using VisitorBase<Head>::visit; + using VisitorBase<Head>::post_visit; - using RecursiveVisitorBase<Tail...>::visit; - using RecursiveVisitorBase<Tail...>::post_visit; + using RecursiveVisitorBase<Tail...>::visit; + using RecursiveVisitorBase<Tail...>::post_visit; }; -template<typename T> -struct RecursiveVisitorBase<T> : public VisitorBase<T> -{ - using VisitorBase<T>::visit; - using VisitorBase<T>::post_visit; +template <typename T> +struct RecursiveVisitorBase<T> : public VisitorBase<T> { + using VisitorBase<T>::visit; + using VisitorBase<T>::post_visit; }; - } template <typename... T> -struct Visitor : public detail::RecursiveVisitorBase<T...> -{ - using detail::RecursiveVisitorBase<T...>::visit; - using detail::RecursiveVisitorBase<T...>::post_visit; +struct Visitor : public detail::RecursiveVisitorBase<T...> { + using detail::RecursiveVisitorBase<T...>::visit; + using detail::RecursiveVisitorBase<T...>::post_visit; }; diff --git a/src/utils/void.hpp b/src/utils/void.hpp index 2615ea7bf..faf378978 100644 --- a/src/utils/void.hpp +++ b/src/utils/void.hpp @@ -3,12 +3,11 @@ #include "utils/total_ordering.hpp" // Type which represents nothing. -class Void : public TotalOrdering<Void> -{ -public: - friend bool operator<(const Void &lhs, const Void &rhs) { return false; } +class Void : public TotalOrdering<Void> { + public: + friend bool operator<(const Void &lhs, const Void &rhs) { return false; } - friend bool operator==(const Void &lhs, const Void &rhs) { return true; } + friend bool operator==(const Void &lhs, const Void &rhs) { return true; } }; static Void _void = {}; diff --git a/tests/benchmark/data_structures/bloom/basic_bloom_filter.cpp b/tests/benchmark/data_structures/bloom/basic_bloom_filter.cpp index c90f628c8..22e541b28 100644 --- a/tests/benchmark/data_structures/bloom/basic_bloom_filter.cpp +++ b/tests/benchmark/data_structures/bloom/basic_bloom_filter.cpp @@ -15,44 +15,41 @@ using StringHashFunction = std::function<uint64_t(const std::string &)>; template <class Type, int Size> static void TestBloom(benchmark::State &state, BloomFilter<Type, Size> *bloom, - const std::vector<Type> &elements) -{ - while (state.KeepRunning()) - { - for (int start = 0; start < state.range(0); start++) - if (start % 2) - bloom->contains(elements[start]); - else - bloom->insert(elements[start]); - } - state.SetComplexityN(state.range(0)); + const std::vector<Type> &elements) { + while (state.KeepRunning()) { + for (int start = 0; start < state.range(0); start++) + if (start % 2) + bloom->contains(elements[start]); + else + bloom->insert(elements[start]); + } + state.SetComplexityN(state.range(0)); } auto BM_Bloom = [](benchmark::State &state, auto *bloom, const auto &elements) { - TestBloom(state, bloom, elements); + TestBloom(state, bloom, elements); }; -int main(int argc, char **argv) -{ - logging::init_async(); - logging::log->pipe(std::make_unique<Stdout>()); +int main(int argc, char **argv) { + logging::init_async(); + logging::log->pipe(std::make_unique<Stdout>()); - StringGenerator generator(4); + StringGenerator generator(4); - auto elements = utils::random::generate_vector(generator, 1 << 16); + auto elements = utils::random::generate_vector(generator, 1 << 16); - StringHashFunction hash1 = fnv64<std::string>; - StringHashFunction hash2 = fnv1a64<std::string>; - std::vector<StringHashFunction> funcs = {hash1, hash2}; + StringHashFunction hash1 = fnv64<std::string>; + StringHashFunction hash2 = fnv1a64<std::string>; + std::vector<StringHashFunction> funcs = {hash1, hash2}; - BloomFilter<std::string, 128> bloom(funcs); + BloomFilter<std::string, 128> bloom(funcs); - benchmark::RegisterBenchmark("SimpleBloomFilter Benchmark Test", BM_Bloom, - &bloom, elements) - ->RangeMultiplier(2) - ->Range(1, 1 << 16) - ->Complexity(benchmark::oN); + benchmark::RegisterBenchmark("SimpleBloomFilter Benchmark Test", BM_Bloom, + &bloom, elements) + ->RangeMultiplier(2) + ->Range(1, 1 << 16) + ->Complexity(benchmark::oN); - benchmark::Initialize(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); + benchmark::Initialize(&argc, argv); + benchmark::RunSpecifiedBenchmarks(); } diff --git a/tests/benchmark/data_structures/concurrent/bloom_map_concurrent.cpp b/tests/benchmark/data_structures/concurrent/bloom_map_concurrent.cpp index 439614b9e..429986503 100644 --- a/tests/benchmark/data_structures/concurrent/bloom_map_concurrent.cpp +++ b/tests/benchmark/data_structures/concurrent/bloom_map_concurrent.cpp @@ -42,16 +42,13 @@ int THREADS, RANGE_START, RANGE_END, STRING_LENGTH; template <class K, class V, class F> static void InsertValue(benchmark::State &state, ConcurrentBloomMap<K, V, F> *map, - const std::vector<std::pair<K, V>> &elements) -{ - while (state.KeepRunning()) - { - for (int start = 0; start < state.range(0); start++) - { - map->insert(elements[start].first, elements[start].second); - } + const std::vector<std::pair<K, V>> &elements) { + while (state.KeepRunning()) { + for (int start = 0; start < state.range(0); start++) { + map->insert(elements[start].first, elements[start].second); } - state.SetComplexityN(state.range(0)); + } + state.SetComplexityN(state.range(0)); } /* @@ -60,24 +57,21 @@ static void InsertValue(benchmark::State &state, template <class K, class V, class F> static void ContainsValue(benchmark::State &state, ConcurrentBloomMap<K, V, F> *map, - const std::vector<std::pair<K, V>> elements) -{ - while (state.KeepRunning()) - { - for (int start = 0; start < state.range(0); start++) - { - map->contains(elements[start].first); - } + const std::vector<std::pair<K, V>> elements) { + while (state.KeepRunning()) { + for (int start = 0; start < state.range(0); start++) { + map->contains(elements[start].first); } - state.SetComplexityN(state.range(0)); + } + state.SetComplexityN(state.range(0)); } auto BM_InsertValue = [](benchmark::State &state, auto *map, auto &elements) { - InsertValue(state, map, elements); + InsertValue(state, map, elements); }; auto BM_ContainsValue = [](benchmark::State &state, auto *map, auto elements) { - ContainsValue(state, map, elements); + ContainsValue(state, map, elements); }; /* @@ -96,98 +90,96 @@ auto BM_ContainsValue = [](benchmark::State &state, auto *map, auto elements) { * Random String lenght -string-length number */ -void parse_arguments(int argc, char **argv) -{ - REGISTER_ARGS(argc, argv); +void parse_arguments(int argc, char **argv) { + REGISTER_ARGS(argc, argv); - RANGE_START = GET_ARG("-start", "0").get_int(); - RANGE_END = GET_ARG("-end", "1000000000").get_int(); + RANGE_START = GET_ARG("-start", "0").get_int(); + RANGE_END = GET_ARG("-end", "1000000000").get_int(); - THREADS = std::min(GET_ARG("-threads", "1").get_int(), - (int)std::thread::hardware_concurrency()); + THREADS = std::min(GET_ARG("-threads", "1").get_int(), + (int)std::thread::hardware_concurrency()); - STRING_LENGTH = - ProgramArguments::instance().get_arg("-string-length", "128").get_int(); + STRING_LENGTH = + ProgramArguments::instance().get_arg("-string-length", "128").get_int(); } -int main(int argc, char **argv) -{ - logging::init_async(); - logging::log->pipe(std::make_unique<Stdout>()); +int main(int argc, char **argv) { + logging::init_async(); + logging::log->pipe(std::make_unique<Stdout>()); - parse_arguments(argc, argv); + parse_arguments(argc, argv); - StringGenerator sg(STRING_LENGTH); - IntegerGenerator ig(RANGE_START, RANGE_END); + StringGenerator sg(STRING_LENGTH); + IntegerGenerator ig(RANGE_START, RANGE_END); - /* - Creates RandomGenerators, ConcurentMaps and Random Element Vectors for the - following use cases: + /* + Creates RandomGenerators, ConcurentMaps and Random Element Vectors for the + following use cases: - Map elements contain keys and value for: - <int, int>, - <int, string> - <string, int> - <string, string> - */ + Map elements contain keys and value for: + <int, int>, + <int, string> + <string, int> + <string, string> + */ - // random generators for tests - PairGenerator<IntegerGenerator, IntegerGenerator> piig(&ig, &ig); - PairGenerator<StringGenerator, StringGenerator> pssg(&sg, &sg); - PairGenerator<StringGenerator, IntegerGenerator> psig(&sg, &ig); - PairGenerator<IntegerGenerator, StringGenerator> pisg(&ig, &sg); + // random generators for tests + PairGenerator<IntegerGenerator, IntegerGenerator> piig(&ig, &ig); + PairGenerator<StringGenerator, StringGenerator> pssg(&sg, &sg); + PairGenerator<StringGenerator, IntegerGenerator> psig(&sg, &ig); + PairGenerator<IntegerGenerator, StringGenerator> pisg(&ig, &sg); - StringHashFunction hash1 = fnv64<std::string>; - StringHashFunction hash2 = fnv1a64<std::string>; - std::vector<StringHashFunction> funcs = {hash1, hash2}; + StringHashFunction hash1 = fnv64<std::string>; + StringHashFunction hash2 = fnv1a64<std::string>; + std::vector<StringHashFunction> funcs = {hash1, hash2}; - BloomFilter<std::string, 128> bloom_filter_(funcs); + BloomFilter<std::string, 128> bloom_filter_(funcs); - // maps used for testing - // ConcurrentBloomMap<int, int> ii_map; - // ConcurrentBloomMap<int, std::string> is_map; - using Filter = BloomFilter<std::string, 128>; - ConcurrentBloomMap<std::string, int, Filter> si_map(bloom_filter_); - ConcurrentBloomMap<std::string, std::string, Filter> ss_map(bloom_filter_); + // maps used for testing + // ConcurrentBloomMap<int, int> ii_map; + // ConcurrentBloomMap<int, std::string> is_map; + using Filter = BloomFilter<std::string, 128>; + ConcurrentBloomMap<std::string, int, Filter> si_map(bloom_filter_); + ConcurrentBloomMap<std::string, std::string, Filter> ss_map(bloom_filter_); - // random elements for testing - // auto ii_elems = utils::random::generate_vector(piig, MAX_ELEMENTS); - // auto is_elems = utils::random::generate_vector(pisg, MAX_ELEMENTS); - auto si_elems = utils::random::generate_vector(psig, MAX_ELEMENTS); - auto ss_elems = utils::random::generate_vector(pssg, MAX_ELEMENTS); + // random elements for testing + // auto ii_elems = utils::random::generate_vector(piig, MAX_ELEMENTS); + // auto is_elems = utils::random::generate_vector(pisg, MAX_ELEMENTS); + auto si_elems = utils::random::generate_vector(psig, MAX_ELEMENTS); + auto ss_elems = utils::random::generate_vector(pssg, MAX_ELEMENTS); - /* insertion Tests */ - benchmark::RegisterBenchmark("InsertValue[String, Int]", BM_InsertValue, - &si_map, si_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + /* insertion Tests */ + benchmark::RegisterBenchmark("InsertValue[String, Int]", BM_InsertValue, + &si_map, si_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("InsertValue[String, String]", BM_InsertValue, - &ss_map, ss_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("InsertValue[String, String]", BM_InsertValue, + &ss_map, ss_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - // Contains Benchmark Tests - benchmark::RegisterBenchmark("ContainsValue[String, Int]", BM_ContainsValue, - &si_map, si_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + // Contains Benchmark Tests + benchmark::RegisterBenchmark("ContainsValue[String, Int]", BM_ContainsValue, + &si_map, si_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("ContainsValue[String, String]", - BM_ContainsValue, &ss_map, ss_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("ContainsValue[String, String]", + BM_ContainsValue, &ss_map, ss_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::Initialize(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); + benchmark::Initialize(&argc, argv); + benchmark::RunSpecifiedBenchmarks(); - return 0; + return 0; } diff --git a/tests/benchmark/data_structures/concurrent/map_concurrent.cpp b/tests/benchmark/data_structures/concurrent/map_concurrent.cpp index e2bbf36db..451cfa07a 100644 --- a/tests/benchmark/data_structures/concurrent/map_concurrent.cpp +++ b/tests/benchmark/data_structures/concurrent/map_concurrent.cpp @@ -38,17 +38,14 @@ int THREADS, RANGE_START, RANGE_END, STRING_LENGTH; */ template <class K, class V> static void InsertValue(benchmark::State &state, ConcurrentMap<K, V> *map, - const std::vector<std::pair<K, V>> &elements) -{ - while (state.KeepRunning()) - { - auto accessor = map->access(); - for (int start = 0; start < state.range(0); start++) - { - accessor.insert(elements[start].first, elements[start].second); - } + const std::vector<std::pair<K, V>> &elements) { + while (state.KeepRunning()) { + auto accessor = map->access(); + for (int start = 0; start < state.range(0); start++) { + accessor.insert(elements[start].first, elements[start].second); } - state.SetComplexityN(state.range(0)); + } + state.SetComplexityN(state.range(0)); } /* @@ -56,17 +53,14 @@ static void InsertValue(benchmark::State &state, ConcurrentMap<K, V> *map, */ template <class K, class V> static void DeleteValue(benchmark::State &state, ConcurrentMap<K, V> *map, - const std::vector<std::pair<K, V>> elements) -{ - while (state.KeepRunning()) - { - auto accessor = map->access(); - for (int start = 0; start < state.range(0); start++) - { - accessor.remove(elements[start].first); - } + const std::vector<std::pair<K, V>> elements) { + while (state.KeepRunning()) { + auto accessor = map->access(); + for (int start = 0; start < state.range(0); start++) { + accessor.remove(elements[start].first); } - state.SetComplexityN(state.range(0)); + } + state.SetComplexityN(state.range(0)); } /* @@ -74,29 +68,26 @@ static void DeleteValue(benchmark::State &state, ConcurrentMap<K, V> *map, */ template <class K, class V> static void ContainsValue(benchmark::State &state, ConcurrentMap<K, V> *map, - const std::vector<std::pair<K, V>> elements) -{ - while (state.KeepRunning()) - { - auto accessor = map->access(); - for (int start = 0; start < state.range(0); start++) - { - accessor.contains(elements[start].first); - } + const std::vector<std::pair<K, V>> elements) { + while (state.KeepRunning()) { + auto accessor = map->access(); + for (int start = 0; start < state.range(0); start++) { + accessor.contains(elements[start].first); } - state.SetComplexityN(state.range(0)); + } + state.SetComplexityN(state.range(0)); } auto BM_InsertValue = [](benchmark::State &state, auto *map, auto &elements) { - InsertValue(state, map, elements); + InsertValue(state, map, elements); }; auto BM_DeleteValue = [](benchmark::State &state, auto *map, auto elements) { - DeleteValue(state, map, elements); + DeleteValue(state, map, elements); }; auto BM_ContainsValue = [](benchmark::State &state, auto *map, auto elements) { - ContainsValue(state, map, elements); + ContainsValue(state, map, elements); }; /* @@ -115,151 +106,149 @@ auto BM_ContainsValue = [](benchmark::State &state, auto *map, auto elements) { * Random String lenght -string-length number */ -void parse_arguments(int argc, char **argv) -{ - REGISTER_ARGS(argc, argv); +void parse_arguments(int argc, char **argv) { + REGISTER_ARGS(argc, argv); - RANGE_START = GET_ARG("-start", "0").get_int(); - RANGE_END = GET_ARG("-end", "1000000000").get_int(); + RANGE_START = GET_ARG("-start", "0").get_int(); + RANGE_END = GET_ARG("-end", "1000000000").get_int(); - THREADS = std::min(GET_ARG("-threads", "1").get_int(), - (int)std::thread::hardware_concurrency()); + THREADS = std::min(GET_ARG("-threads", "1").get_int(), + (int)std::thread::hardware_concurrency()); - STRING_LENGTH = - ProgramArguments::instance().get_arg("-string-length", "128").get_int(); + STRING_LENGTH = + ProgramArguments::instance().get_arg("-string-length", "128").get_int(); } -int main(int argc, char **argv) -{ - logging::init_async(); - logging::log->pipe(std::make_unique<Stdout>()); +int main(int argc, char **argv) { + logging::init_async(); + logging::log->pipe(std::make_unique<Stdout>()); - parse_arguments(argc, argv); + parse_arguments(argc, argv); - StringGenerator sg(STRING_LENGTH); - IntegerGenerator ig(RANGE_START, RANGE_END); + StringGenerator sg(STRING_LENGTH); + IntegerGenerator ig(RANGE_START, RANGE_END); - /* - Creates RandomGenerators, ConcurentMaps and Random Element Vectors for the - following use cases: + /* + Creates RandomGenerators, ConcurentMaps and Random Element Vectors for the + following use cases: - Map elements contain keys and value for: - <int, int>, - <int, string> - <string, int> - <string, string> - */ + Map elements contain keys and value for: + <int, int>, + <int, string> + <string, int> + <string, string> + */ - // random generators for tests - PairGenerator<IntegerGenerator, IntegerGenerator> piig(&ig, &ig); - PairGenerator<StringGenerator, StringGenerator> pssg(&sg, &sg); - PairGenerator<StringGenerator, IntegerGenerator> psig(&sg, &ig); - PairGenerator<IntegerGenerator, StringGenerator> pisg(&ig, &sg); + // random generators for tests + PairGenerator<IntegerGenerator, IntegerGenerator> piig(&ig, &ig); + PairGenerator<StringGenerator, StringGenerator> pssg(&sg, &sg); + PairGenerator<StringGenerator, IntegerGenerator> psig(&sg, &ig); + PairGenerator<IntegerGenerator, StringGenerator> pisg(&ig, &sg); - // maps used for testing - ConcurrentMap<int, int> ii_map; - ConcurrentMap<int, std::string> is_map; - ConcurrentMap<std::string, int> si_map; - ConcurrentMap<std::string, std::string> ss_map; + // maps used for testing + ConcurrentMap<int, int> ii_map; + ConcurrentMap<int, std::string> is_map; + ConcurrentMap<std::string, int> si_map; + ConcurrentMap<std::string, std::string> ss_map; - // random elements for testing - auto ii_elems = utils::random::generate_vector(piig, MAX_ELEMENTS); - auto is_elems = utils::random::generate_vector(pisg, MAX_ELEMENTS); - auto si_elems = utils::random::generate_vector(psig, MAX_ELEMENTS); - auto ss_elems = utils::random::generate_vector(pssg, MAX_ELEMENTS); + // random elements for testing + auto ii_elems = utils::random::generate_vector(piig, MAX_ELEMENTS); + auto is_elems = utils::random::generate_vector(pisg, MAX_ELEMENTS); + auto si_elems = utils::random::generate_vector(psig, MAX_ELEMENTS); + auto ss_elems = utils::random::generate_vector(pssg, MAX_ELEMENTS); - /* insertion Tests */ + /* insertion Tests */ - benchmark::RegisterBenchmark("InsertValue[Int, Int]", BM_InsertValue, - &ii_map, ii_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("InsertValue[Int, Int]", BM_InsertValue, &ii_map, + ii_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("InsertValue[Int, String]", BM_InsertValue, - &is_map, is_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("InsertValue[Int, String]", BM_InsertValue, + &is_map, is_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("InsertValue[String, Int]", BM_InsertValue, - &si_map, si_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("InsertValue[String, Int]", BM_InsertValue, + &si_map, si_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("InsertValue[String, String]", BM_InsertValue, - &ss_map, ss_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("InsertValue[String, String]", BM_InsertValue, + &ss_map, ss_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - // Contains Benchmark Tests + // Contains Benchmark Tests - benchmark::RegisterBenchmark("ContainsValue[Int, Int]", BM_ContainsValue, - &ii_map, ii_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("ContainsValue[Int, Int]", BM_ContainsValue, + &ii_map, ii_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("ContainsValue[Int, String]", BM_ContainsValue, - &is_map, is_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("ContainsValue[Int, String]", BM_ContainsValue, + &is_map, is_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("ContainsValue[String, Int]", BM_ContainsValue, - &si_map, si_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("ContainsValue[String, Int]", BM_ContainsValue, + &si_map, si_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("ContainsValue[String, String]", - BM_ContainsValue, &ss_map, ss_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("ContainsValue[String, String]", + BM_ContainsValue, &ss_map, ss_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - // Deletion Banchamark Tests + // Deletion Banchamark Tests - benchmark::RegisterBenchmark("DeleteValue[Int, Int]", BM_DeleteValue, - &ii_map, ii_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("DeleteValue[Int, Int]", BM_DeleteValue, &ii_map, + ii_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("DeleteValue[Int, String]", BM_DeleteValue, - &is_map, is_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("DeleteValue[Int, String]", BM_DeleteValue, + &is_map, is_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("DeleteValue[String, Int]", BM_DeleteValue, - &si_map, si_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("DeleteValue[String, Int]", BM_DeleteValue, + &si_map, si_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::RegisterBenchmark("DeleteValue[String, String]", BM_DeleteValue, - &ss_map, ss_elems) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("DeleteValue[String, String]", BM_DeleteValue, + &ss_map, ss_elems) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::Initialize(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); + benchmark::Initialize(&argc, argv); + benchmark::RunSpecifiedBenchmarks(); - return 0; + return 0; } diff --git a/tests/benchmark/data_structures/concurrent/map_mix_concurrent.cpp b/tests/benchmark/data_structures/concurrent/map_mix_concurrent.cpp index 4beceec86..6d2f34510 100644 --- a/tests/benchmark/data_structures/concurrent/map_mix_concurrent.cpp +++ b/tests/benchmark/data_structures/concurrent/map_mix_concurrent.cpp @@ -29,38 +29,29 @@ int THREADS, INSERT_PERC, DELETE_PERC, CONTAINS_PERC, RANGE_START, RANGE_END; // ConcurrentMap Becnhmark Test using percentages for Insert, Delete, Find template <class K, class V> static void Rape(benchmark::State &state, ConcurrentMap<int, int> *map, - const std::vector<std::pair<K, V>> &elements) -{ - int number_of_elements = state.range(0); + const std::vector<std::pair<K, V>> &elements) { + int number_of_elements = state.range(0); - while (state.KeepRunning()) - { - auto accessor = map->access(); + while (state.KeepRunning()) { + auto accessor = map->access(); - for (int start = 0; start < state.range(0); start++) - { - float current_percentage = - (float)start / (float)number_of_elements * 100; - if (current_percentage < (float)INSERT_PERC) - { - accessor.insert(elements[start].first, elements[start].second); - } - else if (current_percentage < (float)CONTAINS_PERC + INSERT_PERC) - { - accessor.contains(elements[start].first); - } - else - { - accessor.remove(elements[start].first); - } - } + for (int start = 0; start < state.range(0); start++) { + float current_percentage = (float)start / (float)number_of_elements * 100; + if (current_percentage < (float)INSERT_PERC) { + accessor.insert(elements[start].first, elements[start].second); + } else if (current_percentage < (float)CONTAINS_PERC + INSERT_PERC) { + accessor.contains(elements[start].first); + } else { + accessor.remove(elements[start].first); + } } + } - state.SetComplexityN(state.range(0)); + state.SetComplexityN(state.range(0)); } auto BM_Rape = [](benchmark::State &state, auto *map, auto &elements) { - Rape(state, map, elements); + Rape(state, map, elements); }; /* @@ -85,51 +76,48 @@ auto BM_Rape = [](benchmark::State &state, auto *map, auto &elements) { * Number of threads -threads number */ -void parse_arguments(int argc, char **argv) -{ - REGISTER_ARGS(argc, argv); +void parse_arguments(int argc, char **argv) { + REGISTER_ARGS(argc, argv); - INSERT_PERC = GET_ARG("-insert", "50").get_int(); - DELETE_PERC = GET_ARG("-delete", "20").get_int(); - CONTAINS_PERC = GET_ARG("-find", "30").get_int(); + INSERT_PERC = GET_ARG("-insert", "50").get_int(); + DELETE_PERC = GET_ARG("-delete", "20").get_int(); + CONTAINS_PERC = GET_ARG("-find", "30").get_int(); - if (INSERT_PERC + DELETE_PERC + CONTAINS_PERC != 100) - { - std::cout << "Invalid percentage" << std::endl; - std::cout << "Percentage must sum to 100" << std::endl; - exit(-1); - } + if (INSERT_PERC + DELETE_PERC + CONTAINS_PERC != 100) { + std::cout << "Invalid percentage" << std::endl; + std::cout << "Percentage must sum to 100" << std::endl; + exit(-1); + } - RANGE_START = GET_ARG("-start", "0").get_int(); + RANGE_START = GET_ARG("-start", "0").get_int(); - RANGE_END = GET_ARG("-end", "1000000000").get_int(); + RANGE_END = GET_ARG("-end", "1000000000").get_int(); - THREADS = std::min(GET_ARG("-threads", "1").get_int(), - (int)std::thread::hardware_concurrency()); + THREADS = std::min(GET_ARG("-threads", "1").get_int(), + (int)std::thread::hardware_concurrency()); } -int main(int argc, char **argv) -{ - logging::init_async(); - logging::log->pipe(std::make_unique<Stdout>()); +int main(int argc, char **argv) { + logging::init_async(); + logging::log->pipe(std::make_unique<Stdout>()); - parse_arguments(argc, argv); + parse_arguments(argc, argv); - IntegerGenerator int_gen(RANGE_START, RANGE_END); - PairGenerator<IntegerGenerator, IntegerGenerator> pair_gen(&int_gen, - &int_gen); + IntegerGenerator int_gen(RANGE_START, RANGE_END); + PairGenerator<IntegerGenerator, IntegerGenerator> pair_gen(&int_gen, + &int_gen); - ConcurrentMap<int, int> map; - auto elements = utils::random::generate_vector(pair_gen, MAX_ELEMENTS); + ConcurrentMap<int, int> map; + auto elements = utils::random::generate_vector(pair_gen, MAX_ELEMENTS); - benchmark::RegisterBenchmark("Rape", BM_Rape, &map, elements) - ->RangeMultiplier(MULTIPLIER) - ->Range(1, MAX_ELEMENTS) - ->Complexity(benchmark::oN) - ->Threads(THREADS); + benchmark::RegisterBenchmark("Rape", BM_Rape, &map, elements) + ->RangeMultiplier(MULTIPLIER) + ->Range(1, MAX_ELEMENTS) + ->Complexity(benchmark::oN) + ->Threads(THREADS); - benchmark::Initialize(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); + benchmark::Initialize(&argc, argv); + benchmark::RunSpecifiedBenchmarks(); - return 0; + return 0; } diff --git a/tests/benchmark/query/strip/stripper.cpp b/tests/benchmark/query/strip/stripper.cpp index 0303cceba..dd552d04c 100644 --- a/tests/benchmark/query/strip/stripper.cpp +++ b/tests/benchmark/query/strip/stripper.cpp @@ -7,41 +7,37 @@ #include "yaml-cpp/yaml.h" auto BM_Strip = [](benchmark::State &state, auto &function, std::string query) { - while (state.KeepRunning()) - { - for (int start = 0; start < state.range(0); start++) - { - function(query); - } + while (state.KeepRunning()) { + for (int start = 0; start < state.range(0); start++) { + function(query); } - state.SetComplexityN(state.range(0)); + } + state.SetComplexityN(state.range(0)); }; -int main(int argc, char **argv) -{ - logging::init_async(); - logging::log->pipe(std::make_unique<Stdout>()); +int main(int argc, char **argv) { + logging::init_async(); + logging::log->pipe(std::make_unique<Stdout>()); - YAML::Node dataset = YAML::LoadFile( - "../../tests/data/cypher_queries/stripper/query_dict.yaml"); + YAML::Node dataset = YAML::LoadFile( + "../../tests/data/cypher_queries/stripper/query_dict.yaml"); - QueryPreprocessor processor; - using std::placeholders::_1; - std::function<StrippedQuery(const std::string &query)> preprocess = - std::bind(&QueryPreprocessor::preprocess, &processor, _1); + QueryPreprocessor processor; + using std::placeholders::_1; + std::function<StrippedQuery(const std::string &query)> preprocess = + std::bind(&QueryPreprocessor::preprocess, &processor, _1); - auto tests = dataset["benchmark_queries"].as<std::vector<std::string>>(); - for (auto &test : tests) - { - auto *benchmark = benchmark::RegisterBenchmark(test.c_str(), BM_Strip, - preprocess, test) - ->RangeMultiplier(2) - ->Range(1, 8 << 10) - ->Complexity(benchmark::oN); - } + auto tests = dataset["benchmark_queries"].as<std::vector<std::string>>(); + for (auto &test : tests) { + auto *benchmark = + benchmark::RegisterBenchmark(test.c_str(), BM_Strip, preprocess, test) + ->RangeMultiplier(2) + ->Range(1, 8 << 10) + ->Complexity(benchmark::oN); + } - benchmark::Initialize(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); + benchmark::Initialize(&argc, argv); + benchmark::RunSpecifiedBenchmarks(); - return 0; + return 0; } diff --git a/tests/concurrent/conncurent_list.cpp b/tests/concurrent/conncurent_list.cpp index 372ca0538..2c5dc9393 100644 --- a/tests/concurrent/conncurent_list.cpp +++ b/tests/concurrent/conncurent_list.cpp @@ -1,94 +1,78 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 8); -constexpr size_t key_range = 1e2; +constexpr size_t THREADS_NO = std::min(max_no_threads, 8); +constexpr size_t key_range = 1e2; constexpr size_t op_per_thread = 1e4; // Depending on value there is a possiblity of numerical overflow -constexpr size_t max_number = 10; -constexpr size_t no_find_per_change = 2; +constexpr size_t max_number = 10; +constexpr size_t no_find_per_change = 2; constexpr size_t no_insert_for_one_delete = 1; // This test simulates behavior of a transactions. // Each thread makes a series of finds interleaved with method which change. // Exact ratio of finds per change and insert per delete can be regulated with // no_find_per_change and no_insert_for_one_delete. -int main() -{ - init_log(); - memory_check(THREADS_NO, [] { - ConcurrentList<std::pair<int, int>> list; - permanent_assert(list.size() == 0, "The list isn't empty"); +int main() { + init_log(); + memory_check(THREADS_NO, [] { + ConcurrentList<std::pair<int, int>> list; + permanent_assert(list.size() == 0, "The list isn't empty"); - auto futures = run<std::pair<long long, long long>>( - THREADS_NO, [&](auto index) mutable { - auto rand = rand_gen(key_range); - auto rand_change = rand_gen_bool(no_find_per_change); - auto rand_delete = rand_gen_bool(no_insert_for_one_delete); - long long sum = 0; - long long count = 0; + auto futures = run<std::pair<long long, long long>>( + THREADS_NO, [&](auto index) mutable { + auto rand = rand_gen(key_range); + auto rand_change = rand_gen_bool(no_find_per_change); + auto rand_delete = rand_gen_bool(no_insert_for_one_delete); + long long sum = 0; + long long count = 0; - for (int i = 0; i < op_per_thread; i++) - { - auto num = rand(); - auto data = num % max_number; - if (rand_change()) - { - if (rand_delete()) - { - for (auto it = list.begin(); it != list.end(); it++) - { - if (it->first == num) - { - if (it.remove()) - { - sum -= data; - count--; - } - break; - } - } - } - else - { - list.begin().push(std::make_pair(num, data)); - sum += data; - count++; - } - } - else - { - for (auto &v : list) - { - if (v.first == num) - { - permanent_assert(v.second == data, - "Data is invalid"); - break; - } - } + for (int i = 0; i < op_per_thread; i++) { + auto num = rand(); + auto data = num % max_number; + if (rand_change()) { + if (rand_delete()) { + for (auto it = list.begin(); it != list.end(); it++) { + if (it->first == num) { + if (it.remove()) { + sum -= data; + count--; } + break; + } } + } else { + list.begin().push(std::make_pair(num, data)); + sum += data; + count++; + } + } else { + for (auto &v : list) { + if (v.first == num) { + permanent_assert(v.second == data, "Data is invalid"); + break; + } + } + } + } - return std::pair<long long, long long>(sum, count); - }); + return std::pair<long long, long long>(sum, count); + }); - auto it = list.begin(); - long long sums = 0; - long long counters = 0; - for (auto &data : collect(futures)) - { - sums += data.second.first; - counters += data.second.second; - } + auto it = list.begin(); + long long sums = 0; + long long counters = 0; + for (auto &data : collect(futures)) { + sums += data.second.first; + counters += data.second.second; + } - for (auto &e : list) - { - sums -= e.second; - } + for (auto &e : list) { + sums -= e.second; + } - permanent_assert(sums == 0, "Same values aren't present"); - check_size_list<ConcurrentList<std::pair<int, int>>>(list, counters); + permanent_assert(sums == 0, "Same values aren't present"); + check_size_list<ConcurrentList<std::pair<int, int>>>(list, counters); - std::this_thread::sleep_for(1s); - }); + std::this_thread::sleep_for(1s); + }); } diff --git a/tests/concurrent/dynamic_bitset.cpp b/tests/concurrent/dynamic_bitset.cpp index 14b213618..378cd3ef5 100644 --- a/tests/concurrent/dynamic_bitset.cpp +++ b/tests/concurrent/dynamic_bitset.cpp @@ -1,47 +1,38 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 8); -constexpr size_t op_per_thread = 1e5; -constexpr size_t bit_part_len = 2; -constexpr size_t no_slots = 1e4; -constexpr size_t key_range = no_slots * THREADS_NO * bit_part_len; +constexpr size_t THREADS_NO = std::min(max_no_threads, 8); +constexpr size_t op_per_thread = 1e5; +constexpr size_t bit_part_len = 2; +constexpr size_t no_slots = 1e4; +constexpr size_t key_range = no_slots * THREADS_NO * bit_part_len; constexpr size_t no_sets_per_clear = 2; // TODO: document the test -int main() -{ - DynamicBitset<> db; +int main() { + DynamicBitset<> db; - auto seted = - collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { - auto rand = rand_gen(no_slots); - auto clear_op = rand_gen_bool(no_sets_per_clear); - std::vector<bool> set(key_range); + auto seted = collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { + auto rand = rand_gen(no_slots); + auto clear_op = rand_gen_bool(no_sets_per_clear); + std::vector<bool> set(key_range); - for (size_t i = 0; i < op_per_thread; i++) - { - size_t num = - rand() * THREADS_NO * bit_part_len + index * bit_part_len; + for (size_t i = 0; i < op_per_thread; i++) { + size_t num = rand() * THREADS_NO * bit_part_len + index * bit_part_len; - if (clear_op()) - { - db.clear(num, bit_part_len); - for (int j = 0; j < bit_part_len; j++) - { - set[num + j] = false; - } - } - else - { - db.set(num, bit_part_len); - for (int j = 0; j < bit_part_len; j++) - set[num + j] = true; - } - } + if (clear_op()) { + db.clear(num, bit_part_len); + for (int j = 0; j < bit_part_len; j++) { + set[num + j] = false; + } + } else { + db.set(num, bit_part_len); + for (int j = 0; j < bit_part_len; j++) set[num + j] = true; + } + } - return set; - })); + return set; + })); - check_set(db, seted); + check_set(db, seted); } diff --git a/tests/concurrent/dynamic_bitset_clear_n.cpp b/tests/concurrent/dynamic_bitset_clear_n.cpp index 51572f0f6..d88aae158 100644 --- a/tests/concurrent/dynamic_bitset_clear_n.cpp +++ b/tests/concurrent/dynamic_bitset_clear_n.cpp @@ -1,59 +1,52 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 4); -constexpr size_t op_per_thread = 1e5; +constexpr size_t THREADS_NO = std::min(max_no_threads, 4); +constexpr size_t op_per_thread = 1e5; constexpr size_t up_border_bit_set_pow2 = 3; constexpr size_t key_range = op_per_thread * THREADS_NO * (1 << up_border_bit_set_pow2) * 2; // TODO: document the test -int main() -{ - DynamicBitset<> db; +int main() { + DynamicBitset<> db; - auto seted = - collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { - auto rand = rand_gen(key_range); - auto rand_len = rand_gen(up_border_bit_set_pow2); - std::vector<bool> set(key_range + (1 << up_border_bit_set_pow2)); + auto seted = collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { + auto rand = rand_gen(key_range); + auto rand_len = rand_gen(up_border_bit_set_pow2); + std::vector<bool> set(key_range + (1 << up_border_bit_set_pow2)); - for (size_t i = 0; i < op_per_thread; i++) - { - auto len = 1 << rand_len(); - size_t num = (rand() / len) * len; - db.set(num, len); - for (int j = 0; j < len; j++) - set[num + j] = true; - } - - return set; - })); - - auto cleared = - collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { - auto rand = rand_gen(key_range); - auto rand_len = rand_gen(up_border_bit_set_pow2); - std::vector<bool> set(key_range + (1 << up_border_bit_set_pow2)); - - for (size_t i = 0; i < op_per_thread; i++) - { - auto len = 1 << rand_len(); - size_t num = (rand() / len) * len; - for (int j = 0; j < len; j++) - { - set[num + j] = set[num + j] | db.at(num + j); - } - db.clear(num, len); - } - - return set; - })); - - for (size_t i = 0; i < seted.size(); i++) - { - seted[i] = seted[i] & (!cleared[i]); + for (size_t i = 0; i < op_per_thread; i++) { + auto len = 1 << rand_len(); + size_t num = (rand() / len) * len; + db.set(num, len); + for (int j = 0; j < len; j++) set[num + j] = true; } - check_set(db, seted); + return set; + })); + + auto cleared = + collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { + auto rand = rand_gen(key_range); + auto rand_len = rand_gen(up_border_bit_set_pow2); + std::vector<bool> set(key_range + (1 << up_border_bit_set_pow2)); + + for (size_t i = 0; i < op_per_thread; i++) { + auto len = 1 << rand_len(); + size_t num = (rand() / len) * len; + for (int j = 0; j < len; j++) { + set[num + j] = set[num + j] | db.at(num + j); + } + db.clear(num, len); + } + + return set; + })); + + for (size_t i = 0; i < seted.size(); i++) { + seted[i] = seted[i] & (!cleared[i]); + } + + check_set(db, seted); } diff --git a/tests/concurrent/dynamic_bitset_set.cpp b/tests/concurrent/dynamic_bitset_set.cpp index bf464fcd5..d680913cb 100644 --- a/tests/concurrent/dynamic_bitset_set.cpp +++ b/tests/concurrent/dynamic_bitset_set.cpp @@ -1,28 +1,26 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 8); +constexpr size_t THREADS_NO = std::min(max_no_threads, 8); constexpr size_t op_per_thread = 1e5; -constexpr size_t key_range = op_per_thread * THREADS_NO * 3; +constexpr size_t key_range = op_per_thread * THREADS_NO * 3; // TODO: document the test -int main() -{ - DynamicBitset<> db; +int main() { + DynamicBitset<> db; - auto set = collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { - auto rand = rand_gen(key_range); - std::vector<bool> set(key_range); + auto set = collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { + auto rand = rand_gen(key_range); + std::vector<bool> set(key_range); - for (size_t i = 0; i < op_per_thread; i++) - { - size_t num = rand(); - db.set(num); - set[num] = true; - } + for (size_t i = 0; i < op_per_thread; i++) { + size_t num = rand(); + db.set(num); + set[num] = true; + } - return set; - })); + return set; + })); - check_set(db, set); + check_set(db, set); } diff --git a/tests/concurrent/dynamic_bitset_set_n.cpp b/tests/concurrent/dynamic_bitset_set_n.cpp index bfc0f0460..c6636e8fd 100644 --- a/tests/concurrent/dynamic_bitset_set_n.cpp +++ b/tests/concurrent/dynamic_bitset_set_n.cpp @@ -1,33 +1,30 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 4); -constexpr size_t op_per_thread = 1e5; +constexpr size_t THREADS_NO = std::min(max_no_threads, 4); +constexpr size_t op_per_thread = 1e5; constexpr size_t up_border_bit_set_pow2 = 3; constexpr size_t key_range = op_per_thread * THREADS_NO * (1 << up_border_bit_set_pow2) * 2; // TODO: document the test -int main() -{ - DynamicBitset<> db; +int main() { + DynamicBitset<> db; - auto set = collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { - auto rand = rand_gen(key_range); - auto rand_len = rand_gen(up_border_bit_set_pow2); - std::vector<bool> set(key_range + (1 << up_border_bit_set_pow2)); + auto set = collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) { + auto rand = rand_gen(key_range); + auto rand_len = rand_gen(up_border_bit_set_pow2); + std::vector<bool> set(key_range + (1 << up_border_bit_set_pow2)); - for (size_t i = 0; i < op_per_thread; i++) - { - auto len = 1 << rand_len(); - size_t num = (rand() / len) * len; - db.set(num, len); - for (int j = 0; j < len; j++) - set[num + j] = true; - } + for (size_t i = 0; i < op_per_thread; i++) { + auto len = 1 << rand_len(); + size_t num = (rand() / len) * len; + db.set(num, len); + for (int j = 0; j < len; j++) set[num + j] = true; + } - return set; - })); + return set; + })); - check_set(db, set); + check_set(db, set); } diff --git a/tests/concurrent/sl_insert.cpp b/tests/concurrent/sl_insert.cpp index 5147aaeb6..5a9f3f8bc 100644 --- a/tests/concurrent/sl_insert.cpp +++ b/tests/concurrent/sl_insert.cpp @@ -3,43 +3,40 @@ constexpr size_t THREADS_NO = std::min(max_no_threads, 8); constexpr size_t elems_per_thread = 100000; -constexpr size_t key_range = elems_per_thread * THREADS_NO * 2; +constexpr size_t key_range = elems_per_thread * THREADS_NO * 2; // TODO: document the test // This test checks insert_unique method under pressure. // Test checks for missing data and changed/overwriten data. -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - map_t skiplist; + memory_check(THREADS_NO, [] { + map_t skiplist; - auto futures = run<std::vector<size_t>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - long long downcount = elems_per_thread; - std::vector<size_t> owned; - auto inserter = - insert_try<size_t, size_t, map_t>(acc, downcount, owned); + auto futures = run<std::vector<size_t>>( + THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + long long downcount = elems_per_thread; + std::vector<size_t> owned; + auto inserter = + insert_try<size_t, size_t, map_t>(acc, downcount, owned); - do - { - inserter(rand(), index); - } while (downcount > 0); + do { + inserter(rand(), index); + } while (downcount > 0); - check_present_same<map_t>(acc, index, owned); - return owned; - }); + check_present_same<map_t>(acc, index, owned); + return owned; + }); - auto accessor = skiplist.access(); - for (auto &owned : collect(futures)) - { - check_present_same<map_t>(accessor, owned); - } + auto accessor = skiplist.access(); + for (auto &owned : collect(futures)) { + check_present_same<map_t>(accessor, owned); + } - check_size<map_t>(accessor, THREADS_NO * elems_per_thread); - check_order<map_t>(accessor); - }); + check_size<map_t>(accessor, THREADS_NO * elems_per_thread); + check_order<map_t>(accessor); + }); } diff --git a/tests/concurrent/sl_insert_competetive.cpp b/tests/concurrent/sl_insert_competetive.cpp index d5fd3b520..a06d933ba 100644 --- a/tests/concurrent/sl_insert_competetive.cpp +++ b/tests/concurrent/sl_insert_competetive.cpp @@ -1,8 +1,8 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 8); +constexpr size_t THREADS_NO = std::min(max_no_threads, 8); constexpr size_t elems_per_thread = 100000; -constexpr size_t key_range = elems_per_thread * THREADS_NO * 2; +constexpr size_t key_range = elems_per_thread * THREADS_NO * 2; // TODO: document the test @@ -10,37 +10,34 @@ constexpr size_t key_range = elems_per_thread * THREADS_NO * 2; // Threads will try to insert keys in the same order. // This will force threads to compete intensly with each other. // Test checks for missing data and changed/overwriten data. -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - map_t skiplist; + memory_check(THREADS_NO, [] { + map_t skiplist; - auto futures = run<std::vector<size_t>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - long long downcount = elems_per_thread; - std::vector<size_t> owned; - auto inserter = - insert_try<size_t, size_t, map_t>(acc, downcount, owned); + auto futures = run<std::vector<size_t>>( + THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + long long downcount = elems_per_thread; + std::vector<size_t> owned; + auto inserter = + insert_try<size_t, size_t, map_t>(acc, downcount, owned); - for (int i = 0; downcount > 0; i++) - { - inserter(i, index); - } + for (int i = 0; downcount > 0; i++) { + inserter(i, index); + } - check_present_same<map_t>(acc, index, owned); - return owned; - }); + check_present_same<map_t>(acc, index, owned); + return owned; + }); - auto accessor = skiplist.access(); - for (auto &owned : collect(futures)) - { - check_present_same<map_t>(accessor, owned); - } + auto accessor = skiplist.access(); + for (auto &owned : collect(futures)) { + check_present_same<map_t>(accessor, owned); + } - check_size<map_t>(accessor, THREADS_NO * elems_per_thread); - check_order<map_t>(accessor); - }); + check_size<map_t>(accessor, THREADS_NO * elems_per_thread); + check_order<map_t>(accessor); + }); } diff --git a/tests/concurrent/sl_map.cpp b/tests/concurrent/sl_map.cpp index 02d7da457..3b15b4afd 100644 --- a/tests/concurrent/sl_map.cpp +++ b/tests/concurrent/sl_map.cpp @@ -1,87 +1,78 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 8); +constexpr size_t THREADS_NO = std::min(max_no_threads, 8); constexpr size_t elems_per_thread = 1e5; // TODO: document the test -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [&] { - ds::static_array<std::thread, THREADS_NO> threads; - map_t skiplist; + memory_check(THREADS_NO, [&] { + ds::static_array<std::thread, THREADS_NO> threads; + map_t skiplist; - // put THREADS_NO * elems_per_thread items to the skiplist - for (size_t thread_i = 0; thread_i < THREADS_NO; ++thread_i) - { - threads[thread_i] = std::thread( - [&skiplist](size_t start, size_t end) { - auto accessor = skiplist.access(); - for (size_t elem_i = start; elem_i < end; ++elem_i) - { - accessor.insert(elem_i, elem_i); - } - }, - thread_i * elems_per_thread, - thread_i * elems_per_thread + elems_per_thread); - } - // wait all threads - for (auto &thread : threads) - { - thread.join(); - } - - // get skiplist size - { + // put THREADS_NO * elems_per_thread items to the skiplist + for (size_t thread_i = 0; thread_i < THREADS_NO; ++thread_i) { + threads[thread_i] = std::thread( + [&skiplist](size_t start, size_t end) { auto accessor = skiplist.access(); - permanent_assert(accessor.size() == THREADS_NO * elems_per_thread, - "all elements in skiplist"); - } - - for (size_t thread_i = 0; thread_i < THREADS_NO; ++thread_i) - { - threads[thread_i] = std::thread( - [&skiplist](size_t start, size_t end) { - auto accessor = skiplist.access(); - for (size_t elem_i = start; elem_i < end; ++elem_i) - { - permanent_assert(accessor.remove(elem_i) == true, ""); - } - }, - thread_i * elems_per_thread, - thread_i * elems_per_thread + elems_per_thread); - } - // // wait all threads - for (auto &thread : threads) - { - thread.join(); - } - - // check size - { - auto accessor = skiplist.access(); - permanent_assert(accessor.size() == 0, - "Size should be 0, but size is " - << accessor.size()); - } - - // check count - { - size_t iterator_counter = 0; - auto accessor = skiplist.access(); - for (auto elem : accessor) - { - ++iterator_counter; - cout << elem.first << " "; + for (size_t elem_i = start; elem_i < end; ++elem_i) { + accessor.insert(elem_i, elem_i); } - permanent_assert(iterator_counter == 0, "deleted elements"); - } + }, + thread_i * elems_per_thread, + thread_i * elems_per_thread + elems_per_thread); + } + // wait all threads + for (auto &thread : threads) { + thread.join(); + } - { + // get skiplist size + { + auto accessor = skiplist.access(); + permanent_assert(accessor.size() == THREADS_NO * elems_per_thread, + "all elements in skiplist"); + } + + for (size_t thread_i = 0; thread_i < THREADS_NO; ++thread_i) { + threads[thread_i] = std::thread( + [&skiplist](size_t start, size_t end) { auto accessor = skiplist.access(); - check_order<map_t>(accessor); - } - }); + for (size_t elem_i = start; elem_i < end; ++elem_i) { + permanent_assert(accessor.remove(elem_i) == true, ""); + } + }, + thread_i * elems_per_thread, + thread_i * elems_per_thread + elems_per_thread); + } + // // wait all threads + for (auto &thread : threads) { + thread.join(); + } + + // check size + { + auto accessor = skiplist.access(); + permanent_assert(accessor.size() == 0, "Size should be 0, but size is " + << accessor.size()); + } + + // check count + { + size_t iterator_counter = 0; + auto accessor = skiplist.access(); + for (auto elem : accessor) { + ++iterator_counter; + cout << elem.first << " "; + } + permanent_assert(iterator_counter == 0, "deleted elements"); + } + + { + auto accessor = skiplist.access(); + check_order<map_t>(accessor); + } + }); } diff --git a/tests/concurrent/sl_memory.cpp b/tests/concurrent/sl_memory.cpp index 1c544fcc0..f9529cb49 100644 --- a/tests/concurrent/sl_memory.cpp +++ b/tests/concurrent/sl_memory.cpp @@ -7,23 +7,21 @@ constexpr size_t elements = 2e6; * Put elements number of elements in the skiplist per each thread and see * is there any memory leak */ -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - map_t skiplist; + memory_check(THREADS_NO, [] { + map_t skiplist; - auto futures = - run<size_t>(THREADS_NO, skiplist, [](auto acc, auto index) { - for (size_t i = 0; i < elements; i++) { - acc.insert(i, index); - } - return index; - }); - collect(futures); - - auto accessor = skiplist.access(); - check_size<map_t>(accessor, elements); + auto futures = run<size_t>(THREADS_NO, skiplist, [](auto acc, auto index) { + for (size_t i = 0; i < elements; i++) { + acc.insert(i, index); + } + return index; }); + collect(futures); + + auto accessor = skiplist.access(); + check_size<map_t>(accessor, elements); + }); } diff --git a/tests/concurrent/sl_memory_leak.cpp b/tests/concurrent/sl_memory_leak.cpp index b58ee6335..808bdb499 100644 --- a/tests/concurrent/sl_memory_leak.cpp +++ b/tests/concurrent/sl_memory_leak.cpp @@ -1,6 +1,6 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 1); +constexpr size_t THREADS_NO = std::min(max_no_threads, 1); constexpr size_t elems_per_thread = 16e5; // TODO: Memory leak at 1,600,000 elements (Kruno wrote this here but @@ -9,78 +9,69 @@ constexpr size_t elems_per_thread = 16e5; // 2. analyse this code // 3. fix the memory leak // 4. write proper test -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [&] { - ds::static_array<std::thread, THREADS_NO> threads; - map_t skiplist; + memory_check(THREADS_NO, [&] { + ds::static_array<std::thread, THREADS_NO> threads; + map_t skiplist; - // put THREADS_NO * elems_per_thread items to the skiplist - for (size_t thread_i = 0; thread_i < THREADS_NO; ++thread_i) - { - threads[thread_i] = std::thread( - [&skiplist](size_t start, size_t end) { - auto accessor = skiplist.access(); - for (size_t elem_i = start; elem_i < end; ++elem_i) - { - accessor.insert(elem_i, elem_i); - } - }, - thread_i * elems_per_thread, - thread_i * elems_per_thread + elems_per_thread); - } - // wait all threads - for (auto &thread : threads) - { - thread.join(); - } - - // get skiplist size - { + // put THREADS_NO * elems_per_thread items to the skiplist + for (size_t thread_i = 0; thread_i < THREADS_NO; ++thread_i) { + threads[thread_i] = std::thread( + [&skiplist](size_t start, size_t end) { auto accessor = skiplist.access(); - permanent_assert(accessor.size() == THREADS_NO * elems_per_thread, - "all elements in skiplist"); - } - - for (size_t thread_i = 0; thread_i < THREADS_NO; ++thread_i) - { - threads[thread_i] = std::thread( - [&skiplist](size_t start, size_t end) { - auto accessor = skiplist.access(); - for (size_t elem_i = start; elem_i < end; ++elem_i) - { - permanent_assert(accessor.remove(elem_i) == true, ""); - } - }, - thread_i * elems_per_thread, - thread_i * elems_per_thread + elems_per_thread); - } - // // wait all threads - for (auto &thread : threads) - { - thread.join(); - } - - // check size - { - auto accessor = skiplist.access(); - permanent_assert(accessor.size() == 0, - "Size should be 0, but size is " - << accessor.size()); - } - - // check count - { - size_t iterator_counter = 0; - auto accessor = skiplist.access(); - for (auto elem : accessor) - { - ++iterator_counter; - cout << elem.first << " "; + for (size_t elem_i = start; elem_i < end; ++elem_i) { + accessor.insert(elem_i, elem_i); } - permanent_assert(iterator_counter == 0, "deleted elements"); - } - }); + }, + thread_i * elems_per_thread, + thread_i * elems_per_thread + elems_per_thread); + } + // wait all threads + for (auto &thread : threads) { + thread.join(); + } + + // get skiplist size + { + auto accessor = skiplist.access(); + permanent_assert(accessor.size() == THREADS_NO * elems_per_thread, + "all elements in skiplist"); + } + + for (size_t thread_i = 0; thread_i < THREADS_NO; ++thread_i) { + threads[thread_i] = std::thread( + [&skiplist](size_t start, size_t end) { + auto accessor = skiplist.access(); + for (size_t elem_i = start; elem_i < end; ++elem_i) { + permanent_assert(accessor.remove(elem_i) == true, ""); + } + }, + thread_i * elems_per_thread, + thread_i * elems_per_thread + elems_per_thread); + } + // // wait all threads + for (auto &thread : threads) { + thread.join(); + } + + // check size + { + auto accessor = skiplist.access(); + permanent_assert(accessor.size() == 0, "Size should be 0, but size is " + << accessor.size()); + } + + // check count + { + size_t iterator_counter = 0; + auto accessor = skiplist.access(); + for (auto elem : accessor) { + ++iterator_counter; + cout << elem.first << " "; + } + permanent_assert(iterator_counter == 0, "deleted elements"); + } + }); } diff --git a/tests/concurrent/sl_multiiterator.cpp b/tests/concurrent/sl_multiiterator.cpp index c1295db37..406bc74ce 100644 --- a/tests/concurrent/sl_multiiterator.cpp +++ b/tests/concurrent/sl_multiiterator.cpp @@ -13,47 +13,46 @@ constexpr size_t no_insert_for_one_delete = 1; * Calls of remove method are interleaved with insert calls which always * succeed. */ -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - multimap_t skiplist; + memory_check(THREADS_NO, [] { + multimap_t skiplist; - auto futures = run<std::vector<long long>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - auto rand_op = rand_gen_bool(no_insert_for_one_delete); - long long downcount = op_per_thread; - std::vector<long long> set(key_range, 0); + auto futures = run<std::vector<long long>>( + THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + auto rand_op = rand_gen_bool(no_insert_for_one_delete); + long long downcount = op_per_thread; + std::vector<long long> set(key_range, 0); - do { - size_t num = rand(); - auto data = num % max_number; - if (rand_op()) { - if (acc.remove(num)) { - downcount--; - set[num]--; - } - } else { - acc.insert(num, data); - downcount--; - set[num]++; - } - } while (downcount > 0); - - return set; - }); - - long set[key_range] = {0}; - for (auto &data : collect(futures)) { - for (int i = 0; i < key_range; i++) { - set[i] += data.second[i]; + do { + size_t num = rand(); + auto data = num % max_number; + if (rand_op()) { + if (acc.remove(num)) { + downcount--; + set[num]--; + } + } else { + acc.insert(num, data); + downcount--; + set[num]++; } - } + } while (downcount > 0); - auto accessor = skiplist.access(); - check_multi_iterator(accessor, key_range, set); - check_order<multimap_t>(accessor); - }); + return set; + }); + + long set[key_range] = {0}; + for (auto &data : collect(futures)) { + for (int i = 0; i < key_range; i++) { + set[i] += data.second[i]; + } + } + + auto accessor = skiplist.access(); + check_multi_iterator(accessor, key_range, set); + check_order<multimap_t>(accessor); + }); } diff --git a/tests/concurrent/sl_multiiterator_remove.cpp b/tests/concurrent/sl_multiiterator_remove.cpp index 2bbc6dabc..14dce18b1 100644 --- a/tests/concurrent/sl_multiiterator_remove.cpp +++ b/tests/concurrent/sl_multiiterator_remove.cpp @@ -1,10 +1,10 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 8); -constexpr size_t key_range = 1e4; +constexpr size_t THREADS_NO = std::min(max_no_threads, 8); +constexpr size_t key_range = 1e4; constexpr size_t op_per_thread = 1e5; // Depending on value there is a possiblity of numerical overflow -constexpr size_t max_number = 10; +constexpr size_t max_number = 10; constexpr size_t no_insert_for_one_delete = 1; /** @@ -13,93 +13,76 @@ constexpr size_t no_insert_for_one_delete = 1; * key values. Calls of remove method are interleaved with insert calls which * always succeed. */ -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - multimap_t skiplist; + memory_check(THREADS_NO, [] { + multimap_t skiplist; - auto futures = run<std::pair<long long, std::vector<long long>>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - auto rand_op = rand_gen_bool(no_insert_for_one_delete); - long long downcount = op_per_thread; - std::vector<long long> set(key_range, 0); - long long sum = 0; + auto futures = run<std::pair<long long, std::vector<long long>>>( + THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + auto rand_op = rand_gen_bool(no_insert_for_one_delete); + long long downcount = op_per_thread; + std::vector<long long> set(key_range, 0); + long long sum = 0; - do - { - size_t num = rand(); - auto data = rand() % max_number; - if (rand_op()) - { - - int len = 0; - for (auto it = acc.find_multi(num); it.has_value(); - it++) - { - len++; - } - if (len > 0) - { - int pos = rand() % len; - for (auto it = acc.find_multi(num); it.has_value(); - it++) - { - if (pos == 0) - { - auto data_r = it->second; - if (it.remove()) - { - downcount--; - set[num]--; - sum -= data_r; - permanent_assert( - it.is_removed(), - "is_removed method doesn't work"); - } - break; - } - pos--; - } - } + do { + size_t num = rand(); + auto data = rand() % max_number; + if (rand_op()) { + int len = 0; + for (auto it = acc.find_multi(num); it.has_value(); it++) { + len++; + } + if (len > 0) { + int pos = rand() % len; + for (auto it = acc.find_multi(num); it.has_value(); it++) { + if (pos == 0) { + auto data_r = it->second; + if (it.remove()) { + downcount--; + set[num]--; + sum -= data_r; + permanent_assert(it.is_removed(), + "is_removed method doesn't work"); } - else - { - acc.insert(num, data); - downcount--; - set[num]++; - sum += data; - } - } while (downcount > 0); - - return std::pair<long long, std::vector<long long>>(sum, set); - }); - - long set[key_range] = {0}; - long long sums = 0; - for (auto &data : collect(futures)) - { - sums += data.second.first; - for (int i = 0; i < key_range; i++) - { - set[i] += data.second.second[i]; + break; + } + pos--; + } + } + } else { + acc.insert(num, data); + downcount--; + set[num]++; + sum += data; } - } + } while (downcount > 0); - auto accessor = skiplist.access(); - check_multi_iterator(accessor, key_range, set); + return std::pair<long long, std::vector<long long>>(sum, set); + }); - for (auto &e : accessor) - { - set[e.first]--; - sums -= e.second; - } - permanent_assert(sums == 0, "Aproximetly Same values are present"); + long set[key_range] = {0}; + long long sums = 0; + for (auto &data : collect(futures)) { + sums += data.second.first; + for (int i = 0; i < key_range; i++) { + set[i] += data.second.second[i]; + } + } - check_zero(key_range, set, "MultiMap"); + auto accessor = skiplist.access(); + check_multi_iterator(accessor, key_range, set); - check_order<multimap_t>(accessor); - }); + for (auto &e : accessor) { + set[e.first]--; + sums -= e.second; + } + permanent_assert(sums == 0, "Aproximetly Same values are present"); + + check_zero(key_range, set, "MultiMap"); + + check_order<multimap_t>(accessor); + }); } diff --git a/tests/concurrent/sl_multiiterator_remove_duplicates.cpp b/tests/concurrent/sl_multiiterator_remove_duplicates.cpp index 1774276e6..083832e1a 100644 --- a/tests/concurrent/sl_multiiterator_remove_duplicates.cpp +++ b/tests/concurrent/sl_multiiterator_remove_duplicates.cpp @@ -1,10 +1,10 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 4); -constexpr size_t key_range = 1e4; +constexpr size_t THREADS_NO = std::min(max_no_threads, 4); +constexpr size_t key_range = 1e4; constexpr size_t op_per_thread = 1e5; // Depending on value there is a possiblity of numerical overflow -constexpr size_t max_number = 10; +constexpr size_t max_number = 10; constexpr size_t no_insert_for_one_delete = 2; /** @@ -13,82 +13,70 @@ constexpr size_t no_insert_for_one_delete = 2; * same key values. Calls of remove method are interleaved with insert calls * which always succeed. */ -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - multimap_t skiplist; + memory_check(THREADS_NO, [] { + multimap_t skiplist; - auto futures = run<std::pair<long long, std::vector<long long>>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - auto rand_op = rand_gen_bool(no_insert_for_one_delete); - long long downcount = op_per_thread; - std::vector<long long> set(key_range, 0); - long long sum = 0; + auto futures = run<std::pair<long long, std::vector<long long>>>( + THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + auto rand_op = rand_gen_bool(no_insert_for_one_delete); + long long downcount = op_per_thread; + std::vector<long long> set(key_range, 0); + long long sum = 0; - do - { - size_t num = rand(); - auto data = rand() % max_number; - if (rand_op()) - { - auto it = acc.find_multi(num); - if (it.has_value()) - { - it++; - while (it.has_value()) - { - auto data_r = it->second; - if (it.remove()) - { - downcount--; - set[num]--; - sum -= data_r; - permanent_assert( - it.is_removed(), - "is_removed method doesn't work"); - } - it++; - } - } - } - else - { - acc.insert(num, data); - downcount--; - set[num]++; - sum += data; - } - } while (downcount > 0); - - return std::pair<long long, std::vector<long long>>(sum, set); - }); - - long set[key_range] = {0}; - long long sums = 0; - for (auto &data : collect(futures)) - { - sums += data.second.first; - for (int i = 0; i < key_range; i++) - { - set[i] += data.second.second[i]; + do { + size_t num = rand(); + auto data = rand() % max_number; + if (rand_op()) { + auto it = acc.find_multi(num); + if (it.has_value()) { + it++; + while (it.has_value()) { + auto data_r = it->second; + if (it.remove()) { + downcount--; + set[num]--; + sum -= data_r; + permanent_assert(it.is_removed(), + "is_removed method doesn't work"); + } + it++; + } + } + } else { + acc.insert(num, data); + downcount--; + set[num]++; + sum += data; } - } + } while (downcount > 0); - auto accessor = skiplist.access(); - check_multi_iterator(accessor, key_range, set); + return std::pair<long long, std::vector<long long>>(sum, set); + }); - for (auto &e : accessor) - { - set[e.first]--; - sums -= e.second; - } - permanent_assert(sums == 0, "Aproximetly Same values are present"); + long set[key_range] = {0}; + long long sums = 0; + for (auto &data : collect(futures)) { + sums += data.second.first; + for (int i = 0; i < key_range; i++) { + set[i] += data.second.second[i]; + } + } - check_zero(key_range, set, "MultiMap"); + auto accessor = skiplist.access(); + check_multi_iterator(accessor, key_range, set); - check_order<multimap_t>(accessor); - }); + for (auto &e : accessor) { + set[e.first]--; + sums -= e.second; + } + permanent_assert(sums == 0, "Aproximetly Same values are present"); + + check_zero(key_range, set, "MultiMap"); + + check_order<multimap_t>(accessor); + }); } diff --git a/tests/concurrent/sl_multimap.cpp b/tests/concurrent/sl_multimap.cpp index fb7eeae82..c794f3537 100644 --- a/tests/concurrent/sl_multimap.cpp +++ b/tests/concurrent/sl_multimap.cpp @@ -1,10 +1,10 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 8); -constexpr size_t key_range = 1e4; +constexpr size_t THREADS_NO = std::min(max_no_threads, 8); +constexpr size_t key_range = 1e4; constexpr size_t op_per_thread = 1e5; // Depending on value there is a possiblity of numerical overflow -constexpr size_t max_number = 10; +constexpr size_t max_number = 10; constexpr size_t no_insert_for_one_delete = 1; // TODO: document the test @@ -13,124 +13,107 @@ constexpr size_t no_insert_for_one_delete = 1; // Each thread removes random data. So removes are joint. // Calls of remove method are interleaved with insert calls which always // succeed. -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - multimap_t skiplist; - std::atomic<long long> size(0); + memory_check(THREADS_NO, [] { + multimap_t skiplist; + std::atomic<long long> size(0); - auto futures = run<std::pair<long long, std::vector<long long>>>( - THREADS_NO, skiplist, [&size](auto acc, auto index) { - auto rand = rand_gen(key_range); - auto rand_op = rand_gen_bool(no_insert_for_one_delete); - long long downcount = op_per_thread; - std::vector<long long> set(key_range, 0); - long long sum = 0; + auto futures = run<std::pair<long long, std::vector<long long>>>( + THREADS_NO, skiplist, [&size](auto acc, auto index) { + auto rand = rand_gen(key_range); + auto rand_op = rand_gen_bool(no_insert_for_one_delete); + long long downcount = op_per_thread; + std::vector<long long> set(key_range, 0); + long long sum = 0; - do - { - size_t num = rand(); - auto data = num % max_number; - if (rand_op()) - { - if (acc.remove(num)) - { - downcount--; - set[num]--; - sum -= data; - size--; - } - } - else - { - acc.insert(num, data); - downcount--; - set[num]++; - sum += data; - size++; - } - } while (downcount > 0); - - return std::pair<long long, std::vector<long long>>(sum, set); - }); - - long set[key_range] = {0}; - long long sums = 0; - long long size_calc = 0; - for (auto &data : collect(futures)) - { - sums += data.second.first; - for (int i = 0; i < key_range; i++) - { - set[i] += data.second.second[i]; - size_calc += data.second.second[i]; + do { + size_t num = rand(); + auto data = num % max_number; + if (rand_op()) { + if (acc.remove(num)) { + downcount--; + set[num]--; + sum -= data; + size--; + } + } else { + acc.insert(num, data); + downcount--; + set[num]++; + sum += data; + size++; } - } - auto accessor = skiplist.access(); - permanent_assert(size == size_calc, "Set size isn't same as counted"); - check_size<multimap_t>(accessor, size); - check_order<multimap_t>(accessor); + } while (downcount > 0); - auto bef_it = accessor.end(); - for (int i = 0; i < key_range; i++) - { - auto it = accessor.find(i); - if (set[i] > 0) - { - permanent_assert(it != accessor.end(), - "Multimap doesn't contain necessary element " - << i); + return std::pair<long long, std::vector<long long>>(sum, set); + }); - if (bef_it == accessor.end()) bef_it = accessor.find(i); - for (int j = 0; j < set[i]; j++) - { - permanent_assert( - bef_it != accessor.end(), - "Previous iterator doesn't iterate through same " - "key entrys. Expected " - << i << " for " << set[i] - j - << " more times but found null"); - permanent_assert( - bef_it->first == i, - "Previous iterator doesn't iterate through same " - "key entrys. Expected " - << i << " for " << set[i] - j - << " more times but found " << bef_it->first - << ". Occurances should be " << set[i]); - bef_it++; - } + long set[key_range] = {0}; + long long sums = 0; + long long size_calc = 0; + for (auto &data : collect(futures)) { + sums += data.second.first; + for (int i = 0; i < key_range; i++) { + set[i] += data.second.second[i]; + size_calc += data.second.second[i]; + } + } + auto accessor = skiplist.access(); + permanent_assert(size == size_calc, "Set size isn't same as counted"); + check_size<multimap_t>(accessor, size); + check_order<multimap_t>(accessor); - for (int j = 0; j < set[i]; j++) - { - permanent_assert(it != accessor.end(), - "Iterator doesn't iterate through same " - "key entrys. Expected " - << i << " for " << set[i] - j - << " more times but found null"); - permanent_assert( - it->first == i, - "Iterator doesn't iterate through same " - "key entrys. Expected " - << i << " for " << set[i] - j - << " more times but found " << it->first - << ". Occurances should be " << set[i]); - it++; - } - permanent_assert(it == accessor.end() || it->first != i, - "There is more data than it should be."); - bef_it = it; - } + auto bef_it = accessor.end(); + for (int i = 0; i < key_range; i++) { + auto it = accessor.find(i); + if (set[i] > 0) { + permanent_assert(it != accessor.end(), + "Multimap doesn't contain necessary element " << i); + + if (bef_it == accessor.end()) bef_it = accessor.find(i); + for (int j = 0; j < set[i]; j++) { + permanent_assert(bef_it != accessor.end(), + "Previous iterator doesn't iterate through same " + "key entrys. Expected " + << i << " for " << set[i] - j + << " more times but found null"); + permanent_assert(bef_it->first == i, + "Previous iterator doesn't iterate through same " + "key entrys. Expected " + << i << " for " << set[i] - j + << " more times but found " << bef_it->first + << ". Occurances should be " << set[i]); + bef_it++; } - for (auto &e : accessor) - { - set[e.first]--; - sums -= e.second; + for (int j = 0; j < set[i]; j++) { + permanent_assert(it != accessor.end(), + "Iterator doesn't iterate through same " + "key entrys. Expected " + << i << " for " << set[i] - j + << " more times but found null"); + permanent_assert(it->first == i, + "Iterator doesn't iterate through same " + "key entrys. Expected " + << i << " for " << set[i] - j + << " more times but found " << it->first + << ". Occurances should be " << set[i]); + it++; } - permanent_assert(sums == 0, "Aproximetly Same values are present"); + permanent_assert(it == accessor.end() || it->first != i, + "There is more data than it should be."); + bef_it = it; + } + } - check_zero(key_range, set, "MultiMap"); - }); + for (auto &e : accessor) { + set[e.first]--; + sums -= e.second; + } + permanent_assert(sums == 0, "Aproximetly Same values are present"); + + check_zero(key_range, set, "MultiMap"); + }); } diff --git a/tests/concurrent/sl_multiset.cpp b/tests/concurrent/sl_multiset.cpp index 6c9ce1c2e..bdccc0947 100644 --- a/tests/concurrent/sl_multiset.cpp +++ b/tests/concurrent/sl_multiset.cpp @@ -11,64 +11,62 @@ constexpr size_t no_insert_for_one_delete = 1; // Each thread removes random data. So removes are joint. // Calls of remove method are interleaved with insert calls which always // succeed. -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - multiset_t skiplist; + memory_check(THREADS_NO, [] { + multiset_t skiplist; - auto futures = run<std::vector<long>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - auto rand_op = rand_gen_bool(no_insert_for_one_delete); - long long downcount = op_per_thread; - std::vector<long> set(key_range, 0); + auto futures = + run<std::vector<long>>(THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + auto rand_op = rand_gen_bool(no_insert_for_one_delete); + long long downcount = op_per_thread; + std::vector<long> set(key_range, 0); - do { - size_t num = rand(); - if (rand_op()) { - if (acc.remove(num)) { - downcount--; - set[num]--; - } - } else { - acc.insert(num); - downcount--; - set[num]++; - } - } while (downcount > 0); - - return set; - }); - - long set[key_range] = {0}; - for (auto &data : collect(futures)) { - for (int i = 0; i < key_range; i++) { - set[i] += data.second[i]; + do { + size_t num = rand(); + if (rand_op()) { + if (acc.remove(num)) { + downcount--; + set[num]--; + } + } else { + acc.insert(num); + downcount--; + set[num]++; } + } while (downcount > 0); + + return set; + }); + + long set[key_range] = {0}; + for (auto &data : collect(futures)) { + for (int i = 0; i < key_range; i++) { + set[i] += data.second[i]; + } + } + + auto accessor = skiplist.access(); + for (int i = 0; i < key_range; i++) { + auto it = accessor.find(i); + if (set[i] > 0) { + for (int j = 0; j < set[i]; j++) { + permanent_assert(it == i, + "Iterator doesn't iterate through same key entrys"); + it++; } + } + permanent_assert(it == accessor.end() || it != i, + "There is more data than it should be."); + } - auto accessor = skiplist.access(); - for (int i = 0; i < key_range; i++) { - auto it = accessor.find(i); - if (set[i] > 0) { - for (int j = 0; j < set[i]; j++) { - permanent_assert( - it == i, - "Iterator doesn't iterate through same key entrys"); - it++; - } - } - permanent_assert(it == accessor.end() || it != i, - "There is more data than it should be."); - } + for (auto &e : accessor) { + set[e]--; + } - for (auto &e : accessor) { - set[e]--; - } + check_zero(key_range, set, "MultiSet"); - check_zero(key_range, set, "MultiSet"); - - }); + }); } diff --git a/tests/concurrent/sl_remove_competetive.cpp b/tests/concurrent/sl_remove_competetive.cpp index d4636d36a..af5393a12 100644 --- a/tests/concurrent/sl_remove_competetive.cpp +++ b/tests/concurrent/sl_remove_competetive.cpp @@ -12,57 +12,56 @@ constexpr size_t no_insert_for_one_delete = 2; // Threads will try to insert and remove keys aproximetly in the same order. // This will force threads to compete intensly with each other. // Calls of remove method are interleaved with insert calls. -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - map_t skiplist; + memory_check(THREADS_NO, [] { + map_t skiplist; - auto futures = run<std::pair<long long, long long>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand_op = rand_gen_bool(no_insert_for_one_delete); - long long downcount = op_per_thread; - long long sum = 0; - long long count = 0; + auto futures = run<std::pair<long long, long long>>( + THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand_op = rand_gen_bool(no_insert_for_one_delete); + long long downcount = op_per_thread; + long long sum = 0; + long long count = 0; - for (int i = 0; downcount > 0; i++) { - auto data = i % max_number; - if (rand_op()) { - auto t = i; - while (t > 0) { - if (acc.remove(t)) { - sum -= t % max_number; - downcount--; - count--; - break; - } - t--; - } - } else { - if (acc.insert(i, data).second) { - sum += data; - count++; - downcount--; - } - } + for (int i = 0; downcount > 0; i++) { + auto data = i % max_number; + if (rand_op()) { + auto t = i; + while (t > 0) { + if (acc.remove(t)) { + sum -= t % max_number; + downcount--; + count--; + break; } - return std::pair<long long, long long>(sum, count); - }); + t--; + } + } else { + if (acc.insert(i, data).second) { + sum += data; + count++; + downcount--; + } + } + } + return std::pair<long long, long long>(sum, count); + }); - auto accessor = skiplist.access(); - long long sums = 0; - long long counters = 0; - for (auto &data : collect(futures)) { - sums += data.second.first; - counters += data.second.second; - } + auto accessor = skiplist.access(); + long long sums = 0; + long long counters = 0; + for (auto &data : collect(futures)) { + sums += data.second.first; + counters += data.second.second; + } - for (auto &e : accessor) { - sums -= e.second; - } - permanent_assert(sums == 0, "Aproximetly Same values are present"); - check_size<map_t>(accessor, counters); - check_order<map_t>(accessor); - }); + for (auto &e : accessor) { + sums -= e.second; + } + permanent_assert(sums == 0, "Aproximetly Same values are present"); + check_size<map_t>(accessor, counters); + check_order<map_t>(accessor); + }); } diff --git a/tests/concurrent/sl_remove_disjoint.cpp b/tests/concurrent/sl_remove_disjoint.cpp index 03e9cacfa..063903269 100644 --- a/tests/concurrent/sl_remove_disjoint.cpp +++ b/tests/concurrent/sl_remove_disjoint.cpp @@ -10,45 +10,43 @@ constexpr size_t no_insert_for_one_delete = 1; // This test checks remove method under pressure. // Each thread removes it's own data. So removes are disjoint. // Calls of remove method are interleaved with insert calls. -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - map_t skiplist; + memory_check(THREADS_NO, [] { + map_t skiplist; - auto futures = run<std::vector<size_t>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - auto rand_op = rand_gen_bool(no_insert_for_one_delete); - long long downcount = op_per_thread; - std::vector<size_t> owned; - auto inserter = - insert_try<size_t, size_t, map_t>(acc, downcount, owned); + auto futures = run<std::vector<size_t>>( + THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + auto rand_op = rand_gen_bool(no_insert_for_one_delete); + long long downcount = op_per_thread; + std::vector<size_t> owned; + auto inserter = + insert_try<size_t, size_t, map_t>(acc, downcount, owned); - do { - if (owned.size() != 0 && rand_op()) { - auto rem = rand() % owned.size(); - permanent_assert(acc.remove(owned[rem]), - "Owned data removed"); - owned.erase(owned.begin() + rem); - downcount--; - } else { - inserter(rand(), index); - } - } while (downcount > 0); + do { + if (owned.size() != 0 && rand_op()) { + auto rem = rand() % owned.size(); + permanent_assert(acc.remove(owned[rem]), "Owned data removed"); + owned.erase(owned.begin() + rem); + downcount--; + } else { + inserter(rand(), index); + } + } while (downcount > 0); - check_present_same<map_t>(acc, index, owned); - return owned; - }); + check_present_same<map_t>(acc, index, owned); + return owned; + }); - auto accessor = skiplist.access(); - size_t count = 0; - for (auto &owned : collect(futures)) { - check_present_same<map_t>(accessor, owned); - count += owned.second.size(); - } - check_size<map_t>(accessor, count); - check_order<map_t>(accessor); - }); + auto accessor = skiplist.access(); + size_t count = 0; + for (auto &owned : collect(futures)) { + check_present_same<map_t>(accessor, owned); + count += owned.second.size(); + } + check_size<map_t>(accessor, count); + check_order<map_t>(accessor); + }); } diff --git a/tests/concurrent/sl_remove_joint.cpp b/tests/concurrent/sl_remove_joint.cpp index aca62a0a4..6942c4349 100644 --- a/tests/concurrent/sl_remove_joint.cpp +++ b/tests/concurrent/sl_remove_joint.cpp @@ -1,10 +1,10 @@ #include "common.h" -constexpr size_t THREADS_NO = std::min(max_no_threads, 8); -constexpr size_t key_range = 1e4; +constexpr size_t THREADS_NO = std::min(max_no_threads, 8); +constexpr size_t key_range = 1e4; constexpr size_t op_per_thread = 1e5; // Depending on value there is a possiblity of numerical overflow -constexpr size_t max_number = 10; +constexpr size_t max_number = 10; constexpr size_t no_insert_for_one_delete = 2; // TODO: document the test @@ -12,62 +12,53 @@ constexpr size_t no_insert_for_one_delete = 2; // This test checks remove method under pressure. // Each thread removes random data. So removes are joint. // Calls of remove method are interleaved with insert calls. -int main() -{ - init_log(); - memory_check(THREADS_NO, [] { - map_t skiplist; +int main() { + init_log(); + memory_check(THREADS_NO, [] { + map_t skiplist; - auto futures = run<std::pair<long long, long long>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - auto rand_op = rand_gen_bool(no_insert_for_one_delete); - long long downcount = op_per_thread; - long long sum = 0; - long long count = 0; + auto futures = run<std::pair<long long, long long>>( + THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + auto rand_op = rand_gen_bool(no_insert_for_one_delete); + long long downcount = op_per_thread; + long long sum = 0; + long long count = 0; - do - { - auto num = rand(); - auto data = num % max_number; - if (rand_op()) - { - if (acc.remove(num)) - { - sum -= data; - downcount--; - count--; - } - } - else - { - if (acc.insert(num, data).second) - { - sum += data; - downcount--; - count++; - } - } - } while (downcount > 0); + do { + auto num = rand(); + auto data = num % max_number; + if (rand_op()) { + if (acc.remove(num)) { + sum -= data; + downcount--; + count--; + } + } else { + if (acc.insert(num, data).second) { + sum += data; + downcount--; + count++; + } + } + } while (downcount > 0); - return std::pair<long long, long long>(sum, count); - }); + return std::pair<long long, long long>(sum, count); + }); - auto accessor = skiplist.access(); - long long sums = 0; - long long counters = 0; - for (auto &data : collect(futures)) - { - sums += data.second.first; - counters += data.second.second; - } + auto accessor = skiplist.access(); + long long sums = 0; + long long counters = 0; + for (auto &data : collect(futures)) { + sums += data.second.first; + counters += data.second.second; + } - for (auto &e : accessor) - { - sums -= e.second; - } - permanent_assert(sums == 0, "Aproximetly Same values are present"); - check_size<map_t>(accessor, counters); - check_order<map_t>(accessor); - }); + for (auto &e : accessor) { + sums -= e.second; + } + permanent_assert(sums == 0, "Aproximetly Same values are present"); + check_size<map_t>(accessor, counters); + check_order<map_t>(accessor); + }); } diff --git a/tests/concurrent/sl_set.cpp b/tests/concurrent/sl_set.cpp index a287c7a0b..57a4976c2 100644 --- a/tests/concurrent/sl_set.cpp +++ b/tests/concurrent/sl_set.cpp @@ -10,58 +10,57 @@ constexpr size_t no_insert_for_one_delete = 2; // This test checks set. // Each thread removes random data. So removes are joint. // Calls of remove method are interleaved with insert calls. -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - ConcurrentSet<std::string> skiplist; + memory_check(THREADS_NO, [] { + ConcurrentSet<std::string> skiplist; - auto futures = run<std::vector<long>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - auto rand_op = rand_gen_bool(no_insert_for_one_delete); - long long downcount = op_per_thread; - std::vector<long> set(key_range); + auto futures = + run<std::vector<long>>(THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + auto rand_op = rand_gen_bool(no_insert_for_one_delete); + long long downcount = op_per_thread; + std::vector<long> set(key_range); - do { - int num = rand(); - std::string num_str = std::to_string(num); - if (rand_op()) { - if (acc.remove(num_str)) { - downcount--; - set[num]--; - } - } else { - std::string num_str = std::to_string(num); - if (acc.insert(num_str).second) { - downcount--; - set[num]++; - } - } - } while (downcount > 0); - - return set; - }); - - long set[key_range] = {0}; - for (auto &data : collect(futures)) { - for (int i = 0; i < key_range; i++) { - set[i] += data.second[i]; + do { + int num = rand(); + std::string num_str = std::to_string(num); + if (rand_op()) { + if (acc.remove(num_str)) { + downcount--; + set[num]--; + } + } else { + std::string num_str = std::to_string(num); + if (acc.insert(num_str).second) { + downcount--; + set[num]++; + } } - } + } while (downcount > 0); - auto accessor = skiplist.access(); - for (int i = 0; i < key_range; i++) { - permanent_assert(set[i] == 0 || set[i] == 1 || - (set[i] == 1) ^ accessor.contains(std::to_string(i)), - "Set doesn't hold it's guarantees."); - } + return set; + }); - for (auto &e : accessor) { - set[std::stoi(e)]--; - } + long set[key_range] = {0}; + for (auto &data : collect(futures)) { + for (int i = 0; i < key_range; i++) { + set[i] += data.second[i]; + } + } - check_zero(key_range, set, "Set"); - }); + auto accessor = skiplist.access(); + for (int i = 0; i < key_range; i++) { + permanent_assert(set[i] == 0 || set[i] == 1 || + (set[i] == 1) ^ accessor.contains(std::to_string(i)), + "Set doesn't hold it's guarantees."); + } + + for (auto &e : accessor) { + set[std::stoi(e)]--; + } + + check_zero(key_range, set, "Set"); + }); } diff --git a/tests/concurrent/sl_simulation.cpp b/tests/concurrent/sl_simulation.cpp index 8d152811b..57394e8f8 100644 --- a/tests/concurrent/sl_simulation.cpp +++ b/tests/concurrent/sl_simulation.cpp @@ -14,60 +14,58 @@ constexpr size_t no_insert_for_one_delete = 1; // Each thread makes a series of finds interleaved with method which change. // Exact ratio of finds per change and insert per delete can be regulated with // no_find_per_change and no_insert_for_one_delete. -int main() -{ - init_log(); +int main() { + init_log(); - memory_check(THREADS_NO, [] { - map_t skiplist; + memory_check(THREADS_NO, [] { + map_t skiplist; - auto futures = run<std::pair<long long, long long>>( - THREADS_NO, skiplist, [](auto acc, auto index) { - auto rand = rand_gen(key_range); - auto rand_change = rand_gen_bool(no_find_per_change); - auto rand_delete = rand_gen_bool(no_insert_for_one_delete); - long long sum = 0; - long long count = 0; + auto futures = run<std::pair<long long, long long>>( + THREADS_NO, skiplist, [](auto acc, auto index) { + auto rand = rand_gen(key_range); + auto rand_change = rand_gen_bool(no_find_per_change); + auto rand_delete = rand_gen_bool(no_insert_for_one_delete); + long long sum = 0; + long long count = 0; - for (int i = 0; i < op_per_thread; i++) { - auto num = rand(); - auto data = num % max_number; - if (rand_change()) { - if (rand_delete()) { - if (acc.remove(num)) { - sum -= data; - count--; - } - } else { - if (acc.insert(num, data).second) { - sum += data; - count++; - } - } - } else { - auto value = acc.find(num); - permanent_assert(value == acc.end() || - value->second == data, - "Data is invalid"); - } + for (int i = 0; i < op_per_thread; i++) { + auto num = rand(); + auto data = num % max_number; + if (rand_change()) { + if (rand_delete()) { + if (acc.remove(num)) { + sum -= data; + count--; } + } else { + if (acc.insert(num, data).second) { + sum += data; + count++; + } + } + } else { + auto value = acc.find(num); + permanent_assert(value == acc.end() || value->second == data, + "Data is invalid"); + } + } - return std::pair<long long, long long>(sum, count); - }); + return std::pair<long long, long long>(sum, count); + }); - auto accessor = skiplist.access(); - long long sums = 0; - long long counters = 0; - for (auto &data : collect(futures)) { - sums += data.second.first; - counters += data.second.second; - } + auto accessor = skiplist.access(); + long long sums = 0; + long long counters = 0; + for (auto &data : collect(futures)) { + sums += data.second.first; + counters += data.second.second; + } - for (auto &e : accessor) { - sums -= e.second; - } - permanent_assert(sums == 0, "Same values aren't present"); - check_size<map_t>(accessor, counters); - check_order<map_t>(accessor); - }); + for (auto &e : accessor) { + sums -= e.second; + } + permanent_assert(sums == 0, "Same values aren't present"); + check_size<map_t>(accessor, counters); + check_order<map_t>(accessor); + }); } diff --git a/tests/concurrent/timer.cpp b/tests/concurrent/timer.cpp index c3874ef62..8924bce6e 100644 --- a/tests/concurrent/timer.cpp +++ b/tests/concurrent/timer.cpp @@ -1,11 +1,11 @@ -#include <iostream> #include <chrono> +#include <iostream> #include "gtest/gtest.h" #include "logging/default.cpp" -#include "utils/timer/timer.hpp" #include "utils/assert.hpp" +#include "utils/timer/timer.hpp" using namespace std::chrono_literals; @@ -16,45 +16,41 @@ using namespace std::chrono_literals; * * @return shared pointer to a timer */ -Timer::sptr create_test_timer(int64_t counter) -{ - return std::make_shared<Timer>( - counter, [](){ logging::info("Timer timeout"); } - ); +Timer::sptr create_test_timer(int64_t counter) { + return std::make_shared<Timer>(counter, + []() { logging::info("Timer timeout"); }); } -TEST(TimerSchedulerTest, TimerSchedulerExecution) -{ - // initialize the timer - TimerScheduler<TimerSet, std::chrono::seconds> timer_scheduler; +TEST(TimerSchedulerTest, TimerSchedulerExecution) { + // initialize the timer + TimerScheduler<TimerSet, std::chrono::seconds> timer_scheduler; - // run the timer - timer_scheduler.run(); + // run the timer + timer_scheduler.run(); - // add a couple of test timers - for (int64_t i = 1; i <= 3; ++i) { - timer_scheduler.add(create_test_timer(i)); - } + // add a couple of test timers + for (int64_t i = 1; i <= 3; ++i) { + timer_scheduler.add(create_test_timer(i)); + } - // wait for that timers - std::this_thread::sleep_for(4s); + // wait for that timers + std::this_thread::sleep_for(4s); - ASSERT_EQ(timer_scheduler.size(), 0); + ASSERT_EQ(timer_scheduler.size(), 0); - // add another test timer - timer_scheduler.add(create_test_timer(1)); + // add another test timer + timer_scheduler.add(create_test_timer(1)); - // wait for another timer - std::this_thread::sleep_for(2s); - - // the test is done - timer_scheduler.stop(); + // wait for another timer + std::this_thread::sleep_for(2s); - ASSERT_EQ(timer_scheduler.size(), 0); + // the test is done + timer_scheduler.stop(); + + ASSERT_EQ(timer_scheduler.size(), 0); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/integration/hardcoded_query/clique_001.cpp b/tests/integration/hardcoded_query/clique_001.cpp index 71baff31e..24a130f64 100644 --- a/tests/integration/hardcoded_query/clique_001.cpp +++ b/tests/integration/hardcoded_query/clique_001.cpp @@ -16,7 +16,10 @@ using std::endl; // Dressipi astar query of 4 clicks. -// Query: MATCH (a:garment)-[:default_outfit]-(b:garment)-[:default_outfit]-(c:garment)-[:default_outfit]-(d:garment)-[:default_outfit]-(a:garment)-[:default_outfit]-(c:garment), (b:garment)-[:default_outfit]-(d:garment) RETURN a.garment_id,b.garment_id,c.garment_id,d.garment_id +// Query: MATCH +// (a:garment)-[:default_outfit]-(b:garment)-[:default_outfit]-(c:garment)-[:default_outfit]-(d:garment)-[:default_outfit]-(a:garment)-[:default_outfit]-(c:garment), +// (b:garment)-[:default_outfit]-(d:garment) RETURN +// a.garment_id,b.garment_id,c.garment_id,d.garment_id // TODO: figure out from the pattern in a query constexpr size_t max_depth = 3; @@ -24,162 +27,143 @@ constexpr size_t max_depth = 3; // TODO: from query LIMIT 10 constexpr size_t limit = 10; -class Node -{ -public: - Node *parent = {nullptr}; - VertexPropertyType<Float> tkey; - double cost; - int depth = {0}; - double sum = {0.0}; - VertexAccessor vacc; +class Node { + public: + Node *parent = {nullptr}; + VertexPropertyType<Float> tkey; + double cost; + int depth = {0}; + double sum = {0.0}; + VertexAccessor vacc; - Node(VertexAccessor vacc, double cost, - VertexPropertyType<Float> const &tkey) - : cost(cost), vacc(vacc), tkey(tkey) - { - } - Node(VertexAccessor vacc, double cost, Node *parent, - VertexPropertyType<Float> const &tkey) - : cost(cost), vacc(vacc), parent(parent), depth(parent->depth + 1), - tkey(tkey) - { - } + Node(VertexAccessor vacc, double cost, VertexPropertyType<Float> const &tkey) + : cost(cost), vacc(vacc), tkey(tkey) {} + Node(VertexAccessor vacc, double cost, Node *parent, + VertexPropertyType<Float> const &tkey) + : cost(cost), + vacc(vacc), + parent(parent), + depth(parent->depth + 1), + tkey(tkey) {} - double sum_vertex_score() - { - auto now = this; - double sum = 0; - do - { - sum += (now->vacc.at(tkey).get())->value(); - now = now->parent; - } while (now != nullptr); - this->sum = sum; - return sum; - } + double sum_vertex_score() { + auto now = this; + double sum = 0; + do { + sum += (now->vacc.at(tkey).get())->value(); + now = now->parent; + } while (now != nullptr); + this->sum = sum; + return sum; + } }; -bool vertex_filter_contained(DbAccessor &t, VertexAccessor &v, Node *before) -{ - if (v.fill()) - { - bool found; - do - { - found = false; - before = before->parent; - if (before == nullptr) - { - return true; - } - } while (v.in_contains(before->vacc)); - } - return false; +bool vertex_filter_contained(DbAccessor &t, VertexAccessor &v, Node *before) { + if (v.fill()) { + bool found; + do { + found = false; + before = before->parent; + if (before == nullptr) { + return true; + } + } while (v.in_contains(before->vacc)); + } + return false; } template <typename Stream> -auto astar(VertexAccessor &va, DbAccessor &t, plan_args_t &, Stream &) -{ - StackAllocator stack; - std::vector<Node *> results; +auto astar(VertexAccessor &va, DbAccessor &t, plan_args_t &, Stream &) { + StackAllocator stack; + std::vector<Node *> results; - // TODO: variable part (extract) - VertexPropertyType<Float> tkey = t.vertex_property_key<Float>("score"); + // TODO: variable part (extract) + VertexPropertyType<Float> tkey = t.vertex_property_key<Float>("score"); - auto cmp = [](Node *left, Node *right) { return left->cost > right->cost; }; - std::priority_queue<Node *, std::vector<Node *>, decltype(cmp)> queue(cmp); + auto cmp = [](Node *left, Node *right) { return left->cost > right->cost; }; + std::priority_queue<Node *, std::vector<Node *>, decltype(cmp)> queue(cmp); - Node *start = new (stack.allocate<Node>()) Node(va, 0, tkey); - queue.push(start); + Node *start = new (stack.allocate<Node>()) Node(va, 0, tkey); + queue.push(start); - size_t count = 0; - do - { - auto now = queue.top(); - queue.pop(); + size_t count = 0; + do { + auto now = queue.top(); + queue.pop(); - if (now->depth >= max_depth) - { - now->sum_vertex_score(); - results.emplace_back(now); + if (now->depth >= max_depth) { + now->sum_vertex_score(); + results.emplace_back(now); - count++; + count++; - if (count >= limit) - { - // the limit was reached -> STOP the execution - break; - } + if (count >= limit) { + // the limit was reached -> STOP the execution + break; + } - // if the limit wasn't reached -> POP the next vertex - continue; - } - - iter::for_all(now->vacc.out(), [&](auto edge) { - VertexAccessor va = edge.to(); - if (vertex_filter_contained(t, va, now)) - { - auto cost = 1 - va.at(tkey).get()->value(); - Node *n = new (stack.allocate<Node>()) - Node(va, now->cost + cost, now, tkey); - queue.push(n); - } - }); - } while (!queue.empty()); - - stack.free(); - - return results; -} - -void reverse_stream_ids(Node *node, Stream& stream, VertexPropertyKey key) -{ - if (node == nullptr) - return; - reverse_stream_ids(node->parent, stream, key); - stream.write(node->vacc.at(key).template as<Int64>()); -} - -class PlanCPU : public PlanInterface<Stream> -{ -public: - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); - - indices_t indices = {{"garment_id", 0}}; - auto properties = query_properties(indices, args); - - auto &label = t.label_find_or_create("garment"); - auto garment_id_prop_key = - t.vertex_property_key("garment_id", args[0].key.flags()); - - stream.write_fields( - {{"a.garment_id", "b.garment_id", "c.garment_id", "d.garment_id"}}); - - label.index() - .for_range(t) - .properties_filter(t, properties) - .for_all([&](auto va) { - auto results = astar(va, t, args, stream); - std::sort(results.begin(), results.end(), - [](Node *a, Node *b) { return a->sum > b->sum; }); - for (auto node : results) - { - stream.write_record(); - stream.write_list_header(max_depth + 1); - reverse_stream_ids(node, stream, garment_id_prop_key); - } - }); - - stream.write_empty_fields(); - stream.write_meta("r"); - - return t.commit(); + // if the limit wasn't reached -> POP the next vertex + continue; } - ~PlanCPU() {} + iter::for_all(now->vacc.out(), [&](auto edge) { + VertexAccessor va = edge.to(); + if (vertex_filter_contained(t, va, now)) { + auto cost = 1 - va.at(tkey).get()->value(); + Node *n = + new (stack.allocate<Node>()) Node(va, now->cost + cost, now, tkey); + queue.push(n); + } + }); + } while (!queue.empty()); + + stack.free(); + + return results; +} + +void reverse_stream_ids(Node *node, Stream &stream, VertexPropertyKey key) { + if (node == nullptr) return; + reverse_stream_ids(node->parent, stream, key); + stream.write(node->vacc.at(key).template as<Int64>()); +} + +class PlanCPU : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); + + indices_t indices = {{"garment_id", 0}}; + auto properties = query_properties(indices, args); + + auto &label = t.label_find_or_create("garment"); + auto garment_id_prop_key = + t.vertex_property_key("garment_id", args[0].key.flags()); + + stream.write_fields( + {{"a.garment_id", "b.garment_id", "c.garment_id", "d.garment_id"}}); + + label.index() + .for_range(t) + .properties_filter(t, properties) + .for_all([&](auto va) { + auto results = astar(va, t, args, stream); + std::sort(results.begin(), results.end(), + [](Node *a, Node *b) { return a->sum > b->sum; }); + for (auto node : results) { + stream.write_record(); + stream.write_list_header(max_depth + 1); + reverse_stream_ids(node, stream, garment_id_prop_key); + } + }); + + stream.write_empty_fields(); + stream.write_meta("r"); + + return t.commit(); + } + + ~PlanCPU() {} }; extern "C" PlanInterface<Stream> *produce() { return new PlanCPU(); } diff --git a/tests/integration/hardcoded_query/create_account_return.cpp b/tests/integration/hardcoded_query/create_account_return.cpp index 5380ab983..7cbd479cb 100644 --- a/tests/integration/hardcoded_query/create_account_return.cpp +++ b/tests/integration/hardcoded_query/create_account_return.cpp @@ -1,58 +1,49 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" -#include "storage/model/properties/all.hpp" +#include "query/util.hpp" #include "storage/edge_x_vertex.hpp" +#include "storage/model/properties/all.hpp" #include "using.hpp" using std::cout; using std::endl; -// Query: CREATE (n:ACCOUNT {id: 2322, name: "TEST", country: "Croatia", "created_at": 2352352}) RETURN n +// Query: CREATE (n:ACCOUNT {id: 2322, name: "TEST", country: "Croatia", +// "created_at": 2352352}) RETURN n -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto prop_id = t.vertex_property_key("id", args[0].key.flags()); + auto prop_name = t.vertex_property_key("name", args[1].key.flags()); + auto prop_country = t.vertex_property_key("country", args[2].key.flags()); + auto prop_created = + t.vertex_property_key("created_at", args[3].key.flags()); - auto prop_id = t.vertex_property_key("id", args[0].key.flags()); - auto prop_name = t.vertex_property_key("name", args[1].key.flags()); - auto prop_country = - t.vertex_property_key("country", args[2].key.flags()); - auto prop_created = - t.vertex_property_key("created_at", args[3].key.flags()); + auto &label = t.label_find_or_create("ACCOUNT"); - auto &label = t.label_find_or_create("ACCOUNT"); + auto vertex_accessor = t.vertex_insert(); - auto vertex_accessor = t.vertex_insert(); + vertex_accessor.set(prop_id, std::move(args[0])); + vertex_accessor.set(prop_name, std::move(args[1])); + vertex_accessor.set(prop_country, std::move(args[2])); + vertex_accessor.set(prop_created, std::move(args[3])); + vertex_accessor.add_label(label); - vertex_accessor.set(prop_id, std::move(args[0])); - vertex_accessor.set(prop_name, std::move(args[1])); - vertex_accessor.set(prop_country, std::move(args[2])); - vertex_accessor.set(prop_created, std::move(args[3])); - vertex_accessor.add_label(label); + stream.write_field("p"); + stream.write_vertex_record(vertex_accessor); + stream.write_meta("w"); - stream.write_field("p"); - stream.write_vertex_record(vertex_accessor); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/create_edge.cpp b/tests/integration/hardcoded_query/create_edge.cpp index 168444272..9428a3cc1 100644 --- a/tests/integration/hardcoded_query/create_edge.cpp +++ b/tests/integration/hardcoded_query/create_edge.cpp @@ -1,10 +1,10 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" -#include "storage/model/properties/all.hpp" +#include "query/util.hpp" #include "storage/edge_x_vertex.hpp" +#include "storage/model/properties/all.hpp" #include "using.hpp" using std::cout; @@ -12,41 +12,32 @@ using std::endl; // Query: MATCH (a {id:0}), (p {id: 1}) CREATE (a)-[r:IS]->(p) RETURN r -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); + auto &edge_type = t.type_find_or_create("IS"); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); - auto &edge_type = t.type_find_or_create("IS"); + auto v1 = t.vertex_find(args[0].as<Int64>().value()); + if (!option_fill(v1)) return t.commit(), false; - auto v1 = t.vertex_find(args[0].as<Int64>().value()); - if (!option_fill(v1)) return t.commit(), false; + auto v2 = t.vertex_find(args[1].as<Int64>().value()); + if (!option_fill(v2)) return t.commit(), false; - auto v2 = t.vertex_find(args[1].as<Int64>().value()); - if (!option_fill(v2)) return t.commit(), false; + auto edge_accessor = t.edge_insert(v1.get(), v2.get()); - auto edge_accessor = t.edge_insert(v1.get(), v2.get()); + edge_accessor.edge_type(edge_type); - edge_accessor.edge_type(edge_type); + stream.write_field("r"); + stream.write_edge_record(edge_accessor); + stream.write_meta("w"); - stream.write_field("r"); - stream.write_edge_record(edge_accessor); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/create_full_profile_return.cpp b/tests/integration/hardcoded_query/create_full_profile_return.cpp index c86f71d44..f0e473f14 100644 --- a/tests/integration/hardcoded_query/create_full_profile_return.cpp +++ b/tests/integration/hardcoded_query/create_full_profile_return.cpp @@ -1,8 +1,8 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" @@ -11,43 +11,31 @@ using std::endl; // Query: CREATE (p:profile {profile_id: 112, partner_id: 55}) RETURN p -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto profile_id = t.vertex_property_key("profile_id", args[0].key.flags()); + auto partner_id = t.vertex_property_key("partner_id", args[1].key.flags()); - auto profile_id = - t.vertex_property_key("profile_id", args[0].key.flags()); - auto partner_id = - t.vertex_property_key("partner_id", args[1].key.flags()); + auto va = t.vertex_insert(); + va.set(profile_id, std::move(args[0])); + va.set(partner_id, std::move(args[1])); - auto va = t.vertex_insert(); - va.set(profile_id, std::move(args[0])); - va.set(partner_id, std::move(args[1])); + auto &profile = t.label_find_or_create("profile"); + va.add_label(profile); - auto &profile = t.label_find_or_create("profile"); - va.add_label(profile); + stream.write_field("p"); + stream.write_vertex_record(va); + stream.write_meta("w"); - stream.write_field("p"); - stream.write_vertex_record(va); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/create_label_name_return.cpp b/tests/integration/hardcoded_query/create_label_name_return.cpp index 41fe70989..b95962915 100644 --- a/tests/integration/hardcoded_query/create_label_name_return.cpp +++ b/tests/integration/hardcoded_query/create_label_name_return.cpp @@ -1,10 +1,10 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" -#include "storage/model/properties/all.hpp" +#include "query/util.hpp" #include "storage/edge_x_vertex.hpp" +#include "storage/model/properties/all.hpp" #include "using.hpp" using std::cout; @@ -12,37 +12,28 @@ using std::endl; // Query: CREATE (n:LABEL {name: "TEST"}) RETURN n -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto property_key = t.vertex_property_key("name", args[0].key.flags()); + auto &label = t.label_find_or_create("LABEL"); - auto property_key = t.vertex_property_key("name", args[0].key.flags()); - auto &label = t.label_find_or_create("LABEL"); + auto vertex_accessor = t.vertex_insert(); + vertex_accessor.set(property_key, std::move(args[0])); + vertex_accessor.add_label(label); - auto vertex_accessor = t.vertex_insert(); - vertex_accessor.set(property_key, std::move(args[0])); - vertex_accessor.add_label(label); + stream.write_field("n"); + stream.write_vertex_record(vertex_accessor); + stream.write_meta("w"); - stream.write_field("n"); - stream.write_vertex_record(vertex_accessor); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/create_other_name_return.cpp b/tests/integration/hardcoded_query/create_other_name_return.cpp index 6385fa40f..541b3d9f6 100644 --- a/tests/integration/hardcoded_query/create_other_name_return.cpp +++ b/tests/integration/hardcoded_query/create_other_name_return.cpp @@ -1,10 +1,10 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" -#include "storage/model/properties/all.hpp" +#include "query/util.hpp" #include "storage/edge_x_vertex.hpp" +#include "storage/model/properties/all.hpp" #include "using.hpp" using std::cout; @@ -12,37 +12,28 @@ using std::endl; // Query: CREATE (n:OTHER {name: "cleaner_test"}) RETURN n -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto property_key = t.vertex_property_key("name", args[0].key.flags()); + auto &label = t.label_find_or_create("OTHER"); - auto property_key = t.vertex_property_key("name", args[0].key.flags()); - auto &label = t.label_find_or_create("OTHER"); + auto vertex_accessor = t.vertex_insert(); + vertex_accessor.set(property_key, std::move(args[0])); + vertex_accessor.add_label(label); - auto vertex_accessor = t.vertex_insert(); - vertex_accessor.set(property_key, std::move(args[0])); - vertex_accessor.add_label(label); + stream.write_field("n"); + stream.write_vertex_record(vertex_accessor); + stream.write_meta("w"); - stream.write_field("n"); - stream.write_vertex_record(vertex_accessor); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/create_prop_return.cpp b/tests/integration/hardcoded_query/create_prop_return.cpp index c82987d01..828a22ce8 100644 --- a/tests/integration/hardcoded_query/create_prop_return.cpp +++ b/tests/integration/hardcoded_query/create_prop_return.cpp @@ -1,10 +1,10 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" -#include "storage/model/properties/all.hpp" +#include "query/util.hpp" #include "storage/edge_x_vertex.hpp" +#include "storage/model/properties/all.hpp" #include "using.hpp" using std::cout; @@ -12,35 +12,26 @@ using std::endl; // Query: CREATE (n {prop: 0}) RETURN n -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto property_key = t.vertex_property_key("prop", args[0].key.flags()); - auto property_key = t.vertex_property_key("prop", args[0].key.flags()); + auto vertex_accessor = t.vertex_insert(); + vertex_accessor.set(property_key, std::move(args[0])); - auto vertex_accessor = t.vertex_insert(); - vertex_accessor.set(property_key, std::move(args[0])); + stream.write_field("n"); + stream.write_vertex_record(vertex_accessor); + stream.write_meta("w"); - stream.write_field("n"); - stream.write_vertex_record(vertex_accessor); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/create_return_g.cpp b/tests/integration/hardcoded_query/create_return_g.cpp index 262d2cb37..1cc599237 100644 --- a/tests/integration/hardcoded_query/create_return_g.cpp +++ b/tests/integration/hardcoded_query/create_return_g.cpp @@ -1,8 +1,8 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" @@ -11,42 +11,32 @@ using std::endl; // Query: CREATE (g:garment {garment_id: 1236, garment_category_id: 1}) RETURN g -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto garment_id = t.vertex_property_key("garment_id", args[0].key.flags()); + auto garment_category_id = + t.vertex_property_key("garment_category_id", args[1].key.flags()); - auto garment_id = - t.vertex_property_key("garment_id", args[0].key.flags()); - auto garment_category_id = - t.vertex_property_key("garment_category_id", args[1].key.flags()); + auto va = t.vertex_insert(); + va.set(garment_id, std::move(args[0])); + va.set(garment_category_id, std::move(args[1])); - auto va = t.vertex_insert(); - va.set(garment_id, std::move(args[0])); - va.set(garment_category_id, std::move(args[1])); + auto &garment = t.label_find_or_create("garment"); + va.add_label(garment); - auto &garment = t.label_find_or_create("garment"); - va.add_label(garment); + stream.write_field("g"); + stream.write_vertex_record(va); + stream.write_meta("w"); - stream.write_field("g"); - stream.write_vertex_record(va); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/match_all_n_detach_delete.cpp b/tests/integration/hardcoded_query/match_all_n_detach_delete.cpp index 51aa3427e..6dcc562d4 100644 --- a/tests/integration/hardcoded_query/match_all_n_detach_delete.cpp +++ b/tests/integration/hardcoded_query/match_all_n_detach_delete.cpp @@ -1,8 +1,8 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" @@ -11,33 +11,23 @@ using std::endl; // Query: MATCH (n) DETACH DELETE n -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + t.edge_access().fill().for_all([&](auto e) { e.remove(); }); + t.vertex_access().fill().isolated().for_all([&](auto a) { a.remove(); }); - t.edge_access().fill().for_all([&](auto e) { e.remove(); }); - t.vertex_access().fill().isolated().for_all( - [&](auto a) { a.remove(); }); + stream.write_empty_fields(); + stream.write_meta("w"); - stream.write_empty_fields(); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/match_delete_garment.cpp b/tests/integration/hardcoded_query/match_delete_garment.cpp index 55085c31b..9ca516b3a 100644 --- a/tests/integration/hardcoded_query/match_delete_garment.cpp +++ b/tests/integration/hardcoded_query/match_delete_garment.cpp @@ -1,8 +1,8 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" @@ -11,40 +11,30 @@ using std::endl; // Query: MATCH (p:garment {garment_id: 1}) DELETE g -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + indices_t indices = {{"garment_id", 0}}; + auto properties = query_properties(indices, args); - indices_t indices = {{"garment_id", 0}}; - auto properties = query_properties(indices, args); + auto &label = t.label_find_or_create("garment"); - auto &label = t.label_find_or_create("garment"); + label.index() + .for_range(t) + .properties_filter(t, properties) + .for_all([&](auto va) { va.remove(); }); - label.index() - .for_range(t) - .properties_filter(t, properties) - .for_all([&](auto va) { va.remove(); }); + stream.write_empty_fields(); + stream.write_meta("w"); - stream.write_empty_fields(); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/match_delete_profile.cpp b/tests/integration/hardcoded_query/match_delete_profile.cpp index 87ceaf949..9c9b24e6a 100644 --- a/tests/integration/hardcoded_query/match_delete_profile.cpp +++ b/tests/integration/hardcoded_query/match_delete_profile.cpp @@ -1,8 +1,8 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" @@ -11,40 +11,30 @@ using std::endl; // Query: MATCH (p:profile {profile_id: 1}) DELETE p -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + indices_t indices = {{"profile_id", 0}}; + auto properties = query_properties(indices, args); - indices_t indices = {{"profile_id", 0}}; - auto properties = query_properties(indices, args); + auto &label = t.label_find_or_create("profile"); - auto &label = t.label_find_or_create("profile"); + label.index() + .for_range(t) + .properties_filter(t, properties) + .for_all([&](auto va) { va.remove(); }); - label.index() - .for_range(t) - .properties_filter(t, properties) - .for_all([&](auto va) { va.remove(); }); + stream.write_empty_fields(); + stream.write_meta("w"); - stream.write_empty_fields(); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/match_delete_score.cpp b/tests/integration/hardcoded_query/match_delete_score.cpp index 234dff117..4185115f0 100644 --- a/tests/integration/hardcoded_query/match_delete_score.cpp +++ b/tests/integration/hardcoded_query/match_delete_score.cpp @@ -1,91 +1,82 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" -#include "storage/model/properties/all.hpp" +#include "query/util.hpp" #include "storage/edge_x_vertex.hpp" +#include "storage/model/properties/all.hpp" #include "using.hpp" using std::cout; using std::endl; -// Query: MATCH (p:profile {profile_id: 111, partner_id:55})-[s:score]-(g:garment {garment_id: 1234}) DELETE s +// Query: MATCH (p:profile {profile_id: 111, +// partner_id:55})-[s:score]-(g:garment {garment_id: 1234}) DELETE s -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto &profile = t.label_find_or_create("profile"); + auto &score = t.type_find_or_create("score"); + auto &garment = t.label_find_or_create("garment"); - auto &profile = t.label_find_or_create("profile"); - auto &score = t.type_find_or_create("score"); - auto &garment = t.label_find_or_create("garment"); + indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}}; + indices_t garment_ind = {{"garment_id", 2}}; - indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}}; - indices_t garment_ind = {{"garment_id", 2}}; + auto profile_prop = query_properties(profile_ind, args); + auto garment_prop = query_properties(garment_ind, args); - auto profile_prop = query_properties(profile_ind, args); - auto garment_prop = query_properties(garment_ind, args); + auto score_key = t.edge_property_key("score", args[3].key.flags()); - auto score_key = t.edge_property_key("score", args[3].key.flags()); + // TODO: decide path (which index is better) + // 3 options p->s->g, g->s->p, g<-s->p + // NOTE! both direections have to be chacked + // because pattern is non directional + // OR + // even better, use index on label and property - // TODO: decide path (which index is better) - // 3 options p->s->g, g->s->p, g<-s->p - // NOTE! both direections have to be chacked - // because pattern is non directional - // OR - // even better, use index on label and property + // just one option p->s->g! + Option<const EdgeAccessor> e1; + profile.index() + .for_range(t) + .properties_filter(t, profile_prop) + .out() + .type(score) + .clone_to(e1) + .to() + .label(garment) + .properties_filter(t, garment_prop) + .for_all([&](auto va) -> void { + auto ea = e1.get().update(); + ea.remove(); + }); - // just one option p->s->g! - Option<const EdgeAccessor> e1; - profile.index() - .for_range(t) - .properties_filter(t, profile_prop) - .out() - .type(score) - .clone_to(e1) - .to() - .label(garment) - .properties_filter(t, garment_prop) - .for_all([&](auto va) -> void { - auto ea = e1.get().update(); - ea.remove(); - }); + Option<const EdgeAccessor> e2; + profile.index() + .for_range(t) + .properties_filter(t, profile_prop) + .in() + .type(score) + .clone_to(e1) + .from() + .label(garment) + .properties_filter(t, garment_prop) + .for_all([&](auto va) -> void { + auto ea = e2.get().update(); + ea.remove(); + }); - Option<const EdgeAccessor> e2; - profile.index() - .for_range(t) - .properties_filter(t, profile_prop) - .in() - .type(score) - .clone_to(e1) - .from() - .label(garment) - .properties_filter(t, garment_prop) - .for_all([&](auto va) -> void { - auto ea = e2.get().update(); - ea.remove(); - }); + stream.write_empty_fields(); + stream.write_meta("w"); - stream.write_empty_fields(); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/match_edge_score.cpp b/tests/integration/hardcoded_query/match_edge_score.cpp index 804183ad4..bd58d925d 100644 --- a/tests/integration/hardcoded_query/match_edge_score.cpp +++ b/tests/integration/hardcoded_query/match_edge_score.cpp @@ -1,89 +1,80 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" -#include "storage/model/properties/all.hpp" +#include "query/util.hpp" #include "storage/edge_x_vertex.hpp" +#include "storage/model/properties/all.hpp" #include "using.hpp" using std::cout; using std::endl; -// Query: MATCH (p:profile {profile_id: 111, partner_id:55})-[s:score]-(g:garment {garment_id: 1234}) SET s.score = 1550 RETURN s.score +// Query: MATCH (p:profile {profile_id: 111, +// partner_id:55})-[s:score]-(g:garment {garment_id: 1234}) SET s.score = 1550 +// RETURN s.score -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto &profile = t.label_find_or_create("profile"); + auto &score = t.type_find_or_create("score"); + auto &garment = t.label_find_or_create("garment"); - auto &profile = t.label_find_or_create("profile"); - auto &score = t.type_find_or_create("score"); - auto &garment = t.label_find_or_create("garment"); + indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}}; + indices_t garment_ind = {{"garment_id", 2}}; - indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}}; - indices_t garment_ind = {{"garment_id", 2}}; + auto profile_prop = query_properties(profile_ind, args); + auto garment_prop = query_properties(garment_ind, args); - auto profile_prop = query_properties(profile_ind, args); - auto garment_prop = query_properties(garment_ind, args); + auto score_key = t.edge_property_key("score", args[3].key.flags()); - auto score_key = t.edge_property_key("score", args[3].key.flags()); + // TODO: decide path (which index is better) + // 3 options p->s->g, g->s->p, g<-s->p + // NOTE! both direections have to be chacked + // because pattern is non directional + // OR + // even better, use index on label and property - // TODO: decide path (which index is better) - // 3 options p->s->g, g->s->p, g<-s->p - // NOTE! both direections have to be chacked - // because pattern is non directional - // OR - // even better, use index on label and property + // just one option p->s->g! + Option<const EdgeAccessor> e1; + profile.index() + .for_range(t) + .properties_filter(t, profile_prop) + .out() + .type(score) + .clone_to(e1) + .to() + .label(garment) + .properties_filter(t, garment_prop) + .for_all([&](auto va) -> void { + auto ea = e1.get().update(); + ea.set(score_key, std::move(args[3])); + }); - // just one option p->s->g! - Option<const EdgeAccessor> e1; - profile.index() - .for_range(t) - .properties_filter(t, profile_prop) - .out() - .type(score) - .clone_to(e1) - .to() - .label(garment) - .properties_filter(t, garment_prop) - .for_all([&](auto va) -> void { - auto ea = e1.get().update(); - ea.set(score_key, std::move(args[3])); - }); + Option<const EdgeAccessor> e2; + profile.index() + .for_range(t) + .properties_filter(t, profile_prop) + .in() + .type(score) + .clone_to(e1) + .from() + .label(garment) + .properties_filter(t, garment_prop) + .for_all([&](auto va) -> void { + auto ea = e2.get().update(); + ea.set(score_key, std::move(args[3])); + }); - Option<const EdgeAccessor> e2; - profile.index() - .for_range(t) - .properties_filter(t, profile_prop) - .in() - .type(score) - .clone_to(e1) - .from() - .label(garment) - .properties_filter(t, garment_prop) - .for_all([&](auto va) -> void { - auto ea = e2.get().update(); - ea.set(score_key, std::move(args[3])); - }); + return t.commit(); + } - - return t.commit(); - - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/match_garment_set_label_return_labels.cpp b/tests/integration/hardcoded_query/match_garment_set_label_return_labels.cpp index a461ecd69..274d42ce3 100644 --- a/tests/integration/hardcoded_query/match_garment_set_label_return_labels.cpp +++ b/tests/integration/hardcoded_query/match_garment_set_label_return_labels.cpp @@ -1,8 +1,8 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" @@ -11,54 +11,44 @@ using std::endl; // Query: MATCH (g:garment {garment_id: 1234}) SET g:FF RETURN labels(g) -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + indices_t indices = {{"garment_id", 0}}; + auto properties = query_properties(indices, args); - indices_t indices = {{"garment_id", 0}}; - auto properties = query_properties(indices, args); + auto &label = t.label_find_or_create("garment"); - auto &label = t.label_find_or_create("garment"); - - stream.write_field("labels(g)"); + stream.write_field("labels(g)"); - label.index() - .for_range(t) - .properties_filter(t, properties) - .for_all([&](auto va) -> void { - va.stream_repr(std::cout); - auto &ff_label = t.label_find_or_create("FF"); - va.add_label(ff_label); - auto &labels = va.labels(); + label.index() + .for_range(t) + .properties_filter(t, properties) + .for_all([&](auto va) -> void { + va.stream_repr(std::cout); + auto &ff_label = t.label_find_or_create("FF"); + va.add_label(ff_label); + auto &labels = va.labels(); - stream.write_record(); - stream.write_list_header(1); - stream.write_list_header(labels.size()); - for (auto &label : labels) - { - stream.write(label.get().str()); - } - stream.chunk(); - }); + stream.write_record(); + stream.write_list_header(1); + stream.write_list_header(labels.size()); + for (auto &label : labels) { + stream.write(label.get().str()); + } + stream.chunk(); + }); - stream.write_meta("rw"); + stream.write_meta("rw"); - return t.commit(); - } + return t.commit(); + } - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/match_garment_set_return.cpp b/tests/integration/hardcoded_query/match_garment_set_return.cpp index 1abd09601..e39acff57 100644 --- a/tests/integration/hardcoded_query/match_garment_set_return.cpp +++ b/tests/integration/hardcoded_query/match_garment_set_return.cpp @@ -1,8 +1,8 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" @@ -11,47 +11,37 @@ using std::endl; // Query: MATCH (g:garment {garment_id: 3456}) SET g.reveals = 50 RETURN g -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto reveals_key = t.vertex_property_key("reveals", args[1].key.flags()); - auto reveals_key = - t.vertex_property_key("reveals", args[1].key.flags()); + indices_t indices = {{"garment_id", 0}}; + auto properties = query_properties(indices, args); - indices_t indices = {{"garment_id", 0}}; - auto properties = query_properties(indices, args); + auto &label = t.label_find_or_create("garment"); - auto &label = t.label_find_or_create("garment"); + stream.write_field("g"); - stream.write_field("g"); + label.index() + .for_range(t) + .properties_filter(t, properties) + .fill() + .for_all([&](auto va) { + va.set(reveals_key, args[1]); + stream.write_vertex_record(va); + }); - label.index() - .for_range(t) - .properties_filter(t, properties) - .fill() - .for_all([&](auto va) { - va.set(reveals_key, args[1]); - stream.write_vertex_record(va); - }); + stream.write_meta("w"); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/match_profile_return.cpp b/tests/integration/hardcoded_query/match_profile_return.cpp index 0966597de..c10cc9861 100644 --- a/tests/integration/hardcoded_query/match_profile_return.cpp +++ b/tests/integration/hardcoded_query/match_profile_return.cpp @@ -1,8 +1,8 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" @@ -11,42 +11,31 @@ using std::endl; // Query: MATCH (p:profile {partner_id: 1}) RETURN p -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + indices_t indices = {{"partner_id", 0}}; + auto properties = query_properties(indices, args); - indices_t indices = {{"partner_id", 0}}; - auto properties = query_properties(indices, args); + auto &label = t.label_find_or_create("profile"); - auto &label = t.label_find_or_create("profile"); + stream.write_field("p"); - stream.write_field("p"); + label.index() + .for_range(t) + .properties_filter(t, properties) + .for_all([&](auto va) { stream.write_vertex_record(va); }); - label.index() - .for_range(t) - .properties_filter(t, properties) - .for_all([&](auto va) { - stream.write_vertex_record(va); - }); + stream.write_meta("r"); - stream.write_meta("r"); - - return t.commit(); - } + return t.commit(); + } - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/match_return.cpp b/tests/integration/hardcoded_query/match_return.cpp index d08e4a7f6..690570a81 100644 --- a/tests/integration/hardcoded_query/match_return.cpp +++ b/tests/integration/hardcoded_query/match_return.cpp @@ -1,8 +1,8 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" @@ -11,42 +11,31 @@ using std::endl; // Query: MATCH (g:garment {garment_id: 1}) RETURN g -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + indices_t indices = {{"garment_id", 0}}; + auto properties = query_properties(indices, args); - indices_t indices = {{"garment_id", 0}}; - auto properties = query_properties(indices, args); + auto &label = t.label_find_or_create("garment"); - auto &label = t.label_find_or_create("garment"); + stream.write_field("g"); - stream.write_field("g"); + label.index() + .for_range(t) + .properties_filter(t, properties) + .for_all([&](auto va) -> void { stream.write_vertex_record(va); }); - label.index() - .for_range(t) - .properties_filter(t, properties) - .for_all([&](auto va) -> void { - stream.write_vertex_record(va); - }); + stream.write_meta("w"); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/merge_path_return_edge.cpp b/tests/integration/hardcoded_query/merge_path_return_edge.cpp index 28a7d012a..0f87689f6 100644 --- a/tests/integration/hardcoded_query/merge_path_return_edge.cpp +++ b/tests/integration/hardcoded_query/merge_path_return_edge.cpp @@ -1,73 +1,65 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" +#include "query/util.hpp" #include "storage/model/properties/all.hpp" #include "using.hpp" using std::cout; using std::endl; -// Query: MERGE (g1:garment {garment_id:1234})-[r:default_outfit]-(g2:garment {garment_id: 2345}) RETURN r +// Query: MERGE (g1:garment {garment_id:1234})-[r:default_outfit]-(g2:garment +// {garment_id: 2345}) RETURN r -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + // TODO: support for index on label and property - // TODO: support for index on label and property + // prepare iterator for g1 + indices_t indices_1 = {{"garment_id", 0}}; + auto properties_1 = query_properties(indices_1, args); + auto &label_1 = t.label_find_or_create("garment"); - // prepare iterator for g1 - indices_t indices_1 = {{"garment_id", 0}}; - auto properties_1 = query_properties(indices_1, args); - auto &label_1 = t.label_find_or_create("garment"); + auto it_vertex_1 = + label_1.index().for_range(t).properties_filter(t, properties_1); - auto it_vertex_1 = - label_1.index().for_range(t).properties_filter(t, properties_1); + // prepare iterator for g1 + indices_t indices_2 = {{"garment_id", 1}}; + auto properties_2 = query_properties(indices_2, args); + auto &label_2 = t.label_find_or_create("garment"); - // prepare iterator for g1 - indices_t indices_2 = {{"garment_id", 1}}; - auto properties_2 = query_properties(indices_2, args); - auto &label_2 = t.label_find_or_create("garment"); + auto it_vertex_2 = + label_2.index().for_range(t).properties_filter(t, properties_2); - auto it_vertex_2 = - label_2.index().for_range(t).properties_filter(t, properties_2); + auto &edge_type = t.type_find_or_create("default_outfit"); - auto &edge_type = t.type_find_or_create("default_outfit"); + // TODO: create g1 and g2 if don't exist - // TODO: create g1 and g2 if don't exist + // TODO: figure out something better - // TODO: figure out something better + stream.write_field("r"); - stream.write_field("r"); + it_vertex_1.fill().for_all([&](auto va1) -> void { + it_vertex_2.fill().for_all([&](auto va2) -> void { + auto edge_accessor = t.edge_insert(va1, va2); + edge_accessor.edge_type(edge_type); - it_vertex_1.fill().for_all([&](auto va1) -> void { - it_vertex_2.fill().for_all([&](auto va2) -> void { - auto edge_accessor = t.edge_insert(va1, va2); - edge_accessor.edge_type(edge_type); + stream.write_edge_record(edge_accessor); + }); + }); - stream.write_edge_record(edge_accessor); - }); - }); + stream.write_meta("w"); - stream.write_meta("w"); + return t.commit(); + } - return t.commit(); - } - - ~CPUPlan() {} + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/hardcoded_query/merge_set_return.cpp b/tests/integration/hardcoded_query/merge_set_return.cpp index 34dcf9814..0a6964477 100644 --- a/tests/integration/hardcoded_query/merge_set_return.cpp +++ b/tests/integration/hardcoded_query/merge_set_return.cpp @@ -1,105 +1,97 @@ #include <iostream> #include <string> -#include "query/util.hpp" #include "query/plan_interface.hpp" -#include "storage/model/properties/all.hpp" +#include "query/util.hpp" #include "storage/edge_x_vertex.hpp" +#include "storage/model/properties/all.hpp" #include "using.hpp" using std::cout; using std::endl; -// Query: MERGE (p:profile {profile_id: 111, partner_id: 55})-[s:score]-(g.garment {garment_id: 1234}) SET s.score=1500 RETURN s +// Query: MERGE (p:profile {profile_id: 111, partner_id: +// 55})-[s:score]-(g.garment {garment_id: 1234}) SET s.score=1500 RETURN s -class CPUPlan : public PlanInterface<Stream> -{ -public: +class CPUPlan : public PlanInterface<Stream> { + public: + bool run(Db &db, const PlanArgsT &args, Stream &stream) override { + DbAccessor t(db); - bool run(Db &db, const PlanArgsT &args, Stream &stream) override - { - DbAccessor t(db); + auto &profile = t.label_find_or_create("profile"); + auto &score = t.type_find_or_create("score"); + auto &garment = t.label_find_or_create("garment"); - auto &profile = t.label_find_or_create("profile"); - auto &score = t.type_find_or_create("score"); - auto &garment = t.label_find_or_create("garment"); + indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}}; + indices_t garment_ind = {{"garment_id", 2}}; - indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}}; - indices_t garment_ind = {{"garment_id", 2}}; + auto profile_prop = query_properties(profile_ind, args); + auto garment_prop = query_properties(garment_ind, args); - auto profile_prop = query_properties(profile_ind, args); - auto garment_prop = query_properties(garment_ind, args); + auto score_key = t.edge_property_key("score", args[3].key.flags()); - auto score_key = t.edge_property_key("score", args[3].key.flags()); - - stream.write_field("s"); + stream.write_field("s"); - // TODO: implement - bool exists = false; - Option<const EdgeAccessor> e1; - profile.index() - .for_range(t) - .properties_filter(t, profile_prop) - .out() - .type(score) - .clone_to(e1) - .to() - .label(garment) - .properties_filter(t, garment_prop) - .for_all([&](auto va) -> void { - exists = true; - auto ea = e1.get().update(); - ea.set(score_key, args[3]); - stream.write_edge_record(ea); - }); + // TODO: implement + bool exists = false; + Option<const EdgeAccessor> e1; + profile.index() + .for_range(t) + .properties_filter(t, profile_prop) + .out() + .type(score) + .clone_to(e1) + .to() + .label(garment) + .properties_filter(t, garment_prop) + .for_all([&](auto va) -> void { + exists = true; + auto ea = e1.get().update(); + ea.set(score_key, args[3]); + stream.write_edge_record(ea); + }); - Option<const EdgeAccessor> e2; - profile.index() - .for_range(t) - .properties_filter(t, profile_prop) - .in() - .type(score) - .clone_to(e1) - .from() - .label(garment) - .properties_filter(t, garment_prop) - .for_all([&](auto va) -> void { - exists = true; - auto ea = e2.get().update(); - ea.set(score_key, args[3]); - stream.write_edge_record(ea); - }); + Option<const EdgeAccessor> e2; + profile.index() + .for_range(t) + .properties_filter(t, profile_prop) + .in() + .type(score) + .clone_to(e1) + .from() + .label(garment) + .properties_filter(t, garment_prop) + .for_all([&](auto va) -> void { + exists = true; + auto ea = e2.get().update(); + ea.set(score_key, args[3]); + stream.write_edge_record(ea); + }); - if (!exists) { - auto it_vertex_garment = - garment.index().for_range(t).properties_filter(t, garment_prop); - auto it_vertex_profile = - profile.index().for_range(t).properties_filter(t, profile_prop); + if (!exists) { + auto it_vertex_garment = + garment.index().for_range(t).properties_filter(t, garment_prop); + auto it_vertex_profile = + profile.index().for_range(t).properties_filter(t, profile_prop); - it_vertex_profile.fill().for_all([&](auto va1) -> void { - it_vertex_garment.fill().for_all([&](auto va2) -> void { - auto ea = t.edge_insert(va1, va2); - ea.edge_type(score); - ea.set(score_key, args[3]); - stream.write_edge_record(ea); - }); - }); - } - - stream.write_field("w"); - - return t.commit(); + it_vertex_profile.fill().for_all([&](auto va1) -> void { + it_vertex_garment.fill().for_all([&](auto va2) -> void { + auto ea = t.edge_insert(va1, va2); + ea.edge_type(score); + ea.set(score_key, args[3]); + stream.write_edge_record(ea); + }); + }); } - ~CPUPlan() {} + stream.write_field("w"); + + return t.commit(); + } + + ~CPUPlan() {} }; -extern "C" PlanInterface<Stream>* produce() -{ - return new CPUPlan(); -} +extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); } -extern "C" void destruct(PlanInterface<Stream>* p) -{ - delete p; -} +extern "C" void destruct(PlanInterface<Stream> *p) { delete p; } diff --git a/tests/integration/query_engine.cpp b/tests/integration/query_engine.cpp index 04215173c..df8a425f6 100644 --- a/tests/integration/query_engine.cpp +++ b/tests/integration/query_engine.cpp @@ -1,5 +1,5 @@ -#include "query_engine_common.hpp" #include "dbms/dbms.hpp" +#include "query_engine_common.hpp" using namespace std::chrono_literals; using namespace tests::integration; @@ -13,25 +13,24 @@ Logger logger; * NOTE: The correctnes can be tested by custom Stream object. * NOTE: This test will be usefull to test generated query plans. */ -int main(int argc, char *argv[]) -{ - /** - * init arguments - */ - REGISTER_ARGS(argc, argv); +int main(int argc, char *argv[]) { + /** + * init arguments + */ + REGISTER_ARGS(argc, argv); - /** - * init engine - */ - auto log = init_logging("IntegrationQueryEngine"); - Dbms dbms; - StreamT stream(std::cout); - QueryEngineT query_engine; - // IMPORTANT: PrintRecordStream can be replaces with a smarter - // object that can test the results + /** + * init engine + */ + auto log = init_logging("IntegrationQueryEngine"); + Dbms dbms; + StreamT stream(std::cout); + QueryEngineT query_engine; + // IMPORTANT: PrintRecordStream can be replaces with a smarter + // object that can test the results - auto db_accessor = dbms.active(); - WarmUpEngine(log, query_engine, db_accessor, stream); + auto db_accessor = dbms.active(); + WarmUpEngine(log, query_engine, db_accessor, stream); - return 0; + return 0; } diff --git a/tests/integration/query_engine_common.hpp b/tests/integration/query_engine_common.hpp index 8340f9280..d40760d56 100644 --- a/tests/integration/query_engine_common.hpp +++ b/tests/integration/query_engine_common.hpp @@ -14,15 +14,13 @@ namespace fs = std::experimental::filesystem; #include "utils/string/file.hpp" #include "utils/string/trim.hpp" -namespace tests -{ -namespace integration -{ +namespace tests { +namespace integration { using namespace utils; -using QueryHashesT = std::set<HashType>; +using QueryHashesT = std::set<HashType>; using QueryEngineT = QueryEngine<PrintRecordStream>; -using StreamT = PrintRecordStream; +using StreamT = PrintRecordStream; /** * Init logging for tested query_engine (test specific logger). It has to be @@ -32,11 +30,10 @@ using StreamT = PrintRecordStream; * * @return logger instance */ -auto init_logging(const std::string &logger_name) -{ - logging::init_sync(); - logging::log->pipe(std::make_unique<Stdout>()); - return logging::log->logger(logger_name); +auto init_logging(const std::string &logger_name) { + logging::init_sync(); + logging::log->pipe(std::make_unique<Stdout>()); + return logging::log->logger(logger_name); } /** @@ -48,26 +45,24 @@ auto init_logging(const std::string &logger_name) * * @return a set with all query hashes from the file */ -auto LoadQueryHashes(Logger &log, const fs::path &path) -{ - log.info("*** Get query hashes from the file defied with path ***"); - // the intention of following block is to get all hashes - // for which query implementations have to be compiled - // calculate all hashes from queries file - QueryPreprocessor preprocessor; - // hashes calculated from all queries in queries file - QueryHashesT query_hashes; - // fill the above set - auto queries = utils::read_lines(path); - for (auto &query : queries) - { - if (query.empty()) continue; - query_hashes.insert(preprocessor.preprocess(query).hash); - } - permanent_assert(query_hashes.size() > 0, - "At least one hash has to be present"); - log.info("{} different query hashes exist", query_hashes.size()); - return query_hashes; +auto LoadQueryHashes(Logger &log, const fs::path &path) { + log.info("*** Get query hashes from the file defied with path ***"); + // the intention of following block is to get all hashes + // for which query implementations have to be compiled + // calculate all hashes from queries file + QueryPreprocessor preprocessor; + // hashes calculated from all queries in queries file + QueryHashesT query_hashes; + // fill the above set + auto queries = utils::read_lines(path); + for (auto &query : queries) { + if (query.empty()) continue; + query_hashes.insert(preprocessor.preprocess(query).hash); + } + permanent_assert(query_hashes.size() > 0, + "At least one hash has to be present"); + log.info("{} different query hashes exist", query_hashes.size()); + return query_hashes; } /** @@ -81,41 +76,38 @@ auto LoadQueryHashes(Logger &log, const fs::path &path) * @return void */ auto LoadQueryPlans(Logger &log, QueryEngineT &engine, - const QueryHashesT &query_hashes, const fs::path &path) -{ - log.info("*** Load/compile needed query implementations ***"); - QueryPreprocessor preprocessor; - auto plan_paths = LoadFilePaths(path, "cpp"); - // query mark will be used to extract queries from files (because we want - // to be independent to a query hash) - auto query_mark = std::string("// Query: "); - for (auto &plan_path : plan_paths) - { - auto lines = read_lines(plan_path); - // find the line with a query in order - // be able to place it in the dynamic libs container (base on query - // hash) - for (auto &line : lines) - { - // find query in the line - auto pos = line.find(query_mark); - // if query doesn't exist pass - if (pos == std::string::npos) continue; - auto query = trim(line.substr(pos + query_mark.size())); - // load/compile implementations only for the queries which are - // contained in queries_file - // it doesn't make sense to compile something which won't be runned - if (query_hashes.find(preprocessor.preprocess(query).hash) == - query_hashes.end()) - continue; - log.info("Path {} will be loaded.", plan_path.c_str()); - engine.ReloadCustom(query, plan_path); - break; - } + const QueryHashesT &query_hashes, const fs::path &path) { + log.info("*** Load/compile needed query implementations ***"); + QueryPreprocessor preprocessor; + auto plan_paths = LoadFilePaths(path, "cpp"); + // query mark will be used to extract queries from files (because we want + // to be independent to a query hash) + auto query_mark = std::string("// Query: "); + for (auto &plan_path : plan_paths) { + auto lines = read_lines(plan_path); + // find the line with a query in order + // be able to place it in the dynamic libs container (base on query + // hash) + for (auto &line : lines) { + // find query in the line + auto pos = line.find(query_mark); + // if query doesn't exist pass + if (pos == std::string::npos) continue; + auto query = trim(line.substr(pos + query_mark.size())); + // load/compile implementations only for the queries which are + // contained in queries_file + // it doesn't make sense to compile something which won't be runned + if (query_hashes.find(preprocessor.preprocess(query).hash) == + query_hashes.end()) + continue; + log.info("Path {} will be loaded.", plan_path.c_str()); + engine.ReloadCustom(query, plan_path); + break; } - permanent_assert(query_hashes.size() == engine.Size(), - "Query engine doesn't contain appropriate number of query " - "implementations"); + } + permanent_assert(query_hashes.size() == engine.Size(), + "Query engine doesn't contain appropriate number of query " + "implementations"); } /** @@ -129,19 +121,18 @@ auto LoadQueryPlans(Logger &log, QueryEngineT &engine, * * @return void */ -auto ExecuteQueryPlans(Logger &log, QueryEngineT &engine, GraphDbAccessor &db_accessor, - const fs::path &path, StreamT &stream) -{ - log.info("*** Execute the queries from the queries_file ***"); - // execute all queries from queries_file - auto queries = utils::read_lines(path); - for (auto &query : queries) - { - if (query.empty()) continue; - permanent_assert(engine.Loaded(trim(query)), - "Implementation wasn't loaded"); - engine.Run(query, db_accessor, stream); - } +auto ExecuteQueryPlans(Logger &log, QueryEngineT &engine, + GraphDbAccessor &db_accessor, const fs::path &path, + StreamT &stream) { + log.info("*** Execute the queries from the queries_file ***"); + // execute all queries from queries_file + auto queries = utils::read_lines(path); + for (auto &query : queries) { + if (query.empty()) continue; + permanent_assert(engine.Loaded(trim(query)), + "Implementation wasn't loaded"); + engine.Run(query, db_accessor, stream); + } } /** @@ -157,24 +148,23 @@ auto ExecuteQueryPlans(Logger &log, QueryEngineT &engine, GraphDbAccessor &db_ac * * @return void */ -auto WarmUpEngine(Logger &log, QueryEngineT &engine, GraphDbAccessor &db_accessor, - StreamT &stream) -{ - // path to a file with queries - auto queries_file = fs::path( - GET_ARG("-q", "../data/queries/core/mg_basic_000.txt").get_string()); - // forlder with query implementations - auto implementations_folder = - fs::path(GET_ARG("-i", "../integration/hardcoded_query").get_string()); +auto WarmUpEngine(Logger &log, QueryEngineT &engine, + GraphDbAccessor &db_accessor, StreamT &stream) { + // path to a file with queries + auto queries_file = fs::path( + GET_ARG("-q", "../data/queries/core/mg_basic_000.txt").get_string()); + // forlder with query implementations + auto implementations_folder = + fs::path(GET_ARG("-i", "../integration/hardcoded_query").get_string()); - // load all query hashes from queries file - auto query_hashes = LoadQueryHashes(log, queries_file); + // load all query hashes from queries file + auto query_hashes = LoadQueryHashes(log, queries_file); - // load compile all needed query plans - LoadQueryPlans(log, engine, query_hashes, implementations_folder); + // load compile all needed query plans + LoadQueryPlans(log, engine, query_hashes, implementations_folder); - // execute all loaded query plasn - ExecuteQueryPlans(log, engine, db_accessor, queries_file, stream); + // execute all loaded query plasn + ExecuteQueryPlans(log, engine, db_accessor, queries_file, stream); } } } diff --git a/tests/integration/stream/print_record_stream.hpp b/tests/integration/stream/print_record_stream.hpp index dac6485f1..e8aaf83ce 100644 --- a/tests/integration/stream/print_record_stream.hpp +++ b/tests/integration/stream/print_record_stream.hpp @@ -1,36 +1,28 @@ #pragma once +#include <iostream> +#include <map> #include <string> #include <vector> -#include <map> -#include <iostream> #include "utils/exceptions/not_yet_implemented.hpp" class PrintRecordStream { -private: + private: std::ostream &stream; -public: + public: PrintRecordStream(std::ostream &stream) : stream(stream) {} - void write_success() { - stream << "SUCCESS\n"; - } + void write_success() { stream << "SUCCESS\n"; } - void write_success_empty() { - stream << "SUCCESS EMPTY\n"; - } + void write_success_empty() { stream << "SUCCESS EMPTY\n"; } - void write_ignored() { - stream << "IGNORED\n"; - } + void write_ignored() { stream << "IGNORED\n"; } - void write_empty_fields() { - stream << "EMPTY FIELDS\n"; - } + void write_empty_fields() { stream << "EMPTY FIELDS\n"; } - void write_fields(const std::vector <std::string> &fields) { + void write_fields(const std::vector<std::string> &fields) { stream << "FIELDS:"; for (auto &field : fields) { stream << " " << field; @@ -42,47 +34,31 @@ public: stream << "Field: " << field << '\n'; } - void write_list_header(size_t size) { - stream << "List: " << size << '\n'; - } + void write_list_header(size_t size) { stream << "List: " << size << '\n'; } - void write_record() { - stream << "Record\n"; - } + void write_record() { stream << "Record\n"; } void write_meta(const std::string &type) { stream << "Meta: " << type << std::endl; } - void write_failure(const std::map <std::string, std::string> &data) { + void write_failure(const std::map<std::string, std::string> &data) { throw NotYetImplemented(); } - void write_count(const size_t count) { - throw NotYetImplemented(); - } + void write_count(const size_t count) { throw NotYetImplemented(); } - void write(const VertexAccessor &vertex) { - throw NotYetImplemented(); - } + void write(const VertexAccessor &vertex) { throw NotYetImplemented(); } void write_vertex_record(const VertexAccessor &va) { throw NotYetImplemented(); } - void write(const EdgeAccessor &edge) { - throw NotYetImplemented(); - } + void write(const EdgeAccessor &edge) { throw NotYetImplemented(); } - void write_edge_record(const EdgeAccessor &ea) { - throw NotYetImplemented(); - } + void write_edge_record(const EdgeAccessor &ea) { throw NotYetImplemented(); } - void send() { - throw NotYetImplemented(); - } + void send() { throw NotYetImplemented(); } - void chunk() { - throw NotYetImplemented(); - } + void chunk() { throw NotYetImplemented(); } }; diff --git a/tests/manual/antlr_parser.cpp b/tests/manual/antlr_parser.cpp index 1c01e2289..5d3516252 100644 --- a/tests/manual/antlr_parser.cpp +++ b/tests/manual/antlr_parser.cpp @@ -7,27 +7,23 @@ using namespace antlrcpptest; using namespace antlr4; -int main(int, const char **a) -{ - const char *query = a[1]; +int main(int, const char **a) { + const char *query = a[1]; - ANTLRInputStream input(query); - CypherLexer lexer(&input); - CommonTokenStream tokens(&lexer); + ANTLRInputStream input(query); + CypherLexer lexer(&input); + CommonTokenStream tokens(&lexer); - tokens.fill(); - for (auto token : tokens.getTokens()) - { - std::cout << "TYPE: " << token->getType() << - "; TEXT: " << token->getText() << - "; STRING: " << token->toString() << std::endl; - } + tokens.fill(); + for (auto token : tokens.getTokens()) { + std::cout << "TYPE: " << token->getType() << "; TEXT: " << token->getText() + << "; STRING: " << token->toString() << std::endl; + } - CypherParser parser(&tokens); - tree::ParseTree *tree = parser.cypher(); + CypherParser parser(&tokens); + tree::ParseTree *tree = parser.cypher(); - std::cout << tree->toStringTree(&parser) << std::endl << std::endl; + std::cout << tree->toStringTree(&parser) << std::endl << std::endl; - return 0; + return 0; } - diff --git a/tests/manual/query_engine.cpp b/tests/manual/query_engine.cpp index a638f9fdd..697c97f09 100644 --- a/tests/manual/query_engine.cpp +++ b/tests/manual/query_engine.cpp @@ -6,69 +6,66 @@ using namespace std::chrono_literals; using namespace tests::integration; -int main(int argc, char *argv[]) -{ - // init arguments - REGISTER_ARGS(argc, argv); +int main(int argc, char* argv[]) { + // init arguments + REGISTER_ARGS(argc, argv); - // forlder with query implementations - auto implementations_folder = fs::path( - GET_ARG("-i", "tests/integration/hardcoded_query").get_string()); + // forlder with query implementations + auto implementations_folder = + fs::path(GET_ARG("-i", "tests/integration/hardcoded_query").get_string()); - // init engine - auto log = init_logging("ManualQueryEngine"); - Dbms dbms; - auto db_accessor = dbms.active(); - StreamT stream(std::cout); - QueryEngineT query_engine; - // IMPORTANT: PrintRecordStream can be replaces with a smarter - // object that can test the results + // init engine + auto log = init_logging("ManualQueryEngine"); + Dbms dbms; + auto db_accessor = dbms.active(); + StreamT stream(std::cout); + QueryEngineT query_engine; + // IMPORTANT: PrintRecordStream can be replaces with a smarter + // object that can test the results - WarmUpEngine(log, query_engine, db_accessor, stream); + WarmUpEngine(log, query_engine, db_accessor, stream); - // init watcher - FSWatcher watcher; - QueryPreprocessor preprocessor; + // init watcher + FSWatcher watcher; + QueryPreprocessor preprocessor; - int i = 0; - watcher.watch( - WatchDescriptor(implementations_folder, FSEventType::CloseNowrite), - [&](FSEvent event) { - i++; // bacause only close_no_write could be detected and this - // call will cause close no write again - if (i % 2 == 1) - { - // take only cpp files - if (event.path.extension() != ".cpp") - return; + int i = 0; + watcher.watch( + WatchDescriptor(implementations_folder, FSEventType::CloseNowrite), + [&](FSEvent event) { + i++; // bacause only close_no_write could be detected and this + // call will cause close no write again + if (i % 2 == 1) { + // take only cpp files + if (event.path.extension() != ".cpp") return; - auto query_mark = std::string("// Query: "); - auto lines = read_lines(event.path); - for (auto &line : lines) - { - auto pos = line.find(query_mark); - if (pos == std::string::npos) continue; - auto query = line.substr(pos + query_mark.size()); - log.info("Reload: {}", query); - query_engine.Unload(query); - try { - query_engine.ReloadCustom(query, event.path); - query_engine.Run(query, db_accessor, stream); - } catch (PlanCompilationException& e) { - log.info("Query compilation failed: {}", e.what()); - } catch (std::exception& e) { - log.info("Query execution failed: unknown reason"); - } - log.info("Number of available query plans: {}", query_engine.Size()); - } + auto query_mark = std::string("// Query: "); + auto lines = read_lines(event.path); + for (auto& line : lines) { + auto pos = line.find(query_mark); + if (pos == std::string::npos) continue; + auto query = line.substr(pos + query_mark.size()); + log.info("Reload: {}", query); + query_engine.Unload(query); + try { + query_engine.ReloadCustom(query, event.path); + query_engine.Run(query, db_accessor, stream); + } catch (PlanCompilationException& e) { + log.info("Query compilation failed: {}", e.what()); + } catch (std::exception& e) { + log.info("Query execution failed: unknown reason"); } - }); + log.info("Number of available query plans: {}", + query_engine.Size()); + } + } + }); - // TODO: watcher for injected query + // TODO: watcher for injected query - std::this_thread::sleep_for(1000s); + std::this_thread::sleep_for(1000s); - watcher.stop(); + watcher.stop(); - return 0; + return 0; } diff --git a/tests/manual/query_hash.cpp b/tests/manual/query_hash.cpp index 59e92da36..f5972eb0d 100644 --- a/tests/manual/query_hash.cpp +++ b/tests/manual/query_hash.cpp @@ -5,9 +5,9 @@ #include "logging/streams/stdout.hpp" #include "query/preprocessor.hpp" #include "utils/command_line/arguments.hpp" +#include "utils/string/file.hpp" #include "utils/type_discovery.hpp" #include "utils/variadic/variadic.hpp" -#include "utils/string/file.hpp" using utils::println; @@ -17,30 +17,29 @@ using utils::println; * Usage: * ./query_hash -q "CREATE (n {name: \"test\n"}) RETURN n" */ -int main(int argc, char **argv) -{ - logging::init_sync(); - logging::log->pipe(std::make_unique<Stdout>()); +int main(int argc, char **argv) { + logging::init_sync(); + logging::log->pipe(std::make_unique<Stdout>()); - // init args - REGISTER_ARGS(argc, argv); + // init args + REGISTER_ARGS(argc, argv); - // take query from input args - auto query = GET_ARG("-q", "CREATE (n) RETURN n").get_string(); + // take query from input args + auto query = GET_ARG("-q", "CREATE (n) RETURN n").get_string(); - // run preprocessing - QueryPreprocessor preprocessor; - auto preprocessed = preprocessor.preprocess(query); + // run preprocessing + QueryPreprocessor preprocessor; + auto preprocessed = preprocessor.preprocess(query); - // print query, stripped query, hash and variable values (propertie values) - println("Query: ", query); - println("Stripped query: ", preprocessed.query); - println("Query hash: ", preprocessed.hash); - println("Property values:"); - for (auto property : preprocessed.arguments) { - println(" ", property.second); - } - println(""); + // print query, stripped query, hash and variable values (propertie values) + println("Query: ", query); + println("Stripped query: ", preprocessed.query); + println("Query hash: ", preprocessed.hash); + println("Property values:"); + for (auto property : preprocessed.arguments) { + println(" ", property.second); + } + println(""); - return 0; + return 0; } diff --git a/tests/unit/basic_bloom_filter.cpp b/tests/unit/basic_bloom_filter.cpp index b94f8c5f9..714dcb411 100644 --- a/tests/unit/basic_bloom_filter.cpp +++ b/tests/unit/basic_bloom_filter.cpp @@ -8,32 +8,30 @@ using StringHashFunction = std::function<uint64_t(const std::string &)>; -TEST(BloomFilterTest, InsertContains) -{ - StringHashFunction hash1 = fnv64<std::string>; - StringHashFunction hash2 = fnv1a64<std::string>; - std::vector<StringHashFunction> funcs = {hash1, hash2}; +TEST(BloomFilterTest, InsertContains) { + StringHashFunction hash1 = fnv64<std::string>; + StringHashFunction hash2 = fnv1a64<std::string>; + std::vector<StringHashFunction> funcs = {hash1, hash2}; - BloomFilter<std::string, 64> bloom(funcs); + BloomFilter<std::string, 64> bloom(funcs); - std::string test = "test"; - std::string kifla = "kifla"; + std::string test = "test"; + std::string kifla = "kifla"; - bool contains_test = bloom.contains(test); - ASSERT_EQ(contains_test, false); - bloom.insert(test); - contains_test = bloom.contains(test); - ASSERT_EQ(contains_test, true); + bool contains_test = bloom.contains(test); + ASSERT_EQ(contains_test, false); + bloom.insert(test); + contains_test = bloom.contains(test); + ASSERT_EQ(contains_test, true); - bool contains_kifla = bloom.contains(kifla); - ASSERT_EQ(contains_kifla, false); - bloom.insert(kifla); - contains_kifla = bloom.contains(kifla); - ASSERT_EQ(contains_kifla, true); + bool contains_kifla = bloom.contains(kifla); + ASSERT_EQ(contains_kifla, false); + bloom.insert(kifla); + contains_kifla = bloom.contains(kifla); + ASSERT_EQ(contains_kifla, true); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/block_allocator.cpp b/tests/unit/block_allocator.cpp index 35bf9cfdc..aa7b54ac9 100644 --- a/tests/unit/block_allocator.cpp +++ b/tests/unit/block_allocator.cpp @@ -2,23 +2,20 @@ #include "utils/memory/block_allocator.hpp" -TEST(BlockAllocatorTest, UnusedVsReleaseSize) -{ - BlockAllocator<64> block_allocator(10); - void *block = block_allocator.acquire(); - block_allocator.release(block); - EXPECT_EQ(block_allocator.unused_size(), 9); - EXPECT_EQ(block_allocator.release_size(), 1); +TEST(BlockAllocatorTest, UnusedVsReleaseSize) { + BlockAllocator<64> block_allocator(10); + void *block = block_allocator.acquire(); + block_allocator.release(block); + EXPECT_EQ(block_allocator.unused_size(), 9); + EXPECT_EQ(block_allocator.release_size(), 1); } -TEST(BlockAllocatorTest, CountMallocAndFreeCalls) -{ - // TODO: implementation - EXPECT_EQ(true, true); +TEST(BlockAllocatorTest, CountMallocAndFreeCalls) { + // TODO: implementation + EXPECT_EQ(true, true); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/chunked_decoder.cpp b/tests/unit/chunked_decoder.cpp index 0b8703bdb..314645864 100644 --- a/tests/unit/chunked_decoder.cpp +++ b/tests/unit/chunked_decoder.cpp @@ -13,14 +13,12 @@ using byte = unsigned char; void print_hex(byte x) { printf("%02X ", static_cast<byte>(x)); } -struct DummyStream -{ - void write(const byte *values, size_t n) - { - data.insert(data.end(), values, values + n); - } +struct DummyStream { + void write(const byte *values, size_t n) { + data.insert(data.end(), values, values + n); + } - std::vector<byte> data; + std::vector<byte> data; }; using Decoder = bolt::ChunkedDecoder<DummyStream>; @@ -36,33 +34,28 @@ static constexpr size_t N = std::extent<decltype(chunks)>::value; std::string decoded = "A quick brown fox jumps over a lazy dog"; -TEST(ChunkedDecoderTest, WriteString) -{ - DummyStream stream; - Decoder decoder(stream); +TEST(ChunkedDecoderTest, WriteString) { + DummyStream stream; + Decoder decoder(stream); - for(size_t i = 0; i < N; ++i) - { - auto & chunk = chunks[i]; - logging::info("Chunk size: {}", chunk.size()); + for (size_t i = 0; i < N; ++i) { + auto &chunk = chunks[i]; + logging::info("Chunk size: {}", chunk.size()); - const byte* start = chunk.data(); - auto finished = decoder.decode(start, chunk.size()); + const byte *start = chunk.data(); + auto finished = decoder.decode(start, chunk.size()); - // break early if finished - if(finished) - break; - } + // break early if finished + if (finished) break; + } - // check validity - ASSERT_EQ(decoded.size(), stream.data.size()); - for(size_t i = 0; i < decoded.size(); ++i) - ASSERT_EQ(decoded[i], stream.data[i]); + // check validity + ASSERT_EQ(decoded.size(), stream.data.size()); + for (size_t i = 0; i < decoded.size(); ++i) + ASSERT_EQ(decoded[i], stream.data[i]); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } - diff --git a/tests/unit/chunked_encoder.cpp b/tests/unit/chunked_encoder.cpp index 16bd84685..b7ed389bb 100644 --- a/tests/unit/chunked_encoder.cpp +++ b/tests/unit/chunked_encoder.cpp @@ -13,111 +13,99 @@ using byte = unsigned char; void print_hex(byte x) { printf("%02X ", static_cast<byte>(x)); } -class DummyStream -{ -public: - void write(const byte *values, size_t n) - { - num_calls++; - data.insert(data.end(), values, values + n); - } +class DummyStream { + public: + void write(const byte *values, size_t n) { + num_calls++; + data.insert(data.end(), values, values + n); + } - byte pop() - { - auto c = data.front(); - data.pop_front(); - return c; - } + byte pop() { + auto c = data.front(); + data.pop_front(); + return c; + } - size_t pop_size() { return ((size_t)pop() << 8) | pop(); } + size_t pop_size() { return ((size_t)pop() << 8) | pop(); } - void print() - { - for (size_t i = 0; i < data.size(); ++i) - print_hex(data[i]); - } + void print() { + for (size_t i = 0; i < data.size(); ++i) print_hex(data[i]); + } - std::deque<byte> data; - size_t num_calls{0}; + std::deque<byte> data; + size_t num_calls{0}; }; using Encoder = bolt::ChunkedEncoder<DummyStream>; -void write_ff(Encoder &encoder, size_t n) -{ - std::vector<byte> v; +void write_ff(Encoder &encoder, size_t n) { + std::vector<byte> v; - for (size_t i = 0; i < n; ++i) - v.push_back('\xFF'); + for (size_t i = 0; i < n; ++i) v.push_back('\xFF'); - encoder.write(v.data(), v.size()); + encoder.write(v.data(), v.size()); } -void check_ff(DummyStream &stream, size_t n) -{ - for (size_t i = 0; i < n; ++i) - ASSERT_EQ(stream.pop(), byte('\xFF')); +void check_ff(DummyStream &stream, size_t n) { + for (size_t i = 0; i < n; ++i) ASSERT_EQ(stream.pop(), byte('\xFF')); - (void)stream; + (void)stream; } using encoder_t = bolt::ChunkedEncoder<DummyStream>; -TEST(ChunkedEncoderTest, Encode) -{ - DummyStream stream; - encoder_t encoder(stream); - size_t chunk_size = encoder_t::chunk_size; +TEST(ChunkedEncoderTest, Encode) { + DummyStream stream; + encoder_t encoder(stream); + size_t chunk_size = encoder_t::chunk_size; - write_ff(encoder, 10); - write_ff(encoder, 10); - encoder.write_chunk(); + write_ff(encoder, 10); + write_ff(encoder, 10); + encoder.write_chunk(); - write_ff(encoder, 10); - write_ff(encoder, 10); - encoder.write_chunk(); + write_ff(encoder, 10); + write_ff(encoder, 10); + encoder.write_chunk(); - // this should be two chunks, one of size 65533 and the other of size 1467 - write_ff(encoder, 67000); - encoder.write_chunk(); + // this should be two chunks, one of size 65533 and the other of size 1467 + write_ff(encoder, 67000); + encoder.write_chunk(); - for (int i = 0; i < 10000; ++i) - write_ff(encoder, 1500); - encoder.write_chunk(); + for (int i = 0; i < 10000; ++i) write_ff(encoder, 1500); + encoder.write_chunk(); - ASSERT_EQ(stream.pop_size(), 20); - check_ff(stream, 20); - ASSERT_EQ(stream.pop_size(), 0); - - ASSERT_EQ(stream.pop_size(), 20); - check_ff(stream, 20); - ASSERT_EQ(stream.pop_size(), 0); - - ASSERT_EQ(stream.pop_size(), chunk_size); - check_ff(stream, chunk_size); - ASSERT_EQ(stream.pop_size(), 0); - - ASSERT_EQ(stream.pop_size(), 1467); - check_ff(stream, 1467); - ASSERT_EQ(stream.pop_size(), 0); - - size_t k = 10000 * 1500; - - while (k > 0) { - auto size = k > chunk_size ? chunk_size : k; - ASSERT_EQ(stream.pop_size(), size); - check_ff(stream, size); - ASSERT_EQ(stream.pop_size(), 0); - k -= size; - } + ASSERT_EQ(stream.pop_size(), 20); + check_ff(stream, 20); + ASSERT_EQ(stream.pop_size(), 0); + + ASSERT_EQ(stream.pop_size(), 20); + check_ff(stream, 20); + ASSERT_EQ(stream.pop_size(), 0); + + ASSERT_EQ(stream.pop_size(), chunk_size); + check_ff(stream, chunk_size); + ASSERT_EQ(stream.pop_size(), 0); + + ASSERT_EQ(stream.pop_size(), 1467); + check_ff(stream, 1467); + ASSERT_EQ(stream.pop_size(), 0); + + size_t k = 10000 * 1500; + + while (k > 0) { + auto size = k > chunk_size ? chunk_size : k; + ASSERT_EQ(stream.pop_size(), size); + check_ff(stream, size); ASSERT_EQ(stream.pop_size(), 0); + k -= size; + } + ASSERT_EQ(stream.pop_size(), 0); } -int main(int argc, char **argv) -{ - logging::init_sync(); - logging::log->pipe(std::make_unique<Stdout>()); +int main(int argc, char **argv) { + logging::init_sync(); + logging::log->pipe(std::make_unique<Stdout>()); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/concurrent_list.cpp b/tests/unit/concurrent_list.cpp index 2e5a3211a..e435f657f 100644 --- a/tests/unit/concurrent_list.cpp +++ b/tests/unit/concurrent_list.cpp @@ -2,79 +2,74 @@ #include "data_structures/concurrent/concurrent_list.hpp" -TEST(ConncurentList, Insert) -{ - ConcurrentList<int> list; - auto it = list.begin(); - it.push(32); - it.reset(); - ASSERT_EQ(*it, 32); +TEST(ConncurentList, Insert) { + ConcurrentList<int> list; + auto it = list.begin(); + it.push(32); + it.reset(); + ASSERT_EQ(*it, 32); } -TEST(ConncurentList, Iterate) -{ - ConcurrentList<int> list; - auto it = list.begin(); - it.push(32); - it.push(7); - it.push(9); - it.push(0); - it.reset(); +TEST(ConncurentList, Iterate) { + ConcurrentList<int> list; + auto it = list.begin(); + it.push(32); + it.push(7); + it.push(9); + it.push(0); + it.reset(); - ASSERT_EQ(*it, 0); - it++; - ASSERT_EQ(*it, 9); - it++; - ASSERT_EQ(*it, 7); - it++; - ASSERT_EQ(*it, 32); - it++; - ASSERT_EQ(it, list.end()); + ASSERT_EQ(*it, 0); + it++; + ASSERT_EQ(*it, 9); + it++; + ASSERT_EQ(*it, 7); + it++; + ASSERT_EQ(*it, 32); + it++; + ASSERT_EQ(it, list.end()); } -TEST(ConncurentList, RemoveHead) -{ - ConcurrentList<int> list; - auto it = list.begin(); - it.push(32); - it.reset(); +TEST(ConncurentList, RemoveHead) { + ConcurrentList<int> list; + auto it = list.begin(); + it.push(32); + it.reset(); - ASSERT_EQ(it.remove(), true); - ASSERT_EQ(it.is_removed(), true); - ASSERT_EQ(!it.remove(), true); + ASSERT_EQ(it.remove(), true); + ASSERT_EQ(it.is_removed(), true); + ASSERT_EQ(!it.remove(), true); - it.reset(); - ASSERT_EQ(it, list.end()); + it.reset(); + ASSERT_EQ(it, list.end()); } -TEST(ConncurentList, Remove) -{ - ConcurrentList<int> list; - auto it = list.begin(); - it.push(32); - it.push(7); - it.push(9); - it.push(0); - it.reset(); +TEST(ConncurentList, Remove) { + ConcurrentList<int> list; + auto it = list.begin(); + it.push(32); + it.push(7); + it.push(9); + it.push(0); + it.reset(); - it++; - it++; - ASSERT_EQ(it.remove(), true); - ASSERT_EQ(it.is_removed(), true); - ASSERT_EQ(!it.remove(), true); + it++; + it++; + ASSERT_EQ(it.remove(), true); + ASSERT_EQ(it.is_removed(), true); + ASSERT_EQ(!it.remove(), true); - it.reset(); - ASSERT_EQ(*it, 0); - it++; - ASSERT_EQ(*it, 9); - it++; - ASSERT_EQ(*it, 32); - it++; - ASSERT_EQ(it, list.end()); + it.reset(); + ASSERT_EQ(*it, 0); + it++; + ASSERT_EQ(*it, 9); + it++; + ASSERT_EQ(*it, 32); + it++; + ASSERT_EQ(it, list.end()); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/concurrent_map.cpp b/tests/unit/concurrent_map.cpp index 540ad59e3..34fa04a84 100644 --- a/tests/unit/concurrent_map.cpp +++ b/tests/unit/concurrent_map.cpp @@ -2,76 +2,71 @@ #include "gtest/gtest.h" -#include "logging/default.hpp" -#include "logging/streams/stdout.hpp" #include "data_structures/concurrent/concurrent_map.hpp" #include "logging/default.hpp" +#include "logging/default.hpp" +#include "logging/streams/stdout.hpp" #include "logging/streams/stdout.hpp" #include "utils/assert.hpp" using skiplist_t = ConcurrentMap<int, int>; -void print_skiplist(const skiplist_t::Accessor &skiplist) -{ - logging::info("Skiplist now has: "); +void print_skiplist(const skiplist_t::Accessor &skiplist) { + logging::info("Skiplist now has: "); - for (auto &kv : skiplist) - logging::info(" ({}, {})", kv.first, kv.second); + for (auto &kv : skiplist) logging::info(" ({}, {})", kv.first, kv.second); } -TEST(ConcurrentMapSkiplist, Mix) -{ - skiplist_t skiplist; - auto accessor = skiplist.access(); +TEST(ConcurrentMapSkiplist, Mix) { + skiplist_t skiplist; + auto accessor = skiplist.access(); - // insert 10 - permanent_assert(accessor.insert(1, 10).second == true, - "add first element"); + // insert 10 + permanent_assert(accessor.insert(1, 10).second == true, "add first element"); - // try insert 10 again (should fail) - permanent_assert(accessor.insert(1, 10).second == false, - "add the same element, should fail"); + // try insert 10 again (should fail) + permanent_assert(accessor.insert(1, 10).second == false, + "add the same element, should fail"); - // insert 20 - permanent_assert(accessor.insert(2, 20).second == true, - "insert new unique element"); + // insert 20 + permanent_assert(accessor.insert(2, 20).second == true, + "insert new unique element"); - print_skiplist(accessor); + print_skiplist(accessor); - // value at key 3 shouldn't exist - permanent_assert((accessor.find(3) == accessor.end()) == true, - "try to find element which doesn't exist"); + // value at key 3 shouldn't exist + permanent_assert((accessor.find(3) == accessor.end()) == true, + "try to find element which doesn't exist"); - // value at key 2 should exist - permanent_assert((accessor.find(2) != accessor.end()) == true, - "find iterator"); + // value at key 2 should exist + permanent_assert((accessor.find(2) != accessor.end()) == true, + "find iterator"); - // at key 2 is 20 (true) - permanent_assert(accessor.find(2)->second == 20, "find element"); + // at key 2 is 20 (true) + permanent_assert(accessor.find(2)->second == 20, "find element"); - // removed existing (1) - permanent_assert(accessor.remove(1) == true, "try to remove element"); + // removed existing (1) + permanent_assert(accessor.remove(1) == true, "try to remove element"); - // removed non-existing (3) - permanent_assert(accessor.remove(3) == false, - "try to remove element which doesn't exist"); + // removed non-existing (3) + permanent_assert(accessor.remove(3) == false, + "try to remove element which doesn't exist"); - // insert (1, 10) - permanent_assert(accessor.insert(1, 10).second == true, - "insert unique element"); + // insert (1, 10) + permanent_assert(accessor.insert(1, 10).second == true, + "insert unique element"); - // insert (4, 40) - permanent_assert(accessor.insert(4, 40).second == true, - "insert unique element"); + // insert (4, 40) + permanent_assert(accessor.insert(4, 40).second == true, + "insert unique element"); - print_skiplist(accessor); + print_skiplist(accessor); } -int main(int argc, char **argv) -{ - logging::init_async(); - logging::log->pipe(std::make_unique<Stdout>()); +int main(int argc, char **argv) { + logging::init_async(); + logging::log->pipe(std::make_unique<Stdout>()); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/concurrent_set.cpp b/tests/unit/concurrent_set.cpp index a29397e21..63e18aefb 100644 --- a/tests/unit/concurrent_set.cpp +++ b/tests/unit/concurrent_set.cpp @@ -7,55 +7,50 @@ #include "logging/streams/stdout.hpp" #include "utils/assert.hpp" -void print_skiplist(const ConcurrentSet<int>::Accessor &skiplist) -{ - logging::info("Skiplist set now has:"); - for (auto &item : skiplist) - logging::info("{}", item); +void print_skiplist(const ConcurrentSet<int>::Accessor &skiplist) { + logging::info("Skiplist set now has:"); + for (auto &item : skiplist) logging::info("{}", item); } -TEST(ConcurrentSet, Mix) -{ - logging::init_async(); - logging::log->pipe(std::make_unique<Stdout>()); +TEST(ConcurrentSet, Mix) { + logging::init_async(); + logging::log->pipe(std::make_unique<Stdout>()); - ConcurrentSet<int> set; + ConcurrentSet<int> set; - auto accessor = set.access(); + auto accessor = set.access(); - permanent_assert(accessor.insert(1).second == true, - "added non-existing 1? (true)"); + permanent_assert(accessor.insert(1).second == true, + "added non-existing 1? (true)"); - permanent_assert(accessor.insert(1).second == false, - "added already existing 1? (false)"); + permanent_assert(accessor.insert(1).second == false, + "added already existing 1? (false)"); - permanent_assert(accessor.insert(2).second == true, - "added non-existing 2? (true)"); + permanent_assert(accessor.insert(2).second == true, + "added non-existing 2? (true)"); - permanent_assert(accessor.find(3) == accessor.end(), - "item 3 doesn't exist? (true)"); + permanent_assert(accessor.find(3) == accessor.end(), + "item 3 doesn't exist? (true)"); - permanent_assert(accessor.contains(3) == false, "item 3 exists? (false)"); + permanent_assert(accessor.contains(3) == false, "item 3 exists? (false)"); - permanent_assert(accessor.find(2) != accessor.end(), - "item 2 exists? (true)"); + permanent_assert(accessor.find(2) != accessor.end(), "item 2 exists? (true)"); - permanent_assert(*accessor.find(2) == 2, "find item 2"); + permanent_assert(*accessor.find(2) == 2, "find item 2"); - permanent_assert(accessor.remove(1) == true, "removed existing 1? (true)"); + permanent_assert(accessor.remove(1) == true, "removed existing 1? (true)"); - permanent_assert(accessor.remove(3) == false, - "try to remove non existing element"); + permanent_assert(accessor.remove(3) == false, + "try to remove non existing element"); - permanent_assert(accessor.insert(1).second == true, "add 1 again"); + permanent_assert(accessor.insert(1).second == true, "add 1 again"); - permanent_assert(accessor.insert(4).second == true, "add 4"); + permanent_assert(accessor.insert(4).second == true, "add 4"); - print_skiplist(accessor); + print_skiplist(accessor); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/dynamic_bitset.cpp b/tests/unit/dynamic_bitset.cpp index 6d1ef7f05..24f3060e0 100644 --- a/tests/unit/dynamic_bitset.cpp +++ b/tests/unit/dynamic_bitset.cpp @@ -2,24 +2,22 @@ #include "data_structures/bitset/dynamic_bitset.hpp" -TEST(DynamicBitset, BasicFunctionality) -{ - DynamicBitset<> db; - db.set(222555, 1); - bool value = db.at(222555, 1); - ASSERT_EQ(value, true); +TEST(DynamicBitset, BasicFunctionality) { + DynamicBitset<> db; + db.set(222555, 1); + bool value = db.at(222555, 1); + ASSERT_EQ(value, true); - db.set(32, 1); - value = db.at(32, 1); - ASSERT_EQ(value, true); + db.set(32, 1); + value = db.at(32, 1); + ASSERT_EQ(value, true); - db.clear(32, 1); - value = db.at(32, 1); - ASSERT_EQ(value, false); + db.clear(32, 1); + value = db.at(32, 1); + ASSERT_EQ(value, false); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/fswatcher.cpp b/tests/unit/fswatcher.cpp index 60571a845..bd75f37c6 100644 --- a/tests/unit/fswatcher.cpp +++ b/tests/unit/fswatcher.cpp @@ -12,125 +12,118 @@ using namespace std::chrono_literals; using namespace utils; fs::path working_dir = "../data"; -fs::path filename = "test.txt"; -fs::path test_path = working_dir / filename; +fs::path filename = "test.txt"; +fs::path test_path = working_dir / filename; -void create_delete_loop(int iterations, ms action_delta) -{ - for (int i = 0; i < iterations; ++i) - { - // create test file - std::ofstream outfile(test_path); - outfile.close(); - std::this_thread::sleep_for(action_delta); - - // remove test file - fs::remove(test_path); - std::this_thread::sleep_for(action_delta); - } -} - -void modify_loop(int iterations, ms action_delta) -{ +void create_delete_loop(int iterations, ms action_delta) { + for (int i = 0; i < iterations; ++i) { // create test file std::ofstream outfile(test_path); outfile.close(); std::this_thread::sleep_for(action_delta); - // append TEST multiple times - for (int i = 0; i < iterations; ++i) - { - outfile.open(test_path, std::ios_base::app); - outfile << "TEST" << i; - outfile.close(); - std::this_thread::sleep_for(action_delta); - } - // remove test file fs::remove(test_path); std::this_thread::sleep_for(action_delta); + } } -TEST(FSWatcherTest, CreateDeleteLoop) -{ - FSWatcher watcher; +void modify_loop(int iterations, ms action_delta) { + // create test file + std::ofstream outfile(test_path); + outfile.close(); + std::this_thread::sleep_for(action_delta); - // parameters - int iterations = 10; - int created_no = 0; - int deleted_no = 0; + // append TEST multiple times + for (int i = 0; i < iterations; ++i) { + outfile.open(test_path, std::ios_base::app); + outfile << "TEST" << i; + outfile.close(); + std::this_thread::sleep_for(action_delta); + } - // 3 is here because the test has to ensure that there is enough time - // between events in order to catch all relevant events (watcher takes a - // sleep between two undelying calls and if there is no enough time - // some events can be overriden) - ms action_delta = watcher.check_interval() * 3; - - // watchers - watcher.watch(WatchDescriptor(working_dir, FSEventType::Created), - [&](FSEvent) {}); - watcher.watch(WatchDescriptor(working_dir, FSEventType::Deleted), - [&](FSEvent) {}); - // above watchers should be ignored - watcher.watch(WatchDescriptor(working_dir, FSEventType::All), - [&](FSEvent event) { - if (event.type == FSEventType::Created) created_no++; - if (event.type == FSEventType::Deleted) deleted_no++; - }); - - ASSERT_EQ(watcher.size(), 1); - - create_delete_loop(iterations, action_delta); - ASSERT_EQ(created_no, iterations); - ASSERT_EQ(deleted_no, iterations); - - watcher.unwatchAll(); - ASSERT_EQ(watcher.size(), 0); - - watcher.unwatchAll(); - ASSERT_EQ(watcher.size(), 0); - - create_delete_loop(iterations, action_delta); - ASSERT_EQ(created_no, iterations); - ASSERT_EQ(deleted_no, iterations); + // remove test file + fs::remove(test_path); + std::this_thread::sleep_for(action_delta); } -TEST(FSWatcherTest, ModifiyLoop) -{ - FSWatcher watcher; +TEST(FSWatcherTest, CreateDeleteLoop) { + FSWatcher watcher; - // parameters - int iterations = 10; - int modified_no = 0; + // parameters + int iterations = 10; + int created_no = 0; + int deleted_no = 0; - // 3 is here because the test has to ensure that there is enough time - // between events in order to catch all relevant events (watcher takes a - // sleep between two undelying calls and if there is no enough time - // some events can be overriden) - ms action_delta = watcher.check_interval() * 3; + // 3 is here because the test has to ensure that there is enough time + // between events in order to catch all relevant events (watcher takes a + // sleep between two undelying calls and if there is no enough time + // some events can be overriden) + ms action_delta = watcher.check_interval() * 3; - watcher.watch(WatchDescriptor(working_dir, FSEventType::Modified), - [&](FSEvent) { modified_no++; }); - ASSERT_EQ(watcher.size(), 1); + // watchers + watcher.watch(WatchDescriptor(working_dir, FSEventType::Created), + [&](FSEvent) {}); + watcher.watch(WatchDescriptor(working_dir, FSEventType::Deleted), + [&](FSEvent) {}); + // above watchers should be ignored + watcher.watch(WatchDescriptor(working_dir, FSEventType::All), + [&](FSEvent event) { + if (event.type == FSEventType::Created) created_no++; + if (event.type == FSEventType::Deleted) deleted_no++; + }); - modify_loop(iterations, action_delta); - ASSERT_EQ(modified_no, iterations); + ASSERT_EQ(watcher.size(), 1); - watcher.unwatch(WatchDescriptor(working_dir, FSEventType::Modified)); - ASSERT_EQ(watcher.size(), 0); + create_delete_loop(iterations, action_delta); + ASSERT_EQ(created_no, iterations); + ASSERT_EQ(deleted_no, iterations); - watcher.unwatch(WatchDescriptor(working_dir, FSEventType::Modified)); - ASSERT_EQ(watcher.size(), 0); + watcher.unwatchAll(); + ASSERT_EQ(watcher.size(), 0); - modify_loop(iterations, action_delta); - ASSERT_EQ(modified_no, iterations); + watcher.unwatchAll(); + ASSERT_EQ(watcher.size(), 0); + + create_delete_loop(iterations, action_delta); + ASSERT_EQ(created_no, iterations); + ASSERT_EQ(deleted_no, iterations); } -int main(int argc, char **argv) -{ - logging::init_sync(); - logging::log->pipe(std::make_unique<Stdout>()); +TEST(FSWatcherTest, ModifiyLoop) { + FSWatcher watcher; - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + // parameters + int iterations = 10; + int modified_no = 0; + + // 3 is here because the test has to ensure that there is enough time + // between events in order to catch all relevant events (watcher takes a + // sleep between two undelying calls and if there is no enough time + // some events can be overriden) + ms action_delta = watcher.check_interval() * 3; + + watcher.watch(WatchDescriptor(working_dir, FSEventType::Modified), + [&](FSEvent) { modified_no++; }); + ASSERT_EQ(watcher.size(), 1); + + modify_loop(iterations, action_delta); + ASSERT_EQ(modified_no, iterations); + + watcher.unwatch(WatchDescriptor(working_dir, FSEventType::Modified)); + ASSERT_EQ(watcher.size(), 0); + + watcher.unwatch(WatchDescriptor(working_dir, FSEventType::Modified)); + ASSERT_EQ(watcher.size(), 0); + + modify_loop(iterations, action_delta); + ASSERT_EQ(modified_no, iterations); +} + +int main(int argc, char **argv) { + logging::init_sync(); + logging::log->pipe(std::make_unique<Stdout>()); + + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/graph_db_accessor.cpp b/tests/unit/graph_db_accessor.cpp index a42000887..e5c6725c9 100644 --- a/tests/unit/graph_db_accessor.cpp +++ b/tests/unit/graph_db_accessor.cpp @@ -1,25 +1,22 @@ #include "gtest/gtest.h" -#include "dbms/dbms.hpp" #include "database/graph_db.hpp" #include "database/graph_db_accessor.hpp" +#include "dbms/dbms.hpp" -#include "storage/vertex_accessor.hpp" #include "storage/edge_accessor.hpp" - +#include "storage/vertex_accessor.hpp" size_t CountVertices(GraphDbAccessor &db_accessor) { size_t r_val = 0; - for (auto va : db_accessor.vertices()) - r_val++; + for (auto va : db_accessor.vertices()) r_val++; return r_val; } size_t CountEdges(GraphDbAccessor &db_accessor) { size_t r_val = 0; - for (auto va : db_accessor.edges()) - r_val++; + for (auto va : db_accessor.edges()) r_val++; return r_val; } @@ -127,8 +124,7 @@ TEST(GraphDbAccessorTest, RemoveEdge) { GraphDbAccessor dba2 = dbms.active(); EXPECT_EQ(CountEdges(dba2), 2); for (auto edge : dba2.edges()) - if (edge.edge_type() == dba2.edge_type("hates")) - dba2.remove_edge(edge); + if (edge.edge_type() == dba2.edge_type("hates")) dba2.remove_edge(edge); // current state: (v1) - [:likes] -> (v2), (v3) dba2.transaction_.commit(); @@ -157,7 +153,6 @@ TEST(GraphDbAccessorTest, RemoveEdge) { } TEST(GraphDbAccessorTest, DetachRemoveVertex) { - Dbms dbms; GraphDbAccessor dba1 = dbms.active(); @@ -187,8 +182,7 @@ TEST(GraphDbAccessorTest, DetachRemoveVertex) { EXPECT_EQ(CountVertices(dba2), 2); EXPECT_EQ(CountEdges(dba2), 1); - for (auto va : dba2.vertices()) - EXPECT_FALSE(dba2.remove_vertex(va)); + for (auto va : dba2.vertices()) EXPECT_FALSE(dba2.remove_vertex(va)); dba2.transaction_.commit(); GraphDbAccessor dba3 = dbms.active(); @@ -208,8 +202,7 @@ TEST(GraphDbAccessorTest, DetachRemoveVertex) { // remove the last vertex, it has no connections // so that should work - for (auto va : dba4.vertices()) - EXPECT_TRUE(dba4.remove_vertex(va)); + for (auto va : dba4.vertices()) EXPECT_TRUE(dba4.remove_vertex(va)); dba4.transaction_.commit(); GraphDbAccessor dba5 = dbms.active(); @@ -259,8 +252,7 @@ TEST(GraphDbAccessorTest, Properties) { EXPECT_NE(prop, dbms.active().property("surname")); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/program_argument.cpp b/tests/unit/program_argument.cpp index b2276e089..b02acd421 100644 --- a/tests/unit/program_argument.cpp +++ b/tests/unit/program_argument.cpp @@ -7,90 +7,85 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wwritable-strings" -TEST(ProgramArgument, FlagOnly) -{ - CLEAR_ARGS(); +TEST(ProgramArgument, FlagOnly) { + CLEAR_ARGS(); - int argc = 2; - char *argv[] = {"ProgramArgument FlagOnly Test", "-test"}; + int argc = 2; + char *argv[] = {"ProgramArgument FlagOnly Test", "-test"}; - REGISTER_ARGS(argc, argv); - REGISTER_REQUIRED_ARGS({"-test"}); + REGISTER_ARGS(argc, argv); + REGISTER_REQUIRED_ARGS({"-test"}); - ASSERT_EQ(CONTAINS_FLAG("-test"), true); + ASSERT_EQ(CONTAINS_FLAG("-test"), true); } -TEST(ProgramArgument, SingleEntry) -{ - CLEAR_ARGS(); +TEST(ProgramArgument, SingleEntry) { + CLEAR_ARGS(); - int argc = 3; - char *argv[] = {"ProgramArgument Single Entry Test", "-bananas", "99"}; + int argc = 3; + char *argv[] = {"ProgramArgument Single Entry Test", "-bananas", "99"}; - REGISTER_REQUIRED_ARGS({"-bananas"}); - REGISTER_ARGS(argc, argv); + REGISTER_REQUIRED_ARGS({"-bananas"}); + REGISTER_ARGS(argc, argv); - ASSERT_EQ(GET_ARG("-bananas", "100").get_int(), 99); + ASSERT_EQ(GET_ARG("-bananas", "100").get_int(), 99); } -TEST(ProgramArgument, MultipleEntries) -{ - CLEAR_ARGS(); +TEST(ProgramArgument, MultipleEntries) { + CLEAR_ARGS(); - int argc = 4; - char *argv[] = {"ProgramArgument Multiple Entries Test", "-files", - "first_file.txt", "second_file.txt"}; + int argc = 4; + char *argv[] = {"ProgramArgument Multiple Entries Test", "-files", + "first_file.txt", "second_file.txt"}; - REGISTER_ARGS(argc, argv); + REGISTER_ARGS(argc, argv); - auto files = GET_ARGS("-files", {}); + auto files = GET_ARGS("-files", {}); - ASSERT_EQ(files[0].get_string(), "first_file.txt"); + ASSERT_EQ(files[0].get_string(), "first_file.txt"); } -TEST(ProgramArgument, Combination) -{ - CLEAR_ARGS(); +TEST(ProgramArgument, Combination) { + CLEAR_ARGS(); - int argc = 14; - char *argv[] = {"ProgramArgument Combination Test", - "-run_tests", - "-tests", - "Test1", - "Test2", - "Test3", - "-run_times", - "10", - "-export", - "test1.txt", - "test2.txt", - "test3.txt", - "-import", - "data.txt"}; + int argc = 14; + char *argv[] = {"ProgramArgument Combination Test", + "-run_tests", + "-tests", + "Test1", + "Test2", + "Test3", + "-run_times", + "10", + "-export", + "test1.txt", + "test2.txt", + "test3.txt", + "-import", + "data.txt"}; - REGISTER_ARGS(argc, argv); + REGISTER_ARGS(argc, argv); - ASSERT_EQ(CONTAINS_FLAG("-run_tests"), true); + ASSERT_EQ(CONTAINS_FLAG("-run_tests"), true); - auto tests = GET_ARGS("-tests", {}); - ASSERT_EQ(tests[0].get_string(), "Test1"); - ASSERT_EQ(tests[1].get_string(), "Test2"); - ASSERT_EQ(tests[2].get_string(), "Test3"); + auto tests = GET_ARGS("-tests", {}); + ASSERT_EQ(tests[0].get_string(), "Test1"); + ASSERT_EQ(tests[1].get_string(), "Test2"); + ASSERT_EQ(tests[2].get_string(), "Test3"); - ASSERT_EQ(GET_ARG("-run_times", "0").get_int(), 10); + ASSERT_EQ(GET_ARG("-run_times", "0").get_int(), 10); - auto exports = GET_ARGS("-export", {}); - ASSERT_EQ(exports[0].get_string(), "test1.txt"); - ASSERT_EQ(exports[1].get_string(), "test2.txt"); - ASSERT_EQ(exports[2].get_string(), "test3.txt"); + auto exports = GET_ARGS("-export", {}); + ASSERT_EQ(exports[0].get_string(), "test1.txt"); + ASSERT_EQ(exports[1].get_string(), "test2.txt"); + ASSERT_EQ(exports[2].get_string(), "test3.txt"); - ASSERT_EQ(GET_ARG("-import", "test.txt").get_string(), "data.txt"); + ASSERT_EQ(GET_ARG("-import", "test.txt").get_string(), "data.txt"); } #pragma clang diagnostic pop -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/ptr_int.cpp b/tests/unit/ptr_int.cpp index b940441ec..68591ced8 100644 --- a/tests/unit/ptr_int.cpp +++ b/tests/unit/ptr_int.cpp @@ -2,29 +2,25 @@ #include "data_structures/ptr_int.hpp" -TEST(PtrInt, SizeOf) -{ - ASSERT_EQ(sizeof(PtrInt<int *, 1, int>), sizeof(uintptr_t)); +TEST(PtrInt, SizeOf) { + ASSERT_EQ(sizeof(PtrInt<int *, 1, int>), sizeof(uintptr_t)); } -TEST(PtrInt, ConstructionAndRead) -{ - auto ptr1 = std::make_unique<int>(2); - PtrInt<int *, 2, int> pack1(ptr1.get(), 1); +TEST(PtrInt, ConstructionAndRead) { + auto ptr1 = std::make_unique<int>(2); + PtrInt<int *, 2, int> pack1(ptr1.get(), 1); - ASSERT_EQ(pack1.get_int(), 1); - ASSERT_EQ(pack1.get_ptr(), ptr1.get()); + ASSERT_EQ(pack1.get_int(), 1); + ASSERT_EQ(pack1.get_ptr(), ptr1.get()); + auto ptr2 = std::make_unique<int>(2); + PtrInt<int *, 3, int> pack2(ptr2.get(), 4); - auto ptr2 = std::make_unique<int>(2); - PtrInt<int *, 3, int> pack2(ptr2.get(), 4); - - ASSERT_EQ(pack2.get_int(), 4); - ASSERT_EQ(pack2.get_ptr(), ptr2.get()); + ASSERT_EQ(pack2.get_int(), 4); + ASSERT_EQ(pack2.get_ptr(), ptr2.get()); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/record_edge_vertex_accessor.cpp b/tests/unit/record_edge_vertex_accessor.cpp index e660ee38f..3c82d6787 100644 --- a/tests/unit/record_edge_vertex_accessor.cpp +++ b/tests/unit/record_edge_vertex_accessor.cpp @@ -2,22 +2,20 @@ #include "gtest/gtest.h" -#include "dbms/dbms.hpp" #include "database/graph_db.hpp" #include "database/graph_db_accessor.hpp" +#include "dbms/dbms.hpp" +#include "storage/edge_accessor.hpp" #include "storage/typed_value.hpp" #include "storage/vertex_accessor.hpp" -#include "storage/edge_accessor.hpp" - TEST(RecordAccessor, Properties) { - Dbms dbms; GraphDbAccessor dba = dbms.active(); auto vertex = dba.insert_vertex(); - auto &properties = vertex.Properties(); + auto& properties = vertex.Properties(); auto property = dba.property("PropName"); auto property_other = dba.property("Other"); @@ -46,7 +44,6 @@ TEST(RecordAccessor, DbAccessor) { } TEST(RecordAccessor, RecordEquality) { - Dbms dbms; GraphDbAccessor dba = dbms.active(); @@ -62,11 +59,10 @@ TEST(RecordAccessor, RecordEquality) { } TEST(RecordAccessor, VertexLabels) { - Dbms dbms; GraphDbAccessor dba = dbms.active(); auto v1 = dba.insert_vertex(); - auto &labels = v1.labels(); + auto& labels = v1.labels(); EXPECT_EQ(v1.labels().size(), 0); @@ -138,9 +134,7 @@ TEST(RecordAccessor, VertexEdgeConnections) { EXPECT_EQ(v2.in().size(), 1); EXPECT_EQ(v2.out().size(), 0); - for (auto e : v1.out()) - EXPECT_EQ(edge, e); + for (auto e : v1.out()) EXPECT_EQ(edge, e); - for (auto e : v2.in()) - EXPECT_EQ(edge, e); + for (auto e : v2.in()) EXPECT_EQ(edge, e); } diff --git a/tests/unit/rh_hashmap.cpp b/tests/unit/rh_hashmap.cpp index 3dc0c2ad4..dcb07d76d 100644 --- a/tests/unit/rh_hashmap.cpp +++ b/tests/unit/rh_hashmap.cpp @@ -2,150 +2,138 @@ #include "data_structures/map/rh_hashmap.hpp" -class Data -{ +class Data { + private: + size_t data = 0; + int key; -private: - size_t data = 0; - int key; + public: + Data(int key) : key(key) {} -public: - Data(int key) : key(key) {} - - const int &get_key() const { return key; } + const int &get_key() const { return key; } }; void cross_validate(RhHashMap<int, Data> &map, std::map<int, Data *> &s_map); -TEST(RobinHoodHashmap, BasicFunctionality) -{ - RhHashMap<int, Data> map; +TEST(RobinHoodHashmap, BasicFunctionality) { + RhHashMap<int, Data> map; - ASSERT_EQ(map.size(), 0); - ASSERT_EQ(map.insert(new Data(0)), true); - ASSERT_EQ(map.size(), 1); + ASSERT_EQ(map.size(), 0); + ASSERT_EQ(map.insert(new Data(0)), true); + ASSERT_EQ(map.size(), 1); } -TEST(RobinHoodHashmap, RemoveFunctionality) -{ - RhHashMap<int, Data> map; +TEST(RobinHoodHashmap, RemoveFunctionality) { + RhHashMap<int, Data> map; - ASSERT_EQ(map.insert(new Data(0)), true); - ASSERT_EQ(map.remove(0).is_present(), true); - ASSERT_EQ(map.size(), 0); - ASSERT_EQ(!map.find(0).is_present(), true); + ASSERT_EQ(map.insert(new Data(0)), true); + ASSERT_EQ(map.remove(0).is_present(), true); + ASSERT_EQ(map.size(), 0); + ASSERT_EQ(!map.find(0).is_present(), true); } -TEST(RobinHoodHashmap, InsertGetCheck) -{ - RhHashMap<int, Data> map; +TEST(RobinHoodHashmap, InsertGetCheck) { + RhHashMap<int, Data> map; - ASSERT_EQ(!map.find(0).is_present(), true); - auto ptr0 = new Data(0); - ASSERT_EQ(map.insert(ptr0), true); - ASSERT_EQ(map.find(0).is_present(), true); - ASSERT_EQ(map.find(0).get(), ptr0); + ASSERT_EQ(!map.find(0).is_present(), true); + auto ptr0 = new Data(0); + ASSERT_EQ(map.insert(ptr0), true); + ASSERT_EQ(map.find(0).is_present(), true); + ASSERT_EQ(map.find(0).get(), ptr0); } -TEST(RobinHoodHashmap, DoubleInsert) -{ - RhHashMap<int, Data> map; +TEST(RobinHoodHashmap, DoubleInsert) { + RhHashMap<int, Data> map; - ASSERT_EQ(map.insert(new Data(0)), true); - ASSERT_EQ(!map.insert(new Data(0)), true); + ASSERT_EQ(map.insert(new Data(0)), true); + ASSERT_EQ(!map.insert(new Data(0)), true); } -TEST(RobinHoodHashmap, FindInsertFind) -{ - RhHashMap<int, Data> map; +TEST(RobinHoodHashmap, FindInsertFind) { + RhHashMap<int, Data> map; - for (int i = 0; i < 128; i++) { - ASSERT_EQ(!map.find(i).is_present(), true); - ASSERT_EQ(map.insert(new Data(i)), true); - ASSERT_EQ(map.find(i).is_present(), true); + for (int i = 0; i < 128; i++) { + ASSERT_EQ(!map.find(i).is_present(), true); + ASSERT_EQ(map.insert(new Data(i)), true); + ASSERT_EQ(map.find(i).is_present(), true); + } + + for (int i = 0; i < 128; i++) { + ASSERT_EQ(map.find(i).is_present(), true); + ASSERT_EQ(map.find(i).get()->get_key(), i); + } +} + +TEST(RobinHoodHashmap, Iterate) { + RhHashMap<int, Data> map; + + for (int i = 0; i < 128; i++) { + ASSERT_EQ(!map.find(i).is_present(), true); + ASSERT_EQ(map.insert(new Data(i)), true); + ASSERT_EQ(map.find(i).is_present(), true); + } + + bool seen[128] = {false}; + for (auto e : map) { + auto key = e->get_key(); + ASSERT_EQ(!seen[key], true); + seen[key] = true; + } + for (int i = 0; i < 128; i++) { + ASSERT_EQ(seen[i], true); + } +} + +TEST(RobinHoodHashmap, Checked) { + RhHashMap<int, Data> map; + std::map<int, Data *> s_map; + + for (int i = 0; i < 128; i++) { + int key = std::rand(); + auto data = new Data(key); + if (map.insert(data)) { + ASSERT_EQ(s_map.find(key), s_map.end()); + s_map[key] = data; + } else { + ASSERT_NE(s_map.find(key), s_map.end()); } + } - for (int i = 0; i < 128; i++) { - ASSERT_EQ(map.find(i).is_present(), true); - ASSERT_EQ(map.find(i).get()->get_key(), i); - } + cross_validate(map, s_map); } -TEST(RobinHoodHashmap, Iterate) -{ - RhHashMap<int, Data> map; +TEST(RobinHoodHashMap, CheckWithRemove) { + RhHashMap<int, Data> map; + std::map<int, Data *> s_map; - for (int i = 0; i < 128; i++) { - ASSERT_EQ(!map.find(i).is_present(), true); - ASSERT_EQ(map.insert(new Data(i)), true); - ASSERT_EQ(map.find(i).is_present(), true); + for (int i = 0; i < 1280; i++) { + int key = std::rand() % 100; + auto data = new Data(key); + if (map.insert(data)) { + ASSERT_EQ(s_map.find(key), s_map.end()); + s_map[key] = data; + cross_validate(map, s_map); + } else { + ASSERT_EQ(map.remove(key).is_present(), true); + ASSERT_EQ(s_map.erase(key), 1); + cross_validate(map, s_map); } + } - bool seen[128] = {false}; - for (auto e : map) { - auto key = e->get_key(); - ASSERT_EQ(!seen[key], true); - seen[key] = true; - } - for (int i = 0; i < 128; i++) { - ASSERT_EQ(seen[i], true); - } + cross_validate(map, s_map); } -TEST(RobinHoodHashmap, Checked) -{ - RhHashMap<int, Data> map; - std::map<int, Data *> s_map; +void cross_validate(RhHashMap<int, Data> &map, std::map<int, Data *> &s_map) { + for (auto e : map) { + ASSERT_NE(s_map.find(e->get_key()), s_map.end()); + } - for (int i = 0; i < 128; i++) { - int key = std::rand(); - auto data = new Data(key); - if (map.insert(data)) { - ASSERT_EQ(s_map.find(key), s_map.end()); - s_map[key] = data; - } else { - ASSERT_NE(s_map.find(key), s_map.end()); - } - } - - cross_validate(map, s_map); + for (auto e : s_map) { + ASSERT_EQ(map.find(e.first).get(), e.second); + } } -TEST(RobinHoodHashMap, CheckWithRemove) -{ - RhHashMap<int, Data> map; - std::map<int, Data *> s_map; - - for (int i = 0; i < 1280; i++) { - int key = std::rand() % 100; - auto data = new Data(key); - if (map.insert(data)) { - ASSERT_EQ(s_map.find(key), s_map.end()); - s_map[key] = data; - cross_validate(map, s_map); - } else { - ASSERT_EQ(map.remove(key).is_present(), true); - ASSERT_EQ(s_map.erase(key), 1); - cross_validate(map, s_map); - } - } - - cross_validate(map, s_map); -} - -void cross_validate(RhHashMap<int, Data> &map, std::map<int, Data *> &s_map) -{ - for (auto e : map) { - ASSERT_NE(s_map.find(e->get_key()), s_map.end()); - } - - for (auto e : s_map) { - ASSERT_EQ(map.find(e.first).get(), e.second); - } -} - -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/rh_hashmultimap.cpp b/tests/unit/rh_hashmultimap.cpp index 26b720b68..9033294e7 100644 --- a/tests/unit/rh_hashmultimap.cpp +++ b/tests/unit/rh_hashmultimap.cpp @@ -2,17 +2,15 @@ #include "data_structures/map/rh_hashmultimap.hpp" -class Data -{ +class Data { + private: + size_t data = 0; + int key; -private: - size_t data = 0; - int key; + public: + Data(int key) : key(key) {} -public: - Data(int key) : key(key) {} - - const int &get_key() { return key; } + const int &get_key() { return key; } }; void cross_validate(RhHashMultiMap<int, Data> &map, @@ -21,259 +19,245 @@ void cross_validate(RhHashMultiMap<int, Data> &map, void cross_validate_weak(RhHashMultiMap<int, Data> &map, std::multimap<int, Data *> &s_map); -TEST(RobinHoodHashmultimap, BasicFunctionality) -{ - RhHashMultiMap<int, Data> map; +TEST(RobinHoodHashmultimap, BasicFunctionality) { + RhHashMultiMap<int, Data> map; - ASSERT_EQ(map.size(), 0); - map.add(new Data(0)); - ASSERT_EQ(map.size(), 1); + ASSERT_EQ(map.size(), 0); + map.add(new Data(0)); + ASSERT_EQ(map.size(), 1); } -TEST(RobinHoodHashmultimap, InsertGetCheck) -{ - RhHashMultiMap<int, Data> map; +TEST(RobinHoodHashmultimap, InsertGetCheck) { + RhHashMultiMap<int, Data> map; - ASSERT_EQ(map.find(0), map.end()); - auto ptr0 = new Data(0); - map.add(ptr0); - ASSERT_NE(map.find(0), map.end()); - ASSERT_EQ(*map.find(0), ptr0); + ASSERT_EQ(map.find(0), map.end()); + auto ptr0 = new Data(0); + map.add(ptr0); + ASSERT_NE(map.find(0), map.end()); + ASSERT_EQ(*map.find(0), ptr0); } -TEST(RobinHoodHashmultimap, ExtremeSameKeyValusFull) -{ - RhHashMultiMap<int, Data> map; +TEST(RobinHoodHashmultimap, ExtremeSameKeyValusFull) { + RhHashMultiMap<int, Data> map; - for (int i = 0; i < 128; i++) { - map.add(new Data(7)); - } - ASSERT_EQ(map.size(), 128); - ASSERT_NE(map.find(7), map.end()); - ASSERT_EQ(map.find(0), map.end()); - auto ptr0 = new Data(0); - map.add(ptr0); - ASSERT_NE(map.find(0), map.end()); - ASSERT_EQ(*map.find(0), ptr0); + for (int i = 0; i < 128; i++) { + map.add(new Data(7)); + } + ASSERT_EQ(map.size(), 128); + ASSERT_NE(map.find(7), map.end()); + ASSERT_EQ(map.find(0), map.end()); + auto ptr0 = new Data(0); + map.add(ptr0); + ASSERT_NE(map.find(0), map.end()); + ASSERT_EQ(*map.find(0), ptr0); } -TEST(RobinHoodHashmultimap, ExtremeSameKeyValusFullWithRemove) -{ - RhHashMultiMap<int, Data> map; +TEST(RobinHoodHashmultimap, ExtremeSameKeyValusFullWithRemove) { + RhHashMultiMap<int, Data> map; - for (int i = 0; i < 127; i++) { - map.add(new Data(7)); - } - auto ptr = new Data(7); - map.add(ptr); - ASSERT_EQ(map.size(), 128); - ASSERT_EQ(!map.remove(new Data(0)), true); - ASSERT_EQ(map.remove(ptr), true); + for (int i = 0; i < 127; i++) { + map.add(new Data(7)); + } + auto ptr = new Data(7); + map.add(ptr); + ASSERT_EQ(map.size(), 128); + ASSERT_EQ(!map.remove(new Data(0)), true); + ASSERT_EQ(map.remove(ptr), true); } -TEST(RobinHoodHasmultihmap, RemoveFunctionality) -{ - RhHashMultiMap<int, Data> map; +TEST(RobinHoodHasmultihmap, RemoveFunctionality) { + RhHashMultiMap<int, Data> map; - ASSERT_EQ(map.find(0), map.end()); - auto ptr0 = new Data(0); - map.add(ptr0); - ASSERT_NE(map.find(0), map.end()); - ASSERT_EQ(*map.find(0), ptr0); - ASSERT_EQ(map.remove(ptr0), true); - ASSERT_EQ(map.find(0), map.end()); + ASSERT_EQ(map.find(0), map.end()); + auto ptr0 = new Data(0); + map.add(ptr0); + ASSERT_NE(map.find(0), map.end()); + ASSERT_EQ(*map.find(0), ptr0); + ASSERT_EQ(map.remove(ptr0), true); + ASSERT_EQ(map.find(0), map.end()); } -TEST(RobinHoodHashmultimap, DoubleInsert) -{ - RhHashMultiMap<int, Data> map; +TEST(RobinHoodHashmultimap, DoubleInsert) { + RhHashMultiMap<int, Data> map; - auto ptr0 = new Data(0); - auto ptr1 = new Data(0); - map.add(ptr0); - map.add(ptr1); + auto ptr0 = new Data(0); + auto ptr1 = new Data(0); + map.add(ptr0); + map.add(ptr1); - for (auto e : map) { - if (ptr0 == e) { - ptr0 = nullptr; - continue; - } - if (ptr1 == e) { - ptr1 = nullptr; - continue; - } - ASSERT_EQ(true, false); + for (auto e : map) { + if (ptr0 == e) { + ptr0 = nullptr; + continue; } + if (ptr1 == e) { + ptr1 = nullptr; + continue; + } + ASSERT_EQ(true, false); + } } -TEST(RobinHoodHashmultimap, FindAddFind) -{ - RhHashMultiMap<int, Data> map; +TEST(RobinHoodHashmultimap, FindAddFind) { + RhHashMultiMap<int, Data> map; - for (int i = 0; i < 128; i++) { - ASSERT_EQ(map.find(i), map.end()); - map.add(new Data(i)); - ASSERT_NE(map.find(i), map.end()); - } + for (int i = 0; i < 128; i++) { + ASSERT_EQ(map.find(i), map.end()); + map.add(new Data(i)); + ASSERT_NE(map.find(i), map.end()); + } - for (int i = 0; i < 128; i++) { - ASSERT_NE(map.find(i), map.end()); - ASSERT_EQ(map.find(i)->get_key(), i); - } + for (int i = 0; i < 128; i++) { + ASSERT_NE(map.find(i), map.end()); + ASSERT_EQ(map.find(i)->get_key(), i); + } } -TEST(RobinHoodHashmultimap, Iterate) -{ - RhHashMultiMap<int, Data> map; +TEST(RobinHoodHashmultimap, Iterate) { + RhHashMultiMap<int, Data> map; - for (int i = 0; i < 128; i++) { - ASSERT_EQ(map.find(i), map.end()); - map.add(new Data(i)); - ASSERT_NE(map.find(i), map.end()); - } + for (int i = 0; i < 128; i++) { + ASSERT_EQ(map.find(i), map.end()); + map.add(new Data(i)); + ASSERT_NE(map.find(i), map.end()); + } - bool seen[128] = {false}; - for (auto e : map) { - auto key = e->get_key(); - ASSERT_EQ(!seen[key], true); - seen[key] = true; - } - for (int i = 0; i < 128; i++) { - ASSERT_EQ(seen[i], true); - } + bool seen[128] = {false}; + for (auto e : map) { + auto key = e->get_key(); + ASSERT_EQ(!seen[key], true); + seen[key] = true; + } + for (int i = 0; i < 128; i++) { + ASSERT_EQ(seen[i], true); + } } -TEST(RobinHoodHashmultimap, Checked) -{ - RhHashMultiMap<int, Data> map; - std::multimap<int, Data *> s_map; +TEST(RobinHoodHashmultimap, Checked) { + RhHashMultiMap<int, Data> map; + std::multimap<int, Data *> s_map; - for (int i = 0; i < 1638; i++) { - int key = (std::rand() % 100) << 3; + for (int i = 0; i < 1638; i++) { + int key = (std::rand() % 100) << 3; - auto data = new Data(key); - map.add(data); - s_map.insert(std::pair<int, Data *>(key, data)); - } - cross_validate(map, s_map); + auto data = new Data(key); + map.add(data); + s_map.insert(std::pair<int, Data *>(key, data)); + } + cross_validate(map, s_map); } -TEST(RobinHoodHashmultimap, CheckedRand) -{ - RhHashMultiMap<int, Data> map; - std::multimap<int, Data *> s_map; - std::srand(std::time(0)); - for (int i = 0; i < 164308; i++) { - int key = (std::rand() % 10000) << 3; +TEST(RobinHoodHashmultimap, CheckedRand) { + RhHashMultiMap<int, Data> map; + std::multimap<int, Data *> s_map; + std::srand(std::time(0)); + for (int i = 0; i < 164308; i++) { + int key = (std::rand() % 10000) << 3; - auto data = new Data(key); - map.add(data); - s_map.insert(std::pair<int, Data *>(key, data)); - } - cross_validate(map, s_map); + auto data = new Data(key); + map.add(data); + s_map.insert(std::pair<int, Data *>(key, data)); + } + cross_validate(map, s_map); } -TEST(RobinHoodHashmultimap, WithRemoveDataChecked) -{ - RhHashMultiMap<int, Data> map; - std::multimap<int, Data *> s_map; +TEST(RobinHoodHashmultimap, WithRemoveDataChecked) { + RhHashMultiMap<int, Data> map; + std::multimap<int, Data *> s_map; - std::srand(std::time(0)); - for (int i = 0; i < 162638; i++) { - int key = (std::rand() % 10000) << 3; - if ((std::rand() % 2) == 0) { - auto it = s_map.find(key); - if (it == s_map.end()) { - ASSERT_EQ(map.find(key), map.end()); - } else { - s_map.erase(it); - ASSERT_EQ(map.remove(it->second), true); - } - } else { - auto data = new Data(key); - map.add(data); - s_map.insert(std::pair<int, Data *>(key, data)); - } + std::srand(std::time(0)); + for (int i = 0; i < 162638; i++) { + int key = (std::rand() % 10000) << 3; + if ((std::rand() % 2) == 0) { + auto it = s_map.find(key); + if (it == s_map.end()) { + ASSERT_EQ(map.find(key), map.end()); + } else { + s_map.erase(it); + ASSERT_EQ(map.remove(it->second), true); + } + } else { + auto data = new Data(key); + map.add(data); + s_map.insert(std::pair<int, Data *>(key, data)); } + } - cross_validate(map, s_map); + cross_validate(map, s_map); } void cross_validate(RhHashMultiMap<int, Data> &map, - std::multimap<int, Data *> &s_map) -{ + std::multimap<int, Data *> &s_map) { + for (auto e : map) { + auto it = s_map.find(e->get_key()); - for (auto e : map) { - auto it = s_map.find(e->get_key()); - - while (it != s_map.end() && it->second != e) { - it++; - } - ASSERT_NE(it, s_map.end()); + while (it != s_map.end() && it->second != e) { + it++; } + ASSERT_NE(it, s_map.end()); + } - for (auto e : s_map) { - auto it = map.find(e.first); + for (auto e : s_map) { + auto it = map.find(e.first); - while (it != map.end() && *it != e.second) { - it++; - } - ASSERT_NE(it, map.end()); + while (it != map.end() && *it != e.second) { + it++; } + ASSERT_NE(it, map.end()); + } } void cross_validate_weak(RhHashMultiMap<int, Data> &map, - std::multimap<int, Data *> &s_map) -{ - int count = 0; - int key = 0; - for (auto e : map) { - if (e->get_key() == key) { - count++; - } else { - auto it = s_map.find(key); + std::multimap<int, Data *> &s_map) { + int count = 0; + int key = 0; + for (auto e : map) { + if (e->get_key() == key) { + count++; + } else { + auto it = s_map.find(key); - while (it != s_map.end() && it->first == key) { - it++; - count--; - } - ASSERT_EQ(count, 0); - key = e->get_key(); - count = 1; - } + while (it != s_map.end() && it->first == key) { + it++; + count--; + } + ASSERT_EQ(count, 0); + key = e->get_key(); + count = 1; } - { - auto it = s_map.find(key); + } + { + auto it = s_map.find(key); - while (it != s_map.end() && it->first == key) { - it++; - count--; - } - ASSERT_EQ(count, 0); + while (it != s_map.end() && it->first == key) { + it++; + count--; } + ASSERT_EQ(count, 0); + } - for (auto e : s_map) { - if (e.first == key) { - count++; - } else { - auto it = map.find(key); + for (auto e : s_map) { + if (e.first == key) { + count++; + } else { + auto it = map.find(key); - while (it != map.end() && it->get_key() == key) { - it++; - count--; - } - ASSERT_EQ(count, 0); - key = e.first; - count = 1; - } + while (it != map.end() && it->get_key() == key) { + it++; + count--; + } + ASSERT_EQ(count, 0); + key = e.first; + count = 1; } - { - auto it = map.find(key); + } + { + auto it = map.find(key); - while (it != map.end() && it->get_key() == key) { - it++; - count--; - } - ASSERT_EQ(count, 0); + while (it != map.end() && it->get_key() == key) { + it++; + count--; } + ASSERT_EQ(count, 0); + } } diff --git a/tests/unit/signal_handler.cpp b/tests/unit/signal_handler.cpp index 7194557d1..210d61ff2 100644 --- a/tests/unit/signal_handler.cpp +++ b/tests/unit/signal_handler.cpp @@ -7,19 +7,17 @@ #include "utils/signals/handler.hpp" #include "utils/stacktrace/stacktrace.hpp" -TEST(SignalHandler, SegmentationFaultTest) -{ - SignalHandler::register_handler(Signal::SegmentationFault, []() { - std::cout << "Segmentation Fault" << std::endl; - Stacktrace stacktrace; - std::cout << stacktrace.dump() << std::endl; - }); +TEST(SignalHandler, SegmentationFaultTest) { + SignalHandler::register_handler(Signal::SegmentationFault, []() { + std::cout << "Segmentation Fault" << std::endl; + Stacktrace stacktrace; + std::cout << stacktrace.dump() << std::endl; + }); - std::raise(SIGSEGV); + std::raise(SIGSEGV); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/skiplist_reverse_iteration.cpp b/tests/unit/skiplist_reverse_iteration.cpp index 12216f214..cb2173590 100644 --- a/tests/unit/skiplist_reverse_iteration.cpp +++ b/tests/unit/skiplist_reverse_iteration.cpp @@ -16,7 +16,7 @@ #include "gtest/gtest.h" #include "data_structures/concurrent/skiplist.hpp" -#include "logging/default.cpp" +#include "logging/default.cpp" #include "utils/random/generator.h" using utils::random::NumberGenerator; @@ -350,7 +350,6 @@ TEST(SkipListReverseIteratorTest, RandomIteratorsElementLowerThanFirst) { ASSERT_EQ(rend, rbegin); } - /* Tests Skiplist ReverseIterator when concurrently inserting an element while iterating. The inserted element should also be traversed. @@ -360,12 +359,12 @@ TEST(SkipListReverseIteratorTest, InsertWhileIteratingTest) { auto accessor = skiplist.access(); int number_of_elements = 1024 * 16; - for (int i = 1; i < number_of_elements; i+=2) accessor.insert(std::move(i)); + for (int i = 1; i < number_of_elements; i += 2) accessor.insert(std::move(i)); auto rbegin = accessor.rbegin(); auto rend = accessor.rend(); - for (int i = 0; i < number_of_elements; i+=2) accessor.insert(std::move(i)); + for (int i = 0; i < number_of_elements; i += 2) accessor.insert(std::move(i)); int element = number_of_elements - 1; while (rbegin != rend) { @@ -375,7 +374,6 @@ TEST(SkipListReverseIteratorTest, InsertWhileIteratingTest) { } } - /* Tests Skiplist ReverseIterator when concurrently deleting an element while iterating. The deleted element shouldn't be traversed except if the element @@ -397,7 +395,7 @@ TEST(SkipListReverseIteratorTest, DeleteWhileIteratingTest) { ASSERT_EQ(element, *rbegin); // delete elements - for (int i = 0; i < number_of_elements; i+=2) accessor.remove(i); + for (int i = 0; i < number_of_elements; i += 2) accessor.remove(i); // check if still points to the same after delete ASSERT_EQ(element, *rbegin); @@ -405,15 +403,15 @@ TEST(SkipListReverseIteratorTest, DeleteWhileIteratingTest) { // check all deleted elements after while (rbegin != rend && element > 0) { - ASSERT_EQ(element-1, *rbegin); + ASSERT_EQ(element - 1, *rbegin); rbegin++; - element-=2; + element -= 2; } } int main(int argc, char** argv) { - logging::init_sync(); - logging::log->pipe(std::make_unique<Stdout>()); + logging::init_sync(); + logging::log->pipe(std::make_unique<Stdout>()); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/tests/unit/skiplistset.cpp b/tests/unit/skiplistset.cpp index 58fdbd8ab..a3f43aac0 100644 --- a/tests/unit/skiplistset.cpp +++ b/tests/unit/skiplistset.cpp @@ -7,52 +7,48 @@ using std::cout; using std::endl; -void print_skiplist(const ConcurrentSet<int>::Accessor &skiplist) -{ - cout << "---- skiplist set now has: "; +void print_skiplist(const ConcurrentSet<int>::Accessor &skiplist) { + cout << "---- skiplist set now has: "; - for (auto &item : skiplist) - cout << item << ", "; + for (auto &item : skiplist) cout << item << ", "; - cout << "----" << endl; + cout << "----" << endl; } -int main(void) -{ - logging::init_async(); - logging::log->pipe(std::make_unique<Stdout>()); +int main(void) { + logging::init_async(); + logging::log->pipe(std::make_unique<Stdout>()); - ConcurrentSet<int> set; - auto accessor = set.access(); + ConcurrentSet<int> set; + auto accessor = set.access(); - cout << std::boolalpha; + cout << std::boolalpha; - cout << "added non-existing 1? (true) " << accessor.insert(1).second - << endl; + cout << "added non-existing 1? (true) " << accessor.insert(1).second << endl; - cout << "added already existing 1? (false) " << accessor.insert(1).second - << endl; + cout << "added already existing 1? (false) " << accessor.insert(1).second + << endl; - accessor.insert(2); - print_skiplist(accessor); + accessor.insert(2); + print_skiplist(accessor); - cout << "item 3 doesn't exist? (true) " - << (accessor.find(3) == accessor.end()) << endl; + cout << "item 3 doesn't exist? (true) " + << (accessor.find(3) == accessor.end()) << endl; - cout << "item 3 exists? (false) " << accessor.contains(3) << endl; + cout << "item 3 exists? (false) " << accessor.contains(3) << endl; - cout << "item 2 exists? (true) " << (accessor.find(2) != accessor.end()) - << endl; + cout << "item 2 exists? (true) " << (accessor.find(2) != accessor.end()) + << endl; - cout << "at item 2 is? 2 " << *accessor.find(2) << endl; + cout << "at item 2 is? 2 " << *accessor.find(2) << endl; - cout << "removed existing 1? (true) " << accessor.remove(1) << endl; - cout << "removed non-existing 3? (false) " << accessor.remove(3) << endl; + cout << "removed existing 1? (true) " << accessor.remove(1) << endl; + cout << "removed non-existing 3? (false) " << accessor.remove(3) << endl; - accessor.insert(1); - accessor.insert(4); + accessor.insert(1); + accessor.insert(4); - print_skiplist(accessor); + print_skiplist(accessor); - return 0; + return 0; } diff --git a/tests/unit/stack_allocator.cpp b/tests/unit/stack_allocator.cpp index ac84fccb0..8427e1404 100644 --- a/tests/unit/stack_allocator.cpp +++ b/tests/unit/stack_allocator.cpp @@ -2,33 +2,28 @@ #include "utils/memory/stack_allocator.hpp" -struct Object -{ - int a; - int b; +struct Object { + int a; + int b; - Object(int a, int b) : a(a), b(b) {} + Object(int a, int b) : a(a), b(b) {} }; -TEST(StackAllocatorTest, AllocationAndObjectValidity) -{ - StackAllocator allocator; - for (int i = 0; i < 64 * 1024; ++i) - { - auto object = allocator.make<Object>(1, 2); - ASSERT_EQ(object->a, 1); - ASSERT_EQ(object->b, 2); - } +TEST(StackAllocatorTest, AllocationAndObjectValidity) { + StackAllocator allocator; + for (int i = 0; i < 64 * 1024; ++i) { + auto object = allocator.make<Object>(1, 2); + ASSERT_EQ(object->a, 1); + ASSERT_EQ(object->b, 2); + } } -TEST(StackAllocatorTest, CountMallocAndFreeCalls) -{ - // TODO: implementation - EXPECT_EQ(true, true); +TEST(StackAllocatorTest, CountMallocAndFreeCalls) { + // TODO: implementation + EXPECT_EQ(true, true); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/template_engine.cpp b/tests/unit/template_engine.cpp index c33622576..25bbbe3d2 100644 --- a/tests/unit/template_engine.cpp +++ b/tests/unit/template_engine.cpp @@ -2,16 +2,14 @@ #include "template_engine/engine.hpp" -TEST(TemplateEngine, BasicPlaceholderReplacement) -{ - auto rendered = template_engine::render("{{one}} {{two}}", - {{"one", "two"}, {"two", "one"}}); +TEST(TemplateEngine, BasicPlaceholderReplacement) { + auto rendered = template_engine::render("{{one}} {{two}}", + {{"one", "two"}, {"two", "one"}}); - ASSERT_EQ(rendered, "two one"); + ASSERT_EQ(rendered, "two one"); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/typed_value.cpp b/tests/unit/typed_value.cpp index 5a7d6cb2d..5bb8a905b 100644 --- a/tests/unit/typed_value.cpp +++ b/tests/unit/typed_value.cpp @@ -2,8 +2,8 @@ // Copyright 2017 Memgraph // Created by Florijan Stamenkovic on 24.01.17.. // -#include <vector> #include <functional> +#include <vector> #include "gtest/gtest.h" @@ -27,15 +27,15 @@ void EXPECT_PROP_TRUE(const TypedValue& a) { EXPECT_TRUE(a.type_ == TypedValue::Type::Bool && a.Value<bool>()); } -void EXPECT_PROP_EQ(const TypedValue& a, const TypedValue& b) { +void EXPECT_PROP_EQ(const TypedValue& a, const TypedValue& b) { EXPECT_PROP_TRUE(a == b); } -void EXPECT_PROP_ISNULL(const TypedValue& a) { +void EXPECT_PROP_ISNULL(const TypedValue& a) { EXPECT_TRUE(a.type_ == TypedValue::Type::Null); } -void EXPECT_PROP_NE(const TypedValue& a, const TypedValue& b) { +void EXPECT_PROP_NE(const TypedValue& a, const TypedValue& b) { EXPECT_PROP_TRUE(a != b); } @@ -45,7 +45,8 @@ TEST(TypedValue, CreationTypes) { EXPECT_TRUE(TypedValue(true).type_ == TypedValue::Type::Bool); EXPECT_TRUE(TypedValue(false).type_ == TypedValue::Type::Bool); - EXPECT_TRUE(TypedValue(std::string("form string class")).type_ == TypedValue::Type::String); + EXPECT_TRUE(TypedValue(std::string("form string class")).type_ == + TypedValue::Type::String); EXPECT_TRUE(TypedValue("form c-string").type_ == TypedValue::Type::String); EXPECT_TRUE(TypedValue(0).type_ == TypedValue::Type::Int); @@ -89,18 +90,17 @@ TEST(TypedValue, Less) { // not_bool_type < bool -> exception TypedValueStore<> props = MakePropsAllTypes(); for (int i = 0; i < props.size() + 1; ++i) { - if (props.at(i).type_ == TypedValue::Type::Bool) - continue; + if (props.at(i).type_ == TypedValue::Type::Bool) continue; // the comparison should raise an exception - // cast to (void) so the compiler does not complain about unused comparison result + // cast to (void) so the compiler does not complain about unused comparison + // result EXPECT_THROW((void)(props.at(i) < TypedValue(true)), TypedValueException); } // not_bool_type < Null = Null props = MakePropsAllTypes(); for (int i = 0; i < props.size() + 1; ++i) { - if (props.at(i).type_ == TypedValue::Type::Bool) - continue; + if (props.at(i).type_ == TypedValue::Type::Bool) continue; EXPECT_PROP_ISNULL(props.at(i) < TypedValue::Null); } @@ -144,7 +144,6 @@ TEST(TypedValue, UnaryMinus) { EXPECT_THROW(-TypedValue("something"), TypedValueException); } - /** * Performs a series of tests on properties of all types. The tests * evaluate how arithmetic operators behave w.r.t. exception throwing @@ -155,7 +154,9 @@ TEST(TypedValue, UnaryMinus) { * @param op The operation lambda. Takes two values and resturns * the results. */ -void ExpectArithmeticThrowsAndNull(bool string_ok, std::function<TypedValue(const TypedValue&, const TypedValue&)> op) { +void ExpectArithmeticThrowsAndNull( + bool string_ok, + std::function<TypedValue(const TypedValue&, const TypedValue&)> op) { // arithmetic ops that raise TypedValueStore<> props = MakePropsAllTypes(); for (int i = 0; i < props.size() + 1; ++i) { @@ -170,10 +171,8 @@ void ExpectArithmeticThrowsAndNull(bool string_ok, std::function<TypedValue(cons // null resulting ops props = MakePropsAllTypes(); for (int i = 0; i < props.size() + 1; ++i) { - if (props.at(i).type_ == TypedValue::Type::Bool) - continue; - if (!string_ok && props.at(i).type_ == TypedValue::Type::String) - continue; + if (props.at(i).type_ == TypedValue::Type::Bool) continue; + if (!string_ok && props.at(i).type_ == TypedValue::Type::String) continue; EXPECT_PROP_ISNULL(op(props.at(i), TypedValue::Null)); EXPECT_PROP_ISNULL(op(TypedValue::Null, props.at(i))); @@ -181,22 +180,27 @@ void ExpectArithmeticThrowsAndNull(bool string_ok, std::function<TypedValue(cons } TEST(TypedValue, Sum) { - ExpectArithmeticThrowsAndNull(true, [](const TypedValue &a, const TypedValue& b) { return a + b; }); + ExpectArithmeticThrowsAndNull( + true, [](const TypedValue& a, const TypedValue& b) { return a + b; }); // sum of props of the same type EXPECT_EQ((TypedValue(2) + TypedValue(3)).Value<int>(), 5); EXPECT_FLOAT_EQ((TypedValue(2.5f) + TypedValue(1.25f)).Value<float>(), 3.75); - EXPECT_EQ((TypedValue("one") + TypedValue("two")).Value<std::string>(), "onetwo"); + EXPECT_EQ((TypedValue("one") + TypedValue("two")).Value<std::string>(), + "onetwo"); // sum of string and numbers EXPECT_EQ((TypedValue("one") + TypedValue(1)).Value<std::string>(), "one1"); EXPECT_EQ((TypedValue(1) + TypedValue("one")).Value<std::string>(), "1one"); - EXPECT_EQ((TypedValue("one") + TypedValue(3.2f)).Value<std::string>(), "one3.2"); - EXPECT_EQ((TypedValue(3.2f) + TypedValue("one")).Value<std::string>(), "3.2one"); + EXPECT_EQ((TypedValue("one") + TypedValue(3.2f)).Value<std::string>(), + "one3.2"); + EXPECT_EQ((TypedValue(3.2f) + TypedValue("one")).Value<std::string>(), + "3.2one"); } TEST(TypedValue, Difference) { - ExpectArithmeticThrowsAndNull(false, [](const TypedValue &a, const TypedValue& b) { return a - b; }); + ExpectArithmeticThrowsAndNull( + false, [](const TypedValue& a, const TypedValue& b) { return a - b; }); // difference of props of the same type EXPECT_EQ((TypedValue(2) - TypedValue(3)).Value<int>(), -1); @@ -208,7 +212,8 @@ TEST(TypedValue, Difference) { } TEST(TypedValue, Divison) { - ExpectArithmeticThrowsAndNull(false, [](const TypedValue &a, const TypedValue& b) { return a / b; }); + ExpectArithmeticThrowsAndNull( + false, [](const TypedValue& a, const TypedValue& b) { return a / b; }); EXPECT_PROP_EQ(TypedValue(10) / TypedValue(2), TypedValue(5)); EXPECT_PROP_EQ(TypedValue(10) / TypedValue(4), TypedValue(2)); @@ -221,22 +226,28 @@ TEST(TypedValue, Divison) { } TEST(TypedValue, Multiplication) { - ExpectArithmeticThrowsAndNull(false, [](const TypedValue &a, const TypedValue& b) { return a * b; }); + ExpectArithmeticThrowsAndNull( + false, [](const TypedValue& a, const TypedValue& b) { return a * b; }); EXPECT_PROP_EQ(TypedValue(10) * TypedValue(2), TypedValue(20)); - EXPECT_FLOAT_EQ((TypedValue(12.5f) * TypedValue(6.6f)).Value<float>(), 12.5f * 6.6f); - EXPECT_FLOAT_EQ((TypedValue(10) * TypedValue(4.5f)).Value<float>(), 10 * 4.5f); - EXPECT_FLOAT_EQ((TypedValue(10.2f) * TypedValue(4)).Value<float>(), 10.2f * 4); + EXPECT_FLOAT_EQ((TypedValue(12.5f) * TypedValue(6.6f)).Value<float>(), + 12.5f * 6.6f); + EXPECT_FLOAT_EQ((TypedValue(10) * TypedValue(4.5f)).Value<float>(), + 10 * 4.5f); + EXPECT_FLOAT_EQ((TypedValue(10.2f) * TypedValue(4)).Value<float>(), + 10.2f * 4); } TEST(TypedValue, Modulo) { - ExpectArithmeticThrowsAndNull(false, [](const TypedValue &a, const TypedValue& b) { return a % b; }); + ExpectArithmeticThrowsAndNull( + false, [](const TypedValue& a, const TypedValue& b) { return a % b; }); EXPECT_PROP_EQ(TypedValue(10) % TypedValue(2), TypedValue(0)); EXPECT_PROP_EQ(TypedValue(10) % TypedValue(4), TypedValue(2)); EXPECT_PROP_EQ(TypedValue(10.0f) % TypedValue(2.0f), TypedValue(0.0f)); - EXPECT_FLOAT_EQ((TypedValue(10.0f) % TypedValue(3.25f)).Value<float>(), 0.25f); + EXPECT_FLOAT_EQ((TypedValue(10.0f) % TypedValue(3.25f)).Value<float>(), + 0.25f); EXPECT_FLOAT_EQ((TypedValue(10) % TypedValue(4.0f)).Value<float>(), 2.0f); EXPECT_FLOAT_EQ((TypedValue(10.0f) % TypedValue(4)).Value<float>(), 2.0f); @@ -250,7 +261,7 @@ TEST(TypedValue, TypeIncompatibility) { // the others for (int i = 0; i < props.size() + 1; ++i) for (int j = 0; j < props.size() + 1; ++j) - EXPECT_EQ(props.at(i).type_== props.at(j).type_, i == j); + EXPECT_EQ(props.at(i).type_ == props.at(j).type_, i == j); } /** @@ -261,17 +272,19 @@ TEST(TypedValue, TypeIncompatibility) { * * @param op The logical operation to test. */ -void TestLogicalThrows(std::function<TypedValue(const TypedValue&, const TypedValue&)> op) { +void TestLogicalThrows( + std::function<TypedValue(const TypedValue&, const TypedValue&)> op) { TypedValueStore<> props = MakePropsAllTypes(); for (int i = 0; i < props.size() + 1; ++i) { auto p1 = props.at(i); for (int j = 0; j < props.size() + 1; ++j) { auto p2 = props.at(j); // skip situations when both p1 and p2 are either bool or null - auto p1_ok = p1.type_ == TypedValue::Type::Bool || p1.type_ == TypedValue::Type::Null; - auto p2_ok = p2.type_ == TypedValue::Type::Bool || p2.type_ == TypedValue::Type::Null; - if (p1_ok && p2_ok) - continue; + auto p1_ok = p1.type_ == TypedValue::Type::Bool || + p1.type_ == TypedValue::Type::Null; + auto p2_ok = p2.type_ == TypedValue::Type::Bool || + p2.type_ == TypedValue::Type::Null; + if (p1_ok && p2_ok) continue; EXPECT_THROW(op(p1, p2), TypedValueException); } @@ -279,14 +292,16 @@ void TestLogicalThrows(std::function<TypedValue(const TypedValue&, const TypedVa } TEST(TypedValue, LogicalAnd) { - TestLogicalThrows([](const TypedValue& p1, const TypedValue& p2) {return p1 && p2;}); + TestLogicalThrows( + [](const TypedValue& p1, const TypedValue& p2) { return p1 && p2; }); EXPECT_PROP_ISNULL(TypedValue::Null && TypedValue(true)); EXPECT_PROP_EQ(TypedValue(true) && TypedValue(true), TypedValue(true)); EXPECT_PROP_EQ(TypedValue(false) && TypedValue(true), TypedValue(false)); } TEST(TypedValue, LogicalOr) { - TestLogicalThrows([](const TypedValue& p1, const TypedValue& p2) {return p1 || p2;}); + TestLogicalThrows( + [](const TypedValue& p1, const TypedValue& p2) { return p1 || p2; }); EXPECT_PROP_ISNULL(TypedValue::Null && TypedValue(true)); EXPECT_PROP_EQ(TypedValue(true) || TypedValue(true), TypedValue(true)); EXPECT_PROP_EQ(TypedValue(false) || TypedValue(true), TypedValue(true)); diff --git a/tests/unit/typed_value_store.cpp b/tests/unit/typed_value_store.cpp index 337b73496..12fe0bded 100644 --- a/tests/unit/typed_value_store.cpp +++ b/tests/unit/typed_value_store.cpp @@ -11,7 +11,6 @@ using std::string; TEST(TypedValueStore, At) { - std::string some_string = "something"; TypedValueStore<> props; @@ -63,7 +62,6 @@ TEST(TypedValueStore, Replace) { } TEST(TypedValueStore, Size) { - TypedValueStore<> props; EXPECT_EQ(props.size(), 0); @@ -74,8 +72,7 @@ TEST(TypedValueStore, Size) { props.set(1, true); EXPECT_EQ(props.size(), 2); - for (int i = 0; i < 100; ++i) - props.set(i + 20, true); + for (int i = 0; i < 100; ++i) props.set(i + 20, true); EXPECT_EQ(props.size(), 102); props.erase(0); @@ -87,16 +84,13 @@ TEST(TypedValueStore, Size) { } TEST(TypedValueStore, Accept) { - int count_props = 0; int count_finish = 0; auto handler = [&](const uint32_t key, const TypedValue& prop) { count_props += 1; }; - auto finish = [&]() { - count_finish += 1; - }; + auto finish = [&]() { count_finish += 1; }; TypedValueStore<uint32_t> props; props.Accept(handler, finish); diff --git a/tests/unit/union_find.cpp b/tests/unit/union_find.cpp index 8f68d36ea..aefbe01a7 100644 --- a/tests/unit/union_find.cpp +++ b/tests/unit/union_find.cpp @@ -5,84 +5,76 @@ #include "data_structures/union_find/union_find.hpp" +void _expect_fully(UnionFind<> &uf, bool connected, int from = 0, int to = -1) { + if (to == -1) to = uf.size(); -void _expect_fully(UnionFind<> &uf, bool connected, int from=0, int to=-1) { - - if (to == -1) - to = uf.size(); - - for (int i = from ; i < to ; i++) - for (int j = from ; j < to ; j++) - if (i != j) - EXPECT_EQ(uf.find(i, j), connected); + for (int i = from; i < to; i++) + for (int j = from; j < to; j++) + if (i != j) EXPECT_EQ(uf.find(i, j), connected); } TEST(UnionFindTest, InitialSizeTest) { - for (int i = 0 ; i < 10 ; i ++) { - UnionFind<> uf(i); - EXPECT_EQ(i, uf.size()); - } + for (int i = 0; i < 10; i++) { + UnionFind<> uf(i); + EXPECT_EQ(i, uf.size()); + } } TEST(UnionFindTest, ModifiedSizeTest) { - UnionFind<> uf(10); - EXPECT_EQ(10, uf.size()); + UnionFind<> uf(10); + EXPECT_EQ(10, uf.size()); - uf.connect(0, 0); - EXPECT_EQ(10, uf.size()); + uf.connect(0, 0); + EXPECT_EQ(10, uf.size()); - uf.connect(0, 1); - EXPECT_EQ(9, uf.size()); + uf.connect(0, 1); + EXPECT_EQ(9, uf.size()); - uf.connect(2, 3); - EXPECT_EQ(8, uf.size()); + uf.connect(2, 3); + EXPECT_EQ(8, uf.size()); - uf.connect(0, 2); - EXPECT_EQ(7, uf.size()); + uf.connect(0, 2); + EXPECT_EQ(7, uf.size()); - uf.connect(1, 3); - EXPECT_EQ(7, uf.size()); + uf.connect(1, 3); + EXPECT_EQ(7, uf.size()); } - TEST(UnionFindTest, Disconectivity) { - UnionFind<> uf(10); - _expect_fully(uf, false); + UnionFind<> uf(10); + _expect_fully(uf, false); } TEST(UnionFindTest, ConnectivityAlongChain) { - UnionFind<> uf(10); - for (unsigned int i = 1 ; i < uf.size() ; i++) - uf.connect(i - 1, i); - _expect_fully(uf, true); + UnionFind<> uf(10); + for (unsigned int i = 1; i < uf.size(); i++) uf.connect(i - 1, i); + _expect_fully(uf, true); } TEST(UnionFindTest, ConnectivityOnTree) { - UnionFind<> uf(10); - _expect_fully(uf, false); - - uf.connect(0, 1); - uf.connect(0, 2); - _expect_fully(uf, true, 0, 3); - _expect_fully(uf, false, 2); + UnionFind<> uf(10); + _expect_fully(uf, false); - uf.connect(2, 3); - _expect_fully(uf, true, 0, 4); - _expect_fully(uf, false, 3); + uf.connect(0, 1); + uf.connect(0, 2); + _expect_fully(uf, true, 0, 3); + _expect_fully(uf, false, 2); + + uf.connect(2, 3); + _expect_fully(uf, true, 0, 4); + _expect_fully(uf, false, 3); } TEST(UnionFindTest, DisjointChains) { - UnionFind<> uf(30); - for (int i = 0 ; i < 30 ; i++) - uf.connect(i, i % 10 == 0 ? i : i - 1); + UnionFind<> uf(30); + for (int i = 0; i < 30; i++) uf.connect(i, i % 10 == 0 ? i : i - 1); - for (int i = 0 ; i < 30 ; i++) - for (int j = 0 ; j < 30 ; j++) - EXPECT_EQ(uf.find(i, j), (j - (j % 10)) == (i - (i % 10))); + for (int i = 0; i < 30; i++) + for (int j = 0; j < 30; j++) + EXPECT_EQ(uf.find(i, j), (j - (j % 10)) == (i - (i % 10))); } -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tests/unit/unique_object_store.cpp b/tests/unit/unique_object_store.cpp index 79a35d74b..d7890d283 100644 --- a/tests/unit/unique_object_store.cpp +++ b/tests/unit/unique_object_store.cpp @@ -1,20 +1,18 @@ #include <stdlib.h> -#include <iostream> #include <cstdlib> +#include <iostream> #include "gtest/gtest.h" -#include "utils/total_ordering.hpp" #include "storage/unique_object_store.hpp" +#include "utils/total_ordering.hpp" /** * Wraps an int and implements total ordering. Used for testing the * UniqueObjectStore with custom classes. */ -class IntWrapper : TotalOrdering<IntWrapper>, TotalOrdering<IntWrapper, int> -{ - -public: +class IntWrapper : TotalOrdering<IntWrapper>, TotalOrdering<IntWrapper, int> { + public: IntWrapper(const int i) : i_(i) {} friend bool operator==(const IntWrapper &lhs, const IntWrapper &rhs) { @@ -25,13 +23,11 @@ public: return lhs.i_ < rhs.i_; } -private: + private: const int i_; }; - TEST(UniqueObjectStoreTest, GetKey) { - UniqueObjectStore<std::string> store; EXPECT_EQ(store.GetKey("name1"), store.GetKey("name1")); EXPECT_NE(store.GetKey("name1"), store.GetKey("name2")); @@ -39,7 +35,6 @@ TEST(UniqueObjectStoreTest, GetKey) { } TEST(UniqueObjectStoreTest, CustomClass) { - UniqueObjectStore<IntWrapper> store; EXPECT_EQ(store.GetKey(42), store.GetKey(IntWrapper(42))); EXPECT_EQ(store.GetKey(1000), store.GetKey(IntWrapper(1000))); @@ -47,17 +42,15 @@ TEST(UniqueObjectStoreTest, CustomClass) { } TEST(UniqueObjectStoreTest, RandomAccess) { - UniqueObjectStore<int> store; - for (int i = 0 ; i < 50 * 50 * 4 ; i++) { + for (int i = 0; i < 50 * 50 * 4; i++) { int rand1 = rand() % 50; int rand2 = rand() % 50; EXPECT_EQ(store.GetKey(rand1) == store.GetKey(rand2), rand1 == rand2); } } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }