Extract vertex creation from FillUpSourceVertexSecondaryLabels
This commit is contained in:
parent
4d2036249e
commit
88487e2513
@ -12,11 +12,13 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <optional>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "parser/opencypher/parser.hpp"
|
#include "parser/opencypher/parser.hpp"
|
||||||
#include "query/v2/requests.hpp"
|
#include "query/v2/requests.hpp"
|
||||||
|
#include "storage/v2/vertex.hpp"
|
||||||
#include "storage/v2/view.hpp"
|
#include "storage/v2/view.hpp"
|
||||||
#include "storage/v3/bindings/ast/ast.hpp"
|
#include "storage/v3/bindings/ast/ast.hpp"
|
||||||
#include "storage/v3/bindings/cypher_main_visitor.hpp"
|
#include "storage/v3/bindings/cypher_main_visitor.hpp"
|
||||||
@ -180,8 +182,8 @@ std::vector<TypedValue> EvaluateVertexExpressions(DbAccessor &dba, const VertexA
|
|||||||
|
|
||||||
struct LocalError {};
|
struct LocalError {};
|
||||||
|
|
||||||
std::optional<msgs::Vertex> FillUpSourceVertexSecondaryLabels(const std::optional<VertexAccessor> &v_acc,
|
std::optional<std::vector<msgs::Label>> FillUpSourceVertexSecondaryLabels(const std::optional<VertexAccessor> &v_acc,
|
||||||
const msgs::ExpandOneRequest &req) {
|
const msgs::ExpandOneRequest &req) {
|
||||||
auto secondary_labels = v_acc->Labels(View::NEW);
|
auto secondary_labels = v_acc->Labels(View::NEW);
|
||||||
if (secondary_labels.HasError()) {
|
if (secondary_labels.HasError()) {
|
||||||
spdlog::debug("Encountered an error while trying to get the secondary labels of a vertex. Transaction id: {}",
|
spdlog::debug("Encountered an error while trying to get the secondary labels of a vertex. Transaction id: {}",
|
||||||
@ -190,13 +192,13 @@ std::optional<msgs::Vertex> FillUpSourceVertexSecondaryLabels(const std::optiona
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto &sec_labels = secondary_labels.GetValue();
|
auto &sec_labels = secondary_labels.GetValue();
|
||||||
msgs::Vertex source_vertex;
|
std::vector<msgs::Label> msgs_secondary_labels;
|
||||||
source_vertex.labels.reserve(sec_labels.size());
|
msgs_secondary_labels.reserve(sec_labels.size());
|
||||||
|
|
||||||
std::transform(sec_labels.begin(), sec_labels.end(), std::back_inserter(source_vertex.labels),
|
std::transform(sec_labels.begin(), sec_labels.end(), std::back_inserter(msgs_secondary_labels),
|
||||||
[](auto label_id) { return msgs::Label{.id = label_id}; });
|
[](auto label_id) { return msgs::Label{.id = label_id}; });
|
||||||
|
|
||||||
return source_vertex;
|
return msgs_secondary_labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::map<PropertyId, Value>> FillUpSourceVertexProperties(const std::optional<VertexAccessor> &v_acc,
|
std::optional<std::map<PropertyId, Value>> FillUpSourceVertexProperties(const std::optional<VertexAccessor> &v_acc,
|
||||||
@ -324,11 +326,13 @@ std::optional<msgs::ExpandOneResultRow> GetExpandOneResult(
|
|||||||
const auto primary_key = ConvertPropertyVector(src_vertex.second);
|
const auto primary_key = ConvertPropertyVector(src_vertex.second);
|
||||||
auto v_acc = acc.FindVertex(primary_key, View::NEW);
|
auto v_acc = acc.FindVertex(primary_key, View::NEW);
|
||||||
|
|
||||||
auto source_vertex = FillUpSourceVertexSecondaryLabels(v_acc, req);
|
msgs::Vertex source_vertex = {.id = src_vertex};
|
||||||
if (!source_vertex) {
|
if (const auto maybe_secondary_labels = FillUpSourceVertexSecondaryLabels(v_acc, req); maybe_secondary_labels) {
|
||||||
|
source_vertex.labels = *maybe_secondary_labels;
|
||||||
|
} else {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
source_vertex->id = src_vertex;
|
|
||||||
std::optional<std::map<PropertyId, Value>> src_vertex_properties;
|
std::optional<std::map<PropertyId, Value>> src_vertex_properties;
|
||||||
src_vertex_properties = FillUpSourceVertexProperties(v_acc, req, storage::v3::View::NEW, schema);
|
src_vertex_properties = FillUpSourceVertexProperties(v_acc, req, storage::v3::View::NEW, schema);
|
||||||
|
|
||||||
@ -345,7 +349,7 @@ std::optional<msgs::ExpandOneResultRow> GetExpandOneResult(
|
|||||||
auto [in_edges, out_edges] = fill_up_connecting_edges.value();
|
auto [in_edges, out_edges] = fill_up_connecting_edges.value();
|
||||||
|
|
||||||
msgs::ExpandOneResultRow result_row;
|
msgs::ExpandOneResultRow result_row;
|
||||||
result_row.src_vertex = std::move(*source_vertex);
|
result_row.src_vertex = std::move(source_vertex);
|
||||||
result_row.src_vertex_properties = std::move(*src_vertex_properties);
|
result_row.src_vertex_properties = std::move(*src_vertex_properties);
|
||||||
static constexpr bool kInEdges = true;
|
static constexpr bool kInEdges = true;
|
||||||
static constexpr bool kOutEdges = false;
|
static constexpr bool kOutEdges = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user