Add requests placeholders

This commit is contained in:
Marko Budiselic 2023-03-13 18:46:20 +00:00
parent 88724f18fa
commit ff07360b85
7 changed files with 35 additions and 4 deletions

View File

@ -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);
}

View File

@ -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>;

View File

@ -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

View File

@ -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);

View File

@ -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))};

View File

@ -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, ());

View File

@ -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());
}