From ff07360b85fc57cf55195e977bfef82c2d4c8db4 Mon Sep 17 00:00:00 2001
From: Marko Budiselic <marko.budiselic@memgraph.com>
Date: Mon, 13 Mar 2023 18:46:20 +0000
Subject: [PATCH] Add requests placeholders

---
 src/query/v2/request_router.hpp              |  6 ++++++
 src/query/v2/requests.hpp                    | 19 +++++++++++++++++--
 src/storage/v3/shard_rsm.cpp                 |  4 ++++
 src/storage/v3/shard_rsm.hpp                 |  3 ++-
 tests/simulation/common.hpp                  |  4 +++-
 tests/unit/mock_helpers.hpp                  |  1 +
 tests/unit/query_v2_expression_evaluator.cpp |  2 ++
 7 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/src/query/v2/request_router.hpp b/src/query/v2/request_router.hpp
index a8326d900..cb796c037 100644
--- a/src/query/v2/request_router.hpp
+++ b/src/query/v2/request_router.hpp
@@ -106,6 +106,7 @@ class RequestRouterInterface {
   virtual std::vector<msgs::ExpandOneResultRow> ExpandOne(msgs::ExpandOneRequest request) = 0;
   virtual std::vector<msgs::CreateExpandResponse> CreateExpand(std::vector<msgs::NewExpand> new_edges) = 0;
   virtual std::vector<msgs::GetPropertiesResultRow> GetProperties(msgs::GetPropertiesRequest request) = 0;
+  virtual std::vector<msgs::GraphResponse> GetGraph(msgs::GraphRequest req) = 0;
 
   virtual storage::v3::EdgeTypeId NameToEdgeType(const std::string &name) const = 0;
   virtual storage::v3::PropertyId NameToProperty(const std::string &name) const = 0;
@@ -403,6 +404,11 @@ class RequestRouter : public RequestRouterInterface {
     return result_rows;
   }
 
+  std::vector<msgs::GraphResponse> GetGraph(msgs::GraphRequest req) override {
+    LOG_FATAL("Implement GetGraph request");
+    return {};
+  }
+
   std::optional<storage::v3::PropertyId> MaybeNameToProperty(const std::string &name) const override {
     return shards_map_.GetPropertyId(name);
   }
diff --git a/src/query/v2/requests.hpp b/src/query/v2/requests.hpp
index 1b7217324..058b24aff 100644
--- a/src/query/v2/requests.hpp
+++ b/src/query/v2/requests.hpp
@@ -574,6 +574,21 @@ struct UpdateEdgesResponse {
   std::optional<ShardError> error;
 };
 
+// TODO(gitbuda): Add more filtering options.
+struct GraphRequest {
+  Hlc transaction_id;
+  std::optional<VertexId> maybe_start_id;
+  //  The empty optional means return all of the properties, while an empty list means do not return any properties
+  std::optional<std::vector<PropertyId>> props_to_return;
+  std::optional<size_t> batch_limit;
+  StorageView storage_view{StorageView::NEW};
+};
+
+struct GraphResponse {
+  std::optional<ShardError> error;
+  Graph data;
+};
+
 struct CommitRequest {
   Hlc transaction_id;
   Hlc commit_timestamp;
@@ -583,8 +598,8 @@ struct CommitResponse {
   std::optional<ShardError> error;
 };
 
-using ReadRequests = std::variant<ExpandOneRequest, GetPropertiesRequest, ScanVerticesRequest>;
-using ReadResponses = std::variant<ExpandOneResponse, GetPropertiesResponse, ScanVerticesResponse>;
+using ReadRequests = std::variant<ExpandOneRequest, GetPropertiesRequest, ScanVerticesRequest, GraphRequest>;
+using ReadResponses = std::variant<ExpandOneResponse, GetPropertiesResponse, ScanVerticesResponse, GraphResponse>;
 
 using WriteRequests = std::variant<CreateVerticesRequest, DeleteVerticesRequest, UpdateVerticesRequest,
                                    CreateExpandRequest, DeleteEdgesRequest, UpdateEdgesRequest, CommitRequest>;
diff --git a/src/storage/v3/shard_rsm.cpp b/src/storage/v3/shard_rsm.cpp
index 881796a70..ef71d0122 100644
--- a/src/storage/v3/shard_rsm.cpp
+++ b/src/storage/v3/shard_rsm.cpp
@@ -706,4 +706,8 @@ msgs::ReadResponses ShardRsm::HandleRead(msgs::GetPropertiesRequest &&req) {
   });
 }
 
