1
0
Fork 0

fixed another bug and added a test for it.

This commit is contained in:
James 2014-12-09 11:19:34 +00:00
parent a4dcf1b9d3
commit afb960f60e
3 changed files with 20 additions and 7 deletions

View File

@ -853,7 +853,7 @@ IndexRangeBlock::IndexRangeBlock (ExecutionEngine* engine,
: ExecutionBlock(engine, en),
_collection(en->collection()),
_posInDocs(0),
_anyBoundVariable(true),
_anyBoundVariable(false),
_skiplistIterator(nullptr),
_condition(&en->_ranges),
_posInRanges(0),
@ -872,7 +872,7 @@ IndexRangeBlock::IndexRangeBlock (ExecutionEngine* engine,
for (auto r : attrRanges) {
isConstant &= r.isConstant();
}
_anyBoundVariable &= ! isConstant;
_anyBoundVariable |= ! isConstant;
_allBoundsConstant.push_back(isConstant);
}
}

View File

@ -551,7 +551,7 @@ RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
RangeInfo ri = y.second.clone();
lhs->differenceRangeInfo(ri);
if (ri.isValid()) {
// if ri is nullptr, then y.second is contained in an existing ri
// if ri is not valid, then y.second is contained in an existing ri
rim->insert(ri);
}
}
@ -635,7 +635,6 @@ RangeInfoMapVec* triagens::aql::andCombineRangeInfoMapVecs (RangeInfoMapVec* lhs
// contained in the other, and, 1 if rhs is contained in lhs.
static int containmentRangeInfos (RangeInfo const& lhs, RangeInfo const& rhs) {
int LoLo = CompareRangeInfoBound(lhs._lowConst, rhs._lowConst, -1);
// -1 if lhs is tighter than rhs, 1 if rhs tighter than lhs
int HiHi = CompareRangeInfoBound(lhs._highConst, rhs._highConst, 1);
@ -688,9 +687,7 @@ static bool areDisjointRangeInfos (RangeInfo const& lhs, RangeInfo const& rhs) {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief differenceRangeInfo: returns the difference of the constant parts of
/// the given RangeInfos.
///
/// @brief differenceRangeInfo:
/// Modifies either lhs or rhs in place, so that the constant parts of lhs
/// and rhs are disjoint, and the union of the modified lhs and rhs equals the
/// union of the originals.
@ -700,6 +697,10 @@ void triagens::aql::differenceRangeInfos (RangeInfo& lhs, RangeInfo& rhs) {
TRI_ASSERT(lhs._var == lhs._var);
TRI_ASSERT(lhs._attr == rhs._attr);
if (! (lhs.isConstant() && rhs.isConstant())) {
return;
}
if (! areDisjointRangeInfos(lhs, rhs)) {
int contained = containmentRangeInfos(lhs, rhs);
if (contained == -1) {

View File

@ -927,6 +927,18 @@ function ahuacatlQueryOptimiserInTestSuite () {
ruleIsNotUsed(query);
},
testOverlappingDynamicAndNonDynamic: function () {
for (var i = 1; i <= 5; ++i) {
c.save({ value1: i, value2: i + 5 });
}
c.ensureSkiplist("value1");
var query = "FOR x IN " + cn + " FILTER x.value1 IN [PASSTHRU(3),PASSTHRU(3),PASSTHRU(3), 4] || x.value1 in [3,4,5,9] RETURN x.value1";
var expected = [ 3, 4, 5 ];
var actual = getQueryResults(query);
assertEqual(expected, actual);
ruleIsUsed(query);
},
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////