Skip to content

Commit 782386f

Browse files
committed
Delete ShardNamer interface.
1 parent 0cce4aa commit 782386f

File tree

7 files changed

+9
-169
lines changed

7 files changed

+9
-169
lines changed

src/mongo/db/SConscript

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,6 @@ env.Library(
10281028
'exec/shard_filter.cpp',
10291029
'exec/shard_filterer_impl.cpp',
10301030
'exec/shard_name.cpp',
1031-
'exec/shard_namer_impl.cpp',
10321031
'exec/skip.cpp',
10331032
'exec/sort.cpp',
10341033
'exec/sort_key_generator.cpp',

src/mongo/db/exec/shard_name.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "mongo/db/exec/filter.h"
3737
#include "mongo/db/exec/scoped_timer.h"
3838
#include "mongo/db/exec/working_set_common.h"
39+
#include "mongo/db/s/sharding_state.h"
3940
#include "mongo/s/shard_key_pattern.h"
4041

4142
namespace mongo {
@@ -49,12 +50,11 @@ using std::string;
4950
const char* ShardNameStage::kStageType = "SHARD_NAME";
5051

5152
ShardNameStage::ShardNameStage(OperationContext* opCtx,
52-
ScopedCollectionMetadata metadata,
5353
WorkingSet* ws,
5454
std::unique_ptr<PlanStage> child)
55-
: PlanStage(kStageType, opCtx), _ws(ws), _shardNamer(std::move(metadata)) {
55+
: PlanStage(kStageType, opCtx), _ws(ws) {
5656
_children.emplace_back(std::move(child));
57-
}
57+
}
5858

5959
ShardNameStage::~ShardNameStage() {}
6060

@@ -72,12 +72,12 @@ PlanStage::StageState ShardNameStage::doWork(WorkingSetID* out) {
7272

7373
if (PlanStage::ADVANCED == status) {
7474
// If we're sharded make sure to add shardName to the output.
75-
if (_shardNamer.isCollectionSharded()) {
75+
auto sharding = ShardingState::get(this->getOpCtx());
76+
if (sharding->enabled()) {
7677
WorkingSetMember* member = _ws->get(*out);
77-
const StringData shardName = _shardNamer.shardName();
7878

7979
// Populate the working set member with the shard name and return it.
80-
member->metadata().setShardName(shardName);
80+
member->metadata().setShardName(sharding->shardId());
8181
}
8282

8383
// If we're here either we have shard state and added the shardName, or we have no shard

src/mongo/db/exec/shard_name.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@
3030
#pragma once
3131

3232
#include "mongo/db/exec/plan_stage.h"
33-
#include "mongo/db/exec/shard_namer_impl.h"
3433

3534
namespace mongo {
3635

3736
class ShardNameStage final : public PlanStage {
3837
public:
3938
ShardNameStage(OperationContext* opCtx,
40-
ScopedCollectionMetadata metadata,
4139
WorkingSet* ws,
4240
std::unique_ptr<PlanStage> child);
4341
~ShardNameStage();
@@ -57,14 +55,6 @@ class ShardNameStage final : public PlanStage {
5755

5856
private:
5957
WorkingSet* _ws;
60-
61-
// Note: it is important that this owns the ScopedCollectionMetadata from the time this stage
62-
// is constructed. See ScopedCollectionMetadata class comment and MetadataManager comment for
63-
// details. The existence of the ScopedCollectionMetadata prevents data which may have been
64-
// migrated from being deleted while the query is still active. If we didn't hold one
65-
// ScopedCollectionMetadata for the entire query, it'd be possible for data which the query
66-
// needs to read to be deleted while it's still running.
67-
ShardNamerImpl _shardNamer;
6858
};
6959

7060
} // namespace mongo

src/mongo/db/exec/shard_namer.h

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/mongo/db/exec/shard_namer_impl.cpp

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/mongo/db/exec/shard_namer_impl.h

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/mongo/db/query/stage_builder.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,9 @@ std::unique_ptr<PlanStage> buildStages(OperationContext* opCtx,
283283
warning() << "building stage: STAGE_SHARD_NAME";
284284
const ShardNameNode* fn = static_cast<const ShardNameNode*>(root);
285285
auto childStage = buildStages(opCtx, collection, cq, qsol, fn->children[0], ws);
286-
if (nullptr == childStage) {
287-
return nullptr;
288-
}
289-
290-
auto css = CollectionShardingState::get(opCtx, collection->ns());
291-
return std::make_unique<ShardNameStage>(opCtx, css->getCurrentMetadata(), ws, std::move(childStage));
286+
return childStage == nullptr
287+
? nullptr
288+
: std::make_unique<ShardNameStage>(opCtx, ws, std::move(childStage));
292289
}
293290
case STAGE_DISTINCT_SCAN: {
294291
const DistinctNode* dn = static_cast<const DistinctNode*>(root);

0 commit comments

Comments
 (0)