int TRI_RemoveBlockerCompactorVocBase (TRI_vocbase_t* vocbase, TRI_voc_tick_t id) { size_t i, n; bool found; found = false; LockCompaction(vocbase); n = vocbase->_compactionBlockers._data._length; for (i = 0; i < n; ++i) { compaction_blocker_t* blocker = TRI_AtVector(&vocbase->_compactionBlockers._data, i); if (blocker->_id == id) { TRI_RemoveVector(&vocbase->_compactionBlockers._data, i); found = true; break; } } UnlockCompaction(vocbase); if (! found) { return TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND; } return TRI_ERROR_NO_ERROR; }
bool TRI_CleanupCompactorVocBase (TRI_vocbase_t* vocbase) { double now; size_t i, n; now = TRI_microtime(); // check if we can instantly acquire the lock if (! TryLockCompaction(vocbase)) { // couldn't acquire lock return false; } // we are now holding the write lock n = vocbase->_compactionBlockers._data._length; i = 0; while (i < n) { compaction_blocker_t* blocker = TRI_AtVector(&vocbase->_compactionBlockers._data, i); if (blocker->_expires < now) { TRI_RemoveVector(&vocbase->_compactionBlockers._data, i); n--; } else { i++; } } UnlockCompaction(vocbase); return true; }
bool TRI_DeleteArrayJson (TRI_memory_zone_t* zone, TRI_json_t* object, char const* name) { size_t n; size_t i; TRI_ASSERT(object->_type == TRI_JSON_ARRAY); TRI_ASSERT(name); n = object->_value._objects._length; for (i = 0; i < n; i += 2) { TRI_json_t* key; key = (TRI_json_t*) TRI_AtVector(&object->_value._objects, i); if (! IsString(key)) { continue; } if (TRI_EqualString(key->_value._string.data, name)) { TRI_json_t* old; // remove key old = (TRI_json_t*) TRI_AtVector(&object->_value._objects, i); if (old != NULL) { TRI_DestroyJson(zone, old); } TRI_RemoveVector(&object->_value._objects, i); // remove value old = (TRI_json_t*) TRI_AtVector(&object->_value._objects, i); if (old != NULL) { TRI_DestroyJson(zone, old); } TRI_RemoveVector(&object->_value._objects, i); return true; } } return false; }
bool TRI_DeleteObjectJson (TRI_memory_zone_t* zone, TRI_json_t* object, char const* name) { TRI_ASSERT(object->_type == TRI_JSON_OBJECT); TRI_ASSERT(name != nullptr); size_t const n = TRI_LengthVector(&object->_value._objects); for (size_t i = 0; i < n; i += 2) { TRI_json_t* key = static_cast<TRI_json_t*>(TRI_AtVector(&object->_value._objects, i)); if (! IsString(key)) { continue; } if (TRI_EqualString(key->_value._string.data, name)) { // remove key TRI_json_t* old = static_cast<TRI_json_t*>(TRI_AtVector(&object->_value._objects, i)); if (old != nullptr) { TRI_DestroyJson(zone, old); } TRI_RemoveVector(&object->_value._objects, i); // remove value old = static_cast<TRI_json_t*>(TRI_AtVector(&object->_value._objects, i)); if (old != nullptr) { TRI_DestroyJson(zone, old); } TRI_RemoveVector(&object->_value._objects, i); return true; } } return false; }
bool TRI_DeleteArrayJson (TRI_memory_zone_t* zone, TRI_json_t* array, size_t index) { TRI_ASSERT(TRI_IsArrayJson(array)); size_t const n = TRI_LengthArrayJson(array); if (index >= n) { return false; } TRI_json_t* element = static_cast<TRI_json_t*>(TRI_AtVector(&array->_value._objects, index)); TRI_ASSERT(element != nullptr); TRI_DestroyJson(zone, element); TRI_RemoveVector(&array->_value._objects, index); return true; }