mirror of https://gitee.com/bigwinds/arangodb
removed separate index lock
This commit is contained in:
parent
1925a16640
commit
ec8742f920
|
@ -479,8 +479,6 @@ namespace triagens {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (document->_primaryIndex._nrUsed == 0) {
|
if (document->_primaryIndex._nrUsed == 0) {
|
||||||
TRI_FreeBarrier(*barrier);
|
TRI_FreeBarrier(*barrier);
|
||||||
*barrier = 0;
|
*barrier = 0;
|
||||||
|
@ -500,8 +498,6 @@ namespace triagens {
|
||||||
*mptr = *((TRI_doc_mptr_t*) beg[pos]);
|
*mptr = *((TRI_doc_mptr_t*) beg[pos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||||
// READ-LOCK END
|
// READ-LOCK END
|
||||||
|
|
||||||
|
@ -547,8 +543,6 @@ namespace triagens {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (document->_primaryIndex._nrUsed > 0) {
|
if (document->_primaryIndex._nrUsed > 0) {
|
||||||
ids.reserve(document->_primaryIndex._nrUsed);
|
ids.reserve(document->_primaryIndex._nrUsed);
|
||||||
|
|
||||||
|
@ -563,8 +557,6 @@ namespace triagens {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (lock) {
|
if (lock) {
|
||||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||||
// READ-LOCK END
|
// READ-LOCK END
|
||||||
|
@ -658,12 +650,8 @@ namespace triagens {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (document->_primaryIndex._nrUsed == 0) {
|
if (document->_primaryIndex._nrUsed == 0) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||||
// READ-LOCK END
|
// READ-LOCK END
|
||||||
return TRI_ERROR_NO_ERROR;
|
return TRI_ERROR_NO_ERROR;
|
||||||
|
@ -672,7 +660,6 @@ namespace triagens {
|
||||||
*barrier = TRI_CreateBarrierElement(&document->_barrierList);
|
*barrier = TRI_CreateBarrierElement(&document->_barrierList);
|
||||||
|
|
||||||
if (*barrier == 0) {
|
if (*barrier == 0) {
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||||
|
|
||||||
return TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
|
@ -723,8 +710,6 @@ namespace triagens {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||||
// READ-LOCK END
|
// READ-LOCK END
|
||||||
|
|
||||||
|
@ -760,11 +745,8 @@ namespace triagens {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (document->_primaryIndex._nrUsed == 0) {
|
if (document->_primaryIndex._nrUsed == 0) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||||
|
|
||||||
// READ-LOCK END
|
// READ-LOCK END
|
||||||
|
@ -774,7 +756,6 @@ namespace triagens {
|
||||||
*barrier = TRI_CreateBarrierElement(&document->_barrierList);
|
*barrier = TRI_CreateBarrierElement(&document->_barrierList);
|
||||||
|
|
||||||
if (*barrier == 0) {
|
if (*barrier == 0) {
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||||
|
|
||||||
return TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
|
@ -806,8 +787,6 @@ namespace triagens {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||||
// READ-LOCK END
|
// READ-LOCK END
|
||||||
|
|
||||||
|
|
|
@ -463,7 +463,6 @@ bool TRI_LoadAuthInfo (TRI_vocbase_t* vocbase) {
|
||||||
TRI_WriteLockReadWriteLock(&vocbase->_authInfoLock);
|
TRI_WriteLockReadWriteLock(&vocbase->_authInfoLock);
|
||||||
ClearAuthInfo(vocbase);
|
ClearAuthInfo(vocbase);
|
||||||
|
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
beg = document->_primaryIndex._table;
|
beg = document->_primaryIndex._table;
|
||||||
end = beg + document->_primaryIndex._nrAlloc;
|
end = beg + document->_primaryIndex._nrAlloc;
|
||||||
ptr = beg;
|
ptr = beg;
|
||||||
|
@ -489,7 +488,6 @@ bool TRI_LoadAuthInfo (TRI_vocbase_t* vocbase) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
TRI_WriteUnlockReadWriteLock(&vocbase->_authInfoLock);
|
TRI_WriteUnlockReadWriteLock(&vocbase->_authInfoLock);
|
||||||
|
|
||||||
|
|
|
@ -461,13 +461,9 @@ static bool Compactifier (TRI_df_marker_t const* marker,
|
||||||
key = (char*) d + d->_offsetKey;
|
key = (char*) d + d->_offsetKey;
|
||||||
|
|
||||||
// check if the document is still active
|
// check if the document is still active
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
found = static_cast<TRI_doc_mptr_t const*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
found = static_cast<TRI_doc_mptr_t const*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
||||||
deleted = (found == NULL || found->_rid > d->_rid);
|
deleted = (found == NULL || found->_rid > d->_rid);
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
LOG_TRACE("found a stale document: %s", key);
|
LOG_TRACE("found a stale document: %s", key);
|
||||||
return true;
|
return true;
|
||||||
|
@ -483,8 +479,6 @@ static bool Compactifier (TRI_df_marker_t const* marker,
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the document is still active
|
// check if the document is still active
|
||||||
TRI_WriteLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
found = static_cast<TRI_doc_mptr_t const*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
found = static_cast<TRI_doc_mptr_t const*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
||||||
deleted = found == NULL;
|
deleted = found == NULL;
|
||||||
|
|
||||||
|
@ -492,8 +486,6 @@ static bool Compactifier (TRI_df_marker_t const* marker,
|
||||||
context->_dfi._numberDead += 1;
|
context->_dfi._numberDead += 1;
|
||||||
context->_dfi._sizeDead += (int64_t) marker->_size;
|
context->_dfi._sizeDead += (int64_t) marker->_size;
|
||||||
|
|
||||||
TRI_WriteUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
LOG_DEBUG("found a stale document after copying: %s", key);
|
LOG_DEBUG("found a stale document after copying: %s", key);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -522,8 +514,6 @@ static bool Compactifier (TRI_df_marker_t const* marker,
|
||||||
// update datafile info
|
// update datafile info
|
||||||
context->_dfi._numberAlive += 1;
|
context->_dfi._numberAlive += 1;
|
||||||
context->_dfi._sizeAlive += (int64_t) marker->_size;
|
context->_dfi._sizeAlive += (int64_t) marker->_size;
|
||||||
|
|
||||||
TRI_WriteUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// deletions
|
// deletions
|
||||||
|
@ -703,13 +693,9 @@ static bool CalculateSize (TRI_df_marker_t const* marker,
|
||||||
key = (char*) d + d->_offsetKey;
|
key = (char*) d + d->_offsetKey;
|
||||||
|
|
||||||
// check if the document is still active
|
// check if the document is still active
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
TRI_doc_mptr_t const* found = static_cast<TRI_doc_mptr_t const*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
TRI_doc_mptr_t const* found = static_cast<TRI_doc_mptr_t const*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
||||||
deleted = (found == NULL || found->_rid > d->_rid);
|
deleted = (found == NULL || found->_rid > d->_rid);
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,9 +562,7 @@ static int InsertPrimaryIndex (TRI_document_collection_t* document,
|
||||||
TRI_ASSERT_MAINTAINER(header->_dataptr != nullptr); // ONLY IN INDEX
|
TRI_ASSERT_MAINTAINER(header->_dataptr != nullptr); // ONLY IN INDEX
|
||||||
|
|
||||||
// insert into primary index
|
// insert into primary index
|
||||||
TRI_WriteLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
int res = TRI_InsertKeyPrimaryIndex(&document->_primaryIndex, header, (void const**) &found);
|
int res = TRI_InsertKeyPrimaryIndex(&document->_primaryIndex, header, (void const**) &found);
|
||||||
TRI_WriteUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
return res;
|
return res;
|
||||||
|
@ -626,9 +624,7 @@ static int DeletePrimaryIndex (TRI_document_collection_t* document,
|
||||||
// remove from main index
|
// remove from main index
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
TRI_WriteLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
TRI_doc_mptr_t* found = static_cast<TRI_doc_mptr_t*>(TRI_RemoveKeyPrimaryIndex(&document->_primaryIndex, TRI_EXTRACT_MARKER_KEY(header))); // ONLY IN INDEX
|
TRI_doc_mptr_t* found = static_cast<TRI_doc_mptr_t*>(TRI_RemoveKeyPrimaryIndex(&document->_primaryIndex, TRI_EXTRACT_MARKER_KEY(header))); // ONLY IN INDEX
|
||||||
TRI_WriteUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (found == nullptr) {
|
if (found == nullptr) {
|
||||||
return TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND;
|
return TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND;
|
||||||
|
@ -1107,9 +1103,7 @@ static int LookupDocument (TRI_document_collection_t* document,
|
||||||
TRI_voc_key_t key,
|
TRI_voc_key_t key,
|
||||||
TRI_doc_update_policy_t const* policy,
|
TRI_doc_update_policy_t const* policy,
|
||||||
TRI_doc_mptr_t*& header) {
|
TRI_doc_mptr_t*& header) {
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
header = static_cast<TRI_doc_mptr_t*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
header = static_cast<TRI_doc_mptr_t*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
if (! IsVisible(header)) {
|
if (! IsVisible(header)) {
|
||||||
return TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND;
|
return TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND;
|
||||||
|
@ -2903,8 +2897,6 @@ size_t TRI_DocumentIteratorPrimaryCollection (TransactionBase const*,
|
||||||
// master pointers and their data pointers in the callback are
|
// master pointers and their data pointers in the callback are
|
||||||
// protected.
|
// protected.
|
||||||
|
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
size_t const nrUsed = (size_t) document->_primaryIndex._nrUsed;
|
size_t const nrUsed = (size_t) document->_primaryIndex._nrUsed;
|
||||||
|
|
||||||
if (nrUsed > 0) {
|
if (nrUsed > 0) {
|
||||||
|
@ -2922,8 +2914,6 @@ size_t TRI_DocumentIteratorPrimaryCollection (TransactionBase const*,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
return nrUsed;
|
return nrUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3470,8 +3460,6 @@ static int FillIndex (TRI_document_collection_t* document,
|
||||||
void** ptr;
|
void** ptr;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
ptr = document->_primaryIndex._table;
|
ptr = document->_primaryIndex._table;
|
||||||
end = ptr + document->_primaryIndex._nrAlloc;
|
end = ptr + document->_primaryIndex._nrAlloc;
|
||||||
|
|
||||||
|
@ -3496,8 +3484,6 @@ static int FillIndex (TRI_document_collection_t* document,
|
||||||
(char*) TRI_EXTRACT_MARKER_KEY(mptr), // ONLY IN INDEX
|
(char*) TRI_EXTRACT_MARKER_KEY(mptr), // ONLY IN INDEX
|
||||||
(unsigned long long) idx->_iid);
|
(unsigned long long) idx->_iid);
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3511,8 +3497,6 @@ static int FillIndex (TRI_document_collection_t* document,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
return TRI_ERROR_NO_ERROR;
|
return TRI_ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5630,8 +5614,6 @@ TRI_vector_t TRI_SelectByExample (TRI_transaction_collection_t* trxCollection,
|
||||||
// do a full scan
|
// do a full scan
|
||||||
shaper = document->_shaper;
|
shaper = document->_shaper;
|
||||||
|
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
TRI_doc_mptr_t const** ptr = (TRI_doc_mptr_t const**) (document->_primaryIndex._table);
|
TRI_doc_mptr_t const** ptr = (TRI_doc_mptr_t const**) (document->_primaryIndex._table);
|
||||||
TRI_doc_mptr_t const** end = (TRI_doc_mptr_t const**) ptr + document->_primaryIndex._nrAlloc;
|
TRI_doc_mptr_t const** end = (TRI_doc_mptr_t const**) ptr + document->_primaryIndex._nrAlloc;
|
||||||
|
|
||||||
|
@ -5643,8 +5625,6 @@ TRI_vector_t TRI_SelectByExample (TRI_transaction_collection_t* trxCollection,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
|
|
||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,8 @@ static bool ResizePrimaryIndex (TRI_primary_index_t* idx,
|
||||||
/// @brief comparison function, compares a master pointer to another
|
/// @brief comparison function, compares a master pointer to another
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static inline bool IsEqualKeyElement (TRI_doc_mptr_t const* header, void const* element) {
|
static inline bool IsEqualKeyElement (TRI_doc_mptr_t const* header,
|
||||||
|
void const* element) {
|
||||||
TRI_doc_mptr_t const* e = static_cast<TRI_doc_mptr_t const*>(element);
|
TRI_doc_mptr_t const* e = static_cast<TRI_doc_mptr_t const*>(element);
|
||||||
|
|
||||||
if (header->_hash != e->_hash) {
|
if (header->_hash != e->_hash) {
|
||||||
|
@ -148,8 +149,6 @@ int TRI_InitPrimaryIndex (TRI_primary_index_t* idx,
|
||||||
idx->_nrAlloc = 0;
|
idx->_nrAlloc = 0;
|
||||||
idx->_nrUsed = 0;
|
idx->_nrUsed = 0;
|
||||||
|
|
||||||
TRI_InitReadWriteLock(&idx->_lock);
|
|
||||||
|
|
||||||
if (nullptr == (idx->_table = (void**) TRI_Allocate(zone, sizeof(void*) * INITIAL_SIZE, true))) {
|
if (nullptr == (idx->_table = (void**) TRI_Allocate(zone, sizeof(void*) * INITIAL_SIZE, true))) {
|
||||||
return TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -168,46 +167,12 @@ void TRI_DestroyPrimaryIndex (TRI_primary_index_t* idx) {
|
||||||
TRI_Free(idx->_memoryZone, idx->_table);
|
TRI_Free(idx->_memoryZone, idx->_table);
|
||||||
idx->_table = nullptr;
|
idx->_table = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_DestroyReadWriteLock(&idx->_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- public functions
|
// --SECTION-- public functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief write-locks the primary index
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_WriteLockPrimaryIndex (TRI_primary_index_t* idx) {
|
|
||||||
TRI_WriteLockReadWriteLock(&idx->_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief write-unlocks the primary index
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_WriteUnlockPrimaryIndex (TRI_primary_index_t* idx) {
|
|
||||||
TRI_WriteUnlockReadWriteLock(&idx->_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief read-locks the primary index
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_ReadLockPrimaryIndex (TRI_primary_index_t* idx) {
|
|
||||||
TRI_ReadLockReadWriteLock(&idx->_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief read-unlocks the primary index
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_ReadUnlockPrimaryIndex (TRI_primary_index_t* idx) {
|
|
||||||
TRI_ReadUnlockReadWriteLock(&idx->_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief looks up an element given a key
|
/// @brief looks up an element given a key
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -48,8 +48,6 @@ typedef struct TRI_primary_index_s {
|
||||||
|
|
||||||
void** _table; // the table itself
|
void** _table; // the table itself
|
||||||
|
|
||||||
TRI_read_write_lock_t _lock; // lock to protect the index
|
|
||||||
|
|
||||||
TRI_memory_zone_t* _memoryZone;
|
TRI_memory_zone_t* _memoryZone;
|
||||||
}
|
}
|
||||||
TRI_primary_index_t;
|
TRI_primary_index_t;
|
||||||
|
@ -75,30 +73,6 @@ void TRI_DestroyPrimaryIndex (TRI_primary_index_t*);
|
||||||
// --SECTION-- public functions
|
// --SECTION-- public functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief write-locks the primary index
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_WriteLockPrimaryIndex (TRI_primary_index_t*);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief write-unlocks the primary index
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_WriteUnlockPrimaryIndex (TRI_primary_index_t*);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief read-locks the primary index
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_ReadLockPrimaryIndex (TRI_primary_index_t*);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief read-unlocks the primary index
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_ReadUnlockPrimaryIndex (TRI_primary_index_t*);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief lookups an element given a key
|
/// @brief lookups an element given a key
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -568,13 +568,11 @@ int CollectorThread::transferMarkers (Logfile::IdType logfileId,
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookup the document in the primary index and update its master pointer
|
// lookup the document in the primary index and update its master pointer
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
TRI_doc_mptr_t* found = static_cast<TRI_doc_mptr_t*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
TRI_doc_mptr_t* found = static_cast<TRI_doc_mptr_t*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
||||||
|
|
||||||
if (found != nullptr) {
|
if (found != nullptr) {
|
||||||
found->_dataptr = static_cast<void*>(dst);
|
found->_dataptr = static_cast<void*>(dst);
|
||||||
}
|
}
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,13 +628,11 @@ int CollectorThread::transferMarkers (Logfile::IdType logfileId,
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookup the document in the primary index and update its master pointer
|
// lookup the document in the primary index and update its master pointer
|
||||||
TRI_ReadLockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
TRI_doc_mptr_t* found = static_cast<TRI_doc_mptr_t*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
TRI_doc_mptr_t* found = static_cast<TRI_doc_mptr_t*>(TRI_LookupByKeyPrimaryIndex(&document->_primaryIndex, key));
|
||||||
|
|
||||||
if (found != nullptr) {
|
if (found != nullptr) {
|
||||||
found->_dataptr = static_cast<void*>(dst);
|
found->_dataptr = static_cast<void*>(dst);
|
||||||
}
|
}
|
||||||
TRI_ReadUnlockPrimaryIndex(&document->_primaryIndex);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue