1
0
Fork 0

moving function getIndexes for EnumerateCollectionNode from h to cpp file.

This commit is contained in:
James 2014-08-22 10:39:41 +02:00
parent 9dfeb4bba2
commit 4ba4ec4523
2 changed files with 39 additions and 33 deletions

View File

@ -397,6 +397,44 @@ void EnumerateCollectionNode::toJsonHelper (triagens::basics::Json& nodes,
nodes(json);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief get vector of indexes with fields <attrs>
////////////////////////////////////////////////////////////////////////////////
std::vector<TRI_index_t*> EnumerateCollectionNode::getIndexes (vector<std::string> attrs) const {
std::vector<TRI_index_t*> out;
TRI_document_collection_t* document = _collection->documentCollection();
size_t const n = document->_allIndexes._length;
for (size_t i = 0; i < n; ++i) {
TRI_index_t* idx = static_cast<TRI_index_t*>(document->_allIndexes._buffer[i]);
size_t seen = 0;
for (size_t j = 0; j < idx->_fields._length; j++) {
bool found = false;
for (size_t k = 0; k < attrs.size(); k++){
if(std::string(idx->_fields._buffer[j]) == attrs[k]) {
found = true;
break;
}
}
if (found) {
seen++;
}
else {
break;
}
}
if (((idx->_type == TRI_IDX_TYPE_HASH_INDEX) && seen == idx->_fields._length )
|| ((idx->_type == TRI_IDX_TYPE_SKIPLIST_INDEX) && seen > 0 )) {
// all fields equal
out.push_back(idx);
}
}
return out;
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of EnumerateListNode
// -----------------------------------------------------------------------------

View File

@ -658,39 +658,7 @@ namespace triagens {
/// @brief get vector of indexes with fields <attrs>
////////////////////////////////////////////////////////////////////////////////
vector<TRI_index_t*> getIndexes (vector<std::string> attrs) const {
vector<TRI_index_t*> out;
TRI_document_collection_t* document = _collection->documentCollection();
size_t const n = document->_allIndexes._length;
for (size_t i = 0; i < n; ++i) {
TRI_index_t* idx = static_cast<TRI_index_t*>(document->_allIndexes._buffer[i]);
size_t seen = 0;
for (size_t j = 0; j < idx->_fields._length; j++) {
bool found = false;
for (size_t k = 0; k < attrs.size(); k++){
if(std::string(idx->_fields._buffer[j]) == attrs[k]) {
found = true;
break;
}
}
if (found) {
seen++;
}
else {
break;
}
}
if (((idx->_type == TRI_IDX_TYPE_HASH_INDEX) && seen == idx->_fields._length )
|| ((idx->_type == TRI_IDX_TYPE_SKIPLIST_INDEX) && seen > 0 )) {
// all fields equal
out.push_back(idx);
}
}
return out;
}
std::vector<TRI_index_t*> getIndexes (vector<std::string> attrs) const;
TRI_vocbase_t* vocbase () const {
return _vocbase;