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/06/29 05:16:27 UTC
[incubator-iotdb] branch master updated: add compression keyword
(#1369)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 37504a2 add compression keyword (#1369)
37504a2 is described below
commit 37504a24eed39a5a3a4e8562d5417e1b91bd633c
Author: Boris <ge...@apache.org>
AuthorDate: Mon Jun 29 13:16:16 2020 +0800
add compression keyword (#1369)
* add compression keyword
---
docs/UserGuide/Operation Manual/SQL Reference.md | 6 +-
.../zh/UserGuide/Operation Manual/SQL Reference.md | 6 +-
.../org/apache/iotdb/db/qp/strategy/SqlBase.g4 | 42 ++++++++++++-
.../iotdb/db/qp/strategy/LogicalGenerator.java | 73 +---------------------
4 files changed, 47 insertions(+), 80 deletions(-)
diff --git a/docs/UserGuide/Operation Manual/SQL Reference.md b/docs/UserGuide/Operation Manual/SQL Reference.md
index 094cf89..359273f 100644
--- a/docs/UserGuide/Operation Manual/SQL Reference.md
+++ b/docs/UserGuide/Operation Manual/SQL Reference.md
@@ -32,14 +32,12 @@ All of these statements are write in IoTDB's own syntax, for details about the s
## Keywords
-Please not use these keywords as identifiers.
+Do not use the following keywords as identifiers. You can open an [issue](https://issues.apache.org/jira/projects/IOTDB/issues) to provide new requirements or suggestions.
```
CREATE, INSERT, UPDATE, DELETE, SELECT, SHOW, GRANT, INTO, SET, WHERE, FROM, TO, BY, DEVICE,
CONFIGURATION, DESCRIBE, SLIMIT, LIMIT, UNLINK, OFFSET, SOFFSET, FILL, LINEAR, PREVIOUS, PREVIOUSUNTILLAST,
-METADATA, TIMESERIES, TIMESTAMP, PROPERTY, WITH, ROOT, DATATYPE, COMPRESSOR, STORAGE, GROUP, LABEL,INT32,
-INT64, FLOAT, DOUBLE, BOOLEAN, TEXT, ENCODING, PLAIN, PLAIN_DICTIONARY, RLE, DIFF, TS_2DIFF, GORILLA, REGULAR,
-BITMAP, ADD, UPSERT, VALUES, NOW, LINK, INDEX, USING, ON, DROP, MERGE, LIST, USER, PRIVILEGES, ROLE, ALL, OF,
+METADATA, TIMESERIES, TIMESTAMP, PROPERTY, WITH, ROOT, DATATYPE, COMPRESSOR, STORAGE, GROUP, LABEL, ADD, UPSERT, VALUES, NOW, LINK, INDEX, USING, ON, DROP, MERGE, LIST, USER, PRIVILEGES, ROLE, ALL, OF,
ALTER, PASSWORD, REVOKE, LOAD, WATERMARK_EMBEDDING, UNSET, TTL, FLUSH, TASK, INFO, DYNAMIC, PARAMETER, VERSION,
REMOVE, MOVE, CHILD, PATHS, DEVICES, COUNT, NODES, LEVEL, MIN_TIME, MAX_TIME, MIN_VALUE, MAX_VALUE, AVG, FIRST_VALUE,
SUM, LAST_VALUE, LAST, DISABLE, ALIGN, COMPRESSION, TIME, ATTRIBUTES, TAGS,RENAME, FULL, CLEAR, CACHE,
diff --git a/docs/zh/UserGuide/Operation Manual/SQL Reference.md b/docs/zh/UserGuide/Operation Manual/SQL Reference.md
index f2d6980..2655ecb 100644
--- a/docs/zh/UserGuide/Operation Manual/SQL Reference.md
+++ b/docs/zh/UserGuide/Operation Manual/SQL Reference.md
@@ -23,14 +23,12 @@
## 关键字
-不要使用这些关键字作为标识符。
+不要使用这些关键字作为标识符。如果有需求或者建议,可以在[issue](https://issues.apache.org/jira/projects/IOTDB/issues)上提出。
```
CREATE, INSERT, UPDATE, DELETE, SELECT, SHOW, GRANT, INTO, SET, WHERE, FROM, TO, BY, DEVICE,
CONFIGURATION, DESCRIBE, SLIMIT, LIMIT, UNLINK, OFFSET, SOFFSET, FILL, LINEAR, PREVIOUS, PREVIOUSUNTILLAST,
-METADATA, TIMESERIES, TIMESTAMP, PROPERTY, WITH, ROOT, DATATYPE, COMPRESSOR, STORAGE, GROUP, LABEL,INT32,
-INT64, FLOAT, DOUBLE, BOOLEAN, TEXT, ENCODING, PLAIN, PLAIN_DICTIONARY, RLE, DIFF, TS_2DIFF, GORILLA, REGULAR,
-BITMAP, ADD, UPSERT, VALUES, NOW, LINK, INDEX, USING, ON, DROP, MERGE, LIST, USER, PRIVILEGES, ROLE, ALL, OF,
+METADATA, TIMESERIES, TIMESTAMP, PROPERTY, WITH, ROOT, DATATYPE, COMPRESSOR, STORAGE, GROUP, LABEL, ADD, UPSERT, VALUES, NOW, LINK, INDEX, USING, ON, DROP, MERGE, LIST, USER, PRIVILEGES, ROLE, ALL, OF,
ALTER, PASSWORD, REVOKE, LOAD, WATERMARK_EMBEDDING, UNSET, TTL, FLUSH, TASK, INFO, DYNAMIC, PARAMETER, VERSION,
REMOVE, MOVE, CHILD, PATHS, DEVICES, COUNT, NODES, LEVEL, MIN_TIME, MAX_TIME, MIN_VALUE, MAX_VALUE, AVG, FIRST_VALU,
SUM, LAST_VALUE, LAST, DISABLE, ALIGN, COMPRESSION, TIME, ATTRIBUTES, TAGS,RENAME, FULL, CLEAR, CACHE
diff --git a/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4 b/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
index 2c39fc5..e6d6329 100644
--- a/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
+++ b/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
@@ -143,12 +143,22 @@ aliasClause
attributeClauses
: DATATYPE OPERATOR_EQ dataType COMMA ENCODING OPERATOR_EQ encoding
- (COMMA (COMPRESSOR | COMPRESSION) OPERATOR_EQ compressor=propertyValue)?
+ (COMMA (COMPRESSOR | COMPRESSION) OPERATOR_EQ compressor)?
(COMMA property)*
tagClause
attributeClause
;
+compressor
+ : UNCOMPRESSED
+ | SNAPPY
+ | GZIP
+ | LZO
+ | SDT
+ | PAA
+ | PLA
+ ;
+
attributeClause
: (ATTRIBUTES LR_BRACKET property (COMMA property)* RR_BRACKET)?
;
@@ -372,6 +382,7 @@ nodeName
| MINUS? INT
| booleanClause
| (ID | OPERATOR_IN)? LS_BRACKET ID? RS_BRACKET ID?
+ | compressor
;
nodeNameWithoutStar
@@ -385,6 +396,7 @@ nodeNameWithoutStar
| MINUS? INT
| booleanClause
| (ID | OPERATOR_IN)? LS_BRACKET ID? RS_BRACKET ID?
+ | compressor
;
dataType
@@ -890,6 +902,34 @@ FALSE
: F A L S E
;
+UNCOMPRESSED
+ : U N C O M P R E S S E D
+ ;
+
+SNAPPY
+ : S N A P P Y
+ ;
+
+GZIP
+ : G Z I P
+ ;
+
+LZO
+ : L Z O
+ ;
+
+SDT
+ : S D T
+ ;
+
+PAA
+ : P A A
+ ;
+
+PLA
+ : P L A
+ ;
+
LATEST
: L A T E S T
;
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 edc2b9c..6b14f26 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
@@ -1129,12 +1129,11 @@ public class LogicalGenerator extends SqlBaseBaseListener {
CompressionType compressor;
List<PropertyContext> properties = ctx.property();
Map<String, String> props = new HashMap<>(properties.size());
- if (ctx.propertyValue() != null) {
- compressor = CompressionType.valueOf(ctx.propertyValue().getText().toUpperCase());
+ if (ctx.compressor() != null) {
+ compressor = CompressionType.valueOf(ctx.compressor().getText().toUpperCase());
} else {
compressor = TSFileDescriptor.getInstance().getConfig().getCompressor();
}
- checkMetadataArgs(dataType, encoding, compressor.toString().toUpperCase());
if (ctx.property(0) != null) {
for (PropertyContext property : properties) {
props.put(property.ID().getText().toLowerCase(),
@@ -1563,74 +1562,6 @@ public class LogicalGenerator extends SqlBaseBaseListener {
return time;
}
- private void checkMetadataArgs(String dataType, String encoding, String compressor) {
- TSDataType tsDataType;
- TSEncoding tsEncoding;
- if (dataType == null) {
- throw new SQLParserException("data type cannot be null");
- }
-
- try {
- tsDataType = TSDataType.valueOf(dataType);
- } catch (Exception e) {
- throw new SQLParserException(String.format("data type %s not support", dataType));
- }
-
- if (encoding == null) {
- throw new SQLParserException("encoding type cannot be null");
- }
-
- try {
- tsEncoding = TSEncoding.valueOf(encoding);
- } catch (Exception e) {
- throw new SQLParserException(String.format("encoding %s is not support", encoding));
- }
-
- try {
- CompressionType.valueOf(compressor);
- } catch (Exception e) {
- throw new SQLParserException(String.format("compressor %s is not support", compressor));
- }
-
- checkDataTypeEncoding(tsDataType, tsEncoding);
- }
-
- private void checkDataTypeEncoding(TSDataType tsDataType, TSEncoding tsEncoding) {
- boolean throwExp = false;
- switch (tsDataType) {
- case BOOLEAN:
- if (!(tsEncoding.equals(TSEncoding.RLE) || tsEncoding.equals(TSEncoding.PLAIN))) {
- throwExp = true;
- }
- break;
- case INT32:
- case INT64:
- if (!(tsEncoding.equals(TSEncoding.RLE) || tsEncoding.equals(TSEncoding.PLAIN)
- || tsEncoding.equals(TSEncoding.TS_2DIFF))) {
- throwExp = true;
- }
- break;
- case FLOAT:
- case DOUBLE:
- if (!(tsEncoding.equals(TSEncoding.RLE) || tsEncoding.equals(TSEncoding.PLAIN)
- || tsEncoding.equals(TSEncoding.TS_2DIFF) || tsEncoding.equals(TSEncoding.GORILLA))) {
- throwExp = true;
- }
- break;
- case TEXT:
- if (!tsEncoding.equals(TSEncoding.PLAIN)) {
- throwExp = true;
- }
- break;
- default:
- throwExp = true;
- }
- if (throwExp) {
- throw new SQLParserException(
- String.format("encoding %s does not support %s", tsEncoding, tsDataType));
- }
- }
-
@Override
public void enterShowMergeStatus(ShowMergeStatusContext ctx) {
super.enterShowMergeStatus(ctx);