+msgs::ReadResponses ShardRsm::HandleRead(msgs::GraphRequest &&req) {
+  LOG_FATAL("Implement ShardRsm HandleRead GraphRequest");
+}
+
 }  // namespace memgraph::storage::v3
diff --git a/src/storage/v3/shard_rsm.hpp b/src/storage/v3/shard_rsm.hpp
index d301bf40b..aa442606a 100644
--- a/src/storage/v3/shard_rsm.hpp
+++ b/src/storage/v3/shard_rsm.hpp
@@ -1,4 +1,4 @@
-// Copyright 2022 Memgraph Ltd.
+// Copyright 2023 Memgraph Ltd.
 //
 // Use of this software is governed by the Business Source License
 // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
@@ -27,6 +27,7 @@ class ShardRsm {
   msgs::ReadResponses HandleRead(msgs::ExpandOneRequest &&req);
   msgs::ReadResponses HandleRead(msgs::GetPropertiesRequest &&req);
   msgs::ReadResponses HandleRead(msgs::ScanVerticesRequest &&req);
+  msgs::ReadResponses HandleRead(msgs::GraphRequest &&req);
 
   msgs::WriteResponses ApplyWrite(msgs::CreateVerticesRequest &&req);
   msgs::WriteResponses ApplyWrite(msgs::DeleteVerticesRequest &&req);
diff --git a/tests/simulation/common.hpp b/tests/simulation/common.hpp
index fcdc1338c..8e07258a9 100644
--- a/tests/simulation/common.hpp
+++ b/tests/simulation/common.hpp
@@ -1,4 +1,4 @@
-// Copyright 2022 Memgraph Ltd.
+// Copyright 2023 Memgraph Ltd.
 //
 // Use of this software is governed by the Business Source License
 // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
@@ -118,6 +118,8 @@ class MockedShardRsm {
     return resp;
   }
 
+  msgs::GraphResponse ReadImpl(msgs::GraphRequest rqst) { LOG_FATAL("Implement Simulator ReadImpl GraphRequest"); }
+
   ReadResponses Read(ReadRequests read_requests) {
     return {std::visit([this]<typename T>(T &&request) { return ReadResponses{ReadImpl(std::forward<T>(request))}; },
                        std::move(read_requests))};
diff --git a/tests/unit/mock_helpers.hpp b/tests/unit/mock_helpers.hpp
index 5ce73538a..1d4775f26 100644
--- a/tests/unit/mock_helpers.hpp
+++ b/tests/unit/mock_helpers.hpp
@@ -27,6 +27,7 @@ class MockedRequestRouter : public RequestRouterInterface {
   MOCK_METHOD(std::vector<msgs::ExpandOneResultRow>, ExpandOne, (msgs::ExpandOneRequest));
   MOCK_METHOD(std::vector<msgs::CreateExpandResponse>, CreateExpand, (std::vector<msgs::NewExpand>));
   MOCK_METHOD(std::vector<msgs::GetPropertiesResultRow>, GetProperties, (msgs::GetPropertiesRequest));
+  MOCK_METHOD(std::vector<msgs::GraphResponse>, GetGraph, (msgs::GraphRequest));
   MOCK_METHOD(void, StartTransaction, ());
   MOCK_METHOD(void, Commit, ());
 
diff --git a/tests/unit/query_v2_expression_evaluator.cpp b/tests/unit/query_v2_expression_evaluator.cpp
index 6b1c23816..9fc4fba4e 100644
--- a/tests/unit/query_v2_expression_evaluator.cpp
+++ b/tests/unit/query_v2_expression_evaluator.cpp
@@ -97,6 +97,8 @@ class MockedRequestRouter : public RequestRouterInterface {
 
   std::vector<GetPropertiesResultRow> GetProperties(GetPropertiesRequest rqst) override { return {}; }
 
+  std::vector<msgs::GraphResponse> GetGraph(msgs::GraphRequest rqst) override { return {}; }
+
   const std::string &PropertyToName(memgraph::storage::v3::PropertyId id) const override {
     return properties_.IdToName(id.AsUint());
   }