This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch dev_TTL
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/dev_TTL by this push:
new f10899d fix ttl grammar and docs
f10899d is described below
commit f10899d9a191c5bde3869c58bd575c8b5b6a1f61
Author: jt <[email protected]>
AuthorDate: Wed Sep 18 16:53:35 2019 +0800
fix ttl grammar and docs
---
.../1-IoTDB Query Statement.md | 11 +++---
.../1-IoTDB Query Statement.md | 7 ++--
.../org/apache/iotdb/db/sql/parse/TSParser.g | 2 +-
.../iotdb/db/qp/strategy/LogicalGenerator.java | 40 ++++++++++------------
4 files changed, 27 insertions(+), 33 deletions(-)
diff --git a/docs/Documentation-CHN/UserGuide/5-IoTDB SQL Documentation/1-IoTDB
Query Statement.md b/docs/Documentation-CHN/UserGuide/5-IoTDB SQL
Documentation/1-IoTDB Query Statement.md
index 3a66444..24b024f 100644
--- a/docs/Documentation-CHN/UserGuide/5-IoTDB SQL Documentation/1-IoTDB Query
Statement.md
+++ b/docs/Documentation-CHN/UserGuide/5-IoTDB SQL Documentation/1-IoTDB Query
Statement.md
@@ -481,19 +481,18 @@ IoTDB支持对存储组级别设置数据存活时间(TTL),这使得IoTDB
可以帮助您控制IoTDB占用的总磁盘空间以避免出现磁盘写满等异常。并且,随着文件数量的增多,查询性能往往随之下降。
及时地删除一些较老的文件有助于使得查询性能维持在一个较高的水平。IoTDB中的TTL操作通过以下的语句进行支持:
-* Set TTL
+* 设置 TTL
```
SET TTL TO StorageGroupName TTLTime
-Eg.1 SET TTL TO root.group1 3600000
-Eg.2 SET TTL TO root.group1 1h
+Eg. SET TTL TO root.group1 3600000
这个例子展示了如何使得root.group1这个存储组只保留近一个小时的数据,一个小时前的数据会被删除或者进入不可见状态。
-Note: TTLTime 可以是毫秒时间戳或是日期格式。一旦TTL被设置,超过TTL时间范围的写入将被拒绝。
+Note: TTLTime 应是毫秒时间戳。一旦TTL被设置,超过TTL时间范围的写入将被拒绝。
```
-* Unset TTL
+* 取消 TTL
```
UNSET TTL TO StorageGroupName
-Eg.1 UNSET TTL TO root.group1
+Eg. UNSET TTL TO root.group1
这个例子展示了如何取消存储组root.group1的TTL,这将使得该存储组接受任意时刻的数据。
```
diff --git a/docs/Documentation/UserGuide/5-IoTDB SQL Documentation/1-IoTDB
Query Statement.md b/docs/Documentation/UserGuide/5-IoTDB SQL
Documentation/1-IoTDB Query Statement.md
index 733fc3f..b5d2830 100644
--- a/docs/Documentation/UserGuide/5-IoTDB SQL Documentation/1-IoTDB Query
Statement.md
+++ b/docs/Documentation/UserGuide/5-IoTDB SQL Documentation/1-IoTDB Query
Statement.md
@@ -513,18 +513,17 @@ following two statements:
* Set TTL
```
SET TTL TO StorageGroupName TTLTime
-Eg.1 SET TTL TO root.group1 3600000
-Eg.2 SET TTL TO root.group1 1h
+Eg. SET TTL TO root.group1 3600000
This example means that for data in root.group1, only that of the latest 1
hour will remain, the
older one is removed or made invisible.
-Note: TTLTime can be millisecond timestamp or date format. When TTL is set,
insertions that fall
+Note: TTLTime should be millisecond timestamp. When TTL is set, insertions
that fall
out of TTL will be rejected.
```
* Unset TTL
```
UNSET TTL TO StorageGroupName
-Eg.1 UNSET TTL TO root.group1
+Eg. UNSET TTL TO root.group1
This example means that data of all time will be stored in this group.
```
diff --git a/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TSParser.g
b/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TSParser.g
index 4afdd68..927a49d 100644
--- a/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TSParser.g
+++ b/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TSParser.g
@@ -917,7 +917,7 @@ ttlStatement
setTTLStatement
:
- KW_SET KW_TTL KW_TO path=prefixPath time=dateFormatWithNumber
+ KW_SET KW_TTL KW_TO path=prefixPath time=UnsignedInteger
-> ^(TOK_TTL TOK_SET $path $time)
;
diff --git
a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
index 0192473..651cc64 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
@@ -236,14 +236,10 @@ public class LogicalGenerator {
}
}
- private void analyzeSetTTL(AstNode astNode) throws LogicalOperatorException {
+ private void analyzeSetTTL(AstNode astNode) {
String path = parsePath(astNode.getChild(1)).getFullPath();
long dataTTL;
- try {
- dataTTL = Long.parseLong(astNode.getChild(2).getText());
- } catch (NumberFormatException e) {
- dataTTL = parseTimeFormat(astNode.getChild(2).getText());
- }
+ dataTTL = Long.parseLong(astNode.getChild(2).getText());
TTLOperator operator = new TTLOperator(SQLConstant.TOK_SET);
initializedOperator = operator;
operator.setStorageGroup(path);
@@ -490,9 +486,9 @@ public class LogicalGenerator {
}
AstNode timeValue = astNode.getChild(2).getChild(0);
if (timeValue.getType() == TSParser.TOK_DATETIME) {
- timestamp = Long.valueOf(parseTokenTime(timeValue));
+ timestamp = parseTimeFormat(parseTokens(timeValue));
} else {
- timestamp = Long.valueOf(astNode.getChild(2).getChild(0).getText());
+ timestamp = Long.parseLong(astNode.getChild(2).getChild(0).getText());
}
} catch (NumberFormatException e) {
throw new LogicalOperatorException(
@@ -647,7 +643,7 @@ public class LogicalGenerator {
case TSParser.KW_NOT:
if (childCount != 1) {
throw new LogicalOperatorException(
- "parsing where clause failed: NOT operator requries one param");
+ "parsing where clause failed: NOT operator requires one param");
}
FilterOperator notOp = new FilterOperator(SQLConstant.KW_NOT);
filterOp.addChildOperator(notOp);
@@ -659,7 +655,7 @@ public class LogicalGenerator {
case TSParser.KW_OR:
if (childCount != 2) {
throw new LogicalOperatorException(
- "parsing where clause failed! node has " + childCount + "
paramter.");
+ "parsing where clause failed! node has " + childCount + "
parameter.");
}
FilterOperator binaryOp = new FilterOperator(
TSParserConstant.getTSTokenIntType(tokenIntType));
@@ -714,15 +710,15 @@ public class LogicalGenerator {
intervalNode = intervalsNode.getChild(i);
AstNode startNode = intervalNode.getChild(0);
if (startNode.getType() == TSParser.TOK_DATETIME) {
- startTime = Long.valueOf(parseTokenTime(startNode));
+ startTime = Long.parseLong(parseTokenTime(startNode));
} else {
- startTime = Long.valueOf(startNode.getText());
+ startTime = Long.parseLong(startNode.getText());
}
AstNode endNode = intervalNode.getChild(1);
if (endNode.getType() == TSParser.TOK_DATETIME) {
- endTime = Long.valueOf(parseTokenTime(endNode));
+ endTime = Long.parseLong(parseTokenTime(endNode));
} else {
- endTime = Long.valueOf(endNode.getText());
+ endTime = Long.parseLong(endNode.getText());
}
intervals.add(new Pair<>(startTime, endTime));
}
@@ -734,9 +730,9 @@ public class LogicalGenerator {
if (childCount == 3) {
AstNode originNode = astNode.getChild(1).getChild(0);
if (originNode.getType() == TSParser.TOK_DATETIME) {
- originTime = Long.valueOf(parseTokenTime(originNode));
+ originTime = Long.parseLong(parseTokenTime(originNode));
} else {
- originTime = Long.valueOf(originNode.getText());
+ originTime = Long.parseLong(originNode.getText());
}
} else {
originTime = parseTimeFormat(SQLConstant.START_TIME_STR);
@@ -900,7 +896,7 @@ public class LogicalGenerator {
return parseTimeFormat(parseTokens(astNode)) + "";
}
- private String parseTokens(AstNode astNode) throws LogicalOperatorException {
+ private String parseTokens(AstNode astNode) {
StringContainer sc = new StringContainer();
for (int i = 0; i < astNode.getChildCount(); i++) {
sc.addTail(astNode.getChild(i).getText());
@@ -911,7 +907,7 @@ public class LogicalGenerator {
/**
* function for parsing time format.
*/
- public long parseTimeFormat(String timestampStr) throws
LogicalOperatorException {
+ long parseTimeFormat(String timestampStr) throws LogicalOperatorException {
if (timestampStr == null || timestampStr.trim().equals("")) {
throw new LogicalOperatorException("input timestamp cannot be empty");
}
@@ -949,9 +945,9 @@ public class LogicalGenerator {
return new Path(new StringContainer(path, TsFileConstant.PATH_SEPARATOR));
}
- private String parseStringWithQuoto(String src) throws
IllegalASTFormatException {
+ private String parseStringWithQuote(String src) throws
IllegalASTFormatException {
if (src.length() < 3 || src.charAt(0) != '\'' || src.charAt(src.length() -
1) != '\'') {
- throw new IllegalASTFormatException("error format for string with
quoto:" + src);
+ throw new IllegalASTFormatException("error format for string with
quote:" + src);
}
return src.substring(1, src.length() - 1);
}
@@ -1074,7 +1070,7 @@ public class LogicalGenerator {
AstNode privilegesNode = astNode.getChild(1);
String[] privileges = new String[privilegesNode.getChildCount()];
for (int i = 0; i < privileges.length; i++) {
- privileges[i] =
parseStringWithQuoto(privilegesNode.getChild(i).getText());
+ privileges[i] =
parseStringWithQuote(privilegesNode.getChild(i).getText());
}
Path nodePath = parsePath(astNode.getChild(2));
if (astNode.getChild(0).getType() == TSParser.TOK_USER) {
@@ -1115,7 +1111,7 @@ public class LogicalGenerator {
AstNode privilegesNode = astNode.getChild(1);
String[] privileges = new String[privilegesNode.getChildCount()];
for (int i = 0; i < privileges.length; i++) {
- privileges[i] =
parseStringWithQuoto(privilegesNode.getChild(i).getText());
+ privileges[i] =
parseStringWithQuote(privilegesNode.getChild(i).getText());
}
Path nodePath = parsePath(astNode.getChild(2));
if (astNode.getChild(0).getType() == TSParser.TOK_USER) {