mirror of https://gitee.com/bigwinds/arangodb
cleaning up
This commit is contained in:
parent
62411fa64a
commit
37e059fb7a
|
@ -570,39 +570,38 @@ std::unordered_set<std::string> RangeInfoMapVec::attributes (std::string const&
|
||||||
/// those RIMs in the right arg (which are not identical to an existing RIM) in
|
/// those RIMs in the right arg (which are not identical to an existing RIM) in
|
||||||
/// a copy of the left arg.
|
/// a copy of the left arg.
|
||||||
///
|
///
|
||||||
/// The return RIMV is new unless one of the arguments is empty.
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
|
RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
|
||||||
RangeInfoMapVec* rhs) {
|
RangeInfoMapVec* rhs) {
|
||||||
|
|
||||||
if (lhs == nullptr || lhs->empty()) {
|
if (lhs == nullptr) {
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs->empty()) {
|
||||||
delete lhs;
|
delete lhs;
|
||||||
return rhs;
|
return rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rhs == nullptr || rhs->empty()) {
|
if (rhs == nullptr) {
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs->empty()) {
|
||||||
delete rhs;
|
delete rhs;
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rimv = new RangeInfoMapVec();
|
//avoid inserting overlapping conditions
|
||||||
|
|
||||||
// this lhs already doesn't contain duplicate conditions
|
|
||||||
for (size_t i = 0; i < lhs->size(); i++) {
|
|
||||||
rimv->emplace_back((*lhs)[i]->clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
delete lhs;
|
|
||||||
|
|
||||||
//avoid inserting identical conditions
|
|
||||||
for (size_t i = 0; i < rhs->size(); i++) {
|
for (size_t i = 0; i < rhs->size(); i++) {
|
||||||
auto rim = new RangeInfoMap();
|
auto rim = new RangeInfoMap();
|
||||||
for (auto x: (*rhs)[i]->_ranges) {
|
for (auto x: (*rhs)[i]->_ranges) {
|
||||||
for (auto y: x.second) {
|
for (auto y: x.second) {
|
||||||
// take the difference of
|
// take the difference of
|
||||||
RangeInfo ri = y.second.clone();
|
RangeInfo ri = y.second.clone();
|
||||||
rimv->differenceRangeInfo(ri);
|
lhs->differenceRangeInfo(ri);
|
||||||
if (ri.isValid()) {
|
if (ri.isValid()) {
|
||||||
// if ri is nullptr, then y.second is contained in an existing ri
|
// if ri is nullptr, then y.second is contained in an existing ri
|
||||||
rim->insert(ri);
|
rim->insert(ri);
|
||||||
|
@ -610,18 +609,18 @@ RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! rim->empty()) {
|
if (! rim->empty()) {
|
||||||
rimv->emplace_back(rim);
|
lhs->emplace_back(rim);
|
||||||
} else {
|
} else {
|
||||||
delete rim;
|
delete rim;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete rhs;
|
delete rhs;
|
||||||
return rimv;
|
return lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief andCombineRangeInfoMaps: insert every RangeInfo in the right argument
|
/// @brief andCombineRangeInfoMaps: insert every RangeInfo in the <rhs> in the
|
||||||
/// in the left argument
|
/// <lhs> and delete the <rhs>
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
RangeInfoMap* triagens::aql::andCombineRangeInfoMaps (RangeInfoMap* lhs, RangeInfoMap* rhs) {
|
RangeInfoMap* triagens::aql::andCombineRangeInfoMaps (RangeInfoMap* lhs, RangeInfoMap* rhs) {
|
||||||
|
@ -647,22 +646,31 @@ RangeInfoMap* triagens::aql::andCombineRangeInfoMaps (RangeInfoMap* lhs, RangeIn
|
||||||
RangeInfoMapVec* triagens::aql::andCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
|
RangeInfoMapVec* triagens::aql::andCombineRangeInfoMapVecs (RangeInfoMapVec* lhs,
|
||||||
RangeInfoMapVec* rhs) {
|
RangeInfoMapVec* rhs) {
|
||||||
if (lhs == nullptr || lhs->empty()) {
|
if (lhs == nullptr || lhs->empty()) {
|
||||||
delete rhs;
|
if (rhs != nullptr) {
|
||||||
|
delete rhs;
|
||||||
|
}
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rhs == nullptr || rhs->empty()) {
|
if (rhs == nullptr || rhs->empty()) {
|
||||||
delete lhs;
|
if (lhs != nullptr) {
|
||||||
|
delete lhs;
|
||||||
|
}
|
||||||
return rhs;
|
return rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rimv = new RangeInfoMapVec();
|
auto rimv = new RangeInfoMapVec(); // must be a new one!
|
||||||
|
try {
|
||||||
for (size_t i = 0; i < lhs->size(); i++) {
|
for (size_t i = 0; i < lhs->size(); i++) {
|
||||||
for (size_t j = 0; j < rhs->size(); j++) {
|
for (size_t j = 0; j < rhs->size(); j++) {
|
||||||
rimv->emplace_back(andCombineRangeInfoMaps((*lhs)[i]->clone(), (*rhs)[j]->clone()));
|
rimv->emplace_back(andCombineRangeInfoMaps((*lhs)[i]->clone(), (*rhs)[j]->clone()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (...) {
|
||||||
|
delete rimv;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
delete lhs;
|
delete lhs;
|
||||||
delete rhs;
|
delete rhs;
|
||||||
return rimv;
|
return rimv;
|
||||||
|
|
Loading…
Reference in New Issue