1
0
Fork 0

fix index handling

This commit is contained in:
Wilfried Goesgens 2019-10-01 16:22:02 +02:00
parent c15083b77c
commit fc96de0f9e
1 changed files with 30 additions and 17 deletions

View File

@ -34,6 +34,7 @@ var helper = require("@arangodb/aql-helper");
var isEqual = helper.isEqual;
var findExecutionNodes = helper.findExecutionNodes;
var getQueryResults = helper.getQueryResults;
var db = require("internal").db;
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
@ -42,7 +43,8 @@ var getQueryResults = helper.getQueryResults;
function ahuacatlQueryOptimizerSortTestSuite () {
var collection = null;
var cn = "UnitTestsAhuacatlOptimizerSort";
var idx = null;
var explain = function (query, params) {
return helper.getCompactPlan(AQL_EXPLAIN(query, params, { optimizer: { rules: [ "-all", "+use-index-for-sort", "+use-indexes", "+remove-redundant-sorts" ] } })).map(function(node) { return node.type; });
};
@ -61,7 +63,11 @@ function ahuacatlQueryOptimizerSortTestSuite () {
for (var i = 0; i < 100; ++i) {
docs.push({ "value" : i, "value2" : i });
}
collection.push(docs);
collection.insert(docs);
},
setUp: function() {
var idx = null;
},
////////////////////////////////////////////////////////////////////////////////
@ -69,7 +75,14 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
tearDownAll : function () {
internal.db._drop(cn);
internal.db._drop(cn);
},
tearDown: function() {
if (idx != null) {
db._dropIndex(idx);
idx = null;
}
},
////////////////////////////////////////////////////////////////////////////////
@ -135,7 +148,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testSkiplist1 : function () {
collection.ensureSkiplist("value");
idx = collection.ensureSkiplist("value");
var query = "FOR c IN " + cn + " SORT c.value RETURN c";
@ -165,7 +178,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testSkiplist2 : function () {
collection.ensureSkiplist("value");
idx = collection.ensureSkiplist("value");
var query = "FOR c IN " + cn + " FILTER c.value >= 15 SORT c.value RETURN c";
@ -196,7 +209,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testSkiplist3 : function () {
collection.ensureSkiplist("value");
idx = collection.ensureSkiplist("value");
var query = "FOR c IN " + cn + " FILTER c.value >= 15 SORT c.value DESC RETURN c";
@ -227,7 +240,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testMultipleSorts1 : function () {
collection.ensureSkiplist("value");
idx = collection.ensureSkiplist("value");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 SORT c.value SORT c.value RETURN c";
@ -260,7 +273,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testMultipleSorts2 : function () {
collection.ensureSkiplist("value");
idx = collection.ensureSkiplist("value");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 SORT c.value SORT c.value DESC RETURN c";
@ -293,7 +306,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testMultipleSorts3 : function () {
collection.ensureSkiplist("value");
idx = collection.ensureSkiplist("value");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 SORT c.value DESC SORT c.value RETURN c";
@ -326,7 +339,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testMultipleFields1 : function () {
collection.ensureSkiplist("value", "value2");
idx = collection.ensureSkiplist("value", "value2");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 SORT c.value RETURN c";
@ -376,7 +389,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testMultipleFields2 : function () {
collection.ensureSkiplist("value", "value2");
idx = collection.ensureSkiplist("value", "value2");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 SORT c.value, c.value2 RETURN c";
@ -428,7 +441,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testMultipleFields3 : function () {
collection.ensureSkiplist("value", "value2");
idx = collection.ensureSkiplist("value", "value2");
var query = "FOR c IN " + cn + " FILTER c.value2 >= 0 SORT c.value RETURN c";
@ -460,7 +473,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testMultipleFields4 : function () {
collection.ensureSkiplist("value", "value2");
idx = collection.ensureSkiplist("value", "value2");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 && c.value2 >= 0 SORT c.value RETURN c";
@ -492,7 +505,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testMultipleFields5 : function () {
collection.ensureSkiplist("value2", "value");
idx = collection.ensureSkiplist("value2", "value");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 SORT c.value RETURN c";
@ -525,7 +538,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testNonFieldSort1 : function () {
collection.ensureSkiplist("value");
idx = collection.ensureSkiplist("value");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 SORT c.value + 1 RETURN c";
@ -558,7 +571,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testNonFieldSort2 : function () {
collection.ensureSkiplist("value");
idx = collection.ensureSkiplist("value");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 SORT 1 + c.value RETURN c";
@ -591,7 +604,7 @@ function ahuacatlQueryOptimizerSortTestSuite () {
////////////////////////////////////////////////////////////////////////////////
testNonFieldSort3 : function () {
collection.ensureSkiplist("value");
idx = collection.ensureSkiplist("value");
var query = "FOR c IN " + cn + " FILTER c.value >= 0 SORT c.value * 2 RETURN c";