1
0
Fork 0

issue 496.4.1: backport 3.4: move StorageEngine-specific flag out of the genric API and closer to the storage engine (#7213)

* issue 496.4.1: backport 3.4: move StorageEngine-specific flag out of the genric API and closer to the storage engine

* address merge issue
This commit is contained in:
Vasiliy 2018-11-04 16:52:54 +03:00 committed by Andrey Abramov
parent cf86d9bbc8
commit d644561f1f
67 changed files with 794 additions and 720 deletions

View File

@ -73,6 +73,7 @@ Result DBServerAgencySync::getLocalCollections(VPackBuilder& collections) {
}
VPackObjectBuilder c(&collections);
for (auto const& database : Databases::list()) {
try {
@ -80,23 +81,33 @@ Result DBServerAgencySync::getLocalCollections(VPackBuilder& collections) {
auto vocbase = &guard.database();
collections.add(VPackValue(database));
VPackObjectBuilder db(&collections);
auto cols = vocbase->collections(false);
for (auto const& collection : cols) {
collections.add(VPackValue(collection->name()));
VPackObjectBuilder col(&collections);
collection->toVelocyPack(collections,true,false);
collection->properties(collections,true,false);
auto const& folls = collection->followers();
std::string const theLeader = folls->getLeader();
collections.add("theLeader", VPackValue(theLeader));
if (theLeader.empty()) { // we are the leader ourselves
// In this case we report our in-sync followers here in the format
// of the agency: [ leader, follower1, follower2, ... ]
collections.add(VPackValue("servers"));
{ VPackArrayBuilder guard(&collections);
collections.add(VPackValue(arangodb::ServerState::instance()->getId()));
std::shared_ptr<std::vector<ServerID> const> srvs = folls->get();
for (auto const& s : *srvs) {
collections.add(VPackValue(s));
}
@ -108,11 +119,9 @@ Result DBServerAgencySync::getLocalCollections(VPackBuilder& collections) {
TRI_ERROR_INTERNAL,
std::string("Failed to guard database ") + database + ": " + e.what());
}
}
return Result();
}
DBServerAgencySyncResult DBServerAgencySync::execute() {

View File

@ -45,7 +45,7 @@ UpdateCollection::UpdateCollection(
ActionBase(feature, desc) {
std::stringstream error;
_labels.emplace(FAST_TRACK);
if (!desc.has(COLLECTION)) {
@ -145,7 +145,6 @@ bool UpdateCollection::first() {
auto const& props = properties();
try {
DatabaseGuard guard(database);
auto vocbase = &guard.database();
@ -162,7 +161,7 @@ bool UpdateCollection::first() {
// ourselves does not appear in shards[shard] but only
// "_" + ourselves.
handleLeadership(*coll, localLeader, plannedLeader, followersToDrop);
_result = Collections::updateProperties(coll.get(), props);
_result = Collections::updateProperties(*coll, props, false); // always a full-update
if (!_result.ok()) {
LOG_TOPIC(ERR, Logger::MAINTENANCE) << "failed to update properties"
@ -179,6 +178,7 @@ bool UpdateCollection::first() {
}
} catch (std::exception const& e) {
std::stringstream error;
error << "action " << _description << " failed with exception " << e.what();
LOG_TOPIC(WARN, Logger::MAINTENANCE) << "UpdateCollection: " << error.str();
_result.reset(TRI_ERROR_INTERNAL, error.str());
@ -190,6 +190,6 @@ bool UpdateCollection::first() {
}
notify();
return false;
return false;
}

View File

@ -69,10 +69,18 @@ IResearchLink::IResearchLink(
}
IResearchLink::~IResearchLink() {
if (_dropCollectionInDestructor) {
drop();
} else {
if (!_dropCollectionInDestructor) {
unload(); // disassociate from view if it has not been done yet
return;
}
auto res = drop();
if (!res.ok()) {
LOG_TOPIC(ERR, arangodb::iresearch::TOPIC)
<< "failed to drop arangosearch view link in link destructor: "
<< res.errorNumber() << " " << res.errorMessage();
}
}
@ -87,6 +95,21 @@ bool IResearchLink::operator==(IResearchLinkMeta const& meta) const noexcept {
return _meta == meta;
}
void IResearchLink::afterTruncate() {
ReadMutex mutex(_mutex); // '_view' can be asynchronously modified
SCOPED_LOCK(mutex);
if (!_view) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_LOADED); // IResearchView required
}
auto res = _view->drop(_view->id(), false);
if (!res.ok()) {
THROW_ARANGO_EXCEPTION(res);
}
}
void IResearchLink::batchInsert(
transaction::Methods* trx,
std::vector<std::pair<arangodb::LocalDocumentId, arangodb::velocypack::Slice>> const& batch,
@ -126,22 +149,24 @@ bool IResearchLink::canBeDropped() const {
return true; // valid for a link to be dropped from an iResearch view
}
int IResearchLink::drop() {
arangodb::Result IResearchLink::drop() {
ReadMutex mutex(_mutex); // '_view' can be asynchronously modified
SCOPED_LOCK(mutex);
if (!_view) {
return TRI_ERROR_ARANGO_COLLECTION_NOT_LOADED; // IResearchView required
return arangodb::Result(
TRI_ERROR_ARANGO_COLLECTION_NOT_LOADED, // IResearchView required
std::string("failed to drop collection '") + _collection.name() + "' from an unset arangosearch view"
);
}
auto res = _view->drop(_collection.id());
if (!res.ok()) {
LOG_TOPIC(WARN, arangodb::iresearch::TOPIC)
<< "failed to drop collection '" << _collection.name()
<< "' from arangosearch view '" << _view->name() << "': " << res.errorMessage();
return res.errorNumber();
return arangodb::Result(
res.errorNumber(),
std::string("failed to drop collection '") + _collection.name() + "' from arangosearch view '" + _view->name() + "': " + res.errorMessage()
);
}
_dropCollectionInDestructor = false; // will do drop now
@ -153,25 +178,10 @@ int IResearchLink::drop() {
// FIXME TODO this workaround should be in ClusterInfo when moving 'Plan' to 'Current', i.e. IResearchViewDBServer::drop
if (arangodb::ServerState::instance()->isDBServer()) {
return view->drop().errorNumber(); // cluster-view in ClusterInfo should already not have cid-view
return view->drop(); // cluster-view in ClusterInfo should already not have cid-view
}
return TRI_ERROR_NO_ERROR;
}
void IResearchLink::doAfterTruncate() {
ReadMutex mutex(_mutex); // '_view' can be asynchronously modified
SCOPED_LOCK(mutex);
if (!_view) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_LOADED); // IResearchView required
}
auto res = _view->drop(_view->id(), false);
if (!res.ok()) {
THROW_ARANGO_EXCEPTION(res);
}
return arangodb::Result();
}
bool IResearchLink::hasBatchInsert() const {
@ -501,7 +511,7 @@ int IResearchLink::unload() {
// FIXME TODO remove once LogicalCollection::drop(...) will drop its indexes explicitly
if (_collection.deleted()
|| TRI_vocbase_col_status_e::TRI_VOC_COL_STATUS_DELETED == _collection.status()) {
return drop();
return drop().errorNumber();
}
_dropCollectionInDestructor = false; // valid link (since unload(..) called), should not be dropped
@ -545,4 +555,4 @@ NS_END // arangodb
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -64,6 +64,8 @@ class IResearchLink {
return !(*this == meta);
}
void afterTruncate(); // arangodb::Index override
////////////////////////////////////////////////////////////////////////////////
/// @brief insert a set of ArangoDB documents into an iResearch View using
/// '_meta' params
@ -79,9 +81,7 @@ class IResearchLink {
////////////////////////////////////////////////////////////////////////////////
/// @brief called when the iResearch Link is dropped
////////////////////////////////////////////////////////////////////////////////
int drop(); // arangodb::Index override
void doAfterTruncate();
arangodb::Result drop(); // arangodb::Index override
bool hasBatchInsert() const; // arangodb::Index override
bool hasSelectivityEstimate() const; // arangodb::Index override

View File

@ -219,8 +219,17 @@ arangodb::Result modifyLinks(
linkDefinitions.emplace_back(std::move(namedJson), std::move(linkMeta));
}
auto trxCtx = arangodb::transaction::StandaloneContext::Create(vocbase);
// add removals for any 'stale' links not found in the 'links' definition
for (auto& id: stale) {
if (!trxCtx->resolver().getCollection(id)) {
LOG_TOPIC(WARN, arangodb::iresearch::TOPIC)
<< "request for removal of a stale link to a missing collection '" << id << "', ignoring";
continue; // skip adding removal requests to stale links to non-existant collections (already dropped)
}
linkModifications.emplace_back(collectionsToLock.size());
linkModifications.back()._stale = true;
collectionsToLock.emplace_back(std::to_string(id));
@ -233,7 +242,7 @@ arangodb::Result modifyLinks(
static std::vector<std::string> const EMPTY;
arangodb::ExecContextScope scope(arangodb::ExecContext::superuser()); // required to remove links from non-RW collections
arangodb::transaction::Methods trx(
arangodb::transaction::StandaloneContext::Create(vocbase),
trxCtx,
EMPTY, // readCollections
EMPTY, // writeCollections
collectionsToLock, // exclusiveCollections
@ -251,7 +260,10 @@ arangodb::Result modifyLinks(
auto res = trx.begin();
if (!res.ok()) {
return res;
return arangodb::Result(
res.errorNumber(),
std::string("failed to start transaction while updating arangosearch view '") + view.name() + "' error: " + res.errorMessage()
);
}
{
@ -419,7 +431,15 @@ arangodb::Result modifyLinks(
}
if (error.empty()) {
return arangodb::Result(trx.commit());
auto res = trx.commit();
return res.ok()
? arangodb::Result()
: arangodb::Result(
res.errorNumber(),
std::string("failed to commit transaction while updating arangosearch view '") + view.name() + "' error: " + res.errorMessage()
)
;
}
return arangodb::Result(

View File

@ -38,6 +38,10 @@ class IResearchMMFilesLink final
virtual ~IResearchMMFilesLink();
void afterTruncate(TRI_voc_tick_t /*tick*/) override {
IResearchLink::afterTruncate();
};
virtual void batchInsert(
transaction::Methods* trx,
std::vector<std::pair<arangodb::LocalDocumentId, arangodb::velocypack::Slice>> const& documents,
@ -51,12 +55,8 @@ class IResearchMMFilesLink final
}
virtual int drop() override {
return IResearchLink::drop();
return IResearchLink::drop().errorNumber();
}
void afterTruncate(TRI_voc_tick_t /*tick*/) override {
IResearchLink::doAfterTruncate();
};
virtual bool hasBatchInsert() const override {
return IResearchLink::hasBatchInsert();
@ -152,4 +152,4 @@ class IResearchMMFilesLink final
NS_END // iresearch
NS_END // arangodb
#endif
#endif

View File

@ -38,6 +38,10 @@ class IResearchRocksDBLink final
virtual ~IResearchRocksDBLink();
virtual void afterTruncate(TRI_voc_tick_t/*tick*/) override {
IResearchLink::afterTruncate();
};
virtual void batchInsert(
transaction::Methods* trx,
std::vector<std::pair<arangodb::LocalDocumentId, arangodb::velocypack::Slice>> const& documents,
@ -52,12 +56,9 @@ class IResearchRocksDBLink final
virtual int drop() override {
writeRocksWalMarker();
return IResearchLink::drop();
return IResearchLink::drop().errorNumber();
}
virtual void afterTruncate(TRI_voc_tick_t/*tick*/) override {
IResearchLink::doAfterTruncate();
};
virtual bool hasBatchInsert() const override {
return IResearchLink::hasBatchInsert();
@ -152,4 +153,4 @@ class IResearchRocksDBLink final
NS_END // iresearch
NS_END // arangodb
#endif
#endif

View File

@ -826,10 +826,7 @@ IResearchView::IResearchView(
auto* viewPtr = view->get();
if (!viewPtr) {
LOG_TOPIC(WARN, arangodb::iresearch::TOPIC)
<< "Invalid call to post-recovery callback of arangosearch view";
return arangodb::Result(); // view no longer in recovery state
return arangodb::Result(); // view no longer in recovery state, i.e. during recovery it was created and later dropped
}
viewPtr->verifyKnownCollections();
@ -1154,7 +1151,7 @@ arangodb::Result IResearchView::drop(
) {
auto filter = iresearch::FilterFactory::filter(cid);
WriteMutex rmutex(_mutex); // '_meta' and '_storeByTid' can be asynchronously updated
ReadMutex rmutex(_mutex); // '_meta' and '_storeByTid' can be asynchronously updated
WriteMutex wmutex(_mutex); // '_meta' and '_storeByTid' can be asynchronously updated
DEFER_SCOPED_LOCK_NAMED(rmutex, rlock);
DEFER_SCOPED_LOCK_NAMED(wmutex, wlock);
@ -1414,11 +1411,9 @@ bool IResearchView::emplace(TRI_voc_cid_t cid) {
}
arangodb::Result IResearchView::commit() {
ReadMutex mutex(_mutex); // '_storePersisted' can be asynchronously updated
SCOPED_LOCK(mutex);
// '_storePersisted' protected by '_asyncSelf' held by snapshot()/registerFlushCallback()
if (!_storePersisted) {
return {}; // nothing more to do
return arangodb::Result(); // nothing more to do
}
try {
@ -1855,6 +1850,7 @@ PrimaryKeyIndexReader* IResearchView::snapshot(
break;
case Snapshot::SyncAndReplace: {
// ingore existing cookie, recreate snapshot
SCOPED_LOCK(_asyncSelf->mutex()); // '_storePersisted' may be modified asynchronously
auto const res = const_cast<IResearchView*>(this)->commit();
if (!res.ok()) {
@ -1887,9 +1883,7 @@ PrimaryKeyIndexReader* IResearchView::snapshot(
}
try {
ReadMutex mutex(_mutex); // _storePersisted can be asynchronously updated
SCOPED_LOCK(mutex);
// '_storePersisted' protected by '_asyncSelf' held by ViewStateRead
if (_storePersisted) {
reader->add(_storePersisted._reader);
}
@ -2030,7 +2024,8 @@ arangodb::Result IResearchView::updateProperties(
return IResearchLinkHelper::updateLinks(
collections, vocbase(), *this, links, stale
); } catch (arangodb::basics::Exception& e) {
);
} catch (arangodb::basics::Exception& e) {
LOG_TOPIC(WARN, iresearch::TOPIC)
<< "caught exception while updating properties for arangosearch view '" << name() << "': " << e.code() << " " << e.what();
IR_LOG_EXCEPTION();

View File

@ -274,7 +274,6 @@ class IResearchView final
//////////////////////////////////////////////////////////////////////////////
/// @brief updates properties of an existing view
//////////////////////////////////////////////////////////////////////////////
using LogicalView::updateProperties;
arangodb::Result updateProperties(std::shared_ptr<AsyncMeta> const& meta); // nullptr == TRI_ERROR_BAD_PARAMETER
///////////////////////////////////////////////////////////////////////////////
@ -363,7 +362,7 @@ class IResearchView final
std::shared_ptr<AsyncMeta> _meta; // the shared view configuration (never null!!!)
IResearchViewMetaState _metaState; // the per-instance configuration state
mutable irs::async_utils::read_write_mutex _mutex; // for use with member maps/sets and '_metaState'
PersistedStore _storePersisted;
PersistedStore _storePersisted; // protected by _asyncSelf->mutex()
std::mutex _readerLock; // prevents query cache double invalidation
std::mutex _updateLinksLock; // prevents simultaneous 'updateLinks'
FlushCallback _flushCallback; // responsible for flush callback unregistration
@ -376,4 +375,4 @@ class IResearchView final
} // iresearch
} // arangodb
#endif
#endif

View File

@ -98,7 +98,7 @@ struct IResearchViewCoordinator::ViewFactory: public arangodb::ViewFactory {
arangodb::velocypack::Builder builder;
builder.openObject();
res = impl->toVelocyPack(builder, true, true); // include links so that Agency will always have a full definition
res = impl->properties(builder, true, true); // include links so that Agency will always have a full definition
if (!res.ok()) {
return res;
@ -327,10 +327,9 @@ bool IResearchViewCoordinator::visitCollections(
return true;
}
arangodb::Result IResearchViewCoordinator::updateProperties(
arangodb::Result IResearchViewCoordinator::properties(
velocypack::Slice const& slice,
bool partialUpdate,
bool /*doSync*/
bool partialUpdate
) {
auto* engine = arangodb::ClusterInfo::instance();
@ -394,7 +393,7 @@ arangodb::Result IResearchViewCoordinator::updateProperties(
builder.openObject();
meta.json(builder);
auto result = toVelocyPack(builder, false, true);
auto result = properties(builder, false, true);
if (!result.ok()) {
return result;

View File

@ -76,18 +76,19 @@ class IResearchViewCoordinator final : public arangodb::LogicalViewClusterInfo {
//////////////////////////////////////////////////////////////////////////////
static arangodb::ViewFactory const& factory();
bool visitCollections(CollectionVisitor const& visitor) const override;
void open() override {
// NOOP
}
virtual arangodb::Result updateProperties(
using LogicalDataSource::properties;
virtual arangodb::Result properties(
velocypack::Slice const& properties,
bool partialUpdate,
bool doSync
bool partialUpdate
) override;
bool visitCollections(CollectionVisitor const& visitor) const override;
protected:
virtual Result appendVelocyPackDetailed(
arangodb::velocypack::Builder& builder,

View File

@ -212,7 +212,7 @@ struct IResearchViewDBServer::ViewFactory: public arangodb::ViewFactory {
arangodb::velocypack::Builder builder;
builder.openObject();
res = impl->toVelocyPack(builder, true, true); // include links so that Agency will always have a full definition
res = impl->properties(builder, true, true); // include links so that Agency will always have a full definition
if (!res.ok()) {
return res;
@ -735,10 +735,9 @@ PrimaryKeyIndexReader* IResearchViewDBServer::snapshot(
return reader;
}
arangodb::Result IResearchViewDBServer::updateProperties(
arangodb::Result IResearchViewDBServer::properties(
arangodb::velocypack::Slice const& slice,
bool partialUpdate,
bool doSync
bool partialUpdate
) {
if (!slice.isObject()) {
return arangodb::Result(

View File

@ -83,6 +83,11 @@ class IResearchViewDBServer final: public arangodb::LogicalViewClusterInfo {
virtual void open() override;
virtual arangodb::Result properties(
arangodb::velocypack::Slice const& properties,
bool partialUpdate
) override;
////////////////////////////////////////////////////////////////////////////////
/// @return pointer to an index reader containing the datastore record snapshot
/// associated with 'state'
@ -95,11 +100,6 @@ class IResearchViewDBServer final: public arangodb::LogicalViewClusterInfo {
IResearchView::Snapshot mode = IResearchView::Snapshot::Find
) const;
virtual arangodb::Result updateProperties(
arangodb::velocypack::Slice const& properties,
bool partialUpdate,
bool doSync
) override;
virtual bool visitCollections(
CollectionVisitor const& visitor
) const override;

View File

@ -2154,15 +2154,11 @@ std::shared_ptr<Index> MMFilesCollection::createIndex(transaction::Methods* trx,
addIndexLocal(idx);
{
bool const doSync =
application_features::ApplicationServer::getFeature<DatabaseFeature>(
"Database")
->forceSyncProperties();
auto builder = _logicalCollection.toVelocyPackIgnore(
{"path", "statusString"}, true, true
);
_logicalCollection.updateProperties(builder.slice(), doSync);
_logicalCollection.properties(builder.slice(), false); // always a full-update
}
created = true;
@ -2353,15 +2349,11 @@ bool MMFilesCollection::dropIndex(TRI_idx_iid_t iid) {
engine->dropIndex(&vocbase, cid, iid);
{
bool const doSync =
application_features::ApplicationServer::getFeature<DatabaseFeature>(
"Database")
->forceSyncProperties();
auto builder = _logicalCollection.toVelocyPackIgnore(
{"path", "statusString"}, true, true
);
_logicalCollection.updateProperties(builder.slice(), doSync);
_logicalCollection.properties(builder.slice(), false); // always a full-update
}
if (!engine->inRecovery()) {

View File

@ -1356,14 +1356,16 @@ Result MMFilesEngine::createView(
}
VPackBuilder builder;
builder.openObject();
view.toVelocyPack(builder, true, true);
view.properties(builder, true, true);
builder.close();
TRI_ASSERT(id != 0);
TRI_UpdateTickServer(static_cast<TRI_voc_tick_t>(id));
res = TRI_ERROR_NO_ERROR;
try {
MMFilesViewMarker marker(TRI_DF_MARKER_VPACK_CREATE_VIEW, vocbase.id(),
view.id(), builder.slice());
@ -1463,10 +1465,10 @@ void MMFilesEngine::saveViewInfo(TRI_vocbase_t* vocbase,
arangodb::LogicalView const* view,
bool forceSync) const {
std::string const filename = viewParametersFilename(vocbase->id(), view->id());
VPackBuilder builder;
builder.openObject();
view->toVelocyPack(builder, true, true);
view->properties(builder, true, true);
builder.close();
LOG_TOPIC(TRACE, Logger::VIEWS)
@ -1499,8 +1501,9 @@ Result MMFilesEngine::changeView(
) {
if (!inRecovery()) {
VPackBuilder infoBuilder;
infoBuilder.openObject();
view.toVelocyPack(infoBuilder, true, true);
view.properties(infoBuilder, true, true);
infoBuilder.close();
MMFilesViewMarker marker(

View File

@ -772,12 +772,8 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
return true;
}
// turn off sync temporarily if the database or collection are going to
// be
// dropped later
bool const forceSync = state->willBeDropped(databaseId, collectionId);
arangodb::Result res =
collection->updateProperties(payloadSlice, forceSync);
auto res = collection->properties(payloadSlice, false); // always a full-update
if (!res.ok()) {
LOG_TOPIC(WARN, arangodb::Logger::ENGINES)
<< "cannot change properties for collection " << collectionId
@ -795,16 +791,6 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
TRI_voc_cid_t const viewId = MMFilesDatafileHelper::ViewId(marker);
VPackSlice const payloadSlice(reinterpret_cast<char const*>(marker) +
MMFilesDatafileHelper::VPackOffset(type));
auto* databaseFeature = application_features::ApplicationServer::lookupFeature<
DatabaseFeature
>("Database");
if (!databaseFeature) {
LOG_TOPIC(WARN, arangodb::Logger::ENGINES)
<< "failed to find feature 'Database' while renaming view";
++state->errorCount;
return state->canContinue();
}
if (!payloadSlice.isObject()) {
LOG_TOPIC(WARN, arangodb::Logger::ENGINES)
@ -842,10 +828,6 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
return true;
}
// turn off sync temporarily if the database or collection are going to
// be dropped later
bool const forceSync = state->willViewBeDropped(databaseId, viewId);
VPackSlice nameSlice = payloadSlice.get("name");
if (nameSlice.isString() && !nameSlice.isEqualString(view->name())) {
@ -863,9 +845,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
vocbase->dropView(other->id(), true);
}
auto res = view->rename(
std::string(name), databaseFeature->forceSyncProperties()
);
auto res = view->rename(std::string(name));
if (!res.ok()) {
LOG_TOPIC(WARN, arangodb::Logger::ENGINES)
@ -878,7 +858,8 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
}
}
auto res = view->updateProperties(payloadSlice, false, forceSync);
auto res = view->properties(payloadSlice, false); // always a full-update
if (!res.ok()) {
LOG_TOPIC(WARN, arangodb::Logger::ENGINES)
<< "cannot change properties for view " << viewId

View File

@ -1036,12 +1036,8 @@ Result DatabaseInitialSyncer::fetchCollectionSync(
Result DatabaseInitialSyncer::changeCollection(arangodb::LogicalCollection* col,
VPackSlice const& slice) {
arangodb::CollectionGuard guard(&vocbase(), col->id());
bool doSync =
application_features::ApplicationServer::getFeature<DatabaseFeature>(
"Database")
->forceSyncProperties();
return guard.collection()->updateProperties(slice, doSync);
return guard.collection()->properties(slice, false); // always a full-update
}
/// @brief determine the number of documents in a collection

View File

@ -805,17 +805,6 @@ Result Syncer::dropIndex(arangodb::velocypack::Slice const& slice) {
/// @brief creates a view, based on the VelocyPack provided
Result Syncer::createView(TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& slice) {
auto* databaseFeature = application_features::ApplicationServer::lookupFeature<
DatabaseFeature
>("Database");
if (!databaseFeature) {
return Result(
TRI_ERROR_INTERNAL,
"failed to find feature 'Database' while creating view"
);
}
if (!slice.isObject()) {
return Result(TRI_ERROR_REPLICATION_INVALID_RESPONSE,
"collection slice is no object");
@ -848,29 +837,28 @@ Result Syncer::createView(TRI_vocbase_t& vocbase,
VPackSlice nameSlice = slice.get(StaticStrings::DataSourceName);
if (nameSlice.isString() && !nameSlice.isEqualString(view->name())) {
auto res = view->rename(
nameSlice.copyString(), databaseFeature->forceSyncProperties()
);
auto res = view->rename(nameSlice.copyString());
if (!res.ok()) {
return res;
}
}
bool doSync = DatabaseFeature::DATABASE->forceSyncProperties();
return view->updateProperties(slice, false, doSync);
return view->properties(slice, false); // always a full-update
}
view = vocbase.lookupView(nameSlice.copyString());
if (view) { // resolve name conflict by deleting existing
Result res = vocbase.dropView(view->id(), /*dropSytem*/false);
if (res.fail()) {
return res;
}
}
VPackBuilder s;
s.openObject();
s.add("id", VPackSlice::nullSlice());
s.close();

View File

@ -691,9 +691,8 @@ Result TailingSyncer::changeCollection(VPackSlice const& slice) {
}
arangodb::CollectionGuard guard(vocbase, col);
bool doSync = DatabaseFeature::DATABASE->forceSyncProperties();
return guard.collection()->updateProperties(data, doSync);
return guard.collection()->properties(data, false); // always a full-update
}
/// @brief truncate a collections. Assumes no trx are running
@ -740,17 +739,6 @@ Result TailingSyncer::truncateCollection(arangodb::velocypack::Slice const& slic
/// @brief changes the properties of a view,
/// based on the VelocyPack provided
Result TailingSyncer::changeView(VPackSlice const& slice) {
auto* databaseFeature = application_features::ApplicationServer::lookupFeature<
DatabaseFeature
>("Database");
if (!databaseFeature) {
return Result(
TRI_ERROR_INTERNAL,
"failed to find feature 'Database' while changing view properties"
);
}
if (!slice.isObject()) {
return Result(TRI_ERROR_REPLICATION_INVALID_RESPONSE,
"view marker slice is no object");
@ -799,9 +787,7 @@ Result TailingSyncer::changeView(VPackSlice const& slice) {
VPackSlice nameSlice = data.get(StaticStrings::DataSourceName);
if (nameSlice.isString() && !nameSlice.isEqualString(view->name())) {
auto res = view->rename(
nameSlice.copyString(), databaseFeature->forceSyncProperties()
);
auto res = view->rename(nameSlice.copyString());
if (!res.ok()) {
return res;
@ -811,9 +797,7 @@ Result TailingSyncer::changeView(VPackSlice const& slice) {
VPackSlice properties = data.get("properties");
if (properties.isObject()) {
bool doSync = DatabaseFeature::DATABASE->forceSyncProperties();
return view->updateProperties(properties, false, doSync);
return view->properties(properties, false); // always a full-update
}
return {};

View File

@ -137,7 +137,7 @@ void RestCollectionHandler::handleCommandGet() {
if (sub == "checksum") {
// /_api/collection/<identifier>/checksum
if (!coll->isLocal()) {
if (ServerState::instance()->isCoordinator()) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
}
@ -411,9 +411,9 @@ void RestCollectionHandler::handleCommandPut() {
}
if (res.ok()) {
if (!coll->isLocal()) { // ClusterInfo::loadPlan eventually updates status
coll->setStatus(TRI_vocbase_col_status_e::TRI_VOC_COL_STATUS_LOADED);
}
if (ServerState::instance()->isCoordinator()) { // ClusterInfo::loadPlan eventually updates status
coll->setStatus(TRI_vocbase_col_status_e::TRI_VOC_COL_STATUS_LOADED);
}
collectionRepresentation(
builder,
@ -424,14 +424,15 @@ void RestCollectionHandler::handleCommandPut() {
/*detailedCount*/ true
);
}
} else if (sub == "properties") {
std::vector<std::string> keep = {"doCompact", "journalSize",
"waitForSync", "indexBuckets",
"replicationFactor", "cacheEnabled"};
VPackBuilder props = VPackCollection::keep(body, keep);
res = methods::Collections::updateProperties(coll.get(), props.slice());
res = methods::Collections::updateProperties(
*coll, props.slice(), false // always a full-update
);
if (res.ok()) {
collectionRepresentation(builder, name, /*showProperties*/ true,
@ -454,7 +455,6 @@ void RestCollectionHandler::handleCommandPut() {
/*showFigures*/ false, /*showCount*/ false,
/*detailedCount*/ true);
}
} else if (sub == "loadIndexesIntoMemory") {
res = methods::Collections::warmup(_vocbase, *coll);

View File

@ -691,8 +691,6 @@ void RestReplicationHandler::handleCommandClusterInventory() {
ClusterInfo* ci = ClusterInfo::instance();
std::vector<std::shared_ptr<LogicalCollection>> cols =
ci->getCollections(dbName);
auto views = ci->getViews(dbName); // ci does not store links in the view objects
VPackBuilder resultBuilder;
resultBuilder.openObject();
resultBuilder.add("collections", VPackValue(VPackValueType::Array));
@ -720,12 +718,18 @@ void RestReplicationHandler::handleCommandClusterInventory() {
}
resultBuilder.close(); // collections
resultBuilder.add("views", VPackValue(VPackValueType::Array));
for (auto const& view : views) {
resultBuilder.openObject();
view->toVelocyPack(resultBuilder, /*details*/true, /*forPersistence*/false);
resultBuilder.add(StaticStrings::DataSourceGuid, VPackValue(view->guid()));
resultBuilder.close();
}
LogicalView::enumerate(
_vocbase,
[&resultBuilder](LogicalView::ptr const& view)->bool {
if (view) {
resultBuilder.openObject();
view->properties(resultBuilder, true, false); // details, !forPersistence because on restore any datasource ids will differ, so need an end-user representation
resultBuilder.close();
}
return true;
}
);
resultBuilder.close(); // views
TRI_voc_tick_t tick = TRI_CurrentTickServer();

View File

@ -92,7 +92,7 @@ void RestViewHandler::getView(std::string const& nameOrId, bool detailed) {
viewBuilder.openObject();
auto res = view->toVelocyPack(viewBuilder, true, false);
auto res = view->properties(viewBuilder, true, false);
if (!res.ok()) {
generateError(res);
@ -109,7 +109,7 @@ void RestViewHandler::getView(std::string const& nameOrId, bool detailed) {
builder.openObject();
auto res = view->toVelocyPack(builder, detailed, false);
auto res = view->properties(builder, detailed, false);
builder.close();
@ -221,7 +221,7 @@ void RestViewHandler::createView() {
velocypack::Builder builder;
builder.openObject();
res = view->toVelocyPack(builder, true, false);
res = view->properties(builder, true, false);
if (!res.ok()) {
generateError(res);
@ -273,19 +273,6 @@ void RestViewHandler::modifyView(bool partialUpdate) {
// handle rename functionality
if (suffixes[1] == "rename") {
auto* databaseFeature = application_features::ApplicationServer::lookupFeature<
DatabaseFeature
>("Database");
if (!databaseFeature) {
generateError(Result(
TRI_ERROR_INTERNAL,
"failed to find feature 'Database' while renaming view"
));
return;
}
VPackSlice newName = body.get("name");
if (!newName.isString()) {
@ -312,7 +299,7 @@ void RestViewHandler::modifyView(bool partialUpdate) {
viewBuilder.openObject();
auto res = view->toVelocyPack(viewBuilder, true, false);
auto res = view->properties(viewBuilder, true, false);
if (!res.ok()) {
generateError(res);
@ -325,9 +312,7 @@ void RestViewHandler::modifyView(bool partialUpdate) {
return; // skip view
}
auto res = view->rename(
newName.copyString(), databaseFeature->forceSyncProperties()
);
auto res = view->rename(newName.copyString());
if (res.ok()) {
getView(view->name(), false);
@ -355,7 +340,7 @@ void RestViewHandler::modifyView(bool partialUpdate) {
builderCurrent.openObject();
auto resCurrent = view->toVelocyPack(builderCurrent, true, false);
auto resCurrent = view->properties(builderCurrent, true, false);
if (!resCurrent.ok()) {
generateError(resCurrent);
@ -364,9 +349,7 @@ void RestViewHandler::modifyView(bool partialUpdate) {
}
}
auto const result = view->updateProperties(
body, partialUpdate, true
); // TODO: not force sync?
auto result = view->properties(body, partialUpdate);
if (!result.ok()) {
generateError(result);
@ -386,7 +369,7 @@ void RestViewHandler::modifyView(bool partialUpdate) {
updated.openObject();
auto res = view->toVelocyPack(updated, true, false);
auto res = view->properties(updated, true, false);
updated.close();
@ -528,7 +511,7 @@ void RestViewHandler::getViews() {
viewBuilder.openObject();
if (!view->toVelocyPack(viewBuilder, true, false).ok()) {
if (!view->properties(viewBuilder, true, false).ok()) {
continue; // skip view
}
} catch(...) {
@ -540,7 +523,7 @@ void RestViewHandler::getViews() {
viewBuilder.openObject();
try {
auto res = view->toVelocyPack(viewBuilder, false, false);
auto res = view->properties(viewBuilder, false, false);
if (!res.ok()) {
generateError(res);

View File

@ -1408,17 +1408,22 @@ Result RocksDBEngine::createView(
RocksDBLogValue logValue = RocksDBLogValue::ViewCreate(vocbase.id(), id);
VPackBuilder props;
props.openObject();
view.toVelocyPack(props, true, true);
view.properties(props, true, true);
props.close();
RocksDBValue const value = RocksDBValue::View(props.slice());
// Write marker + key into RocksDB inside one batch
batch.PutLogData(logValue.slice());
batch.Put(RocksDBColumnFamily::definitions(), key.string(), value.string());
auto res = _db->Write(wo, &batch);
LOG_TOPIC_IF(TRACE, Logger::VIEWS, !res.ok())
<< "could not create view: " << res.ToString();
return rocksutils::convertStatus(res);
}
@ -1432,7 +1437,7 @@ arangodb::Result RocksDBEngine::dropView(
VPackBuilder builder;
builder.openObject();
view.toVelocyPack(builder, true, true);
view.properties(builder, true, true);
builder.close();
auto logValue =
@ -1478,11 +1483,13 @@ Result RocksDBEngine::changeView(
}
RocksDBKey key;
key.constructView(vocbase.id(), view.id());
VPackBuilder infoBuilder;
infoBuilder.openObject();
view.toVelocyPack(infoBuilder, true, true);
view.properties(infoBuilder, true, true);
infoBuilder.close();
RocksDBLogValue log = RocksDBLogValue::ViewChange(vocbase.id(), view.id());
@ -1491,14 +1498,18 @@ Result RocksDBEngine::changeView(
rocksdb::WriteBatch batch;
rocksdb::WriteOptions wo; // TODO: check which options would make sense
rocksdb::Status s;
s = batch.PutLogData(log.slice());
if (!s.ok()) {
LOG_TOPIC(TRACE, Logger::VIEWS)
<< "failed to write change view marker " << s.ToString();
return rocksutils::convertStatus(s);
}
s = batch.Put(RocksDBColumnFamily::definitions(),
key.string(), value.string());
if (!s.ok()) {
LOG_TOPIC(TRACE, Logger::VIEWS)
<< "failed to write change view marker " << s.ToString();

View File

@ -1123,6 +1123,7 @@ static void JS_PropertiesVocbaseCol(
}
bool const isModification = (args.Length() != 0);
if (isModification) {
v8::Handle<v8::Value> par = args[0];
@ -1134,11 +1135,13 @@ static void JS_PropertiesVocbaseCol(
TRI_V8_THROW_EXCEPTION(res);
}
}
TRI_ASSERT(builder.isClosed());
Result res = methods::Collections::updateProperties(consoleColl, builder.slice());
auto res = methods::Collections::updateProperties(
*consoleColl, builder.slice(), false // always a full-update
);
if (res.fail() && ServerState::instance()->isCoordinator()) {
TRI_V8_THROW_EXCEPTION(res);
}
@ -1147,6 +1150,7 @@ static void JS_PropertiesVocbaseCol(
// TODO API compatibility, for now we ignore if persisting fails...
}
}
// in the cluster the collection object might contain outdated
// properties, which will break tests. We need an extra lookup
VPackBuilder builder;

View File

@ -381,7 +381,7 @@ static void JS_ViewVocbase(v8::FunctionCallbackInfo<v8::Value> const& args) {
viewBuilder.openObject();
auto res = view->toVelocyPack(viewBuilder, true, false);
auto res = view->properties(viewBuilder, true, false);
if (!res.ok()) {
TRI_V8_THROW_EXCEPTION(res); // skip view
@ -453,7 +453,7 @@ static void JS_ViewsVocbase(v8::FunctionCallbackInfo<v8::Value> const& args) {
viewBuilder.openObject();
if (!view->toVelocyPack(viewBuilder, true, false).ok()) {
if (!view->properties(viewBuilder, true, false).ok()) {
continue; // skip view
}
} catch(...) {
@ -563,24 +563,20 @@ static void JS_PropertiesViewVocbase(
builderCurrent.openObject();
auto resCurrent = viewPtr->toVelocyPack(builderCurrent, true, false);
auto resCurrent = viewPtr->properties(builderCurrent, true, false);
if (!resCurrent.ok()) {
TRI_V8_THROW_EXCEPTION(resCurrent);
}
}
auto doSync = arangodb::application_features::ApplicationServer::getFeature<
DatabaseFeature
>("Database")->forceSyncProperties();
auto view = resolver.getView(viewPtr->id()); // ensure have the latest definition
if (!view) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
}
auto res = view->updateProperties(builder.slice(), partialUpdate, doSync);
auto res = view->properties(builder.slice(), partialUpdate);
if (!res.ok()) {
TRI_V8_THROW_EXCEPTION_MESSAGE(res.errorNumber(), res.errorMessage());
@ -606,7 +602,7 @@ static void JS_PropertiesViewVocbase(
builder.openObject();
auto res = view->toVelocyPack(builder, true, false);
auto res = view->properties(builder, true, false);
builder.close();
@ -629,16 +625,6 @@ static void JS_RenameViewVocbase(
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
auto* databaseFeature = application_features::ApplicationServer::lookupFeature<
DatabaseFeature
>("Database");
if (!databaseFeature) {
TRI_V8_THROW_EXCEPTION_INTERNAL(
"failed to find feature 'Database' while renaming view"
);
}
if (args.Length() < 1) {
TRI_V8_THROW_EXCEPTION_USAGE("rename(<name>)");
}
@ -672,7 +658,7 @@ static void JS_RenameViewVocbase(
viewBuilder.openObject();
auto res = view->toVelocyPack(viewBuilder, true, false);
auto res = view->properties(viewBuilder, true, false);
if (!res.ok()) {
TRI_V8_THROW_EXCEPTION(res); // skip view
@ -681,8 +667,7 @@ static void JS_RenameViewVocbase(
TRI_V8_THROW_EXCEPTION(TRI_ERROR_INTERNAL); // skip view
}
auto res =
view->rename(std::string(name), databaseFeature->forceSyncProperties());
auto res = view->rename(std::string(name));
if (!res.ok()) {
TRI_V8_THROW_EXCEPTION(res);

View File

@ -1358,7 +1358,7 @@ static void MapGetVocBase(v8::Local<v8::String> const name,
// check if the collection is still alive
if (status != TRI_VOC_COL_STATUS_DELETED
&& cid > 0
&& collection->isLocal()) {
&& !ServerState::instance()->isCoordinator()) {
TRI_GET_GLOBAL_STRING(_IdKey);
TRI_GET_GLOBAL_STRING(VersionKeyHidden);
if (value->Has(_IdKey)) {

View File

@ -173,9 +173,7 @@ LogicalCollection::LogicalCollection(
info, "status", TRI_VOC_COL_STATUS_CORRUPTED)),
_isAStub(isAStub),
_isSmart(Helper::readBooleanValue(info, StaticStrings::IsSmart, false)),
_isLocal(!ServerState::instance()->isCoordinator()),
_waitForSync(Helper::readBooleanValue(info, StaticStrings::WaitForSyncString, false)),
_allowUserKeys(Helper::readBooleanValue(info, "allowUserKeys", true)),
_keyOptions(nullptr),
_keyGenerator(),
@ -228,7 +226,7 @@ LogicalCollection::LogicalCollection(
return category;
}
LogicalCollection::~LogicalCollection() {}
// SECTION: sharding
@ -409,8 +407,6 @@ TRI_voc_rid_t LogicalCollection::revision(transaction::Methods* trx) const {
return _physical->revision(trx);
}
bool LogicalCollection::isLocal() const { return _isLocal; }
bool LogicalCollection::waitForSync() const { return _waitForSync; }
bool LogicalCollection::isSmart() const { return _isSmart; }
@ -418,7 +414,7 @@ bool LogicalCollection::isSmart() const { return _isSmart; }
std::unique_ptr<FollowerInfo> const& LogicalCollection::followers() const {
return _followers;
}
std::unordered_map<std::string, double> LogicalCollection::clusterIndexEstimates(bool allowUpdate) {
return getPhysical()->clusterIndexEstimates(allowUpdate);
}
@ -456,10 +452,20 @@ bool LogicalCollection::allowUserKeys() const { return _allowUserKeys; }
// not fail. the WAL entry for the rename will be written *after* the call
// to "renameCollection" returns
Result LogicalCollection::rename(std::string&& newName, bool doSync) {
Result LogicalCollection::rename(std::string&& newName) {
// Should only be called from inside vocbase.
// Otherwise caching is destroyed.
TRI_ASSERT(!ServerState::instance()->isCoordinator()); // NOT YET IMPLEMENTED
auto* databaseFeature = application_features::ApplicationServer::lookupFeature<
DatabaseFeature
>("Database");
if (!databaseFeature) {
return Result(
TRI_ERROR_INTERNAL,
"failed to find feature 'Database' while renaming collection"
);
}
// Check for illegal states.
switch (_status) {
@ -484,6 +490,7 @@ Result LogicalCollection::rename(std::string&& newName, bool doSync) {
return TRI_ERROR_INTERNAL;
}
auto doSync = databaseFeature->forceSyncProperties();
std::string oldName = name();
// Okay we can finally rename safely
@ -616,7 +623,6 @@ arangodb::Result LogicalCollection::appendVelocyPack(
// with 'forPersistence' added by LogicalDataSource::toVelocyPack
// FIXME TODO is this needed in !forPersistence???
result.add(StaticStrings::DataSourceDeleted, VPackValue(deleted()));
result.add(StaticStrings::DataSourceGuid, VPackValue(guid()));
result.add(StaticStrings::DataSourceSystem, VPackValue(system()));
}
@ -628,11 +634,10 @@ arangodb::Result LogicalCollection::appendVelocyPack(
if (_keyGenerator != nullptr) {
result.openObject();
_keyGenerator->toVelocyPack(result);
result.close();
} else {
result.openArray();
result.close();
}
result.close();
// Physical Information
getPhysical()->getPropertiesVPack(result);
@ -677,7 +682,7 @@ VPackBuilder LogicalCollection::toVelocyPackIgnore(
bool forPersistence) const {
VPackBuilder full;
full.openObject();
toVelocyPack(full, translateCids, forPersistence);
properties(full, translateCids, forPersistence);
full.close();
return VPackCollection::remove(full.slice(), ignoreKeys);
}
@ -688,8 +693,10 @@ void LogicalCollection::includeVelocyPackEnterprise(VPackBuilder&) const {
void LogicalCollection::increaseInternalVersion() { ++_internalVersion; }
arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
bool doSync) {
arangodb::Result LogicalCollection::properties(
velocypack::Slice const& slice,
bool partialUpdate
) {
// the following collection properties are intentionally not updated,
// as updating them would be very complicated:
// - _cid
@ -699,6 +706,26 @@ arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
// - _isVolatile
// ... probably a few others missing here ...
auto* databaseFeature = application_features::ApplicationServer::lookupFeature<
DatabaseFeature
>("Database");
if (!databaseFeature) {
return Result(
TRI_ERROR_INTERNAL,
"failed to find feature 'Database' while updating collection"
);
}
auto* engine = EngineSelectorFeature::ENGINE;
if (!engine) {
return Result(
TRI_ERROR_INTERNAL,
"failed to find a storage engine while updating collection"
);
}
MUTEX_LOCKER(guard, _infoLock); // prevent simultanious updates
size_t rf = _sharding->replicationFactor();
@ -716,7 +743,8 @@ arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
return Result(TRI_ERROR_BAD_PARAMETER, "bad value for replicationFactor");
}
if (!_isLocal && rf != _sharding->replicationFactor()) { // sanity checks
if (ServerState::instance()->isCoordinator()
&& rf != _sharding->replicationFactor()) { // sanity checks
if (!_sharding->distributeShardsLike().empty()) {
return Result(TRI_ERROR_FORBIDDEN, "Cannot change replicationFactor, "
"please change " + _sharding->distributeShardsLike());
@ -750,6 +778,8 @@ arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
}
}
auto doSync = !engine->inRecovery() && databaseFeature->forceSyncProperties();
// The physical may first reject illegal properties.
// After this call it either has thrown or the properties are stored
Result res = getPhysical()->updateProperties(slice, doSync);
@ -761,15 +791,13 @@ arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
_waitForSync = Helper::getBooleanValue(slice, "waitForSync", _waitForSync);
_sharding->replicationFactor(rf);
if (!_isLocal) {
if (ServerState::instance()->isCoordinator()) {
// We need to inform the cluster as well
return ClusterInfo::instance()->setCollectionPropertiesCoordinator(
vocbase().name(), std::to_string(id()), this
);
}
StorageEngine* engine = EngineSelectorFeature::ENGINE;
engine->changeCollection(vocbase(), id(), *this, doSync);
if (DatabaseFeature::DATABASE != nullptr &&
@ -920,7 +948,7 @@ Result LogicalCollection::update(transaction::Methods* trx,
TRI_IF_FAILURE("LogicalCollection::update") {
return Result(TRI_ERROR_DEBUG);
}
resultMarkerTick = 0;
if (!newSlice.isObject()) {
return Result(TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID);
@ -1069,4 +1097,3 @@ ChecksumResult LogicalCollection::checksum(bool withRevisions, bool withData) co
return ChecksumResult(std::move(b));
}

View File

@ -141,7 +141,6 @@ class LogicalCollection : public LogicalDataSource {
// SECTION: Properties
TRI_voc_rid_t revision(transaction::Methods*) const;
bool isLocal() const;
bool waitForSync() const;
bool isSmart() const;
bool isAStub() const { return _isAStub; }
@ -216,7 +215,7 @@ class LogicalCollection : public LogicalDataSource {
void unload();
virtual arangodb::Result drop() override;
virtual Result rename(std::string&& name, bool doSync) override;
virtual Result rename(std::string&& name) override;
virtual void setStatus(TRI_vocbase_col_status_e);
// SECTION: Serialization
@ -234,7 +233,11 @@ class LogicalCollection : public LogicalDataSource {
bool allInSync) const;
// Update this collection.
virtual arangodb::Result updateProperties(velocypack::Slice const&, bool);
using LogicalDataSource::properties;
virtual arangodb::Result properties(
velocypack::Slice const& slice,
bool partialUpdate
) override;
/// @brief return the figures for a collection
virtual std::shared_ptr<velocypack::Builder> figures() const;
@ -375,8 +378,6 @@ class LogicalCollection : public LogicalDataSource {
bool _isSmart;
// SECTION: Properties
bool _isLocal;
bool _waitForSync;
bool const _allowUserKeys;
@ -402,4 +403,4 @@ class LogicalCollection : public LogicalDataSource {
} // namespace arangodb
#endif
#endif

View File

@ -209,7 +209,7 @@ LogicalDataSource::LogicalDataSource(
TRI_ASSERT(!_guid.empty());
}
Result LogicalDataSource::toVelocyPack(
Result LogicalDataSource::properties(
velocypack::Builder& builder,
bool detailed,
bool forPersistence
@ -221,6 +221,7 @@ Result LogicalDataSource::toVelocyPack(
);
}
builder.add(StaticStrings::DataSourceGuid, toValuePair(guid())); // required for dump/restore
builder.add(
StaticStrings::DataSourceId,
velocypack::Value(std::to_string(id()))
@ -232,7 +233,6 @@ Result LogicalDataSource::toVelocyPack(
// includeSystem if we are persisting the properties
if (forPersistence) {
builder.add(StaticStrings::DataSourceDeleted, velocypack::Value(deleted()));
builder.add(StaticStrings::DataSourceGuid, toValuePair(guid()));
builder.add(StaticStrings::DataSourceSystem, velocypack::Value(system()));
// FIXME not sure if the following is relevant
@ -250,4 +250,4 @@ Result LogicalDataSource::toVelocyPack(
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -139,9 +139,7 @@ class LogicalDataSource {
std::string const& name() const noexcept { return _name; }
TRI_voc_cid_t planId() const noexcept { return _planId; }
uint64_t planVersion() const noexcept { return _planVersion; }
virtual Result rename(std::string&& newName, bool doSync) = 0;
bool system() const noexcept { return _system; }
//////////////////////////////////////////////////////////////////////////////
/// @brief append a jSON definition of the data-source to the 'builder'
/// @param the buffer to append to, must be an open object
@ -151,12 +149,24 @@ class LogicalDataSource {
/// @param forPersistence this definition is meant to be persisted
/// @return success
//////////////////////////////////////////////////////////////////////////////
Result toVelocyPack(
Result properties(
velocypack::Builder& builder,
bool detailed,
bool forPersistence
) const /*final*/;
) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief updates properties of an existing DataSource
/// @param definition the properties being updated
/// @param partialUpdate modify only the specified properties (false == all)
//////////////////////////////////////////////////////////////////////////////
virtual Result properties(
velocypack::Slice const& definition,
bool partialUpdate
) = 0;
virtual Result rename(std::string&& newName) = 0;
bool system() const noexcept { return _system; }
Type const& type() const noexcept { return _type; }
TRI_vocbase_t& vocbase() const noexcept { return _vocbase; }

View File

@ -29,6 +29,7 @@
#include "Basics/VelocyPackHelper.h"
#include "Cluster/ClusterInfo.h"
#include "Cluster/ServerState.h"
#include "RestServer/DatabaseFeature.h"
#include "RestServer/ViewTypesFeature.h"
#include "StorageEngine/EngineSelectorFeature.h"
#include "StorageEngine/StorageEngine.h"
@ -267,9 +268,9 @@ arangodb::Result LogicalViewClusterInfo::drop() {
return arangodb::Result();
}
arangodb::Result LogicalViewClusterInfo::rename(std::string&&, bool) {
arangodb::Result LogicalViewClusterInfo::rename(std::string&&) {
// renaming a view in a cluster is unsupported
return TRI_ERROR_NOT_IMPLEMENTED;
return TRI_ERROR_CLUSTER_UNSUPPORTED;
}
// -----------------------------------------------------------------------------
@ -376,10 +377,29 @@ arangodb::Result LogicalViewStorageEngine::drop() {
return arangodb::Result();
}
Result LogicalViewStorageEngine::rename(std::string&& newName, bool doSync) {
Result LogicalViewStorageEngine::rename(std::string&& newName) {
TRI_ASSERT(!ServerState::instance()->isCoordinator());
auto* databaseFeature = application_features::ApplicationServer::lookupFeature<
DatabaseFeature
>("Database");
if (!databaseFeature) {
return Result(
TRI_ERROR_INTERNAL,
"failed to find feature 'Database' while renaming view"
);
}
StorageEngine* engine = EngineSelectorFeature::ENGINE;
TRI_ASSERT(engine);
if (!engine) {
return Result(
TRI_ERROR_INTERNAL,
"failed to find a storage engine while renaming view"
);
}
auto doSync = databaseFeature->forceSyncProperties();
auto oldName = name();
auto res = vocbase().renameView(id(), newName);
@ -414,13 +434,32 @@ Result LogicalViewStorageEngine::rename(std::string&& newName, bool doSync) {
return TRI_ERROR_NO_ERROR;
}
arangodb::Result LogicalViewStorageEngine::updateProperties(
arangodb::Result LogicalViewStorageEngine::properties(
VPackSlice const& slice,
bool partialUpdate,
bool doSync
bool partialUpdate
) {
TRI_ASSERT(!ServerState::instance()->isCoordinator());
auto* databaseFeature = application_features::ApplicationServer::lookupFeature<
DatabaseFeature
>("Database");
if (!databaseFeature) {
return Result(
TRI_ERROR_INTERNAL,
"failed to find feature 'Database' while updating collection"
);
}
auto* engine = EngineSelectorFeature::ENGINE;
if (!engine) {
return Result(
TRI_ERROR_INTERNAL,
"failed to find a storage engine while updating collection"
);
}
auto res = updateProperties(slice, partialUpdate);
if (!res.ok()) {
@ -431,10 +470,9 @@ arangodb::Result LogicalViewStorageEngine::updateProperties(
LOG_TOPIC(DEBUG, Logger::VIEWS) << "updated view with properties '"
<< slice.toJson() << "'";
// after this call the properties are stored
StorageEngine* engine = EngineSelectorFeature::ENGINE;
TRI_ASSERT(engine);
auto doSync = !engine->inRecovery() && databaseFeature->forceSyncProperties();
// after this call the properties are stored
if (engine->inRecovery()) {
return arangodb::Result(); // do not modify engine while in recovery
}

View File

@ -150,6 +150,15 @@ class LogicalView : public LogicalDataSource {
uint64_t planVersion = 0 // '0' by default for non-cluster
);
//////////////////////////////////////////////////////////////////////////////
/// @brief updates properties of an existing view
//////////////////////////////////////////////////////////////////////////////
using LogicalDataSource::properties;
virtual arangodb::Result properties(
velocypack::Slice const& properties,
bool partialUpdate
) override = 0;
//////////////////////////////////////////////////////////////////////////////
/// @brief opens an existing view when the server is restarted
//////////////////////////////////////////////////////////////////////////////
@ -163,19 +172,7 @@ class LogicalView : public LogicalDataSource {
//////////////////////////////////////////////////////////////////////////////
/// @brief renames an existing view
//////////////////////////////////////////////////////////////////////////////
virtual Result rename(
std::string&& newName,
bool doSync
) override = 0;
//////////////////////////////////////////////////////////////////////////////
/// @brief updates properties of an existing view
//////////////////////////////////////////////////////////////////////////////
virtual arangodb::Result updateProperties(
velocypack::Slice const& properties,
bool partialUpdate,
bool doSync
) = 0;
virtual Result rename(std::string&& newName) override = 0;
//////////////////////////////////////////////////////////////////////////////
/// @brief invoke visitor on all collections that a view will return
@ -204,7 +201,7 @@ class LogicalView : public LogicalDataSource {
class LogicalViewClusterInfo: public LogicalView {
public:
virtual Result drop() override final;
virtual Result rename(std::string&& newName, bool doSync) override final;
virtual Result rename(std::string&& newName) override final;
protected:
LogicalViewClusterInfo(
@ -242,14 +239,15 @@ class LogicalViewStorageEngine: public LogicalView {
~LogicalViewStorageEngine() override;
virtual Result drop() override final;
virtual Result rename(std::string&& newName, bool doSync) override final;
arangodb::Result updateProperties(
using LogicalDataSource::properties;
virtual arangodb::Result properties(
velocypack::Slice const& properties,
bool partialUpdate,
bool doSync
bool partialUpdate
) override final;
virtual Result rename(std::string&& newName) override final;
protected:
LogicalViewStorageEngine(
TRI_vocbase_t& vocbase,

View File

@ -382,11 +382,16 @@ Result Collections::properties(Context& ctxt, VPackBuilder& builder) {
return TRI_ERROR_NO_ERROR;
}
Result Collections::updateProperties(LogicalCollection* coll,
VPackSlice const& props) {
Result Collections::updateProperties(
LogicalCollection& collection,
velocypack::Slice const& props,
bool partialUpdate
) {
ExecContext const* exec = ExecContext::CURRENT;
if (exec != nullptr) {
bool canModify = exec->canUseCollection(coll->name(), auth::Level::RW);
bool canModify = exec->canUseCollection(collection.name(), auth::Level::RW);
if ((exec->databaseAuthLevel() != auth::Level::RW || !canModify)) {
return TRI_ERROR_FORBIDDEN;
}
@ -394,17 +399,17 @@ Result Collections::updateProperties(LogicalCollection* coll,
if (ServerState::instance()->isCoordinator()) {
ClusterInfo* ci = ClusterInfo::instance();
auto info = ci->getCollection(
collection.vocbase().name(), std::to_string(collection.id())
);
TRI_ASSERT(coll);
auto info =
ci->getCollection(coll->vocbase().name(), std::to_string(coll->id()));
return info->updateProperties(props, false);
return info->properties(props, partialUpdate);
} else {
auto ctx =
transaction::V8Context::CreateWhenRequired(coll->vocbase(), false);
SingleCollectionTransaction trx(ctx, *coll, AccessMode::Type::EXCLUSIVE);
transaction::V8Context::CreateWhenRequired(collection.vocbase(), false);
SingleCollectionTransaction trx(
ctx, collection, AccessMode::Type::EXCLUSIVE
);
Result res = trx.begin();
if (!res.ok()) {
@ -412,15 +417,15 @@ Result Collections::updateProperties(LogicalCollection* coll,
}
// try to write new parameter to file
bool doSync = DatabaseFeature::DATABASE->forceSyncProperties();
arangodb::Result updateRes = coll->updateProperties(props, doSync);
auto updateRes = collection.properties(props, partialUpdate);
if (!updateRes.ok()) {
return updateRes;
}
auto physical = coll->getPhysical();
auto physical = collection.getPhysical();
TRI_ASSERT(physical != nullptr);
return physical->persistProperties();
}
}
@ -628,7 +633,7 @@ Result Collections::revisionId(Context& ctxt, TRI_voc_rid_t& rid) {
arangodb::aql::Query query(false, vocbase, aql::QueryString(q), binds,
std::make_shared<VPackBuilder>(),
arangodb::aql::PART_MAIN);
auto queryRegistry = QueryRegistryFeature::registry();;
auto queryRegistry = QueryRegistryFeature::registry();
TRI_ASSERT(queryRegistry != nullptr);
aql::QueryResult queryResult = query.executeSync(queryRegistry);

View File

@ -85,8 +85,11 @@ struct Collections {
static Result unload(TRI_vocbase_t* vocbase, LogicalCollection* coll);
static Result properties(Context& ctxt, velocypack::Builder&);
static Result updateProperties(LogicalCollection* coll,
velocypack::Slice const&);
static Result updateProperties(
LogicalCollection& collection,
velocypack::Slice const& props,
bool partialUpdate
);
static Result rename(LogicalCollection* coll, std::string const& newName,
bool doOverride);

View File

@ -811,16 +811,12 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection,
collection->deleted(true);
StorageEngine* engine = EngineSelectorFeature::ENGINE;
bool doSync =
!engine->inRecovery() &&
application_features::ApplicationServer::getFeature<DatabaseFeature>(
"Database")
->forceSyncProperties();
VPackBuilder builder;
engine->getCollectionInfo(*this, collection->id(), builder, false, 0);
arangodb::Result res = collection->updateProperties(
builder.slice().get("parameters"), doSync);
auto res =
collection->properties(builder.slice().get("parameters"), false); // always a full-update
if (!res.ok()) {
return res.errorNumber();
@ -1032,25 +1028,18 @@ void TRI_vocbase_t::inventory(
result.close(); // </collection>
result.add("views", VPackValue(VPackValueType::Array, true));
if (ServerState::instance()->isCoordinator()) {
auto views = ClusterInfo::instance()->getViews(name());
for (auto const& view : views) {
result.openObject();
view->toVelocyPack(result, /*details*/true, /*forPersistence*/false);
result.close();
}
} else {
for (auto const& dataSource : dataSourceById) {
if (dataSource.second->category() != LogicalView::category()) {
continue;
LogicalView::enumerate(
*this,
[&result](LogicalView::ptr const& view)->bool {
if (view) {
result.openObject();
view->properties(result, true, false); // details, !forPersistence because on restore any datasource ids will differ, so need an end-user representation
result.close();
}
return true;
}
LogicalView const* view = static_cast<LogicalView*>(dataSource.second.get());
result.openObject();
view->toVelocyPack(result, /*details*/true, /*forPersistence*/false);
result.add(StaticStrings::DataSourceGuid, VPackValue(view->guid()));
result.close();
}
}
);
result.close(); // </views>
}
@ -1519,11 +1508,7 @@ arangodb::Result TRI_vocbase_t::renameCollection(
TRI_ASSERT(std::dynamic_pointer_cast<arangodb::LogicalCollection>(itr1->second));
auto* databaseFeature =
application_features::ApplicationServer::getFeature<DatabaseFeature>("Database");
TRI_ASSERT(databaseFeature);
auto doSync = databaseFeature->forceSyncProperties();
auto res = itr1->second->rename(std::string(newName), doSync);
auto res = itr1->second->rename(std::string(newName));
if (!res.ok()) {
return res.errorNumber(); // rename failed

View File

@ -210,6 +210,7 @@ ArangoView.prototype.properties = function (properties, partialUpdate) {
const mask = {
'code': true,
'globallyUniqueId': true,
'id': true,
'name': true,
'type': true,

View File

@ -229,7 +229,7 @@ static inline v8::Handle<v8::String> v8Utf8StringFactory(v8::Isolate* isolate, v
/// @brief "not yet implemented" handler for sharding
#define TRI_THROW_SHARDING_COLLECTION_NOT_YET_IMPLEMENTED(collection) \
if (collection != nullptr && !collection->isLocal()) { \
if (collection && ServerState::instance()->isCoordinator()) { \
TRI_V8_THROW_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED); \
}
@ -746,4 +746,4 @@ void TRI_AddGlobalVariableVocbase(v8::Isolate* isolate,
v8::Handle<v8::String> name,
v8::Handle<v8::Value> value);
#endif
#endif

View File

@ -39,6 +39,7 @@
#include "IResearch/IResearchFeature.h"
#include "Logger/Logger.h"
#include "RestServer/AqlFeature.h"
#include "RestServer/DatabaseFeature.h"
#include "RestServer/DatabasePathFeature.h"
#include "RestServer/QueryRegistryFeature.h"
#include "RestServer/SystemDatabaseFeature.h"
@ -149,6 +150,7 @@ struct IResearchIndexSetup {
// setup required application features
features.emplace_back(new arangodb::AqlFeature(server), true); // required for arangodb::aql::Query(...)
features.emplace_back(new arangodb::DatabaseFeature(server), false); // required for LogicalViewStorageEngine::modify(...)
features.emplace_back(new arangodb::DatabasePathFeature(server), false); // requires for IResearchView::open()
features.emplace_back(new arangodb::ShardingFeature(server), false);
features.emplace_back(new arangodb::ViewTypesFeature(server), true); // required by TRI_vocbase_t::createView(...)
@ -267,10 +269,10 @@ SECTION("test_analyzer") {
} } \
} }");
CHECK((viewImpl->updateProperties(updateJson->slice(), false, false).ok()));
CHECK((viewImpl->properties(updateJson->slice(), false).ok()));
}
// docs match from both collections (2 analyzers used for collectio0, 1 analyzer used for collection 1)
// docs match from both collections (2 analyzers used for collection0, 1 analyzer used for collection 1)
{
auto result = arangodb::tests::executeQuery(
vocbase,
@ -293,7 +295,7 @@ SECTION("test_analyzer") {
CHECK((i == expected.size()));
}
// docs match from both collections (2 analyzers used for collectio0, 1 analyzer used for collection 1)
// docs match from both collections (2 analyzers used for collection0, 1 analyzer used for collection 1)
{
auto result = arangodb::tests::executeQuery(
vocbase,
@ -316,7 +318,7 @@ SECTION("test_analyzer") {
CHECK((i == expected.size()));
}
// docs match from both collections (2 analyzers used for collectio0, 1 analyzer used for collection 1)
// docs match from both collections (2 analyzers used for collection0, 1 analyzer used for collection 1)
{
auto result = arangodb::tests::executeQuery(
vocbase,
@ -498,7 +500,7 @@ SECTION("test_async_index") {
} } \
} }");
CHECK((viewImpl->updateProperties(updateJson->slice(), false, false).ok()));
CHECK((viewImpl->properties(updateJson->slice(), false).ok()));
}
// `catch` doesn't support cuncurrent checks
@ -872,7 +874,7 @@ SECTION("test_fields") {
} } \
} }");
CHECK((viewImpl->updateProperties(updateJson->slice(), false, false).ok()));
CHECK((viewImpl->properties(updateJson->slice(), false).ok()));
}
// docs match from both collections

View File

@ -262,7 +262,7 @@ TEST_CASE("IResearchQueryTestAggregate", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"includeAllFields\": true }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -262,7 +262,7 @@ TEST_CASE("IResearchQueryTestAnd", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"analyzers\": [ \"test_analyzer\", \"identity\" ], \"includeAllFields\": true, \"storeValues\":\"id\" }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -270,7 +270,7 @@ TEST_CASE("IResearchQueryTestBooleanTerm", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"includeAllFields\": true }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -272,7 +272,7 @@ TEST_CASE("IResearchQueryTestComplexBoolean", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"includeAllFields\": true, \"analyzers\": [ \"test_analyzer\", \"identity\" ], \"storeValues\":\"id\" }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -264,7 +264,7 @@ TEST_CASE("IResearchQueryTestExists", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"includeAllFields\": true, \"storeValues\": \"id\" }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));
@ -1522,7 +1522,7 @@ TEST_CASE("IResearchQueryTestExistsStoreMaskPartially", "[iresearch][iresearch-q
"\"testCollection1\": { \"includeAllFields\": true, \"storeValues\": \"id\" }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -98,6 +98,7 @@ struct IResearchQueryInSetup {
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(server), true);
features.emplace_back(new arangodb::AuthenticationFeature(server), true);
features.emplace_back(new arangodb::DatabaseFeature(server), false); // required for LogicalViewStorageEngine::modify(...)
features.emplace_back(new arangodb::DatabasePathFeature(server), false);
features.emplace_back(new arangodb::ShardingFeature(server), false);
features.emplace_back(new arangodb::QueryRegistryFeature(server), false); // must be first
@ -262,7 +263,7 @@ TEST_CASE("IResearchQueryTestIn", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"includeAllFields\": true }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -372,12 +372,12 @@ TEST_CASE("IResearchQueryTestJoinDuplicateDataSource", "[iresearch][iresearch-qu
"\"collection_2\": { \"analyzers\": [ \"test_analyzer\", \"identity\" ], \"includeAllFields\": true }"
"}}"
);
CHECK((view->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((view->properties(updateJson->slice(), true).ok()));
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
@ -522,12 +522,12 @@ TEST_CASE("IResearchQueryTestJoin", "[iresearch][iresearch-query]") {
"\"collection_2\": { \"analyzers\": [ \"test_analyzer\", \"identity\" ], \"includeAllFields\": true }"
"}}"
);
CHECK((view->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((view->properties(updateJson->slice(), true).ok()));
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();

View File

@ -268,7 +268,7 @@ TEST_CASE("IResearchQueryTestNullTerm", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"includeAllFields\": true }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -226,12 +226,12 @@ TEST_CASE("IResearchQueryTestNumericTerm", "[iresearch][iresearch-query]") {
"\"collection_2\" : { \"includeAllFields\" : true }"
"}}"
);
CHECK((view->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((view->properties(updateJson->slice(), true).ok()));
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();

View File

@ -227,12 +227,12 @@ TEST_CASE("IResearchQueryTestOr", "[iresearch][iresearch-query]") {
"\"collection_2\": { \"analyzers\": [ \"test_analyzer\", \"identity\" ], \"includeAllFields\": true, \"storeValues\":\"id\" }"
"}}"
);
CHECK((view->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((view->properties(updateJson->slice(), true).ok()));
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();

View File

@ -272,7 +272,7 @@ TEST_CASE("IResearchQueryTestPhrase", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"analyzers\": [ \"test_analyzer\", \"identity\" ], \"includeAllFields\": true }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -217,12 +217,12 @@ TEST_CASE("IResearchQueryTestSelectAll", "[iresearch][iresearch-query]") {
"\"collection_2\" : { \"includeAllFields\" : true }"
"}}"
);
CHECK((view->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((view->properties(updateJson->slice(), true).ok()));
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();

View File

@ -217,12 +217,12 @@ TEST_CASE("IResearchQueryTestStartsWith", "[iresearch][iresearch-query]") {
"\"collection_2\" : { \"includeAllFields\" : true }"
"}}"
);
CHECK((view->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((view->properties(updateJson->slice(), true).ok()));
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();

View File

@ -257,12 +257,12 @@ TEST_CASE("IResearchQueryTestStringTerm", "[iresearch][iresearch-query]") {
"\"collection_2\" : { \"includeAllFields\" : true }"
"}}"
);
CHECK((view->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((view->properties(updateJson->slice(), true).ok()));
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();

View File

@ -270,7 +270,7 @@ TEST_CASE("IResearchQueryTestTokens", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"includeAllFields\": true }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -303,7 +303,7 @@ TEST_CASE("IResearchQueryTestTraversal", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"includeAllFields\": true }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

View File

@ -262,7 +262,7 @@ TEST_CASE("IResearchQueryTestValue", "[iresearch][iresearch-query]") {
"\"testCollection1\": { \"includeAllFields\": true }"
"}}"
);
CHECK((impl->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((impl->properties(updateJson->slice(), true).ok()));
std::set<TRI_voc_cid_t> cids;
impl->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
CHECK((2 == cids.size()));

File diff suppressed because it is too large Load Diff

View File

@ -273,9 +273,9 @@ SECTION("test_rename") {
CHECK(arangodb::LogicalView::category() == view->category());
CHECK(&vocbase == &view->vocbase());
auto const res = view->rename("otherName", true);
auto const res = view->rename("otherName");
CHECK(res.fail());
CHECK(TRI_ERROR_NOT_IMPLEMENTED == res.errorNumber());
CHECK(TRI_ERROR_CLUSTER_UNSUPPORTED == res.errorNumber());
}
SECTION("visit_collections") {
@ -356,7 +356,7 @@ SECTION("test_defaults") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, true);
view->properties(builder, true, true);
builder.close();
auto slice = builder.slice();
arangodb::iresearch::IResearchViewMeta meta;
@ -379,13 +379,14 @@ SECTION("test_defaults") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((10U == slice.length()));
CHECK((11U == slice.length()));
CHECK((slice.hasKey("globallyUniqueId") && slice.get("globallyUniqueId").isString() && false == slice.get("globallyUniqueId").copyString().empty()));
CHECK((slice.get("id").copyString() == "1"));
CHECK((slice.get("name").copyString() == "testView"));
CHECK((slice.get("type").copyString() == arangodb::iresearch::DATA_SOURCE_TYPE.name()));
@ -399,13 +400,14 @@ SECTION("test_defaults") {
{
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->properties(builder, false, false);
builder.close();
auto slice = builder.slice();
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((3 == slice.length()));
CHECK((4U == slice.length()));
CHECK((slice.hasKey("globallyUniqueId") && slice.get("globallyUniqueId").isString() && false == slice.get("globallyUniqueId").copyString().empty()));
CHECK((slice.get("id").copyString() == "1"));
CHECK((slice.get("name").copyString() == "testView"));
CHECK((slice.get("type").copyString() == arangodb::iresearch::DATA_SOURCE_TYPE.name()));
@ -418,7 +420,7 @@ SECTION("test_defaults") {
{
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, true);
view->properties(builder, false, true);
builder.close();
auto slice = builder.slice();
@ -744,7 +746,7 @@ SECTION("test_drop_with_link") {
CHECK(arangodb::AgencyComm().setValue(path, value->slice(), 0.0).successful());
}
CHECK((logicalView->updateProperties(viewUpdateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(viewUpdateJson->slice(), true).ok()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -856,7 +858,7 @@ SECTION("test_update_properties") {
{
VPackBuilder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
arangodb::iresearch::IResearchViewMeta meta;
@ -871,7 +873,7 @@ SECTION("test_update_properties") {
// update properties - full update
{
auto props = arangodb::velocypack::Parser::fromJson("{ \"cleanupIntervalStep\": 42, \"consolidationIntervalMsec\": 50 }");
CHECK(view->updateProperties(props->slice(), false, true).ok());
CHECK(view->properties(props->slice(), false).ok());
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
@ -891,7 +893,7 @@ SECTION("test_update_properties") {
{
VPackBuilder builder;
builder.openObject();
fullyUpdatedView->toVelocyPack(builder, true, false);
fullyUpdatedView->properties(builder, true, false);
builder.close();
arangodb::iresearch::IResearchViewMeta meta;
@ -908,7 +910,7 @@ SECTION("test_update_properties") {
{
VPackBuilder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
arangodb::iresearch::IResearchViewMeta meta;
@ -922,7 +924,7 @@ SECTION("test_update_properties") {
// partially update properties
{
auto props = arangodb::velocypack::Parser::fromJson("{ \"consolidationIntervalMsec\": 42 }");
CHECK(fullyUpdatedView->updateProperties(props->slice(), true, true).ok());
CHECK(fullyUpdatedView->properties(props->slice(), true).ok());
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
@ -942,7 +944,7 @@ SECTION("test_update_properties") {
{
VPackBuilder builder;
builder.openObject();
partiallyUpdatedView->toVelocyPack(builder, true, false);
partiallyUpdatedView->properties(builder, true, false);
builder.close();
arangodb::iresearch::IResearchViewMeta meta;
@ -1082,7 +1084,7 @@ SECTION("test_update_links_partial_remove") {
" \"testCollection3\" : { \"id\": \"3\" } "
"} }"
);
CHECK(view->updateProperties(linksJson->slice(), true, true).ok()); // add links
CHECK(view->properties(linksJson->slice(), true).ok()); // add links
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
auto oldView = view;
@ -1115,7 +1117,7 @@ SECTION("test_update_links_partial_remove") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -1307,7 +1309,7 @@ SECTION("test_update_links_partial_remove") {
CHECK(0 < slice.get("figures").get("memory").getUInt());
}
CHECK(view->updateProperties(linksJson->slice(), true, true).ok()); // same properties -> should not affect plan version
CHECK(view->properties(linksJson->slice(), true).ok()); // same properties -> should not affect plan version
CHECK(planVersion == arangodb::tests::getCurrentPlanVersion()); // plan did't change version
// remove testCollection2 link
@ -1322,7 +1324,7 @@ SECTION("test_update_links_partial_remove") {
" \"2\" : null "
"} }"
);
CHECK(view->updateProperties(updateJson->slice(), true, true).ok());
CHECK(view->properties(updateJson->slice(), true).ok());
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
oldView = view;
@ -1354,7 +1356,7 @@ SECTION("test_update_links_partial_remove") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -1642,7 +1644,7 @@ SECTION("test_update_links_partial_add") {
" \"testCollection3\" : { \"id\": \"3\" } "
"} }"
);
CHECK(view->updateProperties(linksJson->slice(), true, true).ok()); // add links
CHECK(view->properties(linksJson->slice(), true).ok()); // add links
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
auto oldView = view;
@ -1674,7 +1676,7 @@ SECTION("test_update_links_partial_add") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -1806,7 +1808,7 @@ SECTION("test_update_links_partial_add") {
CHECK(0 < slice.get("figures").get("memory").getUInt());
}
CHECK(view->updateProperties(linksJson->slice(), true, true).ok()); // same properties -> should not affect plan version
CHECK(view->properties(linksJson->slice(), true).ok()); // same properties -> should not affect plan version
CHECK(planVersion == arangodb::tests::getCurrentPlanVersion()); // plan did't change version
// remove testCollection2 link
@ -1821,7 +1823,7 @@ SECTION("test_update_links_partial_add") {
" \"2\" : { \"id\": \"2\", \"trackListPositions\" : true } "
"} }"
);
CHECK(view->updateProperties(updateJson->slice(), true, true).ok());
CHECK(view->properties(updateJson->slice(), true).ok());
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
oldView = view;
@ -1854,7 +1856,7 @@ SECTION("test_update_links_partial_add") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -2051,7 +2053,7 @@ SECTION("test_update_links_partial_add") {
// partial update - empty delta
{
auto const updateJson = arangodb::velocypack::Parser::fromJson("{ }");
CHECK(view->updateProperties(updateJson->slice(), true, true).ok()); // empty properties -> should not affect plan version
CHECK(view->properties(updateJson->slice(), true).ok()); // empty properties -> should not affect plan version
CHECK(planVersion == arangodb::tests::getCurrentPlanVersion()); // plan did't change version
}
@ -2128,7 +2130,7 @@ SECTION("test_update_links_partial_add") {
userManager->setQueryRegistry(&queryRegistry);
auto resetUserManager = irs::make_finally([userManager]()->void{ userManager->removeAllUsers(); });
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(linksJson->slice(), true, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(linksJson->slice(), true).errorNumber()));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection1));
logicalView = ci->getView(vocbase->name(), viewId); // get new version of the view
@ -2250,7 +2252,7 @@ SECTION("test_update_links_replace") {
" \"testCollection3\" : { \"id\": \"3\" } "
"} }"
);
CHECK(view->updateProperties(linksJson->slice(), false, true).ok()); // add link
CHECK(view->properties(linksJson->slice(), false).ok()); // add link
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
auto oldView = view;
@ -2282,7 +2284,7 @@ SECTION("test_update_links_replace") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -2414,10 +2416,10 @@ SECTION("test_update_links_replace") {
CHECK(0 < slice.get("figures").get("memory").getUInt());
}
CHECK(view->updateProperties(linksJson->slice(), false, true).ok()); // same properties -> should not affect plan version
CHECK(view->properties(linksJson->slice(), false).ok()); // same properties -> should not affect plan version
CHECK(planVersion == arangodb::tests::getCurrentPlanVersion()); // plan did't change version
CHECK(view->updateProperties(linksJson->slice(), true, true).ok()); // same properties -> should not affect plan version
CHECK(view->properties(linksJson->slice(), true).ok()); // same properties -> should not affect plan version
CHECK(planVersion == arangodb::tests::getCurrentPlanVersion()); // plan did't change version
// replace links with testCollection2 link
@ -2440,7 +2442,7 @@ SECTION("test_update_links_replace") {
" \"2\" : { \"id\": \"2\", \"trackListPositions\" : true } "
"} }"
);
CHECK(view->updateProperties(updateJson->slice(), false, true).ok());
CHECK(view->properties(updateJson->slice(), false).ok());
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
oldView = view;
@ -2471,7 +2473,7 @@ SECTION("test_update_links_replace") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -2562,7 +2564,7 @@ SECTION("test_update_links_replace") {
" \"2\" : null "
"} }"
);
CHECK(view->updateProperties(updateJson->slice(), false, true).ok());
CHECK(view->properties(updateJson->slice(), false).ok());
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
oldView = view;
@ -2593,7 +2595,7 @@ SECTION("test_update_links_replace") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -2823,7 +2825,7 @@ SECTION("test_update_links_clear") {
" \"testCollection3\" : { \"id\": \"3\" } "
"} }"
);
CHECK(view->updateProperties(linksJson->slice(), false, true).ok()); // add link
CHECK(view->properties(linksJson->slice(), false).ok()); // add link
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
auto oldView = view;
@ -2856,7 +2858,7 @@ SECTION("test_update_links_clear") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -3049,10 +3051,10 @@ SECTION("test_update_links_clear") {
CHECK(0 < slice.get("figures").get("memory").getUInt());
}
CHECK(view->updateProperties(linksJson->slice(), false, true).ok()); // same properties -> should not affect plan version
CHECK(view->properties(linksJson->slice(), false).ok()); // same properties -> should not affect plan version
CHECK(planVersion == arangodb::tests::getCurrentPlanVersion()); // plan did't change version
CHECK(view->updateProperties(linksJson->slice(), true, true).ok()); // same properties -> should not affect plan version
CHECK(view->properties(linksJson->slice(), true).ok()); // same properties -> should not affect plan version
CHECK(planVersion == arangodb::tests::getCurrentPlanVersion()); // plan did't change version
// remove all links
@ -3071,7 +3073,7 @@ SECTION("test_update_links_clear") {
}
auto const updateJson = arangodb::velocypack::Parser::fromJson("{ \"links\": {} }");
CHECK(view->updateProperties(updateJson->slice(), false, true).ok());
CHECK(view->properties(updateJson->slice(), false).ok());
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
oldView = view;
@ -3098,7 +3100,7 @@ SECTION("test_update_links_clear") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -3211,7 +3213,7 @@ SECTION("test_drop_link") {
}
auto linksJson = arangodb::velocypack::Parser::fromJson("{ \"links\": { \"testCollection\" : { \"includeAllFields\" : true } } }");
CHECK(view->updateProperties(linksJson->slice(), true, true).ok()); // add link
CHECK(view->properties(linksJson->slice(), true).ok()); // add link
CHECK(planVersion < arangodb::tests::getCurrentPlanVersion()); // plan version changed
planVersion = arangodb::tests::getCurrentPlanVersion();
@ -3241,7 +3243,7 @@ SECTION("test_drop_link") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -3318,7 +3320,7 @@ SECTION("test_drop_link") {
CHECK(0 < slice.get("figures").get("memory").getUInt());
}
CHECK(view->updateProperties(linksJson->slice(), true, true).ok()); // same properties -> should not affect plan version
CHECK(view->properties(linksJson->slice(), true).ok()); // same properties -> should not affect plan version
CHECK(planVersion == arangodb::tests::getCurrentPlanVersion()); // plan did't change version
// simulate heartbeat thread (drop index from current)
@ -3353,7 +3355,7 @@ SECTION("test_drop_link") {
{
VPackBuilder info;
info.openObject();
view->toVelocyPack(info, true, false);
view->properties(info, true, false);
info.close();
auto const properties = info.slice();
@ -3410,7 +3412,7 @@ SECTION("test_drop_link") {
userManager->setQueryRegistry(&queryRegistry);
auto resetUserManager = irs::make_finally([userManager]()->void{ userManager->removeAllUsers(); });
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), false, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), false).errorNumber()));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection1));
logicalView = ci->getView(vocbase->name(), viewId); // get new version of the view
@ -3462,14 +3464,14 @@ SECTION("test_update_overwrite") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
expectedMeta._cleanupIntervalStep = 10;
CHECK((TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND == logicalView->updateProperties(viewUpdateJson->slice(), false, false).errorNumber()));
CHECK((TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND == logicalView->properties(viewUpdateJson->slice(), false).errorNumber()));
logicalView = ci->getView(vocbase->name(), viewId);
REQUIRE((false == !logicalView));
CHECK((true == logicalView->visitCollections([](TRI_voc_cid_t)->bool { return false; })));
arangodb::velocypack::Builder builder;
builder.openObject();
logicalView->toVelocyPack(builder, true, true); // 'forPersistence' to avoid auth check
logicalView->properties(builder, true, true); // 'forPersistence' to avoid auth check
builder.close();
auto slice = builder.slice();
@ -3505,14 +3507,14 @@ SECTION("test_update_overwrite") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
expectedMeta._cleanupIntervalStep = 10;
CHECK((TRI_ERROR_BAD_PARAMETER == logicalView->updateProperties(viewUpdateJson->slice(), false, false).errorNumber()));
CHECK((TRI_ERROR_BAD_PARAMETER == logicalView->properties(viewUpdateJson->slice(), false).errorNumber()));
logicalView = ci->getView(vocbase->name(), viewId);
REQUIRE((false == !logicalView));
CHECK((true == logicalView->visitCollections([](TRI_voc_cid_t)->bool { return false; })));
arangodb::velocypack::Builder builder;
builder.openObject();
logicalView->toVelocyPack(builder, true, true); // 'forPersistence' to avoid auth check
logicalView->properties(builder, true, true); // 'forPersistence' to avoid auth check
builder.close();
auto slice = builder.slice();
@ -3555,7 +3557,7 @@ SECTION("test_update_overwrite") {
}
auto updateJson = arangodb::velocypack::Parser::fromJson("{ \"links\": { \"testCollection\": {} } }");
CHECK((logicalView->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(updateJson->slice(), true).ok()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -3585,13 +3587,13 @@ SECTION("test_update_overwrite") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
expectedMeta._cleanupIntervalStep = 10;
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), false, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), false).errorNumber()));
logicalView = ci->getView(vocbase->name(), viewId);
REQUIRE((false == !logicalView));
arangodb::velocypack::Builder builder;
builder.openObject();
logicalView->toVelocyPack(builder, true, true); // 'forPersistence' to avoid auth check
logicalView->properties(builder, true, true); // 'forPersistence' to avoid auth check
builder.close();
auto slice = builder.slice();
@ -3610,13 +3612,13 @@ SECTION("test_update_overwrite") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
expectedMeta._cleanupIntervalStep = 62;
CHECK((logicalView->updateProperties(viewUpdateJson->slice(), false, false).ok()));
CHECK((logicalView->properties(viewUpdateJson->slice(), false).ok()));
logicalView = ci->getView(vocbase->name(), viewId);
REQUIRE((false == !logicalView));
arangodb::velocypack::Builder builder;
builder.openObject();
logicalView->toVelocyPack(builder, true, true); // 'forPersistence' to avoid auth check
logicalView->properties(builder, true, true); // 'forPersistence' to avoid auth check
builder.close();
auto slice = builder.slice();
@ -3664,7 +3666,7 @@ SECTION("test_update_overwrite") {
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto resetUserManager = irs::make_finally([userManager]()->void{ userManager->removeAllUsers(); });
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), false, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), false).errorNumber()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -3708,7 +3710,7 @@ SECTION("test_update_overwrite") {
}
auto updateJson = arangodb::velocypack::Parser::fromJson("{ \"links\": { \"testCollection\": {} } }");
CHECK((logicalView->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(updateJson->slice(), true).ok()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -3742,7 +3744,7 @@ SECTION("test_update_overwrite") {
user.grantCollection(vocbase->name(), "testCollection", arangodb::auth::Level::NONE); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), false, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), false).errorNumber()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -3758,7 +3760,7 @@ SECTION("test_update_overwrite") {
user.grantCollection(vocbase->name(), "testCollection", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((logicalView->updateProperties(viewUpdateJson->slice(), false, false).ok()));
CHECK((logicalView->properties(viewUpdateJson->slice(), false).ok()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -3815,7 +3817,7 @@ SECTION("test_update_overwrite") {
}
auto updateJson = arangodb::velocypack::Parser::fromJson("{ \"links\": { \"testCollection0\": {} } }");
CHECK((logicalView->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(updateJson->slice(), true).ok()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -3846,7 +3848,7 @@ SECTION("test_update_overwrite") {
user.grantCollection(vocbase->name(), "testCollection1", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), false, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), false).errorNumber()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -3866,7 +3868,7 @@ SECTION("test_update_overwrite") {
user.grantCollection(vocbase->name(), "testCollection1", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((logicalView->updateProperties(viewUpdateJson->slice(), false, false).ok()));
CHECK((logicalView->properties(viewUpdateJson->slice(), false).ok()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -3926,7 +3928,7 @@ SECTION("test_update_overwrite") {
}
auto updateJson = arangodb::velocypack::Parser::fromJson("{ \"links\": { \"testCollection0\": {}, \"testCollection1\": {} } }");
CHECK((logicalView->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(updateJson->slice(), true).ok()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -3963,7 +3965,7 @@ SECTION("test_update_overwrite") {
user.grantCollection(vocbase->name(), "testCollection1", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), false, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), false).errorNumber()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -3983,7 +3985,7 @@ SECTION("test_update_overwrite") {
user.grantCollection(vocbase->name(), "testCollection1", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((logicalView->updateProperties(viewUpdateJson->slice(), false, false).ok()));
CHECK((logicalView->properties(viewUpdateJson->slice(), false).ok()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -4039,14 +4041,14 @@ SECTION("test_update_partial") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
expectedMeta._cleanupIntervalStep = 10;
CHECK((TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND == logicalView->updateProperties(viewUpdateJson->slice(), true, false).errorNumber()));
CHECK((TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND == logicalView->properties(viewUpdateJson->slice(), true).errorNumber()));
logicalView = ci->getView(vocbase->name(), viewId);
REQUIRE((false == !logicalView));
CHECK((true == logicalView->visitCollections([](TRI_voc_cid_t)->bool { return false; })));
arangodb::velocypack::Builder builder;
builder.openObject();
logicalView->toVelocyPack(builder, true, true); // 'forPersistence' to avoid auth check
logicalView->properties(builder, true, true); // 'forPersistence' to avoid auth check
builder.close();
auto slice = builder.slice();
@ -4082,14 +4084,14 @@ SECTION("test_update_partial") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
expectedMeta._cleanupIntervalStep = 10;
CHECK((TRI_ERROR_BAD_PARAMETER == logicalView->updateProperties(viewUpdateJson->slice(), true, false).errorNumber()));
CHECK((TRI_ERROR_BAD_PARAMETER == logicalView->properties(viewUpdateJson->slice(), true).errorNumber()));
logicalView = ci->getView(vocbase->name(), viewId);
REQUIRE((false == !logicalView));
CHECK((true == logicalView->visitCollections([](TRI_voc_cid_t)->bool { return false; })));
arangodb::velocypack::Builder builder;
builder.openObject();
logicalView->toVelocyPack(builder, true, true); // 'forPersistence' to avoid auth check
logicalView->properties(builder, true, true); // 'forPersistence' to avoid auth check
builder.close();
auto slice = builder.slice();
@ -4132,7 +4134,7 @@ SECTION("test_update_partial") {
}
auto updateJson = arangodb::velocypack::Parser::fromJson("{ \"links\": { \"testCollection\": {} } }");
CHECK((logicalView->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(updateJson->slice(), true).ok()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -4162,13 +4164,13 @@ SECTION("test_update_partial") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
expectedMeta._cleanupIntervalStep = 10;
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), true, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), true).errorNumber()));
logicalView = ci->getView(vocbase->name(), viewId);
REQUIRE((false == !logicalView));
arangodb::velocypack::Builder builder;
builder.openObject();
logicalView->toVelocyPack(builder, true, true); // 'forPersistence' to avoid auth check
logicalView->properties(builder, true, true); // 'forPersistence' to avoid auth check
builder.close();
auto slice = builder.slice();
@ -4187,13 +4189,13 @@ SECTION("test_update_partial") {
arangodb::iresearch::IResearchViewMeta expectedMeta;
expectedMeta._cleanupIntervalStep = 62;
CHECK((logicalView->updateProperties(viewUpdateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(viewUpdateJson->slice(), true).ok()));
logicalView = ci->getView(vocbase->name(), viewId);
REQUIRE((false == !logicalView));
arangodb::velocypack::Builder builder;
builder.openObject();
logicalView->toVelocyPack(builder, true, true); // 'forPersistence' to avoid auth check
logicalView->properties(builder, true, true); // 'forPersistence' to avoid auth check
builder.close();
auto slice = builder.slice();
@ -4241,7 +4243,7 @@ SECTION("test_update_partial") {
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto resetUserManager = irs::make_finally([userManager]()->void{ userManager->removeAllUsers(); });
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), true, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), true).errorNumber()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -4285,7 +4287,7 @@ SECTION("test_update_partial") {
}
auto updateJson = arangodb::velocypack::Parser::fromJson("{ \"links\": { \"testCollection\": {} } }");
CHECK((logicalView->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(updateJson->slice(), true).ok()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -4318,7 +4320,7 @@ SECTION("test_update_partial") {
user.grantCollection(vocbase->name(), "testCollection", arangodb::auth::Level::NONE); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), true, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), true).errorNumber()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -4334,7 +4336,7 @@ SECTION("test_update_partial") {
user.grantCollection(vocbase->name(), "testCollection", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((logicalView->updateProperties(viewUpdateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(viewUpdateJson->slice(), true).ok()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
logicalView = ci->getView(vocbase->name(), viewId);
@ -4388,7 +4390,7 @@ SECTION("test_update_partial") {
}
auto updateJson = arangodb::velocypack::Parser::fromJson("{ \"links\": { \"testCollection0\": {} } }");
CHECK((logicalView->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(updateJson->slice(), true).ok()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -4428,7 +4430,7 @@ SECTION("test_update_partial") {
user.grantCollection(vocbase->name(), "testCollection1", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), true, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), true).errorNumber()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -4448,7 +4450,7 @@ SECTION("test_update_partial") {
user.grantCollection(vocbase->name(), "testCollection1", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((logicalView->updateProperties(viewUpdateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(viewUpdateJson->slice(), true).ok()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -4508,7 +4510,7 @@ SECTION("test_update_partial") {
}
auto updateJson = arangodb::velocypack::Parser::fromJson("{ \"links\": { \"testCollection0\": {}, \"testCollection1\": {} } }");
CHECK((logicalView->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(updateJson->slice(), true).ok()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -4545,7 +4547,7 @@ SECTION("test_update_partial") {
user.grantCollection(vocbase->name(), "testCollection1", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((TRI_ERROR_FORBIDDEN == logicalView->updateProperties(viewUpdateJson->slice(), true, false).errorNumber()));
CHECK((TRI_ERROR_FORBIDDEN == logicalView->properties(viewUpdateJson->slice(), true).errorNumber()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);
@ -4565,7 +4567,7 @@ SECTION("test_update_partial") {
user.grantCollection(vocbase->name(), "testCollection1", arangodb::auth::Level::RO); // for missing collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
CHECK((logicalView->updateProperties(viewUpdateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(viewUpdateJson->slice(), true).ok()));
logicalCollection0 = ci->getCollection(vocbase->name(), collectionId0);
REQUIRE((false == !logicalCollection0));
logicalCollection1 = ci->getCollection(vocbase->name(), collectionId1);

View File

@ -358,7 +358,7 @@ SECTION("test_drop_database") {
REQUIRE((false == !wiewImpl));
beforeCount = 0; // reset before call to StorageEngine::createView(...)
auto res = logicalWiew->updateProperties(viewUpdateJson->slice(), true, false);
auto res = logicalWiew->properties(viewUpdateJson->slice(), true);
REQUIRE(true == res.ok());
CHECK((1 + 2 + 1 == beforeCount)); // +1 for StorageEngineMock::createView(...), +2 for StorageEngineMock::getViewProperties(...), +1 for StorageEngineMock::changeView(...)
@ -599,7 +599,7 @@ SECTION("test_query") {
CHECK((false == !logicalWiew));
auto* wiewImpl = dynamic_cast<arangodb::iresearch::IResearchViewDBServer*>(logicalWiew.get());
CHECK((false == !wiewImpl));
arangodb::Result res = logicalWiew->updateProperties(links->slice(), true, false);
arangodb::Result res = logicalWiew->properties(links->slice(), true);
CHECK(true == res.ok());
CHECK((false == logicalCollection->getIndexes().empty()));
@ -699,7 +699,7 @@ SECTION("test_query") {
REQUIRE((false == !logicalWiew));
auto* wiewImpl = dynamic_cast<arangodb::iresearch::IResearchViewDBServer*>(logicalWiew.get());
REQUIRE((false == !wiewImpl));
arangodb::Result res = logicalWiew->updateProperties(viewUpdateJson->slice(), true, false);
arangodb::Result res = logicalWiew->properties(viewUpdateJson->slice(), true);
REQUIRE(true == res.ok());
// start flush thread
@ -775,19 +775,19 @@ SECTION("test_rename") {
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, false, false);
wiew->properties(builder, false, false);
builder.close();
CHECK((builder.slice().hasKey("name")));
CHECK((std::string("testView") == builder.slice().get("name").copyString()));
}
CHECK((TRI_ERROR_NOT_IMPLEMENTED == wiew->rename("newName", true).errorNumber()));
CHECK((TRI_ERROR_CLUSTER_UNSUPPORTED == wiew->rename("newName").errorNumber()));
{
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, false, false);
wiew->properties(builder, false, false);
builder.close();
CHECK((builder.slice().hasKey("name")));
CHECK((std::string("testView") == builder.slice().get("name").copyString()));
@ -827,26 +827,26 @@ SECTION("test_rename") {
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, false, false);
wiew->properties(builder, false, false);
builder.close();
CHECK((builder.slice().hasKey("name")));
CHECK((std::string("testView") == builder.slice().get("name").copyString()));
}
CHECK((TRI_ERROR_NOT_IMPLEMENTED == wiew->rename("newName", true).errorNumber()));
CHECK((TRI_ERROR_CLUSTER_UNSUPPORTED == wiew->rename("newName").errorNumber()));
{
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, false, false);
wiew->properties(builder, false, false);
builder.close();
CHECK((builder.slice().hasKey("name")));
CHECK((std::string("testView") == builder.slice().get("name").copyString()));
}
CHECK((("_iresearch_123_" + wiewId) == view->name()));
wiew->rename("testView", true); // rename back or vocbase will be out of sync
wiew->rename("testView"); // rename back or vocbase will be out of sync
}
}
@ -864,10 +864,11 @@ SECTION("test_toVelocyPack") {
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder,false, false);
wiew->properties(builder,false, false);
builder.close();
auto slice = builder.slice();
CHECK((3 == slice.length()));
CHECK((4U == slice.length()));
CHECK((slice.hasKey("globallyUniqueId") && slice.get("globallyUniqueId").isString() && false == slice.get("globallyUniqueId").copyString().empty()));
CHECK((slice.hasKey("id") && slice.get("id").isString() && std::string("1") == slice.get("id").copyString()));
CHECK((slice.hasKey("name") && slice.get("name").isString() && std::string("testView") == slice.get("name").copyString()));
CHECK((slice.hasKey("type") && slice.get("type").isString() && arangodb::iresearch::DATA_SOURCE_TYPE.name() == slice.get("type").copyString()));
@ -886,10 +887,11 @@ SECTION("test_toVelocyPack") {
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, true, false);
wiew->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((9U == slice.length()));
CHECK((10U == slice.length()));
CHECK((slice.hasKey("globallyUniqueId") && slice.get("globallyUniqueId").isString() && false == slice.get("globallyUniqueId").copyString().empty()));
CHECK((slice.hasKey("id") && slice.get("id").isString() && std::string("2") == slice.get("id").copyString()));
CHECK((slice.hasKey("name") && slice.get("name").isString() && std::string("testView") == slice.get("name").copyString()));
CHECK((slice.hasKey("type") && slice.get("type").isString() && arangodb::iresearch::DATA_SOURCE_TYPE.name() == slice.get("type").copyString()));
@ -908,7 +910,7 @@ SECTION("test_toVelocyPack") {
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, false, true);
wiew->properties(builder, false, true);
builder.close();
auto slice = builder.slice();
CHECK((7 == slice.length()));
@ -1052,12 +1054,12 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, true, false);
wiew->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((9U == slice.length()));
CHECK((10U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 24 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 42 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((!slice.hasKey("links")));
@ -1065,19 +1067,19 @@ SECTION("test_updateProperties") {
{
auto update = arangodb::velocypack::Parser::fromJson("{ \"collections\": [ 6, 7, 8, 9 ], \"consolidationIntervalMsec\": 52, \"links\": { \"testCollection\": {} } }");
CHECK((true == wiew->updateProperties(update->slice(), true, true).ok()));
CHECK((true == wiew->properties(update->slice(), true).ok()));
}
{
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, true, false);
wiew->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((9U == slice.length()));
CHECK((10U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 24 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 52 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((!slice.hasKey("links")));
@ -1093,12 +1095,12 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((10U == slice.length()));
CHECK((11U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 24 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 52 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((slice.hasKey("links") && slice.get("links").isObject() && 0 == slice.get("links").length()));
@ -1109,7 +1111,7 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, true);
view->properties(builder, true, true);
builder.close();
auto slice = builder.slice();
@ -1142,12 +1144,12 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, true, false);
wiew->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((9U == slice.length()));
CHECK((10U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 24 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 42 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((!slice.hasKey("links")));
@ -1155,19 +1157,19 @@ SECTION("test_updateProperties") {
{
auto update = arangodb::velocypack::Parser::fromJson("{ \"collections\": [ 6, 7, 8, 9 ], \"links\": { \"testCollection\": {} }, \"consolidationIntervalMsec\": 52 }");
CHECK((true == wiew->updateProperties(update->slice(), false, true).ok()));
CHECK((true == wiew->properties(update->slice(), false).ok()));
}
{
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, true, false);
wiew->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((9U == slice.length()));
CHECK((10U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 10 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 52 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((!slice.hasKey("links")));
@ -1183,12 +1185,12 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((10U == slice.length()));
CHECK((11U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 10 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 52 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((slice.hasKey("links") && slice.get("links").isObject() && 0 == slice.get("links").length()));
@ -1199,7 +1201,7 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, true);
view->properties(builder, true, true);
builder.close();
auto slice = builder.slice();
@ -1237,12 +1239,12 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, true, false);
wiew->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((9U == slice.length()));
CHECK((10U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 24 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 42 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((!slice.hasKey("links")));
@ -1250,19 +1252,19 @@ SECTION("test_updateProperties") {
{
auto update = arangodb::velocypack::Parser::fromJson("{ \"collections\": [ 6, 7, 8 ], \"links\": { \"testCollection\": {} }, \"consolidationIntervalMsec\": 52 }");
CHECK((true == wiew->updateProperties(update->slice(), true, true).ok()));
CHECK((true == wiew->properties(update->slice(), true).ok()));
}
{
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, true, false);
wiew->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((9U == slice.length()));
CHECK((10U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 24 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 52 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((!slice.hasKey("links")));
@ -1275,12 +1277,12 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((10U == slice.length()));
CHECK((11U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 24 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 52 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((slice.hasKey("links") && slice.get("links").isObject() && 0 == slice.get("links").length()));
@ -1291,7 +1293,7 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, true);
view->properties(builder, true, true);
builder.close();
auto slice = builder.slice();
@ -1332,12 +1334,12 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, true, false);
wiew->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((9U == slice.length()));
CHECK((10U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 24 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 42 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((!slice.hasKey("links")));
@ -1345,19 +1347,19 @@ SECTION("test_updateProperties") {
{
auto update = arangodb::velocypack::Parser::fromJson("{ \"collections\": [ 6, 7, 8 ], \"links\": { \"testCollection\": {} }, \"consolidationIntervalMsec\": 52 }");
CHECK((true == wiew->updateProperties(update->slice(), false, true).ok()));
CHECK((true == wiew->properties(update->slice(), false).ok()));
}
{
arangodb::velocypack::Builder builder;
builder.openObject();
wiew->toVelocyPack(builder, true, false);
wiew->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((9U == slice.length()));
CHECK((10U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 10 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 52 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((!slice.hasKey("links")));
@ -1370,12 +1372,12 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, false);
view->properties(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK((slice.isObject()));
CHECK((10U == slice.length()));
CHECK((11U == slice.length()));
CHECK((slice.hasKey("cleanupIntervalStep") && slice.get("cleanupIntervalStep").isNumber<size_t>() && 10 == slice.get("cleanupIntervalStep").getNumber<size_t>()));
CHECK((slice.hasKey("consolidationIntervalMsec") && slice.get("consolidationIntervalMsec").isNumber<size_t>() && 52 == slice.get("consolidationIntervalMsec").getNumber<size_t>()));
CHECK((slice.hasKey("links") && slice.get("links").isObject() && 0 == slice.get("links").length()));
@ -1386,7 +1388,7 @@ SECTION("test_updateProperties") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, true, true);
view->properties(builder, true, true);
builder.close();
auto slice = builder.slice();

View File

@ -1052,7 +1052,7 @@ SECTION("collections") {
"\"testCollection2\": { \"includeAllFields\": true }"
"}}"
);
CHECK((logicalView->updateProperties(updateJson->slice(), true, false).ok()));
CHECK((logicalView->properties(updateJson->slice(), true).ok()));
// dummy query
arangodb::aql::Query query(

View File

@ -1004,7 +1004,7 @@ arangodb::Result StorageEngineMock::changeView(
arangodb::velocypack::Builder builder;
builder.openObject();
view.toVelocyPack(builder, true, true);
view.properties(builder, true, true);
builder.close();
views[std::make_pair(vocbase.id(), view.id())] = std::move(builder);
return {};
@ -1106,7 +1106,7 @@ arangodb::Result StorageEngineMock::createView(
arangodb::velocypack::Builder builder;
builder.openObject();
view.toVelocyPack(builder, true, true);
view.properties(builder, true, true);
builder.close();
views[std::make_pair(vocbase.id(), view.id())] = std::move(builder);

View File

@ -62,8 +62,8 @@ struct TestView: public arangodb::LogicalView {
}
virtual arangodb::Result drop() override { return arangodb::Result(); }
virtual void open() override {}
virtual arangodb::Result rename(std::string&& newName, bool doSync) override { name(std::move(newName)); return arangodb::Result(); }
virtual arangodb::Result updateProperties(arangodb::velocypack::Slice const& properties, bool partialUpdate, bool doSync) override { _properties = arangodb::velocypack::Builder(properties); return arangodb::Result(); }
virtual arangodb::Result rename(std::string&& newName) override { name(std::move(newName)); return arangodb::Result(); }
virtual arangodb::Result properties(arangodb::velocypack::Slice const& properties, bool partialUpdate) override { _properties = arangodb::velocypack::Builder(properties); return arangodb::Result(); }
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};

View File

@ -52,8 +52,8 @@ struct TestView: public arangodb::LogicalView {
}
virtual arangodb::Result drop() override { return vocbase().dropView(id(), true); }
virtual void open() override {}
virtual arangodb::Result rename(std::string&& newName, bool doSync) override { auto res = vocbase().renameView(id(), newName); name(std::move(newName)); return res; }
virtual arangodb::Result updateProperties(arangodb::velocypack::Slice const& properties, bool partialUpdate, bool doSync) override { _properties = arangodb::velocypack::Builder(properties); return arangodb::Result(); }
virtual arangodb::Result rename(std::string&& newName) override { auto res = vocbase().renameView(id(), newName); name(std::move(newName)); return res; }
virtual arangodb::Result properties(arangodb::velocypack::Slice const& properties, bool partialUpdate) override { _properties = arangodb::velocypack::Builder(properties); return arangodb::Result(); }
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};

View File

@ -43,8 +43,8 @@ struct TestView: public arangodb::LogicalView {
virtual arangodb::Result appendVelocyPack(arangodb::velocypack::Builder&, bool , bool) const override { return arangodb::Result(); }
virtual arangodb::Result drop() override { deleted(true); return vocbase().dropView(id(), true); }
virtual void open() override {}
virtual arangodb::Result rename(std::string&& newName, bool doSync) override { name(std::move(newName)); return arangodb::Result(); }
virtual arangodb::Result updateProperties(arangodb::velocypack::Slice const&, bool, bool) override { return arangodb::Result(); }
virtual arangodb::Result rename(std::string&& newName) override { name(std::move(newName)); return arangodb::Result(); }
virtual arangodb::Result properties(arangodb::velocypack::Slice const&, bool) override { return arangodb::Result(); }
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};

View File

@ -81,8 +81,8 @@ struct TestView: public arangodb::LogicalView {
}
virtual arangodb::Result drop() override { return arangodb::Result(); }
virtual void open() override {}
virtual arangodb::Result rename(std::string&& newName, bool doSync) override { name(std::move(newName)); return arangodb::Result(); }
virtual arangodb::Result updateProperties(arangodb::velocypack::Slice const& properties, bool partialUpdate, bool doSync) override { _properties = arangodb::velocypack::Builder(properties); return arangodb::Result(); }
virtual arangodb::Result rename(std::string&& newName) override { name(std::move(newName)); return arangodb::Result(); }
virtual arangodb::Result properties(arangodb::velocypack::Slice const& properties, bool partialUpdate) override { _properties = arangodb::velocypack::Builder(properties); return arangodb::Result(); }
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};

View File

@ -79,8 +79,8 @@ struct TestView: public arangodb::LogicalView {
}
virtual arangodb::Result drop() override { return vocbase().dropView(id(), true); }
virtual void open() override {}
virtual arangodb::Result rename(std::string&& newName, bool doSync) override { auto res = vocbase().renameView(id(), newName); name(std::move(newName)); return res; }
virtual arangodb::Result updateProperties(arangodb::velocypack::Slice const& properties, bool partialUpdate, bool doSync) override { _properties = arangodb::velocypack::Builder(properties); return arangodb::Result(); }
virtual arangodb::Result rename(std::string&& newName) override { auto res = vocbase().renameView(id(), newName); name(std::move(newName)); return res; }
virtual arangodb::Result properties(arangodb::velocypack::Slice const& properties, bool partialUpdate) override { _properties = arangodb::velocypack::Builder(properties); return arangodb::Result(); }
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};

View File

@ -109,8 +109,8 @@ SECTION("test_category") {
}
virtual arangodb::Result drop() override { return arangodb::Result(); }
virtual void open() override {}
virtual arangodb::Result rename(std::string&& newName, bool doSync) override { return arangodb::Result(); }
virtual arangodb::Result updateProperties(arangodb::velocypack::Slice const& properties, bool partialUpdate, bool doSync) override { return arangodb::Result(); }
virtual arangodb::Result rename(std::string&& newName) override { return arangodb::Result(); }
virtual arangodb::Result properties(arangodb::velocypack::Slice const& properties, bool partialUpdate) override { return arangodb::Result(); }
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};
@ -143,8 +143,8 @@ SECTION("test_construct") {
}
virtual arangodb::Result drop() override { return arangodb::Result(); }
virtual void open() override {}
virtual arangodb::Result rename(std::string&& newName, bool doSync) override { return arangodb::Result(); }
virtual arangodb::Result updateProperties(arangodb::velocypack::Slice const& properties, bool partialUpdate, bool doSync) override { return arangodb::Result(); }
virtual arangodb::Result rename(std::string&& newName) override { return arangodb::Result(); }
virtual arangodb::Result properties(arangodb::velocypack::Slice const& properties, bool partialUpdate) override { return arangodb::Result(); }
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};
@ -179,8 +179,8 @@ SECTION("test_defaults") {
}
virtual arangodb::Result drop() override { return arangodb::Result(); }
virtual void open() override {}
virtual arangodb::Result rename(std::string&& newName, bool doSync) override { return arangodb::Result(); }
virtual arangodb::Result updateProperties(arangodb::velocypack::Slice const& properties, bool partialUpdate, bool doSync) override { return arangodb::Result(); }
virtual arangodb::Result rename(std::string&& newName) override { return arangodb::Result(); }
virtual arangodb::Result properties(arangodb::velocypack::Slice const& properties, bool partialUpdate) override { return arangodb::Result(); }
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};

View File

@ -44,8 +44,8 @@ struct TestView: public arangodb::LogicalView {
virtual arangodb::Result appendVelocyPack(arangodb::velocypack::Builder&, bool , bool) const override { return arangodb::Result(); }
virtual arangodb::Result drop() override { deleted(true); return vocbase().dropView(id(), true); }
virtual void open() override {}
virtual arangodb::Result rename(std::string&& newName, bool doSync) override { name(std::move(newName)); return arangodb::Result(); }
virtual arangodb::Result updateProperties(arangodb::velocypack::Slice const&, bool, bool) override { return arangodb::Result(); }
virtual arangodb::Result rename(std::string&& newName) override { name(std::move(newName)); return arangodb::Result(); }
virtual arangodb::Result properties(arangodb::velocypack::Slice const&, bool) override { return arangodb::Result(); }
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};