mirror of https://gitee.com/bigwinds/arangodb
fixed some indexes
This commit is contained in:
parent
05ddccd515
commit
3f22fa03be
|
@ -211,7 +211,7 @@ static void RemoveIndexCapConstraint (TRI_index_t* idx,
|
|||
|
||||
static int InsertCapConstraint (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
TRI_cap_constraint_t* cap = (TRI_cap_constraint_t*) idx;
|
||||
|
||||
if (cap->_size > 0) {
|
||||
|
@ -251,7 +251,7 @@ static int PostInsertCapConstraint (TRI_transaction_collection_t* trxCollection,
|
|||
|
||||
static int RemoveCapConstraint (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,6 @@
|
|||
// --SECTION-- private defines
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Fulltext
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief we'll set this bit (the highest of a uint32_t) if the list is sorted
|
||||
/// if the list is not sorted, this bit is cleared
|
||||
|
@ -53,19 +48,10 @@
|
|||
|
||||
#define GROWTH_FACTOR 1.2
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Fulltext
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief compare two entries in a list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -150,7 +136,7 @@ static inline void SetNumEntries (TRI_fulltext_list_t* const list,
|
|||
/// @brief return the number of allocated entries
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline uint32_t GetNumAllocated (const TRI_fulltext_list_t* const list) {
|
||||
static inline uint32_t GetNumAllocated (TRI_fulltext_list_t const* list) {
|
||||
uint32_t* head = (uint32_t*) list;
|
||||
|
||||
return (*head & ~SORTED_BIT);
|
||||
|
@ -160,7 +146,8 @@ static inline uint32_t GetNumAllocated (const TRI_fulltext_list_t* const list) {
|
|||
/// @brief initialise a new list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void InitList (TRI_fulltext_list_t* const list, const uint32_t size) {
|
||||
static void InitList (TRI_fulltext_list_t* list,
|
||||
uint32_t size) {
|
||||
uint32_t* head = (uint32_t*) list;
|
||||
|
||||
*(head++) = size;
|
||||
|
@ -171,15 +158,14 @@ static void InitList (TRI_fulltext_list_t* const list, const uint32_t size) {
|
|||
/// @brief sort a list in place
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void SortList (TRI_fulltext_list_t* const list) {
|
||||
uint32_t numEntries;
|
||||
|
||||
static void SortList (TRI_fulltext_list_t* list) {
|
||||
if (IsSorted(list)) {
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
numEntries = GetNumEntries(list);
|
||||
uint32_t numEntries = GetNumEntries(list);
|
||||
|
||||
if (numEntries > 1) {
|
||||
// only sort if more than one elements
|
||||
qsort(GetStart(list), numEntries, sizeof(TRI_fulltext_list_entry_t), &CompareEntries);
|
||||
|
@ -204,55 +190,40 @@ static inline size_t MemoryList (const uint32_t size) {
|
|||
|
||||
static TRI_fulltext_list_t* IncreaseList (TRI_fulltext_list_t* list,
|
||||
const uint32_t size) {
|
||||
TRI_fulltext_list_t* copy;
|
||||
TRI_fulltext_list_t* copy = TRI_Reallocate(TRI_UNKNOWN_MEM_ZONE, list, MemoryList(size));
|
||||
|
||||
copy = TRI_Reallocate(TRI_UNKNOWN_MEM_ZONE, list, MemoryList(size));
|
||||
if (copy == NULL) {
|
||||
// out of memory
|
||||
return NULL;
|
||||
if (copy != nullptr) {
|
||||
InitList(copy, size);
|
||||
}
|
||||
|
||||
InitList(copy, size);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors / destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Fulltext
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clone a list by copying an existing one
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_fulltext_list_t* TRI_CloneListFulltextIndex (const TRI_fulltext_list_t* const source) {
|
||||
TRI_fulltext_list_t* list;
|
||||
TRI_fulltext_list_t* TRI_CloneListFulltextIndex (TRI_fulltext_list_t const* source) {
|
||||
uint32_t numEntries;
|
||||
|
||||
if (source == NULL) {
|
||||
if (source == nullptr) {
|
||||
numEntries = 0;
|
||||
}
|
||||
else {
|
||||
numEntries = GetNumEntries(source);
|
||||
}
|
||||
|
||||
list = TRI_CreateListFulltextIndex(numEntries);
|
||||
if (list == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
TRI_fulltext_list_t* list = TRI_CreateListFulltextIndex(numEntries);
|
||||
|
||||
if (numEntries > 0) {
|
||||
memcpy(GetStart(list), GetStart(source), numEntries * sizeof(TRI_fulltext_list_entry_t));
|
||||
SetNumEntries(list, numEntries);
|
||||
if (list != nullptr) {
|
||||
if (numEntries > 0) {
|
||||
memcpy(GetStart(list), GetStart(source), numEntries * sizeof(TRI_fulltext_list_entry_t));
|
||||
SetNumEntries(list, numEntries);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -263,12 +234,11 @@ TRI_fulltext_list_t* TRI_CloneListFulltextIndex (const TRI_fulltext_list_t* cons
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_fulltext_list_t* TRI_CreateListFulltextIndex (const uint32_t size) {
|
||||
TRI_fulltext_list_t* list;
|
||||
TRI_fulltext_list_t* list = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, MemoryList(size), false);
|
||||
|
||||
list = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, MemoryList(size), false);
|
||||
if (list == NULL) {
|
||||
if (list == nullptr) {
|
||||
// out of memory
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
InitList(list, size);
|
||||
|
@ -284,27 +254,16 @@ void TRI_FreeListFulltextIndex (TRI_fulltext_list_t* list) {
|
|||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, list);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Fulltext
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the memory usage of a list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
size_t TRI_MemoryListFulltextIndex (const TRI_fulltext_list_t* const list) {
|
||||
uint32_t size;
|
||||
|
||||
size = GetNumAllocated(list);
|
||||
size_t TRI_MemoryListFulltextIndex (TRI_fulltext_list_t const* list) {
|
||||
uint32_t size = GetNumAllocated(list);
|
||||
return MemoryList(size);
|
||||
}
|
||||
|
||||
|
@ -643,8 +602,8 @@ TRI_fulltext_list_t* TRI_InsertListFulltextIndex (TRI_fulltext_list_t* list,
|
|||
/// the map is provided by the routines that handle the compaction
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32_t TRI_RewriteListFulltextIndex (TRI_fulltext_list_t* const list,
|
||||
const void* const data) {
|
||||
uint32_t TRI_RewriteListFulltextIndex (TRI_fulltext_list_t* list,
|
||||
void const* data) {
|
||||
TRI_fulltext_list_entry_t* listEntries;
|
||||
TRI_fulltext_list_entry_t* map;
|
||||
uint32_t numEntries;
|
||||
|
@ -689,7 +648,7 @@ uint32_t TRI_RewriteListFulltextIndex (TRI_fulltext_list_t* const list,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if TRI_FULLTEXT_DEBUG
|
||||
void TRI_DumpListFulltextIndex (const TRI_fulltext_list_t* const list) {
|
||||
void TRI_DumpListFulltextIndex (TRI_fulltext_list_t const* list) {
|
||||
TRI_fulltext_list_entry_t* listEntries;
|
||||
uint32_t numEntries;
|
||||
uint32_t i;
|
||||
|
@ -718,7 +677,7 @@ void TRI_DumpListFulltextIndex (const TRI_fulltext_list_t* const list) {
|
|||
/// @brief return the number of entries
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32_t TRI_NumEntriesListFulltextIndex (const TRI_fulltext_list_t* const list) {
|
||||
uint32_t TRI_NumEntriesListFulltextIndex (TRI_fulltext_list_t const* list) {
|
||||
return GetNumEntries(list);
|
||||
}
|
||||
|
||||
|
@ -726,14 +685,10 @@ uint32_t TRI_NumEntriesListFulltextIndex (const TRI_fulltext_list_t* const list)
|
|||
/// @brief return a pointer to the first list entry
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_fulltext_list_entry_t* TRI_StartListFulltextIndex (const TRI_fulltext_list_t* const list) {
|
||||
TRI_fulltext_list_entry_t* TRI_StartListFulltextIndex (TRI_fulltext_list_t const* list) {
|
||||
return GetStart(list);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Fulltext
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief typedef for a fulltext list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -51,30 +46,21 @@ typedef void TRI_fulltext_list_t;
|
|||
|
||||
typedef uint32_t TRI_fulltext_list_entry_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors / destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Fulltext
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clone a list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_fulltext_list_t* TRI_CloneListFulltextIndex (const TRI_fulltext_list_t* const);
|
||||
TRI_fulltext_list_t* TRI_CloneListFulltextIndex (TRI_fulltext_list_t const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_fulltext_list_t* TRI_CreateListFulltextIndex (const uint32_t);
|
||||
TRI_fulltext_list_t* TRI_CreateListFulltextIndex (uint32_t);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief free a list
|
||||
|
@ -82,24 +68,15 @@ TRI_fulltext_list_t* TRI_CreateListFulltextIndex (const uint32_t);
|
|||
|
||||
void TRI_FreeListFulltextIndex (TRI_fulltext_list_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Fulltext
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the memory usage of a list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
size_t TRI_MemoryListFulltextIndex (const TRI_fulltext_list_t* const);
|
||||
size_t TRI_MemoryListFulltextIndex (TRI_fulltext_list_t const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief unionise two lists
|
||||
|
@ -138,32 +115,28 @@ TRI_fulltext_list_t* TRI_InsertListFulltextIndex (TRI_fulltext_list_t*,
|
|||
/// returns the number of entries remaining in the list after rewrite
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32_t TRI_RewriteListFulltextIndex (TRI_fulltext_list_t* const,
|
||||
const void* const);
|
||||
uint32_t TRI_RewriteListFulltextIndex (TRI_fulltext_list_t*,
|
||||
void const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief dump a list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if TRI_FULLTEXT_DEBUG
|
||||
void TRI_DumpListFulltextIndex (const TRI_fulltext_list_t* const);
|
||||
void TRI_DumpListFulltextIndex (TRI_fulltext_list_t const*);
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return the number of entries
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32_t TRI_NumEntriesListFulltextIndex (const TRI_fulltext_list_t* const);
|
||||
uint32_t TRI_NumEntriesListFulltextIndex (TRI_fulltext_list_t const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return a pointer to the first list entry
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_fulltext_list_entry_t* TRI_StartListFulltextIndex (const TRI_fulltext_list_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
TRI_fulltext_list_entry_t* TRI_StartListFulltextIndex (TRI_fulltext_list_t const*);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ static TRI_json_t* JsonGeo2Index (TRI_index_t const* idx) {
|
|||
|
||||
static int InsertGeoIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
GeoCoordinate gc;
|
||||
TRI_shaped_json_t shapedJson;
|
||||
TRI_geo_index_t* geo;
|
||||
|
@ -417,7 +417,7 @@ static int InsertGeoIndex (TRI_index_t* idx,
|
|||
|
||||
static int RemoveGeoIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
GeoCoordinate gc;
|
||||
TRI_shaped_json_t shapedJson;
|
||||
TRI_geo_index_t* geo;
|
||||
|
|
|
@ -37,24 +37,13 @@
|
|||
// --SECTION-- COMPARISON
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup HashArray
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns true if an element is 'empty'
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool IsEmptyElement (TRI_hash_array_t* array,
|
||||
TRI_hash_index_element_t* element) {
|
||||
if (element != NULL) {
|
||||
if (element->_document == NULL) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
static inline bool IsEmptyElement (TRI_hash_array_t* array,
|
||||
TRI_hash_index_element_t* element) {
|
||||
return (element != nullptr && element->_document == nullptr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -63,8 +52,8 @@ static bool IsEmptyElement (TRI_hash_array_t* array,
|
|||
|
||||
static void ClearElement (TRI_hash_array_t* array,
|
||||
TRI_hash_index_element_t* element) {
|
||||
if (element != NULL) {
|
||||
element->_document = NULL;
|
||||
if (element != nullptr) {
|
||||
element->_document = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,8 +63,8 @@ static void ClearElement (TRI_hash_array_t* array,
|
|||
|
||||
static void DestroyElement (TRI_hash_array_t* array,
|
||||
TRI_hash_index_element_t* element) {
|
||||
if (element != NULL) {
|
||||
if (element->_document != NULL) {
|
||||
if (element != nullptr) {
|
||||
if (element->_document != nullptr) {
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, element->_subObjects);
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +81,7 @@ static void DestroyElement (TRI_hash_array_t* array,
|
|||
static bool IsEqualElementElement (TRI_hash_array_t* array,
|
||||
TRI_hash_index_element_t* left,
|
||||
TRI_hash_index_element_t* right) {
|
||||
if (left->_document == NULL || right->_document == NULL) {
|
||||
if (left->_document == nullptr || right->_document == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -106,13 +95,11 @@ static bool IsEqualElementElement (TRI_hash_array_t* array,
|
|||
static bool IsEqualKeyElement (TRI_hash_array_t* array,
|
||||
TRI_index_search_value_t* left,
|
||||
TRI_hash_index_element_t* right) {
|
||||
size_t j;
|
||||
|
||||
if (right->_document == NULL) {
|
||||
if (right->_document == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (j = 0; j < array->_numFields; ++j) {
|
||||
for (size_t j = 0; j < array->_numFields; ++j) {
|
||||
TRI_shaped_json_t* leftJson = &left->_values[j];
|
||||
TRI_shaped_sub_t* rightSub = &right->_subObjects[j];
|
||||
size_t length;
|
||||
|
@ -128,7 +115,7 @@ static bool IsEqualKeyElement (TRI_hash_array_t* array,
|
|||
}
|
||||
|
||||
if (0 < length) {
|
||||
char* ptr = ((char*) right->_document->getDataPtr()) + rightSub->_offset; // ONLY IN INDEX
|
||||
char const* ptr = right->_document->getShapedJsonPtr() + rightSub->_offset; // ONLY IN INDEX
|
||||
|
||||
if (memcmp(leftJson->_data.data, ptr, length) != 0) {
|
||||
return false;
|
||||
|
@ -146,13 +133,13 @@ static bool IsEqualKeyElement (TRI_hash_array_t* array,
|
|||
static uint64_t HashKey (TRI_hash_array_t* array,
|
||||
TRI_index_search_value_t* key) {
|
||||
uint64_t hash = TRI_FnvHashBlockInitial();
|
||||
size_t j;
|
||||
|
||||
for (j = 0; j < array->_numFields; ++j) {
|
||||
for (size_t j = 0; j < array->_numFields; ++j) {
|
||||
|
||||
// ignore the sid for hashing
|
||||
hash = TRI_FnvHashBlock(hash, key->_values[j]._data.data, key->_values[j]._data.length);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
@ -166,7 +153,7 @@ static uint64_t HashElement (TRI_hash_array_t* array,
|
|||
|
||||
for (size_t j = 0; j < array->_numFields; j++) {
|
||||
// ignore the sid for hashing
|
||||
char* ptr = ((char*) element->_document->getDataPtr()) + element->_subObjects[j]._offset; // ONLY IN INDEX
|
||||
char const* ptr = element->_document->getShapedJsonPtr() + element->_subObjects[j]._offset; // ONLY IN INDEX
|
||||
|
||||
// only hash the data block
|
||||
hash = TRI_FnvHashBlock(hash, ptr, element->_subObjects[j]._length);
|
||||
|
@ -175,10 +162,6 @@ static uint64_t HashElement (TRI_hash_array_t* array,
|
|||
return hash;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- HASH ARRAY
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -187,11 +170,6 @@ static uint64_t HashElement (TRI_hash_array_t* array,
|
|||
// --SECTION-- private defines
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup HashArray
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initial preallocation size of the hash table when the table is
|
||||
/// first created
|
||||
|
@ -201,24 +179,15 @@ static uint64_t HashElement (TRI_hash_array_t* array,
|
|||
|
||||
#define INITIAL_SIZE (251)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup HashArray
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return the size of a single entry
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline size_t TableEntrySize (TRI_hash_array_t const* array) {
|
||||
constexpr size_t TableEntrySize () {
|
||||
return sizeof(TRI_hash_index_element_t);
|
||||
}
|
||||
|
||||
|
@ -252,7 +221,7 @@ static void AddElement (TRI_hash_array_t* array,
|
|||
// memcpy ok here since are simply moving array items internally
|
||||
// ...........................................................................
|
||||
|
||||
memcpy(&array->_table[i], element, TableEntrySize(array));
|
||||
memcpy(&array->_table[i], element, TableEntrySize());
|
||||
array->_nrUsed++;
|
||||
}
|
||||
|
||||
|
@ -264,11 +233,11 @@ static void AddElement (TRI_hash_array_t* array,
|
|||
|
||||
static int AllocateTable (TRI_hash_array_t* array,
|
||||
size_t numElements) {
|
||||
size_t const size = TableEntrySize(array) * numElements;
|
||||
size_t const size = TableEntrySize() * numElements;
|
||||
|
||||
TRI_hash_index_element_t* table = static_cast<TRI_hash_index_element_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, size, true));
|
||||
|
||||
if (table == NULL) {
|
||||
if (table == nullptr) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -311,19 +280,10 @@ static int ResizeHashArray (TRI_hash_array_t* array,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup HashArray
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initialises an array
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -340,7 +300,7 @@ int TRI_InitHashArray (TRI_hash_array_t* array,
|
|||
TRI_ASSERT(numFields > 0);
|
||||
|
||||
array->_numFields = numFields;
|
||||
array->_table = NULL;
|
||||
array->_table = nullptr;
|
||||
array->_nrUsed = 0;
|
||||
array->_nrAlloc = 0;
|
||||
|
||||
|
@ -366,7 +326,7 @@ int TRI_InitHashArray (TRI_hash_array_t* array,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_DestroyHashArray (TRI_hash_array_t* array) {
|
||||
if (array == NULL) {
|
||||
if (array == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -375,7 +335,7 @@ void TRI_DestroyHashArray (TRI_hash_array_t* array) {
|
|||
// ...........................................................................
|
||||
|
||||
// array->_table might be NULL if array initialisation fails
|
||||
if (array->_table != NULL) {
|
||||
if (array->_table != nullptr) {
|
||||
TRI_hash_index_element_t* p;
|
||||
TRI_hash_index_element_t* e;
|
||||
|
||||
|
@ -395,35 +355,26 @@ void TRI_DestroyHashArray (TRI_hash_array_t* array) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeHashArray (TRI_hash_array_t* array) {
|
||||
if (array != NULL) {
|
||||
if (array != nullptr) {
|
||||
TRI_DestroyHashArray(array);
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, array);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Collections
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the hash array's memory usage
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
size_t TRI_MemoryUsageHashArray (TRI_hash_array_t const* array) {
|
||||
if (array == NULL) {
|
||||
if (array == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (size_t) (array->_nrAlloc * TableEntrySize(array));
|
||||
return (size_t) (array->_nrAlloc * TableEntrySize());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -473,15 +424,13 @@ TRI_hash_index_element_t* TRI_LookupByKeyHashArray (TRI_hash_array_t* array,
|
|||
|
||||
TRI_hash_index_element_t* TRI_FindByKeyHashArray (TRI_hash_array_t* array,
|
||||
TRI_index_search_value_t* key) {
|
||||
TRI_hash_index_element_t* element;
|
||||
|
||||
element = TRI_LookupByKeyHashArray(array, key);
|
||||
TRI_hash_index_element_t* element = TRI_LookupByKeyHashArray(array, key);
|
||||
|
||||
if (! IsEmptyElement(array, element) && IsEqualKeyElement(array, key, element)) {
|
||||
return element;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -530,7 +479,7 @@ TRI_hash_index_element_t* TRI_FindByElementHashArray (TRI_hash_array_t* array,
|
|||
return element2;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -825,10 +774,6 @@ int TRI_RemoveKeyHashArray (TRI_hash_array_t* array,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- HASH ARRAY MULTI
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -837,11 +782,6 @@ int TRI_RemoveKeyHashArray (TRI_hash_array_t* array,
|
|||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup HashArray
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief lookups an element given a key
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1206,10 +1146,6 @@ int TRI_RemoveKeyHashArrayMulti (TRI_hash_array_t* array,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
/// @brief return the number of paths of the index
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline size_t NumPaths (TRI_hash_index_t const* idx) {
|
||||
constexpr size_t NumPaths (TRI_hash_index_t const* idx) {
|
||||
return idx->_paths._length;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ static inline size_t NumPaths (TRI_hash_index_t const* idx) {
|
|||
/// @brief returns the memory needed for an index key entry
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline size_t KeyEntrySize (TRI_hash_index_t const* idx) {
|
||||
constexpr size_t KeyEntrySize (TRI_hash_index_t const* idx) {
|
||||
return NumPaths(idx) * sizeof(TRI_shaped_json_t);
|
||||
}
|
||||
|
||||
|
@ -63,17 +63,17 @@ static int FillIndexSearchValueByHashIndexElement (TRI_hash_index_t* hashIndex,
|
|||
TRI_hash_index_element_t* element) {
|
||||
key->_values = static_cast<TRI_shaped_json_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, KeyEntrySize(hashIndex), false));
|
||||
|
||||
if (key->_values == NULL) {
|
||||
if (key->_values == nullptr) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
char const* ptr = static_cast<char const*>(element->_document->getDataPtr()); // ONLY IN INDEX
|
||||
|
||||
char const* ptr = element->_document->getShapedJsonPtr(); // ONLY IN INDEX
|
||||
size_t const n = NumPaths(hashIndex);
|
||||
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
key->_values[i]._sid = element->_subObjects[i]._sid;
|
||||
key->_values[i]._sid = element->_subObjects[i]._sid;
|
||||
key->_values[i]._data.length = (uint32_t) element->_subObjects[i]._length;
|
||||
key->_values[i]._data.data = const_cast<char*>(ptr + element->_subObjects[i]._offset);
|
||||
key->_values[i]._data.data = const_cast<char*>(ptr + element->_subObjects[i]._offset);
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
|
@ -90,7 +90,7 @@ static int AllocateSubObjectsHashIndexElement (TRI_hash_index_t const* idx,
|
|||
|
||||
element->_subObjects = static_cast<TRI_shaped_sub_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, *elementSize, false));
|
||||
|
||||
if (element->_subObjects == NULL) {
|
||||
if (element->_subObjects == nullptr) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ static int AllocateSubObjectsHashIndexElement (TRI_hash_index_t const* idx,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void FreeSubObjectsHashIndexElement (TRI_hash_index_element_t* element) {
|
||||
if (element->_subObjects != NULL) {
|
||||
if (element->_subObjects != nullptr) {
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, element->_subObjects);
|
||||
}
|
||||
}
|
||||
|
@ -134,6 +134,7 @@ static int HashIndexHelper (TRI_hash_index_t const* hashIndex,
|
|||
TRI_EXTRACT_SHAPED_JSON_MARKER(shapedJson, document->getDataPtr()); // ONLY IN INDEX
|
||||
|
||||
hashElement->_document = const_cast<TRI_doc_mptr_t*>(document);
|
||||
char const* ptr = document->getShapedJsonPtr(); // ONLY IN INDEX
|
||||
|
||||
// .............................................................................
|
||||
// Extract the attribute values
|
||||
|
@ -145,10 +146,10 @@ static int HashIndexHelper (TRI_hash_index_t const* hashIndex,
|
|||
TRI_shape_pid_t path = *((TRI_shape_pid_t*)(TRI_AtVector(&hashIndex->_paths, j)));
|
||||
|
||||
// determine if document has that particular shape
|
||||
TRI_shape_access_t const*acc = TRI_FindAccessorVocShaper(shaper, shapedJson._sid, path);
|
||||
TRI_shape_access_t const* acc = TRI_FindAccessorVocShaper(shaper, shapedJson._sid, path);
|
||||
|
||||
// field not part of the object
|
||||
if (acc == NULL || acc->_resultSid == 0) {
|
||||
if (acc == nullptr || acc->_resultSid == TRI_SHAPE_ILLEGAL) {
|
||||
shapedSub._sid = TRI_LookupBasicSidShaper(TRI_SHAPE_NULL);
|
||||
shapedSub._length = 0;
|
||||
shapedSub._offset = 0;
|
||||
|
@ -169,7 +170,7 @@ static int HashIndexHelper (TRI_hash_index_t const* hashIndex,
|
|||
|
||||
shapedSub._sid = shapedObject._sid;
|
||||
shapedSub._length = shapedObject._data.length;
|
||||
shapedSub._offset = ((char const*) shapedObject._data.data) - ((char const*) document->getDataPtr()); // ONLY IN INDEX
|
||||
shapedSub._offset = ((char const*) shapedObject._data.data) - ptr;
|
||||
}
|
||||
|
||||
// store the json shaped sub-object -- this is what will be hashed
|
||||
|
@ -241,9 +242,7 @@ static int HashIndex_insert (TRI_hash_index_t* hashIndex,
|
|||
TRI_hash_index_element_t* element,
|
||||
size_t elementSize) {
|
||||
TRI_index_search_value_t key;
|
||||
int res;
|
||||
|
||||
res = FillIndexSearchValueByHashIndexElement(hashIndex, &key, element);
|
||||
int res = FillIndexSearchValueByHashIndexElement(hashIndex, &key, element);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// out of memory
|
||||
|
@ -252,7 +251,7 @@ static int HashIndex_insert (TRI_hash_index_t* hashIndex,
|
|||
|
||||
res = TRI_InsertKeyHashArray(&hashIndex->_hashArray, &key, element, false);
|
||||
|
||||
if (key._values != NULL) {
|
||||
if (key._values != nullptr) {
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, key._values);
|
||||
}
|
||||
|
||||
|
@ -272,9 +271,7 @@ static int HashIndex_insert (TRI_hash_index_t* hashIndex,
|
|||
static int HashIndex_remove (TRI_hash_index_t* hashIndex,
|
||||
TRI_hash_index_element_t* element,
|
||||
size_t elementSize) {
|
||||
int res;
|
||||
|
||||
res = TRI_RemoveElementHashArray(&hashIndex->_hashArray, element);
|
||||
int res = TRI_RemoveElementHashArray(&hashIndex->_hashArray, element);
|
||||
|
||||
// this might happen when rolling back
|
||||
if (res == TRI_RESULT_ELEMENT_NOT_FOUND) {
|
||||
|
@ -304,13 +301,13 @@ static TRI_index_result_t HashIndex_find (TRI_hash_index_t* hashIndex,
|
|||
|
||||
result = TRI_FindByKeyHashArray(&hashIndex->_hashArray, key);
|
||||
|
||||
if (result != NULL) {
|
||||
if (result != nullptr) {
|
||||
|
||||
// unique hash index: maximum number is 1
|
||||
results._length = 1;
|
||||
results._documents = static_cast<TRI_doc_mptr_t**>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, 1 * sizeof(TRI_doc_mptr_t*), false));
|
||||
|
||||
if (results._documents == NULL) {
|
||||
if (results._documents == nullptr) {
|
||||
// no memory. prevent worst case by re-setting results length to 0
|
||||
results._length = 0;
|
||||
return results;
|
||||
|
@ -320,7 +317,7 @@ static TRI_index_result_t HashIndex_find (TRI_hash_index_t* hashIndex,
|
|||
}
|
||||
else {
|
||||
results._length = 0;
|
||||
results._documents = NULL;
|
||||
results._documents = nullptr;
|
||||
}
|
||||
|
||||
return results;
|
||||
|
@ -340,9 +337,7 @@ static TRI_index_result_t HashIndex_find (TRI_hash_index_t* hashIndex,
|
|||
static int MultiHashIndex_insert (TRI_hash_index_t* hashIndex,
|
||||
TRI_hash_index_element_t* element,
|
||||
size_t elementSize) {
|
||||
int res;
|
||||
|
||||
res = TRI_InsertElementHashArrayMulti(&hashIndex->_hashArray, element, false);
|
||||
int res = TRI_InsertElementHashArrayMulti(&hashIndex->_hashArray, element, false);
|
||||
|
||||
if (res == TRI_RESULT_ELEMENT_EXISTS) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
|
@ -362,9 +357,7 @@ static int MultiHashIndex_insert (TRI_hash_index_t* hashIndex,
|
|||
int MultiHashIndex_remove (TRI_hash_index_t* hashIndex,
|
||||
TRI_hash_index_element_t* element,
|
||||
size_t elementSize) {
|
||||
int res;
|
||||
|
||||
res = TRI_RemoveElementHashArrayMulti(&hashIndex->_hashArray, element);
|
||||
int res = TRI_RemoveElementHashArrayMulti(&hashIndex->_hashArray, element);
|
||||
|
||||
if (res == TRI_RESULT_ELEMENT_NOT_FOUND) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
|
@ -395,7 +388,7 @@ static TRI_index_result_t MultiHashIndex_find (TRI_hash_index_t* hashIndex,
|
|||
|
||||
if (result._length == 0) {
|
||||
results._length = 0;
|
||||
results._documents = NULL;
|
||||
results._documents = nullptr;
|
||||
}
|
||||
else {
|
||||
size_t j;
|
||||
|
@ -403,7 +396,7 @@ static TRI_index_result_t MultiHashIndex_find (TRI_hash_index_t* hashIndex,
|
|||
results._length = result._length;
|
||||
results._documents = static_cast<TRI_doc_mptr_t**>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, result._length* sizeof(TRI_doc_mptr_t*), false));
|
||||
|
||||
if (results._documents == NULL) {
|
||||
if (results._documents == nullptr) {
|
||||
// no memory. prevent worst case by re-setting results length to 0
|
||||
TRI_DestroyVectorPointer(&result);
|
||||
results._length = 0;
|
||||
|
@ -443,11 +436,6 @@ size_t MemoryHashIndex (TRI_index_t const* idx) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static TRI_json_t* JsonHashIndex (TRI_index_t const* idx) {
|
||||
TRI_json_t* json;
|
||||
TRI_json_t* fields;
|
||||
char const** fieldList;
|
||||
size_t j;
|
||||
|
||||
// .............................................................................
|
||||
// Recast as a hash index
|
||||
// .............................................................................
|
||||
|
@ -459,26 +447,28 @@ static TRI_json_t* JsonHashIndex (TRI_index_t const* idx) {
|
|||
// Allocate sufficent memory for the field list
|
||||
// .............................................................................
|
||||
|
||||
fieldList = TRI_FieldListByPathList(document->_shaper, &hashIndex->_paths);
|
||||
char const** fieldList = TRI_FieldListByPathList(document->_shaper, &hashIndex->_paths);
|
||||
|
||||
if (fieldList == NULL) {
|
||||
return NULL;
|
||||
if (fieldList == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ..........................................................................
|
||||
// create json object and fill it
|
||||
// ..........................................................................
|
||||
|
||||
json = TRI_JsonIndex(TRI_CORE_MEM_ZONE, idx);
|
||||
TRI_json_t* json = TRI_JsonIndex(TRI_CORE_MEM_ZONE, idx);
|
||||
|
||||
if (json == NULL) {
|
||||
return NULL;
|
||||
if (json == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
fields = TRI_CreateListJson(TRI_CORE_MEM_ZONE);
|
||||
for (j = 0; j < hashIndex->_paths._length; ++j) {
|
||||
TRI_json_t* fields = TRI_CreateListJson(TRI_CORE_MEM_ZONE);
|
||||
|
||||
for (size_t j = 0; j < hashIndex->_paths._length; ++j) {
|
||||
TRI_PushBack3ListJson(TRI_CORE_MEM_ZONE, fields, TRI_CreateStringCopyJson(TRI_CORE_MEM_ZONE, fieldList[j]));
|
||||
}
|
||||
|
||||
TRI_Insert3ArrayJson(TRI_CORE_MEM_ZONE, json, "fields", fields);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, (void*) fieldList);
|
||||
|
||||
|
@ -491,15 +481,12 @@ static TRI_json_t* JsonHashIndex (TRI_index_t const* idx) {
|
|||
|
||||
static int InsertHashIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* document,
|
||||
const bool isRollback) {
|
||||
TRI_hash_index_element_t hashElement;
|
||||
TRI_hash_index_t* hashIndex;
|
||||
bool isRollback) {
|
||||
TRI_hash_index_t* hashIndex = (TRI_hash_index_t*) idx;
|
||||
|
||||
size_t elementSize;
|
||||
int res;
|
||||
|
||||
hashIndex = (TRI_hash_index_t*) idx;
|
||||
|
||||
res = HashIndexHelperAllocate(hashIndex, &hashElement, document, &elementSize);
|
||||
TRI_hash_index_element_t hashElement;
|
||||
int res = HashIndexHelperAllocate(hashIndex, &hashElement, document, &elementSize);
|
||||
|
||||
if (res == TRI_ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING) {
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
|
@ -525,15 +512,12 @@ static int InsertHashIndex (TRI_index_t* idx,
|
|||
|
||||
static int RemoveHashIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* document,
|
||||
const bool isRollback) {
|
||||
TRI_hash_index_element_t hashElement;
|
||||
TRI_hash_index_t* hashIndex;
|
||||
bool isRollback) {
|
||||
TRI_hash_index_t* hashIndex = (TRI_hash_index_t*) idx;
|
||||
|
||||
size_t elementSize;
|
||||
int res;
|
||||
|
||||
hashIndex = (TRI_hash_index_t*) idx;
|
||||
|
||||
res = HashIndexHelperAllocate(hashIndex, &hashElement, document, &elementSize);
|
||||
TRI_hash_index_element_t hashElement;
|
||||
int res = HashIndexHelperAllocate(hashIndex, &hashElement, document, &elementSize);
|
||||
|
||||
if (res == TRI_ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING) {
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
|
@ -560,9 +544,7 @@ static int RemoveHashIndex (TRI_index_t* idx,
|
|||
|
||||
static int SizeHintHashIndex (TRI_index_t* idx,
|
||||
size_t size) {
|
||||
TRI_hash_index_t* hashIndex;
|
||||
|
||||
hashIndex = (TRI_hash_index_t*) idx;
|
||||
TRI_hash_index_t* hashIndex = (TRI_hash_index_t*) idx;
|
||||
TRI_ResizeHashArray(&hashIndex->_hashArray, size);
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
|
@ -616,16 +598,16 @@ TRI_index_t* TRI_CreateHashIndex (TRI_document_collection_t* document,
|
|||
TRI_DestroyVector(&hashIndex->_paths);
|
||||
TRI_DestroyVectorString(&idx->_fields);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, hashIndex);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
// Assign the function calls used by the query engine
|
||||
// ...........................................................................
|
||||
|
||||
idx->indexQuery = NULL;
|
||||
idx->indexQueryFree = NULL;
|
||||
idx->indexQueryResult = NULL;
|
||||
idx->indexQuery = nullptr;
|
||||
idx->indexQueryFree = nullptr;
|
||||
idx->indexQueryResult = nullptr;
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
|
|
@ -68,15 +68,14 @@ static int CompareKeyElement (TRI_shaped_json_t const* left,
|
|||
TRI_shaper_t* shaper) {
|
||||
int result;
|
||||
|
||||
TRI_ASSERT(NULL != left);
|
||||
TRI_ASSERT(NULL != right);
|
||||
result = TRI_CompareShapeTypes(NULL,
|
||||
NULL,
|
||||
TRI_ASSERT(nullptr != left);
|
||||
TRI_ASSERT(nullptr != right);
|
||||
result = TRI_CompareShapeTypes(nullptr,
|
||||
nullptr,
|
||||
left,
|
||||
right->_document,
|
||||
&right->_subObjects[rightPosition],
|
||||
NULL,
|
||||
shaper,
|
||||
nullptr,
|
||||
shaper);
|
||||
|
||||
// ...........................................................................
|
||||
|
@ -105,18 +104,16 @@ static int CompareElementElement (TRI_skiplist_index_element_t* left,
|
|||
TRI_skiplist_index_element_t* right,
|
||||
size_t rightPosition,
|
||||
TRI_shaper_t* shaper) {
|
||||
int result;
|
||||
TRI_ASSERT(nullptr != left);
|
||||
TRI_ASSERT(nullptr != right);
|
||||
|
||||
TRI_ASSERT(NULL != left);
|
||||
TRI_ASSERT(NULL != right);
|
||||
result = TRI_CompareShapeTypes(left->_document,
|
||||
&left->_subObjects[leftPosition],
|
||||
NULL,
|
||||
right->_document,
|
||||
&right->_subObjects[rightPosition],
|
||||
NULL,
|
||||
shaper,
|
||||
shaper);
|
||||
int result = TRI_CompareShapeTypes(left->_document,
|
||||
&left->_subObjects[leftPosition],
|
||||
nullptr,
|
||||
right->_document,
|
||||
&right->_subObjects[rightPosition],
|
||||
nullptr,
|
||||
shaper);
|
||||
|
||||
// ...........................................................................
|
||||
// In the above function CompareShapeTypes we use strcmp which may
|
||||
|
@ -126,13 +123,13 @@ static int CompareElementElement (TRI_skiplist_index_element_t* left,
|
|||
// ...........................................................................
|
||||
|
||||
if (result < 0) {
|
||||
result = -1;
|
||||
return -1;
|
||||
}
|
||||
else if (result > 0) {
|
||||
result = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -146,29 +143,25 @@ static int CmpElmElm (void* sli,
|
|||
|
||||
TRI_skiplist_index_element_t* leftElement = static_cast<TRI_skiplist_index_element_t*>(left);
|
||||
TRI_skiplist_index_element_t* rightElement = static_cast<TRI_skiplist_index_element_t*>(right);
|
||||
int compareResult;
|
||||
TRI_shaper_t* shaper;
|
||||
size_t j;
|
||||
|
||||
TRI_ASSERT(NULL != left);
|
||||
TRI_ASSERT(NULL != right);
|
||||
|
||||
if (leftElement == rightElement) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TRI_ASSERT(nullptr != left);
|
||||
TRI_ASSERT(nullptr != right);
|
||||
|
||||
// ..........................................................................
|
||||
// The document could be the same -- so no further comparison is required.
|
||||
// ..........................................................................
|
||||
|
||||
if (leftElement->_document == rightElement->_document) {
|
||||
if (leftElement == rightElement ||
|
||||
leftElement->_document == rightElement->_document) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
SkiplistIndex* skiplistindex = static_cast<SkiplistIndex*>(sli);
|
||||
shaper = skiplistindex->_collection->_shaper;
|
||||
int compareResult;
|
||||
|
||||
for (j = 0; j < skiplistindex->_numFields; j++) {
|
||||
for (size_t j = 0; j < skiplistindex->_numFields; j++) {
|
||||
compareResult = CompareElementElement(leftElement,
|
||||
j,
|
||||
rightElement,
|
||||
|
@ -197,10 +190,10 @@ static int CmpElmElm (void* sli,
|
|||
TRI_EXTRACT_MARKER_KEY(rightElement->_document)); // ONLY IN INDEX
|
||||
|
||||
if (compareResult < 0) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
else if (compareResult > 0) {
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -215,10 +208,9 @@ static int CmpKeyElm (void* sli,
|
|||
TRI_skiplist_index_key_t* leftKey = static_cast<TRI_skiplist_index_key_t*>(left);
|
||||
TRI_skiplist_index_element_t* rightElement = static_cast<TRI_skiplist_index_element_t*>(right);
|
||||
TRI_shaper_t* shaper;
|
||||
size_t j;
|
||||
|
||||
TRI_ASSERT(NULL != left);
|
||||
TRI_ASSERT(NULL != right);
|
||||
TRI_ASSERT(nullptr != left);
|
||||
TRI_ASSERT(nullptr != right);
|
||||
|
||||
SkiplistIndex* skiplistindex = static_cast<SkiplistIndex*>(sli);
|
||||
shaper = skiplistindex->_collection->_shaper;
|
||||
|
@ -226,7 +218,7 @@ static int CmpKeyElm (void* sli,
|
|||
// Note that the key might contain fewer fields than there are indexed
|
||||
// attributes, therefore we only run the following loop to
|
||||
// leftKey->_numFields.
|
||||
for (j = 0; j < leftKey->_numFields; j++) {
|
||||
for (size_t j = 0; j < leftKey->_numFields; j++) {
|
||||
int compareResult = CompareKeyElement(&leftKey->_fields[j], rightElement, j, shaper);
|
||||
|
||||
if (compareResult != 0) {
|
||||
|
@ -250,12 +242,12 @@ static void FreeElm (void* e) {
|
|||
static int CopyElement (SkiplistIndex* skiplistindex,
|
||||
TRI_skiplist_index_element_t* leftElement,
|
||||
TRI_skiplist_index_element_t* rightElement) {
|
||||
TRI_ASSERT(NULL != leftElement && NULL != rightElement);
|
||||
TRI_ASSERT(nullptr != leftElement && nullptr != rightElement);
|
||||
|
||||
leftElement->_document = rightElement->_document;
|
||||
leftElement->_subObjects = static_cast<TRI_shaped_sub_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_shaped_sub_t) * skiplistindex->_numFields, false));
|
||||
|
||||
if (leftElement->_subObjects == NULL) {
|
||||
if (leftElement->_subObjects == nullptr) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -265,7 +257,6 @@ static int CopyElement (SkiplistIndex* skiplistindex,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Some static helper functions:
|
||||
// These are assigned to some callback hooks but do not seem to be used,
|
||||
|
@ -373,9 +364,9 @@ static TRI_skiplist_index_element_t* SkiplistIteration(
|
|||
// Some simple checks.
|
||||
// ...........................................................................
|
||||
|
||||
TRI_ASSERT(NULL != iterator);
|
||||
TRI_ASSERT(nullptr != iterator);
|
||||
|
||||
if (NULL == iterator->_cursor) {
|
||||
if (nullptr == iterator->_cursor) {
|
||||
// In this case the iterator is exhausted or does not even have intervals.
|
||||
return NULL;
|
||||
}
|
||||
|
@ -400,8 +391,8 @@ static TRI_skiplist_index_element_t* SkiplistIteration(
|
|||
break; // we found a next one
|
||||
}
|
||||
if (iterator->_currentInterval == (iterator->_intervals._length - 1)) {
|
||||
iterator->_cursor = NULL; // exhausted
|
||||
return NULL;
|
||||
iterator->_cursor = nullptr; // exhausted
|
||||
return nullptr;
|
||||
}
|
||||
++iterator->_currentInterval;
|
||||
interval = (TRI_skiplist_iterator_interval_t*)
|
||||
|
@ -419,7 +410,7 @@ static TRI_skiplist_index_element_t* SkiplistIteration(
|
|||
|
||||
static TRI_skiplist_index_element_t* SkiplistNextIterationCallback(
|
||||
TRI_skiplist_iterator_t* iterator) {
|
||||
return SkiplistIteration(iterator,1);
|
||||
return SkiplistIteration(iterator, 1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -478,8 +469,8 @@ int SkiplistIndex_assignMethod (void* methodHandle,
|
|||
/// @brief Free a skiplist iterator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeSkiplistIterator (TRI_skiplist_iterator_t* const iterator) {
|
||||
TRI_ASSERT(NULL != iterator);
|
||||
void TRI_FreeSkiplistIterator (TRI_skiplist_iterator_t* iterator) {
|
||||
TRI_ASSERT(nullptr != iterator);
|
||||
|
||||
TRI_DestroyVector(&iterator->_intervals);
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, iterator);
|
||||
|
@ -490,12 +481,12 @@ void TRI_FreeSkiplistIterator (TRI_skiplist_iterator_t* const iterator) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkiplistIndex_destroy (SkiplistIndex* slIndex) {
|
||||
if (slIndex == NULL) {
|
||||
if (slIndex == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
TRI_FreeSkipList(slIndex->skiplist);
|
||||
slIndex->skiplist = NULL;
|
||||
slIndex->skiplist = nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -567,7 +558,7 @@ static bool skiplistIndex_findHelperIntervalValid(
|
|||
|
||||
lNode = interval->_leftEndPoint;
|
||||
|
||||
if (lNode == NULL) {
|
||||
if (lNode == nullptr) {
|
||||
return false;
|
||||
}
|
||||
// Note that the right end point can be NULL to indicate the end of the index.
|
||||
|
@ -583,7 +574,7 @@ static bool skiplistIndex_findHelperIntervalValid(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (NULL != rNode && TRI_SkipListNextNode(rNode) == lNode) {
|
||||
if (nullptr != rNode && TRI_SkipListNextNode(rNode) == lNode) {
|
||||
// Interval empty, nothing to do with it.
|
||||
return false;
|
||||
}
|
||||
|
@ -593,7 +584,7 @@ static bool skiplistIndex_findHelperIntervalValid(
|
|||
}
|
||||
|
||||
if ( lNode == TRI_SkipListStartNode(skiplistIndex->skiplist) ||
|
||||
NULL == rNode ) {
|
||||
nullptr == rNode ) {
|
||||
// The index is not empty, the nodes are not neighbours, one of them
|
||||
// is at the boundary, so the interval is valid and not empty.
|
||||
return true;
|
||||
|
@ -611,18 +602,18 @@ static bool skiplistIndex_findHelperIntervalIntersectionValid (
|
|||
TRI_skiplist_iterator_interval_t* lInterval,
|
||||
TRI_skiplist_iterator_interval_t* rInterval,
|
||||
TRI_skiplist_iterator_interval_t* interval) {
|
||||
int compareResult;
|
||||
TRI_skiplist_node_t* lNode;
|
||||
TRI_skiplist_node_t* rNode;
|
||||
|
||||
lNode = lInterval->_leftEndPoint;
|
||||
rNode = rInterval->_leftEndPoint;
|
||||
|
||||
if (NULL == lNode || NULL == rNode) {
|
||||
if (nullptr == lNode || nullptr == rNode) {
|
||||
// At least one left boundary is the end, intersection is empty.
|
||||
return false;
|
||||
}
|
||||
|
||||
int compareResult;
|
||||
// Now find the larger of the two start nodes:
|
||||
if (lNode == TRI_SkipListStartNode(skiplistIndex->skiplist)) {
|
||||
// We take rNode, even if it is the start node as well.
|
||||
|
@ -648,11 +639,11 @@ static bool skiplistIndex_findHelperIntervalIntersectionValid (
|
|||
rNode = rInterval->_rightEndPoint;
|
||||
|
||||
// Now find the smaller of the two end nodes:
|
||||
if (NULL == lNode) {
|
||||
if (nullptr == lNode) {
|
||||
// We take rNode, even is this also the end node.
|
||||
compareResult = 1;
|
||||
}
|
||||
else if (NULL == rNode) {
|
||||
else if (nullptr == rNode) {
|
||||
// We take lNode.
|
||||
compareResult = -1;
|
||||
}
|
||||
|
@ -762,12 +753,12 @@ static void SkiplistIndex_findHelper (SkiplistIndex* skiplistIndex,
|
|||
|
||||
case TRI_EQ_INDEX_OPERATOR: {
|
||||
temp = TRI_SkipListLeftKeyLookup(skiplistIndex->skiplist, &values);
|
||||
if (NULL != temp) {
|
||||
if (nullptr != temp) {
|
||||
interval._leftEndPoint = temp;
|
||||
if (skiplistIndex->unique) {
|
||||
// At most one hit:
|
||||
temp = TRI_SkipListNextNode(temp);
|
||||
if (NULL != temp) {
|
||||
if (nullptr != temp) {
|
||||
if (0 == CmpKeyElm(skiplistIndex, &values, temp->doc)) {
|
||||
interval._rightEndPoint = TRI_SkipListNextNode(temp);
|
||||
if (skiplistIndex_findHelperIntervalValid(skiplistIndex,
|
||||
|
@ -819,7 +810,7 @@ static void SkiplistIndex_findHelper (SkiplistIndex* skiplistIndex,
|
|||
case TRI_GE_INDEX_OPERATOR: {
|
||||
temp = TRI_SkipListLeftKeyLookup(skiplistIndex->skiplist, &values);
|
||||
interval._leftEndPoint = temp;
|
||||
interval._rightEndPoint = NULL;
|
||||
interval._rightEndPoint = nullptr;
|
||||
|
||||
if (skiplistIndex_findHelperIntervalValid(skiplistIndex,&interval)) {
|
||||
TRI_PushBackVector(resultIntervalList, &interval);
|
||||
|
@ -832,7 +823,7 @@ static void SkiplistIndex_findHelper (SkiplistIndex* skiplistIndex,
|
|||
case TRI_GT_INDEX_OPERATOR: {
|
||||
temp = TRI_SkipListRightKeyLookup(skiplistIndex->skiplist, &values);
|
||||
interval._leftEndPoint = temp;
|
||||
interval._rightEndPoint = NULL;
|
||||
interval._rightEndPoint = nullptr;
|
||||
|
||||
if (skiplistIndex_findHelperIntervalValid(skiplistIndex,&interval)) {
|
||||
TRI_PushBackVector(resultIntervalList, &interval);
|
||||
|
@ -854,14 +845,14 @@ TRI_skiplist_iterator_t* SkiplistIndex_find (
|
|||
TRI_index_operator_t* indexOperator) {
|
||||
TRI_skiplist_iterator_t* results = static_cast<TRI_skiplist_iterator_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_skiplist_iterator_t), true));
|
||||
|
||||
if (results == NULL) {
|
||||
return NULL; // calling procedure needs to care when the iterator is null
|
||||
if (results == nullptr) {
|
||||
return nullptr; // calling procedure needs to care when the iterator is null
|
||||
}
|
||||
results->_index = skiplistIndex;
|
||||
TRI_InitVector(&(results->_intervals), TRI_UNKNOWN_MEM_ZONE,
|
||||
sizeof(TRI_skiplist_iterator_interval_t));
|
||||
results->_currentInterval = 0;
|
||||
results->_cursor = NULL;
|
||||
results->_cursor = nullptr;
|
||||
results->_hasNext = SkiplistHasNextIterationCallback;
|
||||
results->_next = SkiplistNextIterationCallback;
|
||||
results->_nexts = SkiplistNextsIterationCallback;
|
||||
|
@ -886,7 +877,7 @@ int SkiplistIndex_insert (SkiplistIndex* skiplistIndex,
|
|||
TRI_skiplist_index_element_t* element) {
|
||||
TRI_skiplist_index_element_t* copy = static_cast<TRI_skiplist_index_element_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_skiplist_index_element_t), false));
|
||||
|
||||
if (NULL == copy) {
|
||||
if (nullptr == copy) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
|
|
@ -1180,15 +1180,13 @@ int TRI_WriteInitialHeaderMarkerDatafile (TRI_datafile_t* datafile,
|
|||
/// @brief checks whether a marker is valid
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsValidMarkerDatafile (TRI_df_marker_t* const marker) {
|
||||
TRI_df_marker_type_t type;
|
||||
|
||||
if (marker == 0) {
|
||||
bool TRI_IsValidMarkerDatafile (TRI_df_marker_t const* marker) {
|
||||
if (marker == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check marker type
|
||||
type = marker->_type;
|
||||
TRI_df_marker_type_t type = marker->_type;
|
||||
if (type <= (TRI_df_marker_type_t) TRI_MARKER_MIN) {
|
||||
// marker type is less than minimum allowed type value
|
||||
return false;
|
||||
|
|
|
@ -640,7 +640,7 @@ int TRI_WriteInitialHeaderMarkerDatafile (TRI_datafile_t*,
|
|||
/// @brief checks whether a marker is valid
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsValidMarkerDatafile (TRI_df_marker_t* const marker);
|
||||
bool TRI_IsValidMarkerDatafile (TRI_df_marker_t const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a CRC and writes that into the header
|
||||
|
|
|
@ -440,7 +440,7 @@ static int DeletePrimaryIndex (TRI_document_collection_t* document,
|
|||
|
||||
static int DeleteSecondaryIndexes (TRI_document_collection_t* document,
|
||||
TRI_doc_mptr_t const* header,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
size_t const n = document->_allIndexes._length;
|
||||
int result = TRI_ERROR_NO_ERROR;
|
||||
|
||||
|
@ -704,6 +704,7 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection,
|
|||
res = InsertSecondaryIndexes(document, header, false);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
DeleteSecondaryIndexes(document, header, true);
|
||||
DeletePrimaryIndex(document, header, true);
|
||||
return res;
|
||||
}
|
||||
|
@ -837,7 +838,7 @@ static int InsertDocumentShapedJson (TRI_transaction_collection_t* trxCollection
|
|||
|
||||
// insert into indexes
|
||||
res = InsertDocument(trxCollection, header, operation, mptr, forceSync);
|
||||
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
TRI_ASSERT(mptr->getDataPtr() != nullptr); // PROTECTED by trx in trxCollection
|
||||
}
|
||||
|
@ -1056,10 +1057,6 @@ static int UpdateDocumentShapedJson (TRI_transaction_collection_t* trxCollection
|
|||
TRI_ASSERT(mptr->getDataPtr() != nullptr); // PROTECTED by trx in trxCollection
|
||||
TRI_ASSERT(mptr->_rid > 0);
|
||||
}
|
||||
else {
|
||||
TRI_ASSERT(mptr->getDataPtr() == nullptr); // PROTECTED by trx in trxCollection
|
||||
TRI_ASSERT(mptr->_rid == 0);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -3679,7 +3676,11 @@ void TRI_UpdateStatisticsDocumentCollection (TRI_document_collection_t* document
|
|||
if (rid > 0) {
|
||||
SetRevision(document, rid, force);
|
||||
}
|
||||
document->_uncollectedLogfileEntries += logfileEntries;
|
||||
|
||||
if (! document->base._info._isVolatile) {
|
||||
// only count logfileEntries if the collection is durable
|
||||
document->_uncollectedLogfileEntries += logfileEntries;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -146,13 +146,47 @@ struct TRI_doc_mptr_t {
|
|||
_next = that._next;
|
||||
}
|
||||
|
||||
void const* getDataPtr () const {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return a pointer to the beginning of the marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void const* getDataPtr () const {
|
||||
return _dataptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief set the pointer to the beginning of the memory for the marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void setDataPtr (void const* d) {
|
||||
_dataptr = d;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return a pointer to the beginning of the shaped json stored in the
|
||||
/// marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char const* getShapedJsonPtr () const {
|
||||
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(_dataptr);
|
||||
|
||||
if (marker->_type == TRI_DOC_MARKER_KEY_DOCUMENT ||
|
||||
marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
|
||||
auto offset = (reinterpret_cast<TRI_doc_document_key_marker_t const*>(marker))->_offsetJson;
|
||||
return static_cast<char const*>(_dataptr) + offset;
|
||||
}
|
||||
else if (marker->_type == TRI_WAL_MARKER_DOCUMENT ||
|
||||
marker->_type == TRI_WAL_MARKER_EDGE) {
|
||||
auto offset = (reinterpret_cast<triagens::wal::document_marker_t const*>(marker))->_offsetJson;
|
||||
return static_cast<char const*>(_dataptr) + offset;
|
||||
}
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER
|
||||
TRI_ASSERT(false);
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TRI_doc_mptr_t& operator= (TRI_doc_mptr_t const&) = delete;
|
||||
TRI_doc_mptr_t(TRI_doc_mptr_t const&) = delete;
|
||||
|
|
|
@ -543,7 +543,7 @@ char const** TRI_FieldListByPathList (TRI_shaper_t const* shaper,
|
|||
|
||||
static int InsertPrimary (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -553,7 +553,7 @@ static int InsertPrimary (TRI_index_t* idx,
|
|||
|
||||
static int RemovePrimary (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -890,7 +890,7 @@ static bool IsEqualElementEdgeTo (TRI_multi_pointer_t* array,
|
|||
|
||||
static int InsertEdge (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* mptr,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
|
||||
TRI_multi_pointer_t* edgesIndex;
|
||||
|
||||
|
@ -910,7 +910,7 @@ static int InsertEdge (TRI_index_t* idx,
|
|||
|
||||
static int RemoveEdge (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* mptr,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
|
||||
TRI_multi_pointer_t* edgesIndex;
|
||||
|
||||
|
@ -1164,11 +1164,7 @@ static int FillLookupSLOperator (TRI_index_operator_t* slOperator,
|
|||
|
||||
TRI_skiplist_iterator_t* TRI_LookupSkiplistIndex (TRI_index_t* idx,
|
||||
TRI_index_operator_t* slOperator) {
|
||||
TRI_skiplist_index_t* skiplistIndex;
|
||||
TRI_skiplist_iterator_t* iteratorResult;
|
||||
int errorResult;
|
||||
|
||||
skiplistIndex = (TRI_skiplist_index_t*)(idx);
|
||||
TRI_skiplist_index_t* skiplistIndex = (TRI_skiplist_index_t*) idx;
|
||||
|
||||
// .........................................................................
|
||||
// fill the relation operators which may be embedded in the slOperator with
|
||||
|
@ -1176,7 +1172,7 @@ TRI_skiplist_iterator_t* TRI_LookupSkiplistIndex (TRI_index_t* idx,
|
|||
// received from a user for query the skiplist.
|
||||
// .........................................................................
|
||||
|
||||
errorResult = FillLookupSLOperator(slOperator, skiplistIndex->base._collection);
|
||||
int errorResult = FillLookupSLOperator(slOperator, skiplistIndex->base._collection);
|
||||
|
||||
if (errorResult != TRI_ERROR_NO_ERROR) {
|
||||
TRI_set_errno(errorResult);
|
||||
|
@ -1184,6 +1180,7 @@ TRI_skiplist_iterator_t* TRI_LookupSkiplistIndex (TRI_index_t* idx,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
TRI_skiplist_iterator_t* iteratorResult;
|
||||
iteratorResult = SkiplistIndex_find(skiplistIndex->_skiplistIndex,
|
||||
&skiplistIndex->_paths,
|
||||
slOperator);
|
||||
|
@ -1204,19 +1201,15 @@ TRI_skiplist_iterator_t* TRI_LookupSkiplistIndex (TRI_index_t* idx,
|
|||
static int SkiplistIndexHelper (const TRI_skiplist_index_t* skiplistIndex,
|
||||
TRI_skiplist_index_element_t* skiplistElement,
|
||||
const TRI_doc_mptr_t* document) {
|
||||
TRI_shaped_json_t shapedObject;
|
||||
TRI_shaped_json_t shapedJson;
|
||||
char const* ptr;
|
||||
size_t j;
|
||||
|
||||
// ..........................................................................
|
||||
// Assign the document to the SkiplistIndexElement structure so that it can
|
||||
// be retrieved later.
|
||||
// ..........................................................................
|
||||
|
||||
TRI_ASSERT(document != NULL);
|
||||
TRI_ASSERT(document->getDataPtr() != NULL); // ONLY IN INDEX
|
||||
TRI_ASSERT(document != nullptr);
|
||||
TRI_ASSERT(document->getDataPtr() != nullptr); // ONLY IN INDEX
|
||||
|
||||
TRI_shaped_json_t shapedJson;
|
||||
TRI_EXTRACT_SHAPED_JSON_MARKER(shapedJson, document->getDataPtr()); // ONLY IN INDEX
|
||||
|
||||
if (shapedJson._sid == 0) {
|
||||
|
@ -1226,9 +1219,9 @@ static int SkiplistIndexHelper (const TRI_skiplist_index_t* skiplistIndex,
|
|||
}
|
||||
|
||||
skiplistElement->_document = const_cast<TRI_doc_mptr_t*>(document);
|
||||
ptr = (char const*) skiplistElement->_document->getDataPtr(); // ONLY IN INDEX
|
||||
char const* ptr = skiplistElement->_document->getShapedJsonPtr(); // ONLY IN INDEX
|
||||
|
||||
for (j = 0; j < skiplistIndex->_paths._length; ++j) {
|
||||
for (size_t j = 0; j < skiplistIndex->_paths._length; ++j) {
|
||||
TRI_shape_pid_t shape = *((TRI_shape_pid_t*)(TRI_AtVector(&skiplistIndex->_paths, j)));
|
||||
|
||||
// ..........................................................................
|
||||
|
@ -1237,7 +1230,7 @@ static int SkiplistIndexHelper (const TRI_skiplist_index_t* skiplistIndex,
|
|||
|
||||
TRI_shape_access_t const* acc = TRI_FindAccessorVocShaper(skiplistIndex->base._collection->_shaper, shapedJson._sid, shape);
|
||||
|
||||
if (acc == NULL || acc->_resultSid == 0) {
|
||||
if (acc == nullptr || acc->_resultSid == TRI_SHAPE_ILLEGAL) {
|
||||
return TRI_ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING;
|
||||
}
|
||||
|
||||
|
@ -1246,6 +1239,7 @@ static int SkiplistIndexHelper (const TRI_skiplist_index_t* skiplistIndex,
|
|||
// Extract the field
|
||||
// ..........................................................................
|
||||
|
||||
TRI_shaped_json_t shapedObject;
|
||||
if (! TRI_ExecuteShapeAccessor(acc, &shapedJson, &shapedObject)) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
@ -1268,7 +1262,7 @@ static int SkiplistIndexHelper (const TRI_skiplist_index_t* skiplistIndex,
|
|||
|
||||
static int InsertSkiplistIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
TRI_skiplist_index_element_t skiplistElement;
|
||||
TRI_skiplist_index_t* skiplistIndex;
|
||||
int res;
|
||||
|
@ -1279,7 +1273,7 @@ static int InsertSkiplistIndex (TRI_index_t* idx,
|
|||
|
||||
skiplistIndex = (TRI_skiplist_index_t*) idx;
|
||||
|
||||
if (idx == NULL) {
|
||||
if (idx == nullptr) {
|
||||
LOG_WARNING("internal error in InsertSkiplistIndex");
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
@ -1291,7 +1285,7 @@ static int InsertSkiplistIndex (TRI_index_t* idx,
|
|||
|
||||
skiplistElement._subObjects = static_cast<TRI_shaped_sub_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_shaped_sub_t) * skiplistIndex->_paths._length, false));
|
||||
|
||||
if (skiplistElement._subObjects == NULL) {
|
||||
if (skiplistElement._subObjects == nullptr) {
|
||||
LOG_WARNING("out-of-memory in InsertSkiplistIndex");
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1359,11 +1353,6 @@ static size_t MemorySkiplistIndex (TRI_index_t const* idx) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static TRI_json_t* JsonSkiplistIndex (TRI_index_t const* idx) {
|
||||
TRI_json_t* json;
|
||||
TRI_json_t* fields;
|
||||
char const** fieldList;
|
||||
size_t j;
|
||||
|
||||
// ..........................................................................
|
||||
// Recast as a skiplist index
|
||||
// ..........................................................................
|
||||
|
@ -1380,13 +1369,13 @@ static TRI_json_t* JsonSkiplistIndex (TRI_index_t const* idx) {
|
|||
// Allocate sufficent memory for the field list
|
||||
// ..........................................................................
|
||||
|
||||
fieldList = static_cast<char const**>(TRI_Allocate(TRI_CORE_MEM_ZONE, (sizeof(char*) * skiplistIndex->_paths._length) , false));
|
||||
char const** fieldList = static_cast<char const**>(TRI_Allocate(TRI_CORE_MEM_ZONE, (sizeof(char*) * skiplistIndex->_paths._length) , false));
|
||||
|
||||
// ..........................................................................
|
||||
// Convert the attributes (field list of the skiplist index) into strings
|
||||
// ..........................................................................
|
||||
|
||||
for (j = 0; j < skiplistIndex->_paths._length; ++j) {
|
||||
for (size_t j = 0; j < skiplistIndex->_paths._length; ++j) {
|
||||
TRI_shape_pid_t shape = *((TRI_shape_pid_t*) TRI_AtVector(&skiplistIndex->_paths, j));
|
||||
const TRI_shape_path_t* path = document->_shaper->lookupAttributePathByPid(document->_shaper, shape);
|
||||
|
||||
|
@ -1402,10 +1391,10 @@ static TRI_json_t* JsonSkiplistIndex (TRI_index_t const* idx) {
|
|||
// create json object and fill it
|
||||
// ..........................................................................
|
||||
|
||||
json = TRI_JsonIndex(TRI_CORE_MEM_ZONE, idx);
|
||||
TRI_json_t* json = TRI_JsonIndex(TRI_CORE_MEM_ZONE, idx);
|
||||
TRI_json_t* fields = TRI_CreateListJson(TRI_CORE_MEM_ZONE);
|
||||
|
||||
fields = TRI_CreateListJson(TRI_CORE_MEM_ZONE);
|
||||
for (j = 0; j < skiplistIndex->_paths._length; ++j) {
|
||||
for (size_t j = 0; j < skiplistIndex->_paths._length; ++j) {
|
||||
TRI_PushBack3ListJson(TRI_CORE_MEM_ZONE, fields, TRI_CreateStringCopyJson(TRI_CORE_MEM_ZONE, fieldList[j]));
|
||||
}
|
||||
TRI_Insert3ArrayJson(TRI_CORE_MEM_ZONE, json, "fields", fields);
|
||||
|
@ -1421,9 +1410,7 @@ static TRI_json_t* JsonSkiplistIndex (TRI_index_t const* idx) {
|
|||
|
||||
static int RemoveSkiplistIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
TRI_skiplist_index_element_t skiplistElement;
|
||||
int res;
|
||||
bool isRollback) {
|
||||
|
||||
// ...........................................................................
|
||||
// Obtain the skiplist index structure
|
||||
|
@ -1435,6 +1422,7 @@ static int RemoveSkiplistIndex (TRI_index_t* idx,
|
|||
// Allocate some memory for the SkiplistIndexElement structure
|
||||
// ...........................................................................
|
||||
|
||||
TRI_skiplist_index_element_t skiplistElement;
|
||||
skiplistElement._subObjects = static_cast<TRI_shaped_sub_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_shaped_sub_t) * skiplistIndex->_paths._length, false));
|
||||
|
||||
if (skiplistElement._subObjects == nullptr) {
|
||||
|
@ -1446,7 +1434,7 @@ static int RemoveSkiplistIndex (TRI_index_t* idx,
|
|||
// Fill the json field list from the document
|
||||
// ..........................................................................
|
||||
|
||||
res = SkiplistIndexHelper(skiplistIndex, &skiplistElement, doc);
|
||||
int res = SkiplistIndexHelper(skiplistIndex, &skiplistElement, doc);
|
||||
|
||||
// ..........................................................................
|
||||
// Error returned generally implies that the document never was part of the
|
||||
|
@ -1672,9 +1660,8 @@ static TRI_fulltext_wordlist_t* GetWordlist (TRI_index_t* idx,
|
|||
|
||||
static int InsertFulltextIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
TRI_fulltext_index_t* fulltextIndex;
|
||||
TRI_fulltext_wordlist_t* wordlist;
|
||||
int res;
|
||||
|
||||
fulltextIndex = (TRI_fulltext_index_t*) idx;
|
||||
|
@ -1686,7 +1673,7 @@ static int InsertFulltextIndex (TRI_index_t* idx,
|
|||
|
||||
res = TRI_ERROR_NO_ERROR;
|
||||
|
||||
wordlist = GetWordlist(idx, doc);
|
||||
TRI_fulltext_wordlist_t* wordlist = GetWordlist(idx, doc);
|
||||
|
||||
if (wordlist == nullptr) {
|
||||
// TODO: distinguish the cases "empty wordlist" and "out of memory"
|
||||
|
@ -1761,7 +1748,7 @@ static TRI_json_t* JsonFulltextIndex (TRI_index_t const* idx) {
|
|||
|
||||
static int RemoveFulltextIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
TRI_fulltext_index_t* fulltextIndex = (TRI_fulltext_index_t*) idx;
|
||||
|
||||
TRI_DeleteDocumentFulltextIndex(fulltextIndex->_fulltextIndex, (TRI_fulltext_doc_t) ((uintptr_t) doc));
|
||||
|
@ -2037,7 +2024,7 @@ static int BitarrayIndexHelper(const TRI_bitarray_index_t* baIndex,
|
|||
|
||||
acc = TRI_FindAccessorVocShaper(baIndex->base._collection->_shaper, shapedDoc->_sid, shape);
|
||||
|
||||
if (acc == NULL || acc->_resultSid == 0) {
|
||||
if (acc == NULL || acc->_resultSid == TRI_SHAPE_ILLEGAL) {
|
||||
return TRI_ERROR_ARANGO_INDEX_BITARRAY_UPDATE_ATTRIBUTE_MISSING;
|
||||
}
|
||||
|
||||
|
@ -2080,7 +2067,7 @@ static int BitarrayIndexHelper(const TRI_bitarray_index_t* baIndex,
|
|||
|
||||
acc = TRI_FindAccessorVocShaper(baIndex->base._collection->_shaper, shapedJson._sid, shape);
|
||||
|
||||
if (acc == NULL || acc->_resultSid == 0) {
|
||||
if (acc == NULL || acc->_resultSid == TRI_SHAPE_ILLEGAL) {
|
||||
return TRI_ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING;
|
||||
}
|
||||
|
||||
|
@ -2113,7 +2100,7 @@ static int BitarrayIndexHelper(const TRI_bitarray_index_t* baIndex,
|
|||
|
||||
static int InsertBitarrayIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
TRI_bitarray_index_key_t element;
|
||||
TRI_bitarray_index_t* baIndex;
|
||||
int result;
|
||||
|
@ -2352,7 +2339,7 @@ static TRI_json_t* JsonBitarrayIndex (TRI_index_t const* idx) {
|
|||
|
||||
static int RemoveBitarrayIndex (TRI_index_t* idx,
|
||||
TRI_doc_mptr_t const* doc,
|
||||
const bool isRollback) {
|
||||
bool isRollback) {
|
||||
TRI_bitarray_index_key_t element;
|
||||
TRI_bitarray_index_t* baIndex;
|
||||
int result;
|
||||
|
|
|
@ -110,8 +110,8 @@ typedef struct TRI_index_s {
|
|||
// the following functions are called for document/collection administration
|
||||
// .........................................................................................
|
||||
|
||||
int (*insert) (struct TRI_index_s*, struct TRI_doc_mptr_t const*, const bool);
|
||||
int (*remove) (struct TRI_index_s*, struct TRI_doc_mptr_t const*, const bool);
|
||||
int (*insert) (struct TRI_index_s*, struct TRI_doc_mptr_t const*, bool);
|
||||
int (*remove) (struct TRI_index_s*, struct TRI_doc_mptr_t const*, bool);
|
||||
|
||||
// NULL by default. will only be called if non-NULL
|
||||
int (*postInsert) (struct TRI_transaction_collection_s*, struct TRI_index_s*, struct TRI_doc_mptr_t const*);
|
||||
|
|
|
@ -1001,8 +1001,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
TRI_doc_mptr_t* rightDocument,
|
||||
TRI_shaped_sub_t* rightObject,
|
||||
TRI_shaped_json_t const* rightShaped,
|
||||
TRI_shaper_t* leftShaper,
|
||||
TRI_shaper_t* rightShaper) {
|
||||
TRI_shaper_t* shaper) {
|
||||
|
||||
TRI_shape_t const* leftShape;
|
||||
TRI_shape_t const* rightShape;
|
||||
|
@ -1017,7 +1016,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
|
||||
// left is either a shaped json or a shaped sub object
|
||||
if (leftDocument != nullptr) {
|
||||
ptr = (char const*) leftDocument->getDataPtr(); // ONLY IN INDEX
|
||||
ptr = leftDocument->getShapedJsonPtr(); // ONLY IN INDEX
|
||||
|
||||
left._sid = leftObject->_sid;
|
||||
left._data.length = (uint32_t) leftObject->_length;
|
||||
|
@ -1029,7 +1028,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
|
||||
// right is either a shaped json or a shaped sub object
|
||||
if (rightDocument != nullptr) {
|
||||
ptr = (char const*) rightDocument->getDataPtr(); // ONLY IN INDEX
|
||||
ptr = rightDocument->getShapedJsonPtr(); // ONLY IN INDEX
|
||||
|
||||
right._sid = rightObject->_sid;
|
||||
right._data.length = (uint32_t) rightObject->_length;
|
||||
|
@ -1040,14 +1039,14 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
}
|
||||
|
||||
// get shape and type
|
||||
if (leftShaper == rightShaper && left._sid == right._sid) {
|
||||
if (left._sid == right._sid) {
|
||||
// identical collection and shape
|
||||
leftShape = rightShape = leftShaper->lookupShapeId(leftShaper, left._sid);
|
||||
leftShape = rightShape = shaper->lookupShapeId(shaper, left._sid);
|
||||
}
|
||||
else {
|
||||
// different shapes
|
||||
leftShape = leftShaper->lookupShapeId(leftShaper, left._sid);
|
||||
rightShape = rightShaper->lookupShapeId(rightShaper, right._sid);
|
||||
leftShape = shaper->lookupShapeId(shaper, left._sid);
|
||||
rightShape = shaper->lookupShapeId(shaper, right._sid);
|
||||
}
|
||||
|
||||
if (leftShape == nullptr || rightShape == nullptr) {
|
||||
|
@ -1197,17 +1196,17 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
// compare strings
|
||||
// extract the strings
|
||||
if (leftType == TRI_SHAPE_SHORT_STRING) {
|
||||
leftString = (char*)(sizeof(TRI_shape_length_short_string_t) + left._data.data);
|
||||
leftString = (char*) (sizeof(TRI_shape_length_short_string_t) + left._data.data);
|
||||
}
|
||||
else {
|
||||
leftString = (char*)(sizeof(TRI_shape_length_long_string_t) + left._data.data);
|
||||
leftString = (char*) (sizeof(TRI_shape_length_long_string_t) + left._data.data);
|
||||
}
|
||||
|
||||
if (rightType == TRI_SHAPE_SHORT_STRING) {
|
||||
rightString = (char*)(sizeof(TRI_shape_length_short_string_t) + right._data.data);
|
||||
rightString = (char*) (sizeof(TRI_shape_length_short_string_t) + right._data.data);
|
||||
}
|
||||
else {
|
||||
rightString = (char*)(sizeof(TRI_shape_length_long_string_t) + right._data.data);
|
||||
rightString = (char*) (sizeof(TRI_shape_length_long_string_t) + right._data.data);
|
||||
}
|
||||
|
||||
return TRI_compare_utf8(leftString, rightString);
|
||||
|
@ -1300,8 +1299,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
nullptr,
|
||||
nullptr,
|
||||
&rightElement,
|
||||
leftShaper,
|
||||
rightShaper);
|
||||
shaper);
|
||||
|
||||
if (result != 0) {
|
||||
return result;
|
||||
|
@ -1357,11 +1355,11 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
TRI_vector_t rightSorted;
|
||||
|
||||
bool error = false;
|
||||
if (FillAttributesVector(&leftSorted, &left, leftShape, leftShaper) != TRI_ERROR_NO_ERROR) {
|
||||
if (FillAttributesVector(&leftSorted, &left, leftShape, shaper) != TRI_ERROR_NO_ERROR) {
|
||||
error = true;
|
||||
}
|
||||
|
||||
if (FillAttributesVector(&rightSorted, &right, rightShape, rightShaper) != TRI_ERROR_NO_ERROR) {
|
||||
if (FillAttributesVector(&rightSorted, &right, rightShape, shaper) != TRI_ERROR_NO_ERROR) {
|
||||
error = true;
|
||||
}
|
||||
|
||||
|
@ -1387,8 +1385,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
nullptr,
|
||||
nullptr,
|
||||
&r->_value,
|
||||
leftShaper,
|
||||
rightShaper);
|
||||
shaper);
|
||||
|
||||
if (result != 0) {
|
||||
break;
|
||||
|
|
|
@ -126,8 +126,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
TRI_doc_mptr_t* rightDocument,
|
||||
TRI_shaped_sub_t* rightObject,
|
||||
TRI_shaped_json_t const* rightShaped,
|
||||
TRI_shaper_t* leftShaper,
|
||||
TRI_shaper_t* rightShaper);
|
||||
TRI_shaper_t* shaper);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief extracts the shape identifier pointer from a marker
|
||||
|
|
|
@ -717,9 +717,13 @@ int CollectorThread::transferMarkers (Logfile* logfile,
|
|||
TRI_ASSERT(vocbase != nullptr);
|
||||
|
||||
triagens::arango::CollectionGuard collectionGuard(vocbase, collectionId);
|
||||
TRI_vocbase_col_t* collection =collectionGuard.collection();
|
||||
TRI_vocbase_col_t* collection = collectionGuard.collection();
|
||||
TRI_ASSERT(collection != nullptr);
|
||||
|
||||
|
||||
if (collection->_collection->base._info._isVolatile) {
|
||||
// don't need to collect data for volatile collections
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
CollectorCache* cache = new CollectorCache(collectionId,
|
||||
databaseId,
|
||||
|
|
|
@ -430,34 +430,32 @@ function CollectionSuite () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testSystemSpecial : function () {
|
||||
[ '_trx', '_users' ].forEach(function(cn) {
|
||||
var c = db._collection(cn);
|
||||
var cn = "_users";
|
||||
var c = db._collection(cn);
|
||||
|
||||
// drop
|
||||
try {
|
||||
c.drop();
|
||||
fail();
|
||||
}
|
||||
catch (err1) {
|
||||
assertEqual(ERRORS.ERROR_FORBIDDEN.code, err1.errorNum);
|
||||
}
|
||||
// drop
|
||||
try {
|
||||
c.drop();
|
||||
fail();
|
||||
}
|
||||
catch (err1) {
|
||||
assertEqual(ERRORS.ERROR_FORBIDDEN.code, err1.errorNum);
|
||||
}
|
||||
|
||||
// rename
|
||||
var cn = "example";
|
||||
db._drop(cn);
|
||||
// rename
|
||||
var cn = "example";
|
||||
db._drop(cn);
|
||||
|
||||
try {
|
||||
c.rename(cn);
|
||||
fail();
|
||||
}
|
||||
catch (err2) {
|
||||
assertEqual(ERRORS.ERROR_FORBIDDEN.code, err2.errorNum);
|
||||
}
|
||||
try {
|
||||
c.rename(cn);
|
||||
fail();
|
||||
}
|
||||
catch (err2) {
|
||||
assertEqual(ERRORS.ERROR_FORBIDDEN.code, err2.errorNum);
|
||||
}
|
||||
|
||||
// unload is allowed
|
||||
c.unload();
|
||||
|
||||
});
|
||||
// unload is allowed
|
||||
c.unload();
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue