10000 manually-merge: cache data-sources in CollectionNameResolver · mnemosdev/arangodb@c8739cd · GitHub
[go: up one dir, main page]

Skip to content

Commit c8739cd

Browse files
manually-merge: cache data-sources in CollectionNameResolver
1 parent f8b9e17 commit c8739cd

34 files changed

+399
-279
lines changed

arangod/Aql/GraphNode.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ GraphNode::GraphNode(ExecutionPlan* plan, size_t id, TRI_vocbase_t* vocbase,
149149
}
150150
seenCollections.emplace(eColName, dir);
151151

152-
if (resolver->getCollectionTypeCluster(eColName) != TRI_COL_TYPE_EDGE) {
152+
auto collection = resolver->getCollection(eColName);
153+
154+
if (!collection || collection->type() != TRI_COL_TYPE_EDGE) {
153155
std::string msg("collection type invalid for collection '" +
154156
std::string(eColName) +
155157
": expecting collection type 'edge'");

arangod/Aql/OptimizerRules.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4656,7 +4656,7 @@ static bool applyFulltextOptimization(EnumerateListNode* elnode,
46564656
coll = colls->add(name, AccessMode::Type::READ);
46574657
if (!ServerState::instance()->isCoordinator()) {
46584658
TRI_ASSERT(coll != nullptr);
4659-
coll->setCollection(vocbase->lookupCollection(name));
4659+
coll->setCollection(vocbase->lookupCollection(name).get());
46604660
// FIXME: does this need to happen in the coordinator?
46614661
plan->getAst()->query()->trx()->addCollectionAtRuntime(name);
46624662
}

arangod/IResearch/IResearchAnalyzerFeature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ void IResearchAnalyzerFeature::start() {
943943
LOG_TOPIC(WARN, iresearch::IResearchFeature::IRESEARCH) << "failure to get system database while starting feature 'IResearchAnalyzer'";
944944
// assume configuration collection exists
945945
} else {
946-
auto* collection = vocbase->lookupCollection(ANALYZER_COLLECTION_NAME);
946+
auto collection = vocbase->lookupCollection(ANALYZER_COLLECTION_NAME);
947947

948948
if (!collection) {
949949
auto* engine = arangodb::EngineSelectorFeature::ENGINE;

arangod/IResearch/IResearchRocksDBRecoveryHelper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ std::pair<TRI_vocbase_t*, arangodb::LogicalCollection*> lookupDatabaseAndCollect
5858
return std::make_pair(nullptr, nullptr);
5959
}
6060

61-
return std::make_pair(vocbase, vocbase->lookupCollection(pair.second));
61+
return std::make_pair(vocbase, vocbase->lookupCollection(pair.second).get());
6262
}
6363

6464
std::vector<std::shared_ptr<arangodb::Index>> lookupLinks(
@@ -82,7 +82,7 @@ arangodb::iresearch::IResearchLink* lookupLink(
8282
TRI_voc_cid_t cid,
8383
TRI_idx_iid_t iid
8484
) {
85-
auto* col = vocbase.lookupCollection(cid);
85+
auto col = vocbase.lookupCollection(cid);
8686

8787
if (!col) {
8888
// invalid cid
@@ -166,7 +166,7 @@ void ensureLink(
166166
return;
167167
}
168168

169-
auto* col = vocbase->lookupCollection(cid);
169+
auto col = vocbase->lookupCollection(cid);
170170

171171
if (!col) {
172172
// if the underlying collection gone, we can go on
@@ -246,7 +246,7 @@ void dropCollectionFromView(
246246
auto* vocbase = db.useDatabase(dbId);
247247

248248
if (vocbase) {
249-
auto* logicalCollection = vocbase->lookupCollection(collectionId);
249+
auto logicalCollection = vocbase->lookupCollection(collectionId);
250250

251251
if (!logicalCollection) {
252252
LOG_TOPIC(TRACE, arangodb::iresearch::IResearchFeature::IRESEARCH)

arangod/IResearch/IResearchView.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ arangodb::Result updateLinks(
468468
}
469469

470470
struct State {
471-
arangodb::LogicalCollection* _collection = nullptr;
471+
std::shared_ptr<arangodb::LogicalCollection> _collection;
472472
size_t _collectionsToLockOffset; // std::numeric_limits<size_t>::max() == removal only
473473
arangodb::iresearch::IResearchLink const* _link = nullptr;
474474
size_t _linkDefinitionsOffset;
@@ -554,12 +554,12 @@ arangodb::Result updateLinks(
554554
// );
555555
}
556556

557-
auto* resolver = trx.resolver();
557+
auto* vocbase = trx.vocbase();
558558

559-
if (!resolver) {
559+
if (!vocbase) {
560560
return arangodb::Result(
561561
TRI_ERROR_INTERNAL,
562-
std::string("failed to get resolver from transaction while updating while iResearch view '") + std::to_string(view.id()) + "'"
562+
std::string("failed to get vocbase from transaction while updating while IResearch view '") + std::to_string(view.id()) + "'"
563563
);
564564
}
565565

@@ -572,7 +572,7 @@ arangodb::Result updateLinks(
572572
auto& state = *itr;
573573
auto& collectionName = collectionsToLock[state._collectionsToLockOffset];
574574

575-
state._collection = const_cast<arangodb::LogicalCollection*>(resolver->getCollectionStruct(collectionName));
575+
state._collection = vocbase->lookupCollection(collectionName);
576576

577577
if (!state._collection) {
578578
// remove modification state if removal of non-existant link on non-existant collection
@@ -708,7 +708,7 @@ void validateLinks(
708708
arangodb::iresearch::IResearchView const& view
709709
) {
710710
for (auto itr = collections.begin(), end = collections.end(); itr != end;) {
711-
auto* collection = vocbase.lookupCollection(*itr);
711+
auto collection = vocbase.lookupCollection(*itr);
712712

713713
if (!collection || !findFirstMatchingLink(*collection, view)) {
714714
itr = collections.erase(itr);
@@ -2012,7 +2012,7 @@ arangodb::Result IResearchView::updateProperties(
20122012
}
20132013

20142014
for (auto& cid: meta._collections) {
2015-
auto* collection = vocbase->lookupCollection(cid);
2015+
auto collection = vocbase->lookupCollection(cid);
20162016

20172017
if (collection) {
20182018
_meta._collections.emplace(cid);

arangod/MMFiles/MMFilesRestReplicationHandler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ void MMFilesRestReplicationHandler::handleCommandLoggerFollow() {
372372
std::string const& value6 = _request->value("collection", found);
373373

374374
if (found) {
375-
arangodb::LogicalCollection* c = _vocbase->lookupCollection(value6);
375+
auto c = _vocbase->lookupCollection(value6);
376376

377377
if (c == nullptr) {
378378
generateError(rest::ResponseCode::NOT_FOUND,
@@ -661,7 +661,7 @@ void MMFilesRestReplicationHandler::handleCommandCreateKeys() {
661661
tickEnd = static_cast<TRI_voc_tick_t>(StringUtils::uint64(value));
662662
}
663663

664-
arangodb::LogicalCollection* c = _vocbase->lookupCollection(collection);
664+
auto c = _vocbase->lookupCollection(collection);
665665

666666
if (c == nullptr) {
667667
generateError(rest::ResponseCode::NOT_FOUND,
@@ -990,7 +990,8 @@ void MMFilesRestReplicationHandler::handleCommandDump() {
990990
withTicks = StringUtils::boolean(value7);
991991
}
992992

993-
LogicalCollection* c = _vocbase->lookupCollection(collection);
993+
auto c = _vocbase->lookupCollection(collection);
994+
994995
if (c == nullptr) {
995996
generateError(rest::ResponseCode::NOT_FOUND,
996997
TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);

arangod/MMFiles/MMFilesTransactionCollection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ int MMFilesTransactionCollection::use(int nestingLevel) {
213213
_collection = _transaction->vocbase()->useCollection(_cid, status);
214214
} else {
215215
// use without usage-lock (lock already set externally)
216-
_collection = _transaction->vocbase()->lookupCollection(_cid);
216+
_collection = _transaction->vocbase()->lookupCollection(_cid).get();
217217

218218
if (_collection == nullptr) {
219219
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;

arangod/MMFiles/MMFilesV8Functions.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@ static void JS_WaitCollectorWal(
472472
}
473473

474474
std::string const name = TRI_ObjectToString(args[0]);
475-
476-
arangodb::LogicalCollection* col = vocbase->lookupCollection(name);
475+
auto col = vocbase->lookupCollection(name);
477476

478477
if (col == nullptr) {
479478
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);

arangod/MMFiles/MMFilesWalRecoverState.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
676676
state->releaseCollection(collectionId);
677677

678678
if (collection == nullptr) {
679-
collection = vocbase->lookupCollection(collectionId);
679+
collection = vocbase->lookupCollection(collectionId).get();
680680
}
681681

682682
if (collection == nullptr) {
@@ -697,7 +697,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
697697
std::string name = nameSlice.copyString();
698698

699699
// check if other collection exist with target name
700-
arangodb::LogicalCollection* other = vocbase->lookupCollection(name);
700+
auto other = vocbase->lookupCollection(name);
701701

702702
if (other != nullptr) {
703703
if (other->cid() == collection->cid()) {
@@ -708,7 +708,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
708708
} else {
709709
TRI_voc_cid_t otherCid = other->cid();
710710
state->releaseCollection(otherCid);
711-
vocbase->dropCollection(other, true, -1.0);
711+
vocbase->dropCollection(other.get(), true, -1.0);
712712
}
713713
}
714714

@@ -963,8 +963,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
963963
return true;
964964
}
965965

966-
arangodb::LogicalCollection* col =
967-
vocbase->lookupCollection(collectionId);
966+
auto col = vocbase->lookupCollection(collectionId);
968967

969968
if (col == nullptr) {
970969
// if the underlying collection gone, we can go on
@@ -1053,7 +1052,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
10531052
state->releaseCollection(collectionId);
10541053

10551054
if (collection == nullptr) {
1056-
collection = vocbase->lookupCollection(collectionId);
1055+
collection = vocbase->lookupCollection(collectionId).get();
10571056
}
10581057

10591058
if (collection != nullptr) {
@@ -1071,7 +1070,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
10711070

10721071
if (nameSlice.isString()) {
10731072
name = nameSlice.copyString();
1074-
collection = vocbase->lookupCollection(name);
1073+
collection = vocbase->lookupCollection(name).get();
10751074

10761075
if (collection != nullptr) {
10771076
TRI_voc_cid_t otherCid = collection->cid();
@@ -1345,8 +1344,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
13451344
return true;
13461345
}
13471346

1348-
arangodb::LogicalCollection* col =
1349-
vocbase->lookupCollection(collectionId);
1347+
auto col = vocbase->lookupCollection(collectionId);
13501348

13511349
if (col == nullptr) {
13521350
// if the underlying collection gone, we can go on
@@ -1396,7 +1394,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
13961394
state->releaseCollection(collectionId);
13971395

13981396
if (collection == nullptr) {
1399-
collection = vocbase->lookupCollection(collectionId);
1397+
collection = vocbase->lookupCollection(collectionId).get();
14001398
}
14011399

14021400
if (collection != nullptr) {

arangod/Pregel/Conductor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ static void resolveInfo(
478478
std::vector<ShardID>& allShards) {
479479
ServerState* ss = ServerState::instance();
480480
if (!ss->isRunningInCluster()) { // single server mode
481-
LogicalCollection* lc = vocbase->lookupCollection(collectionID);
481+
auto lc = vocbase->lookupCollection(collectionID);
482+
482483
if (lc == nullptr || lc->deleted()) {
483484
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
484485
collectionID);

0 commit comments

Comments
 (0)
0