mirror of https://gitee.com/bigwinds/arangodb
Removed V8Traverser files and made ShortestPathOptions an extension of Graph::BaseOptions. Now they are ready to use LokkupInfos as well. Now starting to move logic around
This commit is contained in:
parent
d9dbf2111a
commit
cf7136264b
|
@ -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 <velocypack/Iterator.h>
|
||||
|
@ -145,9 +145,9 @@ static std::unique_ptr<traverser::TraverserOptions> CreateTraversalOptions(
|
|||
return options;
|
||||
}
|
||||
|
||||
static std::unique_ptr<traverser::ShortestPathOptions> CreateShortestPathOptions(
|
||||
static std::unique_ptr<graph::ShortestPathOptions> CreateShortestPathOptions(
|
||||
arangodb::transaction::Methods* trx, AstNode const* node) {
|
||||
auto options = std::make_unique<traverser::ShortestPathOptions>(trx);
|
||||
auto options = std::make_unique<graph::ShortestPathOptions>(trx);
|
||||
|
||||
if (node != nullptr && node->type == NODE_TYPE_OBJECT) {
|
||||
size_t n = node->numMembers();
|
||||
|
|
|
@ -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<ManagedDocumentResult> _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<arangodb::traverser::EdgeCollectionInfo*> _collectionInfos;
|
||||
|
|
|
@ -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 <velocypack/Iterator.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
@ -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<traverser::ShortestPathOptions>& options)
|
||||
std::unique_ptr<graph::ShortestPathOptions>& 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<traverser::ShortestPathOptions>& options)
|
||||
std::unique_ptr<graph::ShortestPathOptions>& 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<traverser::ShortestPathOptions>(
|
||||
_options = std::make_unique<graph::ShortestPathOptions>(
|
||||
_plan->getAst()->query()->trx(), base);
|
||||
}
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ ExecutionNode* ShortestPathNode::clone(ExecutionPlan* plan,
|
|||
bool withProperties) const {
|
||||
|
||||
auto tmp =
|
||||
std::make_unique<arangodb::traverser::ShortestPathOptions>(*_options.get());
|
||||
std::make_unique<arangodb::graph::ShortestPathOptions>(*_options.get());
|
||||
auto c = new ShortestPathNode(plan, _id, _vocbase, _edgeColls, _directions,
|
||||
_inStartVariable, _startVertexId,
|
||||
_inTargetVariable, _targetVertexId, tmp);
|
||||
|
|
|
@ -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<traverser::ShortestPathOptions>& options);
|
||||
AstNode const* graph, std::unique_ptr<graph::ShortestPathOptions>& 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<traverser::ShortestPathOptions>& options);
|
||||
std::unique_ptr<graph::ShortestPathOptions>& 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<traverser::ShortestPathOptions> _options;
|
||||
std::unique_ptr<graph::ShortestPathOptions> _options;
|
||||
};
|
||||
|
||||
} // namespace arangodb::aql
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
@ -121,7 +118,6 @@ struct BaseOptions {
|
|||
virtual double estimateCost(size_t& nrItems) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
double costForLookupInfoList(std::vector<LookupInfo> 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<LookupInfo>&, aql::Ast* ast,
|
||||
std::string const& collectionName,
|
||||
|
@ -155,7 +152,6 @@ struct BaseOptions {
|
|||
|
||||
/// @brief the traverser cache
|
||||
std::unique_ptr<traverser::TraverserCache> _cache;
|
||||
|
||||
};
|
||||
|
||||
} // namespace graph
|
||||
|
|
|
@ -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 <velocypack/Iterator.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
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;
|
||||
}
|
|
@ -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
|
Loading…
Reference in New Issue