You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by lt...@apache.org on 2019/04/03 13:47:43 UTC
[incubator-iotdb] branch add_create_ts_operator created (now
91a7beb)
This is an automated email from the ASF dual-hosted git repository.
lta pushed a change to branch add_create_ts_operator
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.
at 91a7beb add_create_ts_operator
This branch includes the following new commits:
new 91a7beb add_create_ts_operator
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-iotdb] 01/01: add_create_ts_operator
Posted by lt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lta pushed a commit to branch add_create_ts_operator
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 91a7beb0a6453a159b709666215086fa0c23dc18
Author: lta <li...@163.com>
AuthorDate: Wed Apr 3 21:47:23 2019 +0800
add_create_ts_operator
---
.../org/apache/iotdb/db/qp/QueryProcessor.java | 1 +
.../iotdb/db/qp/executor/OverflowQPExecutor.java | 1 +
.../org/apache/iotdb/db/qp/logical/Operator.java | 2 +-
.../iotdb/db/qp/logical/sys/MetadataOperator.java | 4 +-
.../iotdb/db/qp/physical/sys/MetadataPlan.java | 5 +-
.../iotdb/db/qp/strategy/PhysicalGenerator.java | 1 +
.../writelog/transfer/PhysicalPlanLogTransfer.java | 1 +
.../org/apache/iotdb/db/qp/QueryProcessorTest.java | 59 ++++++++++++++++++++++
.../iotdb/db/qp/strategy/LogicalGeneratorTest.java | 1 +
.../transfer/PhysicalPlanLogTransferTest.java | 29 ++++++-----
10 files changed, 87 insertions(+), 17 deletions(-)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/QueryProcessor.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/QueryProcessor.java
index 1ec75a7..c64c71a 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/QueryProcessor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/QueryProcessor.java
@@ -128,6 +128,7 @@ public class QueryProcessor {
case AUTHOR:
case METADATA:
case SET_STORAGE_GROUP:
+ case CREATE_TIMESERIES:
case DELETE_TIMESERIES:
case PROPERTY:
case LOADDATA:
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/OverflowQPExecutor.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/OverflowQPExecutor.java
index 061bb47..93b8be1 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/OverflowQPExecutor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/OverflowQPExecutor.java
@@ -143,6 +143,7 @@ public class OverflowQPExecutor extends QueryProcessExecutor {
MManager.getInstance());
return true;
case DELETE_TIMESERIES:
+ case CREATE_TIMESERIES:
case SET_STORAGE_GROUP:
case METADATA:
MetadataPlan metadata = (MetadataPlan) plan;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/Operator.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/Operator.java
index b346cdb..c7a9eb7 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/Operator.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/Operator.java
@@ -69,7 +69,7 @@ public abstract class Operator {
SFW, JOIN, UNION, FILTER, GROUPBY, ORDERBY, LIMIT, SELECT, SEQTABLESCAN, HASHTABLESCAN,
MERGEJOIN, FILEREAD, NULL, TABLESCAN, UPDATE, INSERT, DELETE, BASIC_FUNC, QUERY, MERGEQUERY,
AGGREGATION, AUTHOR, FROM, FUNC, LOADDATA, METADATA, PROPERTY, INDEX, INDEXQUERY, FILL,
- SET_STORAGE_GROUP, DELETE_TIMESERIES, CREATE_USER, DELETE_USER, MODIFY_PASSWORD,
+ SET_STORAGE_GROUP, CREATE_TIMESERIES, DELETE_TIMESERIES, CREATE_USER, DELETE_USER, MODIFY_PASSWORD,
GRANT_USER_PRIVILEGE, REVOKE_USER_PRIVILEGE, GRANT_USER_ROLE, REVOKE_USER_ROLE, CREATE_ROLE,
DELETE_ROLE, GRANT_ROLE_PRIVILEGE, REVOKE_ROLE_PRIVILEGE, LIST_USER, LIST_ROLE,
LIST_USER_PRIVILEGE, LIST_ROLE_PRIVILEGE, LIST_USER_ROLES, LIST_ROLE_USERS;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/sys/MetadataOperator.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/sys/MetadataOperator.java
index a0e81b0..4f2c6bd 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/sys/MetadataOperator.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/sys/MetadataOperator.java
@@ -47,9 +47,11 @@ public class MetadataOperator extends RootOperator {
namespaceType = type;
switch (type) {
case SET_FILE_LEVEL:
- case ADD_PATH:
operatorType = OperatorType.SET_STORAGE_GROUP;
break;
+ case ADD_PATH:
+ operatorType = OperatorType.CREATE_TIMESERIES;
+ break;
case DELETE_PATH:
operatorType = OperatorType.DELETE_TIMESERIES;
break;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/physical/sys/MetadataPlan.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/physical/sys/MetadataPlan.java
index f612165..4a63b68 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/physical/sys/MetadataPlan.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/physical/sys/MetadataPlan.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
import org.apache.iotdb.db.qp.logical.sys.MetadataOperator;
import org.apache.iotdb.db.qp.physical.PhysicalPlan;
import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
@@ -57,9 +58,11 @@ public class MetadataPlan extends PhysicalPlan {
this.deletePathList = deletePathList;
switch (namespaceType) {
case SET_FILE_LEVEL:
- case ADD_PATH:
setOperatorType(Operator.OperatorType.SET_STORAGE_GROUP);
break;
+ case ADD_PATH:
+ setOperatorType(Operator.OperatorType.CREATE_TIMESERIES);
+ break;
case DELETE_PATH:
setOperatorType(Operator.OperatorType.DELETE_TIMESERIES);
break;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
index 2caac94..7d8318a 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
@@ -80,6 +80,7 @@ public class PhysicalGenerator {
LoadDataOperator loadData = (LoadDataOperator) operator;
return new LoadDataPlan(loadData.getInputFilePath(), loadData.getMeasureType());
case SET_STORAGE_GROUP:
+ case CREATE_TIMESERIES:
case DELETE_TIMESERIES:
case METADATA:
MetadataOperator metadata = (MetadataOperator) operator;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanLogTransfer.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanLogTransfer.java
index 110e5e9..838ddb7 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanLogTransfer.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanLogTransfer.java
@@ -41,6 +41,7 @@ public class PhysicalPlanLogTransfer {
codec = (Codec<PhysicalPlan>) PhysicalPlanCodec.fromOpcode(SystemLogOperator.DELETE).codec;
break;
case DELETE_TIMESERIES:
+ case CREATE_TIMESERIES:
case SET_STORAGE_GROUP:
codec = (Codec<PhysicalPlan>) PhysicalPlanCodec.fromOpcode(SystemLogOperator.METADATA).codec;
break;
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/qp/QueryProcessorTest.java b/iotdb/src/test/java/org/apache/iotdb/db/qp/QueryProcessorTest.java
new file mode 100644
index 0000000..489bd20
--- /dev/null
+++ b/iotdb/src/test/java/org/apache/iotdb/db/qp/QueryProcessorTest.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.db.qp;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.iotdb.db.exception.ArgsErrorException;
+import org.apache.iotdb.db.exception.ProcessorException;
+import org.apache.iotdb.db.exception.qp.QueryProcessorException;
+import org.apache.iotdb.db.qp.executor.OverflowQPExecutor;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.db.qp.physical.PhysicalPlan;
+import org.junit.Test;
+
+public class QueryProcessorTest {
+
+ private QueryProcessor processor = new QueryProcessor(new OverflowQPExecutor());
+
+ @Test
+ public void parseSQLToPhysicalPlan()
+ throws ArgsErrorException, ProcessorException, QueryProcessorException {
+ String createSGStatement = "set storage group to root.vehicle";
+ PhysicalPlan plan1 = processor.parseSQLToPhysicalPlan(createSGStatement);
+ assertEquals(OperatorType.SET_STORAGE_GROUP, plan1.getOperatorType());
+
+ String createTSStatement = "create timeseries root.vehicle.d1.s1 with datatype=INT32,encoding=RLE";
+ PhysicalPlan plan2 = processor.parseSQLToPhysicalPlan(createTSStatement);
+ assertEquals(OperatorType.CREATE_TIMESERIES, plan2.getOperatorType());
+
+ String deleteTSStatement = "delete timeseries root.vehicle.d1.s1";
+ PhysicalPlan plan3 = processor.parseSQLToPhysicalPlan(deleteTSStatement);
+ assertEquals(OperatorType.DELETE_TIMESERIES, plan3.getOperatorType());
+
+ String insertStatement = "insert into root.vehicle.d0(timestamp,s0) values(10,100)";
+ PhysicalPlan plan4 = processor.parseSQLToPhysicalPlan(insertStatement);
+ assertEquals(OperatorType.INSERT, plan4.getOperatorType());
+
+ String propertyStatement = "add label label1021 to property propropro";
+ PhysicalPlan plan5 = processor.parseSQLToPhysicalPlan(propertyStatement);
+ assertEquals(OperatorType.PROPERTY, plan5.getOperatorType());
+
+ }
+}
\ No newline at end of file
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/qp/strategy/LogicalGeneratorTest.java b/iotdb/src/test/java/org/apache/iotdb/db/qp/strategy/LogicalGeneratorTest.java
index 093fd93..f22a6e8 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/qp/strategy/LogicalGeneratorTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/qp/strategy/LogicalGeneratorTest.java
@@ -74,4 +74,5 @@ public class LogicalGeneratorTest {
public void testParseTimeFormatFail2() throws LogicalOperatorException {
generator.parseTimeFormat("");
}
+
}
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanLogTransferTest.java b/iotdb/src/test/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanLogTransferTest.java
index a226336..58e8b1f 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanLogTransferTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanLogTransferTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.iotdb.db.writelog.transfer;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
@@ -55,19 +56,19 @@ public class PhysicalPlanLogTransferTest {
byte[] insertPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(insertPlan);
Codec<InsertPlan> insertPlanCodec = CodecInstances.multiInsertPlanCodec;
byte[] insertPlanProperty = insertPlanCodec.encode(insertPlan);
- assertEquals(true, Arrays.equals(insertPlanProperty, insertPlanBytesTest));
+ assertArrayEquals(insertPlanProperty, insertPlanBytesTest);
/** Delete Plan test **/
byte[] deletePlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(deletePlan);
Codec<DeletePlan> deletePlanCodec = CodecInstances.deletePlanCodec;
byte[] deletePlanProperty = deletePlanCodec.encode(deletePlan);
- assertEquals(true, Arrays.equals(deletePlanProperty, deletePlanBytesTest));
+ assertArrayEquals(deletePlanProperty, deletePlanBytesTest);
/** Update Plan test **/
byte[] updatePlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(updatePlan);
Codec<UpdatePlan> updatePlanCodec = CodecInstances.updatePlanCodec;
byte[] updatePlanProperty = updatePlanCodec.encode(updatePlan);
- assertEquals(true, Arrays.equals(updatePlanProperty, updatePlanBytesTest));
+ assertArrayEquals(updatePlanProperty, updatePlanBytesTest);
/** Metadata Plan test **/
String metadataStatement = "create timeseries root.vehicle.d1.s1 with datatype=INT32,encoding=RLE";
@@ -75,7 +76,7 @@ public class PhysicalPlanLogTransferTest {
byte[] metadataPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(metadataPlan);
Codec<MetadataPlan> metadataPlanCodec = CodecInstances.metadataPlanCodec;
byte[] metadataPlanProperty = metadataPlanCodec.encode(metadataPlan);
- assertEquals(true, Arrays.equals(metadataPlanProperty, metadataPlanBytesTest));
+ assertArrayEquals(metadataPlanProperty, metadataPlanBytesTest);
/** Author Plan test **/
String sql = "grant role xm privileges 'SET_STORAGE_GROUP','DELETE_TIMESERIES' on root.vehicle.device.sensor";
@@ -83,13 +84,13 @@ public class PhysicalPlanLogTransferTest {
byte[] authorPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(authorPlan);
Codec<AuthorPlan> authorPlanCodec = CodecInstances.authorPlanCodec;
byte[] authorPlanProperty = authorPlanCodec.encode(authorPlan);
- assertEquals(true, Arrays.equals(authorPlanProperty, authorPlanBytesTest));
+ assertArrayEquals(authorPlanProperty, authorPlanBytesTest);
/** LoadData Plan test **/
byte[] loadDataPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(loadDataPlan);
Codec<LoadDataPlan> loadDataPlanCodec = CodecInstances.loadDataPlanCodec;
byte[] loadDataPlanProperty = loadDataPlanCodec.encode(loadDataPlan);
- assertEquals(true, Arrays.equals(loadDataPlanProperty, loadDataPlanBytesTest));
+ assertArrayEquals(loadDataPlanProperty, loadDataPlanBytesTest);
/** Property Plan test **/
sql = "add label label1021 to property propropro";
@@ -97,7 +98,7 @@ public class PhysicalPlanLogTransferTest {
byte[] propertyPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(propertyPlan);
Codec<PropertyPlan> propertyPlanCodec = CodecInstances.propertyPlanCodec;
byte[] propertyPlanProperty = propertyPlanCodec.encode(propertyPlan);
- assertEquals(true, Arrays.equals(propertyPlanProperty, propertyPlanBytesTest));
+ assertArrayEquals(propertyPlanProperty, propertyPlanBytesTest);
}
@@ -109,19 +110,19 @@ public class PhysicalPlanLogTransferTest {
byte[] insertPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(insertPlan);
InsertPlan insertPlanTest = (InsertPlan) PhysicalPlanLogTransfer
.logToOperator(insertPlanBytesTest);
- assertEquals(true, insertPlanTest.equals(insertPlan));
+ assertEquals(insertPlanTest, insertPlan);
/** Delete Plan test **/
byte[] deletePlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(deletePlan);
DeletePlan deletePlanTest = (DeletePlan) PhysicalPlanLogTransfer
.logToOperator(deletePlanBytesTest);
- assertEquals(true, deletePlanTest.equals(deletePlan));
+ assertEquals(deletePlanTest, deletePlan);
/** Update Plan test **/
byte[] updatePlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(updatePlan);
UpdatePlan updatePlanTest = (UpdatePlan) PhysicalPlanLogTransfer
.logToOperator(updatePlanBytesTest);
- assertEquals(true, updatePlanTest.equals(updatePlan));
+ assertEquals(updatePlanTest, updatePlan);
/** Metadata Plan test **/
String metadataStatement = "create timeseries root.vehicle.d1.s1 with datatype=INT32,encoding=RLE";
@@ -129,7 +130,7 @@ public class PhysicalPlanLogTransferTest {
byte[] metadataPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(metadataPlan);
MetadataPlan metadataPlanTest = (MetadataPlan) PhysicalPlanLogTransfer
.logToOperator(metadataPlanBytesTest);
- assertEquals(true, metadataPlanTest.equals(metadataPlan));
+ assertEquals(metadataPlanTest, metadataPlan);
/** Author Plan test **/
String sql = "grant role xm privileges 'SET_STORAGE_GROUP','DELETE_TIMESERIES' on root.vehicle.device.sensor";
@@ -137,13 +138,13 @@ public class PhysicalPlanLogTransferTest {
byte[] authorPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(authorPlan);
AuthorPlan authorPlanTest = (AuthorPlan) PhysicalPlanLogTransfer
.logToOperator(authorPlanBytesTest);
- assertEquals(true, authorPlanTest.equals(authorPlan));
+ assertEquals(authorPlanTest, authorPlan);
/** LoadData Plan test **/
byte[] loadDataPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(loadDataPlan);
LoadDataPlan loadDataPlanTest = (LoadDataPlan) PhysicalPlanLogTransfer
.logToOperator(loadDataPlanBytesTest);
- assertEquals(true, loadDataPlan.equals(loadDataPlanTest));
+ assertEquals(loadDataPlan, loadDataPlanTest);
/** Property Plan test **/
sql = "add label label1021 to property propropro";
@@ -151,7 +152,7 @@ public class PhysicalPlanLogTransferTest {
byte[] propertyPlanBytesTest = PhysicalPlanLogTransfer.operatorToLog(propertyPlan);
PropertyPlan propertyPlanTest = (PropertyPlan) PhysicalPlanLogTransfer
.logToOperator(propertyPlanBytesTest);
- assertEquals(true, propertyPlanTest.equals(propertyPlan));
+ assertEquals(propertyPlanTest, propertyPlan);
}
}
\ No newline at end of file