1
0
Fork 0

Merge branch 'devel' of ssh://github.com/ArangoDB/ArangoDB into devel

This commit is contained in:
Max Neunhoeffer 2015-05-15 17:19:46 -07:00
commit eef79e68eb
7 changed files with 47 additions and 34 deletions

View File

@ -198,8 +198,8 @@ ExecutionEngine::~ExecutionEngine () {
// shutdown can throw - ignore it in the destructor
}
for (auto it = _blocks.begin(); it != _blocks.end(); ++it) {
delete (*it);
for (auto& it : _blocks) {
delete it;
}
}

View File

@ -138,7 +138,7 @@ void Profile::enter (ExecutionState state) {
TRI_json_t* Profile::toJson (TRI_memory_zone_t*) {
triagens::basics::Json result(triagens::basics::Json::Object);
for (auto& it : results) {
for (auto const& it : results) {
result.set(StateNames[static_cast<int>(it.first)].c_str(), triagens::basics::Json(it.second));
}
return result.steal();

View File

@ -265,7 +265,8 @@ triagens::basics::Json RestCursorHandler::buildExtra (triagens::aql::QueryResult
///
/// - *batchSize*: maximum number of result documents to be transferred from
/// the server to the client in one roundtrip (optional). If this attribute is
/// not set, a server-controlled default value will be used.
/// not set, a server-controlled default value will be used. A *batchSize* value of
/// *0* is disallowed.
///
/// - *ttl*: an optional time-to-live for the cursor (in seconds). The cursor will be
/// removed on the server automatically after the specified amount of time. This

View File

@ -30,6 +30,7 @@
#include "voc-shaper.h"
#include "Basics/Exceptions.h"
#include "Basics/fasthash.h"
#include "Basics/Mutex.h"
#include "Basics/MutexLocker.h"
#include "Basics/ReadLocker.h"
@ -67,9 +68,10 @@ typedef struct voc_shaper_s {
TRI_document_collection_t* _collection;
triagens::basics::ReadWriteLock _accessorLock;
triagens::basics::Mutex _shapeLock;
triagens::basics::Mutex _attributeLock;
triagens::basics::ReadWriteLock _accessorLock[8];
}
voc_shaper_t;
@ -899,11 +901,12 @@ TRI_shape_access_t const* TRI_FindAccessorVocShaper (TRI_shaper_t* s,
TRI_shape_pid_t pid) {
TRI_shape_access_t search = { sid, pid, 0, nullptr };
size_t const lockId = static_cast<size_t>(fasthash64(&sid, sizeof(TRI_shape_sid_t), fasthash64(&pid, sizeof(TRI_shape_pid_t), 0x87654321)) % 8);
voc_shaper_t* shaper = (voc_shaper_t*) s;
TRI_shape_access_t const* found;
{
READ_LOCKER(shaper->_accessorLock);
READ_LOCKER(shaper->_accessorLock[lockId]);
found = static_cast<TRI_shape_access_t const*>(TRI_LookupByElementAssociativePointer(&shaper->_accessors, &search));
@ -922,7 +925,8 @@ TRI_shape_access_t const* TRI_FindAccessorVocShaper (TRI_shaper_t* s,
// acquire the write-lock and try to insert our own accessor
{
WRITE_LOCKER(shaper->_accessorLock);
WRITE_LOCKER(shaper->_accessorLock[lockId]);
found = static_cast<TRI_shape_access_t const*>(TRI_InsertElementAssociativePointer(&shaper->_accessors, const_cast<void*>(static_cast<void const*>(accessor)), false));
}

View File

@ -755,12 +755,11 @@ void* TRI_LookupByKeyAssociativePointer (TRI_associative_pointer_t* array,
void* TRI_LookupByElementAssociativePointer (TRI_associative_pointer_t* array,
void const* element) {
uint64_t hash;
uint64_t i;
// compute the hash
hash = array->hashElement(array, element);
i = hash % array->_nrAlloc;
uint64_t const hash = array->hashElement(array, element);
uint64_t const n = array->_nrAlloc;
uint64_t i, k;
i = k = hash % n;
#ifdef TRI_INTERNAL_STATS
// update statistics
@ -768,11 +767,10 @@ void* TRI_LookupByElementAssociativePointer (TRI_associative_pointer_t* array,
#endif
// search the table
while (array->_table[i] != NULL && ! array->isEqualElementElement(array, element, array->_table[i])) {
i = TRI_IncModU64(i, array->_nrAlloc);
#ifdef TRI_INTERNAL_STATS
array->_nrProbesF++;
#endif
for (; i < n && array->_table[i] != nullptr && ! array->isEqualElementElement(array, element, array->_table[i]); ++i);
if (i == n) {
for (i = 0; i < k && array->_table[i] != nullptr && ! array->isEqualElementElement(array, element, array->_table[i]); ++i);
}
// return whatever we found
@ -1231,19 +1229,22 @@ void TRI_FreeAssociativeSynced (TRI_memory_zone_t* zone, TRI_associative_synced_
void const* TRI_LookupByKeyAssociativeSynced (TRI_associative_synced_t* array,
void const* key) {
uint64_t hash;
uint64_t i;
void const* result;
// compute the hash
hash = array->hashKey(array, key);
uint64_t const hash = array->hashKey(array, key);
// search the table
TRI_ReadLockReadWriteLock(&array->_lock);
i = hash % array->_nrAlloc;
uint64_t const n = array->_nrAlloc;
uint64_t i, k;
while (array->_table[i] != NULL && ! array->isEqualKeyElement(array, key, array->_table[i])) {
i = TRI_IncModU64(i, array->_nrAlloc);
i = k = hash % n;
for (; i < n && array->_table[i] != nullptr && ! array->isEqualKeyElement(array, key, array->_table[i]); ++i);
if (i == n) {
for (i = 0; i < k && array->_table[i] != nullptr && ! array->isEqualKeyElement(array, key, array->_table[i]); ++i);
}
result = array->_table[i];
@ -1260,19 +1261,22 @@ void const* TRI_LookupByKeyAssociativeSynced (TRI_associative_synced_t* array,
void const* TRI_LookupByElementAssociativeSynced (TRI_associative_synced_t* array,
void const* element) {
uint64_t hash;
uint64_t i;
void const* result;
// compute the hash
hash = array->hashElement(array, element);
uint64_t const hash = array->hashElement(array, element);
// search the table
TRI_ReadLockReadWriteLock(&array->_lock);
i = hash % array->_nrAlloc;
uint64_t const n = array->_nrAlloc;
uint64_t i, k;
while (array->_table[i] != NULL && ! array->isEqualElementElement(array, element, array->_table[i])) {
i = TRI_IncModU64(i, array->_nrAlloc);
i = k = hash % n;
for (; i < n && array->_table[i] != nullptr && ! array->isEqualElementElement(array, element, array->_table[i]); ++i);
if (i == n) {
for (i = 0; i < k && array->_table[i] != nullptr && ! array->isEqualElementElement(array, element, array->_table[i]); ++i);
}
result = array->_table[i];

View File

@ -411,14 +411,18 @@ T TRI_ProcessByKeyAssociativeSynced (TRI_associative_synced_t* array,
void const* key,
std::function<T(void const*)> callback) {
// compute the hash
uint64_t hash = array->hashKey(array, key);
uint64_t const hash = array->hashKey(array, key);
// search the table
TRI_ReadLockReadWriteLock(&array->_lock);
uint64_t i = hash % array->_nrAlloc;
uint64_t const n = array->_nrAlloc;
uint64_t i, k;
i = k = hash % n;
while (array->_table[i] != NULL && ! array->isEqualKeyElement(array, key, array->_table[i])) {
i = TRI_IncModU64(i, array->_nrAlloc);
for (; i < n && array->_table[i] != nullptr && ! array->isEqualKeyElement(array, key, array->_table[i]); ++i);
if (i == n) {
for (i = 0; i < k && array->_table[i] != nullptr && ! array->isEqualKeyElement(array, key, array->_table[i]); ++i);
}
T result = callback(array->_table[i]);

View File

@ -198,7 +198,7 @@ static bool EqualNameKeyAttributePath (TRI_associative_synced_t* array,
char const* e = static_cast<char const*>(element);
TRI_shape_path_t const* ee = static_cast<TRI_shape_path_t const*>(element);
return TRI_EqualString(k,e + sizeof(TRI_shape_path_t) + ee->_aidLength * sizeof(TRI_shape_aid_t));
return TRI_EqualString(k, e + sizeof(TRI_shape_path_t) + ee->_aidLength * sizeof(TRI_shape_aid_t));
}
////////////////////////////////////////////////////////////////////////////////