Browse Source

Cosmetic for Cypress tx mirroring
1d447641f9f45024e30a81903e439513a3a8847f

kvk1920 10 months ago
parent
commit
84ddb341fa

+ 4 - 0
yt/yt/core/misc/protobuf_helpers-inl.h

@@ -37,6 +37,10 @@ DEFINE_TRIVIAL_PROTO_CONVERSIONS(bool)
 
 ////////////////////////////////////////////////////////////////////////////////
 
+#define YT_PROTO_OPTIONAL_CONVERT(...) __VA_OPT__(::NYT::FromProto<__VA_ARGS__>)
+
+////////////////////////////////////////////////////////////////////////////////
+
 // These conversions work in case if the patched protobuf that uses
 // TString is used.
 inline void ToProto(TString* serialized, TString original)

+ 11 - 2
yt/yt/core/misc/protobuf_helpers.h

@@ -378,8 +378,17 @@ google::protobuf::Timestamp GetProtoNow();
 
 ////////////////////////////////////////////////////////////////////////////////
 
-//! This macro may be used to extract std::optional<T> from protobuf message field of type T.
-#define YT_PROTO_OPTIONAL(message, field) (((message).has_##field()) ? std::make_optional((message).field()) : std::nullopt)
+//! This macro may be used to extract std::optional<T> from protobuf message
+//! field. Macro accepts desired target type as optional third parameter.
+//! Usage:
+//!     // Get as is.
+//!     int instantInt = YT_PROTO_OPTIONAL(message, instant);
+//!     // Get with conversion.
+//!     TInstant instant = YT_PROTO_OPTIONAL(message, instant, TInstant);
+#define YT_PROTO_OPTIONAL(message, field, ...) \
+    (((message).has_##field()) \
+        ? std::optional(YT_PROTO_OPTIONAL_CONVERT(__VA_ARGS__)((message).field())) \
+        : std::nullopt)
 
 ////////////////////////////////////////////////////////////////////////////////
 

+ 1 - 1
yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto

@@ -368,7 +368,7 @@ message TReqStartTransaction
 {
     message TReplicateToMasterCellTags
     {
-        repeated int32 cell_tags = 1;
+        repeated uint32 cell_tags = 1;
     }
 
     required ETransactionType type = 1;