Address review comments
This commit is contained in:
parent
e565fc6e3a
commit
ab5fc05fd7
@ -71,7 +71,7 @@ query::v2::TypedValue ToTypedValue(const Value &value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BoltResult<communication::bolt::Vertex> ToBoltVertex(const query::v2::accessors::VertexAccessor &vertex,
|
communication::bolt::Vertex ToBoltVertex(const query::v2::accessors::VertexAccessor &vertex,
|
||||||
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
||||||
storage::v3::View /*view*/) {
|
storage::v3::View /*view*/) {
|
||||||
auto id = communication::bolt::Id::FromUint(0);
|
auto id = communication::bolt::Id::FromUint(0);
|
||||||
@ -91,7 +91,7 @@ BoltResult<communication::bolt::Vertex> ToBoltVertex(const query::v2::accessors:
|
|||||||
return communication::bolt::Vertex{id, new_labels, new_properties};
|
return communication::bolt::Vertex{id, new_labels, new_properties};
|
||||||
}
|
}
|
||||||
|
|
||||||
BoltResult<communication::bolt::Edge> ToBoltEdge(const query::v2::accessors::EdgeAccessor &edge,
|
communication::bolt::Edge ToBoltEdge(const query::v2::accessors::EdgeAccessor &edge,
|
||||||
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
||||||
storage::v3::View /*view*/) {
|
storage::v3::View /*view*/) {
|
||||||
// TODO(jbajic) Fix bolt communication
|
// TODO(jbajic) Fix bolt communication
|
||||||
@ -108,15 +108,16 @@ BoltResult<communication::bolt::Edge> ToBoltEdge(const query::v2::accessors::Edg
|
|||||||
return communication::bolt::Edge{id, from, to, type, new_properties};
|
return communication::bolt::Edge{id, from, to, type, new_properties};
|
||||||
}
|
}
|
||||||
|
|
||||||
BoltResult<communication::bolt::Path> ToBoltPath(const query::v2::accessors::Path & /*edge*/,
|
communication::bolt::Path ToBoltPath(const query::v2::accessors::Path & /*edge*/,
|
||||||
const msgs::ShardRequestManagerInterface * /*shard_request_manager*/,
|
const msgs::ShardRequestManagerInterface * /*shard_request_manager*/,
|
||||||
storage::v3::View /*view*/) {
|
storage::v3::View /*view*/) {
|
||||||
// TODO(jbajic) Fix bolt communication
|
// TODO(jbajic) Fix bolt communication
|
||||||
return {SHARD_ERROR(ErrorCode::DELETED_OBJECT)};
|
MG_ASSERT(false, "Path is unimplemented!");
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
BoltResult<Value> ToBoltValue(const query::v2::TypedValue &value,
|
Value ToBoltValue(const query::v2::TypedValue &value, const msgs::ShardRequestManagerInterface *shard_request_manager,
|
||||||
const msgs::ShardRequestManagerInterface *shard_request_manager, storage::v3::View view) {
|
storage::v3::View view) {
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
case query::v2::TypedValue::Type::Null:
|
case query::v2::TypedValue::Type::Null:
|
||||||
return Value();
|
return Value();
|
||||||
@ -132,35 +133,30 @@ BoltResult<Value> ToBoltValue(const query::v2::TypedValue &value,
|
|||||||
std::vector<Value> values;
|
std::vector<Value> values;
|
||||||
values.reserve(value.ValueList().size());
|
values.reserve(value.ValueList().size());
|
||||||
for (const auto &v : value.ValueList()) {
|
for (const auto &v : value.ValueList()) {
|
||||||
auto maybe_value = ToBoltValue(v, shard_request_manager, view);
|
auto value = ToBoltValue(v, shard_request_manager, view);
|
||||||
if (maybe_value.HasError()) return maybe_value.GetError();
|
values.emplace_back(std::move(value));
|
||||||
values.emplace_back(std::move(*maybe_value));
|
|
||||||
}
|
}
|
||||||
return Value(std::move(values));
|
return Value(std::move(values));
|
||||||
}
|
}
|
||||||
case query::v2::TypedValue::Type::Map: {
|
case query::v2::TypedValue::Type::Map: {
|
||||||
std::map<std::string, Value> map;
|
std::map<std::string, Value> map;
|
||||||
for (const auto &kv : value.ValueMap()) {
|
for (const auto &kv : value.ValueMap()) {
|
||||||
auto maybe_value = ToBoltValue(kv.second, shard_request_manager, view);
|
auto value = ToBoltValue(kv.second, shard_request_manager, view);
|
||||||
if (maybe_value.HasError()) return maybe_value.GetError();
|
map.emplace(kv.first, std::move(value));
|
||||||
map.emplace(kv.first, std::move(*maybe_value));
|
|
||||||
}
|
}
|
||||||
return Value(std::move(map));
|
return Value(std::move(map));
|
||||||
}
|
}
|
||||||
case query::v2::TypedValue::Type::Vertex: {
|
case query::v2::TypedValue::Type::Vertex: {
|
||||||
auto maybe_vertex = ToBoltVertex(value.ValueVertex(), shard_request_manager, view);
|
auto vertex = ToBoltVertex(value.ValueVertex(), shard_request_manager, view);
|
||||||
if (maybe_vertex.HasError()) return maybe_vertex.GetError();
|
return Value(std::move(vertex));
|
||||||
return Value(std::move(*maybe_vertex));
|
|
||||||
}
|
}
|
||||||
case query::v2::TypedValue::Type::Edge: {
|
case query::v2::TypedValue::Type::Edge: {
|
||||||
auto maybe_edge = ToBoltEdge(value.ValueEdge(), shard_request_manager, view);
|
auto edge = ToBoltEdge(value.ValueEdge(), shard_request_manager, view);
|
||||||
if (maybe_edge.HasError()) return maybe_edge.GetError();
|
return Value(std::move(edge));
|
||||||
return Value(std::move(*maybe_edge));
|
|
||||||
}
|
}
|
||||||
case query::v2::TypedValue::Type::Path: {
|
case query::v2::TypedValue::Type::Path: {
|
||||||
auto maybe_path = ToBoltPath(value.ValuePath(), shard_request_manager, view);
|
auto path = ToBoltPath(value.ValuePath(), shard_request_manager, view);
|
||||||
if (maybe_path.HasError()) return maybe_path.GetError();
|
return Value(std::move(path));
|
||||||
return Value(std::move(*maybe_path));
|
|
||||||
}
|
}
|
||||||
case query::v2::TypedValue::Type::Date:
|
case query::v2::TypedValue::Type::Date:
|
||||||
return Value(value.ValueDate());
|
return Value(value.ValueDate());
|
||||||
|
@ -30,16 +30,13 @@ class VertexAccessor;
|
|||||||
|
|
||||||
namespace memgraph::glue::v2 {
|
namespace memgraph::glue::v2 {
|
||||||
|
|
||||||
template <class TValue>
|
|
||||||
using BoltResult = utils::BasicResult<storage::v3::ShardError, TValue>;
|
|
||||||
|
|
||||||
/// @param storage::v3::VertexAccessor for converting to
|
/// @param storage::v3::VertexAccessor for converting to
|
||||||
/// communication::bolt::Vertex.
|
/// communication::bolt::Vertex.
|
||||||
/// @param msgs::ShardRequestManagerInterface *shard_request_manager getting label and property names.
|
/// @param msgs::ShardRequestManagerInterface *shard_request_manager getting label and property names.
|
||||||
/// @param storage::v3::View for deciding which vertex attributes are visible.
|
/// @param storage::v3::View for deciding which vertex attributes are visible.
|
||||||
///
|
///
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
BoltResult<communication::bolt::Vertex> ToBoltVertex(const storage::v3::VertexAccessor &vertex,
|
communication::bolt::Vertex ToBoltVertex(const storage::v3::VertexAccessor &vertex,
|
||||||
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
||||||
storage::v3::View view);
|
storage::v3::View view);
|
||||||
|
|
||||||
@ -48,7 +45,7 @@ BoltResult<communication::bolt::Vertex> ToBoltVertex(const storage::v3::VertexAc
|
|||||||
/// @param storage::v3::View for deciding which edge attributes are visible.
|
/// @param storage::v3::View for deciding which edge attributes are visible.
|
||||||
///
|
///
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
BoltResult<communication::bolt::Edge> ToBoltEdge(const storage::v3::EdgeAccessor &edge,
|
communication::bolt::Edge ToBoltEdge(const storage::v3::EdgeAccessor &edge,
|
||||||
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
||||||
storage::v3::View view);
|
storage::v3::View view);
|
||||||
|
|
||||||
@ -57,7 +54,7 @@ BoltResult<communication::bolt::Edge> ToBoltEdge(const storage::v3::EdgeAccessor
|
|||||||
/// @param storage::v3::View for ToBoltVertex and ToBoltEdge.
|
/// @param storage::v3::View for ToBoltVertex and ToBoltEdge.
|
||||||
///
|
///
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
BoltResult<communication::bolt::Path> ToBoltPath(const query::v2::accessors::Path &path,
|
communication::bolt::Path ToBoltPath(const query::v2::accessors::Path &path,
|
||||||
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
||||||
storage::v3::View view);
|
storage::v3::View view);
|
||||||
|
|
||||||
@ -66,7 +63,7 @@ BoltResult<communication::bolt::Path> ToBoltPath(const query::v2::accessors::Pat
|
|||||||
/// @param storage::v3::View for ToBoltVertex and ToBoltEdge.
|
/// @param storage::v3::View for ToBoltVertex and ToBoltEdge.
|
||||||
///
|
///
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
BoltResult<communication::bolt::Value> ToBoltValue(const query::v2::TypedValue &value,
|
communication::bolt::Value ToBoltValue(const query::v2::TypedValue &value,
|
||||||
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
const msgs::ShardRequestManagerInterface *shard_request_manager,
|
||||||
storage::v3::View view);
|
storage::v3::View view);
|
||||||
|
|
||||||
|
@ -481,27 +481,9 @@ class BoltSession final : public memgraph::communication::bolt::Session<memgraph
|
|||||||
const auto &summary = interpreter_.Pull(&stream, n, qid);
|
const auto &summary = interpreter_.Pull(&stream, n, qid);
|
||||||
std::map<std::string, memgraph::communication::bolt::Value> decoded_summary;
|
std::map<std::string, memgraph::communication::bolt::Value> decoded_summary;
|
||||||
for (const auto &kv : summary) {
|
for (const auto &kv : summary) {
|
||||||
auto maybe_value = memgraph::glue::v2::ToBoltValue(kv.second, interpreter_.GetShardRequestManager(),
|
auto bolt_value = memgraph::glue::v2::ToBoltValue(kv.second, interpreter_.GetShardRequestManager(),
|
||||||
memgraph::storage::v3::View::NEW);
|
memgraph::storage::v3::View::NEW);
|
||||||
if (maybe_value.HasError()) {
|
decoded_summary.emplace(kv.first, std::move(bolt_value));
|
||||||
switch (maybe_value.GetError().code) {
|
|
||||||
case memgraph::common::ErrorCode::DELETED_OBJECT:
|
|
||||||
case memgraph::common::ErrorCode::SERIALIZATION_ERROR:
|
|
||||||
case memgraph::common::ErrorCode::VERTEX_HAS_EDGES:
|
|
||||||
case memgraph::common::ErrorCode::PROPERTIES_DISABLED:
|
|
||||||
case memgraph::common::ErrorCode::NONEXISTENT_OBJECT:
|
|
||||||
case memgraph::common::ErrorCode::VERTEX_ALREADY_INSERTED:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED:
|
|
||||||
case memgraph::common::ErrorCode::OBJECT_NOT_FOUND:
|
|
||||||
throw memgraph::communication::bolt::ClientError("Unexpected storage error when streaming summary.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
decoded_summary.emplace(kv.first, std::move(*maybe_value));
|
|
||||||
}
|
}
|
||||||
return decoded_summary;
|
return decoded_summary;
|
||||||
} catch (const memgraph::query::v2::QueryException &e) {
|
} catch (const memgraph::query::v2::QueryException &e) {
|
||||||
@ -522,28 +504,8 @@ class BoltSession final : public memgraph::communication::bolt::Session<memgraph
|
|||||||
std::vector<memgraph::communication::bolt::Value> decoded_values;
|
std::vector<memgraph::communication::bolt::Value> decoded_values;
|
||||||
decoded_values.reserve(values.size());
|
decoded_values.reserve(values.size());
|
||||||
for (const auto &v : values) {
|
for (const auto &v : values) {
|
||||||
auto maybe_value = memgraph::glue::v2::ToBoltValue(v, shard_request_manager_, memgraph::storage::v3::View::NEW);
|
auto bolt_value = memgraph::glue::v2::ToBoltValue(v, shard_request_manager_, memgraph::storage::v3::View::NEW);
|
||||||
if (maybe_value.HasError()) {
|
decoded_values.emplace_back(std::move(bolt_value));
|
||||||
switch (maybe_value.GetError().code) {
|
|
||||||
case memgraph::common::ErrorCode::DELETED_OBJECT:
|
|
||||||
throw memgraph::communication::bolt::ClientError("Returning a deleted object as a result.");
|
|
||||||
case memgraph::common::ErrorCode::NONEXISTENT_OBJECT:
|
|
||||||
case memgraph::common::ErrorCode::OBJECT_NOT_FOUND:
|
|
||||||
throw memgraph::communication::bolt::ClientError("Returning a nonexistent object as a result.");
|
|
||||||
case memgraph::common::ErrorCode::VERTEX_HAS_EDGES:
|
|
||||||
case memgraph::common::ErrorCode::SERIALIZATION_ERROR:
|
|
||||||
case memgraph::common::ErrorCode::PROPERTIES_DISABLED:
|
|
||||||
case memgraph::common::ErrorCode::VERTEX_ALREADY_INSERTED:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY:
|
|
||||||
case memgraph::common::ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED:
|
|
||||||
throw memgraph::communication::bolt::ClientError("Unexpected storage error when streaming results.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
decoded_values.emplace_back(std::move(*maybe_value));
|
|
||||||
}
|
}
|
||||||
encoder_->MessageRecord(decoded_values);
|
encoder_->MessageRecord(decoded_values);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "storage/v3/id_types.hpp"
|
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
#include "utils/skip_list.hpp"
|
#include "utils/skip_list.hpp"
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ struct ShardError {
|
|||||||
: code{code}, source{fmt::format("{}:{}", location.file_name(), location.line())} {}
|
: code{code}, source{fmt::format("{}:{}", location.file_name(), location.line())} {}
|
||||||
|
|
||||||
common::ErrorCode code;
|
common::ErrorCode code;
|
||||||
// TODO Maybe add category
|
|
||||||
std::string message;
|
std::string message;
|
||||||
std::string source;
|
std::string source;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user