1
0
Fork 0

The TraverserEngine now honors variables in conditions properly

This commit is contained in:
Michael Hackstein 2016-08-09 16:28:07 +02:00
parent 3dedde1688
commit ec31db017d
4 changed files with 35 additions and 3 deletions

View File

@ -838,6 +838,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
//
// {
// "options": <options.toVelocyPack>,
// "variables": [<vars used in conditions>], // optional
// "shards": {
// "edges" : [
// [ <shards of edge collection 1> ],
@ -854,6 +855,19 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
query->vocbase()->_name) +
"/_internal/traverser");
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;
for (auto const& list : mappingServerToCollections) {
std::unordered_set<std::string> shardSet;
@ -861,6 +875,10 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
engineInfo.openObject();
engineInfo.add(VPackValue("options"));
engineInfo.add(optsBuilder.slice());
if (hasVars) {
engineInfo.add(VPackValue("variables"));
engineInfo.add(varInfo.slice());
}
engineInfo.add(VPackValue("shards"));
engineInfo.openObject();

View File

@ -305,8 +305,6 @@ class TraversalNode : public ExecutionNode {
/// traversal
bool _specializedNeighborsSearch;
#warning THIS IS ALL NEW STUFF
/// @brief Temporary pseudo variable for the currently traversed object.
Variable const* _tmpObjVariable;

View File

@ -24,6 +24,7 @@
#include "TraverserEngine.h"
#include "Basics/Exceptions.h"
#include "Aql/Ast.h"
#include "Aql/Query.h"
#include "Utils/AqlTransaction.h"
#include "Utils/CollectionNameResolver.h"
@ -37,6 +38,7 @@ using namespace arangodb::traverser;
static const std::string OPTIONS = "options";
static const std::string SHARDS = "shards";
static const std::string EDGES = "edges";
static const std::string VARIABLES = "variables";
static const std::string VERTICES = "vertices";
TraverserEngine::TraverserEngine(TRI_vocbase_t* vocbase,
@ -103,6 +105,21 @@ TraverserEngine::TraverserEngine(TRI_vocbase_t* vocbase,
auto opts = std::make_shared<VPackBuilder>();
_query = new aql::Query(true, vocbase, "", 0, params, opts, aql::PART_DEPENDENT);
_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.
// We also setup indexes before we lock.
_opts.reset(new TraverserOptions(_query, optsSlice, edgesSlice));

View File

@ -101,7 +101,6 @@ void InternalRestTraverserHandler::createEngine() {
"Expected an object with traverser information as body parameter");
return;
}
traverser::TraverserEngineID id = _registry->createNew(_vocbase, parsedBody->slice());
TRI_ASSERT(id != 0);
VPackBuilder resultBuilder;