8 #include "common/datatypes/Value.h"
9 #include "common/datatypes/Vertex.h"
10 #include "common/thrift/ThriftTypes.h"
19 std::unordered_map<std::string, Value> props;
23 : dst(s.dst), type(s.type), name(s.name), ranking(s.ranking), props(s.props) {}
25 : dst(std::move(s.dst)),
26 type(std::move(s.type)),
27 name(std::move(s.name)),
28 ranking(std::move(s.ranking)),
29 props(std::move(s.props)) {}
34 std::unordered_map<std::string, Value> p) noexcept
35 : dst(std::move(d)), type(t), name(std::move(n)), ranking(r), props(std::move(p)) {}
49 std::string toString()
const {
51 os <<
"-[" << name <<
"(" << type <<
")]->"
53 <<
"@" << ranking <<
" ";
54 for (
const auto& prop : props) {
55 os << prop.first <<
":" << prop.second <<
",";
62 Step& operator=(
Step&& rhs) noexcept {
64 dst = std::move(rhs.dst);
65 type = std::move(rhs.type);
66 name = std::move(rhs.name);
67 ranking = std::move(rhs.ranking);
68 props = std::move(rhs.props);
73 Step& operator=(
const Step& rhs) noexcept {
78 ranking = rhs.ranking;
84 bool operator==(
const Step& rhs)
const {
85 return dst == rhs.dst && type == rhs.type && name == rhs.name && ranking == rhs.ranking &&
89 bool operator<(
const Step& rhs)
const {
93 if (type != rhs.dst) {
94 return type < rhs.type;
96 if (ranking != rhs.ranking) {
97 return ranking < rhs.ranking;
99 if (props.size() != rhs.props.size()) {
100 return props.size() < rhs.props.size();
108 std::vector<Step> steps;
112 Path(
Path&& p) noexcept : src(std::move(p.src)), steps(std::move(p.steps)) {}
113 Path(
Vertex v, std::vector<Step> s) : src(std::move(v)), steps(std::move(s)) {}
124 std::string toString()
const {
125 std::stringstream os;
126 os <<
"(" << src <<
")";
128 for (
const auto& s : steps) {
135 Path& operator=(
Path&& rhs) noexcept {
137 src = std::move(rhs.src);
138 steps = std::move(rhs.steps);
143 Path& operator=(
const Path& rhs) noexcept {
151 bool operator==(
const Path& rhs)
const {
152 return src == rhs.src && steps == rhs.steps;
155 void addStep(
Step step) {
156 steps.emplace_back(std::move(step));
163 bool append(
Path path);
165 bool operator<(
const Path& rhs)
const {
166 if (src != rhs.src) {
167 return src < rhs.src;
169 if (steps != rhs.steps) {
170 return steps < rhs.steps;
175 bool hasDuplicateEdges()
const;
176 bool hasDuplicateVertices()
const;
179 inline void swap(
Step& a,
Step& b) {
180 auto tmp = std::move(a);
185 inline std::ostream& operator<<(std::ostream& os,
const Path& p) {
186 return os << p.toString();
194 struct hash<nebula::Step> {
195 std::size_t operator()(
const nebula::Step& h)
const noexcept;
199 struct hash<nebula::Path> {
200 std::size_t operator()(
const nebula::Path& h)
const noexcept;