From c8cdb5ab9380db5ca1540ef22b90fd74136479cb Mon Sep 17 00:00:00 2001 From: Michael Hackstein Date: Wed, 4 May 2016 10:17:29 +0200 Subject: [PATCH] Added a test for large overlapping ranges in skiplists. This covers a bug where unification of results lead to early lookup abortion. --- js/server/tests/aql/aql-skiplist.js | 86 +++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 js/server/tests/aql/aql-skiplist.js diff --git a/js/server/tests/aql/aql-skiplist.js b/js/server/tests/aql/aql-skiplist.js new file mode 100644 index 0000000000..87fe86096f --- /dev/null +++ b/js/server/tests/aql/aql-skiplist.js @@ -0,0 +1,86 @@ +/*jshint globalstrict:false, strict:false, maxlen: 500 */ +/*global assertEqual, AQL_EXECUTE, AQL_EXPLAIN */ + +//////////////////////////////////////////////////////////////////////////////// +/// @brief tests for Ahuacatl, skiplist index queries +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2010-2016 ArangoDB GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is ArangoDB GmbH, Cologne, Germany +/// +/// @author Michael Hackstein +/// @author Copyright 2016, ArangoDB GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +var internal = require("internal"); +var jsunity = require("jsunity"); +var helper = require("@arangodb/aql-helper"); +var getQueryResults = helper.getQueryResults; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test suite +//////////////////////////////////////////////////////////////////////////////// + +function ahuacatlSkiplistOverlappingTestSuite () { + const rulesDisabled = {optimizer: {rules: ["-all"]}}; + const rulesEnabled = {optimizer: {rules: [""]}}; + + let skiplist; + + return { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief set up +//////////////////////////////////////////////////////////////////////////////// + + setUp : function () { + internal.db._drop("UnitTestsAhuacatlSkiplist"); + skiplist = internal.db._create("UnitTestsAhuacatlSkiplist"); + skiplist.ensureSkiplist("a"); + + for (var i = 0; i < 10000; ++i) { + skiplist.save({a: i}); + } + }, + + tearDown : function () { + internal.db._drop("UnitTestsAhuacatlSkiplist"); + }, + + testLargeOverlappingRanges : function () { + let query = `FOR x IN @@cn FILTER (1000 <= x.a && x.a < 2500) + || (1500 <= x.a && x.a < 3000) + RETURN x`; + + let bindVars = {"@cn": skiplist.name()}; + assertEqual(2000, AQL_EXECUTE(query, bindVars, rulesDisabled).json.length); + assertEqual(2000, AQL_EXECUTE(query, bindVars, rulesEnabled).json.length); + } + + }; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief executes the test suite +//////////////////////////////////////////////////////////////////////////////// + +jsunity.run(ahuacatlSkiplistOverlappingTestSuite); + +return jsunity.done(); +