mirror of https://gitee.com/bigwinds/arangodb
finalize test for the time being.
This commit is contained in:
parent
02207d5f70
commit
9524863c44
|
@ -175,31 +175,13 @@ function optimizerRuleTestSuite() {
|
|||
skiplist = null;
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test that rule has no effect when explicitly disabled
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testRuleDisabled : function () {
|
||||
/*
|
||||
var queries = [
|
||||
"LET a = 1 FOR i IN 1..10 FILTER a == 1 RETURN i",
|
||||
"FOR i IN 1..10 LET a = 25 RETURN i",
|
||||
"FOR i IN 1..10 LET a = 1 LET b = 2 LET c = 3 FILTER i > 3 LET d = 1 RETURN i"
|
||||
];
|
||||
|
||||
queries.forEach(function(query) {
|
||||
var result = AQL_EXPLAIN(query, { }, { optimizer: { rules: [ "-all" ] } });
|
||||
assertEqual([ ], result.plan.rules);
|
||||
});
|
||||
*/
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test that rule has no effect
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testRuleNoEffect : function () {
|
||||
/*
|
||||
|
||||
var queries = [
|
||||
|
||||
"FOR v IN " + colName + " SORT v.c RETURN [v.a, v.b]",
|
||||
|
@ -214,15 +196,13 @@ function optimizerRuleTestSuite() {
|
|||
|
||||
queries.forEach(function(query) {
|
||||
|
||||
// require("internal").print(query);
|
||||
var result = AQL_EXPLAIN(query, { }, paramIFS);
|
||||
// require("internal").print(result);
|
||||
assertEqual([], result.plan.rules, query);
|
||||
});
|
||||
*/
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test that rule has an effect
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -240,12 +220,10 @@ function optimizerRuleTestSuite() {
|
|||
var i = 0;
|
||||
queries.forEach(function(query) {
|
||||
|
||||
//require("internal").print(query);
|
||||
var result = AQL_EXPLAIN(query, { }, paramIFS);
|
||||
assertEqual([ ruleName ], result.plan.rules, query);
|
||||
QResults[0] = AQL_EXECUTE(query, { }, paramNone).json;
|
||||
QResults[1] = AQL_EXECUTE(query, { }, paramIFS ).json;
|
||||
// require("internal").print(result);
|
||||
|
||||
assertTrue(isEqual(QResults[0], QResults[1]), "Result " + i + " is Equal?");
|
||||
i++;
|
||||
|
@ -254,6 +232,10 @@ function optimizerRuleTestSuite() {
|
|||
},
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test that rule has an effect, but the sort is kept in place since
|
||||
// the index can't fullfill all the sorting.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testRuleHasEffectButSortsStill : function () {
|
||||
|
||||
var queries = [
|
||||
|
@ -263,9 +245,8 @@ function optimizerRuleTestSuite() {
|
|||
var QResults = [];
|
||||
var i = 0;
|
||||
queries.forEach(function(query) {
|
||||
// require("internal").print(query);
|
||||
|
||||
var result = AQL_EXPLAIN(query, { }, paramIFS);
|
||||
// require("internal").print(result);
|
||||
assertEqual([ ruleName ], result.plan.rules);
|
||||
hasIndexRangeNode_WithRanges(result, false);
|
||||
hasSortNode(result);
|
||||
|
@ -276,55 +257,9 @@ function optimizerRuleTestSuite() {
|
|||
});
|
||||
|
||||
},
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test generated plans
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
testPlans : function () {
|
||||
var plans = [
|
||||
|
||||
[ "FOR i IN 1..10 LET a = 1 RETURN i", [ "SingletonNode", "CalculationNode", "CalculationNode", "EnumerateListNode", "ReturnNode" ] ],
|
||||
[ "FOR i IN 1..10 FILTER i == 1 LET a = 1 RETURN i", [ "SingletonNode", "CalculationNode", "CalculationNode", "EnumerateListNode", "CalculationNode", "FilterNode", "ReturnNode" ] ]
|
||||
];
|
||||
|
||||
plans.forEach(function(plan) {
|
||||
var result = AQL_EXPLAIN(plan[0], { }, paramIFS);
|
||||
assertEqual([ ruleName ], result.plan.rules, plan[0]);
|
||||
assertEqual(plan[1], helper.getCompactPlan(result).map(function(node) { return node.type; }), plan[0]);
|
||||
});
|
||||
},
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test results
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
testResults : function () {
|
||||
var queries = [
|
||||
[ "FOR i IN 1..10 LET a = 1 RETURN i", [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] ],
|
||||
[ "FOR i IN 1..10 LET a = 1 RETURN a", [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ],
|
||||
[ "FOR i IN 1..10 FILTER i == 1 LET a = 1 RETURN i", [ 1 ] ],
|
||||
[ "FOR i IN 1..10 FILTER i == 1 LET a = 1 RETURN a", [ 1 ] ],
|
||||
];
|
||||
|
||||
queries.forEach(function(query) {
|
||||
var planDisabled = AQL_EXPLAIN(query[0], { }, { optimizer: { rules: [ "+all", "-" + ruleName ] } });
|
||||
var planEnabled = AQL_EXPLAIN(query[0], { }, paramIFS);
|
||||
|
||||
var resultDisabled = AQL_EXECUTE(query[0], { }, { optimizer: { rules: [ "+all", "-" + ruleName ] } });
|
||||
var resultEnabled = AQL_EXECUTE(query[0], { }, paramIFS);
|
||||
|
||||
assertTrue(planDisabled.plan.rules.indexOf(ruleName) === -1, query[0]);
|
||||
assertTrue(planEnabled.plan.rules.indexOf(ruleName) !== -1, query[0]);
|
||||
|
||||
assertEqual(resultDisabled.json, query[1], query[0]);
|
||||
assertEqual(resultEnabled.json, query[1], query[0]);
|
||||
});
|
||||
},
|
||||
*/
|
||||
/*
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- sortToIndexRange
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -343,8 +278,6 @@ function optimizerRuleTestSuite() {
|
|||
QResults[0] = AQL_EXECUTE(query, { }, paramNone).json.sort(sortArray);
|
||||
|
||||
// -> use-index-for-sort alone.
|
||||
XPresult = AQL_EXPLAIN(query, { }, paramNone);
|
||||
|
||||
XPresult = AQL_EXPLAIN(query, { }, paramIFS);
|
||||
QResults[1] = AQL_EXECUTE(query, { }, paramIFS).json;
|
||||
// our rule should have been applied.
|
||||
|
@ -360,7 +293,10 @@ function optimizerRuleTestSuite() {
|
|||
},
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that this rule has an effect, but the sort is kept in
|
||||
// place since the index can't fullfill all of the sorting criteria.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testSortMoreThanIndexed: function () {
|
||||
|
||||
var query = "FOR v IN " + colName + " FILTER v.a == 1 SORT v.a, v.c RETURN [v.a, v.b, v.c]";
|
||||
|
@ -379,7 +315,6 @@ function optimizerRuleTestSuite() {
|
|||
// our rule should be there.
|
||||
assertEqual([ ruleName ], XPresult.plan.rules);
|
||||
// The sortnode and its calculation node should have been removed.
|
||||
// require("internal").print(XPresult);
|
||||
|
||||
hasSortNode(XPresult);
|
||||
hasCalculationNodes(XPresult, 4);
|
||||
|
@ -419,6 +354,10 @@ function optimizerRuleTestSuite() {
|
|||
}
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that an index range fullfills everything the sort does,
|
||||
// and thus the sort is removed.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testRangeSuperseedsSort: function () {
|
||||
|
||||
var query = "FOR v IN " + colName + " FILTER v.a == 1 SORT v.a RETURN [v.a, v.b, v.c]";
|
||||
|
@ -472,11 +411,74 @@ function optimizerRuleTestSuite() {
|
|||
|
||||
},
|
||||
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that an index range fullfills everything the sort does,
|
||||
// and thus the sort is removed; multi-dimensional indexes are utilized.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testRangeSuperseedsSort2: function () {
|
||||
|
||||
var query = "FOR v IN " + colName + " FILTER v.a == 1 SORT v.a, v.b RETURN [v.a, v.b, v.c]";
|
||||
var XPresult;
|
||||
var QResults=[];
|
||||
var i;
|
||||
|
||||
// the index we will compare to sorts by a & b, so we need to re-sort the result here to accomplish similarity.
|
||||
|
||||
QResults[0] = AQL_EXECUTE(query, { }, paramNone).json;
|
||||
|
||||
// -> use-index-for-sort alone.
|
||||
QResults[1] = AQL_EXECUTE(query, { }, paramIFS).json;
|
||||
XPresult = AQL_EXPLAIN(query, { }, paramIFS);
|
||||
// our rule should be there.
|
||||
assertEqual([ ruleName ], XPresult.plan.rules);
|
||||
// The sortnode and its calculation node should have been removed.
|
||||
hasNoSortNode(XPresult);
|
||||
hasCalculationNodes(XPresult, 2);
|
||||
// The IndexRangeNode created by this rule is simple; it shouldn't have ranges.
|
||||
hasIndexRangeNode_WithRanges(XPresult, false);
|
||||
|
||||
// -> combined use-index-for-sort and use-index-range
|
||||
QResults[2] = AQL_EXECUTE(query, { }, paramBoth).json;
|
||||
|
||||
XPresult = AQL_EXPLAIN(query, { }, paramBoth);
|
||||
|
||||
assertEqual([ secondRuleName, ruleName ].sort(), XPresult.plan.rules.sort());
|
||||
// The sortnode and its calculation node should have been removed.
|
||||
hasNoSortNode(XPresult);
|
||||
hasCalculationNodes(XPresult, 2);
|
||||
// The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
hasIndexRangeNode_WithRanges(XPresult, true);
|
||||
|
||||
// -> use-index-range alone.
|
||||
QResults[3] = AQL_EXECUTE(query, { }, paramIR).json;
|
||||
XPresult = AQL_EXPLAIN(query, { }, paramIR);
|
||||
assertEqual([ secondRuleName ], XPresult.plan.rules);
|
||||
// the sortnode and its calculation node should be there.
|
||||
hasSortNode(XPresult);
|
||||
hasCalculationNodes(XPresult, 4);
|
||||
// we should be able to find exactly one sortnode property - its a Calculation node.
|
||||
var sortProperty = findReferencedNodes(XPresult, findExecutionNodes(XPresult, "SortNode")[0]);
|
||||
|
||||
assertEqual(sortProperty.length, 2);
|
||||
isNodeType(sortProperty[0], "CalculationNode");
|
||||
// The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
hasIndexRangeNode_WithRanges(XPresult, true);
|
||||
|
||||
|
||||
for (i = 1; i < 4; i++) {
|
||||
assertTrue(isEqual(QResults[0], QResults[i]), "Result " + i + " is Equal?");
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- toIndexRange
|
||||
// -----------------------------------------------------------------------------
|
||||
/*
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that an index range can be used for an equality filter.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testRangeEquals: function () {
|
||||
|
||||
var query = "FOR v IN " + colName + " FILTER v.a == 1 RETURN [v.a, v.b, v.c]";
|
||||
|
@ -512,6 +514,9 @@ function optimizerRuleTestSuite() {
|
|||
},
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that an index range can be used for a less then filter.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testRangeLessThen: function () {
|
||||
var query = "FOR v IN " + colName + " FILTER v.a < 5 RETURN [v.a, v.b]";
|
||||
|
||||
|
@ -537,16 +542,12 @@ function optimizerRuleTestSuite() {
|
|||
|
||||
assertTrue(isEqual(QResults[0], QResults[1]), "Results are Equal?");
|
||||
},
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that an index range can be used for a greater then filter.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testRangeGreaterThen: function () {
|
||||
/*
|
||||
TODO: can skiplist do a range?
|
||||
var query = "FOR v IN " + colName + " FILTER v.a < 5 RETURN [v.a, v.b, v.c]";
|
||||
var query = "FOR v IN " + colName + " FILTER v.a > 1 && v.a < 5 RETURN [v.a, v.b, v.c]";
|
||||
var query = "FOR v IN " + colName + " FILTER v.c > 1 && v.c < 5 RETURN [v.a, v.b, v.c]";
|
||||
*/
|
||||
var query = "FOR v IN " + colName + " FILTER v.a > 5 RETURN [v.a, v.b]";
|
||||
/*
|
||||
var XPresult;
|
||||
var QResults=[];
|
||||
|
||||
|
@ -563,20 +564,21 @@ function optimizerRuleTestSuite() {
|
|||
|
||||
// The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
var RAs = getRangeAttributes(XPresult);
|
||||
// require("internal").print(RAs);
|
||||
var first = getRangeAttribute(RAs, "v", "a", 1);
|
||||
|
||||
// require("internal").print(first);
|
||||
assertEqual(first.low.bound.vType, "int", "Type is int");
|
||||
assertEqual(first.low.bound.value, 5, "proper value was set");
|
||||
|
||||
assertTrue(isEqual(QResults[0], QResults[1]), "Results are Equal?");
|
||||
*/
|
||||
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that an index range can be used for an and combined
|
||||
/// greater then + less then filter spanning a range.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testRangeBandpass: function () {
|
||||
var query = "FOR v IN " + colName + " FILTER v.a > 4 && v.a < 10 RETURN [v.a, v.b]";
|
||||
/*
|
||||
var XPresult;
|
||||
var QResults=[];
|
||||
|
||||
|
@ -593,120 +595,128 @@ function optimizerRuleTestSuite() {
|
|||
|
||||
// The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
var RAs = getRangeAttributes(XPresult);
|
||||
// require("internal").print(RAs);
|
||||
var first = getRangeAttribute(RAs, "v", "a", 1);
|
||||
|
||||
// require("internal").print(first);
|
||||
assertEqual(first.low.bound.vType, "int", "Type is int");
|
||||
assertEqual(first.low.bound.value, 4, "proper value was set");
|
||||
assertEqual(first.high.bound.vType, "int", "Type is int");
|
||||
assertEqual(first.high.bound.value, 10, "proper value was set");
|
||||
|
||||
assertTrue(isEqual(QResults[0], QResults[1]), "Results are Equal?");
|
||||
*/
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that an index range can be used for an and combined
|
||||
/// greater then + less then filter spanning a range. TODO: doesn't work now.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testRangeBandpassInvalid: function () {
|
||||
/* TODO: this doesn't do anything. should it simply flush that range since its empty? or even raise?
|
||||
var query = "FOR v IN " + colName + " FILTER v.a > 7 && v.a < 4 RETURN [v.a, v.b]";
|
||||
|
||||
var XPresult;
|
||||
var QResults=[];
|
||||
|
||||
// the index we will compare to sorts by a & b, so we need to re-sort the result here to accomplish similarity.
|
||||
QResults[0] = AQL_EXECUTE(query, { }, paramNone).json.sort(sortArray);
|
||||
|
||||
// -> use-index-range alone.
|
||||
QResults[1] = AQL_EXECUTE(query, { }, paramIR).json;
|
||||
|
||||
|
||||
XPresult = AQL_EXPLAIN(query, { }, paramIR);
|
||||
require("internal").print(XPresult);
|
||||
assertEqual([ secondRuleName ], XPresult.plan.rules);
|
||||
// the sortnode and its calculation node should be there.
|
||||
hasCalculationNodes(XPresult, 2);
|
||||
|
||||
// The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
var RAs = getRangeAttributes(XPresult);
|
||||
// TODO: this doesn't do anything. should it simply flush that range since its empty? or even raise?
|
||||
// var query = "FOR v IN " + colName + " FILTER v.a > 7 && v.a < 4 RETURN [v.a, v.b]";
|
||||
//
|
||||
// var XPresult;
|
||||
// var QResults=[];
|
||||
//
|
||||
// // the index we will compare to sorts by a & b, so we need to re-sort the result here to accomplish similarity.
|
||||
// QResults[0] = AQL_EXECUTE(query, { }, paramNone).json.sort(sortArray);
|
||||
//
|
||||
// // -> use-index-range alone.
|
||||
// QResults[1] = AQL_EXECUTE(query, { }, paramIR).json;
|
||||
//
|
||||
//
|
||||
// XPresult = AQL_EXPLAIN(query, { }, paramIR);
|
||||
// require("internal").print(XPresult);
|
||||
// assertEqual([ secondRuleName ], XPresult.plan.rules);
|
||||
// // the sortnode and its calculation node should be there.
|
||||
// hasCalculationNodes(XPresult, 2);
|
||||
//
|
||||
// // The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
// var RAs = getRangeAttributes(XPresult);
|
||||
// require("internal").print(RAs);
|
||||
var first = getRangeAttribute(RAs, "v", "a", 1);
|
||||
|
||||
require("internal").print(first);
|
||||
// var first = getRangeAttribute(RAs, "v", "a", 1);
|
||||
//
|
||||
// require("internal").print(first);
|
||||
// require("internal").print(first);
|
||||
assertEqual(first.low.bound.vType, "int", "Type is int");
|
||||
assertEqual(first.low.bound.value, 4, "proper value was set");
|
||||
assertEqual(first.high.bound.vType, "int", "Type is int");
|
||||
assertEqual(first.high.bound.value, 10, "proper value was set");
|
||||
|
||||
assertTrue(isEqual(QResults[0], QResults[1]), "Results are Equal?");
|
||||
*/
|
||||
// assertEqual(first.low.bound.vType, "int", "Type is int");
|
||||
// assertEqual(first.low.bound.value, 4, "proper value was set");
|
||||
// assertEqual(first.high.bound.vType, "int", "Type is int");
|
||||
// assertEqual(first.high.bound.value, 10, "proper value was set");
|
||||
//
|
||||
// assertTrue(isEqual(QResults[0], QResults[1]), "Results are Equal?");
|
||||
//
|
||||
},
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that an index range can be used for an or combined
|
||||
/// greater then + less then filter spanning a range. TODO: doesn't work now.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testRangeBandstop: function () {
|
||||
/* TODO: OR isn't implemented
|
||||
var query = "FOR v IN " + colName + " FILTER v.a < 5 || v.a > 10 RETURN [v.a, v.b]";
|
||||
|
||||
var XPresult;
|
||||
var QResults=[];
|
||||
|
||||
// the index we will compare to sorts by a & b, so we need to re-sort the result here to accomplish similarity.
|
||||
QResults[0] = AQL_EXECUTE(query, { }, paramNone).json.sort(sortArray);
|
||||
|
||||
// -> use-index-range alone.
|
||||
QResults[1] = AQL_EXECUTE(query, { }, paramIR).json;
|
||||
|
||||
XPresult = AQL_EXPLAIN(query, { }, paramIR);
|
||||
assertEqual([ secondRuleName ], XPresult.plan.rules);
|
||||
// the sortnode and its calculation node should be there.
|
||||
hasCalculationNodes(XPresult, 2);
|
||||
|
||||
// The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
var RAs = getRangeAttributes(XPresult);
|
||||
require("internal").print(RAs);
|
||||
var first = getRangeAttribute(RAs, "v", "a", 1);
|
||||
|
||||
require("internal").print(first);
|
||||
assertEqual(first.low.bound.vType, "int", "Type is int");
|
||||
assertEqual(first.low.bound.value, 5, "proper value was set");
|
||||
|
||||
require("internal").print(QResults[0]);
|
||||
require("internal").print(QResults[1]);
|
||||
assertTrue(isEqual(QResults[0], QResults[1]), "Results are Equal?");
|
||||
*/
|
||||
// TODO: OR isn't implemented
|
||||
// var query = "FOR v IN " + colName + " FILTER v.a < 5 || v.a > 10 RETURN [v.a, v.b]";
|
||||
//
|
||||
// var XPresult;
|
||||
// var QResults=[];
|
||||
//
|
||||
// // the index we will compare to sorts by a & b, so we need to re-sort the result here to accomplish similarity.
|
||||
// QResults[0] = AQL_EXECUTE(query, { }, paramNone).json.sort(sortArray);
|
||||
//
|
||||
// // -> use-index-range alone.
|
||||
// QResults[1] = AQL_EXECUTE(query, { }, paramIR).json;
|
||||
//
|
||||
// XPresult = AQL_EXPLAIN(query, { }, paramIR);
|
||||
// assertEqual([ secondRuleName ], XPresult.plan.rules);
|
||||
// // the sortnode and its calculation node should be there.
|
||||
// hasCalculationNodes(XPresult, 2);
|
||||
//
|
||||
// // The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
// var RAs = getRangeAttributes(XPresult);
|
||||
// require("internal").print(RAs);
|
||||
// var first = getRangeAttribute(RAs, "v", "a", 1);
|
||||
//
|
||||
// require("internal").print(first);
|
||||
// assertEqual(first.low.bound.vType, "int", "Type is int");
|
||||
// assertEqual(first.low.bound.value, 5, "proper value was set");
|
||||
//
|
||||
// require("internal").print(QResults[0]);
|
||||
// require("internal").print(QResults[1]);
|
||||
// assertTrue(isEqual(QResults[0], QResults[1]), "Results are Equal?");
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test in detail that an index range can be used for an or combined
|
||||
/// greater then + less then filter spanning multiple ranges. TODO: doesn't work now.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
testMultiRangeBandpass: function () {
|
||||
/* TODO: OR isn't implemented
|
||||
var query = "FOR v IN " + colName + " FILTER ((v.a > 3 && v.a < 5) || (v.a > 4 && v.a < 7)) RETURN [v.a, v.b]";
|
||||
|
||||
var XPresult;
|
||||
var QResults=[];
|
||||
|
||||
// the index we will compare to sorts by a & b, so we need to re-sort the result here to accomplish similarity.
|
||||
QResults[0] = AQL_EXECUTE(query, { }, paramNone).json.sort(sortArray);
|
||||
|
||||
// -> use-index-range alone.
|
||||
QResults[1] = AQL_EXECUTE(query, { }, paramIR).json;
|
||||
|
||||
XPresult = AQL_EXPLAIN(query, { }, paramIR);
|
||||
assertEqual([ secondRuleName ], XPresult.plan.rules);
|
||||
// the sortnode and its calculation node should be there.
|
||||
hasCalculationNodes(XPresult, 2);
|
||||
|
||||
// The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
var RAs = getRangeAttributes(XPresult);
|
||||
// require("internal").print(RAs);
|
||||
var first = getRangeAttribute(RAs, "v", "a", 1);
|
||||
// TODO: OR isn't implemented
|
||||
// var query = "FOR v IN " + colName + " FILTER ((v.a > 3 && v.a < 5) || (v.a > 4 && v.a < 7)) RETURN [v.a, v.b]";
|
||||
//
|
||||
// var XPresult;
|
||||
// var QResults=[];
|
||||
//
|
||||
// // the index we will compare to sorts by a & b, so we need to re-sort the result here to accomplish similarity.
|
||||
// QResults[0] = AQL_EXECUTE(query, { }, paramNone).json.sort(sortArray);
|
||||
//
|
||||
// // -> use-index-range alone.
|
||||
// QResults[1] = AQL_EXECUTE(query, { }, paramIR).json;
|
||||
//
|
||||
// XPresult = AQL_EXPLAIN(query, { }, paramIR);
|
||||
// assertEqual([ secondRuleName ], XPresult.plan.rules);
|
||||
// // the sortnode and its calculation node should be there.
|
||||
// hasCalculationNodes(XPresult, 2);
|
||||
//
|
||||
// // The IndexRangeNode created by this rule should be more clever, it knows the ranges.
|
||||
// var RAs = getRangeAttributes(XPresult);
|
||||
//// require("internal").print(RAs);
|
||||
// var first = getRangeAttribute(RAs, "v", "a", 1);
|
||||
//
|
||||
//// require("internal").print(first);
|
||||
// assertEqual(first.low.bound.vType, "int", "Type is int");
|
||||
// assertEqual(first.low.bound.value, 4, "proper value was set");
|
||||
// assertEqual(first.high.bound.vType, "int", "Type is int");
|
||||
// assertEqual(first.high.bound.value, 10, "proper value was set");
|
||||
//
|
||||
// assertTrue(isEqual(QResults[0], QResults[1]), "Results are Equal?");
|
||||
|
||||
// require("internal").print(first);
|
||||
assertEqual(first.low.bound.vType, "int", "Type is int");
|
||||
assertEqual(first.low.bound.value, 4, "proper value was set");
|
||||
assertEqual(first.high.bound.vType, "int", "Type is int");
|
||||
assertEqual(first.high.bound.value, 10, "proper value was set");
|
||||
|
||||
assertTrue(isEqual(QResults[0], QResults[1]), "Results are Equal?");
|
||||
*/
|
||||
},
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -714,8 +724,10 @@ function optimizerRuleTestSuite() {
|
|||
// -----------------------------------------------------------------------------
|
||||
testDSRuleHasEffect : function () {
|
||||
|
||||
var queries = [
|
||||
|
||||
/// TODO: asc/desc? -> desc should win; doesn't work now!
|
||||
/// "FOR v IN " + colName + " SORT v.c ASC SORT v.c DESC RETURN [v.a, v.b]",
|
||||
var queries = [
|
||||
"FOR v IN " + colName + " SORT v.c SORT v.c RETURN [v.a, v.b]",
|
||||
"FOR v IN " + colName + " SORT v.c SORT v.c , v.d RETURN [v.a, v.b]",
|
||||
"FOR v IN " + colName + " SORT v.c, v.d SORT v.c RETURN [v.a, v.b]",
|
||||
|
@ -723,15 +735,6 @@ function optimizerRuleTestSuite() {
|
|||
"FOR v IN " + colName + " SORT v.c, v.d SORT v.c SORT v.c, v.d SORT v.c RETURN [v.a, v.b]",
|
||||
|
||||
"FOR v IN " + colName + " SORT v.c FILTER v.c > 3 SORT v.c RETURN [v.a, v.b]"
|
||||
/*
|
||||
// todo: we use an index anyways right now. "FOR v IN " + colName + " SORT v.a DESC RETURN [v.a, v.b]",// currently only ASC supported.
|
||||
"FOR v IN " + colName + " SORT v.b, v.a RETURN [v.a, v.b]",
|
||||
"FOR v IN " + colName + " SORT v.c RETURN [v.a, v.b]",
|
||||
"FOR v IN " + colName + " SORT v.a + 1 RETURN [v.a, v.b]",
|
||||
"FOR v IN " + colName + " SORT CONCAT(TO_STRING(v.a), \"lol\") RETURN [v.a, v.b]",
|
||||
"FOR v IN " + colName + " FILTER v.a > 2 LIMIT 3 SORT v.a RETURN [v.a, v.b] ", // TODO: limit blocks sort atm.
|
||||
"FOR v IN " + colName + " FOR w IN " + colNameOther + " SORT v.a RETURN [v.a, v.b]"
|
||||
*/
|
||||
];
|
||||
|
||||
queries.forEach(function(query) {
|
||||
|
@ -741,8 +744,30 @@ function optimizerRuleTestSuite() {
|
|||
// require("internal").print(result);
|
||||
assertEqual([thirdRuleName], result.plan.rules, query);
|
||||
});
|
||||
|
||||
},
|
||||
testDSRuleHasNoEffect : function () {
|
||||
// TODO: howto have "dependencies" on a sort node?
|
||||
// var queries = [
|
||||
// "FOR v IN " + colName + " SORT v.c SORT v.c RETURN [v.a, v.b]",
|
||||
// "FOR v IN " + colName + " SORT v.c SORT v.c , v.d RETURN [v.a, v.b]",
|
||||
// "FOR v IN " + colName + " SORT v.c, v.d SORT v.c RETURN [v.a, v.b]",
|
||||
// "FOR v IN " + colName + " SORT v.c SORT v.c, v.d SORT v.c RETURN [v.a, v.b]",
|
||||
// "FOR v IN " + colName + " SORT v.c, v.d SORT v.c SORT v.c, v.d SORT v.c RETURN [v.a, v.b]",
|
||||
//
|
||||
// "FOR v IN " + colName + " SORT v.c FILTER v.c > 3 SORT v.c RETURN [v.a, v.b]"
|
||||
// ];
|
||||
//
|
||||
// queries.forEach(function(query) {
|
||||
//
|
||||
//// require("internal").print(query);
|
||||
// var result = AQL_EXPLAIN(query, { }, paramRS);
|
||||
//// require("internal").print(result);
|
||||
// assertEqual([thirdRuleName], result.plan.rules, query);
|
||||
// });
|
||||
//
|
||||
}
|
||||
//*/
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue