8000 issue 344.7: remove more redundant functions (#4863) · Sandychuang/arangodb@06eb8ad · GitHub
[go: up one dir, main page]

Skip to content

Commit 06eb8ad

Browse files
vasiliy-arangodbjsteemann
authored andcommitted
issue 344.7: remove more redundant functions (arangodb#4863)
* issue 344.7: remove more redundant functions * backport: fix missed functions under USE_ENTERPRISE
1 parent 7931015 commit 06eb8ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+420
-282
lines changed

arangod/Aql/EnumerateCollectionBlock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ int EnumerateCollectionBlock::initialize() {
5757
if (_collection->isSatellite()) {
5858
auto logicalCollection = _collection->getCollection();
5959
auto cid = logicalCollection->planId();
60-
auto dbName = logicalCollection->dbName();
61-
60+
TRI_ASSERT(logicalCollection->vocbase());
61+
auto dbName = logicalCollection->vocbase()->name();
6262
double maxWait = _engine->getQuery()->queryOptions().satelliteSyncWait;
6363
bool inSync = false;
6464
unsigned long waitInterval = 10000;

arangod/Aql/ExecutionEngine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
483483
aql::QueryOptions opts = query->queryOptions();
484484
TRI_ASSERT(opts.transactionOptions.skipInaccessibleCollections);
485485
opts.inaccessibleCollections.insert(shardId);
486-
opts.inaccessibleCollections.insert(collection->getCollection()->cid_as_string());
486+
opts.inaccessibleCollections.insert(std::to_string(collection->getCollection()->id()));
487487
opts.toVelocyPack(result, true);
488488
} else {
489489
// the toVelocyPack will open & close the "options" object
@@ -832,7 +832,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
832832
TRI_ASSERT(ServerState::instance()->isSingleServerOrCoordinator());
833833
TRI_ASSERT(trxOps.skipInaccessibleCollections);
834834
pair->second.inaccessibleShards.insert(shard);
835-
pair->second.inaccessibleShards.insert(collection.second->getCollection()->cid_as_string());
835+
pair->second.inaccessibleShards.insert(std::to_string(collection.second->getCollection()->id()));
836836
}
837837
#endif
838838
}
@@ -860,7 +860,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
860860
if (trx->isInaccessibleCollectionId(it->getPlanId())) {
861861
TRI_ASSERT(trxOps.skipInaccessibleCollections);
862862
pair->second.inaccessibleShards.insert(shard);
863-
pair->second.inaccessibleShards.insert(it->getCollection()->cid_as_string());
863+
pair->second.inaccessibleShards.insert(std::to_string(it->getCollection()->id()));
864864
}
865865
#endif
866866
}

arangod/Cluster/ClusterMethods.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,9 @@ CloneShardDistribution(ClusterInfo* ci, LogicalCollection* col,
552552
auto result = std::make_shared<std::unordered_map<std::string, std::vector<std::string>>>();
553553
TRI_ASSERT(cid != 0);
554554
std::string cidString = arangodb::basics::StringUtils::itoa(cid);
555-
std::shared_ptr<LogicalCollection> other =
556-
ci->getCollection(col->dbName(), cidString);
555+
TRI_ASSERT(col->vocbase());
556+
auto other = ci->getCollection(col->vocbase()->name(), cidString);
557+
557558
// The function guarantees that no nullptr is returned
558559
TRI_ASSERT(other != nullptr);
559560

@@ -2685,9 +2686,11 @@ std::shared_ptr<LogicalCollection> ClusterMethods::persistCollectionInAgency(
26852686
col->setStatus(TRI_VOC_COL_STATUS_LOADED);
26862687
VPackBuilder velocy = col->toVelocyPackIgnore(ignoreKeys, false, false);
26872688

2689+
TRI_ASSERT(col->vocbase());
2690+
auto& dbName = col->vocbase()->name();
26882691
std::string errorMsg;
26892692
int myerrno = ci->createCollectionCoordinator(
2690-
col->dbName(),
2693+
dbName,
26912694
std::to_string(col->id()),
26922695
col->numberOfShards(), col->replicationFactor(),
26932696
waitForSyncReplication, velocy.slice(), errorMsg, 240.0);
@@ -2698,9 +2701,10 @@ std::shared_ptr<LogicalCollection> ClusterMethods::persistCollectionInAgency(
26982701
}
26992702
THROW_ARANGO_EXCEPTION_MESSAGE(myerrno, errorMsg);
27002703
}
2704+
27012705
ci->loadPlan();
27022706

2703-
auto c = ci->getCollection(col->dbName(), std::to_string(col->id()));
2707+
auto c = ci->getCollection(dbName, std::to_string(col->id()));
27042708
// We never get a nullptr here because an exception is thrown if the
27052709
// collection does not exist. Also, the create collection should have
27062710
// failed before.

arangod/Cluster/ShardDistributionReporter.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,11 @@ void ShardDistributionReporter::helperDistributionForDatabase(
290290
std::vector<ServerID> serversToAsk;
291291
while (!todoSyncStateCheck.empty()) {
292292
counters.clear();
293-
auto const col = todoSyncStateCheck.front();
294293

294+
auto const col = todoSyncStateCheck.front();
295295
auto allShards = col->shardIds();
296-
auto cic = _ci->getCollectionCurrent(dbName, col->cid_as_string());
296+
auto cic = _ci->getCollectionCurrent(dbName, std::to_string(col->id()));
297+
297298
// Send requests
298299
for (auto const& s : *(allShards.get())) {
299300
double timeleft = endtime - TRI_microtime();
@@ -480,12 +481,15 @@ bool ShardDistributionReporter::testAllShardsInSync(
480481
TRI_ASSERT(col != nullptr);
481482
TRI_ASSERT(shardIds != nullptr);
482483

483-
auto cic = _ci->getCollectionCurrent(dbName, col->cid_as_string());
484+
auto cic = _ci->getCollectionCurrent(dbName, std::to_string(col->id()));
485+
484486
for (auto const& s : *shardIds) {
485487
auto curServers = cic->servers(s.first);
488+
486489
if (!TestIsShardInSync(s.second, curServers)) {
487490
return false;
488491
}
489492
}
493+
490494
return true;
491495
}

arangod/Indexes/Index.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,19 +378,23 @@ bool Index::Compare(VPackSlice const& lhs, VPackSlice const& rhs) {
378378

379379
/// @brief return a contextual string for logging
380380
std::string Index::context() const {
381+
TRI_ASSERT(_collection->vocbase());
381382
std::ostringstream result;
382383

383384
result << "index { id: " << id() << ", type: " << oldtypeName()
384-
<< ", collection: " << _collection->dbName() << "/"
385+
<< ", collection: " << _collection->vocbase()->name() << "/"
385386
<< _collection->name() << ", unique: " << (_unique ? "true" : "false")
386387
<< ", fields: ";
387388
result << "[";
389+
388390
for (size_t i = 0; i < _fields.size(); ++i) {
389391
if (i > 0) {
390392
result << ", ";
391393
}
394+
392395
result << _fields[i];
393396
}
397+
394398
result << "] }";
395399

396400
return result.str();

arangod/MMFiles/MMFilesCollection.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3332,11 +3332,17 @@ Result MMFilesCollection::update(
33323332
*builder.get(), options.isRestore, revisionId);
33333333

33343334
if (_isDBServer) {
3335+
TRI_ASSERT(_logicalCollection->vocbase());
33353336
// Need to check that no sharding keys have changed:
3336-
if (arangodb::shardKeysChanged(_logicalCollection->dbName(),
3337-
trx->resolver()->getCollectionNameCluster(
3338-
_logicalCollection->planId()),
3339-
oldDoc, builder->slice(), false)) {
3337+
if (arangodb::shardKeysChanged(
3338+
_logicalCollection->vocbase()->name(),
3339+
trx->resolver()->getCollectionNameCluster(
3340+
_logicalCollection->planId()
3341+
),
3342+
oldDoc,
3343+
builder->slice(),
3344+
false
3345+
)) {
33403346
return Result(TRI_ERROR_CLUSTER_MUST_NOT_CHANGE_SHARDING_ATTRIBUTES);
33413347
}
33423348
}
@@ -3465,11 +3471,17 @@ Result MMFilesCollection::replace(
34653471
options.isRestore, revisionId);
34663472

34673473
if (_isDBServer) {
3474+
TRI_ASSERT(_logicalCollection->vocbase());
34683475
// Need to check that no sharding keys have changed:
3469-
if (arangodb::shardKeysChanged(_logicalCollection->dbName(),
3470-
trx->resolver()->getCollectionNameCluster(
3471-
_logicalCollection->planId()),
3472-
oldDoc, builder->slice(), false)) {
3476+
if (arangodb::shardKeysChanged(
3477+
_logicalCollection->vocbase()->name(),
3478+
trx->resolver()->getCollectionNameCluster(
3479+
_logicalCollection->planId()
3480+
),
3481+
oldDoc,
3482+
builder->slice(),
3483+
false
3484+
)) {
34733485
return Result(TRI_ERROR_CLUSTER_MUST_NOT_CHANGE_SHARDING_ATTRIBUTES);
34743486
}
34753487
}

arangod/MMFiles/MMFilesWalRecoverState.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,13 +700,14 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
700700
auto other = vocbase->lookupCollection(name);
701701

702702
if (other != nullptr) {
703-
if (other->cid() == collection->cid()) {
703+
if (other->id() == collection->id()) {
704704
LOG_TOPIC(TRACE, arangodb::Logger::ENGINES)
705705
<< "collection " << collectionId << " in database "
706706
<< databaseId << " already renamed; moving on";
707707
break;
708708
} else {
709-
TRI_voc_cid_t otherCid = other->cid();
709+
auto otherCid = other->id();
710+
710711
state->releaseCollection(otherCid);
711712
vocbase->dropCollection(other.get(), true, -1.0);
712713
}
@@ -1073,7 +1074,7 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
10731074
collection = vocbase->lookupCollection(name).get();
10741075

10751076
if (collection != nullptr) {
1076-
TRI_voc_cid_t otherCid = collection->cid();
1077+
auto otherCid = collection->id();
10771078

10781079
state->releaseCollection(otherCid);
10791080
vocbase->dropCollection(collection, true, -1.0);
@@ -1609,9 +1610,9 @@ int MMFilesWalRecoverState::fillIndexes() {
16091610
physical->useSecondaryIndexes(true);
16101611

16111612
auto ctx = transaction::StandaloneContext::Create(collection->vocbase());
1612-
arangodb::SingleCollectionTransaction trx(ctx, collection->cid(),
1613-
AccessMode::Type::WRITE);
1614-
1613+
arangodb::SingleCollectionTransaction trx(
1614+
ctx, collection->id(), AccessMode::Type::WRITE
1615+
);
16151616
int res = physical->fillAllIndexes(&trx);
16161617

16171618
if (res != TRI_ERROR_NO_ERROR) {

arangod/MMFiles/mmfiles-replication-dump.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,9 @@ static int DumpCollection(MMFilesReplicationDumpContext* dump,
365365
TRI_voc_tick_t databaseId, TRI_voc_cid_t collectionId,
366366
TRI_voc_tick_t dataMin, TRI_voc_tick_t dataMax,
367367
bool withTicks, bool useVst = false) {
368-
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "dumping collection " << collection->cid() << ", tick range "
369-
<< dataMin << " - " << dataMax;
368+
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
369+
<< "dumping collection " << collection->id()
370+
<< ", tick range " << dataMin << " - " << dataMax;
370371

371372
bool const isEdgeCollection = (collection->type() == TRI_COL_TYPE_EDGE);
372373

@@ -460,8 +461,15 @@ int MMFilesDumpCollectionReplication(MMFilesReplicationDumpContext* dump,
460461
MMFilesCompactionPreventer compactionPreventer(mmfiles);
461462

462463
try {
463-
res = DumpCollection(dump, collection, collection->vocbase()->id(),
464-
collection->cid(), dataMin, dataMax, withTicks);
464+
res = DumpCollection(
465+
dump,
466+
collection,
467+
collection->vocbase()->id(),
468+
collection->id(),
469+
dataMin,
470+
dataMax,
471+
withTicks
472+
);
465473
} catch (...) {
466474
res = TRI_ERROR_INTERNAL;
467475
}

arangod/Replication/DatabaseInitialSyncer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ Result DatabaseInitialSyncer::handleCollection(VPackSlice const& parameters,
798798
// -------------------------------------------------------------------------------------
799799

800800
if (phase == PHASE_DROP_CREATE) {
801-
arangodb::LogicalCollection* col = resolveCollection(vocbase(), parameters);
801+
auto* col = resolveCollection(vocbase(), parameters).get();
802802

803803
if (col == nullptr) {
804804
// not found...
@@ -918,16 +918,16 @@ Result DatabaseInitialSyncer::handleCollection(VPackSlice const& parameters,
918918
std::string const progress = "dumping data for " + collectionMsg;
919919
setProgress(progress);
920920

921-
arangodb::LogicalCollection* col = resolveCollection(vocbase(), parameters);
921+
auto* col = resolveCollection(vocbase(), parameters).get();
922922

923923
if (col == nullptr) {
924924
return Result(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND, std::string("cannot dump: ") +
925925
collectionMsg + " not found on slave. Collection info " + parameters.toJson());
926926
}
927927

928928
Result res;
929-
930929
std::string const& masterColl = !masterUuid.empty() ? masterUuid : StringUtils::itoa(masterCid);
930+
931931
if (incremental && getSize(col) > 0) {
932932
res = handleCollectionSync(col, masterColl, _masterInfo._lastLogTick);
933933
} else {

0 commit comments

Comments
 (0)
0