Skip to content

Commit 22e9599

Browse files
committed
Add missing deprecation support for max threads in export
1 parent 2c2431f commit 22e9599

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ private void validateDeprecatedOptions() {
131131
DEPRECATED_END_EXCLUSIVE_OPTION,
132132
END_INCLUSIVE_OPTION,
133133
END_INCLUSIVE_OPTION_SHORT);
134+
validateDeprecatedOptionPair(
135+
spec.commandLine(),
136+
DEPRECATED_THREADS_OPTION,
137+
MAX_THREADS_OPTION,
138+
MAX_THREADS_OPTION_SHORT);
134139
}
135140

136141
private String getScalarDbPropertiesFilePath() {

data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommandOptions.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public class ExportCommandOptions {
1616
public static final String END_INCLUSIVE_OPTION = "--end-inclusive";
1717
public static final String END_INCLUSIVE_OPTION_SHORT = "-ei";
1818
public static final String DEPRECATED_END_EXCLUSIVE_OPTION = "--end-exclusive";
19+
public static final String MAX_THREADS_OPTION = "--max-threads";
20+
public static final String MAX_THREADS_OPTION_SHORT = "-mt";
21+
public static final String DEPRECATED_THREADS_OPTION = "--threads";
1922

2023
@CommandLine.Option(
2124
names = {"--config", "-c"},
@@ -79,6 +82,15 @@ public class ExportCommandOptions {
7982
"Maximum number of threads to use for parallel processing (default: number of available processors)")
8083
protected Integer maxThreads;
8184

85+
// Deprecated option - kept for backward compatibility
86+
@CommandLine.Option(
87+
names = {DEPRECATED_THREADS_OPTION},
88+
paramLabel = "<THREADS>",
89+
description = "Deprecated: Use --max-threads instead",
90+
hidden = true)
91+
@Deprecated
92+
protected Integer threadsDeprecated;
93+
8294
@CommandLine.Option(
8395
names = {"--start-key", "-sk"},
8496
paramLabel = "<KEY=VALUE>",
@@ -184,5 +196,10 @@ public void applyDeprecatedOptions() {
184196
if (endExclusiveDeprecated != null) {
185197
scanEndInclusive = !endExclusiveDeprecated;
186198
}
199+
200+
// If the deprecated option is set, use its value
201+
if (threadsDeprecated != null) {
202+
maxThreads = threadsDeprecated;
203+
}
187204
}
188205
}

data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommandTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,35 @@ void call_withOnlyDeprecatedEndExclusive_shouldApplyInvertedValue() {
191191
assertEquals(true, command.scanEndInclusive);
192192
}
193193

194+
@Test
195+
void call_withOnlyDeprecatedThreads_shouldApplyValue() {
196+
// Simulate command line parsing with only deprecated option
197+
String[] args = {
198+
"--config",
199+
"scalardb.properties",
200+
"--namespace",
201+
"scalar",
202+
"--table",
203+
"asset",
204+
"--format",
205+
"JSON",
206+
"--threads",
207+
"12"
208+
};
209+
ExportCommand command = new ExportCommand();
210+
CommandLine cmd = new CommandLine(command);
211+
cmd.parseArgs(args);
212+
213+
// Verify the deprecated value was parsed
214+
assertEquals(12, command.threadsDeprecated);
215+
216+
// Apply deprecated options (this is what the command does after validation)
217+
command.applyDeprecatedOptions();
218+
219+
// Verify the value was applied to maxThreads
220+
assertEquals(12, command.maxThreads);
221+
}
222+
194223
@Test
195224
void call_withMaxThreadsSpecified_shouldUseSpecifiedValue() {
196225
// Simulate command line parsing with --max-threads

0 commit comments

Comments
 (0)