1
0
Fork 0

better tests

This commit is contained in:
Jan Christoph Uhde 2016-12-13 17:03:01 +01:00
parent 615b85e5f5
commit 3d17672feb
2 changed files with 64 additions and 34 deletions

View File

@ -4384,6 +4384,7 @@ bool applyGeoOptimization(bool near, ExecutionPlan* plan, GeoIndexInfo& first, G
plan->registerNode(inode); plan->registerNode(inode);
condition.release(); condition.release();
plan->replaceNode(first.collectionNode,inode);
replaceGeoCondition(plan, first); replaceGeoCondition(plan, first);
replaceGeoCondition(plan, second); replaceGeoCondition(plan, second);
@ -4402,7 +4403,6 @@ bool applyGeoOptimization(bool near, ExecutionPlan* plan, GeoIndexInfo& first, G
}; };
unlinkNode(first); unlinkNode(first);
plan->replaceNode(first.collectionNode,inode);
unlinkNode(second); unlinkNode(second);
//signal that plan has been changed //signal that plan has been changed

View File

@ -81,35 +81,35 @@ function optimizerRuleTestSuite() {
} }
return 0; return 0;
}; };
var hasSortNode = function (plan) { var hasSortNode = function (plan,query) {
assertEqual(findExecutionNodes(plan, "SortNode").length, 1, "Has SortNode"); assertEqual(findExecutionNodes(plan, "SortNode").length, 1, query.string + " Has SortNode ");
}; };
var hasNoSortNode = function (plan) { var hasNoSortNode = function (plan,query) {
assertEqual(findExecutionNodes(plan, "SortNode").length, 0, "Has no SortNode"); assertEqual(findExecutionNodes(plan, "SortNode").length, 0, query.string + " Has no SortNode");
}; };
var hasFilterNode = function (plan) { var hasFilterNode = function (plan,query) {
assertEqual(findExecutionNodes(plan, "FilterNode").length, 1, "Has FilterNode"); assertEqual(findExecutionNodes(plan, "FilterNode").length, 1, query.string + " Has FilterNode");
}; };
var hasNoFilterNode = function (plan) { var hasNoFilterNode = function (plan,query) {
assertEqual(findExecutionNodes(plan, "FilterNode").length, 0, "Has no FilterNode"); assertEqual(findExecutionNodes(plan, "FilterNode").length, 0, query.string + " Has no FilterNode");
}; };
var hasNoIndexNode = function (plan) { var hasNoIndexNode = function (plan,query) {
assertEqual(findExecutionNodes(plan, "IndexNode").length, 0, "Has no IndexNode"); assertEqual(findExecutionNodes(plan, "IndexNode").length, 0, query.string + " Has no IndexNode");
}; };
var hasNoResultsNode = function (plan) { var hasNoResultsNode = function (plan,query) {
assertEqual(findExecutionNodes(plan, "NoResultsNode").length, 1, "Has NoResultsNode"); assertEqual(findExecutionNodes(plan, "NoResultsNode").length, 1, query.string + " Has NoResultsNode");
}; };
var hasCalculationNodes = function (plan, countXPect) { var hasCalculationNodes = function (plan,query, countXPect) {
assertEqual(findExecutionNodes(plan, "CalculationNode").length, assertEqual(findExecutionNodes(plan, "CalculationNode").length,
countXPect, "Has " + countXPect + " CalculationNode"); countXPect, "Has " + countXPect + " CalculationNode");
}; };
var hasIndexNode = function (plan) { var hasIndexNode = function (plan,query) {
var rn = findExecutionNodes(plan, "IndexNode"); var rn = findExecutionNodes(plan,"IndexNode");
assertEqual(rn.length, 1, "Has IndexNode"); assertEqual(rn.length, 1, query.string + "Has IndexNode");
return; return;
}; };
var isNodeType = function(node, type) { var isNodeType = function(node, type) {
assertEqual(node.type, type, "check whether this node is of type "+type); assertEqual(node.type, type, query.string + " check whether this node is of type "+type);
}; };
var geodistance = function(latitude1, longitude1, latitude2, longitude2) { var geodistance = function(latitude1, longitude1, latitude2, longitude2) {
@ -175,16 +175,46 @@ function optimizerRuleTestSuite() {
var queries = [ var queries = [
//query clust sort filter index //query clust sort filter index
[ "FOR d IN " + colName + " SORT distance(d.lat,d.lon, 0 ,0 ) ASC LIMIT 1 RETURN d", false, false, false, true ], { string : "FOR d IN " + colName + " SORT distance(d.lat,d.lon, 0 ,0 ) ASC LIMIT 1 RETURN d"
[ "FOR d IN " + colName + " SORT distance(0, 0, d.lat,d.lon ) ASC LIMIT 1 RETURN d", false, false, false, true ], , cluster : false
[ "FOR d IN " + colName + " FILTER distance(0, 0, d.lat,d.lon ) < 1 LIMIT 1 RETURN d", false, false, false, true ], , sort : false
[ "FOR d IN " + colName + " SORT distance(0, 0, d.lat, d.lon) FILTER distance(0, 0, d.lat,d.lon ) < 1 LIMIT 1 RETURN d", false, false, false, true ], , filter : false
[ "FOR d IN " + colName + " SORT distance(0, 0, d.lat, d.lon) FILTER distance(0, 0, d.lat,d.lon ) < 1 LIMIT 1 RETURN d", false, false, false, true ], , index : true
[ "FOR i in 1..2 FOR d IN " + colName + " FILTER distance(0, 0, d.lat,d.lon ) < 1 && i > 1 LIMIT 1 RETURN d", false, false, true, false ], },
{ string : "FOR d IN " + colName + " SORT distance(0, 0, d.lat,d.lon ) ASC LIMIT 1 RETURN d"
, cluster : false
, sort : false
, filter : false
, index : true
},
{ string : "FOR d IN " + colName + " FILTER distance(0, 0, d.lat,d.lon ) < 1 LIMIT 1 RETURN d"
, cluster : false
, sort : false
, filter : false
, index : true
},
{ string : "FOR d IN " + colName + " SORT distance(0, 0, d.lat, d.lon) FILTER distance(0, 0, d.lat,d.lon ) < 1 LIMIT 1 RETURN d"
, cluster : false
, sort : false
, filter : false
, index : true
},
{ string : "FOR d IN " + colName + " SORT distance(0, 0, d.lat, d.lon) FILTER distance(0, 0, d.lat,d.lon ) < 1 LIMIT 1 RETURN d"
, cluster : false
, sort : false
, filter : false
, index : true
},
{ string : "FOR i in 1..2 FOR d IN " + colName + " FILTER distance(0, 0, d.lat,d.lon ) < 1 && i > 1 LIMIT 1 RETURN d"
, cluster : false
, sort : false
, filter : true
, index : false
},
]; ];
queries.forEach(function(query) { queries.forEach(function(query) {
var result = AQL_EXPLAIN(query[0]); var result = AQL_EXPLAIN(query.string);
// //optimized on cluster // //optimized on cluster
// if (query[1]) { // if (query[1]) {
@ -195,23 +225,23 @@ function optimizerRuleTestSuite() {
// } // }
//sort nodes //sort nodes
if (query[2]) { if (query.sort) {
hasSortNode(result); hasSortNode(result,query);
} else { } else {
hasNoSortNode(result); hasNoSortNode(result,query);
} }
//filter nodes //filter nodes
if (query[3]) { if (query.filter) {
hasFilterNode(result); hasFilterNode(result,query);
} else { } else {
hasNoFilterNode(result); hasNoFilterNode(result,query);
} }
if (query[4]) { if (query.index){
hasIndexNode(result); hasIndexNode(result,query);
} else { } else {
hasNoIndexNode(result); hasNoIndexNode(result,query);
} }
}); });