Compare commits

..

274 Commits

Author SHA1 Message Date
jeremy
82957ef727 Impl of Scan with filters (unfinished) 2022-09-23 09:52:48 +02:00
jeremy
93460f0fee Merge branch 'T1010-MG-implement-query-engine-client' into add_distributed_unwind 2022-09-22 14:27:17 +02:00
Jeremy B
440571f721 Merge branch 'project-pineapples' into T1010-MG-implement-query-engine-client 2022-09-22 14:24:28 +02:00
jeremy
87b5c55c14 Implement DistributedUnwindCursor 2022-09-22 14:11:37 +02:00
jbajic
6d89a15956 Fix storage_v3_expr 2022-09-22 14:09:36 +02:00
kostas kyrimis
3fa3f06581 Merge branch 'project-pineapples' into T1010-MG-implement-query-engine-client 2022-09-21 18:22:07 +00:00
kostas kyrimis
8d4c246d8f Address comments 2022-09-21 15:12:52 +00:00
kostas kyrimis
7ea0df2731 Make clang-tidy happy 2022-09-21 13:23:14 +00:00
gvolfing
b541548d49 Fix failing shard_rsm test 2022-09-21 15:01:37 +02:00
kostas kyrimis
f89af77be9 Merge branch 'E118-MG-lexicographically-ordered-storage' into T1010-MG-implement-query-engine-client 2022-09-21 11:35:30 +00:00
kostas kyrimis
834c80091e Remove unnecessary output on shard request manager test 2022-09-20 09:41:57 +00:00
kostas kyrimis
018800f01e Revert accidental changes on query/reequired_priviledges 2022-09-20 07:47:00 +00:00
kostas kyrimis
ba8cd4b492 Add dummy test to generate lisp deps so clang-tidy can work 2022-09-19 15:08:02 +00:00
kostas kyrimis
9c9d0343a9 Fix clang-tidy warnings 2022-09-19 13:55:25 +00:00
kostas kyrimis
708e745410 Clean up commented out code 2022-09-19 09:43:01 +00:00
Kostas Kyrimis
632f0398b5 Add missing glue code on DistributedCreateVertices 2022-09-14 15:12:16 +03:00
Kostas Kyrimis
c182cf8384 Added prototype for distributed ScanAll and CreateVertices cursors.
Changed ScanAll request return type to be friendlier for use.
2022-09-12 16:54:35 +03:00
Kostas Kyrimis
b5f8060c1f Integrated new accessors with TypedValue and temporary disabled
procedures, streams, triggers. Additionally, small changes to
ExpressionEvaluator and commented out parts of the operators that
used old accessors
2022-09-09 20:56:24 +03:00
Kostas Kyrimis
ced3b7db06 ExpandOne prototype 2022-09-09 12:48:04 +03:00
Kostas Kyrimis
e078947d10 Comment out query engine tests temporarily because of the new TypedValue 2022-09-08 19:57:48 +03:00
Kostas Kyrimis
2eaad15804 Added TypedValue with new accessors and simplified requests 2022-09-08 19:56:48 +03:00
Kostas Kyrimis
002e08b4f8 Merge branch 'project-pineapples' into T1010-MG-implement-query-engine-client 2022-09-07 18:17:46 +03:00
Kostas Kyrimis
e7d9ab1c5f Added accessors prototype, and ExpandOne request boilerplate 2022-09-07 17:36:49 +03:00
Kostas Kyrimis
a2b04db23c Rename Middleware to ShardRequestManager 2022-09-06 13:12:48 +03:00
Kostas Kyrimis
5fa4e8c33a Merge project-pineapples 2022-09-06 13:05:48 +03:00
Kostas Kyrimis
57836f7c2b Added CreateVertices request test and polished 2022-09-05 22:28:15 +03:00
Kostas Kyrimis
c8bc4c7dbc Added Request ScanVertices on RequestClientManager and polished 2022-09-05 21:13:12 +03:00
Kostas Kyrimis
e442bf435a Add abstract interface to Middleware and rename it. Cleaned up member function implementation and tests 2022-09-05 15:46:03 +03:00
Kostas Kyrimis
ba06d29a35 Added ScanAll prototype 2022-09-05 10:02:21 +03:00
Kostas Kyrimis
1a2f138e09 middleware prototype 2022-09-02 16:50:48 +03:00
Tyler Neely
445cd2d206 Rename StorageClient in the tests to ShardClient to be consistent with ShardRsm 2022-08-31 14:42:57 +00:00
Tyler Neely
0fd448b300 Rename StorageRsm to ShardRsm 2022-08-31 14:40:53 +00:00
Tyler Neely
af4f3a5cb5 Add ShardMap::GetPropertyId 2022-08-31 14:24:20 +00:00
Tyler Neely
27459a9eb0 Add AllocatePropertyIds request/response pair for Coordinator + ShardMap 2022-08-31 14:22:40 +00:00
Tyler Neely
61b1fbfbc9 A number of clean-ups related to the coordinator and its tests 2022-08-30 15:14:28 +00:00
Tyler Neely
025df32d9e Small simplifications around compound keys 2022-08-30 14:19:50 +00:00
Tyler Neely
ab6585f19e Small clean-up of some TODOs and implementation of GetShardsForRange 2022-08-30 13:50:24 +00:00
Tyler Neely
f96133e0b9 Merge branch 'project-pineapples' of github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-08-30 13:00:35 +00:00
Tyler Neely
2a395a18b0 Merge branch 'T0941-MG-implement-basic-raft-version' of github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-08-30 08:38:14 +00:00
Tyler Neely
910c484c76 Simplify simulator code around reasoning about blocked participants 2022-08-30 08:22:54 +00:00
Tyler Neely
13787a0b17 Do not count clients waiting on promises as blocking when calculating quiescent counts in the simulator 2022-08-30 08:19:04 +00:00
Tyler Neely
46afb25415 use static cast for micros 2022-08-30 07:53:45 +00:00
Tyler Neely
62bb9a399a Revert incorrect code suggestion 2022-08-30 07:51:36 +00:00
Tyler Neely
ec95cd31ed Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-30 09:12:54 +02:00
Tyler Neely
c0bbfc4f0e Address clang-tidy feedback 2022-08-29 15:42:19 +00:00
Tyler Neely
d50a6ab232 Properly use Follower's next_index for sending batches instead of the known committed_log_size 2022-08-29 14:13:40 +00:00
Tyler Neely
28fae9e6d0 Assert that terms in the log are monotonic 2022-08-29 14:01:30 +00:00
Tyler Neely
b7e54cbe44 Assert that terms in the log are monotonic 2022-08-29 14:00:29 +00:00
Tyler Neely
a410864855 Improve constness in several method bodies 2022-08-29 13:43:27 +00:00
Tyler Neely
325aae34d2 Optimize Cron calling order 2022-08-29 13:32:16 +00:00
Tyler Neely
8657909ef3 Simplify Handle(Leader, AppendResponse...) 2022-08-29 13:30:01 +00:00
Tyler Neely
726c42a3fc Use std::make_move_iterator for adding entries from AppendRequest into a Follower's Raft log 2022-08-29 13:24:34 +00:00
Tyler Neely
e67eefb1a3 Use a concept to lock-down certain Handle methods for Raft 2022-08-29 12:00:53 +00:00
Tyler Neely
cb33a0a0c6 Merge branch 'project-pineapples' of github.com:memgraph/memgraph into T0941-MG-implement-basic-raft-version 2022-08-29 11:35:24 +00:00
Tyler Neely
f6e41bd0f5 Make Raft index tracking less bug-prone by focusing on "log size" which gracefully initializes to 0 instead of 1-indexed log index tracking which does not cleanly initialize as intuitively 2022-08-29 09:18:25 +00:00
Tyler Neely
10f8af4681 Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-24 18:23:17 +02:00
Tyler Neely
87e9897c94 Use extracted constants for various timeout durations 2022-08-24 16:10:36 +00:00
Tyler Neely
34c3d94163 Fix and clarify comment 2022-08-24 16:01:19 +00:00
Tyler Neely
12c55d5d0b Remove several cases of unnecessary 'auto &&' 2022-08-24 15:58:46 +00:00
Tyler Neely
0d1616a5e0 Use Duration instead of std::chrono::microseconds which it aliases to 2022-08-24 15:55:10 +00:00
Tyler Neely
0be36a5805 Remove unnecessary aliases 2022-08-24 15:53:22 +00:00
Tyler Neely
8cea2937b8 Apply some feedback from clang-tidy 2022-08-24 15:00:52 +00:00
Tyler Neely
0b7f195f4b Remove unused include 2022-08-23 11:35:40 +00:00
Tyler Neely
409fe692d9 Check-in CoordinatorClient 2022-08-23 11:34:18 +00:00
Tyler Neely
7d1318b4d7 Clean up some rsm client and coordinator code 2022-08-19 15:17:33 +00:00
Tyler Neely
d42fa1fc87 Fix ShardMap::GetShardForKey 2022-08-18 15:14:04 +00:00
Tyler Neely
2a3a3338f0 Clean up coordinator a bit 2022-08-18 14:04:28 +00:00
Tyler Neely
2320f95dd1 Update the coordinator to include request for initializing a new shard map 2022-08-18 14:01:47 +00:00
Tyler Neely
3794693356 Make shard_rsm.hpp a bit more clear 2022-08-18 13:34:11 +00:00
Tyler Neely
d50b6c1abb Move rsm_client to src/io/rsm 2022-08-18 13:20:56 +00:00
Tyler Neely
d292162b00 Use new RsmClient in raft test 2022-08-17 16:40:18 +00:00
Tyler Neely
9c4556618a Rework RsmClient and update sharded_map commit 2022-08-17 16:35:35 +00:00
Tyler Neely
f0dc0d911d Merge branch 'T0941-MG-implement-basic-raft-version' of github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-08-16 16:51:09 +00:00
Tyler Neely
e545beaf78 Merge branch 'T0941-MG-implement-basic-raft-version' of github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-08-16 16:47:13 +00:00
Tyler Neely
3c50b68954 Small comment fix 2022-08-16 16:47:13 +00:00
Tyler Neely
fad0c893f1 Merge branch 'T0941-MG-implement-basic-raft-version' of github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-08-16 16:47:13 +00:00
Tyler Neely
866f1feeeb Added request for edge id batch request to coordinator rsm 2022-08-16 16:47:13 +00:00
gvolfing
16d1fa2c22 Gerneral clean-up 2022-08-16 16:47:13 +00:00
gvolfing
518e8df04c Resolve issues with the sharded_map test 2022-08-16 16:47:13 +00:00
gvolfing
9c453779f5 Add the coordinator part to the sharded_map test 2022-08-16 16:47:13 +00:00
gvolfing
5d66a4e828 Check against cas_succeeded 2022-08-16 16:47:13 +00:00
gvolfing
2553a8fdc3 Remove unfinished statement 2022-08-16 16:47:13 +00:00
gvolfing
9aeca7a4b3 Add test for sharded_map 2022-08-16 16:47:13 +00:00
gvolfing
1b2c8f6b29 Move RsmClient into a separate folder and header 2022-08-16 16:47:13 +00:00
gvolfing
a74a556fcc Remove unnecessary storage pool, general cleanup 2022-08-16 16:47:13 +00:00
gvolfing
66e791d042 Make Coordinator apply splitting on request. 2022-08-16 16:47:13 +00:00
gvolfing
797c76cdfd Add logic to split shards 2022-08-16 16:47:13 +00:00
gvolfing
7af917e408 Add abstraction for RsmClient 2022-08-16 16:47:13 +00:00
gvolfing
c7282e8935 Temporarly remove the stanby server pool 2022-08-16 16:47:13 +00:00
gvolfing
4ed5801588 Change min and max key related shard logic 2022-08-16 16:47:13 +00:00
gvolfing
5963c83a60 Update Coordinator 2022-08-16 16:47:13 +00:00
gvolfing
edf1293274 Add GetShardMap read-only request to coordinator 2022-08-16 16:47:13 +00:00
gvolfing
dd46cc407f Return an error and the latest known ShardMap version if the requested key is not possibly stored in the given shard 2022-08-16 16:47:13 +00:00
Tyler Neely
92d69e080c Add todos to coordinator.hpp 2022-08-16 16:47:13 +00:00
Tyler Neely
629fd231b3 Merge branch 'T0941-MG-implement-basic-raft-version' of github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-08-16 16:47:09 +00:00
Tyler Neely
95e90e6c2e Check-in in-progress shard test 2022-08-16 16:42:28 +00:00
Tyler Neely
502a9b4823 Check-in coordinator_rsm.hpp 2022-08-16 16:42:28 +00:00
Tyler Neely
c62b0eff93 Add Simulator::RegisterNew helper method 2022-08-16 16:42:28 +00:00
Tyler Neely
6b9311e0b8 Bump shard_rsm to use new method names 2022-08-16 16:42:28 +00:00
Tyler Neely
e3dd404865 Add new test, start to fill out coordinator RSM 2022-08-16 16:42:28 +00:00
Tyler Neely
523e2b9186 Merge branch 'T0912-MG-in-memory-shard-map' of github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-08-16 16:42:28 +00:00
Tyler Neely
79539d13c9 Use Read/Apply instead of read/apply in Rsm concept 2022-08-16 16:42:28 +00:00
Tyler Neely
6169eb221b Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-16 17:13:41 +02:00
Tyler Neely
342611691a Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-16 17:13:30 +02:00
Tyler Neely
c256dce601 Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-16 17:13:03 +02:00
Tyler Neely
2e9cf8f37d Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-16 17:12:13 +02:00
Tyler Neely
47186cab18 Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-16 17:11:56 +02:00
Tyler Neely
dcc5ec920a Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-16 17:11:41 +02:00
Tyler Neely
c7d96ed5c5 Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-16 17:11:11 +02:00
Tyler Neely
7ad9b62968 Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-16 17:10:37 +02:00
Tyler Neely
bb44aaa188 Update src/io/rsm/raft.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-16 17:09:51 +02:00
Tyler Neely
9961659103 Use spdlog instead of cout 2022-08-16 14:52:03 +00:00
Tyler Neely
6f906c0488 Use spdlog instead of cout 2022-08-16 14:44:17 +00:00
Tyler Neely
d161163fb4 Merge branch 'project-pineapples' of github.com:memgraph/memgraph into T0941-MG-implement-basic-raft-version 2022-08-15 13:49:50 +00:00
Tyler Neely
1423da5f51 Improve comments around majority index selection 2022-08-15 11:57:19 +00:00
Tyler Neely
5e4733ac98 Add extra safety checks to commit_index management 2022-08-12 13:20:11 +00:00
Tyler Neely
cbdfd54e5f Properly apply state updates in Follower Handle for AppendRequest 2022-08-11 12:30:26 +00:00
Tyler Neely
69a2d73172 Fix bug-prone leader application of write requests to the replicated state 2022-08-11 12:17:33 +00:00
Tyler Neely
5b69f435b6 Small comment cleanup 2022-08-11 08:39:11 +00:00
Tyler Neely
f098d6b331 Merge branch 'T0879-MG-transport-prototype' of github.com:memgraph/memgraph into T0941-MG-implement-basic-raft-version 2022-08-10 10:48:17 +00:00
Tyler Neely
f6edce8f0b Apply Kostas's feedback to transport interface 2022-08-10 09:34:02 +00:00
Tyler Neely
1225230c3a Apply feedback from cpplint 2022-08-09 15:52:24 +00:00
Tyler Neely
5f225a623e align cpp w/ hpp naming 2022-08-09 15:21:52 +00:00
Tyler Neely
d15105455a Clean up comments and TODOs 2022-08-09 14:07:42 +00:00
Tyler Neely
36c133ce4e Merge branch 'T0879-MG-transport-prototype' of github.com:memgraph/memgraph into T0941-MG-implement-basic-raft-version 2022-08-08 16:29:48 +00:00
Tyler Neely
91d48f05f3 Merge branch 'project-pineapples' into T0879-MG-transport-prototype 2022-08-08 13:34:30 +02:00
Tyler Neely
7bac0d1c61 Use default equality operator for Address 2022-08-08 11:32:42 +00:00
Tyler Neely
a4b1d5efb4 Update src/io/future.hpp
Co-authored-by: Jure Bajic <jure.bajic@memgraph.com>
2022-08-08 13:27:06 +02:00
Tyler Neely
0a43afdec1 Update raft implementation to use std::chrono like upstream 2022-08-04 13:28:52 +00:00
Tyler Neely
618a3d96b3 Merge branch 'T0879-MG-transport-prototype' of github.com:memgraph/memgraph into T0941-MG-implement-basic-raft-version 2022-08-04 12:07:54 +00:00
gvolfing
ee16954641 Add minimum and maximum key for shard rsm prototype 2022-08-04 11:20:19 +02:00
gvolfing
0aab854e34 Add shard rsm prototype 2022-08-04 10:47:00 +02:00
Tyler Neely
343648f564 Merge branch 'T0941-MG-implement-basic-raft-version' of github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-08-04 07:49:09 +00:00
gvolfing
726fabd387 Constrain Raft class template with concept 2022-08-04 09:09:18 +02:00
Tyler Neely
d1c5aead61 Implement the rest of the KV-on-Raft RSM test 2022-08-03 15:07:08 +00:00
Tyler Neely
aebac2c519 Hoist read and write requests on the RSM into wrapper structs for futureproofing 2022-08-03 14:21:37 +00:00
Tyler Neely
74b354979c Check in incremental progress on fixing compilation error 2022-08-03 13:42:08 +00:00
gvolfing
b5cff5999b Unfinished rsm changes 2022-08-03 14:39:09 +02:00
Tyler Neely
b2a8063a96 Make more temporaries const 2022-08-02 14:33:05 +00:00
Tyler Neely
54369958d1 Extract BlockedServers functionality from MaybeTickSimulator and IncrementServerCountAndWaitForQuiescentState 2022-08-02 14:30:12 +00:00
Tyler Neely
4f06eb0f2f Address rule-of-five for abstract inhertance in OpaquePromise 2022-08-02 14:24:59 +00:00
Tyler Neely
ad0a8c4942 Use simple virtual inheritance instead of bespoke vtable for OpaquePromise 2022-08-02 13:36:40 +00:00
Tyler Neely
997fdf5a16 Check-in skeleton for RSM logic on top of Raft 2022-08-02 10:18:38 +00:00
Tyler Neely
8be88deee6 Merge branch 'project-pineapples' of github.com:memgraph/memgraph into T0941-MG-implement-basic-raft-version 2022-08-02 08:48:20 +00:00
Tyler Neely
902a46d14f Make dynamic message Take messages rvalue methods 2022-08-02 07:12:05 +00:00
Tyler Neely
3b44ef70b6 Denest operator< for clarity 2022-08-02 07:06:43 +00:00
Tyler Neely
4d8f9ea821 Remove unnecessary comment 2022-08-02 07:03:12 +00:00
Tyler Neely
e935a9a7b1 Make parenthesization less confusing 2022-08-02 07:02:17 +00:00
Tyler Neely
dd93b594bc Remove dead code 2022-08-02 07:01:25 +00:00
Tyler Neely
997d25d536 Remove buggy usage of std::forward 2022-08-01 15:53:37 +00:00
Tyler Neely
ace5f2b639 Complete clang-tidy cleanup 2022-08-01 15:44:34 +00:00
Tyler Neely
9576eea051 Address some feedback from clang-tidy 2022-08-01 15:37:16 +00:00
Tyler Neely
5bb3361a2d Use std::chrono::microseconds explicitly for Duration. Fix compiler warning related to timeouts 2022-08-01 14:32:07 +00:00
gvolfing
a84f5f6115 Undo the structured binding changes 2022-08-01 16:13:29 +02:00
Tyler Neely
cacb0dac80 Avoid unnamed namespace in future.hpp 2022-08-01 14:12:07 +00:00
gvolfing
918fa7212e Further improve const-correctness and replace dispensable structured bindings with exact return values 2022-08-01 15:30:44 +02:00
gvolfing
e905591372 Add references to the raft paper 2022-08-01 15:17:29 +02:00
Tyler Neely
649b5437b0 Improve docs around Io interface 2022-08-01 12:58:55 +00:00
Tyler Neely
102d997288 Update src/io/simulator/simulator_handle.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-01 14:52:06 +02:00
Tyler Neely
a3f3e05fc2 Include replier address in operator< for PromiseKey 2022-08-01 12:50:48 +00:00
Tyler Neely
4f4eb9ea13 Update src/io/future.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-08-01 14:47:13 +02:00
Tyler Neely
ca638db509 Remove extra blank line 2022-08-01 12:45:45 +00:00
Tyler Neely
7d33bb1937 Update Future unit test to use gtest 2022-08-01 12:42:37 +00:00
Tyler Neely
b8487da392 Move future test to unit tests 2022-08-01 11:58:54 +00:00
Tyler Neely
dbd744470b Add future benchmark 2022-08-01 11:48:21 +00:00
Tyler Neely
b2b11f3a30 Run simulation tests in CI 2022-08-01 11:24:21 +00:00
Tyler Neely
eb1b6c3ac8 Make SimulatorHandle::TimeoutPromisesPastDeadline private 2022-08-01 11:10:00 +00:00
Tyler Neely
0c2cbb5461 Make a couple more things const 2022-08-01 11:08:17 +00:00
Tyler Neely
69ea79a75e Make a couple more things const 2022-08-01 11:07:39 +00:00
Tyler Neely
c0d6cec9ab Split simulator_handle.cpp into a source and header file 2022-08-01 11:06:08 +00:00
Tyler Neely
9b915be1aa Make some methods const. Remove outdated TODO 2022-08-01 10:30:37 +00:00
Tyler Neely
b127f6f345 Use spdlog and create a formatter for Address 2022-08-01 10:23:25 +00:00
Tyler Neely
66ef5b2072 Make certain temporaries const 2022-08-01 08:26:09 +00:00
Tyler Neely
f877f8e1d3 Add some requests and additional metadata around coordinator operations 2022-07-29 14:40:08 +00:00
gvolfing
0ea9878fd1 CTAD 2022-07-29 14:27:55 +02:00
gvolfing
af94270dc6 Remove redundant else clauses when returning from every branch 2022-07-29 14:22:57 +02:00
gvolfing
8aac3ae7ea Make unchanged variables const 2022-07-29 14:08:37 +02:00
Tyler Neely
507018a630 Merge branch 'T0879-MG-transport-prototype' of github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-07-29 11:50:21 +00:00
Tyler Neely
e0bbf4766a Merge branch 'project-pineapples' of github.com:memgraph/memgraph into T0879-MG-transport-prototype 2022-07-29 11:47:50 +00:00
Tyler Neely
1a48e0ffa8 Merge github.com:memgraph/memgraph into T0912-MG-in-memory-shard-map 2022-07-29 11:46:54 +00:00
Tyler Neely
6a808ce1fc Delete empty line 2022-07-28 16:27:57 +00:00
Tyler Neely
a89a2d9caa Update src/io/simulator/simulator_transport.hpp
Co-authored-by: Jure Bajic <jure.bajic@memgraph.com>
2022-07-28 18:26:36 +02:00
Tyler Neely
c4f1764fee Rely on default initialization of random number generators 2022-07-28 16:24:45 +00:00
Tyler Neely
48a445f2ed Merge branch 'T0879-MG-transport-prototype' of github.com:memgraph/memgraph into T0879-MG-transport-prototype 2022-07-28 16:24:34 +00:00
Tyler Neely
406da4b25c Use uint8_t instead of int for SimulatorConfig::drop_percent 2022-07-28 16:23:10 +00:00
Tyler Neely
8fde05444d Update src/io/future.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-07-28 18:13:50 +02:00
Tyler Neely
6bdfb43ad0 Use rvalue reference requirement for Future::Wait 2022-07-28 16:07:20 +00:00
Tyler Neely
9056e2c97a Make Address's == and < operators consider uuid 2022-07-28 16:06:48 +00:00
Tyler Neely
51371398ce Update src/io/future.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-07-27 17:27:11 +02:00
Tyler Neely
b38dc28e01 Update src/io/future.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-07-27 17:26:00 +02:00
Tyler Neely
6cc550719b Update src/io/future.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-07-27 17:25:25 +02:00
Tyler Neely
ef70b858e2 Centralize Future's Shared state taking logic. Fix a race condition in quiescence tracking 2022-07-27 15:24:33 +00:00
Tyler Neely
509c12956c Update src/io/future.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-07-27 17:09:32 +02:00
Tyler Neely
1527509e36 Use std::chrono instead of raw uint64_t 2022-07-27 15:07:01 +00:00
Tyler Neely
0cfb68bb89 Update src/io/simulator/simulator_handle.hpp
Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
2022-07-27 16:56:14 +02:00
Tyler Neely
e2968c2e21 Use std::chrono instead of raw uint64_t 2022-07-27 14:55:39 +00:00
Tyler Neely
4ee4612a9c Remove removed raft.cpp from CMakeLists.txt for the simulator tests 2022-07-27 14:06:16 +00:00
Tyler Neely
dc38296575 avoid unnecessary std::optional around std::function which can be nullable 2022-07-27 14:05:57 +00:00
Tyler Neely
06962a3ec4 Check shard map version 2022-07-26 15:35:37 +00:00
Tyler Neely
c0b0b08d12 Check-in deregistration and shard split things 2022-07-26 15:32:22 +00:00
Tyler Neely
c100a86644 Check-in changes from hangout 2022-07-26 15:23:55 +00:00
Tyler Neely
3ec1ff9ee4 Commit small changes from meeting 2022-07-26 11:49:08 +00:00
Tyler Neely
98206caf85 Separate split functionality from ShardMap 2022-07-25 10:38:50 +00:00
Tyler Neely
962767ea1c Initial check-in of shard map ideas 2022-07-25 10:34:27 +00:00
Tyler Neely
2a199c9484 Merge branch 'master' of github.com:memgraph/memgraph into T0879-MG-transport-prototype 2022-07-22 12:14:18 +00:00
Tyler Neely
a85e9fcdd4 Remove raft-related code from transport prototype branch 2022-07-22 12:11:00 +00:00
Kostas
72b4337864 Added ScanVertices request/response example 2022-07-21 18:37:06 +03:00
János Benjamin Antal
ed71332773 Add dummy storage engine to test 2022-07-21 16:23:27 +02:00
Tyler Neely
fd3d70d847 Move raft-related code to replicated state machine (rsm) namespace 2022-07-21 12:41:02 +00:00
Tyler Neely
f8e5032011 Restructure files into namespaces and subdirectories 2022-07-21 12:10:23 +00:00
Tyler Neely
5b59d890c0 Remove awkward Reply sugar for now 2022-07-21 11:53:51 +00:00
Tyler Neely
0351db2461 Move future.hpp to src/io 2022-07-21 11:45:05 +00:00
Tyler Neely
c379475e12 Merge branch 'project-pineapples' of github.com:memgraph/memgraph into T0879-MG-transport-prototype 2022-07-21 11:01:04 +00:00
Tyler Neely
9c5d19bc19 Start to adapt the transport-related code to use namespaces 2022-07-21 11:00:11 +00:00
Tyler Neely
4d85a7e605 Check-in simulator_transport.hpp 2022-07-21 10:49:33 +00:00
Tyler Neely
f6c2202772 Use anonymous namespace to avoid friend declarations in future.hpp 2022-07-21 10:49:19 +00:00
Tyler Neely
498ae97ae9 Clean up log messages 2022-07-21 10:26:08 +00:00
Tyler Neely
fbd015d3c6 Continue codebase clean-up in preparation for merge 2022-07-21 10:24:13 +00:00
Tyler Neely
1ef11a36f4 Apply feedback from cpplint 2022-07-21 09:33:06 +00:00
Tyler Neely
9ae1671e4f Fix bug with MgFuture where its safety check was not correctly initialized 2022-07-20 18:17:06 +00:00
Tyler Neely
b4afe45de5 Handle Request timeouts properly in the simulator 2022-07-20 17:18:07 +00:00
Tyler Neely
581925e660 Fix a few bugs, expose stats 2022-07-20 17:07:18 +00:00
Tyler Neely
afef6dc11b A large batch of bug fixes and clean-ups 2022-07-20 13:18:00 +00:00
Tyler Neely
689336e765 Fix several bugs, clean-ups and tuning 2022-07-19 14:57:01 +00:00
Marko Budiselic
5dd0ddc352 Killing bugs 2022-07-18 11:36:56 +02:00
Marko Budiselic
1480d975a7 Fix the basic_request example, something sill broken 2022-07-17 17:22:39 +02:00
Tyler Neely
9dc37a87f7 Enable more aggressive message scrambling to get a race condition to jump out about 0.2% of the time 2022-07-15 16:46:54 +00:00
Tyler Neely
46a2879ece Fix a number of bugs in raft, and it can now go for around 1400 simulations before hitting a race condition 2022-07-15 16:44:42 +00:00
Tyler Neely
b2142e8d38 Remove unnecessary log message 2022-07-15 16:20:05 +00:00
Tyler Neely
0dc69c180d Start cranking up the testing intensity and fix a variety of correctness and code quality issues 2022-07-15 16:19:00 +00:00
Tyler Neely
ad1d8637e5 Fix race condition in simulator. Make leader election function more reliably in raft code 2022-07-15 09:07:39 +00:00
Tyler Neely
4876b7cd8c Start removing load-bearing sleep statements to get race conditions to jump out in the simulator 2022-07-15 05:43:40 +00:00
Tyler Neely
a6133dab49 Start to tune various timeouts in the raft implementation 2022-07-15 05:38:04 +00:00
Tyler Neely
3466c15f76 Make raft work in the happy path 2022-07-14 19:57:52 +00:00
Tyler Neely
63beeb8771 Send log state along with AppendRequest messages from Leader 2022-07-14 19:06:56 +00:00
Tyler Neely
d14f7705b1 Get most of the raft data path up and running 2022-07-14 18:45:24 +00:00
Tyler Neely
5e98971bb2 Continue filling out AppendEntries state transition logic 2022-07-14 13:06:54 +00:00
Tyler Neely
dc78adde40 Move empty in-flight early exit of simulator tick to before time advancement 2022-07-14 13:06:22 +00:00
Tyler Neely
80970a97f0 Get basic leader election to work and clean some things up 2022-07-14 12:18:09 +00:00
Tyler Neely
57533f2746 A large number of scattered cleanups. Don't use transport Request in state machine code 2022-07-14 10:50:49 +00:00
Tyler Neely
1a12a80af0 Continue to implement raft state machine transitions 2022-07-14 07:09:50 +00:00
Tyler Neely
30c97e658d Implement some more of the raft state machine transitions 2022-07-13 22:31:51 +00:00
Tyler Neely
dd9862d32c Add support for scrambling messages to the simulator 2022-07-13 19:59:23 +00:00
Tyler Neely
dc6548c996 Add support to the simulator to drop messages randomly 2022-07-13 19:51:04 +00:00
Tyler Neely
881e914b92 Add random number generator support to the IO interface 2022-07-13 13:37:38 +00:00
Tyler Neely
48ee40ce87 Start to fill out more raft logic now that role-specialized Handle and Cron are in place 2022-07-13 06:50:16 +00:00
Tyler Neely
d6742f643c Significant simplification of event-handling logic by using std::visit while matching on both the message type and node role 2022-07-12 19:04:32 +00:00
Tyler Neely
d8f09b59b3 Add MgFuture::Cancel to signal that a future is intentionally dropped 2022-07-12 19:03:12 +00:00
Tyler Neely
2e5d8b7e8c Check-in in-progress work for raft test on top of simulator 2022-07-11 18:01:13 +00:00
Tyler Neely
88eee66258 Small cleanup of basic_request test 2022-07-11 18:00:30 +00:00
Tyler Neely
d4cb259979 Fix issue with recursive parameter pack std::variant conversion of std::any. Improve documentation of the complex functionality 2022-07-11 17:59:52 +00:00
Tyler Neely
1a87dd2497 Add two methods to MgFuture: IsReady and TryGet 2022-07-11 17:59:08 +00:00
Tyler Neely
15d637729e Clean-up basic_request example 2022-07-08 14:10:33 +00:00
Tyler Neely
5ee95a2e70 Add ShutDown method to Simulator and update basic_request test to utilize it 2022-07-08 14:05:02 +00:00
Tyler Neely
597a5d191c Check-in SimulatorConfig 2022-07-08 11:49:29 +00:00
Tyler Neely
eee2a7e019 Fix memory leak caught by LSAN 2022-07-08 11:04:44 +00:00
Tyler Neely
25b0a445b9 Properly fill response promises in the simulator 2022-07-08 08:21:37 +00:00
Tyler Neely
20a6dae047 Get the message receive path up and running. Large number of small refactors 2022-07-07 20:58:16 +00:00
Tyler Neely
04dbedc3af Add functionality for converting from std::any to a std::variant. Improve type names. Continue simulator implementation 2022-07-07 11:27:02 +00:00
Tyler Neely
a0058bc10a Add OpaquePromise type with correct dtor. Make a few structs comparable for storage in maps. Fix initialization of Shared 2022-07-06 15:19:16 +00:00
Tyler Neely
f601e83f6f Continue structuring the simulator and filling in its implementation 2022-07-05 21:11:39 +00:00
Tyler Neely
e1aab7065f Use TSAN on futures test. Continue implementation of simulator 2022-07-05 18:02:01 +00:00
Tyler Neely
28516763b9 Fix issue with movement/consumption tracking in MgFuture and MgPromise 2022-07-05 17:36:47 +00:00
Tyler Neely
29e8d8e72c Fix cmake config for new transport 2022-07-05 16:04:03 +00:00
Tyler Neely
6debc9e7d8 Revamp MgFuture, continue threading logic through Simulator 2022-07-05 15:45:59 +00:00
Tyler Neely
eb4ca543ea Continue to implement the simulated transport 2022-07-04 21:42:10 +00:00
Tyler Neely
38ca430713 Small refactor of cmake for simulator test 2022-07-04 20:44:51 +00:00
Tyler Neely
24128e0bca Check-in new test 2022-07-04 19:42:23 +00:00
Tyler Neely
73719b2120 Continue to bolt-down MgFuture impl 2022-07-04 18:54:09 +00:00
Tyler Neely
20839b0ae0 Add simple test for MgFuture 2022-07-04 15:00:32 +00:00
Tyler Neely
6cec9acbb9 Add basic test skeleton 2022-07-04 11:56:41 +00:00
Tyler Neely
cb70431301 Reset optional after moving its value out in Future::Wait 2022-07-04 11:55:18 +00:00
Tyler Neely
0ef1f7eb5d Apply Rule-Of-Five and uniform CamelCase function names 2022-07-01 08:45:19 +00:00
Tyler Neely
4140f3e05e [SQUASH ME] Initial check-in for getting feedback 2022-06-29 15:52:37 +00:00
4 changed files with 128 additions and 267 deletions

