diff --git a/arangod/Aql/ExecutionPlan.cpp b/arangod/Aql/ExecutionPlan.cpp index e40dc86095..c12bfa200f 100644 --- a/arangod/Aql/ExecutionPlan.cpp +++ b/arangod/Aql/ExecutionPlan.cpp @@ -43,7 +43,7 @@ #include "Basics/SmallVector.h" #include "Basics/StaticStrings.h" #include "Basics/VelocyPackHelper.h" -#include "V8Server/V8Traverser.h" +#include "Graph/ShortestPathOptions.h" #include "VocBase/AccessMode.h" #include @@ -145,9 +145,9 @@ static std::unique_ptr CreateTraversalOptions( return options; } -static std::unique_ptr CreateShortestPathOptions( +static std::unique_ptr CreateShortestPathOptions( arangodb::transaction::Methods* trx, AstNode const* node) { - auto options = std::make_unique(trx); + auto options = std::make_unique(trx); if (node != nullptr && node->type == NODE_TYPE_OBJECT) { size_t n = node->numMembers(); diff --git a/arangod/Aql/ShortestPathBlock.h b/arangod/Aql/ShortestPathBlock.h index b5b88dd87f..1ba18fafba 100644 --- a/arangod/Aql/ShortestPathBlock.h +++ b/arangod/Aql/ShortestPathBlock.h @@ -26,13 +26,18 @@ #include "Aql/ExecutionBlock.h" #include "Aql/ShortestPathNode.h" -#include "V8Server/V8Traverser.h" +#include "Graph/ShortestPathOptions.h" namespace arangodb { class ManagedDocumentResult; +namespace graph { +class ShortestPathFinder; +} + namespace traverser { class EdgeCollectionInfo; +class ShortestPath; } namespace aql { @@ -94,7 +99,7 @@ class ShortestPathBlock : public ExecutionBlock { std::unique_ptr _mmdr; /// @brief options to compute the shortest path - traverser::ShortestPathOptions _opts; + graph::ShortestPathOptions _opts; /// @brief list of edge collection infos used to compute the path std::vector _collectionInfos; diff --git a/arangod/Aql/ShortestPathNode.cpp b/arangod/Aql/ShortestPathNode.cpp index 85a62af1b3..6b69e07c29 100644 --- a/arangod/Aql/ShortestPathNode.cpp +++ b/arangod/Aql/ShortestPathNode.cpp @@ -30,10 +30,10 @@ #include "Aql/ExecutionPlan.h" #include "Aql/Query.h" #include "Cluster/ClusterComm.h" +#include "Graph/ShortestPathOptions.h" #include "Indexes/Index.h" #include "Utils/CollectionNameResolver.h" #include "VocBase/LogicalCollection.h" -#include "V8Server/V8Traverser.h" #include #include @@ -84,7 +84,7 @@ ShortestPathNode::ShortestPathNode(ExecutionPlan* plan, size_t id, TRI_vocbase_t* vocbase, uint64_t direction, AstNode const* start, AstNode const* target, AstNode const* graph, - std::unique_ptr& options) + std::unique_ptr& options) : ExecutionNode(plan, id), _vocbase(vocbase), _vertexOutVariable(nullptr), @@ -240,7 +240,7 @@ ShortestPathNode::ShortestPathNode(ExecutionPlan* plan, size_t id, std::string const& startVertexId, Variable const* inTargetVariable, std::string const& targetVertexId, - std::unique_ptr& options) + std::unique_ptr& options) : ExecutionNode(plan, id), _vocbase(vocbase), _vertexOutVariable(nullptr), @@ -263,7 +263,7 @@ ShortestPathNode::ShortestPathNode(ExecutionPlan* plan, size_t id, ShortestPathNode::~ShortestPathNode() {} -void ShortestPathNode::fillOptions(arangodb::traverser::ShortestPathOptions& opts) const { +void ShortestPathNode::fillOptions(arangodb::graph::ShortestPathOptions& opts) const { if (!_options->weightAttribute.empty()) { opts.useWeight = true; opts.weightAttribute = _options->weightAttribute; @@ -395,7 +395,7 @@ ShortestPathNode::ShortestPathNode(ExecutionPlan* plan, // Flags if (base.hasKey("shortestPathFlags")) { - _options = std::make_unique( + _options = std::make_unique( _plan->getAst()->query()->trx(), base); } } @@ -456,7 +456,7 @@ ExecutionNode* ShortestPathNode::clone(ExecutionPlan* plan, bool withProperties) const { auto tmp = - std::make_unique(*_options.get()); + std::make_unique(*_options.get()); auto c = new ShortestPathNode(plan, _id, _vocbase, _edgeColls, _directions, _inStartVariable, _startVertexId, _inTargetVariable, _targetVertexId, tmp); diff --git a/arangod/Aql/ShortestPathNode.h b/arangod/Aql/ShortestPathNode.h index e8aa0c1d56..b82adf5c4b 100644 --- a/arangod/Aql/ShortestPathNode.h +++ b/arangod/Aql/ShortestPathNode.h @@ -31,7 +31,7 @@ namespace arangodb { -namespace traverser { +namespace graph { struct ShortestPathOptions; } namespace aql { @@ -46,7 +46,7 @@ class ShortestPathNode : public ExecutionNode { public: ShortestPathNode(ExecutionPlan* plan, size_t id, TRI_vocbase_t* vocbase, uint64_t direction, AstNode const* start, AstNode const* target, - AstNode const* graph, std::unique_ptr& options); + AstNode const* graph, std::unique_ptr& options); ShortestPathNode(ExecutionPlan* plan, arangodb::velocypack::Slice const& base); @@ -61,7 +61,7 @@ class ShortestPathNode : public ExecutionNode { std::string const& startVertexId, Variable const* inTargetVariable, std::string const& targetVertexId, - std::unique_ptr& options); + std::unique_ptr& options); public: /// @brief return the type of the node @@ -151,7 +151,7 @@ class ShortestPathNode : public ExecutionNode { } } - void fillOptions(arangodb::traverser::ShortestPathOptions&) const; + void fillOptions(arangodb::graph::ShortestPathOptions&) const; private: @@ -189,7 +189,7 @@ class ShortestPathNode : public ExecutionNode { Graph const* _graphObj; /// @brief Options for traversals - std::unique_ptr _options; + std::unique_ptr _options; }; } // namespace arangodb::aql diff --git a/arangod/CMakeLists.txt b/arangod/CMakeLists.txt index beec93bc9c..2ec87f5375 100644 --- a/arangod/CMakeLists.txt +++ b/arangod/CMakeLists.txt @@ -222,6 +222,7 @@ SET(ARANGOD_SOURCES Graph/BreadthFirstEnumerator.cpp Graph/ConstantWeightShortestPathFinder.cpp Graph/NeighborsEnumerator.cpp + Graph/ShortestPathOptions.cpp Indexes/Index.cpp Indexes/IndexIterator.cpp Indexes/SimpleAttributeEqualityMatcher.cpp @@ -315,7 +316,6 @@ SET(ARANGOD_SOURCES V8Server/FoxxQueuesFeature.cpp V8Server/V8Context.cpp V8Server/V8DealerFeature.cpp - V8Server/V8Traverser.cpp V8Server/v8-actions.cpp V8Server/v8-collection-util.cpp V8Server/v8-collection.cpp diff --git a/arangod/Graph/BaseOptions.h b/arangod/Graph/BaseOptions.h index cecd473aeb..80c1db333b 100644 --- a/arangod/Graph/BaseOptions.h +++ b/arangod/Graph/BaseOptions.h @@ -24,8 +24,8 @@ #ifndef ARANGOD_GRAPH_BASE_OPTIONS_H #define ARANGOD_GRAPH_BASE_OPTIONS_H 1 -#include "Basics/Common.h" #include "Aql/FixedVarExpressionContext.h" +#include "Basics/Common.h" #include "Cluster/ServerState.h" #include "Transaction/Methods.h" @@ -49,9 +49,7 @@ class Slice; namespace graph { struct BaseOptions { - protected: - struct LookupInfo { // This struct does only take responsibility for the expression // NOTE: The expression can be nullptr! @@ -76,7 +74,6 @@ struct BaseOptions { void buildEngineInfo(arangodb::velocypack::Builder&) const; double estimateCost(size_t& nrItems) const; - }; public: @@ -87,7 +84,7 @@ struct BaseOptions { explicit BaseOptions(BaseOptions const&); BaseOptions(arangodb::aql::Query*, arangodb::velocypack::Slice, - arangodb::velocypack::Slice); + arangodb::velocypack::Slice); virtual ~BaseOptions(); @@ -121,7 +118,6 @@ struct BaseOptions { virtual double estimateCost(size_t& nrItems) const = 0; protected: - double costForLookupInfoList(std::vector const& list, size_t& createItems) const; @@ -137,7 +133,8 @@ struct BaseOptions { aql::Expression* getEdgeExpression(size_t cursorId) const; - bool evaluateExpression(aql::Expression*, arangodb::velocypack::Slice varValue) const; + bool evaluateExpression(aql::Expression*, + arangodb::velocypack::Slice varValue) const; void injectLookupInfoInList(std::vector&, aql::Ast* ast, std::string const& collectionName, @@ -155,9 +152,8 @@ struct BaseOptions { /// @brief the traverser cache std::unique_ptr _cache; - }; -} // namespace graph -} // namespace arangodb +} // namespace graph +} // namespace arangodb #endif diff --git a/arangod/V8Server/V8Traverser.cpp b/arangod/Graph/ShortestPathOptions.cpp similarity index 82% rename from arangod/V8Server/V8Traverser.cpp rename to arangod/Graph/ShortestPathOptions.cpp index 50eea6b289..1cecf29e67 100644 --- a/arangod/V8Server/V8Traverser.cpp +++ b/arangod/Graph/ShortestPathOptions.cpp @@ -21,19 +21,20 @@ /// @author Michael Hackstein //////////////////////////////////////////////////////////////////////////////// -#include "V8Traverser.h" -#include "VocBase/LogicalCollection.h" -#include "VocBase/SingleServerTraverser.h" +#include "ShortestPathOptions.h" + +#include "Basics/VelocyPackHelper.h" #include #include using namespace arangodb; using namespace arangodb::basics; -using namespace arangodb::traverser; +using namespace arangodb::graph; + ShortestPathOptions::ShortestPathOptions(transaction::Methods* trx) - : BasicOptions(trx), + : BaseOptions(trx), direction("outbound"), useWeight(false), weightAttribute(""), @@ -43,7 +44,7 @@ ShortestPathOptions::ShortestPathOptions(transaction::Methods* trx) ShortestPathOptions::ShortestPathOptions(transaction::Methods* trx, VPackSlice const& info) - : BasicOptions(trx), + : BaseOptions(trx), direction("outbound"), useWeight(false), weightAttribute(""), @@ -60,6 +61,13 @@ ShortestPathOptions::ShortestPathOptions(transaction::Methods* trx, } } +ShortestPathOptions::~ShortestPathOptions() {} + +void ShortestPathOptions::buildEngineInfo(VPackBuilder& result) const { + // TODO Implement me! + BaseOptions::buildEngineInfo(result); +} + void ShortestPathOptions::setStart(std::string const& id) { start = id; startBuilder.clear(); @@ -83,3 +91,12 @@ void ShortestPathOptions::toVelocyPack(VPackBuilder& builder) const { builder.add("weightAttribute", VPackValue(weightAttribute)); builder.add("defaultWeight", VPackValue(defaultWeight)); } + +void ShortestPathOptions::toVelocyPackIndexes(VPackBuilder& builder) const { + // TODO Implement me +} + +double ShortestPathOptions::estimateCost(size_t& nrItems) const { + // TODO Implement me + return 0; +} diff --git a/arangod/V8Server/V8Traverser.h b/arangod/Graph/ShortestPathOptions.h similarity index 65% rename from arangod/V8Server/V8Traverser.h rename to arangod/Graph/ShortestPathOptions.h index b694fd5175..16cf9cb0ad 100644 --- a/arangod/V8Server/V8Traverser.h +++ b/arangod/Graph/ShortestPathOptions.h @@ -21,41 +21,27 @@ /// @author Michael Hackstein //////////////////////////////////////////////////////////////////////////////// -#ifndef ARANGOD_V8_SERVER_V8_TRAVERSER_H -#define ARANGOD_V8_SERVER_V8_TRAVERSER_H 1 +#ifndef ARANGOD_GRAPH_SHORTEST_PATH_OPTIONS_H +#define ARANGOD_GRAPH_SHORTEST_PATH_OPTIONS_H 1 -#include "Basics/VelocyPackHelper.h" -#include "VocBase/Traverser.h" +#include "Graph/BaseOptions.h" namespace arangodb { +namespace transaction { +class Methods; +} + namespace velocypack { +class Builder; class Slice; } -} +namespace graph { -namespace arangodb { -namespace traverser { - -// A collection of shared options used in several functions. -// Should not be used directly, use specialization instead. -struct BasicOptions { - transaction::Methods* _trx; - - protected: - explicit BasicOptions(transaction::Methods* trx) : _trx(trx) {} - - virtual ~BasicOptions() {} +struct ShortestPathOptions : public BaseOptions { public: std::string start; - - public: - transaction::Methods* trx() { return _trx; } -}; - -struct ShortestPathOptions : BasicOptions { - public: std::string direction; bool useWeight; std::string weightAttribute; @@ -71,15 +57,31 @@ struct ShortestPathOptions : BasicOptions { ShortestPathOptions(transaction::Methods* trx, arangodb::velocypack::Slice const& info); + ~ShortestPathOptions(); + + // Creates a complete Object containing all EngineInfo + // in the given builder. + void buildEngineInfo(arangodb::velocypack::Builder&) const override; + void setStart(std::string const&); void setEnd(std::string const&); arangodb::velocypack::Slice getStart() const; arangodb::velocypack::Slice getEnd() const; - void toVelocyPack(arangodb::velocypack::Builder&) const; + /// @brief Build a velocypack for cloning in the plan. + void toVelocyPack(arangodb::velocypack::Builder&) const override; + + // Creates a complete Object containing all index information + // in the given builder. + void toVelocyPackIndexes(arangodb::velocypack::Builder&) const override; + + /// @brief Estimate the total cost for this operation + double estimateCost(size_t& nrItems) const override; + }; -} -} + +} // namespace graph +} // namespace arangodb #endif