1
0
Fork 0

fixing duplicates in dynamic bounds

This commit is contained in:
James 2014-12-09 10:19:01 +00:00
parent 46fe461ca1
commit 1467b34c5e
3 changed files with 49 additions and 6 deletions

View File

@ -1148,10 +1148,8 @@ bool IndexRangeBlock::initRanges () {
andCombineIndexOrRIBHigh(rangeInfoOr, rib);
}
}
if (newCondition != nullptr) {
for (size_t i = 0; i < rangeInfoOr->size(); i++) {
newCondition->emplace_back(rangeInfoOr->at(i));
}
if (newCondition != nullptr && !newCondition->empty()) {
orCombineIndexOrs(newCondition, rangeInfoOr);
delete rangeInfoOr;
} else {
newCondition = rangeInfoOr;
@ -1197,6 +1195,36 @@ bool IndexRangeBlock::initRanges () {
LEAVE_BLOCK;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief orCombineIndexOrs: return the lhs by appending the difference of
/// those RIs in the rhs with those in the lhs into the lhs.
////////////////////////////////////////////////////////////////////////////////
void IndexRangeBlock::orCombineIndexOrs (IndexOrCondition* lhs,
IndexOrCondition* rhs) {
TRI_ASSERT(lhs != nullptr && !lhs->empty());
if (rhs->empty()) {
return;
}
//avoid inserting overlapping conditions
for (IndexAndCondition indexAnd: *rhs) {
std::vector<RangeInfo> newIndexAnd;
for (RangeInfo& ri: indexAnd) {
differenceIndexOrRangeInfo(lhs, ri);
if (ri.isValid()) {
// if ri is invalid, then don't insert it
newIndexAnd.emplace_back(ri);
}
}
if (! newIndexAnd.empty()) {
lhs->emplace_back(newIndexAnd);
}
}
}
// ioc = IndexOrCondition(IndexAndCondition(A && B) || IndexAndCondition(C && D))
// riv = RangeInfoVec(E || F)
// combined into

View File

@ -518,8 +518,6 @@ std::unordered_set<std::string> RangeInfoMapVec::attributes (std::string const&
/// @brief orCombineRangeInfoMapVecs: return a new RangeInfoMapVec appending
/// those RIMs in the right arg (which are not identical to an existing RIM) in
/// a copy of the left arg.
///
///
////////////////////////////////////////////////////////////////////////////////
RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
@ -573,6 +571,7 @@ RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
return lhs;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief andCombineRangeInfoMaps: insert every RangeInfo in the <rhs> in the
/// <lhs> and delete the <rhs>
@ -753,3 +752,18 @@ void RangeInfoMapVec::differenceRangeInfo (RangeInfo& newRi) {
}
}
}
void triagens::aql::differenceIndexOrRangeInfo(IndexOrCondition const* ioc,
RangeInfo& newRi) {
for (IndexAndCondition iac: *ioc) {
for (RangeInfo oldRi: iac) {
differenceRangeInfos(oldRi, newRi);
if (! newRi.isValid()) {
break;
}
}
if (! newRi.isValid()) {
break;
}
}
}

View File

@ -938,6 +938,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
void differenceRangeInfos (RangeInfo&, RangeInfo&);
void differenceIndexOrRangeInfo (IndexOrCondition const*, RangeInfo&);
}
}