From 3e178821604dd89bb76a181fcf0ade4efe3ae5ae Mon Sep 17 00:00:00 2001 From: James Date: Sat, 22 Nov 2014 16:47:44 +0000 Subject: [PATCH] cleaning up --- arangod/Aql/RangeInfo.cpp | 37 ++-------------- arangod/Aql/RangeInfo.h | 88 +++++++++++++++++++++++++++++---------- 2 files changed, 70 insertions(+), 55 deletions(-) diff --git a/arangod/Aql/RangeInfo.cpp b/arangod/Aql/RangeInfo.cpp index 98c63270da..5aae26d190 100644 --- a/arangod/Aql/RangeInfo.cpp +++ b/arangod/Aql/RangeInfo.cpp @@ -337,7 +337,7 @@ static bool isIdenticalRangeInfo (RangeInfo lhs, RangeInfo rhs) { } bool RangeInfoMap::isValid (std::string const& var) { - // are all the range infos valid? + // are all the range infos valid? FIXME should this be any instead of all? std::unordered_map* map = find(var); if (map != nullptr) { @@ -406,16 +406,6 @@ void RangeInfoMap::eraseEmptyOrUndefined(std::string const& var) { //////////////////////////////////////////////////////////////////////////////// -/*RangeInfoMapVec::RangeInfoMapVec (std::string const& var, - std::string const& name, - RangeInfoBound low, - RangeInfoBound high, - bool equality) : - _rangeInfoMapVec() { - - _rangeInfoMapVec.emplace_back(new RangeInfoMap(var, name, low, high, equality)); -}*/ - RangeInfoMapVec::RangeInfoMapVec (RangeInfoMap* rim) : _rangeInfoMapVec() { @@ -457,26 +447,6 @@ std::unordered_map* RangeInfoMapVec::find ( return _rangeInfoMapVec[pos]->find(var); } -void RangeInfoMapVec::insertAnd (std::string const& var, - std::string const& name, - RangeInfoBound low, - RangeInfoBound high, - bool equality) { - insertAnd(RangeInfo(var, name, low, high, equality)); -} - -// var.attr > 1 and var.attr < 10 - -void RangeInfoMapVec::insertAnd (RangeInfo range) { - - if (_rangeInfoMapVec.empty()) { - _rangeInfoMapVec.emplace_back(new RangeInfoMap()); - } - for (size_t i = 0; i < _rangeInfoMapVec.size(); i++) { - _rangeInfoMapVec[i]->insert(range); - } - -} bool RangeInfoMapVec::isIdenticalToExisting (RangeInfo x) { @@ -505,12 +475,11 @@ RangeInfoMapVec* triagens::aql::orCombineRangeInfoMapVecs (RangeInfoMapVec* lhs, RangeInfoMapVec* rhs) { if (lhs->empty()) { - return rhs; //TODO copy? + return rhs; } - if (rhs->empty()) { - return lhs; //TODO copy? + return lhs; } auto rimv = new RangeInfoMapVec(); diff --git a/arangod/Aql/RangeInfo.h b/arangod/Aql/RangeInfo.h index 6f74921dc4..dd6bea037d 100644 --- a/arangod/Aql/RangeInfo.h +++ b/arangod/Aql/RangeInfo.h @@ -774,49 +774,72 @@ namespace triagens { return list; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief operator[] +//////////////////////////////////////////////////////////////////////////////// + RangeInfoMap* operator[] (size_t pos) { return _rangeInfoMapVec[pos]; } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief size: the number of RangeInfoMaps in the vector +//////////////////////////////////////////////////////////////////////////////// size_t size () { return _rangeInfoMapVec.size(); } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief empty: is the vector of RangeInfoMaps empty +//////////////////////////////////////////////////////////////////////////////// bool empty () { return _rangeInfoMapVec.empty(); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief emplace_back: emplace_back RangeInfoMap in vector +//////////////////////////////////////////////////////////////////////////////// + void emplace_back (RangeInfoMap*); - void eraseEmptyOrUndefined (std::string const&); +//////////////////////////////////////////////////////////////////////////////// +/// @brief eraseEmptyOrUndefined remove all empty or undefined RangeInfos for +/// the variable in every RangeInfoMap in the vector +//////////////////////////////////////////////////////////////////////////////// - void insertAnd (std::string const& var, - std::string const& name, - RangeInfoBound low, - RangeInfoBound high, - bool equality); + void eraseEmptyOrUndefined (std::string const& var); - - void insertAnd (RangeInfo range); - - void insertOr (std::vector ranges); - - void insertOr (std::string const& var, - std::string const& name, - RangeInfoBound low, - RangeInfoBound high, - bool equality); - - void insertDistributeAndIntoOr (std::vector ranges); +//////////////////////////////////////////////////////////////////////////////// +/// @brief find: this is the same as _rangeInfoMapVec[pos]->find(var), i.e. find +/// the map of RangeInfos for the variable . +//////////////////////////////////////////////////////////////////////////////// std::unordered_map* find (std::string const& var, size_t pos); - std::vector validPositions (std::string const& var); - // in what positions are the RangeInfoMaps in the vector valid - std::unordered_set attributes (std::string const& var); +//////////////////////////////////////////////////////////////////////////////// +/// @brief isIdenticalToExisting: returns true if the input RangeInfo is +/// identical to an existing RangeInfo at any position in the vector. +//////////////////////////////////////////////////////////////////////////////// bool isIdenticalToExisting (RangeInfo); +//////////////////////////////////////////////////////////////////////////////// +/// @brief validPositions: returns a vector of the positions in the RIM vector +/// that contain valid RangeInfoMap for the variable named var +//////////////////////////////////////////////////////////////////////////////// + + std::vector validPositions (std::string const& var); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief attributes: returns a vector of the names of the attributes for the +/// variable var stored in the RIM vector. +//////////////////////////////////////////////////////////////////////////////// + + // in what positions are the RangeInfoMaps in the vector valid + std::unordered_set attributes (std::string const& var); + //////////////////////////////////////////////////////////////////////////////// /// @brief private data //////////////////////////////////////////////////////////////////////////////// @@ -825,8 +848,31 @@ namespace triagens { std::vector _rangeInfoMapVec; }; +//////////////////////////////////////////////////////////////////////////////// +/// @brief andCombineRangeInfoMaps: insert every RangeInfo in the right argument +/// in a new copy of the left argument +//////////////////////////////////////////////////////////////////////////////// + RangeInfoMap* andCombineRangeInfoMaps (RangeInfoMap*, RangeInfoMap*); + +//////////////////////////////////////////////////////////////////////////////// +/// @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* orCombineRangeInfoMapVecs (RangeInfoMapVec*, RangeInfoMapVec*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief andCombineRangeInfoMapVecs: return a new RangeInfoMapVec by +/// 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. +//////////////////////////////////////////////////////////////////////////////// + RangeInfoMapVec* andCombineRangeInfoMapVecs (RangeInfoMapVec*, RangeInfoMapVec*); ////////////////////////////////////////////////////////////////////////////////