View File

@@ -2703,10 +2703,27 @@ bool Foreach::Accept(HierarchicalLogicalOperatorVisitor &visitor) {
return visitor.PostVisit(*this);
}
/*
#NoCommit #JBA we will need to also modify the request sent (attributes?) + the client of storage + the storage side
for the string version we need to stringify the expression
perhaps not needed now for customer?
Note: operators are not yet connected to anything are they? For now I think the plan still use the non-distrib version
*/
class DistributedScanAllCursor : public Cursor {
public:
explicit DistributedScanAllCursor(Symbol output_symbol, UniqueCursorPtr input_cursor, const char *op_name)
: output_symbol_(output_symbol), input_cursor_(std::move(input_cursor)), op_name_(op_name) {}
explicit DistributedScanAllCursor(
Symbol output_symbol, UniqueCursorPtr input_cursor, const char *op_name,
std::optional<storage::v3::LabelId> label_to_filter, std::optional<storage::v3::PropertyId> property_to_filter,
std::optional<std::vector<std::pair<storage::v3::PropertyId, Expression *>>> property_value_pairs_to_filter)
: output_symbol_(output_symbol),
input_cursor_(std::move(input_cursor)),
op_name_(op_name),
label_to_filter_(label_to_filter),
property_to_filter_(property_to_filter),
property_value_pairs_to_filter_(property_value_pairs_to_filter) {
ResetExecutionState();
}
using VertexAccessor = accessors::VertexAccessor;
@@ -2744,6 +2761,47 @@ class DistributedScanAllCursor : public Cursor {
current_batch.clear();
current_vertex_it = current_batch.end();
request_state_ = msgs::ExecutionState<msgs::ScanVerticesRequest>{};
/*
Many questions here:
Where are all attributes of ScanVerticesRequest init?
Then why vector of request? What do we expect?
How do we build the vector? What are the several elements corresponding to?
Where do we iterate on those requests?
Convert the Expression* to string version of ast? or something?
We gonna have to break down the expression at some point somewhere
Is there a way to Ut something? Perhaps we can UT the creatiuon of request and compare we exactly get the
ScanVerticesRequest we want
*/
auto request = msgs::ScanVerticesRequest{};
if (label_to_filter_.has_value()) {
request.label_to_filter_ = msgs::Label{.id = label_to_filter_.value()};
}
if (property_to_filter_.has_value()) {
request.property_to_filter_ = property_to_filter_;
}
if (property_value_pairs_to_filter_.has_value()) {
auto res = std::vector<std::pair<storage::v3::PropertyId, std::string>>{}; // #NoCommit not int
res.reserve(property_value_pairs_to_filter_->size());
std::transform(
property_value_pairs_to_filter_->begin(), property_value_pairs_to_filter_->end(), std::back_inserter(res),
[](auto &property_value_pair) {
return std::make_pair(
property_value_pair.first,
std::string("") /* ToString(property_value_pair.second)*/); // #NoCommit call expression.tostring? see
// the json thing?
// #NoCommit we need to replace the node by a special character (sequence?) that the storage will
// identify as a node to know where is the symbol on the frame #NoCommit not bool but something
// with property_value_pair.second?
});
request.property_value_pairs_to_filter_ = res;
}
request_state_.requests.emplace_back(request);
}
void Reset() override {
@@ -2758,6 +2816,9 @@ class DistributedScanAllCursor : public Cursor {
std::vector<VertexAccessor> current_batch;
decltype(std::vector<VertexAccessor>().begin()) current_vertex_it;
msgs::ExecutionState<msgs::ScanVerticesRequest> request_state_;
std::optional<storage::v3::LabelId> label_to_filter_;
std::optional<storage::v3::PropertyId> property_to_filter_;
std::optional<std::vector<std::pair<storage::v3::PropertyId, Expression *>>> property_value_pairs_to_filter_;
};
class DistributedCreateNodeCursor : public Cursor {
@@ -2824,4 +2885,62 @@ class DistributedCreateNodeCursor : public Cursor {
std::vector<NodeCreationInfo> nodes_info_;
msgs::ExecutionState<msgs::CreateVerticesRequest> state_;
};
class DistributedUnwindCursor : public Cursor {
public:
DistributedUnwindCursor(const Unwind &self, utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(mem)), input_value_(mem) {}
bool Pull(Frame &frame, ExecutionContext &context) override {
SCOPED_PROFILE_OP("Unwind");
while (true) {
if (MustAbort(context)) {
throw HintedAbortError();
}
// if we reached the end of our list of values
// pull from the input
if (input_value_it_ == input_value_.end()) {
if (!input_cursor_->Pull(frame, context)) {
return false;
}
// successful pull from input, initialize value and iterator
ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, context.db_accessor,
storage::v3::View::OLD);
TypedValue input_value = self_.input_expression_->Accept(evaluator);
if (input_value.type() != TypedValue::Type::List) {
throw QueryRuntimeException("Argument of UNWIND must be a list, but '{}' was provided.", input_value.type());
}
// Copy the evaluted input_value_list to our vector.
input_value_ = input_value.ValueList();
input_value_it_ = input_value_.begin();
}
// if we reached the end of our list of values goto back to top
if (input_value_it_ == input_value_.end()) {
continue;
}
frame[self_.output_symbol_] = *input_value_it_++;
return true;
}
}
void Shutdown() override { input_cursor_->Shutdown(); }
void Reset() override {
input_cursor_->Reset();
input_value_.clear();
input_value_it_ = input_value_.end();
}
private:
const Unwind &self_;
const UniqueCursorPtr input_cursor_;
// typed values we are unwinding and yielding
utils::pmr::vector<TypedValue> input_value_;
// current position in input_value_
decltype(input_value_)::iterator input_value_it_ = input_value_.end();
};
} // namespace memgraph::query::v2::plan

View File

@@ -376,13 +376,19 @@ struct OrderBy {
enum class StorageView { OLD = 0, NEW = 1 };
// #NoCommit #JBA to modify
struct ScanVerticesRequest {
Hlc transaction_id;
VertexId start_id;
std::optional<std::vector<PropertyId>> props_to_return;
std::optional<std::vector<std::string>> filter_expressions;
std::optional<std::vector<std::string>> filter_expressions; // #NoCommit what the use of that exactly?
std::optional<size_t> batch_limit;
StorageView storage_view;
std::optional<Label> label_to_filter_;
std::optional<PropertyId> property_to_filter_;
std::optional<std::vector<std::pair<storage::v3::PropertyId, std::string>>> property_value_pairs_to_filter_;
// #NoCommit not bool but the string version of the ast? to double check
};
struct ScanResultRow {

View File

@@ -433,7 +433,3 @@ target_link_libraries(${test_prefix}local_transport mg-io)
# Test MachineManager with LocalTransport
add_unit_test(machine_manager.cpp)
target_link_libraries(${test_prefix}machine_manager mg-io mg-coordinator mg-storage-v3)
# Test ExpressionEvaluator with expressions
add_unit_test(storage_v3_expr_usage.cpp)
target_link_libraries(${test_prefix}storage_v3_expr_usage mg-io mg-expr mg-storage-v3)

View File

@@ -1,260 +0,0 @@
// Copyright 2022 Memgraph Ltd.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
// License, and you may not use this file except in compliance with the Business Source License.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
#include <chrono>
#include <limits>
#include <thread>
#include <gtest/gtest.h>
#include <coordinator/coordinator.hpp>
#include <coordinator/coordinator_client.hpp>
#include <coordinator/hybrid_logical_clock.hpp>
#include <coordinator/shard_map.hpp>
#include <io/local_transport/local_system.hpp>
#include <io/local_transport/local_transport.hpp>
#include <io/rsm/rsm_client.hpp>
#include <io/transport.hpp>
#include <machine_manager/machine_config.hpp>
#include <machine_manager/machine_manager.hpp>
#include "common/types.hpp"
#include "exceptions.hpp"
#include "io/rsm/rsm_client.hpp"
#include "parser/opencypher/parser.hpp"
#include "storage/v3/bindings/ast/ast.hpp"
#include "storage/v3/bindings/bindings.hpp"
#include "storage/v3/bindings/cypher_main_visitor.hpp"
#include "storage/v3/bindings/db_accessor.hpp"
#include "storage/v3/bindings/eval.hpp"
#include "storage/v3/bindings/frame.hpp"
#include "storage/v3/bindings/symbol_generator.hpp"
#include "storage/v3/bindings/symbol_table.hpp"
#include "storage/v3/bindings/typed_value.hpp"
#include "storage/v3/id_types.hpp"
#include "storage/v3/key_store.hpp"
#include "storage/v3/property_value.hpp"
#include "storage/v3/schemas.hpp"
#include "storage/v3/shard.hpp"
#include "utils/string.hpp"
namespace memgraph::storage::v3::test {
class ExpressionEvaluatorUsageTest : public ::testing::Test {
protected:
LabelId primary_label{LabelId::FromInt(1)};
PropertyId primary_property{PropertyId::FromInt(2)};
PrimaryKey min_pk{PropertyValue(0)};
Shard db{primary_label, min_pk, std::nullopt};
Shard::Accessor storage_dba{db.Access(GetNextHlc())};
DbAccessor dba{&storage_dba};
AstStorage storage;
memgraph::utils::MonotonicBufferResource mem{1024};
EvaluationContext ctx{.memory = &mem};
SymbolTable symbol_table_;
Frame frame_{128};
ExpressionEvaluator eval{&frame_, symbol_table_, ctx, &dba, View::NEW};
coordinator::Hlc last_hlc{0, io::Time{}};
void SetUp() override {
db.StoreMapping({{1, "label"}, {2, "property"}});
ASSERT_TRUE(
db.CreateSchema(primary_label, {storage::v3::SchemaProperty{primary_property, common::SchemaType::INT}}));
}
std::vector<PropertyId> NamesToProperties(const std::vector<std::string> &property_names) {
std::vector<PropertyId> properties;
properties.reserve(property_names.size());
for (const auto &name : property_names) {
properties.push_back(dba.NameToProperty(name));
}
return properties;
}
std::vector<LabelId> NamesToLabels(const std::vector<std::string> &label_names) {
std::vector<LabelId> labels;
labels.reserve(label_names.size());
for (const auto &name : label_names) {
labels.push_back(dba.NameToLabel(name));
}
return labels;
}
Identifier *CreateIdentifierWithValue(std::string name, const TypedValue &value) {
auto *id = storage.Create<Identifier>(name, true);
auto symbol = symbol_table_.CreateSymbol(name, true);
id->MapTo(symbol);
frame_[symbol] = value;
return id;
}
template <class TExpression>
auto Eval(TExpression *expr) {
ctx.properties = NamesToProperties(storage.properties_);
ctx.labels = NamesToLabels(storage.labels_);
auto value = expr->Accept(eval);
EXPECT_EQ(value.GetMemoryResource(), &mem) << "ExpressionEvaluator must use the MemoryResource from "
"EvaluationContext for allocations!";
return value;
}
coordinator::Hlc GetNextHlc() {
++last_hlc.logical_id;
last_hlc.coordinator_wall_clock += std::chrono::seconds(1);
return last_hlc;
}
};
class StrippedQuery {
public:
/**
* Strips the input query and stores stripped query, stripped arguments and
* stripped query hash.
*
* @param query Input query.
*/
explicit StrippedQuery(const std::string &query);
/**
* Copy constructor is deleted because we don't want to make unnecessary
* copies of this object (copying of string and vector could be expensive)
*/
StrippedQuery(const StrippedQuery &other) = delete;
StrippedQuery &operator=(const StrippedQuery &other) = delete;
/**
* Move is allowed operation because it is not expensive and we can
* move the object after it was created.
*/
StrippedQuery(StrippedQuery &&other) = default;
StrippedQuery &operator=(StrippedQuery &&other) = default;
const std::string &query() const { return query_; }
const auto &original_query() const { return original_; }
const auto &literals() const { return literals_; }
const auto &named_expressions() const { return named_exprs_; }
const auto &parameters() const { return parameters_; }
uint64_t hash() const { return hash_; }
private:
// Return len of matched keyword if something is matched, otherwise 0.
int MatchKeyword(int start) const;
int MatchString(int start) const;
int MatchSpecial(int start) const;
int MatchDecimalInt(int start) const;
int MatchOctalInt(int start) const;
int MatchHexadecimalInt(int start) const;
int MatchReal(int start) const;
int MatchParameter(int start) const;
int MatchEscapedName(int start) const;
int MatchUnescapedName(int start) const;
int MatchWhitespaceAndComments(int start) const;
// Original query.
std::string original_;
// Stripped query.
std::string query_;
// Token positions of stripped out literals mapped to their values.
// TODO: Parameters class really doesn't provide anything interesting. This
// could be changed to std::unordered_map, but first we need to rewrite (or
// get rid of) hardcoded queries which expect Parameters.
Parameters literals_;
// Token positions of query parameters mapped to their names.
std::unordered_map<int, std::string> parameters_;
// Token positions of nonaliased named expressions in return statement mapped
// to their original (unstripped) string.
std::unordered_map<int, std::string> named_exprs_;
// Hash based on the stripped query.
uint64_t hash_;
};
TEST_F(ExpressionEvaluatorUsageTest, DummyExample) {
// dummy
const std::string expr1{"2+1-3+2"};
// Parse stuff
memgraph::frontend::opencypher::Parser<frontend::opencypher::ParserOpTag::EXPRESSION> parser(expr1);
expr::ParsingContext pc;
CypherMainVisitor visitor(pc, &storage);
auto *ast = parser.tree();
auto ladida = visitor.visit(ast);
auto res1 = Eval(std::any_cast<Expression *>(ladida));
EXPECT_EQ(res1.ValueInt(), 2);
}
TEST_F(ExpressionEvaluatorUsageTest, PropertyLookup) {
db.StoreMapping({{1, "label"}, {2, "property"}, {3, "prop2"}});
const auto prop2 = PropertyId::FromUint(3);
auto v1 = *dba.InsertVertexAndValidate(primary_label, {}, {{primary_property, PropertyValue(1)}});
ASSERT_TRUE(v1.SetPropertyAndValidate(prop2, PropertyValue(5)).HasValue());
auto v2 = *dba.InsertVertexAndValidate(primary_label, {}, {{primary_property, PropertyValue(2)}});
ASSERT_TRUE(v2.SetPropertyAndValidate(prop2, PropertyValue(5)).HasValue());
auto v3 = *dba.InsertVertexAndValidate(primary_label, {}, {{primary_property, PropertyValue(3)}});
ASSERT_TRUE(v3.SetPropertyAndValidate(prop2, PropertyValue(5)).HasValue());
// Property filtering
// const std::string expr1{"n.prop2 > 0"};
const std::string expr1{"node.prop2 > 0 AND node.prop2 < 10"};
// Parse stuff
memgraph::frontend::opencypher::Parser<memgraph::frontend::opencypher::ParserOpTag::EXPRESSION> parser(expr1);
expr::ParsingContext pc;
CypherMainVisitor visitor(pc, &storage);
auto *ast = parser.tree();
auto expr = visitor.visit(ast);
static constexpr const char *node_name = "node";
static constexpr const char *edge_name = "edge";
static Identifier node_identifier = Identifier(std::string(node_name), false);
bool is_node_identifier_present = false;
static Identifier edge_identifier = Identifier(std::string(edge_name), false);
bool is_edge_identifier_present = false;
std::vector<Identifier *> identifiers;
if (expr1.find(node_name) != std::string::npos) {
is_node_identifier_present = true;
identifiers.push_back(&node_identifier);
}
if (expr1.find(edge_name) != std::string::npos) {
is_edge_identifier_present = true;
identifiers.push_back(&edge_identifier);
}
expr::SymbolGenerator symbol_generator(&symbol_table_, identifiers);
(std::any_cast<Expression *>(expr))->Accept(symbol_generator);
if (is_node_identifier_present) {
frame_[symbol_table_.at(node_identifier)] = v2; // vertex accessor
}
if (is_edge_identifier_present) {
frame_[symbol_table_.at(edge_identifier)] = v1; // edge accessor
}
auto res1 = Eval(std::any_cast<Expression *>(expr));
ASSERT_TRUE(res1.ValueBool());
}
} // namespace memgraph::storage::v3::test