1
0
Fork 0

use std::shared_ptrs for views

This commit is contained in:
jsteemann 2017-03-15 13:07:08 +01:00
parent 00e99ea794
commit 49aef67cca
8 changed files with 99 additions and 118 deletions

View File

@ -108,7 +108,6 @@ PhysicalView* MMFilesView::clone(LogicalView* logical, PhysicalView* physical){
MMFilesView::MMFilesView(LogicalView* view,
VPackSlice const& info)
: PhysicalView(view, info) {
LOG_TOPIC(ERR, Logger::FIXME) << "CTOR PHYSICAL " << this;
auto pathSlice = info.get("path");
if (pathSlice.isString()) {
_path = pathSlice.copyString();
@ -117,13 +116,9 @@ MMFilesView::MMFilesView(LogicalView* view,
MMFilesView::MMFilesView(LogicalView* logical,
PhysicalView* physical)
: PhysicalView(logical, VPackSlice::emptyObjectSlice()) {
LOG_TOPIC(ERR, Logger::FIXME) << "CTOR2 PHYSICAL " << this;
}
: PhysicalView(logical, VPackSlice::emptyObjectSlice()) {}
MMFilesView::~MMFilesView() {
LOG_TOPIC(ERR, Logger::FIXME) << "DTOR PHYSICAL " << this;
}
MMFilesView::~MMFilesView() {}
void MMFilesView::getPropertiesVPack(velocypack::Builder& result) const {
TRI_ASSERT(result.isOpenObject());

View File

@ -784,7 +784,7 @@ bool MMFilesWalRecoverState::ReplayMarker(TRI_df_marker_t const* marker,
return true;
}
LogicalView* view = vocbase->lookupView(viewId);
std::shared_ptr<arangodb::LogicalView> view = vocbase->lookupView(viewId);
if (view == nullptr) {
// if the underlying collection is gone, we can go on
@ -1039,7 +1039,7 @@ bool MMFilesWalRecoverState::ReplayMarker(TRI_df_marker_t const* marker,
return true;
}
arangodb::LogicalView* view = vocbase->lookupView(viewId);
std::shared_ptr<arangodb::LogicalView> view = vocbase->lookupView(viewId);
if (view != nullptr) {
// drop an existing view
@ -1277,7 +1277,7 @@ bool MMFilesWalRecoverState::ReplayMarker(TRI_df_marker_t const* marker,
}
// ignore any potential error returned by this call
arangodb::LogicalView* view = vocbase->lookupView(viewId);
std::shared_ptr<arangodb::LogicalView> view = vocbase->lookupView(viewId);
if (view != nullptr) {
vocbase->dropView(view);

View File

@ -24,13 +24,8 @@
#include "RestViewHandler.h"
#include "Basics/Exceptions.h"
#include "Basics/StaticStrings.h"
#include "Basics/VelocyPackDumper.h"
#include "Basics/VelocyPackHelper.h"
#include "Transaction/Context.h"
#include <velocypack/Iterator.h>
#include <velocypack/Value.h>
#include <velocypack/velocypack-aliases.h>
using namespace arangodb;
@ -109,7 +104,7 @@ void RestViewHandler::createView() {
}
TRI_voc_cid_t id = 0;
LogicalView* view = _vocbase->createView(body, id);
std::shared_ptr<LogicalView> view = _vocbase->createView(body, id);
if (view != nullptr) {
generateOk(rest::ResponseCode::CREATED);
} else {
@ -141,7 +136,7 @@ void RestViewHandler::modifyView() {
}
std::string const& name = suffixes[0];
LogicalView* view = _vocbase->lookupView(name);
std::shared_ptr<LogicalView> view = _vocbase->lookupView(name);
if (view == nullptr) {
generateError(rest::ResponseCode::NOT_FOUND, TRI_ERROR_HTTP_NOT_FOUND,
"could not find view by that name");
@ -180,16 +175,14 @@ void RestViewHandler::deleteView() {
}
std::string const& name = suffixes[0];
LogicalView* view = _vocbase->lookupView(name);
if (view == nullptr) {
generateError(rest::ResponseCode::NOT_FOUND, TRI_ERROR_HTTP_NOT_FOUND,
"could not find view by that name");
return;
}
int res = _vocbase->dropView(view);
int res = _vocbase->dropView(name);
if (res == TRI_ERROR_NO_ERROR) {
generateOk();
} else if (res == TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND) {
generateError(rest::ResponseCode::NOT_FOUND, TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
"could not find view by that name");
} else {
generateError(rest::ResponseCode::SERVER_ERROR, TRI_ERROR_INTERNAL,
"problem dropping view");

View File

@ -28,10 +28,6 @@
#include "Basics/Common.h"
#include "RestHandler/RestVocbaseBaseHandler.h"
#include <velocypack/Builder.h>
#include <velocypack/Slice.h>
#include <velocypack/velocypack-aliases.h>
namespace arangodb {
////////////////////////////////////////////////////////////////////////////////

View File

@ -40,7 +40,7 @@
using namespace arangodb;
using namespace arangodb::basics;
static arangodb::LogicalView* GetViewFromArgument(
static std::shared_ptr<arangodb::LogicalView> GetViewFromArgument(
TRI_vocbase_t* vocbase, v8::Handle<v8::Value> const val) {
// number
if (val->IsNumber() || val->IsNumberObject()) {
@ -57,10 +57,14 @@ static void WeakViewCallback(const v8::WeakCallbackInfo<
auto isolate = data.GetIsolate();
auto persistent = data.GetParameter();
auto myView = v8::Local<v8::External>::New(isolate, *persistent);
auto view = static_cast<LogicalView*>(myView->Value());
auto v = static_cast<std::shared_ptr<LogicalView>*>(myView->Value());
TRI_ASSERT(v != nullptr);
LogicalView* view = v->get();
TRI_ASSERT(view != nullptr);
TRI_GET_GLOBALS();
LOG_TOPIC(ERR, Logger::FIXME) << "WEAK CALLBACK FOR VIEW: " << view << "; VIEW: " << view->name();
v8g->decreaseActiveExternals();
// decrease the reference-counter for the database
@ -77,39 +81,39 @@ LOG_TOPIC(ERR, Logger::FIXME) << "WEAK CALLBACK FOR VIEW: " << view << "; VIEW:
v8g->JSViews.erase(view);
view->vocbase()->release();
delete view;
delete v; // delete the shared_ptr on the heap
}
/// @brief wraps a LogicalView
v8::Handle<v8::Object> WrapView(v8::Isolate* isolate,
arangodb::LogicalView* view) {
std::shared_ptr<arangodb::LogicalView> view) {
v8::EscapableHandleScope scope(isolate);
LOG_TOPIC(ERR, Logger::FIXME) << "WRAPPER FOR VIEW: " << view << "; VIEW: " << view->name();
TRI_GET_GLOBALS();
TRI_GET_GLOBAL(VocbaseViewTempl, v8::ObjectTemplate);
v8::Handle<v8::Object> result = VocbaseViewTempl->NewInstance();
if (!result.IsEmpty()) {
// create a new shared_ptr on the heap
auto v = new std::shared_ptr<arangodb::LogicalView>(view);
result->SetInternalField(SLOT_CLASS_TYPE,
v8::Integer::New(isolate, WRP_VOCBASE_VIEW_TYPE));
result->SetInternalField(SLOT_CLASS,
v8::External::New(isolate, view));
v8::External::New(isolate, v));
auto const& it = v8g->JSViews.find(view);
auto const& it = v8g->JSViews.find(view.get());
if (it == v8g->JSViews.end()) {
// increase the reference-counter for the database
TRI_ASSERT(!view->vocbase()->isDangling());
view->vocbase()->forceUse();
try {
auto externalView = v8::External::New(isolate, view);
auto externalView = v8::External::New(isolate, v);
result->SetInternalField(SLOT_EXTERNAL, externalView);
v8g->JSViews[view].Reset(isolate, externalView);
v8g->JSViews[view].SetWeak(&v8g->JSViews[view],
v8g->JSViews[view.get()].Reset(isolate, externalView);
v8g->JSViews[view.get()].SetWeak(&v8g->JSViews[view.get()],
WeakViewCallback,
v8::WeakCallbackType::kFinalizer);
v8g->increaseActiveExternals();
@ -125,7 +129,7 @@ LOG_TOPIC(ERR, Logger::FIXME) << "WRAPPER FOR VIEW: " << view << "; VIEW: " << v
TRI_GET_GLOBAL_STRING(_DbNameKey);
result->ForceSet(_IdKey, TRI_V8UInt64String<TRI_voc_cid_t>(isolate, view->id()),
v8::ReadOnly);
result->Set(_DbNameKey, TRI_V8_STRING(view->vocbase()->name().c_str()));
result->Set(_DbNameKey, TRI_V8_STD_STRING(view->vocbase()->name()));
}
return scope.Escape<v8::Object>(result);
@ -184,7 +188,7 @@ static void JS_CreateViewVocbase(v8::FunctionCallbackInfo<v8::Value> const& args
try {
TRI_voc_cid_t id = 0;
arangodb::LogicalView* view = vocbase->createView(infoSlice, id);
std::shared_ptr<arangodb::LogicalView> view = vocbase->createView(infoSlice, id);
TRI_ASSERT(view != nullptr);
@ -209,16 +213,18 @@ static void JS_DropViewVocbase(v8::FunctionCallbackInfo<v8::Value> const& args)
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
arangodb::LogicalView* view =
TRI_UnwrapClass<arangodb::LogicalView>(args.Holder(), WRP_VOCBASE_VIEW_TYPE);
std::shared_ptr<arangodb::LogicalView>* v =
TRI_UnwrapClass<std::shared_ptr<arangodb::LogicalView>>(args.Holder(), WRP_VOCBASE_VIEW_TYPE);
if (view == nullptr) {
if (v == nullptr || v->get() == nullptr) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract view");
}
LogicalView* view = v->get();
PREVENT_EMBEDDED_TRANSACTION();
int res = view->vocbase()->dropView(view);
int res = view->vocbase()->dropView(view->name());
if (res != TRI_ERROR_NO_ERROR) {
TRI_V8_THROW_EXCEPTION_MESSAGE(res, "cannot drop view");
@ -249,7 +255,7 @@ static void JS_ViewVocbase(
}
v8::Handle<v8::Value> val = args[0];
arangodb::LogicalView* view = GetViewFromArgument(vocbase, val);
std::shared_ptr<arangodb::LogicalView> view = GetViewFromArgument(vocbase, val);
if (view == nullptr) {
TRI_V8_RETURN_NULL();
@ -277,9 +283,9 @@ static void JS_ViewsVocbase(
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
std::vector<LogicalView*> views = vocbase->views();
std::vector<std::shared_ptr<LogicalView>> views = vocbase->views();
std::sort(views.begin(), views.end(), [](LogicalView* lhs, LogicalView* rhs) -> bool {
std::sort(views.begin(), views.end(), [](std::shared_ptr<LogicalView> const& lhs, std::shared_ptr<LogicalView> const& rhs) -> bool {
return StringUtils::tolower(lhs->name()) < StringUtils::tolower(rhs->name());
});
@ -315,13 +321,15 @@ static void JS_NameViewVocbase(v8::FunctionCallbackInfo<v8::Value> const& args)
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
arangodb::LogicalView* view =
TRI_UnwrapClass<arangodb::LogicalView>(args.Holder(), WRP_VOCBASE_VIEW_TYPE);
std::shared_ptr<arangodb::LogicalView>* v =
TRI_UnwrapClass<std::shared_ptr<arangodb::LogicalView>>(args.Holder(), WRP_VOCBASE_VIEW_TYPE);
if (view == nullptr) {
if (v == nullptr || v->get() == nullptr) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract view");
}
LogicalView* view = v->get();
std::string const name(view->name());
if (name.empty()) {
@ -339,13 +347,15 @@ static void JS_PropertiesViewVocbase(
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
arangodb::LogicalView* view =
TRI_UnwrapClass<arangodb::LogicalView>(args.Holder(), WRP_VOCBASE_VIEW_TYPE);
std::shared_ptr<arangodb::LogicalView>* v =
TRI_UnwrapClass<std::shared_ptr<arangodb::LogicalView>>(args.Holder(), WRP_VOCBASE_VIEW_TYPE);
if (view == nullptr) {
if (v == nullptr || v->get() == nullptr) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract view");
}
LogicalView* view = v->get();
bool const isModification = (args.Length() != 0);
// check if we want to change some parameters
@ -396,13 +406,15 @@ static void JS_TypeViewVocbase(v8::FunctionCallbackInfo<v8::Value> const& args)
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
arangodb::LogicalView* view =
TRI_UnwrapClass<arangodb::LogicalView>(args.Holder(), WRP_VOCBASE_VIEW_TYPE);
std::shared_ptr<arangodb::LogicalView>* v =
TRI_UnwrapClass<std::shared_ptr<arangodb::LogicalView>>(args.Holder(), WRP_VOCBASE_VIEW_TYPE);
if (view == nullptr) {
if (v == nullptr || v->get() == nullptr) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract view");
}
LogicalView* view = v->get();
std::string const type = view->type();
TRI_V8_RETURN(TRI_V8_STD_STRING(type));
TRI_V8_TRY_CATCH_END

View File

@ -120,7 +120,6 @@ LogicalView::LogicalView(TRI_vocbase_t* vocbase,
_vocbase(vocbase),
_physical(
EngineSelectorFeature::ENGINE->createPhysicalView(this, info)) {
LOG_TOPIC(ERR, Logger::FIXME) << "CTOR LOGICAL " << this;
TRI_ASSERT(_physical != nullptr);
if (!IsAllowedName(info)) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_ILLEGAL_NAME);
@ -130,9 +129,7 @@ LogicalView::LogicalView(TRI_vocbase_t* vocbase,
TRI_UpdateTickServer(static_cast<TRI_voc_tick_t>(_id));
}
LogicalView::~LogicalView() {
LOG_TOPIC(ERR, Logger::FIXME) << "DTOR LOGICAL " << this;
}
LogicalView::~LogicalView() {}
bool LogicalView::IsAllowedName(VPackSlice parameters) {
std::string name = ReadStringValue(parameters, "name", "");

View File

@ -222,7 +222,7 @@ bool TRI_vocbase_t::unregisterCollection(arangodb::LogicalCollection* collection
/// @brief adds a new view
/// caller must hold _viewLock in write mode or set doLock
void TRI_vocbase_t::registerView(
bool doLock, arangodb::LogicalView* view) {
bool doLock, std::shared_ptr<arangodb::LogicalView> view) {
std::string const name = view->name();
TRI_voc_cid_t const id = view->id();
{
@ -259,25 +259,13 @@ void TRI_vocbase_t::registerView(
}
TRI_ASSERT(_viewsByName.size() == _viewsById.size());
try {
_views.emplace_back(view);
}
catch (...) {
_viewsByName.erase(name);
_viewsById.erase(id);
TRI_ASSERT(_viewsByName.size() == _viewsById.size());
throw;
}
TRI_ASSERT(_viewsByName.size() == _viewsById.size());
}
}
/// @brief removes a views name from the global list of views
/// This function is called when a view is dropped.
/// NOTE: You need a writelock on _viewsLock
bool TRI_vocbase_t::unregisterView(arangodb::LogicalView* view) {
bool TRI_vocbase_t::unregisterView(std::shared_ptr<arangodb::LogicalView> view) {
TRI_ASSERT(view != nullptr);
std::string const name(view->name());
@ -926,9 +914,9 @@ LogicalCollection* TRI_vocbase_t::lookupCollection(TRI_voc_cid_t id) {
}
/// @brief looks up a view by name
LogicalView* TRI_vocbase_t::lookupView(std::string const& name) {
std::shared_ptr<LogicalView> TRI_vocbase_t::lookupView(std::string const& name) {
if (name.empty()) {
return nullptr;
return std::shared_ptr<LogicalView>();
}
// if view name is passed as a stringified id, we'll use the lookupbyid
@ -944,19 +932,19 @@ LogicalView* TRI_vocbase_t::lookupView(std::string const& name) {
auto it = _viewsByName.find(name);
if (it == _viewsByName.end()) {
return nullptr;
return std::shared_ptr<LogicalView>();
}
return (*it).second;
}
/// @brief looks up a view by identifier
LogicalView* TRI_vocbase_t::lookupView(TRI_voc_cid_t id) {
std::shared_ptr<LogicalView> TRI_vocbase_t::lookupView(TRI_voc_cid_t id) {
READ_LOCKER(readLocker, _viewsLock);
auto it = _viewsById.find(id);
if (it == _viewsById.end()) {
return nullptr;
return std::shared_ptr<LogicalView>();
}
return (*it).second;
}
@ -1301,22 +1289,19 @@ void TRI_vocbase_t::releaseCollection(arangodb::LogicalCollection* collection) {
}
/// @brief creates a new view, worker function
arangodb::LogicalView* TRI_vocbase_t::createViewWorker(
std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::createViewWorker(
VPackSlice parameters, TRI_voc_cid_t& id) {
std::string name = arangodb::basics::VelocyPackHelper::getStringValue(parameters, "name" , "");
TRI_ASSERT(!name.empty());
// Try to create a new view. This is not registered yet
std::unique_ptr<arangodb::LogicalView> view =
std::make_unique<arangodb::LogicalView>(this, parameters);
std::shared_ptr<arangodb::LogicalView> view =
std::make_shared<arangodb::LogicalView>(this, parameters);
TRI_ASSERT(view != nullptr);
WRITE_LOCKER(writeLocker, _viewsLock);
// reserve room for the new view
_views.reserve(_views.size() + 1);
auto it = _viewsByName.find(name);
if (it != _viewsByName.end()) {
@ -1324,7 +1309,7 @@ arangodb::LogicalView* TRI_vocbase_t::createViewWorker(
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_DUPLICATE_NAME);
}
registerView(basics::ConditionalLocking::DoNotLock, view.get());
registerView(basics::ConditionalLocking::DoNotLock, view);
try {
// cid might have been assigned
@ -1334,9 +1319,9 @@ arangodb::LogicalView* TRI_vocbase_t::createViewWorker(
view->persistPhysicalView();
events::CreateView(name, TRI_ERROR_NO_ERROR);
return view.release();
return view;
} catch (...) {
unregisterView(view.get());
unregisterView(view);
throw;
}
}
@ -1346,7 +1331,7 @@ arangodb::LogicalView* TRI_vocbase_t::createViewWorker(
/// this means that the system will assign a new id automatically
/// using a cid of > 0 is supported to import dumps from other servers etc.
/// but the functionality is not advertised
arangodb::LogicalView* TRI_vocbase_t::createView(
std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::createView(
VPackSlice parameters,
TRI_voc_cid_t id) {
// check that the name does not contain any strange characters
@ -1357,7 +1342,7 @@ arangodb::LogicalView* TRI_vocbase_t::createView(
READ_LOCKER(readLocker, _inventoryLock);
// note: id may be modified by this function call
arangodb::LogicalView* view = createViewWorker(parameters, id);
std::shared_ptr<LogicalView> view = createViewWorker(parameters, id);
if (view == nullptr) {
// something went wrong... must not continue
@ -1367,20 +1352,28 @@ arangodb::LogicalView* TRI_vocbase_t::createView(
StorageEngine* engine = EngineSelectorFeature::ENGINE;
TRI_ASSERT(engine != nullptr);
// TODO Review
arangodb::Result res2 = engine->persistView(this, view);
arangodb::Result res2 = engine->persistView(this, view.get());
// API compatibility, we always return the view, even if creation failed.
return view;
}
int TRI_vocbase_t::dropView(std::string const& name) {
std::shared_ptr<LogicalView> view = lookupView(name);
if (view == nullptr) {
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
}
return dropView(view);
}
/// @brief drops a view
int TRI_vocbase_t::dropView(arangodb::LogicalView* view) {
int TRI_vocbase_t::dropView(std::shared_ptr<arangodb::LogicalView> view) {
TRI_ASSERT(view != nullptr);
READ_LOCKER(readLocker, _inventoryLock);
std::string const viewName(view->name());
// do not acquire these locks instantly
CONDITIONAL_WRITE_LOCKER(writeLocker, _viewsLock, basics::ConditionalLocking::DoNotLock);
CONDITIONAL_WRITE_LOCKER(locker, view->_lock, basics::ConditionalLocking::DoNotLock);
@ -1421,12 +1414,12 @@ int TRI_vocbase_t::dropView(arangodb::LogicalView* view) {
unregisterView(view);
StorageEngine* engine = EngineSelectorFeature::ENGINE;
engine->dropView(this, view);
engine->dropView(this, view.get());
locker.unlock();
writeLocker.unlock();
events::DropView(viewName, TRI_ERROR_NO_ERROR);
events::DropView(view->name(), TRI_ERROR_NO_ERROR);
return TRI_ERROR_NO_ERROR;
}
@ -1467,11 +1460,6 @@ TRI_vocbase_t::~TRI_vocbase_t() {
for (auto& it : _collections) {
delete it;
}
// do a final cleanup of views
for (auto& it : _views) {
delete it;
}
}
std::string TRI_vocbase_t::path() const {
@ -1556,8 +1544,8 @@ TRI_vocbase_t::getReplicationClients() {
return result;
}
std::vector<arangodb::LogicalView*> TRI_vocbase_t::views() {
std::vector<arangodb::LogicalView*> views;
std::vector<std::shared_ptr<arangodb::LogicalView>> TRI_vocbase_t::views() {
std::vector<std::shared_ptr<arangodb::LogicalView>> views;
{
READ_LOCKER(readLocker, _viewsLock);

View File

@ -164,9 +164,8 @@ struct TRI_vocbase_t {
std::unordered_map<TRI_voc_cid_t, arangodb::LogicalCollection*> _collectionsById; // collections by id
arangodb::basics::ReadWriteLock _viewsLock; // views management lock
std::vector<arangodb::LogicalView*> _views; // pointers to ALL views
std::unordered_map<std::string, arangodb::LogicalView*> _viewsByName; // views by name
std::unordered_map<TRI_voc_cid_t, arangodb::LogicalView*> _viewsById; // views by id
std::unordered_map<std::string, std::shared_ptr<arangodb::LogicalView>> _viewsByName; // views by name
std::unordered_map<TRI_voc_cid_t, std::shared_ptr<arangodb::LogicalView>> _viewsById; // views by id
std::unique_ptr<arangodb::aql::QueryList> _queries;
@ -240,7 +239,7 @@ struct TRI_vocbase_t {
void shutdown();
/// @brief returns all known views
std::vector<arangodb::LogicalView*> views();
std::vector<std::shared_ptr<arangodb::LogicalView>> views();
/// @brief returns all known collections
std::vector<arangodb::LogicalCollection*> collections(bool includeDeleted);
@ -259,9 +258,9 @@ struct TRI_vocbase_t {
arangodb::LogicalCollection* lookupCollection(TRI_voc_cid_t id);
/// @brief looks up a view by name
arangodb::LogicalView* lookupView(std::string const& name);
std::shared_ptr<arangodb::LogicalView> lookupView(std::string const& name);
/// @brief looks up a view by identifier
arangodb::LogicalView* lookupView(TRI_voc_cid_t id);
std::shared_ptr<arangodb::LogicalView> lookupView(TRI_voc_cid_t id);
/// @brief returns all known collections with their parameters
/// and optionally indexes
@ -299,11 +298,12 @@ struct TRI_vocbase_t {
/// this means that the system will assign a new id automatically
/// using a cid of > 0 is supported to import dumps from other servers etc.
/// but the functionality is not advertised
arangodb::LogicalView* createView(
std::shared_ptr<arangodb::LogicalView> createView(
arangodb::velocypack::Slice parameters, TRI_voc_cid_t id);
/// @brief drops a view
int dropView(arangodb::LogicalView* view);
int dropView(std::string const& name);
int dropView(std::shared_ptr<arangodb::LogicalView> view);
/// @brief locks a collection for usage, loading or manifesting it
/// Note that this will READ lock the collection you have to release the
@ -350,17 +350,17 @@ struct TRI_vocbase_t {
DropState& state);
/// @brief creates a new view, worker function
arangodb::LogicalView* createViewWorker(
std::shared_ptr<arangodb::LogicalView> createViewWorker(
arangodb::velocypack::Slice parameters, TRI_voc_cid_t& id);
/// @brief adds a new view
/// caller must hold _viewsLock in write mode or set doLock
void registerView(bool doLock, arangodb::LogicalView* view);
void registerView(bool doLock, std::shared_ptr<arangodb::LogicalView> view);
/// @brief removes a view from the global list of views
/// This function is called when a view is dropped.
bool unregisterView(arangodb::LogicalView* view);
bool unregisterView(std::shared_ptr<arangodb::LogicalView> view);
};
// scope guard for a database