1
0
Fork 0
This commit is contained in:
James 2014-12-02 09:36:11 +00:00
parent 2d9c4196ac
commit 3bab43be0a
3 changed files with 23 additions and 13 deletions

View File

@ -791,11 +791,11 @@ class FilterToEnumCollFinder : public WalkerWorker<ExecutionNode> {
ExecutionPlan* plan,
Variable const* var,
Optimizer::RuleLevel level)
: _opt(opt),
: _rangeInfoMapVec(nullptr),
_opt(opt),
_plan(plan),
_canThrow(false),
_level(level) {
_rangeInfoMapVec = new RangeInfoMapVec();
_varIds.insert(var->id);
};
@ -817,7 +817,7 @@ class FilterToEnumCollFinder : public WalkerWorker<ExecutionNode> {
std::string attr;
Variable const* enumCollVar = nullptr;
// there is an implicit AND between FILTER statements
if (_rangeInfoMapVec->empty()) {
if (_rangeInfoMapVec == nullptr) {
_rangeInfoMapVec = buildRangeInfo(node->expression()->node(), enumCollVar, attr);
} else {
_rangeInfoMapVec = andCombineRangeInfoMapVecs(_rangeInfoMapVec,

View File

@ -463,6 +463,17 @@ RangeInfoMapVec::RangeInfoMapVec (RangeInfoMap* rim) :
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief destructor
////////////////////////////////////////////////////////////////////////////////
RangeInfoMapVec::~RangeInfoMapVec () {
for (auto x: _rangeInfoMapVec) {
delete x;
}
_rangeInfoMapVec.clear();
}
////////////////////////////////////////////////////////////////////////////////
/// @brief emplace_back: emplace_back RangeInfoMap in vector
////////////////////////////////////////////////////////////////////////////////
@ -603,19 +614,17 @@ RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
////////////////////////////////////////////////////////////////////////////////
/// @brief andCombineRangeInfoMaps: insert every RangeInfo in the right argument
/// in a new copy of the left argument
/// in the left argument
////////////////////////////////////////////////////////////////////////////////
RangeInfoMap* triagens::aql::andCombineRangeInfoMaps (RangeInfoMap* lhs, RangeInfoMap* rhs) {
RangeInfoMap* rim = lhs->clone();
for (auto x: rhs->_ranges) {
for (auto y: x.second) {
rim->insert(y.second.clone());
lhs->insert(y.second.clone());
}
}
return rim;
return lhs;
}
////////////////////////////////////////////////////////////////////////////////
@ -623,16 +632,16 @@ RangeInfoMap* triagens::aql::andCombineRangeInfoMaps (RangeInfoMap* lhs, RangeIn
/// distributing the AND into the ORs in a condition like:
/// (OR condition) AND (OR condition).
///
/// The return RIMV is new unless one of the arguments is empty.
/// The return RIMV is the lhs, unless the it is empty or the nullptr, in which case it is the rhs.
////////////////////////////////////////////////////////////////////////////////
RangeInfoMapVec* triagens::aql::andCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
RangeInfoMapVec* rhs) {
if (lhs->empty()) {
if (lhs == nullptr || lhs->empty()) {
return lhs;
}
if (rhs->empty()) {
if (rhs == nullptr || rhs->empty()) {
return rhs;
}
@ -643,6 +652,8 @@ RangeInfoMapVec* triagens::aql::andCombineRangeInfoMapVecs (RangeInfoMapVec* lhs
rimv->emplace_back(andCombineRangeInfoMaps((*lhs)[i]->clone(), (*rhs)[j]->clone()));
}
}
delete lhs;
delete rhs;
return rimv;
}

View File

@ -784,8 +784,7 @@ namespace triagens {
/// @brief destructor
////////////////////////////////////////////////////////////////////////////////
~RangeInfoMapVec() {
}
~RangeInfoMapVec();
////////////////////////////////////////////////////////////////////////////////
/// @brief toString, via Json