Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.apache.iotdb.jdbc.IoTDBJDBCResultSet;
import org.apache.iotdb.service.rpc.thrift.ServerProperties;
import org.apache.iotdb.tool.ImportCsv;
import org.apache.thrift.TException;

public abstract class AbstractCli {

Expand Down Expand Up @@ -306,8 +305,8 @@ private static void setFetchSize(String fetchSizeString) {

static void setMaxDisplayNumber(String maxDisplayNum) {
long tmp = Long.parseLong(maxDisplayNum.trim());
if (tmp > Integer.MAX_VALUE || tmp < 0) {
maxPrintRowCount = Integer.MAX_VALUE;
if (tmp > Integer.MAX_VALUE || tmp <= 0) {
throw new NumberFormatException();
} else {
maxPrintRowCount = Integer.parseInt(maxDisplayNum.trim());
}
Expand Down Expand Up @@ -407,7 +406,7 @@ static OperationResult handleInputCmd(String cmd, IoTDBConnection connection) {
}

if (specialCmd.startsWith(SET_MAX_DISPLAY_NUM)) {
setMaxDisplaNum(specialCmd, cmd);
setMaxDisplayNum(specialCmd, cmd);
return OperationResult.CONTINUE_OPER;
}

Expand Down Expand Up @@ -506,7 +505,7 @@ private static void setFetchSize(String specialCmd, String cmd) {
println("Fetch size has set to " + values[1].trim());
}

private static void setMaxDisplaNum(String specialCmd, String cmd) {
private static void setMaxDisplayNum(String specialCmd, String cmd) {
String[] values = specialCmd.split("=");
if (values.length != 2) {
println(String.format("Max display number format error, please input like %s = 10000",
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/java/org/apache/iotdb/cli/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private static boolean parseCommandLine(Options options, String[] newArgs, HelpF
return false;
} catch (NumberFormatException e) {
println(
IOTDB_CLI_PREFIX + "> error format of max print row count, it should be number");
IOTDB_CLI_PREFIX + "> error format of max print row count, it should be a number and greater than 0");
return false;
}
return true;
Expand Down
8 changes: 5 additions & 3 deletions cli/src/main/java/org/apache/iotdb/cli/WinCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ private static boolean parseCommandLine(Options options, String[] newArgs, HelpF
}
if (commandLine.hasOption(MAX_PRINT_ROW_COUNT_ARGS)) {
maxPrintRowCount = Integer.parseInt(commandLine.getOptionValue(MAX_PRINT_ROW_COUNT_ARGS));
if (maxPrintRowCount < 0) {
maxPrintRowCount = Integer.MAX_VALUE;
if (maxPrintRowCount <= 0) {
println(
IOTDB_CLI_PREFIX + "> error format of max print row count, it should be a number greater than 0");
return false;
}
}
} catch (ParseException e) {
Expand All @@ -109,7 +111,7 @@ private static boolean parseCommandLine(Options options, String[] newArgs, HelpF
return false;
} catch (NumberFormatException e) {
println(
IOTDB_CLI_PREFIX + "> error format of max print row count, it should be number");
IOTDB_CLI_PREFIX + "> error format of max print row count, it should be a number");
return false;
}
return true;
Expand Down
29 changes: 23 additions & 6 deletions cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,28 @@ private void testSetTimeFormat() {
}

private void testSetMaxDisplayNumber() {
AbstractCli.setMaxDisplayNumber("10");
assertEquals(10, AbstractCli.maxPrintRowCount);
AbstractCli.setMaxDisplayNumber("111111111111111");
assertEquals(Integer.MAX_VALUE, AbstractCli.maxPrintRowCount);
AbstractCli.setMaxDisplayNumber("-10");
assertEquals(Integer.MAX_VALUE, AbstractCli.maxPrintRowCount);
try {
AbstractCli.setMaxDisplayNumber("10");
} catch (NumberFormatException e) {
fail();
}

try {
AbstractCli.setMaxDisplayNumber("111111111111111");
fail();
} catch (NumberFormatException e) {
}

try {
AbstractCli.setMaxDisplayNumber("-10");
fail();
} catch (NumberFormatException e) {
}

try {
AbstractCli.setMaxDisplayNumber("0");
fail();
} catch (NumberFormatException e) {
}
}
}