mirror of https://gitee.com/bigwinds/arangodb
transactions
This commit is contained in:
parent
ab9baf2f9b
commit
f7a5cf4cf3
|
@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE (tst_basic_elements) {
|
|||
BOOST_CHECK_EQUAL(8, sizeof(TRI_shape_size_t));
|
||||
BOOST_CHECK_EQUAL(8, sizeof(TRI_voc_cid_t));
|
||||
BOOST_CHECK_EQUAL(4, sizeof(TRI_voc_crc_t));
|
||||
BOOST_CHECK_EQUAL(8, sizeof(TRI_voc_eid_t));
|
||||
BOOST_CHECK_EQUAL(8, sizeof(TRI_voc_tid_t));
|
||||
BOOST_CHECK_EQUAL(8, sizeof(TRI_voc_rid_t));
|
||||
BOOST_CHECK_EQUAL(4, sizeof(TRI_voc_size_t));
|
||||
BOOST_CHECK_EQUAL(8, sizeof(TRI_voc_tick_t));
|
||||
|
@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE (tst_doc_document_key_marker) {
|
|||
|
||||
BOOST_CHECK_EQUAL( 0, offsetof(struct TRI_doc_document_key_marker_s, base));
|
||||
BOOST_CHECK_EQUAL(24, offsetof(struct TRI_doc_document_key_marker_s, _rid));
|
||||
BOOST_CHECK_EQUAL(32, offsetof(struct TRI_doc_document_key_marker_s, _sid));
|
||||
BOOST_CHECK_EQUAL(32, offsetof(struct TRI_doc_document_key_marker_s, _tid));
|
||||
BOOST_CHECK_EQUAL(40, offsetof(struct TRI_doc_document_key_marker_s, _shape));
|
||||
BOOST_CHECK_EQUAL(48, offsetof(struct TRI_doc_document_key_marker_s, _offsetKey));
|
||||
BOOST_CHECK_EQUAL(50, offsetof(struct TRI_doc_document_key_marker_s, _offsetJson));
|
||||
|
@ -204,7 +204,7 @@ BOOST_AUTO_TEST_CASE (tst_doc_edge_key_marker) {
|
|||
BOOST_AUTO_TEST_CASE (tst_doc_begin_transaction_marker) {
|
||||
size_t s = sizeof(TRI_doc_begin_transaction_marker_t);
|
||||
|
||||
BOOST_CHECK_EQUAL(24 + 8, s); // base + own size
|
||||
BOOST_CHECK_EQUAL(24 + 8 + 8, s); // base + own size
|
||||
BOOST_CHECK_EQUAL(true, s % 8 == 0);
|
||||
|
||||
BOOST_CHECK_EQUAL( 0, offsetof(struct TRI_doc_begin_transaction_marker_s, base));
|
||||
|
|
|
@ -236,8 +236,8 @@ static or_element_t* FindOrElement (const TRI_vector_pointer_t* const vector,
|
|||
const char* const name) {
|
||||
size_t i, n;
|
||||
|
||||
TRI_ASSERT_DEBUG(vector != NULL);
|
||||
TRI_ASSERT_DEBUG(name != NULL);
|
||||
TRI_ASSERT_MAINTAINER(vector != NULL);
|
||||
TRI_ASSERT_MAINTAINER(name != NULL);
|
||||
|
||||
n = vector->_length;
|
||||
for (i = 0; i < n; ++i) {
|
||||
|
@ -245,7 +245,7 @@ static or_element_t* FindOrElement (const TRI_vector_pointer_t* const vector,
|
|||
|
||||
current = (or_element_t*) TRI_AtVectorPointer(vector, i);
|
||||
|
||||
TRI_ASSERT_DEBUG(current != NULL);
|
||||
TRI_ASSERT_MAINTAINER(current != NULL);
|
||||
|
||||
if (TRI_EqualString(name, current->_name)) {
|
||||
return current;
|
||||
|
@ -275,8 +275,8 @@ static bool InsertOrs (TRI_aql_context_t* const context,
|
|||
|
||||
fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(source, i);
|
||||
|
||||
TRI_ASSERT_DEBUG(fieldAccess != NULL);
|
||||
TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess->_fullName != NULL);
|
||||
|
||||
orElement = FindOrElement(dest, fieldAccess->_fullName);
|
||||
if (orElement == NULL) {
|
||||
|
@ -336,8 +336,8 @@ static bool InsertOrs (TRI_aql_context_t* const context,
|
|||
static void SetNameLength (TRI_aql_field_access_t* const fieldAccess) {
|
||||
char* dotPosition;
|
||||
|
||||
TRI_ASSERT_DEBUG(fieldAccess != NULL);
|
||||
TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess->_fullName != NULL);
|
||||
|
||||
dotPosition = strchr(fieldAccess->_fullName, '.');
|
||||
if (dotPosition == NULL) {
|
||||
|
@ -354,7 +354,7 @@ static void SetNameLength (TRI_aql_field_access_t* const fieldAccess) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void FreeAccessMembers (TRI_aql_field_access_t* const fieldAccess) {
|
||||
TRI_ASSERT_DEBUG(fieldAccess != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess != NULL);
|
||||
|
||||
switch (fieldAccess->_type) {
|
||||
case TRI_AQL_ACCESS_EXACT:
|
||||
|
@ -428,8 +428,8 @@ static TRI_aql_field_access_t* CreateFieldAccess (TRI_aql_context_t* const conte
|
|||
|
||||
bool IsSameReference (const TRI_aql_field_access_t* const lhs,
|
||||
const TRI_aql_field_access_t* const rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_REFERENCE);
|
||||
TRI_ASSERT_DEBUG(rhs->_type == TRI_AQL_ACCESS_REFERENCE);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_REFERENCE);
|
||||
TRI_ASSERT_MAINTAINER(rhs->_type == TRI_AQL_ACCESS_REFERENCE);
|
||||
|
||||
if (lhs->_value._reference._type == TRI_AQL_REFERENCE_VARIABLE &&
|
||||
rhs->_value._reference._type == TRI_AQL_REFERENCE_VARIABLE) {
|
||||
|
@ -469,7 +469,7 @@ static TRI_aql_field_access_t* MergeAndImpossible (TRI_aql_context_t* const cont
|
|||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
// impossible merged with anything just returns impossible
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_IMPOSSIBLE);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_IMPOSSIBLE);
|
||||
TRI_FreeAccessAql(rhs);
|
||||
|
||||
return lhs;
|
||||
|
@ -485,7 +485,7 @@ static TRI_aql_field_access_t* MergeAndAll (TRI_aql_context_t* const context,
|
|||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
// all merged with anything just returns the other side
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_ALL);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_ALL);
|
||||
TRI_FreeAccessAql(lhs);
|
||||
|
||||
return rhs;
|
||||
|
@ -501,7 +501,7 @@ static TRI_aql_field_access_t* MergeAndAll (TRI_aql_context_t* const context,
|
|||
static TRI_aql_field_access_t* MergeAndExact (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_EXACT);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_EXACT);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_EXACT) {
|
||||
// check if values are identical
|
||||
|
@ -623,7 +623,7 @@ static TRI_aql_field_access_t* MergeAndExact (TRI_aql_context_t* const context,
|
|||
static TRI_aql_field_access_t* MergeAndList (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_LIST);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_LIST);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_LIST) {
|
||||
// make a list of both
|
||||
|
@ -750,7 +750,7 @@ static TRI_aql_field_access_t* MergeAndList (TRI_aql_context_t* const context,
|
|||
static TRI_aql_field_access_t* MergeAndRangeSingle (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE) {
|
||||
TRI_json_t* lhsValue;
|
||||
|
@ -1095,7 +1095,7 @@ static TRI_aql_field_access_t* MergeAndRangeDouble (TRI_aql_context_t* const con
|
|||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE) {
|
||||
int compareResult;
|
||||
|
@ -1163,7 +1163,7 @@ static TRI_aql_field_access_t* MergeAndRangeDouble (TRI_aql_context_t* const con
|
|||
static TRI_aql_field_access_t* MergeAndReference (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_REFERENCE);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_REFERENCE);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_REFERENCE) {
|
||||
TRI_aql_node_type_e lhsType = lhs->_value._reference._operator;
|
||||
|
@ -1269,7 +1269,7 @@ static TRI_aql_field_access_t* MergeOrImpossible (TRI_aql_context_t* const conte
|
|||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
// impossible merged with anything just returns the other side
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_IMPOSSIBLE);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_IMPOSSIBLE);
|
||||
TRI_FreeAccessAql(lhs);
|
||||
|
||||
return rhs;
|
||||
|
@ -1285,7 +1285,7 @@ static TRI_aql_field_access_t* MergeOrAll (TRI_aql_context_t* const context,
|
|||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
// all merged with anything just returns all
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_ALL);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_ALL);
|
||||
TRI_FreeAccessAql(rhs);
|
||||
|
||||
return lhs;
|
||||
|
@ -1301,7 +1301,7 @@ static TRI_aql_field_access_t* MergeOrAll (TRI_aql_context_t* const context,
|
|||
static TRI_aql_field_access_t* MergeOrExact (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_EXACT);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_EXACT);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_EXACT) {
|
||||
TRI_json_t* result;
|
||||
|
@ -1448,7 +1448,7 @@ static TRI_aql_field_access_t* MergeOrExact (TRI_aql_context_t* const context,
|
|||
static TRI_aql_field_access_t* MergeOrList (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_LIST);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_LIST);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_LIST) {
|
||||
// make a list of both
|
||||
|
@ -1494,7 +1494,7 @@ static TRI_aql_field_access_t* MergeOrList (TRI_aql_context_t* const context,
|
|||
static TRI_aql_field_access_t* MergeOrRangeSingle (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE) {
|
||||
TRI_aql_range_e lhsType;
|
||||
|
@ -1594,7 +1594,7 @@ static TRI_aql_field_access_t* MergeOrRangeSingle (TRI_aql_context_t* const cont
|
|||
static TRI_aql_field_access_t* MergeOrRangeDouble (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE) {
|
||||
int compareResult;
|
||||
|
@ -1665,7 +1665,7 @@ static TRI_aql_field_access_t* MergeOrRangeDouble (TRI_aql_context_t* const cont
|
|||
static TRI_aql_field_access_t* MergeOrReference (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_REFERENCE);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type == TRI_AQL_ACCESS_REFERENCE);
|
||||
|
||||
if (rhs->_type == TRI_AQL_ACCESS_REFERENCE) {
|
||||
TRI_aql_node_type_e lhsType = lhs->_value._reference._operator;
|
||||
|
@ -1734,11 +1734,11 @@ static TRI_aql_field_access_t* MergeOrReference (TRI_aql_context_t* const contex
|
|||
static TRI_aql_field_access_t* MergeAttributeAccessAnd (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(lhs != NULL);
|
||||
TRI_ASSERT_DEBUG(rhs != NULL);
|
||||
TRI_ASSERT_DEBUG(lhs->_fullName != NULL);
|
||||
TRI_ASSERT_DEBUG(rhs->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(lhs != NULL);
|
||||
TRI_ASSERT_MAINTAINER(rhs != NULL);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(rhs->_fullName != NULL);
|
||||
|
||||
if (lhs->_type > rhs->_type) {
|
||||
// swap operands so they are always sorted
|
||||
|
@ -1747,7 +1747,7 @@ static TRI_aql_field_access_t* MergeAttributeAccessAnd (TRI_aql_context_t* const
|
|||
rhs = tmp;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(lhs->_type <= rhs->_type);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type <= rhs->_type);
|
||||
|
||||
switch (lhs->_type) {
|
||||
case TRI_AQL_ACCESS_IMPOSSIBLE:
|
||||
|
@ -1777,11 +1777,11 @@ static TRI_aql_field_access_t* MergeAttributeAccessAnd (TRI_aql_context_t* const
|
|||
static TRI_aql_field_access_t* MergeAttributeAccessOr (TRI_aql_context_t* const context,
|
||||
TRI_aql_field_access_t* lhs,
|
||||
TRI_aql_field_access_t* rhs) {
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(lhs != NULL);
|
||||
TRI_ASSERT_DEBUG(rhs != NULL);
|
||||
TRI_ASSERT_DEBUG(lhs->_fullName != NULL);
|
||||
TRI_ASSERT_DEBUG(rhs->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(lhs != NULL);
|
||||
TRI_ASSERT_MAINTAINER(rhs != NULL);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(rhs->_fullName != NULL);
|
||||
|
||||
if (lhs->_type > rhs->_type) {
|
||||
// swap operands so they are always sorted
|
||||
|
@ -1790,7 +1790,7 @@ static TRI_aql_field_access_t* MergeAttributeAccessOr (TRI_aql_context_t* const
|
|||
rhs = tmp;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(lhs->_type <= rhs->_type);
|
||||
TRI_ASSERT_MAINTAINER(lhs->_type <= rhs->_type);
|
||||
|
||||
switch (lhs->_type) {
|
||||
case TRI_AQL_ACCESS_IMPOSSIBLE:
|
||||
|
@ -1829,7 +1829,7 @@ static TRI_aql_field_access_t* MergeAttributeAccessOr (TRI_aql_context_t* const
|
|||
static TRI_vector_pointer_t* CreateEmptyVector (TRI_aql_context_t* const context) {
|
||||
TRI_vector_pointer_t* result;
|
||||
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
|
||||
result = (TRI_vector_pointer_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_vector_pointer_t), false);
|
||||
|
||||
|
@ -1852,7 +1852,7 @@ static TRI_vector_pointer_t* Vectorize (TRI_aql_context_t* const context,
|
|||
TRI_aql_field_access_t* fieldAccess) {
|
||||
TRI_vector_pointer_t* vector;
|
||||
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
|
||||
if (fieldAccess == NULL) {
|
||||
return NULL;
|
||||
|
@ -1887,8 +1887,8 @@ static TRI_vector_pointer_t* MakeAllVector (TRI_aql_context_t* const context,
|
|||
// turn all field access values into an all items access
|
||||
TRI_aql_field_access_t* fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(fieldAccesses, i);
|
||||
|
||||
TRI_ASSERT_DEBUG(fieldAccess != NULL);
|
||||
TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess->_fullName != NULL);
|
||||
|
||||
// modify the element in place
|
||||
FreeAccessMembers(fieldAccess);
|
||||
|
@ -1910,8 +1910,8 @@ static void MergeVector (TRI_aql_context_t* const context,
|
|||
const TRI_vector_pointer_t* const source) {
|
||||
size_t i, n;
|
||||
|
||||
TRI_ASSERT_DEBUG(result != NULL);
|
||||
TRI_ASSERT_DEBUG(source != NULL);
|
||||
TRI_ASSERT_MAINTAINER(result != NULL);
|
||||
TRI_ASSERT_MAINTAINER(source != NULL);
|
||||
|
||||
n = source->_length;
|
||||
for (i = 0; i < n; ++i) {
|
||||
|
@ -1919,8 +1919,8 @@ static void MergeVector (TRI_aql_context_t* const context,
|
|||
size_t j, len;
|
||||
bool found = false;
|
||||
|
||||
TRI_ASSERT_DEBUG(fieldAccess != NULL);
|
||||
TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess->_fullName != NULL);
|
||||
|
||||
// check if element is in result vector already
|
||||
len = result->_length;
|
||||
|
@ -1963,16 +1963,16 @@ static void InsertVector (TRI_aql_context_t* const context,
|
|||
const TRI_vector_pointer_t* const source) {
|
||||
size_t i, n;
|
||||
|
||||
TRI_ASSERT_DEBUG(result != NULL);
|
||||
TRI_ASSERT_DEBUG(source != NULL);
|
||||
TRI_ASSERT_MAINTAINER(result != NULL);
|
||||
TRI_ASSERT_MAINTAINER(source != NULL);
|
||||
|
||||
n = source->_length;
|
||||
for (i = 0; i < n; ++i) {
|
||||
TRI_aql_field_access_t* fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(source, i);
|
||||
TRI_aql_field_access_t* copy;
|
||||
|
||||
TRI_ASSERT_DEBUG(fieldAccess != NULL);
|
||||
TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess->_fullName != NULL);
|
||||
|
||||
copy = TRI_CloneAccessAql(context, fieldAccess);
|
||||
|
||||
|
@ -1998,8 +1998,8 @@ static TRI_vector_pointer_t* MergeVectors (TRI_aql_context_t* const context,
|
|||
TRI_vector_pointer_t* result;
|
||||
TRI_vector_pointer_t* orElements;
|
||||
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(mergeType == TRI_AQL_NODE_OPERATOR_BINARY_AND || mergeType == TRI_AQL_NODE_OPERATOR_BINARY_OR);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(mergeType == TRI_AQL_NODE_OPERATOR_BINARY_AND || mergeType == TRI_AQL_NODE_OPERATOR_BINARY_OR);
|
||||
|
||||
// first check if we can get away without copying/merging the vectors
|
||||
if (inheritedRestrictions == NULL) {
|
||||
|
@ -2084,7 +2084,7 @@ static TRI_vector_pointer_t* MergeVectors (TRI_aql_context_t* const context,
|
|||
or_element_t* orElement;
|
||||
|
||||
fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(result, i);
|
||||
TRI_ASSERT_DEBUG(fieldAccess != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess != NULL);
|
||||
|
||||
if (fieldAccess->_type == TRI_AQL_ACCESS_ALL) {
|
||||
continue;
|
||||
|
@ -2103,7 +2103,7 @@ static TRI_vector_pointer_t* MergeVectors (TRI_aql_context_t* const context,
|
|||
or_element_t* orElement;
|
||||
|
||||
orElement = (or_element_t*) TRI_AtVectorPointer(orElements, i);
|
||||
TRI_ASSERT_DEBUG(orElement != NULL);
|
||||
TRI_ASSERT_MAINTAINER(orElement != NULL);
|
||||
|
||||
// free members
|
||||
TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, orElement->_name);
|
||||
|
@ -2141,10 +2141,10 @@ static TRI_aql_field_access_t* CreateAccessForNode (TRI_aql_context_t* const con
|
|||
TRI_aql_field_access_t* fieldAccess;
|
||||
TRI_json_t* value;
|
||||
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(field != NULL);
|
||||
TRI_ASSERT_DEBUG(field->_name._buffer != NULL);
|
||||
TRI_ASSERT_DEBUG(node != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(field != NULL);
|
||||
TRI_ASSERT_MAINTAINER(field->_name._buffer != NULL);
|
||||
TRI_ASSERT_MAINTAINER(node != NULL);
|
||||
|
||||
fieldAccess = (TRI_aql_field_access_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_aql_field_access_t), false);
|
||||
if (fieldAccess == NULL) {
|
||||
|
@ -2227,7 +2227,7 @@ static TRI_aql_field_access_t* CreateAccessForNode (TRI_aql_context_t* const con
|
|||
else if (operator == TRI_AQL_NODE_OPERATOR_BINARY_IN) {
|
||||
TRI_json_t* list;
|
||||
|
||||
TRI_ASSERT_DEBUG(value->_type == TRI_JSON_LIST);
|
||||
TRI_ASSERT_MAINTAINER(value->_type == TRI_JSON_LIST);
|
||||
|
||||
// create a list access
|
||||
fieldAccess->_type = TRI_AQL_ACCESS_LIST;
|
||||
|
@ -2266,8 +2266,8 @@ static TRI_aql_field_access_t* GetAttributeAccess (TRI_aql_context_t* const cont
|
|||
const TRI_aql_node_t* const node) {
|
||||
TRI_aql_field_access_t* fieldAccess;
|
||||
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(node != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(node != NULL);
|
||||
|
||||
if (field == NULL || ! field->_name._buffer) {
|
||||
// this is ok if the node type is not supported
|
||||
|
@ -2291,8 +2291,8 @@ static TRI_aql_field_access_t* GetAttributeAccess (TRI_aql_context_t* const cont
|
|||
|
||||
static TRI_aql_attribute_name_t* GetAttributeName (TRI_aql_context_t* const context,
|
||||
const TRI_aql_node_t* const node) {
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(node != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(node != NULL);
|
||||
|
||||
if (node->_type == TRI_AQL_NODE_ATTRIBUTE_ACCESS) {
|
||||
TRI_aql_attribute_name_t* field = GetAttributeName(context, TRI_AQL_NODE_MEMBER(node, 0));
|
||||
|
@ -2362,13 +2362,13 @@ static TRI_vector_pointer_t* ProcessNode (TRI_aql_context_t* const context,
|
|||
TRI_aql_node_t* node,
|
||||
bool* changed,
|
||||
const TRI_vector_pointer_t* const inheritedRestrictions) {
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(node != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(node != NULL);
|
||||
|
||||
if (node->_type == TRI_AQL_NODE_OPERATOR_UNARY_NOT) {
|
||||
TRI_aql_node_t* lhs = TRI_AQL_NODE_MEMBER(node, 0);
|
||||
|
||||
TRI_ASSERT_DEBUG(lhs != NULL);
|
||||
TRI_ASSERT_MAINTAINER(lhs != NULL);
|
||||
|
||||
// can ignore inherited restrictions here
|
||||
return MakeAllVector(context, ProcessNode(context, lhs, changed, NULL));
|
||||
|
@ -2380,8 +2380,8 @@ static TRI_vector_pointer_t* ProcessNode (TRI_aql_context_t* const context,
|
|||
TRI_aql_node_t* rhs = TRI_AQL_NODE_MEMBER(node, 1);
|
||||
TRI_vector_pointer_t* result;
|
||||
|
||||
TRI_ASSERT_DEBUG(lhs != NULL);
|
||||
TRI_ASSERT_DEBUG(rhs != NULL);
|
||||
TRI_ASSERT_MAINTAINER(lhs != NULL);
|
||||
TRI_ASSERT_MAINTAINER(rhs != NULL);
|
||||
|
||||
// recurse into next level
|
||||
result = MergeVectors(context,
|
||||
|
@ -2449,7 +2449,7 @@ static TRI_vector_pointer_t* ProcessNode (TRI_aql_context_t* const context,
|
|||
node2 = lhs;
|
||||
operator = TRI_ReverseOperatorRelationalAql(node->_type);
|
||||
|
||||
TRI_ASSERT_DEBUG(operator != TRI_AQL_NODE_NOP);
|
||||
TRI_ASSERT_MAINTAINER(operator != TRI_AQL_NODE_NOP);
|
||||
|
||||
if (lhs->_type == TRI_AQL_NODE_REFERENCE || lhs->_type == TRI_AQL_NODE_ATTRIBUTE_ACCESS || lhs->_type == TRI_AQL_NODE_FCALL) {
|
||||
// expression of type reference|attribute access|fcall operator reference|attribute access|fcall
|
||||
|
@ -2575,7 +2575,7 @@ bool TRI_ContainsImpossibleAql (const TRI_vector_pointer_t* const fieldAccesses)
|
|||
for (i = 0; i < n; ++i) {
|
||||
TRI_aql_field_access_t* fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(fieldAccesses, i);
|
||||
|
||||
TRI_ASSERT_DEBUG(fieldAccess != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess != NULL);
|
||||
|
||||
if (fieldAccess->_type == TRI_AQL_ACCESS_IMPOSSIBLE) {
|
||||
// impossible range found
|
||||
|
@ -2614,7 +2614,7 @@ TRI_vector_pointer_t* TRI_CloneAccessesAql (TRI_aql_context_t* const context,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeAccessAql (TRI_aql_field_access_t* const fieldAccess) {
|
||||
TRI_ASSERT_DEBUG(fieldAccess != NULL);
|
||||
TRI_ASSERT_MAINTAINER(fieldAccess != NULL);
|
||||
|
||||
FreeAccessMembers(fieldAccess);
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, fieldAccess->_fullName);
|
||||
|
@ -2629,8 +2629,8 @@ TRI_aql_field_access_t* TRI_CloneAccessAql (TRI_aql_context_t* const context,
|
|||
TRI_aql_field_access_t* const source) {
|
||||
TRI_aql_field_access_t* fieldAccess;
|
||||
|
||||
TRI_ASSERT_DEBUG(source != NULL);
|
||||
TRI_ASSERT_DEBUG(source->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(source != NULL);
|
||||
TRI_ASSERT_MAINTAINER(source->_fullName != NULL);
|
||||
|
||||
fieldAccess = CreateFieldAccess(context, source->_type, source->_fullName);
|
||||
if (fieldAccess == NULL) {
|
||||
|
@ -2771,9 +2771,9 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context,
|
|||
size_t i, n;
|
||||
bool found;
|
||||
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(candidate != NULL);
|
||||
TRI_ASSERT_DEBUG(candidate->_fullName != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(candidate != NULL);
|
||||
TRI_ASSERT_MAINTAINER(candidate->_fullName != NULL);
|
||||
|
||||
if (previous != NULL) {
|
||||
// use existing vector if already available
|
||||
|
@ -2788,7 +2788,7 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context,
|
|||
}
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(accesses != NULL);
|
||||
TRI_ASSERT_MAINTAINER(accesses != NULL);
|
||||
|
||||
found = false;
|
||||
n = accesses->_length;
|
||||
|
@ -2809,7 +2809,7 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context,
|
|||
TRI_aql_field_access_t* copy;
|
||||
|
||||
// free existing field access
|
||||
TRI_ASSERT_DEBUG(existing != NULL);
|
||||
TRI_ASSERT_MAINTAINER(existing != NULL);
|
||||
TRI_FreeAccessAql(existing);
|
||||
copy = TRI_CloneAccessAql(context, candidate);
|
||||
if (copy == NULL) {
|
||||
|
|
|
@ -167,8 +167,8 @@ TRI_aql_context_t* TRI_CreateContextAql (TRI_vocbase_t* vocbase,
|
|||
const char* const query) {
|
||||
TRI_aql_context_t* context;
|
||||
|
||||
TRI_ASSERT_DEBUG(vocbase != NULL);
|
||||
TRI_ASSERT_DEBUG(query != NULL);
|
||||
TRI_ASSERT_MAINTAINER(vocbase != NULL);
|
||||
TRI_ASSERT_MAINTAINER(query != NULL);
|
||||
|
||||
LOG_TRACE("creating context");
|
||||
|
||||
|
@ -248,7 +248,7 @@ TRI_aql_context_t* TRI_CreateContextAql (TRI_vocbase_t* vocbase,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeContextAql (TRI_aql_context_t* const context) {
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
|
||||
LOG_TRACE("freeing context");
|
||||
|
||||
|
@ -388,8 +388,8 @@ bool TRI_SetupCollectionsContextAql (TRI_aql_context_t* const context) {
|
|||
|
||||
bool TRI_RegisterNodeContextAql (TRI_aql_context_t* const context,
|
||||
void* const node) {
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(node != NULL);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(node != NULL);
|
||||
|
||||
TRI_PushBackVectorPointer(&context->_memory._nodes, node);
|
||||
|
||||
|
@ -436,8 +436,8 @@ void TRI_SetErrorContextAql (TRI_aql_context_t* const context,
|
|||
const int code,
|
||||
const char* const data) {
|
||||
|
||||
TRI_ASSERT_DEBUG(context != NULL);
|
||||
TRI_ASSERT_DEBUG(code > 0);
|
||||
TRI_ASSERT_MAINTAINER(context != NULL);
|
||||
TRI_ASSERT_MAINTAINER(code > 0);
|
||||
|
||||
if (context->_error._code == 0) {
|
||||
// do not overwrite previous error
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "Ahuacatl/ahuacatl-functions.h"
|
||||
|
||||
#include "BasicsC/associative.h"
|
||||
#include "BasicsC/hashes.h"
|
||||
#include "BasicsC/logging.h"
|
||||
#include "BasicsC/tri-strings.h"
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ bool TRI_IsListNodeAql (const TRI_aql_node_t* const node) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsConstantValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
TRI_ASSERT_DEBUG(node != NULL);
|
||||
TRI_ASSERT_MAINTAINER(node != NULL);
|
||||
|
||||
if (node->_type != TRI_AQL_NODE_VALUE &&
|
||||
node->_type != TRI_AQL_NODE_LIST &&
|
||||
|
@ -246,7 +246,7 @@ bool TRI_IsConstantValueNodeAql (const TRI_aql_node_t* const node) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsNumericValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
TRI_ASSERT_DEBUG(node != NULL);
|
||||
TRI_ASSERT_MAINTAINER(node != NULL);
|
||||
|
||||
if (node->_type != TRI_AQL_NODE_VALUE) {
|
||||
return false;
|
||||
|
@ -261,7 +261,7 @@ bool TRI_IsNumericValueNodeAql (const TRI_aql_node_t* const node) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsBooleanValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
TRI_ASSERT_DEBUG(node != NULL);
|
||||
TRI_ASSERT_MAINTAINER(node != NULL);
|
||||
|
||||
return (node->_type == TRI_AQL_NODE_VALUE && node->_value._type == TRI_AQL_TYPE_BOOL);
|
||||
}
|
||||
|
|
|
@ -75,11 +75,11 @@ namespace triagens {
|
|||
for (size_t i = 0; i < n; ++i) {
|
||||
TRI_aql_collection_t* collection = (TRI_aql_collection_t*) TRI_AtVectorPointer(collections, i);
|
||||
|
||||
TRI_transaction_cid_t cid = 0;
|
||||
TRI_voc_cid_t cid = 0;
|
||||
TRI_vocbase_col_t const* col = resolver.getCollectionStruct(collection->_name);
|
||||
|
||||
if (col != 0) {
|
||||
cid = (TRI_transaction_cid_t) col->_cid;
|
||||
cid = col->_cid;
|
||||
}
|
||||
|
||||
int res = this->addCollection(cid, TRI_TRANSACTION_READ);
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace triagens {
|
|||
|
||||
SingleCollectionReadOnlyTransaction (struct TRI_vocbase_s* const vocbase,
|
||||
const triagens::arango::CollectionNameResolver& resolver,
|
||||
const TRI_transaction_cid_t cid) :
|
||||
const TRI_voc_cid_t cid) :
|
||||
SingleCollectionTransaction<T>(vocbase, resolver, cid, TRI_TRANSACTION_READ) {
|
||||
}
|
||||
|
||||
|
|
|
@ -30,16 +30,16 @@
|
|||
|
||||
#include "BasicsC/common.h"
|
||||
|
||||
#include "BasicsC/voc-errors.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "Utils/Transaction.h"
|
||||
|
||||
#include "VocBase/barrier.h"
|
||||
#include "VocBase/primary-collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "BasicsC/voc-errors.h"
|
||||
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Logger/Logger.h"
|
||||
|
||||
#include "Utils/Transaction.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
namespace triagens {
|
||||
namespace arango {
|
||||
|
@ -71,7 +71,7 @@ namespace triagens {
|
|||
|
||||
SingleCollectionTransaction (TRI_vocbase_t* const vocbase,
|
||||
const triagens::arango::CollectionNameResolver& resolver,
|
||||
const TRI_transaction_cid_t cid,
|
||||
const TRI_voc_cid_t cid,
|
||||
const TRI_transaction_type_e accessType) :
|
||||
Transaction<T>(vocbase, resolver),
|
||||
_cid(cid),
|
||||
|
@ -108,11 +108,11 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline TRI_transaction_collection_t* trxCollection () {
|
||||
TRI_ASSERT_DEBUG(_cid > 0);
|
||||
TRI_ASSERT_MAINTAINER(_cid > 0);
|
||||
|
||||
TRI_transaction_collection_t* trxCollection = TRI_GetCollectionTransaction(this->_trx, this->_cid, _accessType);
|
||||
|
||||
TRI_ASSERT_DEBUG(trxCollection != 0);
|
||||
TRI_ASSERT_MAINTAINER(trxCollection != 0);
|
||||
return trxCollection;
|
||||
}
|
||||
|
||||
|
@ -123,9 +123,9 @@ namespace triagens {
|
|||
inline TRI_primary_collection_t* primaryCollection () {
|
||||
TRI_transaction_collection_t* trxCollection = this->trxCollection();
|
||||
|
||||
TRI_ASSERT_DEBUG(trxCollection != 0);
|
||||
TRI_ASSERT_DEBUG(trxCollection->_collection != 0);
|
||||
TRI_ASSERT_DEBUG(trxCollection->_collection->_collection != 0);
|
||||
TRI_ASSERT_MAINTAINER(trxCollection != 0);
|
||||
TRI_ASSERT_MAINTAINER(trxCollection->_collection != 0);
|
||||
TRI_ASSERT_MAINTAINER(trxCollection->_collection->_collection != 0);
|
||||
|
||||
return trxCollection->_collection->_collection;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ namespace triagens {
|
|||
/// @brief collection id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_transaction_cid_t _cid;
|
||||
TRI_voc_cid_t _cid;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief collection access type
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "ShapedJson/shaped-json.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
namespace triagens {
|
||||
namespace arango {
|
||||
|
@ -70,7 +71,7 @@ namespace triagens {
|
|||
|
||||
SingleCollectionWriteTransaction (TRI_vocbase_t* const vocbase,
|
||||
const triagens::arango::CollectionNameResolver& resolver,
|
||||
const TRI_transaction_cid_t cid) :
|
||||
const TRI_voc_cid_t cid) :
|
||||
SingleCollectionTransaction<T>(vocbase, resolver, cid, TRI_TRANSACTION_WRITE),
|
||||
_numWrites(0) {
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace triagens {
|
|||
_vocbase(vocbase),
|
||||
_resolver(resolver) {
|
||||
|
||||
TRI_ASSERT_DEBUG(_vocbase != 0);
|
||||
TRI_ASSERT_MAINTAINER(_vocbase != 0);
|
||||
|
||||
this->setupTransaction();
|
||||
}
|
||||
|
@ -257,10 +257,10 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_primary_collection_t* primaryCollection (TRI_transaction_collection_t const* trxCollection) const {
|
||||
TRI_ASSERT_DEBUG(_trx != 0);
|
||||
TRI_ASSERT_DEBUG(getStatus() == TRI_TRANSACTION_RUNNING);
|
||||
TRI_ASSERT_DEBUG(trxCollection->_collection != 0);
|
||||
TRI_ASSERT_DEBUG(trxCollection->_collection->_collection != 0);
|
||||
TRI_ASSERT_MAINTAINER(_trx != 0);
|
||||
TRI_ASSERT_MAINTAINER(getStatus() == TRI_TRANSACTION_RUNNING);
|
||||
TRI_ASSERT_MAINTAINER(trxCollection->_collection != 0);
|
||||
TRI_ASSERT_MAINTAINER(trxCollection->_collection->_collection != 0);
|
||||
|
||||
return trxCollection->_collection->_collection;
|
||||
}
|
||||
|
@ -270,10 +270,10 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_shaper_t* shaper (TRI_transaction_collection_t const* trxCollection) const {
|
||||
TRI_ASSERT_DEBUG(_trx != 0);
|
||||
TRI_ASSERT_DEBUG(getStatus() == TRI_TRANSACTION_RUNNING);
|
||||
TRI_ASSERT_DEBUG(trxCollection->_collection != 0);
|
||||
TRI_ASSERT_DEBUG(trxCollection->_collection->_collection != 0);
|
||||
TRI_ASSERT_MAINTAINER(_trx != 0);
|
||||
TRI_ASSERT_MAINTAINER(getStatus() == TRI_TRANSACTION_RUNNING);
|
||||
TRI_ASSERT_MAINTAINER(trxCollection->_collection != 0);
|
||||
TRI_ASSERT_MAINTAINER(trxCollection->_collection->_collection != 0);
|
||||
|
||||
return trxCollection->_collection->_collection->_shaper;
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ namespace triagens {
|
|||
/// @brief add a collection by id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int addCollection (TRI_transaction_cid_t cid,
|
||||
int addCollection (TRI_voc_cid_t cid,
|
||||
TRI_transaction_type_e type) {
|
||||
if (_trx == 0) {
|
||||
return registerError(TRI_ERROR_INTERNAL);
|
||||
|
@ -802,13 +802,13 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int registerError (int errorNum) {
|
||||
TRI_ASSERT_DEBUG(errorNum != TRI_ERROR_NO_ERROR);
|
||||
TRI_ASSERT_MAINTAINER(errorNum != TRI_ERROR_NO_ERROR);
|
||||
|
||||
if (_setupState == TRI_ERROR_NO_ERROR) {
|
||||
_setupState = errorNum;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(_setupState != TRI_ERROR_NO_ERROR);
|
||||
TRI_ASSERT_MAINTAINER(_setupState != TRI_ERROR_NO_ERROR);
|
||||
|
||||
return errorNum;
|
||||
}
|
||||
|
@ -818,7 +818,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int addCollectionEmbedded (TRI_voc_cid_t cid, TRI_transaction_type_e type) {
|
||||
TRI_ASSERT_DEBUG(_trx != 0);
|
||||
TRI_ASSERT_MAINTAINER(_trx != 0);
|
||||
|
||||
int res = TRI_AddCollectionTransaction(_trx, cid, type, _nestingLevel);
|
||||
|
||||
|
@ -834,7 +834,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int addCollectionToplevel (TRI_voc_cid_t cid, TRI_transaction_type_e type) {
|
||||
TRI_ASSERT_DEBUG(_trx != 0);
|
||||
TRI_ASSERT_MAINTAINER(_trx != 0);
|
||||
|
||||
int res;
|
||||
|
||||
|
@ -881,7 +881,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int setupEmbedded () {
|
||||
TRI_ASSERT_DEBUG(_nestingLevel == 0);
|
||||
TRI_ASSERT_MAINTAINER(_nestingLevel == 0);
|
||||
|
||||
_nestingLevel = ++_trx->_nestingLevel;
|
||||
|
||||
|
@ -900,7 +900,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int setupToplevel () {
|
||||
TRI_ASSERT_DEBUG(_nestingLevel == 0);
|
||||
TRI_ASSERT_MAINTAINER(_nestingLevel == 0);
|
||||
|
||||
// we are not embedded. now start our own transaction
|
||||
_trx = TRI_CreateTransaction(_vocbase->_transactionContext);
|
||||
|
@ -918,7 +918,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int freeTransaction () {
|
||||
TRI_ASSERT_DEBUG(! isEmbeddedTransaction());
|
||||
TRI_ASSERT_MAINTAINER(! isEmbeddedTransaction());
|
||||
|
||||
if (_trx != 0) {
|
||||
this->unregisterTransaction();
|
||||
|
|
|
@ -2766,7 +2766,7 @@ static v8::Handle<v8::Value> JS_UpgradeVocbaseCol (v8::Arguments const& argv) {
|
|||
|
||||
voc_did_t _did; // this is the tick for a create, but not an update
|
||||
TRI_voc_rid_t _rid; // this is the tick for an create and update
|
||||
TRI_voc_eid_t _sid;
|
||||
TRI_voc_tid_t _sid;
|
||||
|
||||
TRI_shape_sid_t _shape;
|
||||
}
|
||||
|
@ -2788,7 +2788,7 @@ static v8::Handle<v8::Value> JS_UpgradeVocbaseCol (v8::Arguments const& argv) {
|
|||
|
||||
voc_did_t _did; // this is the tick for a create, but not an update
|
||||
TRI_voc_rid_t _rid; // this is the tick for an create and update
|
||||
TRI_voc_eid_t _sid;
|
||||
TRI_voc_tid_t _sid;
|
||||
}
|
||||
doc_deletion_marker_t_deprecated;
|
||||
|
||||
|
@ -2962,7 +2962,7 @@ static v8::Handle<v8::Value> JS_UpgradeVocbaseCol (v8::Arguments const& argv) {
|
|||
TRI_CopyString(keyBody, didBuffer, keySize);
|
||||
|
||||
newMarker._rid = oldMarker->_rid;
|
||||
newMarker._sid = oldMarker->_sid;
|
||||
newMarker._tid = 0;
|
||||
newMarker._shape = oldMarker->_shape;
|
||||
newMarker._offsetKey = newMarkerSize;
|
||||
newMarker._offsetJson = newMarkerSize + keyBodySize;
|
||||
|
@ -3022,7 +3022,7 @@ static v8::Handle<v8::Value> JS_UpgradeVocbaseCol (v8::Arguments const& argv) {
|
|||
TRI_CopyString(keyBody + keySize + toSize, fromDidBuffer, fromSize);
|
||||
|
||||
newMarker.base._rid = oldMarker->base._rid;
|
||||
newMarker.base._sid = oldMarker->base._sid;
|
||||
newMarker.base._tid = 0;
|
||||
newMarker.base._shape = oldMarker->base._shape;
|
||||
newMarker.base._offsetKey = newMarkerSize;
|
||||
newMarker.base._offsetJson = newMarkerSize + keyBodySize;
|
||||
|
@ -3071,7 +3071,7 @@ static v8::Handle<v8::Value> JS_UpgradeVocbaseCol (v8::Arguments const& argv) {
|
|||
TRI_CopyString(keyBody, didBuffer, keySize);
|
||||
|
||||
newMarker._rid = oldMarker->_rid;
|
||||
newMarker._sid = oldMarker->_sid;
|
||||
newMarker._tid = 0;
|
||||
newMarker._offsetKey = newMarkerSize;
|
||||
|
||||
newMarker.base._size = newMarkerSize + keyBodySize;
|
||||
|
|
|
@ -166,15 +166,15 @@ typedef enum {
|
|||
TRI_DOC_MARKER_HEADER = 3000,
|
||||
TRI_DOC_MARKER_DOCUMENT = 3001,
|
||||
TRI_DOC_MARKER_DELETION = 3002,
|
||||
TRI_DOC_MARKER_BEGIN_TRANSACTION = 3003, // currently unused
|
||||
TRI_DOC_MARKER_COMMIT_TRANSACTION = 3004, // currently unused
|
||||
TRI_DOC_MARKER_ABORT_TRANSACTION = 3005, // currently unused
|
||||
TRI_DOC_MARKER_EDGE = 3006,
|
||||
|
||||
TRI_DOC_MARKER_KEY_DOCUMENT = 3007, // new marker with key values
|
||||
TRI_DOC_MARKER_KEY_EDGE = 3008, // new marker with key values
|
||||
TRI_DOC_MARKER_KEY_DELETION = 3009, // new marker with key values
|
||||
|
||||
TRI_DOC_MARKER_BEGIN_TRANSACTION = 3100,
|
||||
TRI_DOC_MARKER_COMMIT_TRANSACTION = 3101,
|
||||
TRI_DOC_MARKER_ABORT_TRANSACTION = 3102,
|
||||
|
||||
TRI_MARKER_MAX // again, this is not a real
|
||||
// marker, but we use it for
|
||||
|
|
|
@ -99,9 +99,9 @@ static int InsertPrimaryIndex (TRI_document_collection_t* document,
|
|||
TRI_primary_collection_t* primary;
|
||||
TRI_doc_mptr_t* found;
|
||||
|
||||
TRI_ASSERT_DEBUG(document != NULL);
|
||||
TRI_ASSERT_DEBUG(header != NULL);
|
||||
TRI_ASSERT_DEBUG(header->_key != NULL);
|
||||
TRI_ASSERT_MAINTAINER(document != NULL);
|
||||
TRI_ASSERT_MAINTAINER(header != NULL);
|
||||
TRI_ASSERT_MAINTAINER(header->_key != NULL);
|
||||
|
||||
if (header->_validTo != 0) {
|
||||
// don't insert in case the document is deleted
|
||||
|
@ -280,16 +280,17 @@ static void IncreaseDocumentCount (TRI_primary_collection_t* primary) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void DecreaseDocumentCount (TRI_primary_collection_t* primary) {
|
||||
TRI_ASSERT_DEBUG(primary->_numberDocuments > 0);
|
||||
TRI_ASSERT_MAINTAINER(primary->_numberDocuments > 0);
|
||||
|
||||
primary->_numberDocuments--;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a new document or edge marker in memory
|
||||
/// @brief creates a new deletion marker in memory
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int CreateDeletionMarker (TRI_doc_deletion_key_marker_t** result,
|
||||
static int CreateDeletionMarker (TRI_voc_tid_t tid,
|
||||
TRI_doc_deletion_key_marker_t** result,
|
||||
TRI_voc_size_t* totalSize,
|
||||
char* keyBody,
|
||||
TRI_voc_size_t keyBodySize) {
|
||||
|
@ -305,7 +306,8 @@ static int CreateDeletionMarker (TRI_doc_deletion_key_marker_t** result,
|
|||
|
||||
TRI_InitMarker(&marker->base, TRI_DOC_MARKER_KEY_DELETION, *totalSize, TRI_NewTickVocBase());
|
||||
|
||||
marker->_sid = 0;
|
||||
// note: the transaction id is 0 for standalone operations
|
||||
marker->_tid = tid;
|
||||
marker->_offsetKey = sizeof(TRI_doc_deletion_key_marker_t);
|
||||
|
||||
// copy the key into the marker
|
||||
|
@ -321,7 +323,8 @@ static int CreateDeletionMarker (TRI_doc_deletion_key_marker_t** result,
|
|||
/// existing marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int CloneDocumentMarker (TRI_df_marker_t const* original,
|
||||
static int CloneDocumentMarker (TRI_voc_tid_t tid,
|
||||
TRI_df_marker_t const* original,
|
||||
TRI_doc_document_key_marker_t** result,
|
||||
TRI_voc_size_t* totalSize,
|
||||
const TRI_df_marker_type_e markerType,
|
||||
|
@ -344,14 +347,14 @@ static int CloneDocumentMarker (TRI_df_marker_t const* original,
|
|||
TRI_doc_document_key_marker_t const* o = (TRI_doc_document_key_marker_t const*) original;
|
||||
|
||||
baseLength = o->_offsetJson;
|
||||
TRI_ASSERT_DEBUG(baseLength > sizeof(TRI_doc_document_key_marker_t));
|
||||
TRI_ASSERT_MAINTAINER(baseLength > sizeof(TRI_doc_document_key_marker_t));
|
||||
}
|
||||
else if (markerType == TRI_DOC_MARKER_KEY_EDGE) {
|
||||
// edge marker
|
||||
TRI_doc_edge_key_marker_t const* o = (TRI_doc_edge_key_marker_t const*) original;
|
||||
|
||||
baseLength = o->base._offsetJson;
|
||||
TRI_ASSERT_DEBUG(baseLength > sizeof(TRI_doc_edge_key_marker_t));
|
||||
TRI_ASSERT_MAINTAINER(baseLength > sizeof(TRI_doc_edge_key_marker_t));
|
||||
}
|
||||
else {
|
||||
// invalid marker type
|
||||
|
@ -373,6 +376,7 @@ static int CloneDocumentMarker (TRI_df_marker_t const* original,
|
|||
TRI_CloneMarker(&marker->base, original, baseLength, *totalSize, tick);
|
||||
|
||||
marker->_rid = tick;
|
||||
marker->_tid = tid;
|
||||
marker->_shape = shaped->_sid;
|
||||
|
||||
// copy shaped json into the marker
|
||||
|
@ -382,17 +386,17 @@ static int CloneDocumentMarker (TRI_df_marker_t const* original,
|
|||
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
TRI_ASSERT_DEBUG(marker->_offsetKey == ((TRI_doc_document_key_marker_t const*) original)->_offsetKey);
|
||||
TRI_ASSERT_DEBUG(marker->_offsetJson == ((TRI_doc_document_key_marker_t const*) original)->_offsetJson);
|
||||
TRI_ASSERT_MAINTAINER(marker->_offsetKey == ((TRI_doc_document_key_marker_t const*) original)->_offsetKey);
|
||||
TRI_ASSERT_MAINTAINER(marker->_offsetJson == ((TRI_doc_document_key_marker_t const*) original)->_offsetJson);
|
||||
|
||||
if (markerType == TRI_DOC_MARKER_KEY_EDGE) {
|
||||
TRI_doc_edge_key_marker_t const* o = (TRI_doc_edge_key_marker_t const*) original;
|
||||
TRI_doc_edge_key_marker_t const* c = (TRI_doc_edge_key_marker_t const*) marker;
|
||||
|
||||
TRI_ASSERT_DEBUG(c->_toCid == o->_toCid);
|
||||
TRI_ASSERT_DEBUG(c->_fromCid == o->_fromCid);
|
||||
TRI_ASSERT_DEBUG(c->_offsetToKey == o->_offsetToKey);
|
||||
TRI_ASSERT_DEBUG(c->_offsetFromKey == o->_offsetFromKey);
|
||||
TRI_ASSERT_MAINTAINER(c->_toCid == o->_toCid);
|
||||
TRI_ASSERT_MAINTAINER(c->_fromCid == o->_fromCid);
|
||||
TRI_ASSERT_MAINTAINER(c->_offsetToKey == o->_offsetToKey);
|
||||
TRI_ASSERT_MAINTAINER(c->_offsetFromKey == o->_offsetFromKey);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -405,7 +409,7 @@ static int CloneDocumentMarker (TRI_df_marker_t const* original,
|
|||
/// @brief creates a new document or edge marker in memory
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int CreateDocumentMarker (TRI_primary_collection_t* primary,
|
||||
static int CreateDocumentMarker (TRI_transaction_collection_t* trxCollection,
|
||||
TRI_doc_document_key_marker_t** result,
|
||||
TRI_voc_size_t* totalSize,
|
||||
char** keyBody,
|
||||
|
@ -413,10 +417,12 @@ static int CreateDocumentMarker (TRI_primary_collection_t* primary,
|
|||
TRI_voc_key_t key,
|
||||
TRI_shaped_json_t const* shaped,
|
||||
void const* data) {
|
||||
TRI_primary_collection_t* primary;
|
||||
TRI_doc_document_key_marker_t* marker;
|
||||
TRI_key_generator_t* keyGenerator;
|
||||
char* position;
|
||||
char keyBuffer[TRI_VOC_KEY_MAX_LENGTH + 1];
|
||||
TRI_voc_tid_t tid;
|
||||
TRI_voc_size_t keyBodySize;
|
||||
TRI_voc_tick_t tick;
|
||||
size_t markerSize;
|
||||
|
@ -427,10 +433,12 @@ static int CreateDocumentMarker (TRI_primary_collection_t* primary,
|
|||
|
||||
*result = NULL;
|
||||
tick = TRI_NewTickVocBase();
|
||||
tid = TRI_GetMarkerIdTransaction(trxCollection->_transaction);
|
||||
primary = trxCollection->_collection->_collection;
|
||||
|
||||
// generate the key
|
||||
keyGenerator = (TRI_key_generator_t*) primary->_keyGenerator;
|
||||
TRI_ASSERT_DEBUG(keyGenerator != NULL);
|
||||
TRI_ASSERT_MAINTAINER(keyGenerator != NULL);
|
||||
|
||||
// create key using key generator
|
||||
res = keyGenerator->generate(keyGenerator,
|
||||
|
@ -484,6 +492,7 @@ static int CreateDocumentMarker (TRI_primary_collection_t* primary,
|
|||
// set the marker type, size, revision id etc.
|
||||
TRI_InitMarker(&marker->base, markerType, *totalSize, tick);
|
||||
marker->_rid = tick;
|
||||
marker->_tid = tid;
|
||||
marker->_shape = shaped->_sid;
|
||||
|
||||
*keyBody = ((char*) marker) + markerSize;
|
||||
|
@ -705,26 +714,6 @@ static int WriteElement (TRI_document_collection_t* document,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief whether or not to write synchronised
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool RealSync (TRI_transaction_collection_t* trxCollection,
|
||||
const bool syncRequested) {
|
||||
if (syncRequested) {
|
||||
// explicit request to sync
|
||||
return true;
|
||||
}
|
||||
|
||||
if (trxCollection->_waitForSync) {
|
||||
// collection has waitForSync property
|
||||
return true;
|
||||
}
|
||||
|
||||
// default is false
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -742,37 +731,39 @@ static bool RealSync (TRI_transaction_collection_t* trxCollection,
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int WriteMarker (TRI_document_collection_t* document,
|
||||
TRI_df_marker_t* marker,
|
||||
const TRI_voc_size_t totalSize,
|
||||
TRI_voc_fid_t* fid,
|
||||
TRI_df_marker_t** result,
|
||||
const bool forceSync) {
|
||||
TRI_datafile_t* journal;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief writes an insert marker into the datafile
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int WriteInsertMarker (TRI_document_collection_t* document,
|
||||
TRI_doc_document_key_marker_t* marker,
|
||||
TRI_doc_mptr_t* header,
|
||||
TRI_voc_size_t totalSize,
|
||||
bool waitForSync) {
|
||||
TRI_df_marker_t* result;
|
||||
TRI_voc_fid_t fid;
|
||||
int res;
|
||||
|
||||
// find and select a journal
|
||||
journal = SelectJournal(document, totalSize, result);
|
||||
|
||||
if (journal == NULL) {
|
||||
return TRI_ERROR_ARANGO_NO_JOURNAL;
|
||||
}
|
||||
res = TRI_WriteMarkerDocumentCollection(document, &marker->base, totalSize, &fid, &result, waitForSync);
|
||||
|
||||
*fid = journal->_fid;
|
||||
|
||||
TRI_ASSERT_DEBUG(*result != NULL);
|
||||
|
||||
// now write marker and blob
|
||||
res = WriteElement(document, journal, marker, totalSize, *result);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
if (forceSync) {
|
||||
WaitSync(document, journal, ((char const*) *result) + totalSize);
|
||||
// writing the element into the datafile has succeeded
|
||||
TRI_doc_datafile_info_t* dfi;
|
||||
|
||||
// update the header with the correct fid and the positions in the datafile
|
||||
header->_fid = fid;
|
||||
header->_data = ((char*) result);
|
||||
header->_key = ((char*) result) + marker->_offsetKey;
|
||||
|
||||
// update the datafile info
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(&document->base, fid);
|
||||
|
||||
if (dfi != NULL) {
|
||||
dfi->_numberAlive++;
|
||||
dfi->_sizeAlive += LengthDataMasterPointer(header);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// writing the element into the datafile has failed
|
||||
LOG_ERROR("cannot write marker into datafile: '%s'", TRI_last_error());
|
||||
|
||||
IncreaseDocumentCount(&document->base);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -790,14 +781,14 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection,
|
|||
TRI_doc_mptr_t* header,
|
||||
TRI_voc_size_t totalSize,
|
||||
bool forceSync,
|
||||
TRI_doc_mptr_t* mptr) {
|
||||
TRI_doc_mptr_t* mptr,
|
||||
bool* freeMarker) {
|
||||
TRI_document_collection_t* document;
|
||||
TRI_df_marker_t* result;
|
||||
TRI_voc_fid_t fid;
|
||||
bool written;
|
||||
int res;
|
||||
bool writeSynced;
|
||||
|
||||
TRI_ASSERT_DEBUG(header != NULL);
|
||||
TRI_ASSERT_MAINTAINER(*freeMarker == true);
|
||||
TRI_ASSERT_MAINTAINER(header != NULL);
|
||||
document = (TRI_document_collection_t*) trxCollection->_collection->_collection;
|
||||
|
||||
// .............................................................................
|
||||
|
@ -809,6 +800,7 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection,
|
|||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// insert has failed
|
||||
document->_headers->release(document->_headers, header);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -818,43 +810,34 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection,
|
|||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// insertion into secondary indexes failed
|
||||
DeletePrimaryIndex(document, header, true);
|
||||
document->_headers->release(document->_headers, header);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// .............................................................................
|
||||
// insert into datafile
|
||||
// .............................................................................
|
||||
|
||||
writeSynced = RealSync(trxCollection, forceSync);
|
||||
res = WriteMarker(document, &marker->base, totalSize, &fid, &result, writeSynced);
|
||||
TRI_ASSERT_MAINTAINER(res == TRI_ERROR_NO_ERROR);
|
||||
|
||||
res = TRI_AddOperationCollectionTransaction(trxCollection,
|
||||
(int) TRI_DOCUMENT_INSERT,
|
||||
header,
|
||||
NULL,
|
||||
&marker->base,
|
||||
totalSize,
|
||||
forceSync,
|
||||
&written);
|
||||
if (! written) {
|
||||
*freeMarker = false;
|
||||
}
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
// writing the element into the datafile has succeeded
|
||||
TRI_doc_datafile_info_t* dfi;
|
||||
size_t i, n;
|
||||
|
||||
TRI_IncreaseWritesCollectionTransaction(trxCollection, writeSynced);
|
||||
|
||||
// update the header with the correct fid and the positions in the datafile
|
||||
header->_fid = fid;
|
||||
header->_data = ((char*) result);
|
||||
header->_key = ((char*) result) + marker->_offsetKey;
|
||||
|
||||
*mptr = *header;
|
||||
|
||||
// update the datafile info
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(&document->base, fid);
|
||||
|
||||
if (dfi != NULL) {
|
||||
dfi->_numberAlive++;
|
||||
dfi->_sizeAlive += LengthDataMasterPointer(mptr);
|
||||
}
|
||||
|
||||
|
||||
// .............................................................................
|
||||
// post process insert
|
||||
// .............................................................................
|
||||
|
||||
*mptr = *header;
|
||||
|
||||
n = document->_allIndexes._length;
|
||||
|
||||
|
@ -868,13 +851,60 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// something has failed.... now delete from the indexes again
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// some error has occurred
|
||||
else {
|
||||
// something has failed.... now delete from the indexes again
|
||||
DeleteSecondaryIndexes(document, header, true);
|
||||
DeletePrimaryIndex(document, header, true);
|
||||
|
||||
// something has failed... free the header
|
||||
document->_headers->release(document->_headers, header);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief writes a remove marker into the datafile
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int WriteRemoveMarker (TRI_document_collection_t* document,
|
||||
TRI_doc_deletion_key_marker_t* marker,
|
||||
TRI_doc_mptr_t* header,
|
||||
TRI_voc_size_t totalSize,
|
||||
bool waitForSync) {
|
||||
TRI_df_marker_t* result;
|
||||
TRI_voc_fid_t fid;
|
||||
int res;
|
||||
|
||||
res = TRI_WriteMarkerDocumentCollection(document, &marker->base, totalSize, &fid, &result, waitForSync);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
// writing the element into the datafile has succeeded
|
||||
TRI_doc_datafile_info_t* dfi;
|
||||
|
||||
// update the datafile info
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(&document->base, header->_fid);
|
||||
|
||||
if (dfi != NULL) {
|
||||
size_t length = LengthDataMasterPointer(header);
|
||||
|
||||
dfi->_numberAlive--;
|
||||
dfi->_sizeAlive -= length;
|
||||
|
||||
dfi->_numberDead++;
|
||||
dfi->_sizeDead += length;
|
||||
}
|
||||
|
||||
if (header->_fid != fid) {
|
||||
// only need to look up datafile if it is not the same
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(&document->base, fid);
|
||||
}
|
||||
|
||||
if (dfi != NULL) {
|
||||
dfi->_numberDeletion++;
|
||||
}
|
||||
|
||||
DecreaseDocumentCount(&document->base);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -891,14 +921,15 @@ static int RemoveDocument (TRI_transaction_collection_t* trxCollection,
|
|||
TRI_doc_update_policy_t const* policy,
|
||||
TRI_doc_deletion_key_marker_t* marker,
|
||||
const TRI_voc_size_t totalSize,
|
||||
const bool forceSync) {
|
||||
const bool forceSync,
|
||||
bool* freeMarker) {
|
||||
TRI_primary_collection_t* primary;
|
||||
TRI_document_collection_t* document;
|
||||
TRI_doc_mptr_t* header;
|
||||
TRI_df_marker_t* result;
|
||||
TRI_voc_fid_t fid;
|
||||
bool written;
|
||||
int res;
|
||||
bool writeSynced;
|
||||
|
||||
TRI_ASSERT_MAINTAINER(*freeMarker == true);
|
||||
|
||||
primary = trxCollection->_collection->_collection;
|
||||
document = (TRI_document_collection_t*) primary;
|
||||
|
@ -945,41 +976,24 @@ static int RemoveDocument (TRI_transaction_collection_t* trxCollection,
|
|||
}
|
||||
|
||||
|
||||
TRI_ASSERT_DEBUG(res == TRI_ERROR_NO_ERROR);
|
||||
|
||||
TRI_ASSERT_MAINTAINER(res == TRI_ERROR_NO_ERROR);
|
||||
|
||||
res = TRI_AddOperationCollectionTransaction(trxCollection,
|
||||
(int) TRI_DOCUMENT_REMOVE,
|
||||
header,
|
||||
header,
|
||||
&marker->base,
|
||||
totalSize,
|
||||
forceSync,
|
||||
&written);
|
||||
|
||||
if (! written) {
|
||||
*freeMarker = false;
|
||||
}
|
||||
|
||||
// find and select a journal
|
||||
writeSynced = RealSync(trxCollection, forceSync);
|
||||
res = WriteMarker(document, &marker->base, totalSize, &fid, &result, writeSynced);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
TRI_doc_datafile_info_t* dfi;
|
||||
size_t i, n;
|
||||
|
||||
TRI_IncreaseWritesCollectionTransaction(trxCollection, writeSynced);
|
||||
|
||||
// update the datafile info
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(primary, header->_fid);
|
||||
|
||||
if (dfi != NULL) {
|
||||
size_t length = LengthDataMasterPointer(header);
|
||||
|
||||
dfi->_numberAlive--;
|
||||
dfi->_sizeAlive -= length;
|
||||
|
||||
dfi->_numberDead++;
|
||||
dfi->_sizeDead += length;
|
||||
}
|
||||
|
||||
if (header->_fid != fid) {
|
||||
// only need to look up datafile if it is not the same
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(primary, fid);
|
||||
}
|
||||
|
||||
if (dfi != NULL) {
|
||||
dfi->_numberDeletion++;
|
||||
}
|
||||
|
||||
|
||||
// .............................................................................
|
||||
// post process delete
|
||||
// .............................................................................
|
||||
|
@ -988,18 +1002,19 @@ static int RemoveDocument (TRI_transaction_collection_t* trxCollection,
|
|||
for (i = 0; i < n; ++i) {
|
||||
TRI_index_t* idx;
|
||||
|
||||
idx = document->_allIndexes._buffer[i];
|
||||
idx = document->_allIndexes._buffer[i];
|
||||
|
||||
if (idx->postRemove != NULL) {
|
||||
idx->postRemove(trxCollection, idx, header);
|
||||
}
|
||||
if (idx->postRemove != NULL) {
|
||||
idx->postRemove(trxCollection, idx, header);
|
||||
}
|
||||
}
|
||||
|
||||
if (written) {
|
||||
// release the header pointer
|
||||
document->_headers->release(document->_headers, header);
|
||||
}
|
||||
|
||||
// release the header pointer
|
||||
document->_headers->release(document->_headers, header);
|
||||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
else {
|
||||
// deletion failed. roll back
|
||||
InsertSecondaryIndexes(document, header, true);
|
||||
InsertPrimaryIndex(document, header, true);
|
||||
|
@ -1028,6 +1043,56 @@ static void UpdateHeader (TRI_voc_fid_t fid,
|
|||
newHeader->_validTo = oldHeader->_validTo; // TODO: fix for trx
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief writes an update marker into the datafile
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int WriteUpdateMarker (TRI_document_collection_t* document,
|
||||
TRI_doc_document_key_marker_t* marker,
|
||||
TRI_doc_mptr_t* header,
|
||||
const TRI_doc_mptr_t* oldHeader,
|
||||
TRI_voc_size_t totalSize,
|
||||
bool waitForSync) {
|
||||
TRI_df_marker_t* result;
|
||||
TRI_voc_fid_t fid;
|
||||
int res;
|
||||
|
||||
res = TRI_WriteMarkerDocumentCollection(document, &marker->base, totalSize, &fid, &result, waitForSync);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
// writing the element into the datafile has succeeded
|
||||
TRI_doc_datafile_info_t* dfi;
|
||||
|
||||
// update the header with the correct fid and the positions in the datafile
|
||||
header->_fid = fid;
|
||||
header->_data = ((char*) result);
|
||||
header->_key = ((char*) result) + marker->_offsetKey;
|
||||
|
||||
// update the datafile info
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(&document->base, fid);
|
||||
|
||||
if (dfi != NULL) {
|
||||
dfi->_numberAlive++;
|
||||
dfi->_sizeAlive += LengthDataMasterPointer(header);
|
||||
}
|
||||
|
||||
if (oldHeader->_fid != fid) {
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(&document->base, oldHeader->_fid);
|
||||
}
|
||||
|
||||
if (dfi != NULL) {
|
||||
size_t length = LengthDataMasterPointer(oldHeader);
|
||||
|
||||
dfi->_numberAlive--;
|
||||
dfi->_sizeAlive -= length;
|
||||
dfi->_numberDead++;
|
||||
dfi->_sizeDead += length;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief updates an existing document splitted into marker and body to file
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1037,15 +1102,15 @@ static int UpdateDocument (TRI_transaction_collection_t* trxCollection,
|
|||
TRI_doc_document_key_marker_t* marker,
|
||||
const TRI_voc_size_t totalSize,
|
||||
const bool forceSync,
|
||||
TRI_doc_mptr_t* mptr) {
|
||||
TRI_doc_mptr_t* mptr,
|
||||
bool *freeMarker) {
|
||||
TRI_document_collection_t* document;
|
||||
TRI_doc_mptr_t* newHeader;
|
||||
TRI_doc_mptr_t oldData;
|
||||
TRI_df_marker_t* result;
|
||||
TRI_voc_fid_t fid;
|
||||
int res;
|
||||
bool writeSynced;
|
||||
bool written;
|
||||
|
||||
TRI_ASSERT_MAINTAINER(*freeMarker == true);
|
||||
document = (TRI_document_collection_t*) trxCollection->_collection->_collection;
|
||||
|
||||
// save the old data, remember
|
||||
|
@ -1095,49 +1160,24 @@ static int UpdateDocument (TRI_transaction_collection_t* trxCollection,
|
|||
}
|
||||
|
||||
|
||||
// .............................................................................
|
||||
// write datafile
|
||||
// .............................................................................
|
||||
TRI_ASSERT_MAINTAINER(res == TRI_ERROR_NO_ERROR);
|
||||
|
||||
writeSynced = RealSync(trxCollection, forceSync);
|
||||
res = WriteMarker(document, &marker->base, totalSize, &fid, &result, writeSynced);
|
||||
res = TRI_AddOperationCollectionTransaction(trxCollection,
|
||||
(int) TRI_DOCUMENT_UPDATE,
|
||||
newHeader,
|
||||
&oldData,
|
||||
&marker->base,
|
||||
totalSize,
|
||||
forceSync,
|
||||
&written);
|
||||
|
||||
if (! written) {
|
||||
*freeMarker = false;
|
||||
}
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
TRI_doc_datafile_info_t* dfi;
|
||||
TRI_primary_collection_t* primary;
|
||||
size_t i, n;
|
||||
|
||||
TRI_IncreaseWritesCollectionTransaction(trxCollection, writeSynced);
|
||||
|
||||
// update the header with the correct fid and the positions in the datafile
|
||||
newHeader->_fid = fid;
|
||||
newHeader->_data = ((char*) result);
|
||||
newHeader->_key = ((char*) result) + marker->_offsetKey;
|
||||
|
||||
primary = (TRI_primary_collection_t*) document;
|
||||
|
||||
// update the datafile info
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(primary, oldData._fid);
|
||||
|
||||
if (dfi != NULL) {
|
||||
size_t length = LengthDataMasterPointer(&oldData);
|
||||
|
||||
dfi->_numberAlive--;
|
||||
dfi->_sizeAlive -= length;
|
||||
dfi->_numberDead++;
|
||||
dfi->_sizeDead += length;
|
||||
}
|
||||
|
||||
if (oldData._fid != fid) {
|
||||
// only select new journal if it different from the old
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(primary, fid);
|
||||
}
|
||||
|
||||
if (dfi != NULL) {
|
||||
dfi->_numberAlive++;
|
||||
dfi->_sizeAlive += LengthDataMasterPointer(newHeader);
|
||||
}
|
||||
|
||||
// .............................................................................
|
||||
// post process update
|
||||
// .............................................................................
|
||||
|
@ -1148,7 +1188,7 @@ static int UpdateDocument (TRI_transaction_collection_t* trxCollection,
|
|||
TRI_index_t* idx;
|
||||
|
||||
idx = document->_allIndexes._buffer[i];
|
||||
|
||||
|
||||
if (idx->postUpdate != NULL) {
|
||||
idx->postUpdate(trxCollection, idx, newHeader, oldHeader, &oldData);
|
||||
}
|
||||
|
@ -1418,66 +1458,58 @@ static int InsertShapedJson (TRI_transaction_collection_t* trxCollection,
|
|||
const bool forceSync) {
|
||||
|
||||
TRI_primary_collection_t* primary;
|
||||
TRI_document_collection_t* document;
|
||||
TRI_doc_document_key_marker_t* marker;
|
||||
TRI_doc_mptr_t* header;
|
||||
char* keyBody;
|
||||
TRI_voc_size_t totalSize;
|
||||
bool freeMarker;
|
||||
int res;
|
||||
|
||||
freeMarker = true;
|
||||
primary = trxCollection->_collection->_collection;
|
||||
|
||||
TRI_ASSERT_DEBUG(primary != NULL);
|
||||
TRI_ASSERT_DEBUG(shaped != NULL);
|
||||
TRI_ASSERT_MAINTAINER(primary != NULL);
|
||||
TRI_ASSERT_MAINTAINER(shaped != NULL);
|
||||
|
||||
// first create a new marker in memory
|
||||
// this does not require any locks
|
||||
|
||||
res = CreateDocumentMarker(primary, &marker, &totalSize, &keyBody, markerType, key, shaped, data);
|
||||
res = CreateDocumentMarker(trxCollection, &marker, &totalSize, &keyBody, markerType, key, shaped, data);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(marker != NULL);
|
||||
TRI_ASSERT_DEBUG(keyBody != NULL);
|
||||
TRI_ASSERT_DEBUG(totalSize > 0);
|
||||
TRI_ASSERT_MAINTAINER(marker != NULL);
|
||||
TRI_ASSERT_MAINTAINER(keyBody != NULL);
|
||||
TRI_ASSERT_MAINTAINER(totalSize > 0);
|
||||
|
||||
document = (TRI_document_collection_t*) primary;
|
||||
|
||||
if (lock) {
|
||||
// WRITE-LOCK START
|
||||
primary->beginWrite(primary);
|
||||
}
|
||||
|
||||
header = NULL;
|
||||
res = CreateHeader(document, marker, 0, &header);
|
||||
res = CreateHeader((TRI_document_collection_t*) primary, marker, 0, &header);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
res = InsertDocument(trxCollection, marker, header, totalSize, forceSync, mptr);
|
||||
res = InsertDocument(trxCollection, marker, header, totalSize, forceSync, mptr, &freeMarker);
|
||||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// something has failed... free the header
|
||||
document->_headers->release(document->_headers, header);
|
||||
}
|
||||
else {
|
||||
IncreaseDocumentCount(primary);
|
||||
}
|
||||
|
||||
if (lock) {
|
||||
primary->endWrite(primary);
|
||||
// WRITE-LOCK END
|
||||
}
|
||||
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, marker);
|
||||
|
||||
if (freeMarker) {
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, marker);
|
||||
}
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
TRI_ASSERT_DEBUG(mptr->_key != NULL);
|
||||
TRI_ASSERT_DEBUG(mptr->_data != NULL);
|
||||
TRI_ASSERT_DEBUG(mptr->_rid > 0);
|
||||
TRI_ASSERT_DEBUG(mptr->_fid > 0);
|
||||
TRI_ASSERT_MAINTAINER(mptr->_key != NULL);
|
||||
TRI_ASSERT_MAINTAINER(mptr->_data != NULL);
|
||||
TRI_ASSERT_MAINTAINER(mptr->_rid > 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1522,10 +1554,9 @@ static int ReadShapedJson (TRI_transaction_collection_t* trxCollection,
|
|||
}
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
TRI_ASSERT_DEBUG(mptr->_key != NULL);
|
||||
TRI_ASSERT_DEBUG(mptr->_data != NULL);
|
||||
TRI_ASSERT_DEBUG(mptr->_rid > 0);
|
||||
TRI_ASSERT_DEBUG(mptr->_fid > 0);
|
||||
TRI_ASSERT_MAINTAINER(mptr->_key != NULL);
|
||||
TRI_ASSERT_MAINTAINER(mptr->_data != NULL);
|
||||
TRI_ASSERT_MAINTAINER(mptr->_rid > 0);
|
||||
#endif
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
|
@ -1546,11 +1577,14 @@ static int UpdateShapedJson (TRI_transaction_collection_t* trxCollection,
|
|||
TRI_doc_document_key_marker_t* marker;
|
||||
TRI_doc_mptr_t* header;
|
||||
TRI_voc_size_t totalSize;
|
||||
TRI_voc_tid_t tid;
|
||||
bool freeMarker;
|
||||
int res;
|
||||
|
||||
|
||||
freeMarker = true;
|
||||
primary = trxCollection->_collection->_collection;
|
||||
|
||||
TRI_ASSERT_DEBUG(mptr != NULL);
|
||||
TRI_ASSERT_MAINTAINER(mptr != NULL);
|
||||
|
||||
// initialise the result
|
||||
mptr->_key = NULL;
|
||||
|
@ -1562,7 +1596,7 @@ static int UpdateShapedJson (TRI_transaction_collection_t* trxCollection,
|
|||
primary->beginWrite(primary);
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(key != NULL);
|
||||
TRI_ASSERT_MAINTAINER(key != NULL);
|
||||
|
||||
// get the header pointer of the previous revision
|
||||
header = TRI_LookupByKeyAssociativePointer(&primary->_primaryIndex, key);
|
||||
|
@ -1582,10 +1616,11 @@ static int UpdateShapedJson (TRI_transaction_collection_t* trxCollection,
|
|||
|
||||
original = header->_data;
|
||||
|
||||
res = CloneDocumentMarker(original, &marker, &totalSize, original->_type, shaped);
|
||||
tid = TRI_GetMarkerIdTransaction(trxCollection->_transaction);
|
||||
res = CloneDocumentMarker(tid, original, &marker, &totalSize, original->_type, shaped);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
res = UpdateDocument(trxCollection, header, marker, totalSize, forceSync, mptr);
|
||||
res = UpdateDocument(trxCollection, header, marker, totalSize, forceSync, mptr, &freeMarker);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1593,16 +1628,15 @@ static int UpdateShapedJson (TRI_transaction_collection_t* trxCollection,
|
|||
primary->endWrite(primary);
|
||||
}
|
||||
|
||||
if (marker != NULL) {
|
||||
if (marker != NULL && freeMarker) {
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, marker);
|
||||
}
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
TRI_ASSERT_DEBUG(mptr->_key != NULL);
|
||||
TRI_ASSERT_DEBUG(mptr->_data != NULL);
|
||||
TRI_ASSERT_DEBUG(mptr->_rid > 0);
|
||||
TRI_ASSERT_DEBUG(mptr->_fid > 0);
|
||||
TRI_ASSERT_MAINTAINER(mptr->_key != NULL);
|
||||
TRI_ASSERT_MAINTAINER(mptr->_data != NULL);
|
||||
TRI_ASSERT_MAINTAINER(mptr->_rid > 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1621,35 +1655,37 @@ static int RemoveShapedJson (TRI_transaction_collection_t* trxCollection,
|
|||
TRI_primary_collection_t* primary;
|
||||
TRI_doc_deletion_key_marker_t* marker;
|
||||
TRI_voc_size_t totalSize;
|
||||
TRI_voc_tid_t tid;
|
||||
bool freeMarker;
|
||||
int res;
|
||||
|
||||
|
||||
freeMarker = true;
|
||||
primary = trxCollection->_collection->_collection;
|
||||
TRI_ASSERT_DEBUG(key != NULL);
|
||||
TRI_ASSERT_MAINTAINER(key != NULL);
|
||||
|
||||
marker = NULL;
|
||||
res = CreateDeletionMarker(&marker, &totalSize, key, strlen(key));
|
||||
tid = TRI_GetMarkerIdTransaction(trxCollection->_transaction);
|
||||
res = CreateDeletionMarker(tid, &marker, &totalSize, key, strlen(key));
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(marker != NULL);
|
||||
TRI_ASSERT_MAINTAINER(marker != NULL);
|
||||
|
||||
if (lock) {
|
||||
primary->beginWrite(primary);
|
||||
}
|
||||
|
||||
res = RemoveDocument(trxCollection, policy, marker, totalSize, forceSync);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
DecreaseDocumentCount(primary);
|
||||
}
|
||||
res = RemoveDocument(trxCollection, policy, marker, totalSize, forceSync, &freeMarker);
|
||||
|
||||
if (lock) {
|
||||
primary->endWrite(primary);
|
||||
}
|
||||
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, marker);
|
||||
|
||||
if (freeMarker) {
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, marker);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1787,7 +1823,7 @@ static bool OpenIterator (TRI_df_marker_t const* marker, void* data, TRI_datafil
|
|||
return false;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(header != NULL);
|
||||
TRI_ASSERT_MAINTAINER(header != NULL);
|
||||
|
||||
// insert into primary index
|
||||
res = InsertPrimaryIndex(document, header, false);
|
||||
|
@ -2305,7 +2341,7 @@ TRI_document_collection_t* TRI_CreateDocumentCollection (TRI_vocbase_t* vocbase,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(keyGenerator != NULL);
|
||||
TRI_ASSERT_MAINTAINER(keyGenerator != NULL);
|
||||
|
||||
|
||||
// first create the document collection
|
||||
|
@ -2423,6 +2459,78 @@ void TRI_FreeDocumentCollection (TRI_document_collection_t* collection) {
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief writes a marker into the datafile
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_WriteMarkerDocumentCollection (TRI_document_collection_t* document,
|
||||
TRI_df_marker_t* marker,
|
||||
const TRI_voc_size_t totalSize,
|
||||
TRI_voc_fid_t* fid,
|
||||
TRI_df_marker_t** result,
|
||||
const bool forceSync) {
|
||||
TRI_datafile_t* journal;
|
||||
int res;
|
||||
|
||||
// find and select a journal
|
||||
journal = SelectJournal(document, totalSize, result);
|
||||
|
||||
if (journal == NULL) {
|
||||
return TRI_ERROR_ARANGO_NO_JOURNAL;
|
||||
}
|
||||
|
||||
if (fid != NULL) {
|
||||
*fid = journal->_fid;
|
||||
}
|
||||
|
||||
TRI_ASSERT_MAINTAINER(*result != NULL);
|
||||
|
||||
// now write marker and blob
|
||||
res = WriteElement(document, journal, marker, totalSize, *result);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
if (forceSync) {
|
||||
WaitSync(document, journal, ((char const*) *result) + totalSize);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// writing the element into the datafile has failed
|
||||
LOG_ERROR("cannot write marker into datafile: '%s'", TRI_last_error());
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief writes a document operation marker into the datafile
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_WriteOperationDocumentCollection (TRI_document_collection_t* document,
|
||||
TRI_document_operation_e type,
|
||||
TRI_doc_mptr_t* header,
|
||||
TRI_doc_mptr_t* oldHeader,
|
||||
TRI_df_marker_t* marker,
|
||||
TRI_voc_size_t totalSize,
|
||||
bool waitForSync) {
|
||||
int res;
|
||||
|
||||
if (type == TRI_DOCUMENT_INSERT) {
|
||||
res = WriteInsertMarker(document, (TRI_doc_document_key_marker_t*) marker, header, totalSize, waitForSync);
|
||||
}
|
||||
else if (type == TRI_DOCUMENT_UPDATE) {
|
||||
res = WriteUpdateMarker(document, (TRI_doc_document_key_marker_t*) marker, header, oldHeader, totalSize, waitForSync);
|
||||
}
|
||||
else if (type == TRI_DOCUMENT_REMOVE) {
|
||||
res = WriteRemoveMarker(document, (TRI_doc_deletion_key_marker_t*) marker, oldHeader, totalSize, waitForSync);
|
||||
}
|
||||
else {
|
||||
res = TRI_ERROR_INTERNAL;
|
||||
LOG_ERROR("logic error in TRI_WriteOperationDocumentCollection");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a new journal
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2510,7 +2618,7 @@ TRI_document_collection_t* TRI_OpenDocumentCollection (TRI_vocbase_t* vocbase, c
|
|||
return NULL;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(keyGenerator != NULL);
|
||||
TRI_ASSERT_MAINTAINER(keyGenerator != NULL);
|
||||
document->base._keyGenerator = keyGenerator;
|
||||
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
|
||||
#include "VocBase/primary-collection.h"
|
||||
|
||||
#include "BasicsC/associative-multi.h"
|
||||
|
||||
#include "VocBase/headers.h"
|
||||
#include "VocBase/index.h"
|
||||
|
||||
|
@ -42,6 +40,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- forward declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct TRI_df_marker_s;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- DOCUMENT COLLECTION
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -172,6 +176,17 @@ extern "C" {
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief enum for write operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef enum {
|
||||
TRI_DOCUMENT_INSERT = 1,
|
||||
TRI_DOCUMENT_UPDATE,
|
||||
TRI_DOCUMENT_REMOVE
|
||||
}
|
||||
TRI_document_operation_e;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief primary collection with global read-write lock
|
||||
///
|
||||
|
@ -257,6 +272,29 @@ void TRI_FreeDocumentCollection (TRI_document_collection_t*);
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief writes a marker into the datafile
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_WriteMarkerDocumentCollection (TRI_document_collection_t*,
|
||||
struct TRI_df_marker_s*,
|
||||
const TRI_voc_size_t,
|
||||
TRI_voc_fid_t*,
|
||||
struct TRI_df_marker_s**,
|
||||
const bool);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief writes a document operation marker into the datafile
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_WriteOperationDocumentCollection (TRI_document_collection_t*,
|
||||
TRI_document_operation_e,
|
||||
TRI_doc_mptr_t*,
|
||||
TRI_doc_mptr_t*,
|
||||
TRI_df_marker_t*,
|
||||
TRI_voc_size_t,
|
||||
bool);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a new journal
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -94,7 +94,7 @@ static size_t GetBlockSize (const size_t blockNumber) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void ClearSimpleHeaders (TRI_doc_mptr_t* header, size_t headerSize) {
|
||||
TRI_ASSERT_DEBUG(header);
|
||||
assert(header != NULL);
|
||||
|
||||
memset(header, 0, headerSize);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ static TRI_doc_mptr_t* RequestSimpleHeaders (TRI_headers_t* h) {
|
|||
size_t blockSize;
|
||||
|
||||
blockSize = GetBlockSize(headers->_blocks._length);
|
||||
TRI_ASSERT_DEBUG(blockSize > 0);
|
||||
TRI_ASSERT_MAINTAINER(blockSize > 0);
|
||||
|
||||
begin = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, blockSize * headers->_headerSize, true);
|
||||
|
||||
|
@ -133,13 +133,13 @@ static TRI_doc_mptr_t* RequestSimpleHeaders (TRI_headers_t* h) {
|
|||
header = ptr;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(headers != NULL);
|
||||
TRI_ASSERT_MAINTAINER(headers != NULL);
|
||||
headers->_freelist = (TRI_doc_mptr_t*) header;
|
||||
|
||||
TRI_PushBackVectorPointer(&headers->_blocks, begin);
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(headers->_freelist != NULL);
|
||||
assert(headers->_freelist != NULL);
|
||||
|
||||
result = CONST_CAST(headers->_freelist);
|
||||
headers->_freelist = result->_data;
|
||||
|
|
|
@ -69,7 +69,7 @@ void TRI_InitIndex (TRI_index_t* idx,
|
|||
struct TRI_primary_collection_s* primary,
|
||||
bool unique,
|
||||
bool needsFullCoverage) {
|
||||
TRI_ASSERT_DEBUG(idx != NULL);
|
||||
assert(idx != NULL);
|
||||
|
||||
idx->_iid = TRI_NewTickVocBase();
|
||||
idx->_type = type;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "PriorityQueue/pqueueindex.h"
|
||||
#include "ShapedJson/shaped-json.h"
|
||||
#include "SkipLists/skiplistIndex.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -54,6 +55,7 @@ struct TRI_collection_s;
|
|||
struct TRI_doc_mptr_s;
|
||||
struct TRI_shaped_json_s;
|
||||
struct TRI_document_collection_s;
|
||||
struct TRI_transaction_collection_s;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
|
|
|
@ -36,6 +36,45 @@
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the name for a marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* TRI_NameMarker (TRI_df_marker_t const* marker) {
|
||||
switch (marker->_type) {
|
||||
case TRI_DOC_MARKER_KEY_DOCUMENT:
|
||||
return "document";
|
||||
case TRI_DOC_MARKER_KEY_EDGE:
|
||||
return "edge";
|
||||
case TRI_DOC_MARKER_KEY_DELETION:
|
||||
return "deletion";
|
||||
case TRI_DOC_MARKER_BEGIN_TRANSACTION:
|
||||
return "begin transaction";
|
||||
case TRI_DOC_MARKER_COMMIT_TRANSACTION:
|
||||
return "commit transaction";
|
||||
case TRI_DOC_MARKER_ABORT_TRANSACTION:
|
||||
return "abort transaction";
|
||||
|
||||
case TRI_DF_MARKER_HEADER:
|
||||
case TRI_COL_MARKER_HEADER:
|
||||
return "header";
|
||||
case TRI_DF_MARKER_FOOTER:
|
||||
return "footer";
|
||||
case TRI_DF_MARKER_ATTRIBUTE:
|
||||
return "attribute";
|
||||
case TRI_DF_MARKER_SHAPE:
|
||||
return "shape";
|
||||
|
||||
case TRI_DOC_MARKER_DOCUMENT:
|
||||
case TRI_DOC_MARKER_EDGE:
|
||||
case TRI_DOC_MARKER_DELETION:
|
||||
return "deprecated";
|
||||
|
||||
default:
|
||||
return "unused/unknown";
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clones a marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -45,11 +84,11 @@ void TRI_CloneMarker (TRI_df_marker_t* dst,
|
|||
TRI_voc_size_t copyLength,
|
||||
TRI_voc_size_t newSize,
|
||||
TRI_voc_tick_t tick) {
|
||||
TRI_ASSERT_DEBUG(src != NULL);
|
||||
TRI_ASSERT_DEBUG(dst != NULL);
|
||||
TRI_ASSERT_DEBUG(copyLength > 0);
|
||||
TRI_ASSERT_DEBUG(newSize > 0);
|
||||
TRI_ASSERT_DEBUG(tick > 0);
|
||||
TRI_ASSERT_MAINTAINER(src != NULL);
|
||||
TRI_ASSERT_MAINTAINER(dst != NULL);
|
||||
TRI_ASSERT_MAINTAINER(copyLength > 0);
|
||||
TRI_ASSERT_MAINTAINER(newSize > 0);
|
||||
TRI_ASSERT_MAINTAINER(tick > 0);
|
||||
|
||||
memcpy(dst, src, copyLength);
|
||||
|
||||
|
@ -66,12 +105,13 @@ void TRI_InitMarker (TRI_df_marker_t* marker,
|
|||
TRI_df_marker_type_e type,
|
||||
TRI_voc_size_t size,
|
||||
TRI_voc_tick_t tick) {
|
||||
TRI_ASSERT_DEBUG(marker != NULL);
|
||||
TRI_ASSERT_DEBUG(type > TRI_MARKER_MIN && type < TRI_MARKER_MAX);
|
||||
TRI_ASSERT_DEBUG(size > 0);
|
||||
TRI_ASSERT_DEBUG(tick > 0);
|
||||
|
||||
// initialise the basic byytes
|
||||
TRI_ASSERT_MAINTAINER(marker != NULL);
|
||||
TRI_ASSERT_MAINTAINER(type > TRI_MARKER_MIN && type < TRI_MARKER_MAX);
|
||||
TRI_ASSERT_MAINTAINER(size > 0);
|
||||
TRI_ASSERT_MAINTAINER(tick > 0);
|
||||
|
||||
// initialise the basic bytes
|
||||
memset(marker, 0, size);
|
||||
|
||||
marker->_size = size;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "BasicsC/common.h"
|
||||
#include "VocBase/datafile.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -45,6 +45,12 @@ extern "C" {
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the name for a marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* TRI_NameMarker (TRI_df_marker_t const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clones a marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -198,7 +198,7 @@ static TRI_datafile_t* CreateJournal (TRI_primary_collection_t* primary,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
TRI_ASSERT_DEBUG(fid == journal->_fid);
|
||||
assert(fid == journal->_fid);
|
||||
|
||||
|
||||
// if a physical file, we can rename it from the temporary name to the correct name
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
#include "ShapedJson/json-shaper.h"
|
||||
#include "VocBase/barrier.h"
|
||||
#include "VocBase/marker.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/update-policy.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -305,7 +307,7 @@ typedef struct TRI_doc_document_key_marker_s {
|
|||
TRI_df_marker_t base;
|
||||
|
||||
TRI_voc_rid_t _rid; // this is the tick for a create and update
|
||||
TRI_voc_eid_t _sid;
|
||||
TRI_voc_tid_t _tid;
|
||||
|
||||
TRI_shape_sid_t _shape;
|
||||
|
||||
|
@ -313,7 +315,7 @@ typedef struct TRI_doc_document_key_marker_s {
|
|||
uint16_t _offsetJson;
|
||||
|
||||
#ifdef TRI_PADDING_32
|
||||
char _padding_df_marker[4];
|
||||
char _padding_df_marker[4];
|
||||
#endif
|
||||
}
|
||||
TRI_doc_document_key_marker_t;
|
||||
|
@ -325,14 +327,14 @@ TRI_doc_document_key_marker_t;
|
|||
typedef struct TRI_doc_edge_key_marker_s {
|
||||
TRI_doc_document_key_marker_t base;
|
||||
|
||||
TRI_voc_cid_t _toCid;
|
||||
TRI_voc_cid_t _fromCid;
|
||||
TRI_voc_cid_t _toCid;
|
||||
TRI_voc_cid_t _fromCid;
|
||||
|
||||
uint16_t _offsetToKey;
|
||||
uint16_t _offsetFromKey;
|
||||
uint16_t _offsetToKey;
|
||||
uint16_t _offsetFromKey;
|
||||
|
||||
#ifdef TRI_PADDING_32
|
||||
char _padding_df_marker[4];
|
||||
char _padding_df_marker[4];
|
||||
#endif
|
||||
}
|
||||
TRI_doc_edge_key_marker_t;
|
||||
|
@ -344,46 +346,13 @@ TRI_doc_edge_key_marker_t;
|
|||
typedef struct TRI_doc_deletion_key_marker_s {
|
||||
TRI_df_marker_t base;
|
||||
|
||||
TRI_voc_rid_t _rid; // this is the tick for an create and update
|
||||
TRI_voc_eid_t _sid;
|
||||
TRI_voc_rid_t _rid; // this is the tick for the deletion
|
||||
TRI_voc_tid_t _tid;
|
||||
|
||||
uint16_t _offsetKey;
|
||||
uint16_t _offsetKey;
|
||||
}
|
||||
TRI_doc_deletion_key_marker_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief document datafile begin transaction marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_doc_begin_transaction_marker_s {
|
||||
TRI_df_marker_t base;
|
||||
|
||||
TRI_voc_tid_t _tid;
|
||||
}
|
||||
TRI_doc_begin_transaction_marker_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief document datafile commit transaction marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_doc_commit_transaction_marker_s {
|
||||
TRI_df_marker_t base;
|
||||
|
||||
TRI_voc_tid_t _tid;
|
||||
}
|
||||
TRI_doc_commit_transaction_marker_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief document datafile abort transaction marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_doc_abort_transaction_marker_s {
|
||||
TRI_df_marker_t base;
|
||||
|
||||
TRI_voc_tid_t _tid;
|
||||
}
|
||||
TRI_doc_abort_transaction_marker_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -101,7 +101,7 @@ static bool CreateJournal (TRI_shape_collection_t* collection) {
|
|||
|
||||
LOG_TRACE("created a new shape journal '%s'", journal->getName(journal));
|
||||
|
||||
TRI_ASSERT_DEBUG(fid == journal->_fid);
|
||||
assert(fid == journal->_fid);
|
||||
|
||||
if (journal->isPhysical(journal)) {
|
||||
char* jname;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,6 +35,9 @@
|
|||
#include "BasicsC/locks.h"
|
||||
#include "BasicsC/vector.h"
|
||||
|
||||
#include "VocBase/datafile.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -43,6 +46,10 @@ extern "C" {
|
|||
// --SECTION-- forward declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct TRI_doc_abort_transaction_marker_s;
|
||||
struct TRI_doc_begin_transaction_marker_s;
|
||||
struct TRI_doc_commit_transaction_marker_s;
|
||||
struct TRI_doc_mptr_s;
|
||||
struct TRI_vocbase_s;
|
||||
struct TRI_vocbase_col_s;
|
||||
|
||||
|
@ -59,18 +66,6 @@ struct TRI_vocbase_col_s;
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief transaction id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_transaction_id_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief collection id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_transaction_cid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief transaction type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -146,12 +141,12 @@ TRI_transaction_context_t;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_transaction_collection_stats_s {
|
||||
TRI_transaction_id_t _lastStartedReader;
|
||||
TRI_transaction_id_t _lastFinishedReader;
|
||||
TRI_voc_tid_t _lastStartedReader;
|
||||
TRI_voc_tid_t _lastFinishedReader;
|
||||
|
||||
TRI_transaction_id_t _lastStartedWriter;
|
||||
TRI_transaction_id_t _lastAbortedWriter;
|
||||
TRI_transaction_id_t _lastFinishedWriter;
|
||||
TRI_voc_tid_t _lastStartedWriter;
|
||||
TRI_voc_tid_t _lastAbortedWriter;
|
||||
TRI_voc_tid_t _lastFinishedWriter;
|
||||
}
|
||||
TRI_transaction_collection_stats_t;
|
||||
|
||||
|
@ -160,7 +155,7 @@ TRI_transaction_collection_stats_t;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_transaction_collection_global_s {
|
||||
TRI_transaction_cid_t _cid;
|
||||
TRI_voc_cid_t _cid;
|
||||
TRI_read_write_lock_t _lock;
|
||||
|
||||
TRI_transaction_collection_stats_t _stats;
|
||||
|
@ -211,14 +206,14 @@ void TRI_FreeTransactionContext (TRI_transaction_context_t* const);
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_RemoveCollectionTransactionContext (TRI_transaction_context_t*,
|
||||
const TRI_transaction_cid_t);
|
||||
const TRI_voc_cid_t);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief populates a struct with transaction statistics for a collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_StatsCollectionTransactionContext (TRI_transaction_context_t*,
|
||||
const TRI_transaction_cid_t,
|
||||
const TRI_voc_cid_t,
|
||||
TRI_transaction_collection_stats_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -263,12 +258,13 @@ TRI_transaction_hint_e;
|
|||
|
||||
typedef struct TRI_transaction_s {
|
||||
TRI_transaction_context_t* _context; // global context object
|
||||
TRI_transaction_id_t _id;
|
||||
TRI_voc_tid_t _id;
|
||||
TRI_transaction_type_e _type; // access type (read|write)
|
||||
TRI_transaction_status_e _status; // current status
|
||||
TRI_vector_pointer_t _collections; // list of participating collections
|
||||
TRI_transaction_hint_t _hints; // hints;
|
||||
int _nestingLevel;
|
||||
int _nestingLevel;
|
||||
bool _hasOperations;
|
||||
}
|
||||
TRI_transaction_t;
|
||||
|
||||
|
@ -278,15 +274,14 @@ TRI_transaction_t;
|
|||
|
||||
typedef struct TRI_transaction_collection_s {
|
||||
TRI_transaction_t* _transaction; // the transaction
|
||||
TRI_transaction_cid_t _cid; // collection id
|
||||
TRI_voc_cid_t _cid; // collection id
|
||||
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
|
||||
TRI_transaction_collection_global_t* _globalInstance; // pointer to the global instance
|
||||
uint64_t _numWrites; // number of writes
|
||||
TRI_vector_t* _operations; // buffered CRUD operations
|
||||
bool _locked; // collection lock flag
|
||||
bool _waitForSync; // whether or not the collection has waitForSync
|
||||
bool _hadSyncedWrites; // whether or not synced writes happened
|
||||
}
|
||||
TRI_transaction_collection_t;
|
||||
|
||||
|
@ -340,14 +335,14 @@ void TRI_IncreaseWritesCollectionTransaction (TRI_transaction_collection_t*,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_WasSynchronousCollectionTransaction (TRI_transaction_t const*,
|
||||
const TRI_transaction_cid_t);
|
||||
const TRI_voc_cid_t);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return the collection from a transaction
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_transaction_collection_t* TRI_GetCollectionTransaction (TRI_transaction_t const*,
|
||||
const TRI_transaction_cid_t,
|
||||
const TRI_voc_cid_t,
|
||||
const TRI_transaction_type_e);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -355,7 +350,7 @@ TRI_transaction_collection_t* TRI_GetCollectionTransaction (TRI_transaction_t co
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_AddCollectionTransaction (TRI_transaction_t* const,
|
||||
const TRI_transaction_cid_t,
|
||||
const TRI_voc_cid_t,
|
||||
const TRI_transaction_type_e,
|
||||
const int);
|
||||
|
||||
|
@ -383,6 +378,32 @@ bool TRI_IsLockedCollectionTransaction (TRI_transaction_collection_t*,
|
|||
const TRI_transaction_type_e,
|
||||
const int);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief add a marker to a transaction collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_AddOperationCollectionTransaction (TRI_transaction_collection_t*,
|
||||
int,
|
||||
struct TRI_doc_mptr_s*,
|
||||
struct TRI_doc_mptr_s*,
|
||||
TRI_df_marker_t*,
|
||||
size_t,
|
||||
bool,
|
||||
bool*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get a transaction's id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_voc_tid_t TRI_GetIdTransaction (const TRI_transaction_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get a transaction's id for writing into a marker
|
||||
/// this will return 0 if the operation is standalone
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_voc_tid_t TRI_GetMarkerIdTransaction (const TRI_transaction_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief begin a transaction
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -409,6 +430,92 @@ int TRI_AbortTransaction (TRI_transaction_t* const,
|
|||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- TRANSACTION MARKERS
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup VocBase
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief begin transaction marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_doc_begin_transaction_marker_s {
|
||||
TRI_df_marker_t base;
|
||||
|
||||
TRI_voc_tid_t _tid;
|
||||
uint16_t _numCollections;
|
||||
}
|
||||
TRI_doc_begin_transaction_marker_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief commit transaction marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_doc_commit_transaction_marker_s {
|
||||
TRI_df_marker_t base;
|
||||
|
||||
TRI_voc_tid_t _tid;
|
||||
}
|
||||
TRI_doc_commit_transaction_marker_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief abort transaction marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_doc_abort_transaction_marker_s {
|
||||
TRI_df_marker_t base;
|
||||
|
||||
TRI_voc_tid_t _tid;
|
||||
}
|
||||
TRI_doc_abort_transaction_marker_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup VocBase
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a "begin" marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_CreateMarkerBeginTransaction (TRI_transaction_t*,
|
||||
struct TRI_doc_begin_transaction_marker_s**,
|
||||
uint16_t);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a "commit" marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_CreateMarkerCommitTransaction (TRI_transaction_t*,
|
||||
struct TRI_doc_commit_transaction_marker_s**);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create an "abort" marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_CreateMarkerAbortTransaction (TRI_transaction_t*,
|
||||
struct TRI_doc_abort_transaction_marker_s**);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief vocbase types
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_VOC_BASE_VOC_TYPES_H
|
||||
#define TRIAGENS_VOC_BASE_VOC_TYPES_H 1
|
||||
|
||||
#include "BasicsC/common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup VocBase
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tick type (48bit)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_tick_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief collection identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_cid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief datafile identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_fid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief document key identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef char* TRI_voc_key_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief revision identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_rid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief transaction identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_tid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief size type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint32_t TRI_voc_size_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief signed size type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef int32_t TRI_voc_ssize_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief crc type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint32_t TRI_voc_crc_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief collection storage type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint32_t TRI_col_type_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
|
@ -35,7 +35,7 @@
|
|||
#include "BasicsC/threads.h"
|
||||
#include "BasicsC/vector.h"
|
||||
#include "BasicsC/voc-errors.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -48,6 +48,7 @@ extern "C" {
|
|||
struct TRI_primary_collection_s;
|
||||
struct TRI_col_info_s;
|
||||
struct TRI_shadow_store_s;
|
||||
struct TRI_transaction_context_s;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public macros
|
||||
|
@ -281,84 +282,6 @@ extern size_t PageSize;
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tick type (48bit)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_tick_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief collection identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_cid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief datafile identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_fid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief document key identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef char* TRI_voc_key_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief revision identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_rid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief step identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_eid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief transaction identifier type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t TRI_voc_tid_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief size type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint32_t TRI_voc_size_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief signed size type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef int32_t TRI_voc_ssize_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief boolean flag type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint32_t TRI_voc_flag_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief milli-seconds
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint32_t TRI_voc_ms_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief crc type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint32_t TRI_voc_crc_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief collection storage type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint32_t TRI_col_type_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief database
|
||||
///
|
||||
|
@ -387,7 +310,7 @@ typedef struct TRI_vocbase_s {
|
|||
TRI_associative_pointer_t _authInfo;
|
||||
TRI_read_write_lock_t _authInfoLock;
|
||||
|
||||
TRI_transaction_context_t* _transactionContext;
|
||||
struct TRI_transaction_context_s* _transactionContext;
|
||||
|
||||
// state of the database
|
||||
// 0 = inactive
|
||||
|
|
|
@ -180,23 +180,24 @@ static inline void* CONST_CAST (void const* ptr) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief a wrapper for assert()
|
||||
///
|
||||
/// This wrapper maps TRI_ASSERT_DEBUG() to (void) 0 for non-maintainers. It
|
||||
/// maps TRI_ASSERT_DEBUG() to assert() when TRI_ENABLE_MAINTAINER_MODE is set.
|
||||
/// This wrapper maps TRI_ASSERT_MAINTAINER() to (void) 0 for non-maintainers.
|
||||
/// It maps TRI_ASSERT_MAINTAINER() to assert() when TRI_ENABLE_MAINTAINER_MODE
|
||||
/// is set.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
#define TRI_ASSERT_DEBUG(what) assert(what)
|
||||
#define TRI_ASSERT_MAINTAINER(what) assert(what)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#define TRI_ASSERT_DEBUG(what) (static_cast<void> (0))
|
||||
#define TRI_ASSERT_MAINTAINER(what) (static_cast<void> (0))
|
||||
|
||||
#else
|
||||
|
||||
#define TRI_ASSERT_DEBUG(what) ((void) (0))
|
||||
#define TRI_ASSERT_MAINTAINER(what) ((void) (0))
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ static int ExtractCurrentFile (unzFile uf,
|
|||
}
|
||||
}
|
||||
else {
|
||||
TRI_ASSERT_DEBUG(result == 0);
|
||||
assert(result == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -782,8 +782,8 @@ static bool FillShapeValueArray (TRI_shaper_t* shaper, TRI_shape_value_t* dst, T
|
|||
char* ptr;
|
||||
|
||||
// sanity checks
|
||||
TRI_ASSERT_DEBUG(json->_type == TRI_JSON_ARRAY);
|
||||
TRI_ASSERT_DEBUG(json->_value._objects._length % 2 == 0);
|
||||
assert(json->_type == TRI_JSON_ARRAY);
|
||||
assert(json->_value._objects._length % 2 == 0);
|
||||
|
||||
// number of attributes
|
||||
n = json->_value._objects._length / 2;
|
||||
|
@ -807,8 +807,8 @@ static bool FillShapeValueArray (TRI_shaper_t* shaper, TRI_shape_value_t* dst, T
|
|||
key = TRI_AtVector(&json->_value._objects, 2 * i);
|
||||
val = TRI_AtVector(&json->_value._objects, 2 * i + 1);
|
||||
|
||||
TRI_ASSERT_DEBUG(key != NULL);
|
||||
TRI_ASSERT_DEBUG(val != NULL);
|
||||
assert(key != NULL);
|
||||
assert(val != NULL);
|
||||
|
||||
if (key->_value._string.data == NULL ||
|
||||
key->_value._string.length == 1 ||
|
||||
|
|
Loading…
Reference in New Issue