1
0
Fork 0

issue 355.6: remove create() from LogicalView, remove IResearch dependency from IndexFactory, store vocbase reference in LogicalDataSource

This commit is contained in:
Vasiliy 2018-04-06 16:38:34 +03:00
parent bdeb6175a9
commit e4368b0991
61 changed files with 1281 additions and 701 deletions

View File

@ -537,18 +537,18 @@ void ClusterInfo::loadPlan() {
VPackSlice type = collectionSlice.get("type");
if (type.isInteger() && type.getUInt() == TRI_COL_TYPE_EDGE) {
newCollection = std::make_shared<VirtualSmartEdgeCollection>(
vocbase, collectionSlice, newPlanVersion
*vocbase, collectionSlice, newPlanVersion
);
} else {
newCollection = std::make_shared<SmartVertexCollection>(
vocbase, collectionSlice, newPlanVersion
*vocbase, collectionSlice, newPlanVersion
);
}
} else
#endif
{
newCollection = std::make_shared<LogicalCollection>(
vocbase, collectionSlice, true, newPlanVersion
*vocbase, collectionSlice, true, newPlanVersion
);
}

View File

@ -2600,9 +2600,13 @@ int flushWalOnAllDBServers(bool waitForSync, bool waitForCollector, double maxWa
#ifndef USE_ENTERPRISE
std::shared_ptr<LogicalCollection> ClusterMethods::createCollectionOnCoordinator(
TRI_col_type_e collectionType, TRI_vocbase_t* vocbase, VPackSlice parameters,
bool ignoreDistributeShardsLikeErrors, bool waitForSyncReplication,
bool enforceReplicationFactor) {
TRI_col_type_e collectionType,
TRI_vocbase_t& vocbase,
velocypack::Slice parameters,
bool ignoreDistributeShardsLikeErrors,
bool waitForSyncReplication,
bool enforceReplicationFactor
) {
auto col = std::make_unique<LogicalCollection>(vocbase, parameters, 0, true);
// Collection is a temporary collection object that undergoes sanity checks etc.
// It is not used anywhere and will be cleaned up after this call.

View File

@ -261,7 +261,8 @@ class ClusterMethods {
// transferred
// to the caller, which is expressed by the returned unique_ptr.
static std::shared_ptr<LogicalCollection> createCollectionOnCoordinator(
TRI_col_type_e collectionType, TRI_vocbase_t* vocbase,
TRI_col_type_e collectionType,
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice parameters,
bool ignoreDistributeShardsLikeErrors,
bool waitForSyncReplication,

View File

@ -25,6 +25,8 @@
#include "search/scorers.hpp"
#include "IResearchFeature.h"
#include "IResearchMMFilesLink.h"
#include "IResearchRocksDBLink.h"
#include "IResearchRocksDBRecoveryHelper.h"
#include "IResearchView.h"
#include "IResearchViewCoordinator.h"
@ -128,6 +130,61 @@ void registerFilters(arangodb::aql::AqlFunctionFeature& functions) {
});
}
void registerIndexFactory() {
if (arangodb::ServerState::instance()->isCoordinator()) {
return; // no registration required on coordinator (collections not instantiated)
}
static const std::map<std::string, arangodb::IndexFactory::IndexTypeFactory> factories = {
{ "MMFilesEngine", arangodb::iresearch::IResearchMMFilesLink::make },
{ "RocksDBEngine", arangodb::iresearch::IResearchRocksDBLink::make },
};
static const auto& indexType = arangodb::iresearch::IResearchFeature::type();
// register 'arangosearch' link
for (auto& entry: factories) {
auto* engine = arangodb::iresearch::getFeature<arangodb::StorageEngine>(entry.first);
// valid situation if not running with the specified storage engine
if (!engine) {
LOG_TOPIC(WARN, arangodb::iresearch::IResearchFeature::IRESEARCH)
<< "failed to find feature '" << entry.first << "' while registering index type '" << indexType << "', skipping";
continue;
}
// ok to const-cast since this should only be called on startup
auto* indexFactory =
const_cast<arangodb::IndexFactory*>(engine->indexFactory());
if (!indexFactory) {
THROW_ARANGO_EXCEPTION_MESSAGE(
TRI_ERROR_INTERNAL,
std::string("failed to retieve index factory from feature '") + entry.first + "' while registering index type '" + indexType + "'"
);
}
auto res = indexFactory->emplaceFactory(indexType, entry.second);
if (!res.ok()) {
THROW_ARANGO_EXCEPTION_MESSAGE(
res.errorNumber(),
std::string("failure registering IResearch link factory with index factory from feature '") + entry.first + "': " + res.errorMessage()
);
}
res = indexFactory->emplaceNormalizer(
indexType, arangodb::iresearch::IResearchLink::normalize
);
if (!res.ok()) {
THROW_ARANGO_EXCEPTION_MESSAGE(
res.errorNumber(),
std::string("failure registering IResearch link normalizer with index factory from feature '") + entry.first + "': " + res.errorMessage()
);
}
}
}
void registerScorers(arangodb::aql::AqlFunctionFeature& functions) {
irs::scorers::visit([&functions](
irs::string_ref const& name, irs::text_format::type_id const& args_format
@ -286,6 +343,9 @@ void IResearchFeature::prepare() {
// load all known scorers
::iresearch::scorers::init();
// register 'arangosearch' index
registerIndexFactory();
// register 'arangosearch' view
registerViewFactory();

View File

@ -410,6 +410,44 @@ size_t IResearchLink::memory() const {
return size;
}
/*static*/ arangodb::Result IResearchLink::normalize(
arangodb::velocypack::Builder& normalized,
velocypack::Slice definition,
bool // isCreation
) {
if (!normalized.isOpenObject()) {
return arangodb::Result(
TRI_ERROR_BAD_PARAMETER,
std::string("invalid output buffer provided for IResearch link normalized definition generation")
);
}
std::string error;
IResearchLinkMeta meta;
if (!meta.init(definition, error)) {
return arangodb::Result(
TRI_ERROR_BAD_PARAMETER,
std::string("error parsing IResearch link parameters from json: ") + error
);
}
normalized.add(LINK_TYPE_FIELD, arangodb::velocypack::Value(LINK_TYPE));
// copy over IResearch View identifier
if (definition.hasKey(VIEW_ID_FIELD)) {
normalized.add(VIEW_ID_FIELD, definition.get(VIEW_ID_FIELD));
}
return meta.json(normalized)
? arangodb::Result()
: arangodb::Result(
TRI_ERROR_BAD_PARAMETER,
std::string("error generating IResearch link normalized definition")
)
;
}
Result IResearchLink::remove(
transaction::Methods* trx,
LocalDocumentId const& documentId,
@ -538,35 +576,6 @@ const IResearchView* IResearchLink::view() const {
return _view;
}
int EnhanceJsonIResearchLink(
VPackSlice const definition,
VPackBuilder& builder,
bool create
) noexcept {
try {
std::string error;
IResearchLinkMeta meta;
if (!meta.init(definition, error)) {
LOG_TOPIC(WARN, iresearch::IResearchFeature::IRESEARCH) << "error parsing view link parameters from json: " << error;
return TRI_ERROR_BAD_PARAMETER;
}
if (definition.hasKey(VIEW_ID_FIELD)) {
builder.add(VIEW_ID_FIELD, definition.get(VIEW_ID_FIELD)); // copy over iResearch View identifier
}
return meta.json(builder) ? TRI_ERROR_NO_ERROR : TRI_ERROR_BAD_PARAMETER;
} catch (std::exception const& e) {
LOG_TOPIC(WARN, iresearch::IResearchFeature::IRESEARCH) << "error serializaing view link parameters to json: " << e.what();
} catch (...) {
LOG_TOPIC(WARN, iresearch::IResearchFeature::IRESEARCH) << "error serializaing view link parameters to json";
}
return TRI_ERROR_INTERNAL;
}
NS_END // iresearch
NS_END // arangodb

View File

@ -122,6 +122,16 @@ class IResearchLink {
////////////////////////////////////////////////////////////////////////////////
size_t memory() const; // arangodb::Index override
//////////////////////////////////////////////////////////////////////////////
/// @brief validate and copy required fields from the 'definition' into
/// 'normalized'
//////////////////////////////////////////////////////////////////////////////
static arangodb::Result normalize(
arangodb::velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
);
////////////////////////////////////////////////////////////////////////////////
/// @brief remove an ArangoDB document from an iResearch View
////////////////////////////////////////////////////////////////////////////////
@ -211,15 +221,6 @@ class IResearchLink {
std::unique_lock<irs::async_utils::read_write_mutex::read_mutex> _viewLock; // prevent view deallocation (lock @ AsyncSelf)
}; // IResearchLink
////////////////////////////////////////////////////////////////////////////////
/// @brief copy required fields from the 'definition' into the 'builder'
////////////////////////////////////////////////////////////////////////////////
int EnhanceJsonIResearchLink(
VPackSlice const definition,
VPackBuilder& builder,
bool create
) noexcept;
NS_END // iresearch
NS_END // arangodb

View File

@ -70,12 +70,13 @@ IResearchMMFilesLink::~IResearchMMFilesLink() {
}
/*static*/ IResearchMMFilesLink::ptr IResearchMMFilesLink::make(
TRI_idx_iid_t iid,
arangodb::LogicalCollection* collection,
arangodb::velocypack::Slice const& definition
arangodb::velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
) noexcept {
try {
PTR_NAMED(IResearchMMFilesLink, ptr, iid, collection);
PTR_NAMED(IResearchMMFilesLink, ptr, id, collection);
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
auto* link = dynamic_cast<arangodb::iresearch::IResearchMMFilesLink*>(ptr.get());
@ -85,9 +86,11 @@ IResearchMMFilesLink::~IResearchMMFilesLink() {
return link && link->init(definition) ? ptr : nullptr;
} catch (std::exception const& e) {
LOG_TOPIC(WARN, Logger::DEVEL) << "caught exception while creating IResearch view MMFiles link '" << iid << "'" << e.what();
LOG_TOPIC(WARN, Logger::DEVEL)
<< "caught exception while creating IResearch view MMFiles link '" << id << "'" << e.what();
} catch (...) {
LOG_TOPIC(WARN, Logger::DEVEL) << "caught exception while creating IResearch view MMFiles link '" << iid << "'";
LOG_TOPIC(WARN, Logger::DEVEL)
<< "caught exception while creating IResearch view MMFiles link '" << id << "'";
}
return nullptr;

View File

@ -92,9 +92,10 @@ class IResearchMMFilesLink final
/// @return nullptr on failure
////////////////////////////////////////////////////////////////////////////////
static ptr make(
TRI_idx_iid_t iid,
arangodb::LogicalCollection* collection,
arangodb::velocypack::Slice const& definition
arangodb::velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
) noexcept;
virtual bool matchesDefinition(

View File

@ -79,12 +79,13 @@ IResearchRocksDBLink::~IResearchRocksDBLink() {
}
/*static*/ IResearchRocksDBLink::ptr IResearchRocksDBLink::make(
TRI_idx_iid_t iid,
arangodb::LogicalCollection* collection,
arangodb::velocypack::Slice const& definition
arangodb::velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
) noexcept {
try {
PTR_NAMED(IResearchRocksDBLink, ptr, iid, collection);
PTR_NAMED(IResearchRocksDBLink, ptr, id, collection);
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
auto* link =
@ -97,12 +98,10 @@ IResearchRocksDBLink::~IResearchRocksDBLink() {
return link && link->init(definition) ? ptr : nullptr;
} catch (std::exception const& e) {
LOG_TOPIC(WARN, Logger::DEVEL)
<< "caught exception while creating IResearch view RocksDB link '"
<< iid << "'" << e.what();
<< "caught exception while creating IResearch view RocksDB link '" << id << "'" << e.what();
} catch (...) {
LOG_TOPIC(WARN, Logger::DEVEL)
<< "caught exception while creating IResearch view RocksDB link '"
<< iid << "'";
<< "caught exception while creating IResearch view RocksDB link '" << id << "'";
}
return nullptr;

View File

@ -90,9 +90,10 @@ class IResearchRocksDBLink final
/// @return nullptr on failure
////////////////////////////////////////////////////////////////////////////////
static ptr make(
TRI_idx_iid_t iid,
arangodb::LogicalCollection* collection,
arangodb::velocypack::Slice const& definition
arangodb::velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
) noexcept;
virtual bool matchesDefinition(

View File

@ -879,7 +879,7 @@ IResearchView::PersistedStore::PersistedStore(irs::utf8_path&& path)
}
IResearchView::IResearchView(
TRI_vocbase_t* vocbase,
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
arangodb::DatabasePathFeature const& dbPathFeature,
uint64_t planVersion
@ -1736,7 +1736,8 @@ int IResearchView::insert(
/*static*/ std::shared_ptr<LogicalView> IResearchView::make(
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
uint64_t planVersion
uint64_t planVersion,
LogicalView::PreCommitCallback const& preCommit /*= LogicalView::PreCommitCallback()*/
) {
auto* feature =
arangodb::iresearch::getFeature<arangodb::DatabasePathFeature>("DatabasePath");
@ -1748,21 +1749,37 @@ int IResearchView::insert(
return nullptr;
}
PTR_NAMED(IResearchView, view, &vocbase, info, *feature, planVersion);
PTR_NAMED(IResearchView, view, vocbase, info, *feature, planVersion);
auto& impl = reinterpret_cast<IResearchView&>(*view);
auto& json = info.isObject() ? info : emptyObjectSlice(); // if no 'info' then assume defaults
auto props = json.get("properties");
auto& properties = props.isObject() ? props : emptyObjectSlice(); // if no 'info' then assume defaults
std::string error;
if (impl._meta.init(properties, error)) {
return view;
if (!impl._meta.init(properties, error)) {
LOG_TOPIC(WARN, IResearchFeature::IRESEARCH)
<< "failed to initialize iResearch view from definition, error: " << error;
return nullptr;
}
LOG_TOPIC(WARN, IResearchFeature::IRESEARCH)
<< "failed to initialize iResearch view from definition, error: " << error;
if (preCommit && !preCommit(view)) {
LOG_TOPIC(ERR, IResearchFeature::IRESEARCH)
<< "Failure during pre-commit while constructing IResearch View in database '" << vocbase.id() << "'";
return nullptr;
return nullptr;
}
auto res = create(static_cast<arangodb::DBServerLogicalView&>(*view));
if (!res.ok()) {
LOG_TOPIC(ERR, IResearchFeature::IRESEARCH)
<< "Failure during commit of created view while constructing IResearch View in database '" << vocbase.id() << "', error: " << res.errorMessage();
return nullptr;
}
return view;
}
size_t IResearchView::memory() const {

View File

@ -192,7 +192,8 @@ class IResearchView final: public arangodb::DBServerLogicalView,
static std::shared_ptr<LogicalView> make(
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
uint64_t planVersion
uint64_t planVersion,
LogicalView::PreCommitCallback const& preCommit = LogicalView::PreCommitCallback()
);
////////////////////////////////////////////////////////////////////////////////
@ -325,7 +326,7 @@ class IResearchView final: public arangodb::DBServerLogicalView,
> FlushTransactionPtr;
IResearchView(
TRI_vocbase_t* vocbase,
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
arangodb::DatabasePathFeature const& dbPathFeature,
uint64_t planVersion

View File

@ -29,7 +29,8 @@ namespace iresearch {
/*static*/ std::shared_ptr<LogicalView> IResearchViewCoordinator::make(
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
uint64_t planVersion
uint64_t planVersion,
LogicalView::PreCommitCallback const& preCommit
) {
// FIXME implement
return nullptr;

View File

@ -43,7 +43,8 @@ class IResearchViewCoordinator final: public arangodb::LogicalView {
static std::shared_ptr<LogicalView> make(
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
uint64_t planVersion
uint64_t planVersion,
LogicalView::PreCommitCallback const& preCommit
);
bool visitCollections(CollectionVisitor const& visitor) const override {

View File

@ -25,11 +25,129 @@
#include "Basics/Exceptions.h"
#include "Basics/StringUtils.h"
#include "Basics/VelocyPackHelper.h"
#include "Cluster/ServerState.h"
#include "Indexes/Index.h"
#include <velocypack/Slice.h>
using namespace arangodb;
namespace arangodb {
Result IndexFactory::emplaceFactory(
std::string const& type,
IndexTypeFactory const& factory
) {
if (!factory) {
return arangodb::Result(
TRI_ERROR_BAD_PARAMETER,
std::string("index factory undefined during index factory registration for index type '") + type + "'"
);
}
if (!_factories.emplace(type, factory).second) {
return arangodb::Result(
TRI_ERROR_ARANGO_DUPLICATE_IDENTIFIER,
std::string("index factory previously registered during index factory registration for index type '") + type + "'"
);
}
return arangodb::Result();
}
Result IndexFactory::emplaceNormalizer(
std::string const& type,
IndexNormalizer const& normalizer
) {
if (!normalizer) {
return arangodb::Result(
TRI_ERROR_BAD_PARAMETER,
std::string("index normalizer undefined during index normalizer registration for index type '") + type + "'"
);
}
if (!_normalizers.emplace(type, normalizer).second) {
return arangodb::Result(
TRI_ERROR_ARANGO_DUPLICATE_IDENTIFIER,
std::string("index normalizer previously registered during index normalizer registration for index type '") + type + "'"
);
}
return arangodb::Result();
}
Result IndexFactory::enhanceIndexDefinition(
velocypack::Slice const definition,
velocypack::Builder& normalized,
bool isCreation,
bool isCoordinator
) const {
auto type = definition.get("type");
if (!type.isString()) {
return TRI_ERROR_BAD_PARAMETER;
}
auto typeString = type.copyString();
auto itr = _normalizers.find(typeString);
if (itr == _normalizers.end()) {
return TRI_ERROR_BAD_PARAMETER;
}
TRI_ASSERT(ServerState::instance()->isCoordinator() == isCoordinator);
TRI_ASSERT(normalized.isEmpty());
try {
velocypack::ObjectBuilder b(&normalized);
auto idSlice = definition.get("id");
uint64_t id = 0;
if (idSlice.isNumber()) {
id = idSlice.getNumericValue<uint64_t>();
} else if (idSlice.isString()) {
id = basics::StringUtils::uint64(idSlice.copyString());
}
if (id) {
normalized.add("id", VPackValue(std::to_string(id)));
}
return itr->second(normalized, definition, isCreation);
} catch (basics::Exception const& ex) {
return ex.code();
} catch (std::exception const&) {
return TRI_ERROR_OUT_OF_MEMORY;
} catch (...) {
return TRI_ERROR_INTERNAL;
}
}
std::shared_ptr<Index> IndexFactory::prepareIndexFromSlice(
velocypack::Slice definition,
bool generateKey,
LogicalCollection* collection,
bool isClusterConstructor
) const {
auto id = validateSlice(definition, generateKey, isClusterConstructor);
auto type = definition.get("type");
if (!type.isString()) {
THROW_ARANGO_EXCEPTION_MESSAGE(
TRI_ERROR_BAD_PARAMETER, "invalid index type definition"
);
}
auto typeString = type.copyString();
auto itr = _factories.find(typeString);
if (itr == _factories.end()) {
THROW_ARANGO_EXCEPTION_MESSAGE(
TRI_ERROR_NOT_IMPLEMENTED,
std::string("invalid or unsupported index type '") + typeString + "'"
);
}
return itr->second(collection, definition, id, isClusterConstructor);
}
TRI_idx_iid_t IndexFactory::validateSlice(arangodb::velocypack::Slice info,
bool generateKey,
@ -59,3 +177,5 @@ TRI_idx_iid_t IndexFactory::validateSlice(arangodb::velocypack::Slice info,
return iid;
}
} // arangodb

View File

@ -24,7 +24,7 @@
#ifndef ARANGOD_INDEXES_INDEX_FACTORY_H
#define ARANGOD_INDEXES_INDEX_FACTORY_H 1
#include "Basics/Common.h"
#include "Basics/Result.h"
#include "VocBase/voc-types.h"
namespace arangodb {
@ -39,32 +39,82 @@ class Slice;
class IndexFactory {
public:
//////////////////////////////////////////////////////////////////////////////
/// @brief typedef for a Index factory function
/// This typedef is used when registering the factory function for any index
/// type. The factory function is called when a index is first created or
/// re-opened after a server restart. The VelocyPack Slice will contain all
/// information about the indexs' general and implementation-specific
/// properties.
//////////////////////////////////////////////////////////////////////////////
typedef std::function<std::shared_ptr<Index>(
LogicalCollection* collection,
velocypack::Slice const& definition, // index definition
TRI_idx_iid_t id,
bool isClusterConstructor
)> IndexTypeFactory;
//////////////////////////////////////////////////////////////////////////////
/// @brief typedef for a Index definition normalizer function
/// This typedef is used when registering the normalizer function for any
/// index type. The normalizer function is called when a index definition
/// needs to be normalized before using it to create the index. The resulting
/// VelocyBuilder will contain the 'type' that should be used for index
/// factory lookup (if no normalizer is registered then use the original type)
//////////////////////////////////////////////////////////////////////////////
typedef std::function<Result(
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)> IndexNormalizer;
IndexFactory() = default;
IndexFactory(IndexFactory const&) = delete;
IndexFactory& operator=(IndexFactory const&) = delete;
virtual ~IndexFactory() = default;
virtual int enhanceIndexDefinition(
arangodb::velocypack::Slice const definition,
arangodb::velocypack::Builder& enhanced, bool isCreation,
bool isCoordinator) const = 0;
/// @return 'factory' for 'type' was added successfully
Result emplaceFactory(
std::string const& type,
IndexTypeFactory const& factory
);
virtual std::shared_ptr<arangodb::Index> prepareIndexFromSlice(
arangodb::velocypack::Slice info, bool generateKey,
arangodb::LogicalCollection* col, bool isClusterConstructor) const = 0;
/// @return 'normalizer' for 'type' was added successfully
Result emplaceNormalizer(
std::string const& type,
IndexNormalizer const& normalizer
);
Result enhanceIndexDefinition(
velocypack::Slice const definition,
velocypack::Builder& normalized,
bool isCreation,
bool isCoordinator
) const;
std::shared_ptr<Index> prepareIndexFromSlice(
velocypack::Slice definition,
bool generateKey,
LogicalCollection* collection,
bool isClusterConstructor
) const;
virtual void fillSystemIndexes(
arangodb::LogicalCollection* col,
std::vector<std::shared_ptr<arangodb::Index>>& systemIndexes) const = 0;
virtual std::vector<std::string> supportedIndexes() const = 0;
static TRI_idx_iid_t validateSlice(arangodb::velocypack::Slice info,
bool generateKey,
bool isClusterConstructor);
private:
std::unordered_map<std::string, IndexTypeFactory> _factories;
std::unordered_map<std::string, IndexNormalizer> _normalizers;
};
} // namespace arangodb
#endif
#endif

View File

@ -2125,7 +2125,7 @@ TRI_vocbase_t* MMFilesEngine::openExistingDatabase(TRI_voc_tick_t id,
// we found a collection that is still active
TRI_ASSERT(!it.get("id").isNone() || !it.get("cid").isNone());
auto uniqCol =
std::make_shared<arangodb::LogicalCollection>(vocbase.get(), it, false);
std::make_shared<arangodb::LogicalCollection>(*vocbase, it, false);
auto collection = uniqCol.get();
TRI_ASSERT(collection != nullptr);
StorageEngine::registerCollection(vocbase.get(), uniqCol);

View File

@ -29,11 +29,6 @@
#include "Basics/VelocyPackHelper.h"
#include "Cluster/ServerState.h"
#include "Indexes/Index.h"
#ifdef USE_IRESEARCH
#include "IResearch/IResearchFeature.h"
#endif
#include "MMFiles/MMFilesEdgeIndex.h"
#include "MMFiles/MMFilesFulltextIndex.h"
#include "MMFiles/MMFilesGeoIndex.h"
@ -270,171 +265,220 @@ static int EnhanceJsonIndexFulltext(VPackSlice const definition,
return res;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief enhances the json of an index
////////////////////////////////////////////////////////////////////////////////
int MMFilesIndexFactory::enhanceIndexDefinition(VPackSlice const definition,
VPackBuilder& enhanced, bool create, bool isCoordinator) const {
// extract index type
Index::IndexType type = Index::TRI_IDX_TYPE_UNKNOWN;
VPackSlice current = definition.get("type");
if (current.isString()) {
std::string t = current.copyString();
// rewrite type "geo" into either "geo1" or "geo2", depending on the number
// of fields
if (t == "geo") {
t = "geo1";
current = definition.get("fields");
if (current.isArray() && current.length() == 2) {
t = "geo2";
}
MMFilesIndexFactory::MMFilesIndexFactory() {
emplaceFactory("edge", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
if (!isClusterConstructor) {
// this indexes cannot be created directly
THROW_ARANGO_EXCEPTION_MESSAGE(
TRI_ERROR_INTERNAL, "cannot create edge index"
);
}
type = Index::type(t);
}
if (type == Index::TRI_IDX_TYPE_UNKNOWN) {
return TRI_ERROR_BAD_PARAMETER;
}
return std::make_shared<MMFilesEdgeIndex>(id, collection);
});
if (create) {
if (type == Index::TRI_IDX_TYPE_PRIMARY_INDEX ||
type == Index::TRI_IDX_TYPE_EDGE_INDEX) {
emplaceFactory("fulltext", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<MMFilesFulltextIndex>(id, collection, definition);
});
emplaceFactory("geo1", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<MMFilesGeoIndex>(id, collection, definition);
});
emplaceFactory("geo2", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<MMFilesGeoIndex>(id, collection, definition);
});
emplaceFactory("hash", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<MMFilesHashIndex>(id, collection, definition);
});
emplaceFactory("persistent", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<MMFilesPersistentIndex>(id, collection, definition);
});
emplaceFactory("primary", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
if (!isClusterConstructor) {
// this indexes cannot be created directly
THROW_ARANGO_EXCEPTION_MESSAGE(
TRI_ERROR_INTERNAL, "cannot create primary index"
);
}
return std::make_shared<MMFilesPrimaryIndex>(collection);
});
emplaceFactory("skiplist", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<MMFilesSkiplistIndex>(id, collection, definition);
});
emplaceNormalizer("edge", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
if (isCreation) {
// creating these indexes yourself is forbidden
return TRI_ERROR_FORBIDDEN;
}
}
TRI_ASSERT(enhanced.isEmpty());
int res = TRI_ERROR_INTERNAL;
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_EDGE_INDEX)));
try {
VPackObjectBuilder b(&enhanced);
current = definition.get("id");
uint64_t id = 0;
if (current.isNumber()) {
id = current.getNumericValue<uint64_t>();
} else if (current.isString()) {
id = basics::StringUtils::uint64(current.copyString());
}
if (id > 0) {
enhanced.add("id", VPackValue(std::to_string(id)));
}
enhanced.add("type", VPackValue(Index::oldtypeName(type)));
switch (type) {
case Index::TRI_IDX_TYPE_PRIMARY_INDEX:
case Index::TRI_IDX_TYPE_EDGE_INDEX: {
break;
}
case Index::TRI_IDX_TYPE_GEO1_INDEX:
res = EnhanceJsonIndexGeo1(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_GEO2_INDEX:
res = EnhanceJsonIndexGeo2(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_HASH_INDEX:
res = EnhanceJsonIndexHash(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_SKIPLIST_INDEX:
res = EnhanceJsonIndexSkiplist(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_PERSISTENT_INDEX:
res = EnhanceJsonIndexPersistent(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_FULLTEXT_INDEX:
res = EnhanceJsonIndexFulltext(definition, enhanced, create);
break;
#ifdef USE_IRESEARCH
case Index::TRI_IDX_TYPE_IRESEARCH_LINK:
res = arangodb::iresearch::EnhanceJsonIResearchLink(definition, enhanced, create);
break;
#endif
case Index::TRI_IDX_TYPE_UNKNOWN:
default: {
res = TRI_ERROR_BAD_PARAMETER;
break;
}
}
} catch (basics::Exception const& ex) {
return ex.code();
} catch (std::exception const&) {
return TRI_ERROR_OUT_OF_MEMORY;
} catch (...) {
return TRI_ERROR_INTERNAL;
}
});
return res;
}
emplaceNormalizer("fulltext", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_FULLTEXT_INDEX)));
// Creates an index object.
// It does not modify anything and does not insert things into
// the index. It's also safe to use in cluster case.
std::shared_ptr<Index> MMFilesIndexFactory::prepareIndexFromSlice(
VPackSlice info, bool generateKey, LogicalCollection* col,
bool isClusterConstructor) const {
TRI_idx_iid_t iid = IndexFactory::validateSlice(info, generateKey, isClusterConstructor);
return EnhanceJsonIndexFulltext(definition, normalized, isCreation);
});
// extract type
VPackSlice value = info.get("type");
emplaceNormalizer("geo", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
auto current = definition.get("fields");
TRI_ASSERT(normalized.isOpenObject());
if (!value.isString()) {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER,
"invalid index type definition");
}
if (current.isArray() && current.length() == 2) {
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO2_INDEX)));
std::string const typeString = value.copyString();
if (typeString == "primary") {
if (!isClusterConstructor) {
// this indexes cannot be created directly
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"cannot create primary index");
return EnhanceJsonIndexGeo2(definition, normalized, isCreation);
}
return std::make_shared<MMFilesPrimaryIndex>(col);
}
if (typeString == "edge") {
if (!isClusterConstructor) {
// this indexes cannot be created directly
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"cannot create edge index");
}
return std::make_shared<MMFilesEdgeIndex>(iid, col);
}
if (typeString == "geo1" || typeString == "geo2") {
return std::make_shared<MMFilesGeoIndex>(iid, col, info);
}
if (typeString == "hash") {
return std::make_shared<MMFilesHashIndex>(iid, col, info);
}
if (typeString == "skiplist") {
return std::make_shared<MMFilesSkiplistIndex>(iid, col, info);
}
if (typeString == "persistent") {
return std::make_shared<MMFilesPersistentIndex>(iid, col, info);
}
if (typeString == "fulltext") {
return std::make_shared<MMFilesFulltextIndex>(iid, col, info);
}
#ifdef USE_IRESEARCH
if (arangodb::iresearch::IResearchFeature::type() == typeString) {
return arangodb::iresearch::IResearchMMFilesLink::make(iid, col, info);
}
#endif
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_NOT_IMPLEMENTED, std::string("invalid or unsupported index type '") + typeString + "'");
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO1_INDEX)));
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
});
emplaceNormalizer("geo1", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO1_INDEX)));
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
});
emplaceNormalizer("geo2", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO2_INDEX)));
return EnhanceJsonIndexGeo2(definition, normalized, isCreation);
});
emplaceNormalizer("hash", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_HASH_INDEX)));
return EnhanceJsonIndexHash(definition, normalized, isCreation);
});
emplaceNormalizer("primary", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
if (isCreation) {
// creating these indexes yourself is forbidden
return TRI_ERROR_FORBIDDEN;
}
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PRIMARY_INDEX)));
return TRI_ERROR_INTERNAL;
});
emplaceNormalizer("persistent", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
});
emplaceNormalizer("rocksdb", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
});
emplaceNormalizer("skiplist", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_SKIPLIST_INDEX)));
return EnhanceJsonIndexSkiplist(definition, normalized, isCreation);
});
}
void MMFilesIndexFactory::fillSystemIndexes(

View File

@ -29,19 +29,9 @@
namespace arangodb {
class MMFilesIndexFactory final : public IndexFactory {
public:
MMFilesIndexFactory() : IndexFactory() {}
~MMFilesIndexFactory() {}
int enhanceIndexDefinition(
arangodb::velocypack::Slice const definition,
arangodb::velocypack::Builder& enhanced, bool isCreation,
bool isCoordinator) const override;
std::shared_ptr<arangodb::Index> prepareIndexFromSlice(
arangodb::velocypack::Slice info, bool generateKey,
LogicalCollection* col, bool isClusterConstructor) const override;
public:
MMFilesIndexFactory();
~MMFilesIndexFactory() = default;
void fillSystemIndexes(arangodb::LogicalCollection* col,
std::vector<std::shared_ptr<arangodb::Index>>&
@ -52,4 +42,4 @@ class MMFilesIndexFactory final : public IndexFactory {
}
#endif
#endif

View File

@ -1088,7 +1088,7 @@ Result RestReplicationHandler::processRestoreCollectionCoordinator(
// not desired, so it is hardcoded to false
auto col = ClusterMethods::createCollectionOnCoordinator(
collectionType,
&_vocbase,
_vocbase,
merged,
ignoreDistributeShardsLikeErrors,
createWaitsForSyncReplication,

View File

@ -37,11 +37,15 @@ class ViewTypesFeature final: public application_features::ApplicationFeature {
/// type. the creator function is called when a view is first created or
/// re-opened after a server restart. the VelocyPack Slice will contain all
/// information about the view's general and implementation-specific properties.
/// @param preCommit called before completing view creation (IFF returns true)
/// e.g. before persisting definition to filesystem
/// IFF preCommit == false then skip invocation
//////////////////////////////////////////////////////////////////////////////
typedef std::function<std::shared_ptr<LogicalView>(
TRI_vocbase_t& vocbase, // database
velocypack::Slice const& definition, // view definition
uint64_t planVersion // cluster plan version ('0' by default for non-cluster)
uint64_t planVersion, // cluster plan version ('0' by default for non-cluster)
LogicalView::PreCommitCallback const& preCommit
)> ViewFactory;
explicit ViewTypesFeature(application_features::ApplicationServer* server);

View File

@ -1742,7 +1742,7 @@ TRI_vocbase_t* RocksDBEngine::openExistingDatabase(TRI_voc_tick_t id,
// we found a collection that is still active
TRI_ASSERT(!it.get("id").isNone() || !it.get("cid").isNone());
auto uniqCol =
std::make_shared<arangodb::LogicalCollection>(vocbase.get(), it, false);
std::make_shared<arangodb::LogicalCollection>(*vocbase, it, false);
auto collection = uniqCol.get();
TRI_ASSERT(collection != nullptr);
StorageEngine::registerCollection(vocbase.get(), uniqCol);

View File

@ -27,11 +27,6 @@
#include "Basics/VelocyPackHelper.h"
#include "Cluster/ServerState.h"
#include "Indexes/Index.h"
#ifdef USE_IRESEARCH
#include "IResearch/IResearchFeature.h"
#endif
#include "RocksDBEngine/RocksDBEdgeIndex.h"
#include "RocksDBEngine/RocksDBEngine.h"
#include "RocksDBEngine/RocksDBFulltextIndex.h"
@ -263,168 +258,410 @@ static int EnhanceJsonIndexFulltext(VPackSlice const definition,
return res;
}
int RocksDBIndexFactory::enhanceIndexDefinition(VPackSlice const definition,
VPackBuilder& enhanced,
bool create,
bool isCoordinator) const {
// extract index type
Index::IndexType type = Index::TRI_IDX_TYPE_UNKNOWN;
VPackSlice current = definition.get("type");
if (current.isString()) {
std::string t = current.copyString();
// rewrite type "geo" into either "geo1" or "geo2", depending on the number
// of fields
if (t == "geo") {
t = "geo1";
current = definition.get("fields");
if (current.isArray() && current.length() == 2) {
t = "geo2";
}
}
type = Index::type(t);
}
if (type == Index::TRI_IDX_TYPE_UNKNOWN) {
return TRI_ERROR_BAD_PARAMETER;
}
if (create) {
if (type == Index::TRI_IDX_TYPE_PRIMARY_INDEX ||
type == Index::TRI_IDX_TYPE_EDGE_INDEX) {
// creating these indexes yourself is forbidden
return TRI_ERROR_FORBIDDEN;
}
}
TRI_ASSERT(enhanced.isEmpty());
VPackObjectBuilder b(&enhanced);
current = definition.get("id");
uint64_t id = 0;
if (current.isNumber()) {
id = current.getNumericValue<uint64_t>();
} else if (current.isString()) {
id = basics::StringUtils::uint64(current.copyString());
}
if (id > 0) {
enhanced.add("id", VPackValue(std::to_string(id)));
}
if (create && !isCoordinator) {
if (!definition.hasKey("objectId")) {
enhanced.add("objectId",
VPackValue(std::to_string(TRI_NewTickServer())));
}
}
enhanced.add("type", VPackValue(Index::oldtypeName(type)));
int res = TRI_ERROR_INTERNAL;
switch (type) {
case Index::TRI_IDX_TYPE_PRIMARY_INDEX:
case Index::TRI_IDX_TYPE_EDGE_INDEX: {
break;
}
case Index::TRI_IDX_TYPE_GEO1_INDEX:
res = EnhanceJsonIndexGeo1(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_GEO2_INDEX:
res = EnhanceJsonIndexGeo2(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_HASH_INDEX:
res = EnhanceJsonIndexHash(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_SKIPLIST_INDEX:
res = EnhanceJsonIndexSkiplist(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_PERSISTENT_INDEX:
res = EnhanceJsonIndexPersistent(definition, enhanced, create);
break;
case Index::TRI_IDX_TYPE_FULLTEXT_INDEX:
res = EnhanceJsonIndexFulltext(definition, enhanced, create);
break;
#ifdef USE_IRESEARCH
case Index::TRI_IDX_TYPE_IRESEARCH_LINK:
res = arangodb::iresearch::EnhanceJsonIResearchLink(definition, enhanced, create);
break;
#endif
default: {
res = TRI_ERROR_BAD_PARAMETER;
break;
}
}
return res;
}
std::shared_ptr<Index> RocksDBIndexFactory::prepareIndexFromSlice(
arangodb::velocypack::Slice info, bool generateKey, LogicalCollection* col,
bool isClusterConstructor) const {
TRI_idx_iid_t iid = IndexFactory::validateSlice(info, generateKey, isClusterConstructor);
// extract type
VPackSlice value = info.get("type");
if (!value.isString()) {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER,
"invalid index type definition");
}
std::string const typeString = value.copyString();
if (typeString == "primary") {
RocksDBIndexFactory::RocksDBIndexFactory() {
emplaceFactory("edge", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
if (!isClusterConstructor) {
// this indexes cannot be created directly
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"cannot create primary index");
THROW_ARANGO_EXCEPTION_MESSAGE(
TRI_ERROR_INTERNAL, "cannot create edge index"
);
}
return std::make_shared<RocksDBPrimaryIndex>(col, info);
}
if (typeString == "edge") {
if (!isClusterConstructor) {
// this indexes cannot be created directly
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"cannot create edge index");
}
VPackSlice fields = info.get("fields");
auto fields = definition.get("fields");
TRI_ASSERT(fields.isArray() && fields.length() == 1);
std::string direction = fields.at(0).copyString();
TRI_ASSERT(direction == StaticStrings::FromString ||
direction == StaticStrings::ToString);
return std::make_shared<RocksDBEdgeIndex>(iid, col, info, direction);
}
if (typeString == "hash") {
return std::make_shared<RocksDBHashIndex>(iid, col, info);
}
if (typeString == "skiplist") {
return std::make_shared<RocksDBSkiplistIndex>(iid, col, info);
}
if (typeString == "persistent") {
return std::make_shared<RocksDBPersistentIndex>(iid, col, info);
}
if (typeString == "geo1" || typeString == "geo2") {
return std::make_shared<RocksDBGeoIndex>(iid, col, info);
}
if (typeString == "fulltext") {
return std::make_shared<RocksDBFulltextIndex>(iid, col, info);
}
#ifdef USE_IRESEARCH
if (arangodb::iresearch::IResearchFeature::type() == typeString) {
return arangodb::iresearch::IResearchRocksDBLink::make(iid, col, info);
}
#endif
auto direction = fields.at(0).copyString();
TRI_ASSERT(
direction == StaticStrings::FromString
|| direction == StaticStrings::ToString
);
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_NOT_IMPLEMENTED, std::string("invalid or unsupported index type '") + typeString + "'");
return std::make_shared<RocksDBEdgeIndex>(
id, collection, definition, direction
);
});
emplaceFactory("fulltext", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<RocksDBFulltextIndex>(id, collection, definition);
});
emplaceFactory("geo1", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<RocksDBGeoIndex>(id, collection, definition);
});
emplaceFactory("geo2", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<RocksDBGeoIndex>(id, collection, definition);
});
emplaceFactory("hash", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<RocksDBHashIndex>(id, collection, definition);
});
emplaceFactory("persistent", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<RocksDBPersistentIndex>(id, collection, definition);
});
emplaceFactory("primary", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
if (!isClusterConstructor) {
// this indexes cannot be created directly
THROW_ARANGO_EXCEPTION_MESSAGE(
TRI_ERROR_INTERNAL, "cannot create primary index"
);
}
return std::make_shared<RocksDBPrimaryIndex>(collection, definition);
});
emplaceFactory("skiplist", [](
LogicalCollection* collection,
velocypack::Slice const& definition,
TRI_idx_iid_t id,
bool isClusterConstructor
)->std::shared_ptr<Index> {
return std::make_shared<RocksDBSkiplistIndex>(id, collection, definition);
});
if (ServerState::instance()->isCoordinator()) {
emplaceNormalizer("edge", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
if (isCreation) {
// creating these indexes yourself is forbidden
return TRI_ERROR_FORBIDDEN;
}
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_EDGE_INDEX)));
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
return TRI_ERROR_INTERNAL;
});
} else {
emplaceNormalizer("edge", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
if (isCreation) {
// creating these indexes yourself is forbidden
return TRI_ERROR_FORBIDDEN;
}
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_EDGE_INDEX)));
return TRI_ERROR_INTERNAL;
});
}
if (ServerState::instance()->isCoordinator()) {
emplaceNormalizer("fulltext", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_FULLTEXT_INDEX)));
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
return EnhanceJsonIndexFulltext(definition, normalized, isCreation);
});
} else {
emplaceNormalizer("fulltext", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_FULLTEXT_INDEX)));
return EnhanceJsonIndexFulltext(definition, normalized, isCreation);
});
}
if (ServerState::instance()->isCoordinator()) {
emplaceNormalizer("geo", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
auto current = definition.get("fields");
TRI_ASSERT(normalized.isOpenObject());
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
if (current.isArray() && current.length() == 2) {
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO2_INDEX)));
return EnhanceJsonIndexGeo2(definition, normalized, isCreation);
}
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO1_INDEX)));
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
});
emplaceNormalizer("geo1", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO1_INDEX)));
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
});
emplaceNormalizer("geo2", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO2_INDEX)));
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
return EnhanceJsonIndexGeo2(definition, normalized, isCreation);
});
} else {
emplaceNormalizer("geo", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
auto current = definition.get("fields");
TRI_ASSERT(normalized.isOpenObject());
if (current.isArray() && current.length() == 2) {
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO2_INDEX)));
return EnhanceJsonIndexGeo2(definition, normalized, isCreation);
}
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO1_INDEX)));
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
});
emplaceNormalizer("geo1", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO1_INDEX)));
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
});
emplaceNormalizer("geo2", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO2_INDEX)));
return EnhanceJsonIndexGeo2(definition, normalized, isCreation);
});
}
if (ServerState::instance()->isCoordinator()) {
emplaceNormalizer("hash", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_HASH_INDEX)));
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
return EnhanceJsonIndexHash(definition, normalized, isCreation);
});
} else {
emplaceNormalizer("hash", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_HASH_INDEX)));
return EnhanceJsonIndexHash(definition, normalized, isCreation);
});
}
if (ServerState::instance()->isCoordinator()) {
emplaceNormalizer("primary", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
if (isCreation) {
// creating these indexes yourself is forbidden
return TRI_ERROR_FORBIDDEN;
}
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PRIMARY_INDEX)));
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
return TRI_ERROR_INTERNAL;
});
} else {
emplaceNormalizer("primary", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
if (isCreation) {
// creating these indexes yourself is forbidden
return TRI_ERROR_FORBIDDEN;
}
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PRIMARY_INDEX)));
return TRI_ERROR_INTERNAL;
});
}
if (ServerState::instance()->isCoordinator()) {
emplaceNormalizer("persistent", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
});
} else {
emplaceNormalizer("persistent", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
});
}
if (ServerState::instance()->isCoordinator()) {
emplaceNormalizer("rocksdb", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
});
} else {
emplaceNormalizer("rocksdb", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
});
}
if (ServerState::instance()->isCoordinator()) {
emplaceNormalizer("skiplist", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_SKIPLIST_INDEX)));
if (isCreation && !definition.hasKey("objectId")) {
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
}
return EnhanceJsonIndexSkiplist(definition, normalized, isCreation);
});
} else {
emplaceNormalizer("skiplist", [](
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation
)->arangodb::Result {
TRI_ASSERT(normalized.isOpenObject());
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_SKIPLIST_INDEX)));
return EnhanceJsonIndexSkiplist(definition, normalized, isCreation);
});
}
}
void RocksDBIndexFactory::fillSystemIndexes(

View File

@ -30,18 +30,8 @@ namespace arangodb {
class RocksDBIndexFactory final : public IndexFactory {
public:
RocksDBIndexFactory() : IndexFactory() {}
~RocksDBIndexFactory() {}
int enhanceIndexDefinition(arangodb::velocypack::Slice const definition,
arangodb::velocypack::Builder& enhanced,
bool isCreation,
bool isCoordinator) const override;
std::shared_ptr<arangodb::Index> prepareIndexFromSlice(
arangodb::velocypack::Slice info, bool generateKey,
LogicalCollection* col, bool isClusterConstructor) const override;
RocksDBIndexFactory();
~RocksDBIndexFactory() = default;
void fillSystemIndexes(arangodb::LogicalCollection* col,
std::vector<std::shared_ptr<arangodb::Index>>&
@ -49,6 +39,7 @@ class RocksDBIndexFactory final : public IndexFactory {
std::vector<std::string> supportedIndexes() const override;
};
}
#endif
#endif

View File

@ -208,7 +208,7 @@ LogicalCollection::LogicalCollection(LogicalCollection const& other)
// The Slice contains the part of the plan that
// is relevant for this collection.
LogicalCollection::LogicalCollection(
TRI_vocbase_t* vocbase,
TRI_vocbase_t& vocbase,
VPackSlice const& info,
bool isAStub,
uint64_t planVersion /*= 0*/

View File

@ -79,7 +79,7 @@ class LogicalCollection: public LogicalDataSource {
public:
LogicalCollection() = delete;
LogicalCollection(
TRI_vocbase_t* vocbase,
TRI_vocbase_t& vocbase,
velocypack::Slice const& info,
bool isAStub,
uint64_t planVersion = 0

View File

@ -86,7 +86,7 @@ class LogicalDataSource {
LogicalDataSource(
Category const& category,
Type const& type,
TRI_vocbase_t* vocbase,
TRI_vocbase_t& vocbase,
TRI_voc_cid_t id,
TRI_voc_cid_t planId,
std::string&& name,
@ -125,7 +125,7 @@ class LogicalDataSource {
uint64_t planVersion() const noexcept { return _planVersion; }
virtual Result rename(std::string&& newName, bool doSync) = 0;
Type const& type() const noexcept { return _type; }
TRI_vocbase_t* vocbase() const noexcept { return _vocbase; }
TRI_vocbase_t* vocbase() const noexcept { return &_vocbase; } // TODO change to reference
protected:
void deleted(bool deleted) noexcept { _deleted = deleted; }
@ -136,7 +136,7 @@ class LogicalDataSource {
std::string _name; // data-source name
Category const& _category; // the category of the logical data-source
Type const& _type; // the type of the underlying data-source implementation
TRI_vocbase_t* const _vocbase; // the database where the data-source resides TODO change to reference
TRI_vocbase_t& _vocbase; // the database where the data-source resides
TRI_voc_cid_t const _id; // local data-source id (current database node)
TRI_voc_cid_t const _planId; // global data-source id (cluster-wide)
uint64_t const _planVersion; // Only set if setPlanVersion was called. This only

View File

@ -95,7 +95,7 @@ namespace arangodb {
// The Slice contains the part of the plan that
// is relevant for this view
LogicalView::LogicalView(
TRI_vocbase_t* vocbase,
TRI_vocbase_t& vocbase,
VPackSlice const& definition,
uint64_t planVersion
): LogicalDataSource(
@ -161,7 +161,7 @@ LogicalView::LogicalView(
return nullptr;
}
auto view = viewFactory(vocbase, definition, planVersion);
auto view = viewFactory(vocbase, definition, planVersion, preCommit);
if (!view) {
LOG_TOPIC(ERR, Logger::VIEWS)
@ -170,24 +170,6 @@ LogicalView::LogicalView(
return nullptr;
}
if (preCommit && !preCommit(view)) {
LOG_TOPIC(ERR, Logger::VIEWS)
<< "Failure during pre-commit callback for view of type: "
<< viewType.toString();
return nullptr;
}
auto res = view->create();
if (!res.ok()) {
LOG_TOPIC(ERR, Logger::VIEWS)
<< "Failure during commit of creation for view of type: "
<< viewType.toString();
return nullptr;
}
return view;
}
@ -196,7 +178,7 @@ LogicalView::LogicalView(
// -----------------------------------------------------------------------------
DBServerLogicalView::DBServerLogicalView(
TRI_vocbase_t* vocbase,
TRI_vocbase_t& vocbase,
VPackSlice const& definition,
uint64_t planVersion
): LogicalView(vocbase, definition, planVersion) {
@ -211,7 +193,9 @@ DBServerLogicalView::~DBServerLogicalView() {
}
}
arangodb::Result DBServerLogicalView::create() noexcept {
/*static*/ arangodb::Result DBServerLogicalView::create(
DBServerLogicalView const& view
) noexcept {
TRI_ASSERT(!ServerState::instance()->isCoordinator());
StorageEngine* engine = EngineSelectorFeature::ENGINE;
TRI_ASSERT(engine);
@ -221,11 +205,11 @@ arangodb::Result DBServerLogicalView::create() noexcept {
// during recovery entry is being played back from the engine
if (!engine->inRecovery()) {
arangodb::velocypack::Builder builder;
auto res = engine->getViews(vocbase(), builder);
auto res = engine->getViews(view.vocbase(), builder);
TRI_ASSERT(TRI_ERROR_NO_ERROR == res);
auto slice = builder.slice();
TRI_ASSERT(slice.isArray());
auto viewId = std::to_string(id());
auto viewId = std::to_string(view.id());
// We have not yet persisted this view
for (auto entry: arangodb::velocypack::ArrayIterator(slice)) {
@ -243,18 +227,18 @@ arangodb::Result DBServerLogicalView::create() noexcept {
}
#endif
engine->createView(vocbase(), id(), *this);
engine->createView(view.vocbase(), view.id(), view);
return engine->persistView(vocbase(), *this);
return engine->persistView(view.vocbase(), view);
} catch (std::exception const& e) {
return arangodb::Result(
TRI_ERROR_INTERNAL,
std::string("caught exception during storage engine persistance of view '") + name() + "': " + e.what()
std::string("caught exception during storage engine persistance of view '") + view.name() + "': " + e.what()
);
} catch (...) {
return arangodb::Result(
TRI_ERROR_INTERNAL,
std::string("caught exception during storage engine persistance of view '") + name() + "'"
std::string("caught exception during storage engine persistance of view '") + view.name() + "'"
);
}
}

View File

@ -45,7 +45,15 @@ class Builder;
class LogicalView : public LogicalDataSource {
public:
typedef std::function<bool(TRI_voc_cid_t)> CollectionVisitor;
typedef std::function<bool(std::shared_ptr<LogicalView>const& view)> PreCommitCallback;
//////////////////////////////////////////////////////////////////////////////
/// @brief typedef for a LogicalView pre-commit callback
/// called before completing view creation
/// e.g. before persisting definition to filesystem
//////////////////////////////////////////////////////////////////////////////
typedef std::function<bool(
std::shared_ptr<LogicalView>const& view // a pointer to the created view
)> PreCommitCallback;
//////////////////////////////////////////////////////////////////////////////
/// @brief the category representing a logical view
@ -108,16 +116,11 @@ class LogicalView : public LogicalDataSource {
protected:
LogicalView(
TRI_vocbase_t* vocbase,
TRI_vocbase_t& vocbase,
velocypack::Slice const& definition,
uint64_t planVersion
);
//////////////////////////////////////////////////////////////////////////////
/// @brief called during view creation to complete creation e.g. persist to FS
//////////////////////////////////////////////////////////////////////////////
virtual arangodb::Result create() noexcept = 0;
private:
// FIXME seems to be ugly
friend struct ::TRI_vocbase_t;
@ -154,12 +157,16 @@ class DBServerLogicalView : public LogicalView {
protected:
DBServerLogicalView(
TRI_vocbase_t* vocbase,
TRI_vocbase_t& vocbase,
velocypack::Slice const& definition,
uint64_t planVersion
);
virtual arangodb::Result create() noexcept override final;
//////////////////////////////////////////////////////////////////////////////
/// @brief called by view factories during view creation to persist the view
/// to the storage engine
//////////////////////////////////////////////////////////////////////////////
static arangodb::Result create(DBServerLogicalView const& view) noexcept;
//////////////////////////////////////////////////////////////////////////////
/// @brief drop implementation-specific parts of an existing view

View File

@ -183,10 +183,15 @@ Result Collections::create(TRI_vocbase_t* vocbase, std::string const& name,
ExecContext const* exe = ExecContext::CURRENT;
AuthenticationFeature* af = AuthenticationFeature::instance();
if (ServerState::instance()->isCoordinator()) {
std::shared_ptr<LogicalCollection> col =
ClusterMethods::createCollectionOnCoordinator(
collectionType, vocbase, infoSlice, false,
createWaitsForSyncReplication, enforceReplicationFactor);
auto col = ClusterMethods::createCollectionOnCoordinator(
collectionType,
*vocbase,
infoSlice,
false,
createWaitsForSyncReplication,
enforceReplicationFactor
);
if (!col) {
return Result(TRI_ERROR_INTERNAL, "createCollectionOnCoordinator");
}

View File

@ -341,7 +341,8 @@ Result Indexes::ensureIndex(LogicalCollection* collection,
StorageEngine* engine = EngineSelectorFeature::ENGINE;
IndexFactory const* idxFactory = engine->indexFactory();
int res = idxFactory->enhanceIndexDefinition(
definition, defBuilder, create, ServerState::instance()->isCoordinator());
definition, defBuilder, create, ServerState::instance()->isCoordinator()
).errorNumber();
if (res != TRI_ERROR_NO_ERROR) {
return Result(res);

View File

@ -467,8 +467,8 @@ std::shared_ptr<arangodb::LogicalCollection> TRI_vocbase_t::createCollectionWork
// Try to create a new collection. This is not registered yet
std::shared_ptr<arangodb::LogicalCollection> collection =
std::make_unique<arangodb::LogicalCollection>(this, parameters, false);
auto collection =
std::make_shared<arangodb::LogicalCollection>(*this, parameters, false);
TRI_ASSERT(collection != nullptr);
RECURSIVE_WRITE_LOCKER(_dataSourceLock, _dataSourceLockWriteOwner);

View File

@ -77,13 +77,13 @@ extern const char* ARGV0; // defined in main.cpp
namespace {
struct IResearchQuerySetup {
struct IResearchBlockMockSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchBlockMockSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -91,6 +91,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true); // required for FeatureCacheFeature
@ -130,14 +135,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchBlockMockSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -167,7 +167,7 @@ struct IResearchQuerySetup {
// -----------------------------------------------------------------------------
TEST_CASE("ExecutionBlockMockTestSingle", "[iresearch]") {
IResearchQuerySetup s;
IResearchBlockMockSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");
@ -300,7 +300,7 @@ TEST_CASE("ExecutionBlockMockTestSingle", "[iresearch]") {
}
TEST_CASE("ExecutionBlockMockTestChain", "[iresearch]") {
IResearchQuerySetup s;
IResearchBlockMockSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -226,13 +226,13 @@ DEFINE_FACTORY_DEFAULT(custom_sort);
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct TestSetup {
struct IResearchExpressionFilterSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
TestSetup(): server(nullptr, nullptr) {
IResearchExpressionFilterSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::aql::AqlFunctionFeature* functions = nullptr;
@ -241,6 +241,10 @@ struct TestSetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -293,13 +297,9 @@ struct TestSetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~TestSetup() {
~IResearchExpressionFilterSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -328,7 +328,7 @@ NS_END
// -----------------------------------------------------------------------------
TEST_CASE("IResearchExpressionFilterTest", "[iresearch][iresearch-expression-filter]") {
TestSetup setup;
IResearchExpressionFilterSetup setup;
UNUSED(setup);
arangodb::velocypack::Builder testData;

View File

@ -147,6 +147,10 @@ struct IResearchFilterSetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
#ifdef USE_ENTERPRISE
features.emplace_back(new arangodb::LdapFeature(&server), false);
@ -207,10 +211,6 @@ struct IResearchFilterSetup {
auto* analyzers = arangodb::iresearch::getFeature<arangodb::iresearch::IResearchAnalyzerFeature>();
analyzers->emplace("test_analyzer", "TestCharAnalyzer", "abc"); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchFilterSetup() {

View File

@ -147,6 +147,10 @@ struct IResearchIndexSetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::AqlFeature(&server), true); // required for arangodb::aql::Query(...)
features.emplace_back(new arangodb::DatabasePathFeature(&server), false); // requires for IResearchView::open()
@ -185,6 +189,7 @@ struct IResearchIndexSetup {
~IResearchIndexSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
arangodb::application_features::ApplicationServer::server = nullptr;
arangodb::EngineSelectorFeature::ENGINE = nullptr;

View File

@ -78,6 +78,10 @@ struct IResearchLinkSetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
features.emplace_back(new arangodb::DatabaseFeature(&server), false);
@ -125,10 +129,6 @@ struct IResearchLinkSetup {
long systemError;
std::string systemErrorStr;
TRI_CreateDirectory(testFilesystemPath.c_str(), systemError, systemErrorStr);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchLinkSetup() {
@ -174,7 +174,7 @@ SECTION("test_defaults") {
auto* logicalCollection = vocbase.createCollection(collectionJson->slice());
REQUIRE((nullptr != logicalCollection));
auto json = arangodb::velocypack::Parser::fromJson("{}");
auto link = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, json->slice());
auto link = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, json->slice(), 1, false);
CHECK((true == !link));
}
@ -186,7 +186,7 @@ SECTION("test_defaults") {
auto* logicalCollection = vocbase.createCollection(collectionJson->slice());
REQUIRE((nullptr != logicalCollection));
auto json = arangodb::velocypack::Parser::fromJson("{ \"view\": 42 }");
auto link = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, json->slice());
auto link = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, json->slice(), 1, false);
CHECK((true == !link));
}
@ -340,7 +340,7 @@ SECTION("test_init") {
CHECK((actual.empty()));
}
auto link = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, linkJson->slice());
auto link = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, linkJson->slice(), 1, false);
CHECK((false == !link));
// collection in view after
@ -399,7 +399,7 @@ SECTION("test_init") {
CHECK((actual.empty()));
}
auto link = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, linkJson->slice());
auto link = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, linkJson->slice(), 1, false);
CHECK((false == !link));
// collection in view after
@ -446,7 +446,7 @@ SECTION("test_drop") {
auto logicalView = vocbase.createView(viewJson->slice());
REQUIRE((false == !logicalView));
auto link0 = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, linkJson->slice());
auto link0 = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, linkJson->slice(), 1, false);
CHECK((false == !link0));
// collection in view before
@ -479,7 +479,7 @@ SECTION("test_drop") {
CHECK((actual.empty()));
}
auto link1 = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, linkJson->slice());
auto link1 = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, linkJson->slice(), 1, false);
CHECK((false == !link1));
// collection in view before (new link)
@ -526,7 +526,7 @@ SECTION("test_unload") {
auto logicalView = vocbase.createView(viewJson->slice());
REQUIRE((false == !logicalView));
auto link = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, linkJson->slice());
auto link = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, linkJson->slice(), 1, false);
CHECK((false == !link));
// collection in view before

View File

@ -215,6 +215,10 @@ struct IResearchOrderSetup {
arangodb::tests::init();
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::AqlFeature(&server), true);
features.emplace_back(new arangodb::QueryRegistryFeature(&server), false);
@ -244,9 +248,6 @@ struct IResearchOrderSetup {
arangodb::aql::Function invalid("INVALID", "|.", false, true, true, false);
functions.add(invalid);
// suppress log messages since tests check error conditions
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchOrderSetup() {

View File

@ -160,6 +160,10 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
#ifdef USE_ENTERPRISE
features.emplace_back(new arangodb::LdapFeature(&server), false);
@ -198,10 +202,6 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryAggregateSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryAggregateSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryAggregateSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestAggregate", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryAggregateSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryAndSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryAndSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryAndSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestAnd", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryAndSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryBooleanTermSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryBooleanTermSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryBooleanTermSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestBooleanTerm", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryBooleanTermSetup s;
UNUSED(s);
// ==, !=, <, <=, >, >=, range

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryComplexBooleanSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryComplexBooleanSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryComplexBooleanSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestComplexBoolean", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryComplexBooleanSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -79,13 +79,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryExistsSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryExistsSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -93,6 +93,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -139,14 +144,9 @@ struct IResearchQuerySetup {
testFilesystemPath /= TRI_GetTempPath();
testFilesystemPath /= std::string("arangodb_tests.") + std::to_string(TRI_microtime());
const_cast<std::string&>(dbPathFeature->directory()) = testFilesystemPath.utf8();
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryExistsSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -180,7 +180,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestExists", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryExistsSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryInSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryInSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -130,14 +135,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryInSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -171,7 +171,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestIn", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryInSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -176,13 +176,13 @@ REGISTER_SCORER_JSON(CustomScorer, CustomScorer::make);
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryJoinSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryJoinSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::aql::AqlFunctionFeature* functions = nullptr;
@ -191,6 +191,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -262,14 +267,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryJoinSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -303,7 +303,7 @@ TEST_CASE("IResearchQueryTestJoinVolatileBlock", "[iresearch][iresearch-query]")
}
TEST_CASE("IResearchQueryTestJoinDuplicateDataSource", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryJoinSetup s;
UNUSED(s);
static std::vector<std::string> const EMPTY;
@ -514,7 +514,7 @@ TEST_CASE("IResearchQueryTestJoinDuplicateDataSource", "[iresearch][iresearch-qu
}
TEST_CASE("IResearchQueryTestJoin", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryJoinSetup s;
UNUSED(s);
static std::vector<std::string> const EMPTY;

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryNullTermSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryNullTermSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryNullTermSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestNullTerm", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryNullTermSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryNumericTermSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryNumericTermSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryNumericTermSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestNumericTerm", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryNumericTermSetup s;
UNUSED(s);
// ArangoDB specific string comparer

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryOrSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryOrSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryOrSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestOr", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryOrSetup s;
UNUSED(s);
static std::vector<std::string> const EMPTY;

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryPhraseSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryPhraseSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryPhraseSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestPhrase", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryPhraseSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQuerySelectAllSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQuerySelectAllSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQuerySelectAllSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestSelectAll", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQuerySelectAllSetup s;
UNUSED(s);
static std::vector<std::string> const EMPTY;

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryStartsWithSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryStartsWithSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryStartsWithSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestStartsWith", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryStartsWithSetup s;
UNUSED(s);
static std::vector<std::string> const EMPTY;

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryStringTermSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryStringTermSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::aql::AqlFunctionFeature* functions = nullptr;
@ -93,6 +93,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -158,14 +163,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryStringTermSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -199,7 +199,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestStringTerm", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryStringTermSetup s;
UNUSED(s);
// ArangoDB specific string comparer

View File

@ -85,13 +85,13 @@ struct TestTermAttribute: public irs::term_attribute {
extern const char* ARGV0; // defined in main.cpp
struct IResearchQuerySetup {
struct IResearchQueryTokensSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryTokensSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -99,6 +99,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -138,14 +143,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryTokensSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -179,7 +179,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestTokens", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryTokensSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryTraversalSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryTraversalSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryTraversalSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestTraversal", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryTraversalSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -78,13 +78,13 @@ NS_LOCAL
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
struct IResearchQuerySetup {
struct IResearchQueryValueSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::unique_ptr<TRI_vocbase_t> system;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
IResearchQuerySetup(): server(nullptr, nullptr) {
IResearchQueryValueSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
arangodb::tests::init(true);
@ -92,6 +92,11 @@ struct IResearchQuerySetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
features.emplace_back(new arangodb::AuthenticationFeature(&server), true);
@ -131,14 +136,9 @@ struct IResearchQuerySetup {
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchQuerySetup() {
~IResearchQueryValueSetup() {
system.reset(); // destroy before reseting the 'ENGINE'
arangodb::AqlFeature(&server).stop(); // unset singleton instance
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::DEFAULT);
@ -172,7 +172,7 @@ NS_END
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("IResearchQueryTestValue", "[iresearch][iresearch-query]") {
IResearchQuerySetup s;
IResearchQueryValueSetup s;
UNUSED(s);
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");

View File

@ -134,6 +134,11 @@ struct IResearchViewSetup {
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(), arangodb::LogLevel::WARN);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::FATAL); // suppress ERROR recovery failure due to error from callback
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
// setup required application features
features.emplace_back(new arangodb::V8DealerFeature(&server), false);
features.emplace_back(new arangodb::ViewTypesFeature(&server), true);
@ -185,11 +190,6 @@ struct IResearchViewSetup {
long systemError;
std::string systemErrorStr;
TRI_CreateDirectory(testFilesystemPath.c_str(), systemError, systemErrorStr);
// suppress log messages since tests check error conditions
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress ERROR recovery failure due to error from callback
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
}
~IResearchViewSetup() {
@ -440,7 +440,6 @@ SECTION("test_drop_cid") {
CHECK((false == !viewImpl));
auto* view = dynamic_cast<arangodb::iresearch::IResearchView*>(viewImpl.get());
CHECK((nullptr != view));
CHECK((s.engine.persistView(&vocbase, *view).ok())); // register view with engine
// fill with test data
{
@ -753,7 +752,6 @@ SECTION("test_emplace_cid") {
CHECK((false == !viewImpl));
auto* view = dynamic_cast<arangodb::iresearch::IResearchView*>(viewImpl.get());
CHECK((nullptr != view));
CHECK((s.engine.persistView(&vocbase, *view).ok())); // register view with engine
// collection in view before
{
@ -1452,7 +1450,7 @@ SECTION("test_register_link") {
StorageEngineMock::inRecoveryResult = true;
auto restore = irs::make_finally([&before]()->void { StorageEngineMock::inRecoveryResult = before; });
persisted = false;
auto link = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, linkJson->slice());
auto link = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, linkJson->slice(), 1, false);
CHECK((false == persisted));
CHECK((false == !link));
@ -1512,7 +1510,7 @@ SECTION("test_register_link") {
}
persisted = false;
auto link = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, linkJson->slice());
auto link = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, linkJson->slice(), 1, false);
CHECK((true == persisted)); // link instantiation does modify and persist view meta
CHECK((false == !link));
std::unordered_set<TRI_voc_cid_t> cids;
@ -1568,7 +1566,7 @@ SECTION("test_register_link") {
}
persisted = false;
auto link0 = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, linkJson->slice());
auto link0 = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, linkJson->slice(), 1, false);
CHECK((false == persisted));
CHECK((false == !link0));
@ -1594,7 +1592,7 @@ SECTION("test_register_link") {
}
persisted = false;
auto link1 = arangodb::iresearch::IResearchMMFilesLink::make(1, logicalCollection, linkJson->slice());
auto link1 = arangodb::iresearch::IResearchMMFilesLink::make(logicalCollection, linkJson->slice(), 1, false);
CHECK((false == persisted));
CHECK((false == !link1)); // duplicate link creation is allowed
std::unordered_set<TRI_voc_cid_t> cids;
@ -1918,7 +1916,6 @@ SECTION("test_tracked_cids") {
StorageEngineMock().registerView(&vocbase, logicalView); // ensure link can find view
auto* viewImpl = dynamic_cast<arangodb::iresearch::IResearchView*>(logicalView.get());
REQUIRE((nullptr != viewImpl));
CHECK((s.engine.persistView(&vocbase, *logicalView).ok())); // register view with engine
CHECK((viewImpl->updateProperties(updateJson->slice(), false, false).ok()));
@ -1947,7 +1944,6 @@ SECTION("test_tracked_cids") {
StorageEngineMock().registerView(&vocbase, logicalView); // ensure link can find view
auto* viewImpl = dynamic_cast<arangodb::iresearch::IResearchView*>(logicalView.get());
REQUIRE((nullptr != viewImpl));
CHECK((s.engine.persistView(&vocbase, *logicalView).ok())); // register view with engine
// create link
{

View File

@ -577,7 +577,7 @@ std::shared_ptr<arangodb::Index> PhysicalCollectionMock::createIndex(arangodb::t
index = EdgeIndexMock::make(++lastId, _logicalCollection, info);
#ifdef USE_IRESEARCH
} else if (0 == type.compare(arangodb::iresearch::IResearchFeature::type())) {
index = arangodb::iresearch::IResearchMMFilesLink::make(++lastId, _logicalCollection, info);
index = arangodb::iresearch::IResearchMMFilesLink::make(_logicalCollection, info, ++lastId, false);
#endif
}

View File

@ -36,18 +36,20 @@
namespace {
std::unique_ptr<arangodb::LogicalView> makeTestView(
std::shared_ptr<arangodb::LogicalView> makeTestView(
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
uint64_t planVersion
uint64_t planVersion,
arangodb::LogicalView::PreCommitCallback const& preCommit
) {
struct Impl: public arangodb::DBServerLogicalView {
Impl(
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
uint64_t planVersion
): arangodb::DBServerLogicalView(&vocbase, info, planVersion) {
): arangodb::DBServerLogicalView(vocbase, info, planVersion) {
}
arangodb::Result create() { return DBServerLogicalView::create(*this); }
virtual arangodb::Result dropImpl() override { return arangodb::Result(); }
virtual void getPropertiesVPack(
arangodb::velocypack::Builder&,
@ -68,7 +70,12 @@ std::unique_ptr<arangodb::LogicalView> makeTestView(
}
};
return std::make_unique<Impl>(vocbase, info, planVersion);
auto view = std::make_shared<Impl>(vocbase, info, planVersion);
return
(!preCommit || preCommit(std::static_pointer_cast<arangodb::LogicalView>(view)))
&& view->create().ok()
? view : nullptr;
}
}

View File

@ -23,6 +23,7 @@
#include "catch.hpp"
#include "../IResearch/StorageEngineMock.h"
#include "RestServer/QueryRegistryFeature.h"
#include "StorageEngine/EngineSelectorFeature.h"
#include "velocypack/Parser.h"
#include "VocBase/LogicalCollection.h"
@ -34,13 +35,43 @@
struct LogicalDataSourceSetup {
StorageEngineMock engine;
arangodb::application_features::ApplicationServer server;
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
LogicalDataSourceSetup() {
LogicalDataSourceSetup(): server(nullptr, nullptr) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
// setup required application features
features.emplace_back(new arangodb::QueryRegistryFeature(&server), false); // required for TRI_vocbase_t
for (auto& f: features) {
arangodb::application_features::ApplicationServer::server->addFeature(f.first);
}
for (auto& f: features) {
f.first->prepare();
}
for (auto& f: features) {
if (f.second) {
f.first->start();
}
}
}
~LogicalDataSourceSetup() {
arangodb::EngineSelectorFeature::ENGINE = nullptr;
// destroy application features
for (auto& f : features) {
if (f.second) {
f.first->stop();
}
}
for (auto& f : features) {
f.first->unprepare();
}
}
};
@ -59,8 +90,9 @@ TEST_CASE("LogicalDataSourceTest", "[vocbase]") {
SECTION("test_category") {
// LogicalCollection
{
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");
auto json = arangodb::velocypack::Parser::fromJson("{ \"name\": \"testCollection\" }");
arangodb::LogicalCollection instance(nullptr, json->slice(), true);
arangodb::LogicalCollection instance(vocbase, json->slice(), true);
CHECK((arangodb::LogicalCollection::category() == instance.category()));
}
@ -69,10 +101,9 @@ SECTION("test_category") {
{
class LogicalViewImpl: public arangodb::LogicalView {
public:
LogicalViewImpl(TRI_vocbase_t* vocbase, arangodb::velocypack::Slice const& definition)
LogicalViewImpl(TRI_vocbase_t& vocbase, arangodb::velocypack::Slice const& definition)
: LogicalView(vocbase, definition, 0) {
}
virtual arangodb::Result create() noexcept override { return arangodb::Result(); }
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(); }
@ -81,8 +112,9 @@ SECTION("test_category") {
virtual bool visitCollections(CollectionVisitor const& visitor) const override { return true; }
};
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");
auto json = arangodb::velocypack::Parser::fromJson("{ \"name\": \"testView\" }");
LogicalViewImpl instance(nullptr, json->slice());
LogicalViewImpl instance(vocbase, json->slice());
CHECK((arangodb::LogicalView::category() == instance.category()));
}

View File

@ -37,18 +37,20 @@
namespace {
std::unique_ptr<arangodb::LogicalView> makeTestView(
std::shared_ptr<arangodb::LogicalView> makeTestView(
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
uint64_t planVersion
uint64_t planVersion,
arangodb::LogicalView::PreCommitCallback const& preCommit
) {
struct Impl: public arangodb::DBServerLogicalView{
Impl(
TRI_vocbase_t& vocbase,
arangodb::velocypack::Slice const& info,
uint64_t planVersion
): DBServerLogicalView(&vocbase, info, planVersion) {
): DBServerLogicalView(vocbase, info, planVersion) {
}
arangodb::Result create() { return DBServerLogicalView::create(*this); }
virtual arangodb::Result dropImpl() override { return arangodb::Result(); }
virtual void getPropertiesVPack(
arangodb::velocypack::Builder&,
@ -69,7 +71,12 @@ std::unique_ptr<arangodb::LogicalView> makeTestView(
}
};
return std::make_unique<Impl>(vocbase, info, planVersion);
auto view = std::make_shared<Impl>(vocbase, info, planVersion);
return
(!preCommit || preCommit(std::static_pointer_cast<arangodb::LogicalView>(view)))
&& view->create().ok()
? view : nullptr;
}
}