| 215 | |
| 216 | |
| 217 | UUID MultipleAccessStorage::insertImpl(const AccessEntityPtr & entity, bool replace_if_exists) |
| 218 | { |
| 219 | auto storages = getStoragesInternal(); |
| 220 | |
| 221 | std::shared_ptr<IAccessStorage> storage_for_insertion; |
| 222 | for (const auto & storage : *storages) |
| 223 | { |
| 224 | if (storage->canInsert(entity) || |
| 225 | storage->find(entity->getType(), entity->getName())) |
| 226 | { |
| 227 | storage_for_insertion = storage; |
| 228 | break; |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | if (!storage_for_insertion) |
| 233 | throw Exception("Not found a storage to insert " + entity->outputTypeAndName(), ErrorCodes::ACCESS_STORAGE_FOR_INSERTION_NOT_FOUND); |
| 234 | |
| 235 | auto id = replace_if_exists ? storage_for_insertion->insertOrReplace(entity) : storage_for_insertion->insert(entity); |
| 236 | std::lock_guard lock{mutex}; |
| 237 | ids_cache.set(id, storage_for_insertion); |
| 238 | return id; |
| 239 | } |
| 240 | |
| 241 | |
| 242 | void MultipleAccessStorage::removeImpl(const UUID & id) |
nothing calls this directly
no test coverage detected