1
0
Fork 0
This commit is contained in:
Dan Larkin-York 2018-11-21 03:35:18 -05:00 committed by Jan
parent c81545ce71
commit 452acf2a11
5 changed files with 46 additions and 6 deletions

View File

@ -74,7 +74,7 @@ bool createLink(
)->bool {
// ignored fields
return key != arangodb::StaticStrings::IndexType
&& key != arangodb::iresearch::StaticStrings::ViewIdField;
&& key != arangodb::iresearch::StaticStrings::ViewIdField;
};
arangodb::velocypack::Builder builder;
@ -181,7 +181,7 @@ arangodb::Result modifyLinks(
)->bool {
// ignored fields
return key != arangodb::StaticStrings::IndexType
&& key != arangodb::iresearch::StaticStrings::ViewIdField;
&& key != arangodb::iresearch::StaticStrings::ViewIdField;
};
arangodb::velocypack::Builder namedJson;
@ -659,4 +659,4 @@ namespace iresearch {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -41,6 +41,7 @@
#include "Aql/AstNode.h"
#include "Aql/QueryCache.h"
#include "Basics/StaticStrings.h"
#include "Logger/LogMacros.h"
#include "StorageEngine/EngineSelectorFeature.h"
#include "StorageEngine/TransactionState.h"
@ -1007,7 +1008,29 @@ arangodb::Result IResearchView::appendVelocyPackDetailed(
}
linkBuilder.close();
linksBuilderWrapper->add(collectionName, linkBuilder.slice());
// need to mask out some fields
static const std::function<bool(irs::string_ref const& key)> acceptor = [](
irs::string_ref const& key
)->bool {
return key != arangodb::StaticStrings::IndexId
&& key != arangodb::StaticStrings::IndexType
&& key != StaticStrings::ViewIdField; // ignored fields
};
arangodb::velocypack::Builder sanitizedBuilder;
sanitizedBuilder.openObject();
if (!mergeSliceSkipKeys(sanitizedBuilder, linkBuilder.slice(), acceptor)) {
Result result(TRI_ERROR_INTERNAL,
std::string("failed to generate externally visible link ")
.append("definition while emplacing link definition into ")
.append("arangosearch view '").append(name()).append("'"));
LOG_TOPIC(WARN, iresearch::TOPIC) << result.errorMessage();
return result;
}
sanitizedBuilder.close();
linksBuilderWrapper->add(collectionName, sanitizedBuilder.slice());
}
}
}

View File

@ -25,6 +25,8 @@
#include "IResearchCommon.h"
#include "IResearchLinkCoordinator.h"
#include "IResearchLinkHelper.h"
#include "Basics/StaticStrings.h"
#include "Basics/StringUtils.h"
#include "Cluster/ClusterInfo.h"
#include "Cluster/ClusterFeature.h"
@ -269,8 +271,9 @@ bool IResearchViewCoordinator::emplace(
static const std::function<bool(irs::string_ref const& key)> acceptor = [](
irs::string_ref const& key
)->bool {
return key != arangodb::StaticStrings::IndexType
&& key != StaticStrings::ViewIdField; // ignored fields
return key != arangodb::StaticStrings::IndexId
&& key != arangodb::StaticStrings::IndexType
&& key != StaticStrings::ViewIdField; // ignored fields
};
arangodb::velocypack::Builder builder;

View File

@ -2402,6 +2402,13 @@ int MMFilesCollection::restoreIndex(transaction::Methods* trx,
return TRI_ERROR_INTERNAL;
}
// check if we already have this index
auto oldIdx = lookupIndex(info);
if (oldIdx) {
idx = oldIdx;
return TRI_ERROR_NO_ERROR;
}
// We create a new Index object to make sure that the index
// is not handed out except for a successful case.
std::shared_ptr<Index> newIdx;

View File

@ -434,6 +434,13 @@ int RocksDBCollection::restoreIndex(transaction::Methods* trx,
if (!info.isObject()) {
return TRI_ERROR_INTERNAL;
}
// check if we already have this index
auto oldIdx = lookupIndex(info);
if (oldIdx) {
idx = oldIdx;
return TRI_ERROR_NO_ERROR;
}
// We create a new Index object to make sure that the index
// is not handed out except for a successful case.