diff --git a/arangod/Aql/ExecutionNode.cpp b/arangod/Aql/ExecutionNode.cpp index b4dd05cd58..ce3e500c0e 100644 --- a/arangod/Aql/ExecutionNode.cpp +++ b/arangod/Aql/ExecutionNode.cpp @@ -294,17 +294,17 @@ void IndexRangeNode::toJsonHelper (std::map& indexTab, // put together the range info . . . Json ranges(Json::List); -/* + for (auto x : *_ranges) { Json item(Json::Array); item("name", Json(x._name)) - ("low", x._low.copy()) + ("low", x._low) ("lowOpen", Json(x._lowOpen)) - ("high", x._high.copy()) + ("high", x._high) ("highOpen", Json(x._highOpen)); ranges(item); } -*/ + // Now put info about vocbase and cid in there json("database", Json(_vocbase->_name)) ("collection", Json(_collection->name)) diff --git a/arangod/Aql/ExecutionNode.h b/arangod/Aql/ExecutionNode.h index 42804edace..bc43124561 100644 --- a/arangod/Aql/ExecutionNode.h +++ b/arangod/Aql/ExecutionNode.h @@ -628,16 +628,23 @@ namespace triagens { struct RangeInfo{ RangeInfo ( std::string name, - basics::Json low, + basics::Json const& low, bool lowOpen, - basics::Json high, + basics::Json const& high, bool highOpen ) : _name(name), - _low(low), + _low(TRI_UNKNOWN_MEM_ZONE, TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, low.json())), _lowOpen(lowOpen), - _high(high), + _high(TRI_UNKNOWN_MEM_ZONE, TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, high.json())), _highOpen(highOpen){} - + + RangeInfo ( const RangeInfo& copy ) : + _name(copy._name), + _low(TRI_UNKNOWN_MEM_ZONE, TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, copy._low.json())), + _lowOpen(copy._lowOpen), + _high(TRI_UNKNOWN_MEM_ZONE, TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, copy._high.json())), + _highOpen(copy._highOpen){}; + ~RangeInfo(){} std::string _name; diff --git a/arangod/Aql/Indexes.h b/arangod/Aql/Indexes.h index 0ec7a22909..8e8efdefb4 100644 --- a/arangod/Aql/Indexes.h +++ b/arangod/Aql/Indexes.h @@ -47,68 +47,69 @@ namespace triagens { Indexes& operator= (Indexes const& other) = delete; - Indexes (struct TRI_vocbase_s* vocbase) - : _vocbase(vocbase), - _indexes() { + Indexes () + : _indexes(){ } ~Indexes () { - for (auto it = _indexes.begin(); it != _indexes.end(); ++it) { - delete (*it).second; + for (auto x: _indexes) { + for (auto y: x.second){ + delete y.second; + } } } public: Index* get (TRI_idx_iid_t id, Collection const* collection) { - auto cid = collection->cid(); // there may be multiple indexes in the same collection . . . - auto it1 = _cids.begin(); - - do{ - auto it2 = _cids.find(it1, _cids.end(), cid); - if (it2 == _cids.end()) { // couldn't find - return nullptr; - } - }((it2*).second.first == id || it1 == _cids.end()); + auto it1 = _indexes.find(collection->cid()); - if((it2*).second.first == id){ - return return (it2*).second.second; + if(it1 == _indexes.end()){ + return nullptr; } - return nullptr; + auto it2 = it1->second.find(id); + + if(it2 == it1->second.end()){ + return nullptr; + } + + return (*it2).second; } void add (TRI_idx_iid_t id, Collection const* collection) { - // check if index already is in our map - if(this.get(id, collection)!=nullptr){ - auto index = new Index(id, collection); - try { - auto x = std::make_pair(id, index); - _ids.insert(x); - _cids.insert(std::make_pair(collection->cid(), x)); - } - catch (...) { - delete index; - throw; - } + auto it = _indexes.find(collection->cid()); + + if (it == _indexes.end()){ + _indexes.insert(std::make_pair(collection->cid(), + std::unordered_map())); + } + + auto index = new Index(id, collection); + try { + it->second.insert(std::make_pair(id, index)); + } + catch (...) { + delete index; + throw; } } - std::vector indexIds () const { - std::vector result; + std::vector indexIds () const { + std::vector result; for (auto x : _indexes) { - result.push_back(x.first); + for (auto y : x.second) { + result.push_back(y.first); + } } return result; } private: - struct TRI_vocbase_s* _vocbase; - std::map _ids; - std::map _cids; + std::unordered_map> _indexes; }; }