14
14
#include < util/generic/serialized_enum.h>
15
15
#include < util/stream/format.h>
16
16
#include < util/string/split.h>
17
+ #include < util/system/info.h>
17
18
18
19
namespace NYdb ::NConsoleClient {
19
20
@@ -142,18 +143,16 @@ void TCommandRestore::Config(TConfig& config) {
142
143
143
144
NDump::TRestoreSettings defaults;
144
145
145
- config.Opts ->AddLongOption (" restore-data" , " Whether to restore data or not" )
146
+ config.Opts ->AddLongOption (" restore-data" , " Whether to restore data or not. " )
146
147
.DefaultValue (defaults.RestoreData_ ).StoreResult (&RestoreData);
147
148
148
- config.Opts ->AddLongOption (" restore-indexes" , " Whether to restore indexes or not" )
149
+ config.Opts ->AddLongOption (" restore-indexes" , " Whether to restore indexes or not. " )
149
150
.DefaultValue (defaults.RestoreIndexes_ ).StoreResult (&RestoreIndexes);
150
151
151
- config.Opts ->AddLongOption (" restore-acl" , " Whether to restore ACL and owner or not" )
152
+ config.Opts ->AddLongOption (" restore-acl" , " Whether to restore ACL and owner or not. " )
152
153
.DefaultValue (defaults.RestoreACL_ ).StoreResult (&RestoreACL);
153
154
154
- config.Opts ->AddLongOption (" skip-document-tables" , TStringBuilder ()
155
- << " Document API tables cannot be restored for now. "
156
- << " Specify this option to skip such tables" )
155
+ config.Opts ->AddLongOption (" skip-document-tables" , " Skip Document API tables." )
157
156
.DefaultValue (defaults.SkipDocumentTables_ ).StoreResult (&SkipDocumentTables)
158
157
.Hidden (); // Deprecated
159
158
@@ -162,37 +161,60 @@ void TCommandRestore::Config(TConfig& config) {
162
161
" will be reverted in case of error." )
163
162
.StoreTrue (&SavePartialResult);
164
163
165
- config.Opts ->AddLongOption (" bandwidth" , " Limit data upload bandwidth, bytes per second (example: 2MiB)" )
166
- .DefaultValue (" 0" ).StoreResult (&UploadBandwidth);
167
-
168
- config.Opts ->AddLongOption (" rps" , " Limit requests per second (example: 100)" )
169
- .DefaultValue (defaults.RateLimiterSettings_ .GetRps ()).StoreResult (&UploadRps);
164
+ config.Opts ->AddLongOption (" bandwidth" , " Limit data upload bandwidth, bytes per second (example: 2MiB)." )
165
+ .DefaultValue (" no limit" )
166
+ .Handler1T <TString>([this ](const TString& arg) {
167
+ UploadBandwidth = (arg == " no limit" ) ? " 0" : arg;
168
+ })
169
+ .Hidden ();
170
+
171
+ config.Opts ->AddLongOption (" rps" , " Limit requests per second (example: 100)." )
172
+ .DefaultValue (" no limit" )
173
+ .Handler1T <TString>([this ](const TString& arg) {
174
+ UploadRps = (arg == " no limit" ) ? " 0" : arg;
175
+ });
170
176
171
- config.Opts ->AddLongOption (" upload-batch-rows" , " Limit upload batch size in rows (example: 1K)" )
172
- .DefaultValue (defaults.RowsPerRequest_ ).StoreResult (&RowsPerRequest);
177
+ config.Opts ->AddLongOption (" upload-batch-rows" , " Limit upload batch size in rows (example: 1K)."
178
+ " Not applicable in ImportData mode." )
179
+ .DefaultValue (" no limit" )
180
+ .Handler1T <TString>([this ](const TString& arg) {
181
+ RowsPerRequest = (arg == " no limit" ) ? " 0" : arg;
182
+ });
173
183
174
- config.Opts ->AddLongOption (" upload-batch-bytes" , " Limit upload batch size in bytes (example: 1MiB)" )
175
- .DefaultValue (HumanReadableSize (defaults.BytesPerRequest_ , SF_BYTES)).StoreResult (&BytesPerRequest);
184
+ config.Opts ->AddLongOption (" upload-batch-rus" , " Limit upload batch size in request units (example: 100)."
185
+ " Not applicable in ImportData mode." )
186
+ .DefaultValue (" no limit" )
187
+ .Handler1T <TString>([this ](const TString& arg) {
188
+ RequestUnitsPerRequest = (arg == " no limit" ) ? " 0" : arg;
189
+ });
176
190
177
- config.Opts ->AddLongOption (" upload-batch-rus" , " Limit upload batch size in request units (example: 100)" )
178
- .DefaultValue (defaults.RequestUnitsPerRequest_ ).StoreResult (&RequestUnitsPerRequest);
191
+ config.Opts ->AddLongOption (" upload-batch-bytes" , " Limit upload batch size in bytes (example: 1MiB)." )
192
+ .DefaultValue (" auto" )
193
+ .Handler1T <TString>([this ](const TString& arg) {
194
+ BytesPerRequest = (arg == " auto" ) ? " 0" : arg;
195
+ });
179
196
180
- config.Opts ->AddLongOption (" in-flight" , " Limit in-flight request count" )
181
- .DefaultValue (defaults.InFly_ ).StoreResult (&InFly);
197
+ config.Opts ->AddLongOption (" in-flight" , " Limit in-flight request count." )
198
+ .DefaultValue (" auto" )
199
+ .Handler1T <TString>([this ](const TString& arg) {
200
+ InFlight = (arg == " auto" ) ? 0 : FromString<ui32>(arg);
201
+ });
182
202
183
203
config.Opts ->AddLongOption (" bulk-upsert" , " Use BulkUpsert - a more efficient way to upload data with lower consistency level."
184
- " Global secondary indexes are not supported in this mode." )
204
+ " Global secondary indexes are not supported in this mode." )
185
205
.StoreTrue (&UseBulkUpsert)
186
206
.Hidden (); // Deprecated. Using ImportData should be more effective.
187
207
188
208
config.Opts ->AddLongOption (" import-data" , " Use ImportData - a more efficient way to upload data."
189
- " ImportData will throw an error if you try to upload data into an existing table that has"
190
- " secondary indexes or is in the process of building them. If you need to restore a table"
191
- " with secondary indexes, make sure it's not already present in the scheme." )
209
+ " ImportData will throw an error if you try to upload data into an existing table that has"
210
+ " secondary indexes or is in the process of building them. If you need to restore a table"
211
+ " with secondary indexes, make sure it's not already present in the scheme." )
192
212
.StoreTrue (&UseImportData);
193
213
194
214
config.Opts ->MutuallyExclusive (" bandwidth" , " rps" );
195
215
config.Opts ->MutuallyExclusive (" import-data" , " bulk-upsert" );
216
+ config.Opts ->MutuallyExclusive (" import-data" , " upload-batch-rows" );
217
+ config.Opts ->MutuallyExclusive (" import-data" , " upload-batch-rus" );
196
218
}
197
219
198
220
void TCommandRestore::ExtractParams (TConfig& config) {
@@ -208,17 +230,24 @@ int TCommandRestore::Run(TConfig& config) {
208
230
.RestoreACL (RestoreACL)
209
231
.SkipDocumentTables (SkipDocumentTables)
210
232
.SavePartialResult (SavePartialResult)
211
- .RowsPerRequest (NYdb::SizeFromString (RowsPerRequest))
212
- .InFly (InFly);
233
+ .RowsPerRequest (NYdb::SizeFromString (RowsPerRequest));
234
+
235
+ if (InFlight) {
236
+ settings.MaxInFlight (InFlight);
237
+ } else if (!UseImportData) {
238
+ settings.MaxInFlight (NSystemInfo::CachedNumberOfCpus ());
239
+ }
213
240
214
241
if (auto bytesPerRequest = NYdb::SizeFromString (BytesPerRequest)) {
215
- if (bytesPerRequest > NDump::TRestoreSettings::MaxBytesPerRequest ) {
242
+ if (UseImportData && bytesPerRequest > NDump::TRestoreSettings::MaxImportDataBytesPerRequest ) {
216
243
throw TMisuseException ()
217
244
<< " --upload-batch-bytes cannot be larger than "
218
- << HumanReadableSize (NDump::TRestoreSettings::MaxBytesPerRequest , SF_BYTES);
245
+ << HumanReadableSize (NDump::TRestoreSettings::MaxImportDataBytesPerRequest , SF_BYTES);
219
246
}
220
247
221
248
settings.BytesPerRequest (bytesPerRequest);
249
+ } else if (UseImportData) {
250
+ settings.BytesPerRequest (NDump::TRestoreSettings::MaxImportDataBytesPerRequest);
222
251
}
223
252
224
253
if (RequestUnitsPerRequest) {
0 commit comments