1
0
Fork 0

code unification

This commit is contained in:
Jan Steemann 2012-11-29 22:34:49 +01:00
parent 6233780862
commit f634b1aff0
3 changed files with 24 additions and 30 deletions

View File

@ -81,7 +81,7 @@ static TRI_aql_collection_t* CreateCollectionContainer (const char* const name)
assert(name);
collection = (TRI_aql_collection_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_aql_collection_t), false);
if (!collection) {
if (collection == NULL) {
return NULL;
}
@ -109,12 +109,12 @@ bool SetupCollections (TRI_aql_context_t* const context) {
char* name = context->_collectionNames._table[i];
TRI_aql_collection_t* collection;
if (!name) {
if (! name) {
continue;
}
collection = CreateCollectionContainer(name);
if (!collection) {
if (! collection) {
result = false;
TRI_SetErrorContextAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL);
break;
@ -149,9 +149,9 @@ bool OpenCollections (TRI_aql_context_t* const context) {
assert(collection);
assert(collection->_name);
assert(!collection->_collection);
assert(!collection->_barrier);
assert(!collection->_readLocked);
assert(! collection->_collection);
assert(! collection->_barrier);
assert(! collection->_readLocked);
LOG_TRACE("locking collection '%s'", collection->_name);
collection->_collection = TRI_UseCollectionByNameVocBase(context->_vocbase, collection->_name);
@ -357,11 +357,11 @@ void TRI_UnlockCollectionsAql (TRI_aql_context_t* const context) {
////////////////////////////////////////////////////////////////////////////////
bool TRI_LockCollectionsAql (TRI_aql_context_t* const context) {
if (!SetupCollections(context)) {
if (! SetupCollections(context)) {
return false;
}
if (!OpenCollections(context)) {
if (! OpenCollections(context)) {
TRI_UnlockCollectionsAql(context);
return false;
}
@ -390,8 +390,8 @@ bool TRI_ReadLockCollectionsAql (TRI_aql_context_t* const context) {
assert(collection->_name);
assert(collection->_collection);
assert(collection->_collection->_collection);
assert(!collection->_readLocked);
assert(!collection->_barrier);
assert(! collection->_readLocked);
assert(! collection->_barrier);
primaryCollection = (TRI_primary_collection_t*) collection->_collection->_collection;
@ -431,18 +431,18 @@ void TRI_ReadUnlockCollectionsAql (TRI_aql_context_t* const context) {
assert(collection);
assert(collection->_name);
if (!collection->_collection) {
if (! collection->_collection) {
// don't unlock collections we weren't able to lock at all
continue;
}
if (!collection->_readLocked) {
if (! collection->_readLocked) {
// don't unlock non-read-locked collections
continue;
}
assert(collection->_collection->_collection);
assert(!collection->_barrier);
assert(! collection->_barrier);
primaryCollection = (TRI_primary_collection_t*) collection->_collection->_collection;

View File

@ -210,7 +210,7 @@ TRI_aql_context_t* TRI_CreateContextAql (TRI_vocbase_t* vocbase,
return NULL;
}
if (!TRI_InitParserAql(context)) {
if (! TRI_InitParserAql(context)) {
// could not initialise the lexer
TRI_FreeContextAql(context);
@ -290,7 +290,7 @@ bool TRI_ValidateQueryContextAql (TRI_aql_context_t* const context) {
}
// parse the query
if (!TRI_ParseAql(context)) {
if (! TRI_ParseAql(context)) {
// lexing/parsing failed
return false;
}
@ -310,19 +310,19 @@ bool TRI_BindQueryContextAql (TRI_aql_context_t* const context,
const TRI_json_t* const parameters) {
// add the bind parameters
if (!TRI_AddParameterValuesAql(context, parameters)) {
if (! TRI_AddParameterValuesAql(context, parameters)) {
// adding parameters failed
return false;
}
// validate the bind parameters used/passed
if (!TRI_ValidateBindParametersAql(context)) {
if (! TRI_ValidateBindParametersAql(context)) {
// invalid bind parameters
return false;
}
// inject the bind parameter values into the query AST
if (!TRI_InjectBindParametersAql(context)) {
if (! TRI_InjectBindParametersAql(context)) {
// bind parameter injection failed
return false;
}
@ -341,7 +341,7 @@ bool TRI_BindQueryContextAql (TRI_aql_context_t* const context,
bool TRI_OptimiseQueryContextAql (TRI_aql_context_t* const context) {
// do some basic optimisations in the AST
if (!TRI_OptimiseAql(context)) {
if (! TRI_OptimiseAql(context)) {
// constant folding failed
return false;
}
@ -364,17 +364,17 @@ bool TRI_OptimiseQueryContextAql (TRI_aql_context_t* const context) {
bool TRI_LockQueryContextAql (TRI_aql_context_t* const context) {
// mark all used collections as being used
if (!TRI_LockCollectionsAql(context)) {
if (! TRI_LockCollectionsAql(context)) {
return false;
}
// acquire read locks on all collections used
if (!TRI_ReadLockCollectionsAql(context)) {
if (! TRI_ReadLockCollectionsAql(context)) {
return false;
}
// add barriers for all collections used
if (!TRI_AddBarrierCollectionsAql(context)) {
if (! TRI_AddBarrierCollectionsAql(context)) {
return false;
}
@ -421,7 +421,7 @@ char* TRI_RegisterStringAql (TRI_aql_context_t* const context,
copy = TRI_DuplicateStringZ(TRI_UNKNOWN_MEM_ZONE, value);
}
if (!copy) {
if (! copy) {
ABORT_OOM
}

View File

@ -412,7 +412,7 @@ void TRI_FreeTransactionContext (TRI_transaction_context_t* const context) {
}
TRI_DestroyAssociativePointer(&context->_collections);
// destroy mutexts
// destroy mutexes
TRI_DestroyMutex(&context->_lock);
TRI_DestroyMutex(&context->_collectionLock);
@ -590,7 +590,6 @@ static int AcquireCollectionLocks (TRI_transaction_t* const trx) {
context = trx->_context;
n = trx->_collections._length;
assert(n > 0);
// process collections in forward order
for (i = 0; i < n; ++i) {
@ -852,7 +851,6 @@ static int RegisterTransaction (TRI_transaction_t* const trx) {
int res;
assert(trx->_status == TRI_TRANSACTION_CREATED);
assert(trx->_collections._length > 0);
context = trx->_context;
@ -1161,10 +1159,6 @@ int TRI_StartTransaction (TRI_transaction_t* const trx, TRI_transaction_hint_t h
assert(trx->_status == TRI_TRANSACTION_CREATED);
if (trx->_collections._length == 0) {
return TRI_ERROR_TRANSACTION_INCOMPLETE;
}
trx->_hints = hints;
res = AcquireCollectionLocks(trx);