diff options
author | David Storch <david.storch@mongodb.com> | 2021-12-21 11:15:42 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-21 11:55:50 +0000 |
commit | 19080405d9c7d08b54e70228a92d237223f2885c (patch) | |
tree | 73748cedfa62252c21968fdd4d0290972bbf3641 /src/mongo/db/s/shard_metadata_util.cpp | |
parent | 58ca93e30a6436f47a8e8eaa3ddc831e376965dc (diff) | |
download | mongo-19080405d9c7d08b54e70228a92d237223f2885c.tar.gz |
SERVER-61385 Migrate callers of 'DBClientBase::query()' legacy API to the modern 'find()' API
There are a handful of remaining callers of the legacy API,
either using the exhaust option or which are involved in a
code path which still relies on the OP_QUERY-inspired BSON
format. These should be cleaned up as follow-up work.
Diffstat (limited to 'src/mongo/db/s/shard_metadata_util.cpp')
-rw-r--r-- | src/mongo/db/s/shard_metadata_util.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/mongo/db/s/shard_metadata_util.cpp b/src/mongo/db/s/shard_metadata_util.cpp index fe9e22f715b..fa829fe2270 100644 --- a/src/mongo/db/s/shard_metadata_util.cpp +++ b/src/mongo/db/s/shard_metadata_util.cpp @@ -162,11 +162,10 @@ StatusWith<ShardCollectionType> readShardCollectionsEntry(OperationContext* opCt try { DBDirectClient client(opCtx); - std::unique_ptr<DBClientCursor> cursor = - client.query(NamespaceString::kShardConfigCollectionsNamespace, - BSON(ShardCollectionType::kNssFieldName << nss.ns()), - Query(), - 1); + FindCommandRequest findRequest{NamespaceString::kShardConfigCollectionsNamespace}; + findRequest.setFilter(BSON(ShardCollectionType::kNssFieldName << nss.ns())); + findRequest.setLimit(1); + std::unique_ptr<DBClientCursor> cursor = client.find(std::move(findRequest)); if (!cursor) { return Status(ErrorCodes::OperationFailed, str::stream() << "Failed to establish a cursor for reading " @@ -191,11 +190,10 @@ StatusWith<ShardCollectionType> readShardCollectionsEntry(OperationContext* opCt StatusWith<ShardDatabaseType> readShardDatabasesEntry(OperationContext* opCtx, StringData dbName) { try { DBDirectClient client(opCtx); - std::unique_ptr<DBClientCursor> cursor = - client.query(NamespaceString::kShardConfigDatabasesNamespace, - BSON(ShardDatabaseType::name() << dbName.toString()), - Query(), - 1); + FindCommandRequest findRequest{NamespaceString::kShardConfigDatabasesNamespace}; + findRequest.setFilter(BSON(ShardDatabaseType::name() << dbName.toString())); + findRequest.setLimit(1); + std::unique_ptr<DBClientCursor> cursor = client.find(std::move(findRequest)); if (!cursor) { return Status(ErrorCodes::OperationFailed, str::stream() << "Failed to establish a cursor for reading " @@ -313,8 +311,13 @@ StatusWith<std::vector<ChunkType>> readShardChunks(OperationContext* opCtx, try { DBDirectClient client(opCtx); - std::unique_ptr<DBClientCursor> cursor = - client.query(chunksNss, query, Query().sort(sort), limit.get_value_or(0)); + FindCommandRequest findRequest{chunksNss}; + findRequest.setFilter(query); + findRequest.setSort(sort); + if (limit) { + findRequest.setLimit(*limit); + } + std::unique_ptr<DBClientCursor> cursor = client.find(std::move(findRequest)); uassert(ErrorCodes::OperationFailed, str::stream() << "Failed to establish a cursor for reading " << chunksNss.ns() << " from local storage", |