From 703cfa3a16d34a3a7f459af7d032a34ef04efaed Mon Sep 17 00:00:00 2001 From: James Date: Sun, 23 Nov 2014 14:16:40 +0000 Subject: [PATCH] moving function --- arangod/Aql/RangeInfo.cpp | 93 ++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/arangod/Aql/RangeInfo.cpp b/arangod/Aql/RangeInfo.cpp index bc91415f30..73e77dba1a 100644 --- a/arangod/Aql/RangeInfo.cpp +++ b/arangod/Aql/RangeInfo.cpp @@ -537,6 +537,53 @@ std::unordered_set RangeInfoMapVec::attributes (std::string const& return _rangeInfoMapVec[0]->attributes(var); } +//////////////////////////////////////////////////////////////////////////////// +/// @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. +/// +/// The return RIMV is new unless one of the arguments is empty. +//////////////////////////////////////////////////////////////////////////////// + +RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs, + RangeInfoMapVec* rhs) { + + if (lhs->empty()) { + return rhs; + } + + if (rhs->empty()) { + return lhs; + } + + auto rimv = new RangeInfoMapVec(); + + // this lhs already doesn't contain duplicate conditions + for (size_t i = 0; i < lhs->size(); i++) { + rimv->emplace_back((*lhs)[i]->clone()); + } + + //avoid inserting identical conditions + for (size_t i = 0; i < rhs->size(); i++) { + auto rim = new RangeInfoMap(); + for (auto x: (*rhs)[i]->_ranges) { + for (auto y: x.second) { + // take the difference of + RangeInfo* ri = rimv->differenceRangeInfo(&y.second); + if (ri != nullptr) { + // if ri is nullptr, then y.second is contained in an existing ri + rim->insert(*ri); + } + } + } + if (! rim->empty()) { + rimv->emplace_back(rim); + } + } + + return rimv; +} + //////////////////////////////////////////////////////////////////////////////// /// @brief andCombineRangeInfoMaps: insert every RangeInfo in the right argument /// in a new copy of the left argument @@ -666,52 +713,6 @@ RangeInfo* RangeInfoMapVec::differenceRangeInfo (RangeInfo* newRi) { return newRi; } -//////////////////////////////////////////////////////////////////////////////// -/// @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. -/// -/// The return RIMV is new unless one of the arguments is empty. -//////////////////////////////////////////////////////////////////////////////// - -RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs, - RangeInfoMapVec* rhs) { - - if (lhs->empty()) { - return rhs; - } - - if (rhs->empty()) { - return lhs; - } - - auto rimv = new RangeInfoMapVec(); - - // this lhs already doesn't contain duplicate conditions - for (size_t i = 0; i < lhs->size(); i++) { - rimv->emplace_back((*lhs)[i]->clone()); - } - - //avoid inserting identical conditions - for (size_t i = 0; i < rhs->size(); i++) { - auto rim = new RangeInfoMap(); - for (auto x: (*rhs)[i]->_ranges) { - for (auto y: x.second) { - // take the difference of - RangeInfo* ri = rimv->differenceRangeInfo(&y.second); - if (ri != nullptr) { - // if ri is nullptr, then y.second is contained in an existing ri - rim->insert(*ri); - } - } - } - if (! rim->empty()) { - rimv->emplace_back(rim); - } - } - - return rimv; -} //////////////////////////////////////////////////////////////////////////////// /// @brief differenceIndexOrAndRangeInfo: analogue of differenceRangeInfo