1
0
Fork 0

changed some include headers around

This commit is contained in:
Jan Steemann 2015-09-07 17:09:10 +02:00
parent b6a1684605
commit 8b599b5274
6 changed files with 52 additions and 38 deletions

View File

@ -34,9 +34,8 @@
#include "Basics/Exceptions.h"
#include "Basics/json.h"
#include "Basics/JsonHelper.h"
#include "Indexes/HashIndex.h"
#include "Indexes/Index.h"
#include "Indexes/SkiplistIndex.h"
#include "Indexes/PathBasedIndex.h"
namespace triagens {
namespace aql {
@ -67,15 +66,11 @@ namespace triagens {
if (type == triagens::arango::Index::TRI_IDX_TYPE_PRIMARY_INDEX) {
unique = true;
}
else if (type == triagens::arango::Index::TRI_IDX_TYPE_HASH_INDEX) {
auto hashIndex = static_cast<triagens::arango::HashIndex const*>(idx);
sparse = hashIndex->sparse();
unique = hashIndex->unique();
}
else if (type == triagens::arango::Index::TRI_IDX_TYPE_SKIPLIST_INDEX) {
auto skiplistIndex = static_cast<triagens::arango::SkiplistIndex const*>(idx);
sparse = skiplistIndex->sparse();
unique = skiplistIndex->unique();
else if (type == triagens::arango::Index::TRI_IDX_TYPE_HASH_INDEX ||
type == triagens::arango::Index::TRI_IDX_TYPE_SKIPLIST_INDEX) {
auto pathBasedIndex = static_cast<triagens::arango::PathBasedIndex const*>(idx);
sparse = pathBasedIndex->sparse();
unique = pathBasedIndex->unique();
}
}

View File

@ -31,6 +31,7 @@
#include "Aql/Collection.h"
#include "Aql/ExecutionBlock.h"
#include "Aql/ExecutionNode.h"
#include "Indexes/SkiplistIndex.h"
#include "Utils/AqlTransaction.h"
#include "VocBase/shaped-json.h"

View File

@ -32,6 +32,7 @@
#include "Aql/AstNode.h"
#include "Basics/JsonHelper.h"
#include "Basics/json-utilities.h"
#include "IndexOperators/index-operator.h"
class VocShaper;

View File

@ -203,7 +203,7 @@ HashIndex::HashIndex (TRI_idx_iid_t iid,
indexBuckets = collection->_info._indexBuckets;
}
std::unique_ptr<HashElementFunc> func(new HashElementFunc(numPaths()));
std::unique_ptr<HashElementFunc> func(new HashElementFunc(_paths.size()));
if (unique) {
std::unique_ptr<IsEqualElementElementByKey> compare(new IsEqualElementElementByKey(_paths.size()));
@ -221,7 +221,7 @@ HashIndex::HashIndex (TRI_idx_iid_t iid,
else {
_multiArray = nullptr;
std::unique_ptr<IsEqualElementElementByKey> compare(new IsEqualElementElementByKey(numPaths()));
std::unique_ptr<IsEqualElementElementByKey> compare(new IsEqualElementElementByKey(_paths.size()));
std::unique_ptr<TRI_HashArrayMulti_t> array(new TRI_HashArrayMulti_t(HashKey,
*(func.get()),
@ -494,13 +494,14 @@ int HashIndex::insertUnique (TRI_doc_mptr_t const* doc,
return _uniqueArray->_hashArray->insert(element);
};
size_t count = elements.size();
for (size_t i = 0; i < count; ++i) {
size_t const n = elements.size();
for (size_t i = 0; i < n; ++i) {
auto hashElement = elements[i];
res = work(hashElement, isRollback);
if (res != TRI_ERROR_NO_ERROR) {
for (size_t j = i; j < count; ++j) {
for (size_t j = i; j < n; ++j) {
// Free all elements that are not yet in the index
FreeElement(elements[j]);
}
@ -527,6 +528,7 @@ int HashIndex::batchInsertUnique (std::vector<TRI_doc_mptr_t const*> const* docu
return res;
}
}
int res = _uniqueArray->_hashArray->batchInsert(&elements, numThreads);
if (res != TRI_ERROR_NO_ERROR) {
@ -545,6 +547,12 @@ int HashIndex::insertMulti (TRI_doc_mptr_t const* doc,
std::vector<TRI_index_element_t*> elements;
int res = fillElement(elements, doc);
if (res != TRI_ERROR_NO_ERROR) {
for (auto& hashElement : elements) {
FreeElement(hashElement);
}
}
auto work = [this] (TRI_index_element_t* element, bool isRollback) -> int {
TRI_IF_FAILURE("InsertHashIndex") {
@ -564,12 +572,14 @@ int HashIndex::insertMulti (TRI_doc_mptr_t const* doc,
return TRI_ERROR_NO_ERROR;
};
size_t const count = elements.size();
for (size_t i = 0; i < count; ++i) {
size_t const n = elements.size();
for (size_t i = 0; i < n; ++i) {
auto hashElement = elements[i];
res = work(hashElement, isRollback);
if (res != TRI_ERROR_NO_ERROR) {
for (size_t j = i; j < count; ++j) {
for (size_t j = i; j < n; ++j) {
// Free all elements that are not yet in the index
FreeElement(elements[j]);
}
@ -643,29 +653,36 @@ int HashIndex::removeUnique (TRI_doc_mptr_t const* doc, bool isRollback) {
}
int HashIndex::removeMultiElement (TRI_index_element_t* element, bool isRollback) {
TRI_IF_FAILURE("RemoveHashIndex") {
return TRI_ERROR_DEBUG;
}
TRI_IF_FAILURE("RemoveHashIndex") {
return TRI_ERROR_DEBUG;
}
TRI_index_element_t* old = _multiArray->_hashArray->remove(element);
if (old == nullptr) {
// not found
if (isRollback) { // ignore in this case, because it can happen
return TRI_ERROR_NO_ERROR;
}
else {
return TRI_ERROR_INTERNAL;
}
TRI_index_element_t* old = _multiArray->_hashArray->remove(element);
if (old == nullptr) {
// not found
if (isRollback) { // ignore in this case, because it can happen
return TRI_ERROR_NO_ERROR;
}
FreeElement(old);
return TRI_ERROR_NO_ERROR;
else {
return TRI_ERROR_INTERNAL;
}
}
FreeElement(old);
return TRI_ERROR_NO_ERROR;
}
int HashIndex::removeMulti (TRI_doc_mptr_t const* doc, bool isRollback) {
std::vector<TRI_index_element_t*> elements;
int res = fillElement(elements, doc);
if (res != TRI_ERROR_NO_ERROR) {
for (auto& hashElement : elements) {
FreeElement(hashElement);
}
}
for (auto& hashElement : elements) {
res = removeMultiElement(hashElement, isRollback);
FreeElement(hashElement);

View File

@ -34,6 +34,7 @@
#include "Basics/string-buffer.h"
#include "Indexes/FulltextIndex.h"
#include "Indexes/GeoIndex2.h"
#include "Indexes/HashIndex.h"
#include "Indexes/SkiplistIndex.h"
#include "FulltextIndex/fulltext-index.h"
#include "FulltextIndex/fulltext-result.h"

View File

@ -323,11 +323,11 @@ namespace triagens {
uint64_t i = hash % n;
uint64_t k = i;
for (; i < n && b._table[i] != nullptr &&
! _isEqualElementElementByKey(element, b._table[i]); ++i);
for (; i < n && b._table[i] != nullptr &&
! _isEqualElementElementByKey(element, b._table[i]); ++i);
if (i == n) {
for (i = 0; i < k && b._table[i] != nullptr &&
! _isEqualElementElementByKey(element, b._table[i]); ++i);
! _isEqualElementElementByKey(element, b._table[i]); ++i);
}
Element* arrayElement = b._table[i];
@ -337,7 +337,6 @@ namespace triagens {
}
b._table[i] = element;
TRI_ASSERT(b._table[i] != nullptr);
b._nrUsed++;
return TRI_ERROR_NO_ERROR;