You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/11/17 10:42:34 UTC
[iotdb] branch rel/0.11 updated: [IOTDB-990] [To rel/0.11] cli
parameter maxPRC shouldn't to be set zero (#2055)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch rel/0.11
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.11 by this push:
new 9f51ea9 [IOTDB-990] [To rel/0.11] cli parameter maxPRC shouldn't to be set zero (#2055)
9f51ea9 is described below
commit 9f51ea96042c6fab4ec72277c19ba9a1e57aa3ba
Author: Haonan <hh...@outlook.com>
AuthorDate: Tue Nov 17 18:42:23 2020 +0800
[IOTDB-990] [To rel/0.11] cli parameter maxPRC shouldn't to be set zero (#2055)
---
.../java/org/apache/iotdb/cli/AbstractCli.java | 9 +++----
cli/src/main/java/org/apache/iotdb/cli/Cli.java | 2 +-
cli/src/main/java/org/apache/iotdb/cli/WinCli.java | 8 +++---
.../java/org/apache/iotdb/cli/AbstractCliIT.java | 29 +++++++++++++++++-----
4 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
index ffc8c39..e413f53 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
@@ -46,7 +46,6 @@ import org.apache.iotdb.jdbc.IoTDBConnection;
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 {
@@ -306,8 +305,8 @@ public abstract class AbstractCli {
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());
}
@@ -407,7 +406,7 @@ public abstract class AbstractCli {
}
if (specialCmd.startsWith(SET_MAX_DISPLAY_NUM)) {
- setMaxDisplaNum(specialCmd, cmd);
+ setMaxDisplayNum(specialCmd, cmd);
return OperationResult.CONTINUE_OPER;
}
@@ -506,7 +505,7 @@ public abstract class AbstractCli {
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",
diff --git a/cli/src/main/java/org/apache/iotdb/cli/Cli.java b/cli/src/main/java/org/apache/iotdb/cli/Cli.java
index ba877ee..dbeae4b 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/Cli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/Cli.java
@@ -101,7 +101,7 @@ public class Cli extends AbstractCli {
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;
diff --git a/cli/src/main/java/org/apache/iotdb/cli/WinCli.java b/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
index cc956d1..4cd27d7 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
@@ -99,8 +99,10 @@ public class WinCli extends AbstractCli {
}
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) {
@@ -109,7 +111,7 @@ public class WinCli extends AbstractCli {
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;
diff --git a/cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java b/cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java
index d6bfb61..342fe0c 100644
--- a/cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java
+++ b/cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java
@@ -208,11 +208,28 @@ public class AbstractCliIT {
}
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) {
+ }
}
}