diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-11-11 11:50:24 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-11 17:19:50 +0000 |
commit | 90cfa3eeb18000ca3081e83be66ca4eaa244665e (patch) | |
tree | 85370139d47ee14edb28b392b35a7adb0ca1ae17 | |
parent | a9cf882445d4fd2775f40910d3087b483c3702e0 (diff) | |
download | mongo-90cfa3eeb18000ca3081e83be66ca4eaa244665e.tar.gz |
SERVER-51848 Rename generic arg/reply functions
-rw-r--r-- | buildscripts/idl/tests/test_parser.py | 2 | ||||
-rw-r--r-- | src/mongo/db/commands.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/commands_bm.cpp | 4 | ||||
-rw-r--r-- | src/mongo/idl/command_generic_argument.cpp | 14 | ||||
-rw-r--r-- | src/mongo/idl/command_generic_argument.h | 11 | ||||
-rw-r--r-- | src/mongo/idl/command_generic_argument_test.cpp | 12 |
6 files changed, 22 insertions, 25 deletions
diff --git a/buildscripts/idl/tests/test_parser.py b/buildscripts/idl/tests/test_parser.py index fac46404bc7..b1d9f0f1826 100644 --- a/buildscripts/idl/tests/test_parser.py +++ b/buildscripts/idl/tests/test_parser.py @@ -881,8 +881,6 @@ class TestParser(testcase.IDLTestcase): strict: false namespace: ignored is_deprecated: false - forward_to_shards: false - forward_from_shards: false immutable: false inline_chained_structs: false generate_comparison_operators: false diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 920c43113a2..65233e75a94 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -467,7 +467,7 @@ void CommandHelpers::filterCommandRequestForPassthrough(BSONObjIterator* cmdIter BSONObjBuilder(requestBuilder->subobjStart("$queryOptions")).append(elem); continue; } - if (isRequestStripArgument(name)) + if (!shouldForwardToShards(name)) continue; requestBuilder->append(elem); } @@ -477,7 +477,7 @@ void CommandHelpers::filterCommandReplyForPassthrough(const BSONObj& cmdObj, BSONObjBuilder* output) { for (auto elem : cmdObj) { const auto name = elem.fieldNameStringData(); - if (isReplyStripArgument(name)) + if (!shouldForwardFromShards(name)) continue; output->append(elem); } diff --git a/src/mongo/db/commands_bm.cpp b/src/mongo/db/commands_bm.cpp index 5c50f9c0ad2..94920bed08c 100644 --- a/src/mongo/db/commands_bm.cpp +++ b/src/mongo/db/commands_bm.cpp @@ -58,7 +58,7 @@ void BM_IsRequestStripArgument(benchmark::State& state) { const auto& key = keys[state.range()]; state.SetLabel(key.c_str()); for (auto _ : state) { - benchmark::DoNotOptimize(mongo::isRequestStripArgument(key)); + benchmark::DoNotOptimize(mongo::shouldForwardToShards(key)); } } @@ -66,7 +66,7 @@ void BM_IsReplyStripArgument(benchmark::State& state) { const auto& key = keys[state.range()]; state.SetLabel(key.c_str()); for (auto _ : state) { - benchmark::DoNotOptimize(mongo::isReplyStripArgument(key)); + benchmark::DoNotOptimize(mongo::shouldForwardFromShards(key)); } } diff --git a/src/mongo/idl/command_generic_argument.cpp b/src/mongo/idl/command_generic_argument.cpp index 9c6ebb2a23b..4d5c2861a6f 100644 --- a/src/mongo/idl/command_generic_argument.cpp +++ b/src/mongo/idl/command_generic_argument.cpp @@ -37,16 +37,14 @@ bool isGenericArgument(StringData arg) { return Generic_args_api_v1::hasField(arg) || Generic_args_unstable_v1::hasField(arg); } -// TODO(SERVER-51848): rename shouldForwardToShards -bool isRequestStripArgument(StringData arg) { - return !(Generic_args_api_v1::shouldForwardToShards(arg) && - Generic_args_unstable_v1::shouldForwardToShards(arg)); +bool shouldForwardToShards(StringData arg) { + return Generic_args_api_v1::shouldForwardToShards(arg) && + Generic_args_unstable_v1::shouldForwardToShards(arg); } -// TODO(SERVER-51848): rename shouldForwardFromShards -bool isReplyStripArgument(StringData arg) { - return !(Generic_reply_fields_api_v1::shouldForwardFromShards(arg) && - Generic_reply_fields_unstable_v1::shouldForwardFromShards(arg)); +bool shouldForwardFromShards(StringData replyField) { + return Generic_reply_fields_api_v1::shouldForwardFromShards(replyField) && + Generic_reply_fields_unstable_v1::shouldForwardFromShards(replyField); } bool isMongocryptdArgument(StringData arg) { diff --git a/src/mongo/idl/command_generic_argument.h b/src/mongo/idl/command_generic_argument.h index 69d695250ec..de8d264b14e 100644 --- a/src/mongo/idl/command_generic_argument.h +++ b/src/mongo/idl/command_generic_argument.h @@ -41,17 +41,18 @@ namespace mongo { bool isGenericArgument(StringData arg); /** - * Returns true if arg must be stripped from requests that are forwarded to shards. - * Only generic arguments are stripped, and some of them are not. + * Returns true if arg should be forwarded to shards. + * * See 'CommandHelpers::filterCommandRequestForPassthrough'. */ -bool isRequestStripArgument(StringData arg); +bool shouldForwardToShards(StringData arg); /** - * Returns true if arg is not safe to blindly forward from shards to clients. + * Returns true if replyField should be forwarded from shards to clients. + * * See 'CommandHelpers::filterCommandReplyForPassthrough'. */ -bool isReplyStripArgument(StringData arg); +bool shouldForwardFromShards(StringData replyField); /** * Returns true if the provided argument is one that should be handled by a mongocryptd process. diff --git a/src/mongo/idl/command_generic_argument_test.cpp b/src/mongo/idl/command_generic_argument_test.cpp index c02230d4722..7403b859821 100644 --- a/src/mongo/idl/command_generic_argument_test.cpp +++ b/src/mongo/idl/command_generic_argument_test.cpp @@ -94,14 +94,14 @@ TEST(CommandGenericArgument, AllGenericArgumentsAndReplyFields) { record.name, record.isGeneric, isGenericArgument(record.name))); } - if (isRequestStripArgument(record.name) != record.stripFromRequest) { - FAIL("isRequestStripArgument('{}') should be {}, but it's {}"_format( - record.name, record.stripFromRequest, isRequestStripArgument(record.name))); + if (shouldForwardToShards(record.name) == record.stripFromRequest) { + FAIL("shouldForwardToShards('{}') should be {}, but it's {}"_format( + record.name, !record.stripFromRequest, shouldForwardToShards(record.name))); } - if (isReplyStripArgument(record.name) != record.stripFromReply) { - FAIL("isReplyStripArgument('{}') should be {}, but it's {}"_format( - record.name, record.stripFromReply, isReplyStripArgument(record.name))); + if (shouldForwardFromShards(record.name) == record.stripFromReply) { + FAIL("shouldForwardFromShards('{}') should be {}, but it's {}"_format( + record.name, !record.stripFromReply, shouldForwardFromShards(record.name))); } } } |