mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'aql2' of https://github.com/triAGENS/ArangoDB into aql2
This commit is contained in:
commit
0666708206
|
@ -294,17 +294,17 @@ void IndexRangeNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
|
||||||
|
|
||||||
// put together the range info . . .
|
// put together the range info . . .
|
||||||
Json ranges(Json::List);
|
Json ranges(Json::List);
|
||||||
/*
|
|
||||||
for (auto x : *_ranges) {
|
for (auto x : *_ranges) {
|
||||||
Json item(Json::Array);
|
Json item(Json::Array);
|
||||||
item("name", Json(x._name))
|
item("name", Json(x._name))
|
||||||
("low", x._low.copy())
|
("low", x._low)
|
||||||
("lowOpen", Json(x._lowOpen))
|
("lowOpen", Json(x._lowOpen))
|
||||||
("high", x._high.copy())
|
("high", x._high)
|
||||||
("highOpen", Json(x._highOpen));
|
("highOpen", Json(x._highOpen));
|
||||||
ranges(item);
|
ranges(item);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// Now put info about vocbase and cid in there
|
// Now put info about vocbase and cid in there
|
||||||
json("database", Json(_vocbase->_name))
|
json("database", Json(_vocbase->_name))
|
||||||
("collection", Json(_collection->name))
|
("collection", Json(_collection->name))
|
||||||
|
|
|
@ -628,16 +628,23 @@ namespace triagens {
|
||||||
struct RangeInfo{
|
struct RangeInfo{
|
||||||
|
|
||||||
RangeInfo ( std::string name,
|
RangeInfo ( std::string name,
|
||||||
basics::Json low,
|
basics::Json const& low,
|
||||||
bool lowOpen,
|
bool lowOpen,
|
||||||
basics::Json high,
|
basics::Json const& high,
|
||||||
bool highOpen )
|
bool highOpen )
|
||||||
: _name(name),
|
: _name(name),
|
||||||
_low(low),
|
_low(TRI_UNKNOWN_MEM_ZONE, TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, low.json())),
|
||||||
_lowOpen(lowOpen),
|
_lowOpen(lowOpen),
|
||||||
_high(high),
|
_high(TRI_UNKNOWN_MEM_ZONE, TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, high.json())),
|
||||||
_highOpen(highOpen){}
|
_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(){}
|
~RangeInfo(){}
|
||||||
|
|
||||||
std::string _name;
|
std::string _name;
|
||||||
|
|
|
@ -47,68 +47,69 @@ namespace triagens {
|
||||||
|
|
||||||
Indexes& operator= (Indexes const& other) = delete;
|
Indexes& operator= (Indexes const& other) = delete;
|
||||||
|
|
||||||
Indexes (struct TRI_vocbase_s* vocbase)
|
Indexes ()
|
||||||
: _vocbase(vocbase),
|
: _indexes(){
|
||||||
_indexes() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~Indexes () {
|
~Indexes () {
|
||||||
for (auto it = _indexes.begin(); it != _indexes.end(); ++it) {
|
for (auto x: _indexes) {
|
||||||
delete (*it).second;
|
for (auto y: x.second){
|
||||||
|
delete y.second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Index* get (TRI_idx_iid_t id, Collection const* collection) {
|
Index* get (TRI_idx_iid_t id, Collection const* collection) {
|
||||||
auto cid = collection->cid();
|
|
||||||
// there may be multiple indexes in the same collection . . .
|
// there may be multiple indexes in the same collection . . .
|
||||||
auto it1 = _cids.begin();
|
auto it1 = _indexes.find(collection->cid());
|
||||||
|
|
||||||
do{
|
if(it1 == _indexes.end()){
|
||||||
auto it2 = _cids.find(it1, _cids.end(), cid);
|
return nullptr;
|
||||||
if (it2 == _cids.end()) { // couldn't find <cid>
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}((it2*).second.first == id || it1 == _cids.end());
|
|
||||||
|
|
||||||
if((it2*).second.first == id){
|
|
||||||
return return (it2*).second.second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
void add (TRI_idx_iid_t id, Collection const* collection) {
|
||||||
// check if index already is in our map
|
auto it = _indexes.find(collection->cid());
|
||||||
if(this.get(id, collection)!=nullptr){
|
|
||||||
auto index = new Index(id, collection);
|
if (it == _indexes.end()){
|
||||||
try {
|
_indexes.insert(std::make_pair(collection->cid(),
|
||||||
auto x = std::make_pair(id, index);
|
std::unordered_map<TRI_idx_iid_t, Index*>()));
|
||||||
_ids.insert(x);
|
}
|
||||||
_cids.insert(std::make_pair(collection->cid(), x));
|
|
||||||
}
|
auto index = new Index(id, collection);
|
||||||
catch (...) {
|
try {
|
||||||
delete index;
|
it->second.insert(std::make_pair(id, index));
|
||||||
throw;
|
}
|
||||||
}
|
catch (...) {
|
||||||
|
delete index;
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> indexIds () const {
|
std::vector<TRI_idx_iid_t> indexIds () const {
|
||||||
std::vector<std::string> result;
|
std::vector<TRI_idx_iid_t> result;
|
||||||
|
|
||||||
for (auto x : _indexes) {
|
for (auto x : _indexes) {
|
||||||
result.push_back(x.first);
|
for (auto y : x.second) {
|
||||||
|
result.push_back(y.first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct TRI_vocbase_s* _vocbase;
|
std::unordered_map<TRI_voc_cid_t, std::unordered_map<TRI_idx_iid_t, Index*>> _indexes;
|
||||||
std::map<TRI_idx_iid_t, Index*> _ids;
|
|
||||||
std::map<TRI_voc_cid_t, _indexes> _cids;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue