From 7469cc7becf1f5f26bd71f8d62cba01905cb8759 Mon Sep 17 00:00:00 2001 From: Michael Hackstein Date: Wed, 12 Apr 2017 09:05:54 +0200 Subject: [PATCH] Reenabled ShortestPath with AttributeWeight. Was accidentially disabled by options modifications. --- arangod/Aql/ShortestPathBlock.cpp | 4 ++-- arangod/Graph/ShortestPathOptions.cpp | 6 ++++-- arangod/Graph/ShortestPathOptions.h | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arangod/Aql/ShortestPathBlock.cpp b/arangod/Aql/ShortestPathBlock.cpp index 3e7f13d074..15bc5582d5 100644 --- a/arangod/Aql/ShortestPathBlock.cpp +++ b/arangod/Aql/ShortestPathBlock.cpp @@ -250,7 +250,7 @@ ShortestPathBlock::ShortestPathBlock(ExecutionEngine* engine, _path = std::make_unique(); if (arangodb::ServerState::instance()->isCoordinator()) { - if (_opts->useWeight) { + if (_opts->useWeight()) { _finder.reset(new arangodb::graph::AttributeWeightShortestPathFinder( EdgeWeightExpanderCluster(this, false), EdgeWeightExpanderCluster(this, true), _opts->bidirectional)); @@ -259,7 +259,7 @@ ShortestPathBlock::ShortestPathBlock(ExecutionEngine* engine, new arangodb::graph::ConstantWeightShortestPathFinder(this)); } } else { - if (_opts->useWeight) { + if (_opts->useWeight()) { _finder.reset(new arangodb::graph::AttributeWeightShortestPathFinder( EdgeWeightExpanderLocal(this, false), EdgeWeightExpanderLocal(this, true), _opts->bidirectional)); diff --git a/arangod/Graph/ShortestPathOptions.cpp b/arangod/Graph/ShortestPathOptions.cpp index fbee3b0068..d3bb35fa77 100644 --- a/arangod/Graph/ShortestPathOptions.cpp +++ b/arangod/Graph/ShortestPathOptions.cpp @@ -35,7 +35,6 @@ using namespace arangodb::graph; ShortestPathOptions::ShortestPathOptions(transaction::Methods* trx) : BaseOptions(trx), direction("outbound"), - useWeight(false), weightAttribute(""), defaultWeight(1), bidirectional(true), @@ -45,7 +44,6 @@ ShortestPathOptions::ShortestPathOptions(transaction::Methods* trx, VPackSlice const& info) : BaseOptions(trx), direction("outbound"), - useWeight(false), weightAttribute(""), defaultWeight(1), bidirectional(true), @@ -85,6 +83,10 @@ VPackSlice ShortestPathOptions::getStart() const { VPackSlice ShortestPathOptions::getEnd() const { return endBuilder.slice(); } +bool ShortestPathOptions::useWeight() const { + return !weightAttribute.empty(); +} + void ShortestPathOptions::toVelocyPack(VPackBuilder& builder) const { VPackObjectBuilder guard(&builder); builder.add("weightAttribute", VPackValue(weightAttribute)); diff --git a/arangod/Graph/ShortestPathOptions.h b/arangod/Graph/ShortestPathOptions.h index 8b5f4e3cb0..5b802cc5b1 100644 --- a/arangod/Graph/ShortestPathOptions.h +++ b/arangod/Graph/ShortestPathOptions.h @@ -42,7 +42,6 @@ struct ShortestPathOptions : public BaseOptions { public: std::string start; std::string direction; - bool useWeight; std::string weightAttribute; double defaultWeight; bool bidirectional; @@ -68,6 +67,9 @@ struct ShortestPathOptions : public BaseOptions { arangodb::velocypack::Slice getStart() const; arangodb::velocypack::Slice getEnd() const; + /// @brief Test if we have to use a weight attribute + bool useWeight() const; + /// @brief Build a velocypack for cloning in the plan. void toVelocyPack(arangodb::velocypack::Builder&) const override;