1
0
Fork 0

fixed cloning of RangeInfos

This commit is contained in:
James 2014-11-20 13:24:52 +00:00
parent 1f69d82a8a
commit 2f80c76f69
3 changed files with 40 additions and 8 deletions

View File

@ -1139,10 +1139,6 @@ class FilterToEnumCollFinder : public WalkerWorker<ExecutionNode> {
if (node->type == NODE_TYPE_OPERATOR_BINARY_EQ) {
auto lhs = node->getMember(0);
auto rhs = node->getMember(1);
if (rhs->type != NODE_TYPE_ATTRIBUTE_ACCESS) {
lhs = node->getMember(1);
rhs = node->getMember(0);
}
if (rhs->type == NODE_TYPE_ATTRIBUTE_ACCESS) {
buildRangeInfo(rhs, enumCollVar, attr, isOrCondition);
if (enumCollVar != nullptr) {
@ -1163,6 +1159,26 @@ class FilterToEnumCollFinder : public WalkerWorker<ExecutionNode> {
}
}
}
if (lhs->type == NODE_TYPE_ATTRIBUTE_ACCESS) {
buildRangeInfo(lhs, enumCollVar, attr, isOrCondition);
if (enumCollVar != nullptr) {
std::unordered_set<Variable*> varsUsed
= Ast::getReferencedVariables(rhs);
if (varsUsed.find(const_cast<Variable*>(enumCollVar))
== varsUsed.end()) {
// Found a multiple attribute access of a variable and an
// expression which does not involve that variable:
insert(enumCollVar->name,
attr.substr(0, attr.size() - 1),
RangeInfoBound(rhs, true),
RangeInfoBound(rhs, true),
true,
isOrCondition);
enumCollVar = nullptr;
attr.clear();
}
}
}
return;
}

View File

@ -465,7 +465,7 @@ void RangeInfoMapVec::insertDistributeAndIntoOr (std::vector<RangeInfo> ranges)
for (size_t j = 1; j < ranges.size(); j++) {
RangeInfoMap* rim = sample->clone();
rim->insert(ranges[j]); // here we intersect with any existing values
_rangeInfoMapVec.push_back(rim);
_rangeInfoMapVec.emplace_back(rim);
}
}
}
@ -474,7 +474,7 @@ void RangeInfoMapVec::insertDistributeAndIntoOr (std::vector<RangeInfo> ranges)
for (auto x: ranges) {
RangeInfoMap* rim = new RangeInfoMap();
rim->insert(x);
_rangeInfoMapVec.push_back(rim);
_rangeInfoMapVec.emplace_back(rim);
}
}
}

View File

@ -529,8 +529,24 @@ namespace triagens {
}
RangeInfo clone () {
//TODO improve this
return RangeInfo(this->toJson());
RangeInfo copy(_var, _attr);
copy._lowConst.assign(_lowConst);
copy._highConst.assign(_highConst);
for (auto x: _lows) {
copy._lows.emplace_back(x);
}
for (auto x: _highs) {
copy._highs.emplace_back(x);
}
copy._valid = _valid;
copy._defined = _defined;
copy._equality = _equality;
return copy;
//FIXME the following should work but doesn't!!
//return RangeInfo(this->toJson());
}
////////////////////////////////////////////////////////////////////////////////