mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'aql2' of ssh://github.com/triAGENS/ArangoDB into aql2
This commit is contained in:
commit
46cb7304bf
|
@ -1215,7 +1215,7 @@ ExecutionNode* ExecutionPlan::fromJson (Ast* ast,
|
||||||
Json const& json) {
|
Json const& json) {
|
||||||
ExecutionNode* ret = nullptr;
|
ExecutionNode* ret = nullptr;
|
||||||
Json nodes = json.get("nodes");
|
Json nodes = json.get("nodes");
|
||||||
std::cout << nodes.toString() << "\n";
|
//std::cout << nodes.toString() << "\n";
|
||||||
|
|
||||||
if (! nodes.isList()) {
|
if (! nodes.isList()) {
|
||||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "nodes is not a list");
|
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "nodes is not a list");
|
||||||
|
|
|
@ -437,66 +437,90 @@ function getCompactPlan (explainResult) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function findExecutionNodes(plan, nodetype) {
|
function findExecutionNodes(plan, nodetype) {
|
||||||
var matches = [];
|
var matches = [];
|
||||||
plan.plan.nodes.forEach(function(node) {
|
plan.plan.nodes.forEach(function(node) {
|
||||||
if (node.type === nodetype) {
|
if (node.type === nodetype) {
|
||||||
|
|
||||||
matches.push(node);
|
matches.push(node);
|
||||||
}
|
}
|
||||||
else if (node.type === "SubqueryNode") {
|
else if (node.type === "SubqueryNode") {
|
||||||
var subPlan = {"plan" : node.subquery};
|
var subPlan = {"plan" : node.subquery};
|
||||||
matches = matches.concat(findExecutionNodes(subPlan, nodetype));
|
matches = matches.concat(findExecutionNodes(subPlan, nodetype));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findReferencedNodes(plan, testNode) {
|
function findReferencedNodes(plan, testNode) {
|
||||||
var matches = [];
|
var matches = [];
|
||||||
if (testNode.elements) {
|
if (testNode.elements) {
|
||||||
testNode.elements.forEach(function(element) {
|
testNode.elements.forEach(function(element) {
|
||||||
plan.plan.nodes.forEach(function(node) {
|
plan.plan.nodes.forEach(function(node) {
|
||||||
if (node.hasOwnProperty("outVariable") &&
|
if (node.hasOwnProperty("outVariable") &&
|
||||||
node.outVariable.id ===
|
node.outVariable.id ===
|
||||||
element.inVariable.id) {
|
element.inVariable.id) {
|
||||||
matches.push(node);
|
matches.push(node);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan.plan.nodes.forEach(function(node) {
|
plan.plan.nodes.forEach(function(node) {
|
||||||
if (node.outVariable.id === testNode.inVariable.id) {
|
if (node.outVariable.id === testNode.inVariable.id) {
|
||||||
matches.push(node);
|
matches.push(node);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getQueryMultiplePlansAndExecutions (query, bindVars) {
|
||||||
|
var plan;
|
||||||
|
var i;
|
||||||
|
var plans = [];
|
||||||
|
var allPlans = [];
|
||||||
|
var results = [];
|
||||||
|
var paramNone = { optimizer: { rules: [ "-all" ]}, verbosePlans: true};
|
||||||
|
var paramAllPlans = { allPlans : true, verbosePlans: true};
|
||||||
|
|
||||||
|
// first fetch the unmodified version
|
||||||
|
plans [0] = AQL_EXPLAIN(query, bindVars, paramNone);
|
||||||
|
// then all of the ones permuted by by the optimizer.
|
||||||
|
allPlans = AQL_EXPLAIN(query, bindVars, paramAllPlans);
|
||||||
|
|
||||||
|
for (i=0; i < allPlans.plans.length; i++) {
|
||||||
|
plans[i+1] = {'plan':allPlans.plans[i]};
|
||||||
|
}
|
||||||
|
// Now execute each of these variations.
|
||||||
|
for (i=0; i < plans.length; i++) {
|
||||||
|
results += AQL_EXECUTEJSON(plans[i].plan, paramNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {'plans': plans, 'results': results};
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- module exports
|
// --SECTION-- module exports
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
exports.isEqual = isEqual;
|
exports.isEqual = isEqual;
|
||||||
exports.getParseResults = getParseResults;
|
exports.getParseResults = getParseResults;
|
||||||
exports.assertParseError = assertParseError;
|
exports.assertParseError = assertParseError;
|
||||||
exports.getQueryExplanation = getQueryExplanation;
|
exports.getQueryExplanation = getQueryExplanation;
|
||||||
exports.getModifyQueryResults = getModifyQueryResults;
|
exports.getModifyQueryResults = getModifyQueryResults;
|
||||||
exports.getModifyQueryResults2 = getModifyQueryResults2;
|
exports.getModifyQueryResults2 = getModifyQueryResults2;
|
||||||
exports.getRawQueryResults = getRawQueryResults;
|
exports.getRawQueryResults = getRawQueryResults;
|
||||||
exports.getQueryResults = getQueryResults;
|
exports.getQueryResults = getQueryResults;
|
||||||
exports.getQueryResults2 = getQueryResults2;
|
exports.getQueryResults2 = getQueryResults2;
|
||||||
exports.getQueryResultsAQL2 = getQueryResultsAQL2;
|
exports.getQueryResultsAQL2 = getQueryResultsAQL2;
|
||||||
exports.assertQueryError = assertQueryError;
|
exports.assertQueryError = assertQueryError;
|
||||||
exports.assertQueryError2 = assertQueryError2;
|
exports.assertQueryError2 = assertQueryError2;
|
||||||
exports.getLinearizedPlan = getLinearizedPlan;
|
exports.getLinearizedPlan = getLinearizedPlan;
|
||||||
exports.getCompactPlan = getCompactPlan;
|
exports.getCompactPlan = getCompactPlan;
|
||||||
exports.findExecutionNodes = findExecutionNodes;
|
exports.findExecutionNodes = findExecutionNodes;
|
||||||
exports.findReferencedNodes = findReferencedNodes;
|
exports.findReferencedNodes = findReferencedNodes;
|
||||||
|
exports.getQueryMultiplePlansAndExecutions = getQueryMultiplePlansAndExecutions;
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue