mirror of https://gitee.com/bigwinds/arangodb
The TraverserEngine now honors variables in conditions properly
This commit is contained in:
parent
3dedde1688
commit
ec31db017d
|
@ -838,6 +838,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
||||||
//
|
//
|
||||||
// {
|
// {
|
||||||
// "options": <options.toVelocyPack>,
|
// "options": <options.toVelocyPack>,
|
||||||
|
// "variables": [<vars used in conditions>], // optional
|
||||||
// "shards": {
|
// "shards": {
|
||||||
// "edges" : [
|
// "edges" : [
|
||||||
// [ <shards of edge collection 1> ],
|
// [ <shards of edge collection 1> ],
|
||||||
|
@ -854,6 +855,19 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
||||||
query->vocbase()->_name) +
|
query->vocbase()->_name) +
|
||||||
"/_internal/traverser");
|
"/_internal/traverser");
|
||||||
auto cc = arangodb::ClusterComm::instance();
|
auto cc = arangodb::ClusterComm::instance();
|
||||||
|
bool hasVars = false;
|
||||||
|
VPackBuilder varInfo;
|
||||||
|
std::vector<aql::Variable const*> vars;
|
||||||
|
en->getConditionVariables(vars);
|
||||||
|
if (!vars.empty()) {
|
||||||
|
hasVars = true;
|
||||||
|
varInfo.openArray();
|
||||||
|
for (auto v : vars) {
|
||||||
|
v->toVelocyPack(varInfo);
|
||||||
|
}
|
||||||
|
varInfo.close();
|
||||||
|
}
|
||||||
|
|
||||||
VPackBuilder engineInfo;
|
VPackBuilder engineInfo;
|
||||||
for (auto const& list : mappingServerToCollections) {
|
for (auto const& list : mappingServerToCollections) {
|
||||||
std::unordered_set<std::string> shardSet;
|
std::unordered_set<std::string> shardSet;
|
||||||
|
@ -861,6 +875,10 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
||||||
engineInfo.openObject();
|
engineInfo.openObject();
|
||||||
engineInfo.add(VPackValue("options"));
|
engineInfo.add(VPackValue("options"));
|
||||||
engineInfo.add(optsBuilder.slice());
|
engineInfo.add(optsBuilder.slice());
|
||||||
|
if (hasVars) {
|
||||||
|
engineInfo.add(VPackValue("variables"));
|
||||||
|
engineInfo.add(varInfo.slice());
|
||||||
|
}
|
||||||
|
|
||||||
engineInfo.add(VPackValue("shards"));
|
engineInfo.add(VPackValue("shards"));
|
||||||
engineInfo.openObject();
|
engineInfo.openObject();
|
||||||
|
|
|
@ -305,8 +305,6 @@ class TraversalNode : public ExecutionNode {
|
||||||
/// traversal
|
/// traversal
|
||||||
bool _specializedNeighborsSearch;
|
bool _specializedNeighborsSearch;
|
||||||
|
|
||||||
#warning THIS IS ALL NEW STUFF
|
|
||||||
|
|
||||||
/// @brief Temporary pseudo variable for the currently traversed object.
|
/// @brief Temporary pseudo variable for the currently traversed object.
|
||||||
Variable const* _tmpObjVariable;
|
Variable const* _tmpObjVariable;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "TraverserEngine.h"
|
#include "TraverserEngine.h"
|
||||||
|
|
||||||
#include "Basics/Exceptions.h"
|
#include "Basics/Exceptions.h"
|
||||||
|
#include "Aql/Ast.h"
|
||||||
#include "Aql/Query.h"
|
#include "Aql/Query.h"
|
||||||
#include "Utils/AqlTransaction.h"
|
#include "Utils/AqlTransaction.h"
|
||||||
#include "Utils/CollectionNameResolver.h"
|
#include "Utils/CollectionNameResolver.h"
|
||||||
|
@ -37,6 +38,7 @@ using namespace arangodb::traverser;
|
||||||
static const std::string OPTIONS = "options";
|
static const std::string OPTIONS = "options";
|
||||||
static const std::string SHARDS = "shards";
|
static const std::string SHARDS = "shards";
|
||||||
static const std::string EDGES = "edges";
|
static const std::string EDGES = "edges";
|
||||||
|
static const std::string VARIABLES = "variables";
|
||||||
static const std::string VERTICES = "vertices";
|
static const std::string VERTICES = "vertices";
|
||||||
|
|
||||||
TraverserEngine::TraverserEngine(TRI_vocbase_t* vocbase,
|
TraverserEngine::TraverserEngine(TRI_vocbase_t* vocbase,
|
||||||
|
@ -103,6 +105,21 @@ TraverserEngine::TraverserEngine(TRI_vocbase_t* vocbase,
|
||||||
auto opts = std::make_shared<VPackBuilder>();
|
auto opts = std::make_shared<VPackBuilder>();
|
||||||
_query = new aql::Query(true, vocbase, "", 0, params, opts, aql::PART_DEPENDENT);
|
_query = new aql::Query(true, vocbase, "", 0, params, opts, aql::PART_DEPENDENT);
|
||||||
_query->injectTransaction(_trx);
|
_query->injectTransaction(_trx);
|
||||||
|
|
||||||
|
VPackSlice variablesSlice = info.get(VARIABLES);
|
||||||
|
if (!variablesSlice.isNone()) {
|
||||||
|
if (!variablesSlice.isArray()) {
|
||||||
|
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||||
|
TRI_ERROR_BAD_PARAMETER,
|
||||||
|
"The optional " + VARIABLES + " has to be an array.");
|
||||||
|
}
|
||||||
|
for (auto v : VPackArrayIterator(variablesSlice)) {
|
||||||
|
// TODO do we have to keep the variable somewhere?
|
||||||
|
_query->ast()->variables()->createVariable(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_trx->begin(); // We begin the transaction before we lock.
|
_trx->begin(); // We begin the transaction before we lock.
|
||||||
// We also setup indexes before we lock.
|
// We also setup indexes before we lock.
|
||||||
_opts.reset(new TraverserOptions(_query, optsSlice, edgesSlice));
|
_opts.reset(new TraverserOptions(_query, optsSlice, edgesSlice));
|
||||||
|
|
|
@ -101,7 +101,6 @@ void InternalRestTraverserHandler::createEngine() {
|
||||||
"Expected an object with traverser information as body parameter");
|
"Expected an object with traverser information as body parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
traverser::TraverserEngineID id = _registry->createNew(_vocbase, parsedBody->slice());
|
traverser::TraverserEngineID id = _registry->createNew(_vocbase, parsedBody->slice());
|
||||||
TRI_ASSERT(id != 0);
|
TRI_ASSERT(id != 0);
|
||||||
VPackBuilder resultBuilder;
|
VPackBuilder resultBuilder;
|
||||||
|
|
Loading…
Reference in New Issue