mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel
This commit is contained in:
commit
8e141d84f4
|
@ -211,7 +211,7 @@ for_statement:
|
|||
}
|
||||
|
||||
node = TRI_CreateNodeForAql(context, $2, $4);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ for_statement:
|
|||
filter_statement:
|
||||
T_FILTER expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeFilterAql(context, $2);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ filter_statement:
|
|||
let_statement:
|
||||
T_LET variable_name T_ASSIGN expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeLetAql(context, $2, $4);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -251,14 +251,14 @@ collect_statement:
|
|||
T_COLLECT {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeListAql(context);
|
||||
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
TRI_PushStackParseAql(context, node);
|
||||
} collect_list optional_into {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeCollectAql(context, TRI_PopStackParseAql(context), $4);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ collect_list:
|
|||
collect_element:
|
||||
variable_name T_ASSIGN expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeAssignAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ sort_statement:
|
|||
T_SORT {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeListAql(context);
|
||||
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ sort_statement:
|
|||
} sort_list {
|
||||
TRI_aql_node_t* list = TRI_PopStackParseAql(context);
|
||||
TRI_aql_node_t* node = TRI_CreateNodeSortAql(context, list);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ sort_list:
|
|||
sort_element:
|
||||
expression sort_direction {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeSortElementAql(context, $1, $2);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ sort_direction:
|
|||
limit_statement:
|
||||
T_LIMIT integer_value {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeLimitAql(context, TRI_CreateNodeValueIntAql(context, 0), $2);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ limit_statement:
|
|||
}
|
||||
| T_LIMIT integer_value T_COMMA integer_value {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeLimitAql(context, $2, $4);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ limit_statement:
|
|||
return_statement:
|
||||
T_RETURN expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeReturnAql(context, $2);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ function_call:
|
|||
}
|
||||
|
||||
node = TRI_CreateNodeListAql(context);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ function_call:
|
|||
} T_OPEN optional_function_call_arguments T_CLOSE %prec FUNCCALL {
|
||||
TRI_aql_node_t* list = TRI_PopStackParseAql(context);
|
||||
TRI_aql_node_t* node = TRI_CreateNodeFcallAql(context, TRI_PopStackParseAql(context), list);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,7 @@ function_call:
|
|||
operator_unary:
|
||||
T_PLUS expression %prec UPLUS {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorUnaryPlusAql(context, $2);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ operator_unary:
|
|||
}
|
||||
| T_MINUS expression %prec UMINUS {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorUnaryMinusAql(context, $2);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -504,7 +504,7 @@ operator_unary:
|
|||
}
|
||||
| T_NOT expression %prec T_NOT {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorUnaryNotAql(context, $2);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ operator_unary:
|
|||
operator_binary:
|
||||
expression T_OR expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryOrAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_AND expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryAndAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -531,7 +531,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_PLUS expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryPlusAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -539,7 +539,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_MINUS expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryMinusAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_TIMES expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryTimesAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -555,7 +555,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_DIV expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryDivAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -563,7 +563,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_MOD expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryModAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -571,7 +571,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_EQ expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryEqAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -579,7 +579,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_NE expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryNeAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -587,7 +587,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_LT expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryLtAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -595,7 +595,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_GT expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryGtAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -603,7 +603,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_LE expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryLeAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -611,7 +611,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_GE expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryGeAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -619,7 +619,7 @@ operator_binary:
|
|||
}
|
||||
| expression T_IN expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryInAql(context, $1, $3);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -630,7 +630,7 @@ operator_binary:
|
|||
operator_ternary:
|
||||
expression T_QUESTION expression T_COLON expression {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeOperatorTernaryAql(context, $1, $3, $5);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -666,7 +666,7 @@ compound_type:
|
|||
list:
|
||||
T_LIST_OPEN {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeListAql(context);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -699,7 +699,7 @@ list_elements_list:
|
|||
array:
|
||||
T_DOC_OPEN {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeArrayAql(context);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -754,7 +754,7 @@ reference:
|
|||
// create a temporary variable for the row iterator (will be popped by "expansion" rule")
|
||||
node = TRI_CreateNodeReferenceAql(context, varname);
|
||||
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -800,7 +800,7 @@ single_reference:
|
|||
node = TRI_CreateNodeCollectionAql(context, $1);
|
||||
}
|
||||
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -880,7 +880,7 @@ atomic_value:
|
|||
value_literal:
|
||||
T_QUOTED_STRING {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeValueStringAql(context, $1);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -904,7 +904,7 @@ value_literal:
|
|||
}
|
||||
|
||||
node = TRI_CreateNodeValueDoubleAql(context, value);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -912,7 +912,7 @@ value_literal:
|
|||
}
|
||||
| T_NULL {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeValueNullAql(context);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -920,7 +920,7 @@ value_literal:
|
|||
}
|
||||
| T_TRUE {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeValueBoolAql(context, true);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -928,7 +928,7 @@ value_literal:
|
|||
}
|
||||
| T_FALSE {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeValueBoolAql(context, false);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -939,7 +939,7 @@ value_literal:
|
|||
bind_parameter:
|
||||
T_PARAMETER {
|
||||
TRI_aql_node_t* node = TRI_CreateNodeParameterAql(context, $1);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
@ -981,7 +981,7 @@ integer_value:
|
|||
}
|
||||
|
||||
node = TRI_CreateNodeValueIntAql(context, value);
|
||||
if (! node) {
|
||||
if (node == NULL) {
|
||||
ABORT_OOM
|
||||
}
|
||||
|
||||
|
|
|
@ -779,6 +779,13 @@ bool ApplicationV8::prepareV8Instance (const size_t i) {
|
|||
context->_isolate->Exit();
|
||||
delete context->_locker;
|
||||
|
||||
// regular shutdown... wait for all threads to finish
|
||||
_vocbase->_state = 2;
|
||||
TRI_JoinThread(&_vocbase->_synchroniser);
|
||||
TRI_JoinThread(&_vocbase->_compactor);
|
||||
_vocbase->_state = 3;
|
||||
TRI_JoinThread(&_vocbase->_cleanup);
|
||||
|
||||
TRI_EXIT_FUNCTION(EXIT_SUCCESS, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,26 +54,36 @@
|
|||
/// @brief hashes the collection id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
static uint64_t HashKeyCid (TRI_associative_pointer_t* array, void const* key) {
|
||||
TRI_voc_cid_t const* k = key;
|
||||
|
||||
return (uint64_t) *k;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief hashs the collection id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
static uint64_t HashElementCid (TRI_associative_pointer_t* array, void const* element) {
|
||||
TRI_transaction_collection_global_t const* e = element;
|
||||
|
||||
return (uint64_t) e->_cid;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief compares a collection id and a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
static bool EqualKeyCid (TRI_associative_pointer_t* array, void const* key, void const* element) {
|
||||
TRI_voc_cid_t const* k = key;
|
||||
TRI_transaction_collection_global_t const* e = element;
|
||||
|
@ -81,10 +91,14 @@ static bool EqualKeyCid (TRI_associative_pointer_t* array, void const* key, void
|
|||
return *k == e->_cid;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a global instance of a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
static TRI_transaction_collection_global_t* CreateGlobalInstance (TRI_voc_cid_t cid) {
|
||||
TRI_transaction_collection_global_t* globalInstance;
|
||||
|
||||
|
@ -104,19 +118,27 @@ static TRI_transaction_collection_global_t* CreateGlobalInstance (TRI_voc_cid_t
|
|||
return globalInstance;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a global instance of a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
static void FreeGlobalInstance (TRI_transaction_collection_global_t* globalInstance) {
|
||||
TRI_DestroyReadWriteLock(&globalInstance->_lock);
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, globalInstance);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the global instance of a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
static TRI_transaction_collection_global_t* GetGlobalInstance (TRI_transaction_context_t* context,
|
||||
TRI_voc_cid_t cid,
|
||||
const bool create) {
|
||||
|
@ -153,7 +175,8 @@ static TRI_transaction_collection_global_t* GetGlobalInstance (TRI_transaction_c
|
|||
TRI_WriteUnlockReadWriteLock(&context->_collectionsLock);
|
||||
|
||||
if (found != NULL) {
|
||||
// someone else inserted another global instance. so we'll return it
|
||||
// someone else inserted the global instance instead. so we'll return the
|
||||
// already existing one
|
||||
FreeGlobalInstance(globalInstance);
|
||||
globalInstance = found;
|
||||
}
|
||||
|
@ -162,10 +185,14 @@ static TRI_transaction_collection_global_t* GetGlobalInstance (TRI_transaction_c
|
|||
return globalInstance;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief update the global transaction statistics
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
static int UpdateGlobalStats (const TRI_transaction_t const* trx,
|
||||
const TRI_transaction_status_e status) {
|
||||
size_t i, n;
|
||||
|
@ -215,6 +242,8 @@ static int UpdateGlobalStats (const TRI_transaction_t const* trx,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -242,7 +271,8 @@ TRI_transaction_context_t* TRI_CreateTransactionContext (TRI_vocbase_t* const vo
|
|||
}
|
||||
|
||||
context->_vocbase = vocbase;
|
||||
|
||||
|
||||
#if 0
|
||||
TRI_InitAssociativePointer(&context->_collections,
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
HashKeyCid,
|
||||
|
@ -250,6 +280,7 @@ TRI_transaction_context_t* TRI_CreateTransactionContext (TRI_vocbase_t* const vo
|
|||
EqualKeyCid,
|
||||
NULL);
|
||||
TRI_InitReadWriteLock(&context->_collectionsLock);
|
||||
#endif
|
||||
|
||||
return context;
|
||||
}
|
||||
|
@ -259,8 +290,10 @@ TRI_transaction_context_t* TRI_CreateTransactionContext (TRI_vocbase_t* const vo
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeTransactionContext (TRI_transaction_context_t* const context) {
|
||||
#if 0
|
||||
TRI_DestroyAssociativePointer(&context->_collections);
|
||||
TRI_DestroyReadWriteLock(&context->_collectionsLock);
|
||||
#endif
|
||||
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, context);
|
||||
}
|
||||
|
@ -285,6 +318,8 @@ void TRI_FreeTransactionContext (TRI_transaction_context_t* const context) {
|
|||
|
||||
void TRI_RemoveCollectionTransactionContext (TRI_transaction_context_t* context,
|
||||
const TRI_voc_cid_t cid) {
|
||||
#if 0
|
||||
|
||||
TRI_transaction_collection_global_t* globalInstance;
|
||||
|
||||
globalInstance = GetGlobalInstance(context, cid, false);
|
||||
|
@ -297,12 +332,16 @@ void TRI_RemoveCollectionTransactionContext (TRI_transaction_context_t* context,
|
|||
|
||||
FreeGlobalInstance(globalInstance);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief populates a struct with transaction statistics for a collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
int TRI_StatsCollectionTransactionContext (TRI_transaction_context_t* context,
|
||||
const TRI_voc_cid_t cid,
|
||||
TRI_transaction_collection_stats_t* stats) {
|
||||
|
@ -321,6 +360,8 @@ int TRI_StatsCollectionTransactionContext (TRI_transaction_context_t* context,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -512,10 +553,8 @@ static int WriteCollectionOperations (TRI_transaction_collection_t* trxCollectio
|
|||
// write the individual operations
|
||||
for (i = 0; i < n; ++i) {
|
||||
transaction_operation_t* trxOperation;
|
||||
bool waitForSync;
|
||||
|
||||
trxOperation = TRI_AtVector(trxCollection->_operations, i);
|
||||
waitForSync = (trxCollection->_waitForSync && (i == n - 1));
|
||||
|
||||
res = TRI_WriteOperationDocumentCollection(document,
|
||||
(TRI_document_operation_e) trxOperation->_type,
|
||||
|
@ -523,7 +562,7 @@ static int WriteCollectionOperations (TRI_transaction_collection_t* trxCollectio
|
|||
&trxOperation->_oldHeader,
|
||||
trxOperation->_marker,
|
||||
trxOperation->_markerSize,
|
||||
waitForSync);
|
||||
false);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
break;
|
||||
|
@ -548,7 +587,7 @@ static int WriteCollectionOperations (TRI_transaction_collection_t* trxCollectio
|
|||
commitMarker->base._size,
|
||||
NULL,
|
||||
&result,
|
||||
false);
|
||||
trxCollection->_waitForSync);
|
||||
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, commitMarker);
|
||||
}
|
||||
|
@ -568,7 +607,7 @@ static int WriteCollectionOperations (TRI_transaction_collection_t* trxCollectio
|
|||
abortMarker->base._size,
|
||||
NULL,
|
||||
&result,
|
||||
false);
|
||||
trxCollection->_waitForSync);
|
||||
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, abortMarker);
|
||||
}
|
||||
|
@ -715,6 +754,7 @@ static TRI_transaction_collection_t* CreateCollection (TRI_transaction_t* trx,
|
|||
const TRI_transaction_type_e accessType,
|
||||
const int nestingLevel) {
|
||||
TRI_transaction_collection_t* trxCollection;
|
||||
#if 0
|
||||
TRI_transaction_collection_global_t* globalInstance;
|
||||
|
||||
globalInstance = GetGlobalInstance(trx->_context, cid, true);
|
||||
|
@ -722,6 +762,7 @@ static TRI_transaction_collection_t* CreateCollection (TRI_transaction_t* trx,
|
|||
if (globalInstance == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
trxCollection = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_transaction_collection_t), false);
|
||||
|
||||
|
@ -736,7 +777,9 @@ static TRI_transaction_collection_t* CreateCollection (TRI_transaction_t* trx,
|
|||
trxCollection->_accessType = accessType;
|
||||
trxCollection->_nestingLevel = nestingLevel;
|
||||
trxCollection->_collection = NULL;
|
||||
#if 0
|
||||
trxCollection->_globalInstance = globalInstance;
|
||||
#endif
|
||||
trxCollection->_operations = NULL;
|
||||
trxCollection->_locked = false;
|
||||
trxCollection->_waitForSync = false;
|
||||
|
@ -819,6 +862,8 @@ static int UnlockCollection (TRI_transaction_collection_t* trxCollection,
|
|||
/// @brief notify all collections of a transaction status change
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
static int NotifyCollections (TRI_transaction_t* const trx,
|
||||
const TRI_transaction_status_e status) {
|
||||
size_t i, n;
|
||||
|
@ -854,6 +899,8 @@ static int NotifyCollections (TRI_transaction_t* const trx,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief use all participating collections of a transaction
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -967,10 +1014,16 @@ static int UpdateTransactionStatus (TRI_transaction_t* const trx,
|
|||
status == TRI_TRANSACTION_ABORTED ||
|
||||
status == TRI_TRANSACTION_COMMITTED) {
|
||||
// notify all participating collections about the status change
|
||||
// currently not necessary. TODO: re-add later with concurrent indexes
|
||||
#if 0
|
||||
UpdateGlobalStats(trx, status);
|
||||
#endif
|
||||
|
||||
// update the global statistics
|
||||
// currently not necessary. TODO: re-add later with concurrent indexes
|
||||
#if 0
|
||||
NotifyCollections(trx, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
trx->_status = status;
|
||||
|
|
|
@ -129,8 +129,10 @@ TRI_transaction_status_e;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_transaction_context_s {
|
||||
#if 0
|
||||
TRI_read_write_lock_t _collectionsLock;
|
||||
TRI_associative_pointer_t _collections;
|
||||
#endif
|
||||
|
||||
struct TRI_vocbase_s* _vocbase;
|
||||
}
|
||||
|
@ -139,7 +141,9 @@ TRI_transaction_context_t;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the stats for a global instance of a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
typedef struct TRI_transaction_collection_stats_s {
|
||||
TRI_voc_tid_t _lastStartedReader;
|
||||
TRI_voc_tid_t _lastFinishedReader;
|
||||
|
@ -150,10 +154,14 @@ typedef struct TRI_transaction_collection_stats_s {
|
|||
}
|
||||
TRI_transaction_collection_stats_t;
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief global instance of a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
typedef struct TRI_transaction_collection_global_s {
|
||||
TRI_voc_cid_t _cid;
|
||||
TRI_read_write_lock_t _lock;
|
||||
|
@ -162,6 +170,8 @@ typedef struct TRI_transaction_collection_global_s {
|
|||
}
|
||||
TRI_transaction_collection_global_t;
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -212,10 +222,14 @@ void TRI_RemoveCollectionTransactionContext (TRI_transaction_context_t*,
|
|||
/// @brief populates a struct with transaction statistics for a collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
|
||||
int TRI_StatsCollectionTransactionContext (TRI_transaction_context_t*,
|
||||
const TRI_voc_cid_t,
|
||||
TRI_transaction_collection_stats_t*);
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -278,7 +292,9 @@ typedef struct TRI_transaction_collection_s {
|
|||
TRI_transaction_type_e _accessType; // access type (read|write)
|
||||
int _nestingLevel; // the transaction level that added this collection
|
||||
struct TRI_vocbase_col_s* _collection; // vocbase collection pointer
|
||||
#if 0
|
||||
TRI_transaction_collection_global_t* _globalInstance; // pointer to the global instance
|
||||
#endif
|
||||
TRI_vector_t* _operations; // buffered CRUD operations
|
||||
bool _locked; // collection lock flag
|
||||
bool _waitForSync; // whether or not the collection has waitForSync
|
||||
|
|
|
@ -233,6 +233,8 @@ static bool UnregisterCollection (TRI_vocbase_t* vocbase, TRI_vocbase_col_t* col
|
|||
TRI_RemoveKeyAssociativePointer(&vocbase->_collectionsByName, collection->_name);
|
||||
TRI_RemoveKeyAssociativePointer(&vocbase->_collectionsById, &collection->_cid);
|
||||
|
||||
TRI_ASSERT_MAINTAINER(vocbase->_collectionsByName._nrUsed == vocbase->_collectionsById._nrUsed);
|
||||
|
||||
TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -27,9 +27,49 @@
|
|||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function ColourMapper(svg) {
|
||||
function ColourMapper() {
|
||||
"use strict";
|
||||
|
||||
var mapCreated = false,
|
||||
mapping = {},
|
||||
colours = [],
|
||||
nextColour = 0;
|
||||
|
||||
colours.push("navy");
|
||||
colours.push("green");
|
||||
colours.push("gold");
|
||||
colours.push("indigo");
|
||||
colours.push("saddlebrown");
|
||||
colours.push("skyblue");
|
||||
colours.push("olive");
|
||||
colours.push("deeppink");
|
||||
colours.push("orange");
|
||||
colours.push("silver");
|
||||
colours.push("blue");
|
||||
colours.push("yellowgreen");
|
||||
colours.push("firebrick");
|
||||
colours.push("rosybrown");
|
||||
colours.push("hotpink");
|
||||
colours.push("purple");
|
||||
colours.push("cyan");
|
||||
colours.push("teal");
|
||||
colours.push("peru");
|
||||
colours.push("maroon");
|
||||
|
||||
this.getColour = function(value) {
|
||||
if (mapping[value] === undefined) {
|
||||
mapping[value] = colours[nextColour];
|
||||
nextColour++;
|
||||
if (nextColour === colours.length) {
|
||||
nextColour = 0;
|
||||
}
|
||||
}
|
||||
return mapping[value];
|
||||
};
|
||||
|
||||
this.reset = function() {
|
||||
mapping = {};
|
||||
nextColour = 0;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global NodeShaper*/
|
||||
/*global document */
|
||||
/*global $, d3*/
|
||||
/*global ColourMapper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
|
@ -38,68 +37,56 @@
|
|||
|
||||
describe('Colour Mapper', function() {
|
||||
|
||||
var svg, mapper;
|
||||
var mapper;
|
||||
|
||||
beforeEach(function () {
|
||||
svg = document.createElement("svg");
|
||||
document.body.appendChild(svg);
|
||||
mapper = new ColourMapper(d3.select("svg"));
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
document.body.removeChild(svg);
|
||||
mapper = new ColourMapper();
|
||||
});
|
||||
|
||||
it('should automatically add the list of colours to svg defs', function() {
|
||||
mapper.getColour("42");
|
||||
expect($("svg defs solidColor").length).toEqual(20);
|
||||
});
|
||||
|
||||
it('should not add the mapping table twice', function() {
|
||||
mapper.getColour("42");
|
||||
var mapper2 = new ColourMapper(d3.select("svg"));
|
||||
mapper2.getColour("23");
|
||||
expect($("svg defs solidColor").length).toEqual(20);
|
||||
});
|
||||
|
||||
it('should return a reference to a colour', function() {
|
||||
it('should return a colour', function() {
|
||||
var colourRef = mapper.getColour("42");
|
||||
|
||||
expect(colourRef).toBeDefined();
|
||||
expect($(colourRef).length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return a different reference for different values', function() {
|
||||
it('should return a different colour for different values', function() {
|
||||
var c1 = mapper.getColour("42"),
|
||||
c2 = mapper.getColour("23");
|
||||
|
||||
expect(c1).not.toEqual(c2);
|
||||
});
|
||||
|
||||
it('should return the same reference for equal values', function() {
|
||||
it('should return the same colour for equal values', function() {
|
||||
var c1 = mapper.getColour("42"),
|
||||
c2 = mapper.getColour("42");
|
||||
|
||||
expect(c1).toEqual(c2);
|
||||
});
|
||||
|
||||
it('should return references for non string values', function() {
|
||||
it('should return colours for non string values', function() {
|
||||
var c1 = mapper.getColour(42),
|
||||
c2 = mapper.getColour(true);
|
||||
|
||||
expect(c1).toBeDefined();
|
||||
expect($(c1).length).toEqual(1);
|
||||
|
||||
expect(c1).toBeDefined();
|
||||
expect(c2).toBeDefined();
|
||||
expect($(c2).length).toEqual(1);
|
||||
|
||||
expect(c1).not.toEqual(c2);
|
||||
});
|
||||
|
||||
it('should be able to manually reset the returned colours', function() {
|
||||
var c1 = mapper.getColour("1"),
|
||||
c2 = mapper.getColour("2"),
|
||||
c3;
|
||||
|
||||
mapper.reset();
|
||||
|
||||
c3 = mapper.getColour("3");
|
||||
|
||||
expect(c1).toEqual(c3);
|
||||
});
|
||||
|
||||
it('should return 20 different colours and than restart', function() {
|
||||
var colours = [],
|
||||
i, j;
|
||||
i, j, cNew;
|
||||
colours.push(mapper.getColour("1"));
|
||||
colours.push(mapper.getColour("2"));
|
||||
colours.push(mapper.getColour("3"));
|
||||
|
@ -120,12 +107,13 @@
|
|||
colours.push(mapper.getColour("18"));
|
||||
colours.push(mapper.getColour("19"));
|
||||
colours.push(mapper.getColour("20"));
|
||||
|
||||
cNew = mapper.getColour("21");
|
||||
for (i = 0; i < colours.length; i++) {
|
||||
for (j = i; j < colours.length; j++) {
|
||||
for (j = i + 1; j < colours.length; j++) {
|
||||
expect(colours[i]).not.toEqual(colours[j]);
|
||||
}
|
||||
}
|
||||
expect(colours[0]).toEqual(cNew);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue