SERVER-120884 Uniform API for IDL enum (de)serializers (#48902)
GitOrigin-RevId: 6537407bf6a76399a8509a4d7d81a94ec80d5a55
This commit is contained in:
parent
c959391697
commit
72dd8215bd
@ -39,6 +39,10 @@ import bson
|
||||
|
||||
from . import ast, common, writer
|
||||
|
||||
_SERIALIZER_ADL_HOOK = "idlSerialize"
|
||||
_DESERIALIZER_ADL_HOOK = "idlDeserialize"
|
||||
_DEFAULT_PARSER_ADL_HOOK = "idlGetDefaultParserFieldName"
|
||||
|
||||
|
||||
class EnumTypeInfoBase(object, metaclass=ABCMeta):
|
||||
"""Base type for enumeration type information."""
|
||||
@ -65,29 +69,17 @@ class EnumTypeInfoBase(object, metaclass=ABCMeta):
|
||||
"""Get the BSON type names for an enum."""
|
||||
pass
|
||||
|
||||
def _get_enum_deserializer_name(self):
|
||||
# type: () -> str
|
||||
"""Return the name of deserializer function without prefix."""
|
||||
return f"{common.title_case(self._enum.name)}_parse"
|
||||
|
||||
def get_enum_deserializer_name(self):
|
||||
# type: () -> str
|
||||
"""Return the name of deserializer function with non-method prefix."""
|
||||
return "::" + common.qualify_cpp_name(
|
||||
self._enum.cpp_namespace, self._get_enum_deserializer_name()
|
||||
)
|
||||
|
||||
def _get_enum_serializer_name(self):
|
||||
# type: () -> str
|
||||
"""Return the name of serializer function without prefix."""
|
||||
return f"{common.title_case(self._enum.name)}_serializer"
|
||||
"""Return the C++ name of the public deserializer function."""
|
||||
return f"::mongo::idl::deserialize<::{common.qualify_cpp_name(
|
||||
self._enum.cpp_namespace, self.get_cpp_type_name())}>"
|
||||
|
||||
def get_enum_serializer_name(self):
|
||||
# type: () -> str
|
||||
"""Return the name of serializer function with non-method prefix."""
|
||||
return "::" + common.qualify_cpp_name(
|
||||
self._enum.cpp_namespace, self._get_enum_serializer_name()
|
||||
)
|
||||
"""Return the C++ name of the public serializer function."""
|
||||
return f"::mongo::idl::serialize<::{common.qualify_cpp_name(
|
||||
self._enum.cpp_namespace, self.get_cpp_type_name())}>"
|
||||
|
||||
def _get_enum_extra_data_name(self):
|
||||
# type: () -> str
|
||||
@ -101,29 +93,35 @@ class EnumTypeInfoBase(object, metaclass=ABCMeta):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_deserializer_declaration(self, mod_tag):
|
||||
def get_deserializer_adl_hook_declaration(self, mod_tag):
|
||||
# type: () -> str
|
||||
"""Get the deserializer function declaration minus trailing semicolon."""
|
||||
"""Get the deserializer ADL hook function declaration minus trailing semicolon."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def gen_deserializer_definition(self, indented_writer):
|
||||
def gen_deserializer_adl_hook_definition(self, indented_writer):
|
||||
# type: (writer.IndentedTextWriter) -> None
|
||||
"""Generate the deserializer function definition."""
|
||||
"""Generate the deserializer ADL hook function definition."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_serializer_declaration(self, mod_tag):
|
||||
def get_serializer_adl_hook_declaration(self, mod_tag):
|
||||
# type: () -> str
|
||||
"""Get the serializer function declaration minus trailing semicolon."""
|
||||
"""Get the serializer ADL hook function declaration minus trailing semicolon."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def gen_serializer_definition(self, indented_writer):
|
||||
def gen_serializer_adl_hook_definition(self, indented_writer):
|
||||
# type: (writer.IndentedTextWriter) -> None
|
||||
"""Generate the serializer function definition."""
|
||||
"""Generate the serializer ADL hook function definition."""
|
||||
pass
|
||||
|
||||
def get_default_parser_field_name_adl_hook(self, mod_tag):
|
||||
"""Return a constexpr function returning the default fieldName for IDLParserContext.
|
||||
The generated function is found via ADL."""
|
||||
cpp_type = self.get_cpp_type_name()
|
||||
return f'{mod_tag}constexpr ::mongo::StringData {_DEFAULT_PARSER_ADL_HOOK}({cpp_type}) {{ return "{cpp_type}"; }}'
|
||||
|
||||
def _get_populated_extra_values(self):
|
||||
# type: () -> List[Union[syntax.EnumValue,ast.EnumValue]]
|
||||
"""Filter the enum values to just those containing extra_data."""
|
||||
@ -199,13 +197,12 @@ class _EnumTypeInt(EnumTypeInfoBase, metaclass=ABCMeta):
|
||||
# type: (ast.EnumValue) -> str
|
||||
return " = %s" % (enum_value.value)
|
||||
|
||||
def get_deserializer_declaration(self, mod_tag):
|
||||
def get_deserializer_adl_hook_declaration(self, mod_tag):
|
||||
# type: () -> str
|
||||
cpp_type = self.get_cpp_type_name()
|
||||
deserializer = self._get_enum_deserializer_name()
|
||||
return f'{mod_tag}{cpp_type} {deserializer}(std::int32_t value, const IDLParserContext& ctxt = IDLParserContext("{self.get_cpp_type_name()}"))'
|
||||
return f"{mod_tag}void {_DESERIALIZER_ADL_HOOK}({cpp_type}& en, std::int32_t value, const IDLParserContext& ctxt)"
|
||||
|
||||
def gen_deserializer_definition(self, indented_writer):
|
||||
def gen_deserializer_adl_hook_definition(self, indented_writer):
|
||||
# type: (writer.IndentedTextWriter) -> None
|
||||
enum_values = sorted(cast(ast.Enum, self._enum).values, key=lambda ev: int(ev.value))
|
||||
|
||||
@ -214,30 +211,29 @@ class _EnumTypeInt(EnumTypeInfoBase, metaclass=ABCMeta):
|
||||
max_value = enum_values[-1].name
|
||||
|
||||
cpp_type = self.get_cpp_type_name()
|
||||
func = self._get_enum_deserializer_name()
|
||||
indented_writer._stream.write(f"""
|
||||
{cpp_type} {func}(std::int32_t value, const IDLParserContext& ctxt) {{
|
||||
void {_DESERIALIZER_ADL_HOOK}({cpp_type}& en, std::int32_t value, const IDLParserContext& ctxt) {{
|
||||
if (!(value >= static_cast<std::underlying_type<{enum_name}>::type>(
|
||||
{enum_name}::{min_value}) &&
|
||||
value <= static_cast<std::underlying_type<{enum_name}>::type>(
|
||||
{enum_name}::{max_value}))) {{
|
||||
ctxt.throwBadEnumValue(value);
|
||||
}} else {{
|
||||
return static_cast<{enum_name}>(value);
|
||||
en = static_cast<{enum_name}>(value);
|
||||
}}
|
||||
}}""")
|
||||
|
||||
def get_serializer_declaration(self, mod_tag):
|
||||
def get_serializer_adl_hook_declaration(self, mod_tag):
|
||||
# type: () -> str
|
||||
"""Get the serializer function declaration minus trailing semicolon."""
|
||||
return f"{mod_tag}std::int32_t {self._get_enum_serializer_name()}({self.get_cpp_type_name()} value)"
|
||||
"""Get the serializer ADL hook function declaration minus trailing semicolon."""
|
||||
return f"{mod_tag}std::int32_t {_SERIALIZER_ADL_HOOK}({self.get_cpp_type_name()} value)"
|
||||
|
||||
def gen_serializer_definition(self, indented_writer):
|
||||
def gen_serializer_adl_hook_definition(self, indented_writer):
|
||||
# type: (writer.IndentedTextWriter) -> None
|
||||
"""Generate the serializer function definition."""
|
||||
"""Generate the serializer ADL hook function definition."""
|
||||
|
||||
indented_writer._stream.write(f"""
|
||||
{self.get_serializer_declaration('')} {{
|
||||
{self.get_serializer_adl_hook_declaration('')} {{
|
||||
return static_cast<std::int32_t>(value);
|
||||
}}""")
|
||||
|
||||
@ -263,16 +259,14 @@ class _EnumTypeString(EnumTypeInfoBase, metaclass=ABCMeta):
|
||||
# type: (ast.EnumValue) -> str
|
||||
return ""
|
||||
|
||||
def get_deserializer_declaration(self, mod_tag):
|
||||
def get_deserializer_adl_hook_declaration(self, mod_tag):
|
||||
# type: () -> str
|
||||
cpp_type = self.get_cpp_type_name()
|
||||
func = self._get_enum_deserializer_name()
|
||||
return f'{mod_tag}{cpp_type} {func}(StringData value, const IDLParserContext& ctxt = IDLParserContext("{cpp_type}"))'
|
||||
return f"{mod_tag}void {_DESERIALIZER_ADL_HOOK}({cpp_type}& en, ::mongo::StringData value, const IDLParserContext& ctxt)"
|
||||
|
||||
def gen_deserializer_definition(self, indented_writer):
|
||||
def gen_deserializer_adl_hook_definition(self, indented_writer):
|
||||
# type: (writer.IndentedTextWriter) -> None
|
||||
cpp_type = self.get_cpp_type_name()
|
||||
func = self._get_enum_deserializer_name()
|
||||
with writer.NamespaceScopeBlock(indented_writer, [""]):
|
||||
with writer.IndentedScopedBlock(
|
||||
indented_writer, f"constexpr std::array {cpp_type}_values{{", "};"
|
||||
@ -288,15 +282,13 @@ class _EnumTypeString(EnumTypeInfoBase, metaclass=ABCMeta):
|
||||
|
||||
with writer.IndentedScopedBlock(
|
||||
indented_writer,
|
||||
f"{cpp_type} {func}(StringData value, const IDLParserContext& ctxt) {{",
|
||||
f"void {_DESERIALIZER_ADL_HOOK}({cpp_type}& en, ::mongo::StringData value, const IDLParserContext& ctxt) {{",
|
||||
"}",
|
||||
):
|
||||
indented_writer.write_line(
|
||||
f"static constexpr auto onMatch = [](int i) {{ return {cpp_type}_values[i]; }};"
|
||||
)
|
||||
indented_writer.write_line(
|
||||
f"auto onFail = [&] {{ ctxt.throwBadEnumValue(value); return {cpp_type}{{}}; }};"
|
||||
f"auto onMatch = [&en](int i) {{ en = {cpp_type}_values[i]; }};"
|
||||
)
|
||||
indented_writer.write_line("auto onFail = [&] { ctxt.throwBadEnumValue(value); };")
|
||||
writer.gen_string_table_find_function_block(
|
||||
indented_writer,
|
||||
"value",
|
||||
@ -305,20 +297,18 @@ class _EnumTypeString(EnumTypeInfoBase, metaclass=ABCMeta):
|
||||
[e.value for e in self._enum.values],
|
||||
)
|
||||
|
||||
def get_serializer_declaration(self, mod_tag):
|
||||
def get_serializer_adl_hook_declaration(self, mod_tag):
|
||||
# type: () -> str
|
||||
"""Get the serializer function declaration minus trailing semicolon."""
|
||||
"""Get the serializer ADL hook function declaration minus trailing semicolon."""
|
||||
cpp_type = self.get_cpp_type_name()
|
||||
func = self._get_enum_serializer_name()
|
||||
return f"{mod_tag}StringData {func}({cpp_type} value)"
|
||||
return f"{mod_tag}::mongo::StringData {_SERIALIZER_ADL_HOOK}({cpp_type} value)"
|
||||
|
||||
def gen_serializer_definition(self, indented_writer):
|
||||
def gen_serializer_adl_hook_definition(self, indented_writer):
|
||||
# type: (writer.IndentedTextWriter) -> None
|
||||
"""Generate the serializer function definition."""
|
||||
func = self._get_enum_serializer_name()
|
||||
"""Generate the serializer ADL hook function definition."""
|
||||
cpp_type = self.get_cpp_type_name()
|
||||
indented_writer._stream.write(f"""
|
||||
StringData {func}({cpp_type} value) {{
|
||||
::mongo::StringData {_SERIALIZER_ADL_HOOK}({cpp_type} value) {{
|
||||
auto idx = static_cast<size_t>(value);
|
||||
invariant(idx < {cpp_type}_names.size());
|
||||
return {cpp_type}_names[idx];
|
||||
|
||||
@ -915,9 +915,17 @@ class _CppHeaderFileWriter(_CppFileWriterBase):
|
||||
enum_type_info = enum_types.get_type_info(idl_enum)
|
||||
mod_tag = make_mod_tag(idl_enum.mod_visibility)
|
||||
|
||||
self._writer.write_line("%s;" % (enum_type_info.get_deserializer_declaration(mod_tag)))
|
||||
self._writer.write_line(
|
||||
"%s;" % (enum_type_info.get_deserializer_adl_hook_declaration(mod_tag))
|
||||
)
|
||||
|
||||
self._writer.write_line("%s;" % (enum_type_info.get_serializer_declaration(mod_tag)))
|
||||
self._writer.write_line(
|
||||
"%s;" % (enum_type_info.get_serializer_adl_hook_declaration(mod_tag))
|
||||
)
|
||||
|
||||
self._writer.write_line(
|
||||
"%s" % (enum_type_info.get_default_parser_field_name_adl_hook(mod_tag))
|
||||
)
|
||||
|
||||
extra_data_decl = enum_type_info.get_extra_data_declaration(mod_tag)
|
||||
if extra_data_decl is not None:
|
||||
@ -3108,10 +3116,10 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
"""Generate the definitions for an enum's supporting functions."""
|
||||
enum_type_info = enum_types.get_type_info(idl_enum)
|
||||
|
||||
enum_type_info.gen_deserializer_definition(self._writer)
|
||||
enum_type_info.gen_deserializer_adl_hook_definition(self._writer)
|
||||
self._writer.write_empty_line()
|
||||
|
||||
enum_type_info.gen_serializer_definition(self._writer)
|
||||
enum_type_info.gen_serializer_adl_hook_definition(self._writer)
|
||||
self._writer.write_empty_line()
|
||||
|
||||
enum_type_info.gen_extra_data_definition(self._writer)
|
||||
@ -3282,12 +3290,10 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
return_type="std::unique_ptr<ServerParameter>",
|
||||
capture_ref=True,
|
||||
):
|
||||
self._writer.write_line(
|
||||
f"""\
|
||||
self._writer.write_line(f"""\
|
||||
auto {varname} = std::make_unique<IDLServerParameterDeprecatedAlias>({_encaps(alias)}, scp_{param_no}.get());
|
||||
{varname}->setIsDeprecated(true);
|
||||
return std::move({varname});"""
|
||||
)
|
||||
return std::move({varname});""")
|
||||
self._writer.write_line(f"registerServerParameter(std::move({varname}));")
|
||||
|
||||
def gen_server_parameters(self, params, header_file_name):
|
||||
|
||||
33
docs/idl.md
33
docs/idl.md
@ -11,6 +11,7 @@
|
||||
- [Enums](#enums)
|
||||
- [String Enums](#string-enums)
|
||||
- [Integer Enums](#integer-enums)
|
||||
- [Serialization/Deserialization API](#serializationdeserialization-api)
|
||||
- [Reference](#reference)
|
||||
- [Types](#types)
|
||||
- [Type Overview](#type-overview)
|
||||
@ -373,7 +374,7 @@ StringEnum:
|
||||
s2: "two"
|
||||
```
|
||||
|
||||
it generates an enum and functions to parse and serialize the enum:
|
||||
it generates an enum and ADL hooks to serialize and deserialize the enum:
|
||||
|
||||
```cpp
|
||||
enum class StringEnumEnum : std::int32_t {
|
||||
@ -382,10 +383,13 @@ enum class StringEnumEnum : std::int32_t {
|
||||
s2,
|
||||
};
|
||||
|
||||
StringEnumEnum StringEnum_parse(const IDLParserContext& ctxt, StringData value);
|
||||
StringData StringEnum_serializer(StringEnumEnum value);
|
||||
void idlDeserialize(StringEnumEnum& en, ::mongo::StringData value, const IDLParserContext& ctxt);
|
||||
::mongo::StringData idlSerialize(StringEnumEnum value);
|
||||
constexpr ::mongo::StringData idlGetDefaultParserFieldName(StringEnumEnum) { return "StringEnumEnum"; }
|
||||
```
|
||||
|
||||
These ADL hooks are not intended to be used directly by user code. See [Serialization/Deserialization API](#serializationdeserialization-api).
|
||||
|
||||
### Integer Enums
|
||||
|
||||
Used to map a integer value to a C++ enum value. In this case, the values of the enums themselves
|
||||
@ -402,7 +406,7 @@ IntEnum:
|
||||
s2: 4
|
||||
```
|
||||
|
||||
it generates an enum and functions to parse and serialize the enum:
|
||||
it generates an enum and ADL hooks to serialize and deserialize the enum:
|
||||
|
||||
```cpp
|
||||
enum class IntEnum : std::int32_t {
|
||||
@ -411,10 +415,27 @@ enum class IntEnum : std::int32_t {
|
||||
kS2 = 4,
|
||||
};
|
||||
|
||||
IntEnum IntEnum_parse(const IDLParserContext& ctxt, std::int32_t value);
|
||||
std::int32_t IntEnum_serializer(IntEnum value);
|
||||
void idlDeserialize(IntEnum& en, std::int32_t value, const IDLParserContext& ctxt);
|
||||
std::int32_t idlSerialize(IntEnum value);
|
||||
constexpr ::mongo::StringData idlGetDefaultParserFieldName(IntEnum) { return "IntEnum"; }
|
||||
```
|
||||
|
||||
These ADL hooks are not intended to be used directly by user code. See [Serialization/Deserialization API](#serializationdeserialization-api).
|
||||
|
||||
### Serialization/Deserialization API
|
||||
|
||||
The public API to serialize and deserialize IDL-generated enums is defined in
|
||||
[idl_parser.h](../src/mongo/idl/idl_parser.h) and can be used like this:
|
||||
|
||||
```cpp
|
||||
auto serialized = idl::serialize(enumToSerialize);
|
||||
auto parsedEnum = idl::deserialize<IdlEnum>(value);
|
||||
```
|
||||
|
||||
The definitions of `idl::serialize()` and `idl::deserialize()` rely on the autogenerated ADL hooks to
|
||||
find the serializer/deserializer implementations for each enum. User code should use this public API
|
||||
and not the ADL hooks directly.
|
||||
|
||||
### Reference
|
||||
|
||||
Each `enum` can have the following pieces:
|
||||
|
||||
@ -255,10 +255,10 @@ struct BSONValidateArrayIndexingParam {
|
||||
ErrorCodes::Error code;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const BSONValidateArrayIndexingParam& param) {
|
||||
os << "{name: " << param.name //
|
||||
<< ", obj: " << param.obj //
|
||||
<< ", mode: " << BSONValidateMode_serializer(param.mode) //
|
||||
<< ", code: " << param.code //
|
||||
os << "{name: " << param.name //
|
||||
<< ", obj: " << param.obj //
|
||||
<< ", mode: " << idl::serialize(param.mode) //
|
||||
<< ", code: " << param.code //
|
||||
<< "}";
|
||||
return os;
|
||||
}
|
||||
@ -454,7 +454,7 @@ public:
|
||||
}
|
||||
|
||||
static std::string generateName(const testing::TestParamInfo<ParamType>& info) {
|
||||
return fmt::format("{}_{}", info.param.name, BSONValidateMode_serializer(info.param.mode));
|
||||
return fmt::format("{}_{}", info.param.name, idl::serialize(info.param.mode));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ const BSONArray TagSet::kMatchAny = BSON_ARRAY(BSONObj());
|
||||
|
||||
Status validateReadPreferenceMode(const std::string& prefStr, const boost::optional<TenantId>&) {
|
||||
try {
|
||||
ReadPreference_parse(prefStr, IDLParserContext(kModeFieldName));
|
||||
idl::deserialize<ReadPreferenceEnum>(prefStr, IDLParserContext(kModeFieldName));
|
||||
} catch (DBException& e) {
|
||||
return e.toStatus();
|
||||
}
|
||||
|
||||
@ -478,7 +478,7 @@ void validateTextSearchIndex(BSONType fieldType,
|
||||
uassert(10774915,
|
||||
"The field 'precision' is not allowed for text-based index but is present",
|
||||
!query.getPrecision().has_value());
|
||||
auto qTypeStr = QueryType_serializer(query.getQueryType());
|
||||
auto qTypeStr = idl::serialize(query.getQueryType());
|
||||
|
||||
uassert(9783401,
|
||||
"Query type is not a text search query type",
|
||||
@ -571,8 +571,8 @@ void validateEncryptedField(const EncryptedField* field) {
|
||||
auto qtype2 = queryTypeConfigs.back().getQueryType();
|
||||
uassert(9783414,
|
||||
fmt::format("Multiple query types may only include the {} and {} query types",
|
||||
QueryType_serializer(QueryTypeEnum::SuffixPreview),
|
||||
QueryType_serializer(QueryTypeEnum::PrefixPreview)),
|
||||
idl::serialize(QueryTypeEnum::SuffixPreview),
|
||||
idl::serialize(QueryTypeEnum::PrefixPreview)),
|
||||
(qtype1 == QueryTypeEnum::SuffixPreview &&
|
||||
qtype2 == QueryTypeEnum::PrefixPreview) ||
|
||||
(qtype2 == QueryTypeEnum::SuffixPreview &&
|
||||
|
||||
@ -3522,7 +3522,7 @@ std::vector<PrfBlock> EDCServerCollection::getRemovedTags(
|
||||
std::back_inserter(staleTags),
|
||||
[](const auto& block) { return PrfBlockfromCDR(block.getView().tag); });
|
||||
} else {
|
||||
auto typeValue = EncryptedBinDataType_serializer(encryptedTypeBinding);
|
||||
auto typeValue = idl::serialize(encryptedTypeBinding);
|
||||
uasserted(7293204,
|
||||
str::stream() << "Field '" << field.fieldPathName
|
||||
<< "' is not a supported encrypted type: " << typeValue);
|
||||
@ -3724,7 +3724,7 @@ std::pair<EncryptedBinDataType, ConstDataRange> fromEncryptedConstDataRange(Cons
|
||||
|
||||
uint8_t subTypeByte = cdrc.readAndAdvance<uint8_t>();
|
||||
|
||||
auto subType = EncryptedBinDataType_parse(subTypeByte, IDLParserContext("subtype"));
|
||||
auto subType = idl::deserialize<EncryptedBinDataType>(subTypeByte, IDLParserContext("subtype"));
|
||||
return {subType, cdrc};
|
||||
}
|
||||
|
||||
@ -3930,8 +3930,8 @@ QueryTypeConfig getQueryType(const EncryptedField& field, QueryTypeEnum queryTyp
|
||||
uassert(8574704,
|
||||
fmt::format("Field '{}' should be of type '{}', got '{}'",
|
||||
field.getPath(),
|
||||
QueryType_serializer(queryType),
|
||||
QueryType_serializer(query.getQueryType())),
|
||||
idl::serialize(queryType),
|
||||
idl::serialize(query.getQueryType())),
|
||||
query.getQueryType() == queryType);
|
||||
return query;
|
||||
},
|
||||
@ -3945,7 +3945,7 @@ QueryTypeConfig getQueryType(const EncryptedField& field, QueryTypeEnum queryTyp
|
||||
8674705,
|
||||
fmt::format("Field '{}' should be of type '{}', but no configs match",
|
||||
field.getPath(),
|
||||
QueryType_serializer(queryType)));
|
||||
idl::serialize(queryType)));
|
||||
}},
|
||||
field.getQueries().get());
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public:
|
||||
}
|
||||
|
||||
_data.resize(kAssociatedDataLength + cipherLength);
|
||||
_data[0] = FleAlgorithmInt_serializer(algorithm);
|
||||
_data[0] = idl::serialize(algorithm);
|
||||
auto uuidCDR = uuid.toCDR();
|
||||
invariant(uuidCDR.length() == 16);
|
||||
std::copy(
|
||||
@ -143,7 +143,7 @@ public:
|
||||
uint8_t* getCiphertextMutable() && = delete;
|
||||
|
||||
FleAlgorithmInt getFLEAlgorithmType() {
|
||||
return FleAlgorithmInt_parse(_data[0], IDLParserContext("root"));
|
||||
return idl::deserialize<FleAlgorithmInt>(_data[0], IDLParserContext("root"));
|
||||
}
|
||||
|
||||
size_t getDataLength() const {
|
||||
@ -211,7 +211,7 @@ public:
|
||||
|
||||
private:
|
||||
FleAlgorithmInt getFLEAlgorithmType() const {
|
||||
return FleAlgorithmInt_parse(*_data.data<uint8_t>(), IDLParserContext("root"));
|
||||
return idl::deserialize<FleAlgorithmInt>(*_data.data<uint8_t>(), IDLParserContext("root"));
|
||||
}
|
||||
|
||||
size_t getDataLength() const {
|
||||
|
||||
@ -111,7 +111,7 @@ std::unique_ptr<TicketingSystem> createTicketingSystem(
|
||||
} // namespace
|
||||
|
||||
void initializeTicketingSystem(ServiceContext* svcCtx) {
|
||||
auto algorithm = ExecutionControlConcurrencyAdjustmentAlgorithm_parse(
|
||||
auto algorithm = idl::deserialize<ExecutionControlConcurrencyAdjustmentAlgorithmEnum>(
|
||||
gConcurrencyAdjustmentAlgorithm,
|
||||
IDLParserContext{"executionControlConcurrencyAdjustmentAlgorithm"});
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ Status TicketingSystem::NormalPrioritySettings::validateConcurrentReadTransactio
|
||||
|
||||
Status TicketingSystem::validateConcurrencyAdjustmentAlgorithm(
|
||||
const std::string& name, const boost::optional<TenantId>&) try {
|
||||
ExecutionControlConcurrencyAdjustmentAlgorithm_parse(
|
||||
idl::deserialize<ExecutionControlConcurrencyAdjustmentAlgorithmEnum>(
|
||||
name, IDLParserContext{"executionControlConcurrencyAdjustmentAlgorithm"});
|
||||
return Status::OK();
|
||||
} catch (const DBException& ex) {
|
||||
@ -385,8 +385,9 @@ void TicketingSystem::setConcurrentTransactions(OperationContext* opCtx,
|
||||
|
||||
void TicketingSystem::setConcurrencyAdjustmentAlgorithm(OperationContext* opCtx,
|
||||
std::string algorithmName) {
|
||||
const auto parsedAlgorithm = ExecutionControlConcurrencyAdjustmentAlgorithm_parse(
|
||||
algorithmName, IDLParserContext{"executionControlConcurrencyAdjustmentAlgorithm"});
|
||||
const auto parsedAlgorithm =
|
||||
idl::deserialize<ExecutionControlConcurrencyAdjustmentAlgorithmEnum>(
|
||||
algorithmName, IDLParserContext{"executionControlConcurrencyAdjustmentAlgorithm"});
|
||||
|
||||
const TicketingState oldState = _state.loadRelaxed();
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ std::string ActionSet::toString() const {
|
||||
|
||||
std::vector<StringData> ActionSet::getActionsAsStringDatas() const {
|
||||
if (contains(ActionType::anyAction)) {
|
||||
return {ActionType_serializer(ActionType::anyAction)};
|
||||
return {idl::serialize(ActionType::anyAction)};
|
||||
}
|
||||
|
||||
std::vector<StringData> result;
|
||||
|
||||
@ -50,7 +50,7 @@ constexpr StringData kAction = "action"_sd;
|
||||
|
||||
StatusWith<ActionType> parseActionFromString(StringData action) {
|
||||
try {
|
||||
return {ActionType_parse(action, IDLParserContext(kAction))};
|
||||
return {idl::deserialize<ActionTypeEnum>(action, IDLParserContext(kAction))};
|
||||
} catch (DBException&) {
|
||||
// ignore
|
||||
}
|
||||
@ -59,15 +59,15 @@ StatusWith<ActionType> parseActionFromString(StringData action) {
|
||||
}
|
||||
|
||||
StringData toStringData(ActionType a) {
|
||||
return ActionType_serializer(a);
|
||||
return idl::serialize(a);
|
||||
}
|
||||
|
||||
std::string toString(ActionType a) {
|
||||
return std::string{ActionType_serializer(a)};
|
||||
return std::string{idl::serialize(a)};
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ActionType& a) {
|
||||
return os << ActionType_serializer(a);
|
||||
return os << idl::serialize(a);
|
||||
}
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
@ -142,7 +142,7 @@ bool AuthorizationContract::contains(const AuthorizationContract& other) const {
|
||||
BSONArrayBuilder builder;
|
||||
for (size_t i = 0; i < missingChecks.size(); i++) {
|
||||
if (missingChecks.test(i)) {
|
||||
builder.append(AccessCheck_serializer(static_cast<AccessCheckEnum>(i)));
|
||||
builder.append(idl::serialize(static_cast<AccessCheckEnum>(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,13 +161,13 @@ bool AuthorizationContract::contains(const AuthorizationContract& other) const {
|
||||
auto at = static_cast<ActionTypeEnum>(k);
|
||||
if (other._privilegeChecks[i].contains(at) &&
|
||||
!_privilegeChecks[i].contains(at)) {
|
||||
builder.append(ActionType_serializer(at));
|
||||
builder.append(idl::serialize(at));
|
||||
}
|
||||
}
|
||||
|
||||
LOGV2(5452403,
|
||||
"Missing Action Types for resource",
|
||||
"resource"_attr = MatchType_serializer(static_cast<MatchTypeEnum>(i)),
|
||||
"resource"_attr = idl::serialize(static_cast<MatchTypeEnum>(i)),
|
||||
"actions"_attr = builder.arr());
|
||||
}
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ MONGO_INITIALIZER(ServerlessPrivilegePermittedMap)(InitializerContext*) try {
|
||||
|
||||
for (std::size_t i = 0; i < idlEnumCount<MatchTypeEnum>; ++i) {
|
||||
auto matchType = static_cast<MatchTypeEnum>(i);
|
||||
auto matchTypeName = MatchType_serializer(matchType);
|
||||
auto matchTypeName = idl::serialize(matchType);
|
||||
auto dataObj = MatchType_get_extra_data(matchType);
|
||||
auto data = MatchTypeExtraData::parse(dataObj, IDLParserContext{matchTypeName});
|
||||
|
||||
@ -154,7 +154,7 @@ void validateSecurityTokenUserPrivileges(const User::ResourcePrivilegeMap& privs
|
||||
// This actually can't happen since the initializer above populated the map with all match
|
||||
// types.
|
||||
uassert(6161701,
|
||||
str::stream() << "Unknown matchType: " << MatchType_serializer(matchType),
|
||||
str::stream() << "Unknown matchType: " << idl::serialize(matchType),
|
||||
it != kServerlessPrivilegesPermitted.end());
|
||||
if (MONGO_unlikely(!it->second.isSupersetOf(actions))) {
|
||||
auto unauthorized = actions;
|
||||
@ -163,7 +163,7 @@ void validateSecurityTokenUserPrivileges(const User::ResourcePrivilegeMap& privs
|
||||
str::stream()
|
||||
<< "Security Token user has one or more actions not approved for "
|
||||
"resource matchType '"
|
||||
<< MatchType_serializer(matchType) << "': " << unauthorized.toString());
|
||||
<< idl::serialize(matchType) << "': " << unauthorized.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return CleanupStructuredEncryptionDataPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
ExecutorFuture<void> _runImpl(std::shared_ptr<executor::ScopedTaskExecutor> executor,
|
||||
|
||||
@ -43,13 +43,13 @@ void BuildInfoAuthModeServerParameter::append(OperationContext*,
|
||||
BSONObjBuilder* builder,
|
||||
StringData fieldName,
|
||||
const boost::optional<TenantId>&) {
|
||||
builder->append(fieldName, BuildInfoAuthMode_serializer(gBuildInfoAuthMode.load()));
|
||||
builder->append(fieldName, idl::serialize(gBuildInfoAuthMode.load()));
|
||||
}
|
||||
|
||||
Status BuildInfoAuthModeServerParameter::setFromString(StringData strMode,
|
||||
const boost::optional<TenantId>&) try {
|
||||
gBuildInfoAuthMode.store(
|
||||
BuildInfoAuthMode_parse(strMode, IDLParserContext{"buildInfoAuthMode"}));
|
||||
idl::deserialize<BuildInfoAuthModeEnum>(strMode, IDLParserContext{"buildInfoAuthMode"}));
|
||||
return Status::OK();
|
||||
} catch (const DBException& ex) {
|
||||
return ex.toStatus().withContext("Invalid value for Server Parameter: 'buildInfoAuthMode'");
|
||||
|
||||
@ -47,9 +47,9 @@ namespace {
|
||||
using Verbosity = explain::VerbosityEnum;
|
||||
|
||||
TEST(ExplainTest, VerbosityEnumToStringReturnsCorrectValues) {
|
||||
ASSERT_EQ(explain::Verbosity_serializer(Verbosity::kQueryPlanner), "queryPlanner"_sd);
|
||||
ASSERT_EQ(explain::Verbosity_serializer(Verbosity::kExecStats), "executionStats"_sd);
|
||||
ASSERT_EQ(explain::Verbosity_serializer(Verbosity::kExecAllPlans), "allPlansExecution"_sd);
|
||||
ASSERT_EQ(idl::serialize(Verbosity::kQueryPlanner), "queryPlanner"_sd);
|
||||
ASSERT_EQ(idl::serialize(Verbosity::kExecStats), "executionStats"_sd);
|
||||
ASSERT_EQ(idl::serialize(Verbosity::kExecAllPlans), "allPlansExecution"_sd);
|
||||
}
|
||||
|
||||
TEST(ExplainTest, ExplainSerializeToBSONCorrectly) {
|
||||
|
||||
@ -325,7 +325,7 @@ void handleDropPendingDBsGarbage(OperationContext* parentOpCtx) {
|
||||
|
||||
ShardsvrJoinDDLCoordinators request;
|
||||
request.setDbName(DatabaseName::kAdmin);
|
||||
request.setTypes({{DDLCoordinatorType_serializer(DDLCoordinatorTypeEnum::kDropDatabase)}});
|
||||
request.setTypes({{idl::serialize(DDLCoordinatorTypeEnum::kDropDatabase)}});
|
||||
|
||||
const auto response = shard->runCommand(opCtx,
|
||||
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
|
||||
|
||||
@ -85,7 +85,7 @@ public:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return CompactStructuredEncryptionDataPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
ExecutorFuture<void> _runImpl(std::shared_ptr<executor::ScopedTaskExecutor> executor,
|
||||
|
||||
@ -135,7 +135,8 @@ GetNextResult ChangeStreamUnwindTransactionStage::doGetNext() {
|
||||
|
||||
bool ChangeStreamUnwindTransactionStage::_isTransactionOplogEntry(const Document& doc) {
|
||||
auto op = doc[repl::OplogEntry::kOpTypeFieldName];
|
||||
auto opType = repl::OpType_parse(op.getStringData(), IDLParserContext("ChangeStreamEntry.op"));
|
||||
auto opType = idl::deserialize<repl::OpTypeEnum>(op.getStringData(),
|
||||
IDLParserContext("ChangeStreamEntry.op"));
|
||||
|
||||
if (opType != repl::OpTypeEnum::kCommand) {
|
||||
return false;
|
||||
|
||||
@ -95,8 +95,8 @@ GetNextResult ListMqlEntitiesStage::doGetNext() {
|
||||
if (_results.empty()) {
|
||||
return GetNextResult::makeEOF();
|
||||
}
|
||||
auto res = Document(
|
||||
BSON("name" << _results.back() << kEntityTypeFieldName << MqlEntityType_serializer(_type)));
|
||||
auto res =
|
||||
Document(BSON("name" << _results.back() << kEntityTypeFieldName << idl::serialize(_type)));
|
||||
_results.pop_back();
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ public:
|
||||
}
|
||||
|
||||
boost::optional<StringData> getExecutorType() const override {
|
||||
return CursorType_serializer(_cursorType);
|
||||
return idl::serialize(_cursorType);
|
||||
}
|
||||
|
||||
QueryFramework getQueryFramework() const override {
|
||||
|
||||
@ -776,7 +776,8 @@ void MatchesSingleElementEvaluator::visit(
|
||||
return;
|
||||
}
|
||||
|
||||
auto fleBlobSubType = EncryptedBinDataType_parse(binData[0], IDLParserContext("subtype"));
|
||||
auto fleBlobSubType =
|
||||
idl::deserialize<EncryptedBinDataType>(binData[0], IDLParserContext("subtype"));
|
||||
switch (fleBlobSubType) {
|
||||
case EncryptedBinDataType::kDeterministic:
|
||||
case EncryptedBinDataType::kRandom: {
|
||||
|
||||
@ -52,7 +52,7 @@ public:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return CloneAuthoritativeMetadataCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
bool _mustAlwaysMakeProgress() override {
|
||||
|
||||
@ -109,7 +109,7 @@ private:
|
||||
};
|
||||
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return CollModCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
ExecutorFuture<void> _runImpl(std::shared_ptr<executor::ScopedTaskExecutor> executor,
|
||||
|
||||
@ -102,9 +102,8 @@ ConfigsvrCoordinatorService::constructInstance(BSONObj initialState) {
|
||||
return std::make_shared<SetClusterParameterCoordinator>(std::move(initialState));
|
||||
default:
|
||||
uasserted(ErrorCodes::BadValue,
|
||||
str::stream()
|
||||
<< "Encountered unknown ConfigsvrCoordinator operation type: "
|
||||
<< ConfigsvrCoordinatorType_serializer(op.getId().getCoordinatorType()));
|
||||
str::stream() << "Encountered unknown ConfigsvrCoordinator operation type: "
|
||||
<< idl::serialize(op.getId().getCoordinatorType()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,7 +168,7 @@ void ConfigsvrCoordinatorService::checkIfConflictsWithOtherInstances(
|
||||
|
||||
uassert(ErrorCodes::AddOrRemoveShardInProgress,
|
||||
fmt::format("Cannot start {} because a topology change is in progress",
|
||||
ConfigsvrCoordinatorType_serializer(op.getId().getCoordinatorType())),
|
||||
idl::serialize(op.getId().getCoordinatorType())),
|
||||
service->areAllCoordinatorsOfTypeFinished(opCtx, DDLCoordinatorTypeEnum::kAddShard));
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ protected:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return ConvertToCappedCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
bool _mustAlwaysMakeProgress() override;
|
||||
|
||||
@ -137,7 +137,7 @@ protected:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return CreateCollectionCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
bool _mustAlwaysMakeProgress() override;
|
||||
|
||||
@ -57,7 +57,7 @@ public:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return CreateDatabaseCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
bool _mustAlwaysMakeProgress() override {
|
||||
|
||||
@ -101,7 +101,7 @@ private:
|
||||
const BSONObj _critSecReason;
|
||||
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return DropCollectionCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
bool _mustAlwaysMakeProgress() override {
|
||||
|
||||
@ -73,7 +73,7 @@ public:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return DropDatabaseCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
bool _mustAlwaysMakeProgress() override {
|
||||
|
||||
@ -57,7 +57,7 @@ public:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return DropIndexesCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
ExecutorFuture<void> _runImpl(std::shared_ptr<executor::ScopedTaskExecutor> executor,
|
||||
|
||||
@ -52,7 +52,7 @@ public:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return InitializePlacementHistoryPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
std::set<NamespaceString> _getAdditionalLocksToAcquire(OperationContext* opCtx) override;
|
||||
|
||||
@ -107,7 +107,7 @@ MigrationBlockingOperationCoordinator::MigrationBlockingOperationCoordinator(
|
||||
void MigrationBlockingOperationCoordinator::checkIfOptionsConflict(const BSONObj& stateDoc) const {}
|
||||
|
||||
StringData MigrationBlockingOperationCoordinator::serializePhase(const Phase& phase) const {
|
||||
return MigrationBlockingOperationCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
ExecutorFuture<void> MigrationBlockingOperationCoordinator::_runImpl(
|
||||
|
||||
@ -147,7 +147,7 @@ logv2::DynamicAttributes MovePrimaryCoordinator::getCoordinatorLogAttrs() const
|
||||
}
|
||||
|
||||
StringData MovePrimaryCoordinator::serializePhase(const Phase& phase) const {
|
||||
return MovePrimaryCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
void MovePrimaryCoordinator::appendCommandInfo(BSONObjBuilder* cmdInfoBuilder) const {
|
||||
|
||||
@ -69,7 +69,7 @@ public:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return RefineCollectionShardKeyCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
bool _mustAlwaysMakeProgress() override {
|
||||
|
||||
@ -82,7 +82,7 @@ protected:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return RenameCollectionCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
bool _mustAlwaysMakeProgress() override {
|
||||
|
||||
@ -216,8 +216,8 @@ void RenameParticipantInstance::_enterPhase(Phase newPhase) {
|
||||
"Rename participant phase transition",
|
||||
"fromNs"_attr = _doc.getFromNss(),
|
||||
"toNs"_attr = _doc.getTo(),
|
||||
"newPhase"_attr = RenameCollectionParticipantPhase_serializer(newDoc.getPhase()),
|
||||
"oldPhase"_attr = RenameCollectionParticipantPhase_serializer(_doc.getPhase()));
|
||||
"newPhase"_attr = idl::serialize(newDoc.getPhase()),
|
||||
"oldPhase"_attr = idl::serialize(_doc.getPhase()));
|
||||
|
||||
auto opCtx = makeOperationContext();
|
||||
PersistentTaskStore<StateDoc> store(NamespaceString::kShardingRenameParticipantsNamespace);
|
||||
|
||||
@ -608,8 +608,7 @@ void ShardingCatalogManager::updateTimeSeriesBucketingParameters(
|
||||
timeseriesParameters->getGranularity().get());
|
||||
updateBob.append("$unset", BSON(bucketRoundingFieldName << ""));
|
||||
bucketUp = BSON(granularityFieldName
|
||||
<< BucketGranularity_serializer(
|
||||
timeseriesParameters->getGranularity().get())
|
||||
<< idl::serialize(timeseriesParameters->getGranularity().get())
|
||||
<< bucketSpanFieldName << bucketSpan);
|
||||
} else {
|
||||
tassert(
|
||||
|
||||
@ -219,7 +219,7 @@ TEST_F(ConfigureCollectionBalancingTest, SettingDefragmentCollection) {
|
||||
|
||||
// defragmentationPhase is set to finished
|
||||
configDoc = getCollectionDocument(_nss);
|
||||
auto storedDefragmentationPhase = DefragmentationPhase_parse(
|
||||
auto storedDefragmentationPhase = idl::deserialize<DefragmentationPhaseEnum>(
|
||||
configDoc.getStringField(CollectionType::kDefragmentationPhaseFieldName),
|
||||
IDLParserContext("ConfigureCollectionBalancingTest"));
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ ExecutorFuture<void> ShardingDDLCoordinator::_acquireLockAsync(
|
||||
auto opCtxHolder = makeOperationContext();
|
||||
auto* opCtx = opCtxHolder.get();
|
||||
|
||||
const auto coorName = DDLCoordinatorType_serializer(_coordId.getOperationType());
|
||||
const auto coorName = idl::serialize(_coordId.getOperationType());
|
||||
|
||||
_scopedLocks.emplace(DDLLockManager::ScopedBaseDDLLock{opCtx,
|
||||
_locker.get(),
|
||||
|
||||
@ -150,9 +150,8 @@ std::shared_ptr<ShardingDDLCoordinator> constructShardingDDLCoordinatorInstance(
|
||||
std::move(initialState));
|
||||
default:
|
||||
uasserted(ErrorCodes::BadValue,
|
||||
str::stream()
|
||||
<< "Encountered unknown Sharding DDL operation type: "
|
||||
<< DDLCoordinatorType_serializer(op.getId().getOperationType()));
|
||||
str::stream() << "Encountered unknown Sharding DDL operation type: "
|
||||
<< idl::serialize(op.getId().getOperationType()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +99,8 @@ public:
|
||||
// If the submitter specified a subset of types, only join those.
|
||||
if (types) {
|
||||
return std::ranges::any_of(*types, [&](StringData type) {
|
||||
return DDLCoordinatorType_parse(type, parserContext) == opType;
|
||||
return idl::deserialize<DDLCoordinatorTypeEnum>(type, parserContext) ==
|
||||
opType;
|
||||
});
|
||||
}
|
||||
// Join all other types.
|
||||
|
||||
@ -120,8 +120,7 @@ void TimeseriesUpgradeDowngradeCoordinator::checkIfOptionsConflict(const BSONObj
|
||||
|
||||
logv2::DynamicAttributes TimeseriesUpgradeDowngradeCoordinator::getCoordinatorLogAttrs() const {
|
||||
return logv2::DynamicAttributes{getBasicCoordinatorAttrs(),
|
||||
"mode"_attr =
|
||||
TimeseriesUpgradeDowngradeMode_serializer(_doc.getMode())};
|
||||
"mode"_attr = idl::serialize(_doc.getMode())};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,8 +252,7 @@ ExecutorFuture<void> TimeseriesUpgradeDowngradeCoordinator::_runImpl(
|
||||
opCtx,
|
||||
"upgradeDowngradeViewlessTimeseries.start",
|
||||
originalNss(),
|
||||
BSON("mode" << TimeseriesUpgradeDowngradeMode_serializer(_doc.getMode())
|
||||
<< "isTracked" << isTracked));
|
||||
BSON("mode" << idl::serialize(_doc.getMode()) << "isTracked" << isTracked));
|
||||
return isTracked;
|
||||
}, // Only for tracked collections
|
||||
[this, executor = executor, anchor = shared_from_this()](auto* opCtx) {
|
||||
@ -528,8 +526,7 @@ ExecutorFuture<void> TimeseriesUpgradeDowngradeCoordinator::_runImpl(
|
||||
opCtx,
|
||||
"upgradeDowngradeViewlessTimeseries.end",
|
||||
originalNss(),
|
||||
BSON("mode" << TimeseriesUpgradeDowngradeMode_serializer(_doc.getMode())
|
||||
<< "isTracked" << isTracked));
|
||||
BSON("mode" << idl::serialize(_doc.getMode()) << "isTracked" << isTracked));
|
||||
})
|
||||
.onError<ErrorCodes::RequestAlreadyFulfilled>(
|
||||
[this, anchor = shared_from_this()](const Status& status) { return Status::OK(); })
|
||||
@ -568,12 +565,10 @@ ExecutorFuture<void> TimeseriesUpgradeDowngradeCoordinator::_cleanupOnAbort(
|
||||
|
||||
// From kCommitOnShards onwards, we've done irreversible work on the shards and must
|
||||
// always make progress. We should never enter cleanup from that point.
|
||||
tassert(
|
||||
11590620,
|
||||
str::stream() << "Unexpected cleanup at phase "
|
||||
<< TimeseriesUpgradeDowngradeCoordinatorPhase_serializer(failedPhase)
|
||||
<< " which is >= kCommitOnShards",
|
||||
failedPhase < Phase::kCommitOnShards);
|
||||
tassert(11590620,
|
||||
str::stream() << "Unexpected cleanup at phase " << idl::serialize(failedPhase)
|
||||
<< " which is >= kCommitOnShards",
|
||||
failedPhase < Phase::kCommitOnShards);
|
||||
|
||||
// If we failed before kFreezeMigrations, we haven't done any work that needs cleanup.
|
||||
if (failedPhase < Phase::kFreezeMigrations) {
|
||||
|
||||
@ -72,7 +72,7 @@ protected:
|
||||
|
||||
private:
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return TimeseriesUpgradeDowngradeCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
bool _mustAlwaysMakeProgress() override {
|
||||
|
||||
@ -66,7 +66,7 @@ private:
|
||||
}
|
||||
|
||||
StringData serializePhase(const Phase& phase) const override {
|
||||
return UntrackUnsplittableCollectionCoordinatorPhase_serializer(phase);
|
||||
return idl::serialize(phase);
|
||||
}
|
||||
|
||||
void _checkPreconditions();
|
||||
|
||||
@ -168,8 +168,8 @@ public:
|
||||
"checkMetadataConsistency command. The router was expecting "
|
||||
"to receive a cluster, database or collection level "
|
||||
"parameter, but received "
|
||||
<< MetadataConsistencyCommandLevel_serializer(commandLevel)
|
||||
<< " with namespace " << nss.toStringForErrorMsg());
|
||||
<< idl::serialize(commandLevel) << " with namespace "
|
||||
<< nss.toStringForErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@ -416,8 +416,8 @@ public:
|
||||
"checkMetadataConsistency command. The router was expecting "
|
||||
"to receive a cluster, database or collection level "
|
||||
"parameter, but received "
|
||||
<< MetadataConsistencyCommandLevel_serializer(commandLevel)
|
||||
<< " with namespace " << nss.toStringForErrorMsg());
|
||||
<< idl::serialize(commandLevel) << " with namespace "
|
||||
<< nss.toStringForErrorMsg());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -150,8 +150,8 @@ public:
|
||||
"checkMetadataConsistency command. The config server was "
|
||||
"expecting to receive a database or collection level "
|
||||
"parameter, but received "
|
||||
<< MetadataConsistencyCommandLevel_serializer(commandLevel)
|
||||
<< " with namespace " << nss.toStringForErrorMsg());
|
||||
<< idl::serialize(commandLevel) << " with namespace "
|
||||
<< nss.toStringForErrorMsg());
|
||||
}
|
||||
|
||||
auto exec = metadata_consistency_util::makeQueuedPlanExecutor(
|
||||
|
||||
@ -58,8 +58,7 @@ template <typename MetadataDetailsType>
|
||||
MetadataInconsistencyItem makeInconsistency(const MetadataInconsistencyTypeEnum& type,
|
||||
const MetadataDetailsType& details) {
|
||||
return {type,
|
||||
std::string{MetadataInconsistencyDescription_serializer(
|
||||
static_cast<MetadataInconsistencyDescriptionEnum>(type))},
|
||||
std::string{idl::serialize(static_cast<MetadataInconsistencyDescriptionEnum>(type))},
|
||||
details.toBSON()};
|
||||
}
|
||||
|
||||
|
||||
@ -211,8 +211,8 @@ public:
|
||||
"checkMetadataConsistency command. The shard server was "
|
||||
"expecting to receive a cluster, database or collection "
|
||||
"level parameter, but received "
|
||||
<< MetadataConsistencyCommandLevel_serializer(commandLevel)
|
||||
<< " with namespace " << nss.toStringForErrorMsg());
|
||||
<< idl::serialize(commandLevel) << " with namespace "
|
||||
<< nss.toStringForErrorMsg());
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
@ -122,8 +122,8 @@ public:
|
||||
<< "Unexpected parameter during the internal execution of "
|
||||
"checkMetadataConsistency command. The shard server was expecting to "
|
||||
"receive a database or collection level parameter, but received "
|
||||
<< MetadataConsistencyCommandLevel_serializer(commandLevel)
|
||||
<< " with namespace " << nss.toStringForErrorMsg(),
|
||||
<< idl::serialize(commandLevel) << " with namespace "
|
||||
<< nss.toStringForErrorMsg(),
|
||||
commandLevel == MetadataConsistencyCommandLevelEnum::kCollectionLevel ||
|
||||
commandLevel == MetadataConsistencyCommandLevelEnum::kDatabaseLevel);
|
||||
|
||||
@ -244,8 +244,8 @@ public:
|
||||
<< "Unexpected parameter during the internal execution of "
|
||||
"checkMetadataConsistency command. The shard server was expecting "
|
||||
"to receive a database or collection level parameter, but received "
|
||||
<< MetadataConsistencyCommandLevel_serializer(commandLevel)
|
||||
<< " with namespace " << nss.toStringForErrorMsg());
|
||||
<< idl::serialize(commandLevel) << " with namespace "
|
||||
<< nss.toStringForErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,8 +336,8 @@ public:
|
||||
"expecting "
|
||||
"to receive a database or collection level parameter, but "
|
||||
"received "
|
||||
<< MetadataConsistencyCommandLevel_serializer(commandLevel)
|
||||
<< " with namespace " << nss.toStringForErrorMsg());
|
||||
<< idl::serialize(commandLevel) << " with namespace "
|
||||
<< nss.toStringForErrorMsg());
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
@ -2160,7 +2160,7 @@ void IndexBuildsCoordinator::_restartIndexBuild(OperationContext* opCtx,
|
||||
"buildUUID"_attr = buildUUID,
|
||||
"collectionUUID"_attr = collUUID,
|
||||
logAttrs(nss.value()),
|
||||
"method"_attr = IndexBuildMethod_serializer(indexBuildOptions.indexBuildMethod));
|
||||
"method"_attr = idl::serialize(indexBuildOptions.indexBuildMethod));
|
||||
|
||||
// Indicate that the initialization should not generate oplog entries or timestamps for the
|
||||
// first catalog write, and that the original durable catalog entries should be dropped and
|
||||
|
||||
@ -527,7 +527,7 @@ StatusWith<std::vector<BSONObj>> MultiIndexBlock::init(
|
||||
"properties"_attr = *descriptor,
|
||||
"specIndex"_attr = i,
|
||||
"numSpecs"_attr = indexes.size(),
|
||||
"method"_attr = IndexBuildMethod_serializer(_method),
|
||||
"method"_attr = idl::serialize(_method),
|
||||
"ident"_attr = indexCatalogEntry->getIdent(),
|
||||
"indexBuildInfo"_attr = indexes[i].toBSON(),
|
||||
"collectionIdent"_attr = collection->getSharedIdent()->getIdent(),
|
||||
@ -685,7 +685,7 @@ Status MultiIndexBlock::insertAllDocumentsInCollection(
|
||||
"collectionUUID"_attr = _collectionUUID,
|
||||
"totalRecords"_attr = progress.get(WithLock::withoutLock())->hits(),
|
||||
"duration"_attr = duration_cast<Milliseconds>(timer.elapsed()),
|
||||
"phase"_attr = IndexBuildPhase_serializer(_phase),
|
||||
"phase"_attr = idl::serialize(_phase),
|
||||
"collectionScanPosition"_attr = _lastRecordIdInserted,
|
||||
"readSource"_attr = RecoveryUnit::toString(
|
||||
shard_role_details::getRecoveryUnit(opCtx)->getTimestampReadSource()),
|
||||
@ -787,7 +787,7 @@ Status MultiIndexBlock::insertAllDocumentsInCollection(
|
||||
"collectionUUID"_attr = _collectionUUID,
|
||||
"totalRecords"_attr = progress.get(WithLock::withoutLock())->hits(),
|
||||
"duration"_attr = duration_cast<Milliseconds>(timer.elapsed()),
|
||||
"phase"_attr = IndexBuildPhase_serializer(_phase),
|
||||
"phase"_attr = idl::serialize(_phase),
|
||||
"collectionScanPosition"_attr = _lastRecordIdInserted,
|
||||
"readSource"_attr = RecoveryUnit::toString(readSource),
|
||||
"error"_attr = ex);
|
||||
@ -795,7 +795,7 @@ Status MultiIndexBlock::insertAllDocumentsInCollection(
|
||||
<< "collection scan stopped. totalRecords: "
|
||||
<< progress.get(WithLock::withoutLock())->hits()
|
||||
<< "; durationMillis: " << duration_cast<Milliseconds>(timer.elapsed())
|
||||
<< "; phase: " << IndexBuildPhase_serializer(_phase)
|
||||
<< "; phase: " << idl::serialize(_phase)
|
||||
<< "; collectionScanPosition: " << _lastRecordIdInserted
|
||||
<< "; readSource: " << RecoveryUnit::toString(readSource));
|
||||
return ex.toStatus();
|
||||
@ -852,7 +852,7 @@ void MultiIndexBlock::_doCollectionScan(OperationContext* opCtx,
|
||||
// scan phase.
|
||||
invariant(_phase == IndexBuildPhaseEnum::kInitialized ||
|
||||
_phase == IndexBuildPhaseEnum::kCollectionScan,
|
||||
IndexBuildPhase_serializer(_phase));
|
||||
idl::serialize(_phase));
|
||||
_phase = IndexBuildPhaseEnum::kCollectionScan;
|
||||
|
||||
BSONObj objToIndex;
|
||||
@ -1038,7 +1038,7 @@ Status MultiIndexBlock::dumpInsertsFromBulk(
|
||||
invariant(_phase == IndexBuildPhaseEnum::kInitialized ||
|
||||
_phase == IndexBuildPhaseEnum::kCollectionScan ||
|
||||
_phase == IndexBuildPhaseEnum::kBulkLoad,
|
||||
IndexBuildPhase_serializer(_phase));
|
||||
idl::serialize(_phase));
|
||||
_phase = IndexBuildPhaseEnum::kBulkLoad;
|
||||
|
||||
// Doesn't allow yielding when in a foreground index build.
|
||||
@ -1166,7 +1166,7 @@ Status MultiIndexBlock::drainBackgroundWrites(
|
||||
// already in the drain writes phase.
|
||||
invariant(_phase == IndexBuildPhaseEnum::kBulkLoad ||
|
||||
_phase == IndexBuildPhaseEnum::kDrainWrites,
|
||||
IndexBuildPhase_serializer(_phase));
|
||||
idl::serialize(_phase));
|
||||
_phase = IndexBuildPhaseEnum::kDrainWrites;
|
||||
|
||||
ReadSourceScope readSourceScope(opCtx, readSource);
|
||||
@ -1375,9 +1375,9 @@ void MultiIndexBlock::setIndexBuildMethod(IndexBuildMethodEnum indexBuildMethod)
|
||||
}
|
||||
|
||||
void MultiIndexBlock::appendBuildInfo(BSONObjBuilder* builder) const {
|
||||
builder->append("method", IndexBuildMethod_serializer(_method));
|
||||
builder->append("method", idl::serialize(_method));
|
||||
builder->append("phase", static_cast<int>(_phase));
|
||||
builder->append("phaseStr", IndexBuildPhase_serializer(_phase));
|
||||
builder->append("phaseStr", idl::serialize(_phase));
|
||||
}
|
||||
|
||||
void MultiIndexBlock::persistResumeState(OperationContext* opCtx,
|
||||
|
||||
@ -1056,14 +1056,14 @@ TEST_F(OpObserverTest, CollModWithCollectionOptionsAndTTLInfo) {
|
||||
|
||||
// Ensure that the old collection metadata was saved.
|
||||
auto o2 = oplogEntry.getObjectField("o2");
|
||||
auto o2Expected = BSON("collectionOptions_old"
|
||||
<< BSON("validationLevel"
|
||||
<< ValidationLevel_serializer(*oldCollOpts.validationLevel)
|
||||
<< "validationAction"
|
||||
<< ValidationAction_serializer(*oldCollOpts.validationAction))
|
||||
<< "indexOptions_old"
|
||||
<< BSON("expireAfterSeconds" << durationCount<Seconds>(
|
||||
indexInfo.oldExpireAfterSeconds.value())));
|
||||
auto o2Expected =
|
||||
BSON("collectionOptions_old"
|
||||
<< BSON("validationLevel" << idl::serialize(*oldCollOpts.validationLevel)
|
||||
<< "validationAction"
|
||||
<< idl::serialize(*oldCollOpts.validationAction))
|
||||
<< "indexOptions_old"
|
||||
<< BSON("expireAfterSeconds"
|
||||
<< durationCount<Seconds>(indexInfo.oldExpireAfterSeconds.value())));
|
||||
|
||||
ASSERT_BSONOBJ_EQ(o2Expected, o2);
|
||||
}
|
||||
@ -1101,11 +1101,10 @@ TEST_F(OpObserverTest, CollModWithOnlyCollectionOptions) {
|
||||
|
||||
// Ensure that the old collection metadata was saved and that TTL info is not present.
|
||||
auto o2 = oplogEntry.getObjectField("o2");
|
||||
auto o2Expected = BSON("collectionOptions_old"
|
||||
<< BSON("validationLevel"
|
||||
<< ValidationLevel_serializer(*oldCollOpts.validationLevel)
|
||||
<< "validationAction"
|
||||
<< ValidationAction_serializer(*oldCollOpts.validationAction)));
|
||||
auto o2Expected = BSON("collectionOptions_old" << BSON(
|
||||
"validationLevel" << idl::serialize(*oldCollOpts.validationLevel)
|
||||
<< "validationAction"
|
||||
<< idl::serialize(*oldCollOpts.validationAction)));
|
||||
|
||||
ASSERT_BSONOBJ_EQ(o2Expected, o2);
|
||||
}
|
||||
|
||||
@ -184,7 +184,8 @@ Document copyDocExceptFields(const Document& source, std::initializer_list<Strin
|
||||
repl::OpTypeEnum getOplogOpType(const Document& oplog) {
|
||||
auto opTypeField = oplog[repl::OplogEntry::kOpTypeFieldName];
|
||||
checkValueType(opTypeField, repl::OplogEntry::kOpTypeFieldName, BSONType::string);
|
||||
return repl::OpType_parse(opTypeField.getString(), IDLParserContext("ChangeStreamEntry.op"));
|
||||
return idl::deserialize<repl::OpTypeEnum>(opTypeField.getString(),
|
||||
IDLParserContext("ChangeStreamEntry.op"));
|
||||
}
|
||||
|
||||
Value makeChangeStreamNsField(const NamespaceString& nss) {
|
||||
|
||||
@ -65,7 +65,7 @@ BSONObj replaceResumeTokenAndVersionInCommand(
|
||||
|
||||
if (changeStreamVersion.has_value()) {
|
||||
changeStreamStage[DocumentSourceChangeStreamSpec::kVersionFieldName] =
|
||||
Value(ChangeStreamReaderVersion_serializer(*changeStreamVersion));
|
||||
Value(idl::serialize(*changeStreamVersion));
|
||||
}
|
||||
|
||||
// Provide 'resumeToken' as part 'startAfter' for resuming the changeStream. 'startAfter' and
|
||||
|
||||
@ -65,10 +65,9 @@ DocumentSourceChangeStreamAddPostImage::createFromBson(
|
||||
|
||||
Value DocumentSourceChangeStreamAddPostImage::doSerialize(const SerializationOptions& opts) const {
|
||||
return opts.isSerializingForExplain()
|
||||
? Value(Document{
|
||||
{DocumentSourceChangeStream::kStageName,
|
||||
Document{{"stage"_sd, kStageName},
|
||||
{kFullDocumentFieldName, FullDocumentMode_serializer(_fullDocumentMode)}}}})
|
||||
? Value(Document{{DocumentSourceChangeStream::kStageName,
|
||||
Document{{"stage"_sd, kStageName},
|
||||
{kFullDocumentFieldName, idl::serialize(_fullDocumentMode)}}}})
|
||||
: Value(Document{{kStageName,
|
||||
DocumentSourceChangeStreamAddPostImageSpec(_fullDocumentMode).toBSON()}});
|
||||
}
|
||||
|
||||
@ -78,11 +78,10 @@ DocumentSourceChangeStreamAddPreImage::createFromBson(
|
||||
|
||||
Value DocumentSourceChangeStreamAddPreImage::doSerialize(const SerializationOptions& opts) const {
|
||||
return opts.isSerializingForExplain()
|
||||
? Value(Document{
|
||||
{DocumentSourceChangeStream::kStageName,
|
||||
Document{{"stage"_sd, "internalAddPreImage"_sd},
|
||||
{"fullDocumentBeforeChange"_sd,
|
||||
FullDocumentBeforeChangeMode_serializer(_fullDocumentBeforeChangeMode)}}}})
|
||||
? Value(Document{{DocumentSourceChangeStream::kStageName,
|
||||
Document{{"stage"_sd, "internalAddPreImage"_sd},
|
||||
{"fullDocumentBeforeChange"_sd,
|
||||
idl::serialize(_fullDocumentBeforeChangeMode)}}}})
|
||||
: Value(Document{
|
||||
{kStageName,
|
||||
DocumentSourceChangeStreamAddPreImageSpec(_fullDocumentBeforeChangeMode).toBSON()}});
|
||||
|
||||
@ -499,7 +499,7 @@ TEST_F(ChangeStreamStageTest, CreatingChangeStreamSucceedsWithValidVersions) {
|
||||
.getDocument()
|
||||
.getField("version"_sd)
|
||||
.getStringData());
|
||||
ASSERT_EQ(ChangeStreamReaderVersion_parse(*version),
|
||||
ASSERT_EQ(idl::deserialize<ChangeStreamReaderVersionEnum>(*version),
|
||||
getExpCtx()->getChangeStreamSpec()->getVersion());
|
||||
} else {
|
||||
ASSERT_EQ("v1",
|
||||
|
||||
@ -347,7 +347,7 @@ TEST_F(FindAndModifyImageLookupTest, ShouldForgeImageEntryWhenMatchingImageDocIs
|
||||
LOGV2(5806002,
|
||||
"Running case",
|
||||
"test"_attr = unittest::getTestName(),
|
||||
"imageType"_attr = repl::RetryImage_serializer(imageType));
|
||||
"imageType"_attr = idl::serialize(imageType));
|
||||
auto documentSourceImageLookup =
|
||||
DocumentSourceFindAndModifyImageLookup::create(getExpCtx());
|
||||
auto imageLookupStage = exec::agg::buildStage(documentSourceImageLookup);
|
||||
@ -393,7 +393,7 @@ TEST_F(FindAndModifyImageLookupTest, ShouldForgeImageEntryWhenMatchingImageDocIs
|
||||
ASSERT_EQUALS(uuid, *forgedImageEntry.getUuid());
|
||||
ASSERT_EQUALS(txnNum, forgedImageEntry.getTxnNumber().value());
|
||||
ASSERT_EQUALS(sessionId, forgedImageEntry.getSessionId().value());
|
||||
ASSERT_EQUALS("n", repl::OpType_serializer(forgedImageEntry.getOpType()));
|
||||
ASSERT_EQUALS("n", idl::serialize(forgedImageEntry.getOpType()));
|
||||
const auto stmtIds = forgedImageEntry.getStatementIds();
|
||||
ASSERT_EQUALS(1U, stmtIds.size());
|
||||
ASSERT_EQUALS(stmtId, stmtIds.front());
|
||||
@ -431,7 +431,7 @@ TEST_F(FindAndModifyImageLookupTest, ShouldForgeImageEntryWhenMatchingImageDocIs
|
||||
LOGV2(6344105,
|
||||
"Running case",
|
||||
"test"_attr = unittest::getTestName(),
|
||||
"imageType"_attr = repl::RetryImage_serializer(imageType));
|
||||
"imageType"_attr = idl::serialize(imageType));
|
||||
auto documentSourceImageLookup = DocumentSourceFindAndModifyImageLookup::create(
|
||||
getExpCtx(), true /* includeCommitTransactionTimestamp */);
|
||||
auto imageLookupStage = exec::agg::buildStage(documentSourceImageLookup);
|
||||
@ -490,7 +490,7 @@ TEST_F(FindAndModifyImageLookupTest, ShouldForgeImageEntryWhenMatchingImageDocIs
|
||||
ASSERT_EQUALS(uuid, *forgedImageEntry.getUuid());
|
||||
ASSERT_EQUALS(txnNum, forgedImageEntry.getTxnNumber().value());
|
||||
ASSERT_EQUALS(sessionId, forgedImageEntry.getSessionId().value());
|
||||
ASSERT_EQUALS("n", repl::OpType_serializer(forgedImageEntry.getOpType()));
|
||||
ASSERT_EQUALS("n", idl::serialize(forgedImageEntry.getOpType()));
|
||||
const auto stmtIds = forgedImageEntry.getStatementIds();
|
||||
ASSERT_EQUALS(1U, stmtIds.size());
|
||||
ASSERT_EQUALS(stmtId, stmtIds.front());
|
||||
|
||||
@ -112,7 +112,7 @@ DocumentSourceContainer::iterator DocumentSourceListMqlEntities::optimizeAt(
|
||||
}
|
||||
|
||||
Value DocumentSourceListMqlEntities::serialize(const SerializationOptions& opts) const {
|
||||
return Value(DOC(kStageName << DOC(kEntityTypeFieldName << MqlEntityType_serializer(_type))));
|
||||
return Value(DOC(kStageName << DOC(kEntityTypeFieldName << idl::serialize(_type))));
|
||||
}
|
||||
|
||||
boost::optional<DocumentSource::DistributedPlanLogic>
|
||||
|
||||
@ -196,8 +196,8 @@ std::unique_ptr<DocumentSourceMerge::LiteParsed> DocumentSourceMerge::LiteParsed
|
||||
fmt::format("Combination of {} modes 'whenMatched: {}' and 'whenNotMatched: {}' "
|
||||
"is not supported",
|
||||
kStageName,
|
||||
MergeWhenMatchedMode_serializer(whenMatched),
|
||||
MergeWhenNotMatchedMode_serializer(whenNotMatched)),
|
||||
idl::serialize(whenMatched),
|
||||
idl::serialize(whenNotMatched)),
|
||||
isSupportedMergeMode(whenMatched, whenNotMatched));
|
||||
boost::optional<LiteParsedPipeline> liteParsedPipeline;
|
||||
if (whenMatched == MergeWhenMatchedModeEnum::kPipeline) {
|
||||
@ -290,8 +290,8 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceMerge::create(
|
||||
fmt::format("Combination of {} modes 'whenMatched: {}' and 'whenNotMatched: {}' "
|
||||
"is not supported",
|
||||
kStageName,
|
||||
MergeWhenMatchedMode_serializer(whenMatched),
|
||||
MergeWhenNotMatchedMode_serializer(whenNotMatched)),
|
||||
idl::serialize(whenMatched),
|
||||
idl::serialize(whenNotMatched)),
|
||||
isSupportedMergeMode(whenMatched, whenNotMatched));
|
||||
|
||||
uassert(ErrorCodes::InvalidNamespace,
|
||||
@ -337,7 +337,7 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceMerge::create(
|
||||
// Ensure the 'let' argument cannot be used with any other merge modes.
|
||||
uassert(51199,
|
||||
fmt::format("Cannot use 'let' variables with 'whenMatched: {}' mode",
|
||||
MergeWhenMatchedMode_serializer(whenMatched)),
|
||||
idl::serialize(whenMatched)),
|
||||
!letVariables);
|
||||
}
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ MergeWhenMatchedPolicy mergeWhenMatchedParseFromBSON(const BSONElement& elem) {
|
||||
|
||||
IDLParserContext ctx{DocumentSourceMergeSpec::kWhenMatchedFieldName};
|
||||
auto value = elem.valueStringData();
|
||||
auto mode = MergeWhenMatchedMode_parse(value, ctx);
|
||||
auto mode = idl::deserialize<MergeWhenMatchedModeEnum>(value, ctx);
|
||||
|
||||
// The 'kPipeline' mode cannot be specified explicitly, a custom pipeline definition must be
|
||||
// used instead.
|
||||
@ -167,7 +167,7 @@ void mergeWhenMatchedSerializeToBSON(const MergeWhenMatchedPolicy& policy,
|
||||
tassert(11282973, "Merge policy lacks the pipeline", policy.pipeline);
|
||||
bob->append(fieldName, *policy.pipeline);
|
||||
} else {
|
||||
bob->append(fieldName, MergeWhenMatchedMode_serializer(policy.mode));
|
||||
bob->append(fieldName, idl::serialize(policy.mode));
|
||||
}
|
||||
}
|
||||
} // namespace mongo
|
||||
|
||||
@ -58,10 +58,8 @@ constexpr StringData kWhenNotMatchedModeFieldName =
|
||||
DocumentSourceMergeSpec::kWhenNotMatchedFieldName;
|
||||
constexpr StringData kIntoFieldName = DocumentSourceMergeSpec::kTargetNssFieldName;
|
||||
constexpr StringData kOnFieldName = DocumentSourceMergeSpec::kOnFieldName;
|
||||
const StringData kDefaultWhenMatchedMode =
|
||||
MergeWhenMatchedMode_serializer(MergeWhenMatchedModeEnum::kMerge);
|
||||
const StringData kDefaultWhenNotMatchedMode =
|
||||
MergeWhenNotMatchedMode_serializer(MergeWhenNotMatchedModeEnum::kInsert);
|
||||
const StringData kDefaultWhenMatchedMode = idl::serialize(MergeWhenMatchedModeEnum::kMerge);
|
||||
const StringData kDefaultWhenNotMatchedMode = idl::serialize(MergeWhenNotMatchedModeEnum::kInsert);
|
||||
|
||||
class DocumentSourceMergeTest : public AggregationContextFixture {
|
||||
public:
|
||||
|
||||
@ -137,13 +137,12 @@ Value DocumentSourceQueryStats::serialize(const SerializationOptions& opts) cons
|
||||
hmacKey =
|
||||
Value(BSONBinData("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 32, BinDataType::Sensitive));
|
||||
}
|
||||
return Value{
|
||||
Document{{kStageName,
|
||||
_transformIdentifiers
|
||||
? Document{{"transformIdentifiers",
|
||||
Document{{"algorithm", TransformAlgorithm_serializer(_algorithm)},
|
||||
{"hmacKey", hmacKey}}}}
|
||||
: Document{}}}};
|
||||
return Value{Document{
|
||||
{kStageName,
|
||||
_transformIdentifiers
|
||||
? Document{{"transformIdentifiers",
|
||||
Document{{"algorithm", idl::serialize(_algorithm)}, {"hmacKey", hmacKey}}}}
|
||||
: Document{}}}};
|
||||
}
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
@ -401,7 +401,7 @@ public:
|
||||
* Get a string representation of the pipeline type.
|
||||
*/
|
||||
auto getTypeString() {
|
||||
return CursorType_serializer(pipelineType);
|
||||
return idl::serialize(pipelineType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -206,8 +206,7 @@ void planShardedSearch(const boost::intrusive_ptr<ExpressionContext>& expCtx,
|
||||
}
|
||||
|
||||
// Add the searchFeatures field.
|
||||
cmd.setSearchFeatures(
|
||||
BSON(SearchFeatures_serializer(SearchFeaturesEnum::kShardedSort) << 1));
|
||||
cmd.setSearchFeatures(BSON(idl::serialize(SearchFeaturesEnum::kShardedSort) << 1));
|
||||
|
||||
return cmd.toBSON();
|
||||
}();
|
||||
|
||||
@ -742,8 +742,7 @@ void FaultManager::appendDescription(BSONObjBuilder* result, bool appendDetails)
|
||||
}
|
||||
BSONObjBuilder sub_result;
|
||||
sub_result.append("intensity",
|
||||
HealthObserverIntensity_serializer(
|
||||
_config->getHealthObserverIntensity(observer->getType())));
|
||||
idl::serialize(_config->getHealthObserverIntensity(observer->getType())));
|
||||
|
||||
HealthObserverLivenessStats stats = observer->getStats();
|
||||
sub_result.append("totalChecks", stats.completedChecksCount);
|
||||
|
||||
@ -89,7 +89,7 @@ void ProgressMonitor::progressMonitorCheck(std::function<void(std::string cause)
|
||||
2,
|
||||
"Skip checking progress of not critical health observer",
|
||||
"observerType"_attr = (str::stream() << observerType),
|
||||
"intensity"_attr = HealthObserverIntensity_serializer(observerIntensity));
|
||||
"intensity"_attr = idl::serialize(observerIntensity));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -271,8 +271,8 @@ Status updateCollationSpecFromICUCollator(const BSONObj& spec,
|
||||
try {
|
||||
// For backwards compatibility, "strength" is parsed from any int, long, or double.
|
||||
// Check it matches an enum value.
|
||||
CollationStrength_parse(collation->getStrength(),
|
||||
IDLParserContext{"collation.strength"});
|
||||
idl::deserialize<CollationStrength>(collation->getStrength(),
|
||||
IDLParserContext{"collation.strength"});
|
||||
} catch (const DBException& exc) {
|
||||
return exc.toStatus();
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ void generateExecutionInfo(PlanExecutor* exec,
|
||||
tassert(11320911,
|
||||
fmt::format("The explain verbosity must be at least 'kExecStats' when generating "
|
||||
"execution info, but found {}",
|
||||
explain::Verbosity_serializer(verbosity)),
|
||||
idl::serialize(verbosity)),
|
||||
verbosity >= ExplainOptions::Verbosity::kExecStats);
|
||||
|
||||
auto&& explainer = exec->getPlanExplainer();
|
||||
|
||||
@ -66,7 +66,7 @@ void generateServerParameters(const boost::intrusive_ptr<ExpressionContext>& exp
|
||||
internalQueryProhibitBlockingMergeOnMongoS.load());
|
||||
out->appendNumber("internalQueryMaxAddToSetBytes", internalQueryMaxAddToSetBytes.load());
|
||||
auto queryControl = expCtx->getQueryKnobConfiguration().getInternalQueryFrameworkControlForOp();
|
||||
out->append("internalQueryFrameworkControl", QueryFrameworkControl_serializer(queryControl));
|
||||
out->append("internalQueryFrameworkControl", idl::serialize(queryControl));
|
||||
out->appendNumber("internalQueryPlannerIgnoreIndexWithCollationForRegex",
|
||||
internalQueryPlannerIgnoreIndexWithCollationForRegex.load());
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ namespace mongo {
|
||||
constexpr StringData ExplainOptions::kVerbosityName;
|
||||
|
||||
StringData ExplainOptions::verbosityString(ExplainOptions::Verbosity verbosity) {
|
||||
return Verbosity_serializer(verbosity);
|
||||
return idl::serialize(verbosity);
|
||||
}
|
||||
|
||||
BSONObj ExplainOptions::toBSON(ExplainOptions::Verbosity verbosity) {
|
||||
|
||||
@ -48,11 +48,12 @@ void QueryFrameworkControl::append(OperationContext*,
|
||||
BSONObjBuilder* b,
|
||||
StringData name,
|
||||
const boost::optional<TenantId>&) {
|
||||
*b << name << QueryFrameworkControl_serializer(_data.get());
|
||||
*b << name << idl::serialize(_data.get());
|
||||
}
|
||||
|
||||
Status QueryFrameworkControl::setFromString(StringData value, const boost::optional<TenantId>&) {
|
||||
_data = QueryFrameworkControl_parse(value, IDLParserContext("internalQueryFrameworkControl"));
|
||||
_data = idl::deserialize<QueryFrameworkControlEnum>(
|
||||
value, IDLParserContext("internalQueryFrameworkControl"));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
@ -47,11 +47,11 @@ void JoinPlanTreeShape::append(OperationContext*,
|
||||
BSONObjBuilder* b,
|
||||
StringData name,
|
||||
const boost::optional<TenantId>&) {
|
||||
*b << name << JoinPlanTreeShape_serializer(_data.get());
|
||||
*b << name << idl::serialize(_data.get());
|
||||
}
|
||||
|
||||
Status JoinPlanTreeShape::setFromString(StringData value, const boost::optional<TenantId>&) {
|
||||
_data = JoinPlanTreeShape_parse(value, IDLParserContext("JoinPlanTreeShape"));
|
||||
_data = idl::deserialize<JoinPlanTreeShapeEnum>(value, IDLParserContext("JoinPlanTreeShape"));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
@ -47,11 +47,11 @@ void JoinReorderMode::append(OperationContext*,
|
||||
BSONObjBuilder* b,
|
||||
StringData name,
|
||||
const boost::optional<TenantId>&) {
|
||||
*b << name << JoinReorderMode_serializer(_data.get());
|
||||
*b << name << idl::serialize(_data.get());
|
||||
}
|
||||
|
||||
Status JoinReorderMode::setFromString(StringData value, const boost::optional<TenantId>&) {
|
||||
_data = JoinReorderMode_parse(value, IDLParserContext("joinReorderMode"));
|
||||
_data = idl::deserialize<JoinReorderModeEnum>(value, IDLParserContext("joinReorderMode"));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
@ -197,7 +197,7 @@ public:
|
||||
* For queries that have multiple executors, this can be used to differentiate between them.
|
||||
*/
|
||||
boost::optional<StringData> getExecutorType() const final {
|
||||
return CursorType_serializer(_cursorType);
|
||||
return idl::serialize(_cursorType);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -49,12 +49,12 @@ void QueryPlanRankerMode::append(OperationContext*,
|
||||
BSONObjBuilder* b,
|
||||
StringData name,
|
||||
const boost::optional<TenantId>&) {
|
||||
*b << name << QueryPlanRankerMode_serializer(_data.get());
|
||||
*b << name << idl::serialize(_data.get());
|
||||
}
|
||||
|
||||
Status QueryPlanRankerMode::setFromString(StringData value, const boost::optional<TenantId>&) {
|
||||
QueryPlanRankerModeEnum mode =
|
||||
QueryPlanRankerMode_parse(value, IDLParserContext("internalQueryCBRCEMode"));
|
||||
QueryPlanRankerModeEnum mode = idl::deserialize<QueryPlanRankerModeEnum>(
|
||||
value, IDLParserContext("internalQueryCBRCEMode"));
|
||||
if (mode == QueryPlanRankerModeEnum::kHistogramCE && !getTestCommandsEnabled()) {
|
||||
return Status(ErrorCodes::BadValue, "histogramCE not allowed");
|
||||
}
|
||||
|
||||
@ -46,12 +46,12 @@ namespace mongo {
|
||||
|
||||
void QueryPlanRankingStrategyForAutomaticQueryPlanRankerMode::append(
|
||||
OperationContext*, BSONObjBuilder* b, StringData name, const boost::optional<TenantId>&) {
|
||||
*b << name << QueryPlanRankingStrategyForAutomaticQueryPlanRankerMode_serializer(_data.get());
|
||||
*b << name << idl::serialize(_data.get());
|
||||
}
|
||||
|
||||
Status QueryPlanRankingStrategyForAutomaticQueryPlanRankerMode::setFromString(
|
||||
StringData value, const boost::optional<TenantId>&) {
|
||||
auto mode = QueryPlanRankingStrategyForAutomaticQueryPlanRankerMode_parse(
|
||||
auto mode = idl::deserialize<QueryPlanRankingStrategyForAutomaticQueryPlanRankerModeEnum>(
|
||||
value, IDLParserContext("automaticCEPlanRankingStrategy"));
|
||||
if (mode ==
|
||||
QueryPlanRankingStrategyForAutomaticQueryPlanRankerModeEnum::
|
||||
|
||||
@ -48,11 +48,12 @@ void CBRSamplingCEMethod::append(OperationContext*,
|
||||
BSONObjBuilder* b,
|
||||
StringData name,
|
||||
const boost::optional<TenantId>&) {
|
||||
*b << name << SamplingCEMethod_serializer(_data.get());
|
||||
*b << name << idl::serialize(_data.get());
|
||||
}
|
||||
|
||||
Status CBRSamplingCEMethod::setFromString(StringData value, const boost::optional<TenantId>&) {
|
||||
_data = SamplingCEMethod_parse(value, IDLParserContext("internalQuerySamplingCEMethod"));
|
||||
_data = idl::deserialize<SamplingCEMethodEnum>(
|
||||
value, IDLParserContext("internalQuerySamplingCEMethod"));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -60,12 +61,12 @@ void JoinSamplingCEMethod::append(OperationContext*,
|
||||
BSONObjBuilder* b,
|
||||
StringData name,
|
||||
const boost::optional<TenantId>&) {
|
||||
*b << name << SamplingCEMethod_serializer(_data.get());
|
||||
*b << name << idl::serialize(_data.get());
|
||||
}
|
||||
|
||||
Status JoinSamplingCEMethod::setFromString(StringData value, const boost::optional<TenantId>&) {
|
||||
_data =
|
||||
SamplingCEMethod_parse(value, IDLParserContext("internalJoinOptimizationSamplingCEMethod"));
|
||||
_data = idl::deserialize<SamplingCEMethodEnum>(
|
||||
value, IDLParserContext("internalJoinOptimizationSamplingCEMethod"));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
@ -48,12 +48,13 @@ void SamplingConfidenceInterval::append(OperationContext*,
|
||||
BSONObjBuilder* b,
|
||||
StringData name,
|
||||
const boost::optional<TenantId>&) {
|
||||
*b << name << SamplingConfidenceInterval_serializer(_data.get());
|
||||
*b << name << idl::serialize(_data.get());
|
||||
}
|
||||
|
||||
Status SamplingConfidenceInterval::setFromString(StringData value,
|
||||
const boost::optional<TenantId>&) {
|
||||
_data = SamplingConfidenceInterval_parse(value, IDLParserContext("samplingConfidenceInterval"));
|
||||
_data = idl::deserialize<SamplingConfidenceIntervalEnum>(
|
||||
value, IDLParserContext("samplingConfidenceInterval"));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
@ -47,12 +47,12 @@ void SbeHashAggIncreasedSpillingMode::append(OperationContext*,
|
||||
BSONObjBuilder* b,
|
||||
StringData name,
|
||||
const boost::optional<TenantId>&) {
|
||||
*b << name << SbeHashAggIncreasedSpillingMode_serializer(_data.get());
|
||||
*b << name << idl::serialize(_data.get());
|
||||
}
|
||||
|
||||
Status SbeHashAggIncreasedSpillingMode::setFromString(StringData value,
|
||||
const boost::optional<TenantId>&) {
|
||||
_data = SbeHashAggIncreasedSpillingMode_parse(
|
||||
_data = idl::deserialize<SbeHashAggIncreasedSpillingModeEnum>(
|
||||
value, IDLParserContext("internalQuerySlotBasedExecutionHashAggIncreasedSpilling"));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ BSONObj extractFindAndModifyIdFilter(const repl::OplogEntry& oplogEntry) {
|
||||
uasserted(11730900,
|
||||
str::stream()
|
||||
<< "Found a findAndModify oplog entry with an unexpected op type "
|
||||
<< OpType_serializer(oplogEntry.getOpType()));
|
||||
<< idl::serialize(oplogEntry.getOpType()));
|
||||
}
|
||||
}();
|
||||
uassert(11730901,
|
||||
|
||||
@ -77,7 +77,7 @@ std::string makePreOrPostImageNotFoundErrorMessage(const repl::OplogEntry& oplog
|
||||
"has been executed but the {} is no longer available",
|
||||
oplog.getSessionId()->toBSON().toString(),
|
||||
*oplog.getTxnNumber(),
|
||||
repl::RetryImage_serializer(*oplog.getNeedsRetryImage()));
|
||||
idl::serialize(*oplog.getNeedsRetryImage()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +94,7 @@ std::string makePreOrPostImageNotFoundErrorMessage(
|
||||
"has been executed but the {} is no longer available: ",
|
||||
oplogWithCorrectLinks.getSessionId()->toBSON().toString(),
|
||||
*oplogWithCorrectLinks.getTxnNumber(),
|
||||
repl::RetryImage_serializer(imageType),
|
||||
idl::serialize(imageType),
|
||||
redact(request.toBSON()).toString());
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ void validateFindAndModifyRetryability(const write_ops::FindAndModifyCommandRequ
|
||||
40606,
|
||||
str::stream() << "findAndModify retry request: " << redact(request.toBSON())
|
||||
<< " is not compatible with previous write in the transaction of type: "
|
||||
<< OpType_serializer(oplogEntry.getOpType()) << ", oplogTs: "
|
||||
<< idl::serialize(oplogEntry.getOpType()) << ", oplogTs: "
|
||||
<< ts.toString() << ", oplog: " << redact(oplogEntry.toBSONForLogging()),
|
||||
request.getRemove().value_or(false));
|
||||
|
||||
@ -137,7 +137,7 @@ void validateFindAndModifyRetryability(const write_ops::FindAndModifyCommandRequ
|
||||
40608,
|
||||
str::stream() << "findAndModify retry request: " << redact(request.toBSON())
|
||||
<< " is not compatible with previous write in the transaction of type: "
|
||||
<< OpType_serializer(oplogEntry.getOpType()) << ", oplogTs: "
|
||||
<< idl::serialize(oplogEntry.getOpType()) << ", oplogTs: "
|
||||
<< ts.toString() << ", oplog: " << redact(oplogEntry.toBSONForLogging()),
|
||||
request.getUpsert().value_or(false));
|
||||
} else {
|
||||
@ -145,7 +145,7 @@ void validateFindAndModifyRetryability(const write_ops::FindAndModifyCommandRequ
|
||||
40609,
|
||||
str::stream() << "findAndModify retry request: " << redact(request.toBSON())
|
||||
<< " is not compatible with previous write in the transaction of type: "
|
||||
<< OpType_serializer(oplogEntry.getOpType()) << ", oplogTs: "
|
||||
<< idl::serialize(oplogEntry.getOpType()) << ", oplogTs: "
|
||||
<< ts.toString() << ", oplog: " << redact(oplogEntry.toBSONForLogging()),
|
||||
opType == repl::OpTypeEnum::kUpdate);
|
||||
|
||||
@ -420,7 +420,7 @@ SingleWriteResult parseOplogEntryForUpdate(const repl::OplogEntry& entry,
|
||||
uasserted(40638,
|
||||
str::stream() << "update retry request is not compatible with previous write in "
|
||||
"the transaction of type: "
|
||||
<< OpType_serializer(entry.getOpType())
|
||||
<< idl::serialize(entry.getOpType())
|
||||
<< ", oplogTs: " << entry.getTimestamp().toString()
|
||||
<< ", oplog: " << redact(entry.toBSONForLogging()));
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ ReadWriteConcernProvenance ReadWriteConcernProvenance::parse(const IDLParserCont
|
||||
}
|
||||
|
||||
StringData ReadWriteConcernProvenance::sourceToString(boost::optional<Source> source) {
|
||||
return source ? ReadWriteConcernProvenanceSource_serializer(*source) : "(unset)";
|
||||
return source ? idl::serialize(*source) : "(unset)";
|
||||
}
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
@ -171,9 +171,8 @@ void notifyChangeStreamsOnReshardCollectionComplete(OperationContext* opCtx,
|
||||
}
|
||||
|
||||
if (notification.getProvenance().has_value()) {
|
||||
o2Builder.append(
|
||||
"provenance",
|
||||
ReshardingProvenance_serializer(notification.getProvenance().value()));
|
||||
o2Builder.append("provenance",
|
||||
idl::serialize(notification.getProvenance().value()));
|
||||
}
|
||||
|
||||
if (!zones.empty()) {
|
||||
|
||||
@ -1220,7 +1220,8 @@ Status dbCheckOplogCommand(OperationContext* opCtx,
|
||||
if (!opCtx->writesAreReplicated()) {
|
||||
opTime = entry.getOpTime();
|
||||
}
|
||||
const auto type = OplogEntries_parse(cmd.getStringField("type"), IDLParserContext("type"));
|
||||
const auto type =
|
||||
idl::deserialize<OplogEntriesEnum>(cmd.getStringField("type"), IDLParserContext("type"));
|
||||
const IDLParserContext ctx("o",
|
||||
auth::ValidatedTenancyScope::get(opCtx),
|
||||
entry.getTid(),
|
||||
|
||||
@ -928,8 +928,8 @@ Status InitialSyncer::_scheduleGetBeginFetchingOpTime(
|
||||
std::shared_ptr<OnCompletionGuard> onCompletionGuard,
|
||||
const OpTime& defaultBeginFetchingOpTime) {
|
||||
|
||||
const auto preparedState = DurableTxnState_serializer(DurableTxnStateEnum::kPrepared);
|
||||
const auto inProgressState = DurableTxnState_serializer(DurableTxnStateEnum::kInProgress);
|
||||
const auto preparedState = idl::serialize(DurableTxnStateEnum::kPrepared);
|
||||
const auto inProgressState = idl::serialize(DurableTxnStateEnum::kInProgress);
|
||||
|
||||
// Obtain the oldest active transaction timestamp from the remote by querying their transactions
|
||||
// table. To prevent oplog holes (primary) or a stale lastAppliedSnapshot (secondary) from
|
||||
|
||||
@ -2777,7 +2777,7 @@ Status applyOperation_inlock(OperationContext* opCtx,
|
||||
}
|
||||
default: {
|
||||
// Commands are processed in applyCommand_inlock().
|
||||
invariant(false, str::stream() << "Unsupported opType " << OpType_serializer(opType));
|
||||
invariant(false, str::stream() << "Unsupported opType " << idl::serialize(opType));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2841,8 +2841,7 @@ Status applyContainerOperation_inlock(OperationContext* opCtx,
|
||||
}
|
||||
default:
|
||||
uasserted(10704705,
|
||||
str::stream()
|
||||
<< "Unsupported opType: " << OpType_serializer(op->getOpType()));
|
||||
str::stream() << "Unsupported opType: " << idl::serialize(op->getOpType()));
|
||||
}
|
||||
|
||||
if (!s.isOK())
|
||||
|
||||
@ -551,11 +551,11 @@ TEST_F(OplogApplierImplTest, applyOplogEntryToRecordChangeStreamPreImages) {
|
||||
repl::getNextOpTime(_opCtx.get());
|
||||
wuow.commit();
|
||||
|
||||
std::string testDesc{
|
||||
str::stream() << "TestCase: opType: " << OpType_serializer(testCase.opType)
|
||||
<< " mode: " << OplogApplication::modeToString(testCase.applicationMode)
|
||||
<< " fromMigrate: " << (testCase.fromMigrate.get_value_or(false))
|
||||
<< " shouldRecordPreImage: " << testCase.shouldRecordPreImage};
|
||||
std::string testDesc{str::stream()
|
||||
<< "TestCase: opType: " << idl::serialize(testCase.opType) << " mode: "
|
||||
<< OplogApplication::modeToString(testCase.applicationMode)
|
||||
<< " fromMigrate: " << (testCase.fromMigrate.get_value_or(false))
|
||||
<< " shouldRecordPreImage: " << testCase.shouldRecordPreImage};
|
||||
|
||||
// Check if pre-image was recorded.
|
||||
if (testCase.shouldRecordPreImage) {
|
||||
|
||||
@ -72,7 +72,7 @@ BSONObj makeOplogEntryDoc(DurableOplogEntryParams p) {
|
||||
builder.append(OplogEntryBase::kTimestampFieldName, p.opTime.getTimestamp());
|
||||
builder.append(OplogEntryBase::kTermFieldName, p.opTime.getTerm());
|
||||
builder.append(OplogEntryBase::kVersionFieldName, p.version);
|
||||
builder.append(OplogEntryBase::kOpTypeFieldName, OpType_serializer(p.opType));
|
||||
builder.append(OplogEntryBase::kOpTypeFieldName, idl::serialize(p.opType));
|
||||
if (p.nss.tenantId() && gMultitenancySupport &&
|
||||
gFeatureFlagRequireTenantID.isEnabled(
|
||||
serverGlobalParams.featureCompatibility.acquireFCVSnapshot())) {
|
||||
@ -130,15 +130,15 @@ BSONObj makeOplogEntryDoc(DurableOplogEntryParams p) {
|
||||
|
||||
if (p.needsRetryImage) {
|
||||
builder.append(OplogEntryBase::kNeedsRetryImageFieldName,
|
||||
RetryImage_serializer(p.needsRetryImage.value()));
|
||||
idl::serialize(p.needsRetryImage.value()));
|
||||
}
|
||||
return builder.obj();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
CommandTypeEnum parseCommandType(const BSONObj& objectField) {
|
||||
return CommandType_parse(objectField.firstElementFieldNameStringData(),
|
||||
IDLParserContext("commandString"));
|
||||
return idl::deserialize<CommandTypeEnum>(objectField.firstElementFieldNameStringData(),
|
||||
IDLParserContext("commandString"));
|
||||
}
|
||||
|
||||
void ReplOperation::extractPrePostImageForTransaction(boost::optional<ImageBundle>* image) const {
|
||||
@ -915,7 +915,7 @@ StatusWith<Timestamp> OplogEntry::extractCommitTransactionTimestamp() const {
|
||||
mongo::ErrorCodes::Error(11730801),
|
||||
str::stream() << "Expected a terminal applyOps oplog entry or a commitTransaction oplog "
|
||||
"entry but found op type "
|
||||
<< repl::OpType_serializer(getOpType())};
|
||||
<< idl::serialize(getOpType())};
|
||||
}
|
||||
|
||||
mongo::Timestamp OplogEntry::getTimestampForPreImage() const {
|
||||
@ -984,8 +984,8 @@ repl::OpTypeEnum OplogEntryParserNonStrict::getOpType() const {
|
||||
str::stream() << "Invalid '" << repl::OplogEntry::kOpTypeFieldName
|
||||
<< "' field type (expected String)",
|
||||
opTypeElement.type() == BSONType::string);
|
||||
return repl::OpType_parse(opTypeElement.checkAndGetStringData(),
|
||||
IDLParserContext("ChangeStreamEntry.op"));
|
||||
return idl::deserialize<repl::OpTypeEnum>(opTypeElement.checkAndGetStringData(),
|
||||
IDLParserContext("ChangeStreamEntry.op"));
|
||||
}
|
||||
|
||||
BSONObj OplogEntryParserNonStrict::getObject() const {
|
||||
|
||||
@ -899,7 +899,7 @@ TEST(OplogEntryParserTest, ParseOpTimeFailure) {
|
||||
|
||||
TEST(OplogEntryParserTest, ParseOpTypeSuccess) {
|
||||
auto const oplogEntry =
|
||||
BSON(OplogEntry::kOpTypeFieldName << OpType_serializer(repl::OpTypeEnum::kDelete));
|
||||
BSON(OplogEntry::kOpTypeFieldName << idl::serialize(repl::OpTypeEnum::kDelete));
|
||||
OplogEntryParserNonStrict parser{oplogEntry};
|
||||
ASSERT_EQ(repl::OpTypeEnum::kDelete, parser.getOpType());
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ TEST_F(OplogTest, LogOpReturnsOpTimeOnSuccessfulInsertIntoOplogCollection) {
|
||||
"oplog: "
|
||||
<< oplogEntry.toBSONForLogging();
|
||||
ASSERT(OpTypeEnum::kNoop == oplogEntry.getOpType())
|
||||
<< "Expected 'n' op type but found '" << OpType_serializer(oplogEntry.getOpType())
|
||||
<< "Expected 'n' op type but found '" << idl::serialize(oplogEntry.getOpType())
|
||||
<< "' instead: " << oplogEntry.toBSONForLogging();
|
||||
ASSERT_BSONOBJ_EQ(msgObj, oplogEntry.getObject());
|
||||
|
||||
|
||||
@ -292,7 +292,7 @@ void ReadConcernArgs::appendInfo(BSONObjBuilder* builder) const {
|
||||
}
|
||||
|
||||
StringData readConcernLevels::toString(ReadConcernLevel level) {
|
||||
return ReadConcernLevel_serializer(level);
|
||||
return idl::serialize(level);
|
||||
}
|
||||
|
||||
} // namespace repl
|
||||
|
||||
@ -1267,7 +1267,7 @@ bool ReplicationCoordinatorExternalStateImpl::isCWWCSetOnConfigShard(
|
||||
if (cmdResponse.response.hasField("defaultWriteConcernSource")) {
|
||||
// FCV is set to "5.0" or higher.
|
||||
isCWWCSet = cmdResponse.response.getField("defaultWriteConcernSource").valueStringData() ==
|
||||
DefaultWriteConcernSource_serializer(DefaultWriteConcernSourceEnum::kGlobal);
|
||||
idl::serialize(DefaultWriteConcernSourceEnum::kGlobal);
|
||||
} else {
|
||||
// FCV is set to lower than "5.0".
|
||||
isCWWCSet = cmdResponse.response.hasField("defaultWriteConcern");
|
||||
|
||||
@ -4873,9 +4873,9 @@ ReadPreference ReplicationCoordinatorImpl::_getSyncSourceReadPreference(WithLock
|
||||
if (memberState.startup2() && _selfIndex != -1) {
|
||||
if (!initialSyncSourceReadPreference.empty()) {
|
||||
try {
|
||||
readPreference =
|
||||
ReadPreference_parse(initialSyncSourceReadPreference,
|
||||
IDLParserContext("initialSyncSourceReadPreference"));
|
||||
readPreference = idl::deserialize<ReadPreferenceEnum>(
|
||||
initialSyncSourceReadPreference,
|
||||
IDLParserContext("initialSyncSourceReadPreference"));
|
||||
parsedSyncSourceFromInitialSync = true;
|
||||
} catch (const DBException& e) {
|
||||
fassertFailedWithStatus(3873100, e.toStatus());
|
||||
|
||||
@ -179,7 +179,7 @@ std::pair<BSONObj, RecordId> RollbackTest::makeCRUDOp(OpTypeEnum opType,
|
||||
|
||||
BSONObjBuilder bob;
|
||||
bob.append("ts", ts);
|
||||
bob.append("op", OpType_serializer(opType));
|
||||
bob.append("op", idl::serialize(opType));
|
||||
uuid.appendToBuilder(&bob, "ui");
|
||||
bob.append("ns", nss);
|
||||
bob.append("o", o);
|
||||
|
||||
@ -4199,7 +4199,7 @@ protected:
|
||||
BSONObjBuilder doc;
|
||||
doc.append("_id", sessionId.toBSON());
|
||||
doc.append("txnNum", txnNum);
|
||||
doc.append("state", DurableTxnState_serializer(state));
|
||||
doc.append("state", idl::serialize(state));
|
||||
doc.append("startOpTime", repl::OpTime(startTs, 1).toBSON());
|
||||
doc.append("lastWriteOpTime", repl::OpTime(startTs, 1).toBSON());
|
||||
doc.append("lastWriteDate", Date_t::now());
|
||||
|
||||
@ -316,7 +316,7 @@ void assertFastCountApplyOpsMatches(const repl::OplogEntry& applyOpsEntry,
|
||||
}
|
||||
default: {
|
||||
FAIL(std::string("Unexpected opType for observed fast-count applyOps entry: ") +
|
||||
repl::OpType_serializer(innerEntry.getOpType()));
|
||||
idl::serialize(innerEntry.getOpType()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -383,7 +383,7 @@ void assertFastCountApplyOpsMatches(const repl::OplogEntry& applyOpsEntry,
|
||||
}
|
||||
default: {
|
||||
FAIL(std::string("Unexpected opType for inputted fast-count applyOps entry: ") +
|
||||
repl::OpType_serializer(innerEntry.getOpType()));
|
||||
idl::serialize(innerEntry.getOpType()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -836,7 +836,7 @@ void Balancer::report(OperationContext* opCtx, BSONObjBuilder* builder) {
|
||||
const auto mode = balancerConfig->getBalancerMode();
|
||||
|
||||
stdx::lock_guard<stdx::mutex> scopedLock(_mutex);
|
||||
builder->append("mode", BalancerMode_serializer(mode));
|
||||
builder->append("mode", idl::serialize(mode));
|
||||
builder->append("inBalancerRound", _inBalancerRound);
|
||||
builder->append("numBalancerRounds", _numBalancerRounds);
|
||||
builder->append("term", repl::ReplicationCoordinator::get(opCtx)->getTerm());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user