1
0
Fork 0

Merge branch 'aql-jmmh-conditions' of https://github.com/arangodb/arangodb into aql-jmmh-conditions

This commit is contained in:
Jan Steemann 2015-10-15 16:19:42 +02:00
commit 6640f8e293
4 changed files with 1989 additions and 14 deletions

View File

@ -739,11 +739,19 @@ TRI_index_element_t* SkiplistIterator::nextIteration () {
// -----------------------------------------------------------------------------
TRI_doc_mptr_t* SkiplistIndexIterator::next () {
if (_iterator == nullptr) {
while (_iterator == nullptr) {
if (_currentOperator == _operators.size()) {
// Sorry nothing found at all
return nullptr;
}
// We restart the lookup
_iterator = _index->lookup(_operators[_currentOperator], _reverse);
TRI_ASSERT(_iterator != nullptr);
if (_iterator == nullptr) {
// This iterator was not created.
_currentOperator++;
}
}
TRI_ASSERT(_iterator != nullptr);
TRI_index_element_t* res = _iterator->next();
while (res == nullptr) {
// Try the next iterator

File diff suppressed because it is too large Load Diff

View File

@ -58,15 +58,10 @@ function optimizerRuleTestSuite() {
assertEqual(findExecutionNodes(plan, "FilterNode").length, 0, "has no filter node");
};
var hasFilterNode = function (plan) {
assertEqual(findExecutionNodes(plan, "FilterNode").length, 1, "has filter node");
};
var hasIndexNodeWithRanges = function (plan) {
var rn = findExecutionNodes(plan, "IndexNode");
assertTrue(rn.length >= 1, "has IndexNode");
assertTrue(rn[0].ranges.length > 0, "whether the IndexNode ranges array is valid");
assertTrue(rn[0].ranges[0].length > 0, "have IndexNode with ranges");
assertTrue(rn[0].indexes.length > 0, "whether the IndexNode uses at least one index");
};
return {
@ -178,14 +173,14 @@ function optimizerRuleTestSuite() {
queries.forEach(function(query) {
var result;
result = AQL_EXPLAIN(query, { }, paramIndexRangeFilter);
assertEqual([ IndexesRule ], removeAlwaysOnClusterRules(result.plan.rules), query);
hasFilterNode(result);
assertEqual([ IndexesRule, FilterRemoveRule ], removeAlwaysOnClusterRules(result.plan.rules), query);
hasNoFilterNode(result);
hasIndexNodeWithRanges(result);
result = AQL_EXPLAIN(query, { }, paramIndexRangeSortFilter);
assertEqual([ IndexesRule ], removeAlwaysOnClusterRules(result.plan.rules), query);
hasFilterNode(result);
assertEqual([ IndexesRule, FilterRemoveRule ], removeAlwaysOnClusterRules(result.plan.rules), query);
hasNoFilterNode(result);
hasIndexNodeWithRanges(result);
var QResults = [];

View File

@ -138,7 +138,6 @@ function optimizerRuleUseIndexRangeTester () {
"FOR i IN UTUseIndexRangeSkipInd FILTER i.a == 2 RETURN i",
"FOR i IN UTUseIndexRangeSkipInd FILTER i.a < 2 RETURN i",
"FOR i IN UTUseIndexRangeSkipInd FILTER i.a < 2 && i.a > 0 RETURN i",
"FOR i IN UTUseIndexRangeSkipInd FILTER i.a < 2 && i.a > 3 RETURN i",
"FOR i IN UTUseIndexRangeHashInd FILTER i.a == 2 RETURN i",
"FOR i IN UTUseIndexRangeBothInd FILTER i.a == 2 RETURN i",
"FOR i IN UTUseIndexRangeBothInd FILTER i.a <= 2 RETURN i",
@ -162,7 +161,6 @@ function optimizerRuleUseIndexRangeTester () {
"FOR i IN UTUseIndexRangeSkipInd FILTER i.a == 2 RETURN i",
"FOR i IN UTUseIndexRangeSkipInd FILTER i.a < 2 RETURN i",
"FOR i IN UTUseIndexRangeSkipInd FILTER i.a < 2 && i.a > 0 RETURN i",
"FOR i IN UTUseIndexRangeSkipInd FILTER i.a < 2 && i.a > 3 RETURN i",
"FOR i IN UTUseIndexRangeHashInd FILTER i.a == 2 RETURN i",
"FOR i IN UTUseIndexRangeBothInd FILTER i.a == 2 RETURN i",
"FOR i IN UTUseIndexRangeBothInd FILTER i.a <= 2 RETURN i",
@ -175,6 +173,27 @@ function optimizerRuleUseIndexRangeTester () {
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test that impossible conditions are detected and optimized
////////////////////////////////////////////////////////////////////////////////
testImpossibleRangesAreDetected : function () {
var queries = [
"FOR i IN UTUseIndexRangeSkipInd FILTER i.a < 2 && i.a > 3 RETURN i"
];
queries.forEach(function(query) {
var result = AQL_EXPLAIN(query, { }, paramAll);
var foundNoResults = false;
for (var t in result.plan.nodes) {
if (result.plan.nodes[t].type === "NoResultsNode") {
foundNoResults = true;
}
}
assertTrue(foundNoResults, query);
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test that plan explosion does not happen
////////////////////////////////////////////////////////////////////////////////