@@ -137,9 +137,7 @@ TFuture<ITransactionPtr> TClientBase::StartTransaction(
137
137
138
138
req->set_type (static_cast <NProto::ETransactionType>(type));
139
139
req->set_timeout (ToProto (timeout));
140
- if (options.Deadline ) {
141
- req->set_deadline (ToProto (*options.Deadline ));
142
- }
140
+ YT_OPTIONAL_SET_PROTO (req, deadline, options.Deadline );
143
141
if (options.Id ) {
144
142
ToProto (req->mutable_id (), options.Id );
145
143
}
@@ -251,9 +249,7 @@ TFuture<TYsonString> TClientBase::GetNode(
251
249
req->mutable_legacy_attributes ()->set_all (true );
252
250
}
253
251
254
- if (options.MaxSize ) {
255
- req->set_max_size (*options.MaxSize );
256
- }
252
+ YT_OPTIONAL_SET_PROTO (req, max_size, options.MaxSize );
257
253
258
254
ToProto (req->mutable_complexity_limits (), options.ComplexityLimits );
259
255
@@ -289,9 +285,7 @@ TFuture<TYsonString> TClientBase::ListNode(
289
285
req->mutable_legacy_attributes ()->set_all (true );
290
286
}
291
287
292
- if (options.MaxSize ) {
293
- req->set_max_size (*options.MaxSize );
294
- }
288
+ YT_OPTIONAL_SET_PROTO (req, max_size, options.MaxSize );
295
289
296
290
ToProto (req->mutable_complexity_limits (), options.ComplexityLimits );
297
291
@@ -423,12 +417,8 @@ TFuture<TLockNodeResult> TClientBase::LockNode(
423
417
req->set_mode (ToProto (mode));
424
418
425
419
req->set_waitable (options.Waitable );
426
- if (options.ChildKey ) {
427
- req->set_child_key (*options.ChildKey );
428
- }
429
- if (options.AttributeKey ) {
430
- req->set_attribute_key (*options.AttributeKey );
431
- }
420
+ YT_OPTIONAL_TO_PROTO (req, child_key, options.ChildKey );
421
+ YT_OPTIONAL_TO_PROTO (req, attribute_key, options.AttributeKey );
432
422
433
423
ToProto (req->mutable_transactional_options (), options);
434
424
ToProto (req->mutable_prerequisite_options (), options);
@@ -642,12 +632,8 @@ TFuture<IFileReaderPtr> TClientBase::CreateFileReader(
642
632
InitStreamingRequest (*req);
643
633
644
634
req->set_path (path);
645
- if (options.Offset ) {
646
- req->set_offset (*options.Offset );
647
- }
648
- if (options.Length ) {
649
- req->set_length (*options.Length );
650
- }
635
+ YT_OPTIONAL_SET_PROTO (req, offset, options.Offset );
636
+ YT_OPTIONAL_SET_PROTO (req, length, options.Length );
651
637
if (options.Config ) {
652
638
req->set_config (ConvertToYsonString (*options.Config ).ToString ());
653
639
}
@@ -691,12 +677,8 @@ IJournalReaderPtr TClientBase::CreateJournalReader(
691
677
692
678
req->set_path (path);
693
679
694
- if (options.FirstRowIndex ) {
695
- req->set_first_row_index (*options.FirstRowIndex );
696
- }
697
- if (options.RowCount ) {
698
- req->set_row_count (*options.RowCount );
699
- }
680
+ YT_OPTIONAL_SET_PROTO (req, first_row_index, options.FirstRowIndex );
681
+ YT_OPTIONAL_SET_PROTO (req, row_count, options.RowCount );
700
682
if (options.Config ) {
701
683
req->set_config (ConvertToYsonString (*options.Config ).ToString ());
702
684
}
@@ -868,9 +850,7 @@ TFuture<TUnversionedLookupRowsResult> TClientBase::LookupRows(
868
850
req->set_keep_missing_rows (options.KeepMissingRows );
869
851
req->set_enable_partial_result (options.EnablePartialResult );
870
852
req->set_replica_consistency (static_cast <NProto::EReplicaConsistency>(options.ReplicaConsistency ));
871
- if (options.UseLookupCache ) {
872
- req->set_use_lookup_cache (*options.UseLookupCache );
873
- }
853
+ YT_OPTIONAL_SET_PROTO (req, use_lookup_cache, options.UseLookupCache );
874
854
875
855
req->SetMultiplexingBand (options.MultiplexingBand );
876
856
req->set_multiplexing_band (static_cast <NProto::EMultiplexingBand>(options.MultiplexingBand ));
@@ -920,9 +900,7 @@ TFuture<TVersionedLookupRowsResult> TClientBase::VersionedLookupRows(
920
900
req->set_keep_missing_rows (options.KeepMissingRows );
921
901
req->set_enable_partial_result (options.EnablePartialResult );
922
902
req->set_replica_consistency (static_cast <NProto::EReplicaConsistency>(options.ReplicaConsistency ));
923
- if (options.UseLookupCache ) {
924
- req->set_use_lookup_cache (*options.UseLookupCache );
925
- }
903
+ YT_OPTIONAL_SET_PROTO (req, use_lookup_cache, options.UseLookupCache );
926
904
927
905
req->SetMultiplexingBand (options.MultiplexingBand );
928
906
req->set_multiplexing_band (static_cast <NProto::EMultiplexingBand>(options.MultiplexingBand ));
@@ -969,9 +947,7 @@ TFuture<std::vector<TUnversionedLookupRowsResult>> TClientBase::MultiLookupRows(
969
947
}
970
948
protoSubrequest->set_keep_missing_rows (subrequestOptions.KeepMissingRows );
971
949
protoSubrequest->set_enable_partial_result (subrequestOptions.EnablePartialResult );
972
- if (subrequestOptions.UseLookupCache ) {
973
- protoSubrequest->set_use_lookup_cache (*subrequestOptions.UseLookupCache );
974
- }
950
+ YT_OPTIONAL_SET_PROTO (protoSubrequest, use_lookup_cache, subrequestOptions.UseLookupCache );
975
951
976
952
auto rowset = SerializeRowset (
977
953
subrequest.NameTable ,
@@ -1079,40 +1055,30 @@ TFuture<TSelectRowsResult> TClientBase::SelectRows(
1079
1055
// TODO(lukyan): Move to FillRequestBySelectRowsOptionsBase
1080
1056
req->SetTimeout (options.Timeout .value_or (config->DefaultSelectRowsTimeout ));
1081
1057
1082
- if (options.InputRowLimit ) {
1083
- req->set_input_row_limit (*options.InputRowLimit );
1084
- }
1085
- if (options.OutputRowLimit ) {
1086
- req->set_output_row_limit (*options.OutputRowLimit );
1087
- }
1058
+ YT_OPTIONAL_SET_PROTO (req, input_row_limit, options.InputRowLimit );
1059
+ YT_OPTIONAL_SET_PROTO (req, output_row_limit, options.OutputRowLimit );
1088
1060
req->set_range_expansion_limit (options.RangeExpansionLimit );
1089
1061
req->set_max_subqueries (options.MaxSubqueries );
1090
1062
req->set_min_row_count_per_subquery (options.MinRowCountPerSubquery );
1091
1063
req->set_allow_full_scan (options.AllowFullScan );
1092
1064
req->set_allow_join_without_index (options.AllowJoinWithoutIndex );
1093
1065
1094
- if (options.ExecutionPool ) {
1095
- req->set_execution_pool (*options.ExecutionPool );
1096
- }
1066
+ YT_OPTIONAL_TO_PROTO (req, execution_pool, options.ExecutionPool );
1097
1067
if (options.PlaceholderValues ) {
1098
1068
req->set_placeholder_values (options.PlaceholderValues .ToString ());
1099
1069
}
1100
1070
req->set_fail_on_incomplete_result (options.FailOnIncompleteResult );
1101
1071
req->set_verbose_logging (options.VerboseLogging );
1102
1072
req->set_new_range_inference (options.NewRangeInference );
1103
- if (options.ExecutionBackend ) {
1104
- req->set_execution_backend (ToProto (*options.ExecutionBackend ));
1105
- }
1073
+ YT_OPTIONAL_SET_PROTO (req, execution_backend, options.ExecutionBackend );
1106
1074
req->set_enable_code_cache (options.EnableCodeCache );
1107
1075
req->set_memory_limit_per_node (options.MemoryLimitPerNode );
1108
1076
ToProto (req->mutable_suppressable_access_tracking_options (), options);
1109
1077
req->set_replica_consistency (static_cast <NProto::EReplicaConsistency>(options.ReplicaConsistency ));
1110
1078
req->set_use_canonical_null_relations (options.UseCanonicalNullRelations );
1111
1079
req->set_merge_versioned_rows (options.MergeVersionedRows );
1112
1080
ToProto (req->mutable_versioned_read_options (), options.VersionedReadOptions );
1113
- if (options.UseLookupCache ) {
1114
- req->set_use_lookup_cache (*options.UseLookupCache );
1115
- }
1081
+ YT_OPTIONAL_SET_PROTO (req, use_lookup_cache, options.UseLookupCache );
1116
1082
1117
1083
return req->Invoke ().Apply (BIND ([] (const TApiServiceProxy::TRspSelectRowsPtr& rsp) {
1118
1084
TSelectRowsResult result;
0 commit comments