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 97e3b6d  Add judgment and Modify level3 cannot be a keyword (#1025)
97e3b6d is described below

commit 97e3b6d1bcae9de7a0d86198ac1fe62ebe272b30
Author: iwasjoker <[email protected]>
AuthorDate: Fri Apr 17 19:31:21 2020 +0800

    Add judgment and Modify level3 cannot be a keyword (#1025)
    
    * Added try/catch on storage group and timeseries
    * Modify level3 cannot be "device" keyword
---
 .../src/main/java/org/apache/iotdb/JDBCExample.java   | 19 +++++++++++++------
 .../main/java/org/apache/iotdb/kafka/Constant.java    | 11 +++++++++--
 .../org/apache/iotdb/kafka/KafkaConsumerThread.java   |  2 +-
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/example/jdbc/src/main/java/org/apache/iotdb/JDBCExample.java 
b/example/jdbc/src/main/java/org/apache/iotdb/JDBCExample.java
index 011fba1..00f1084 100644
--- a/example/jdbc/src/main/java/org/apache/iotdb/JDBCExample.java
+++ b/example/jdbc/src/main/java/org/apache/iotdb/JDBCExample.java
@@ -18,6 +18,8 @@
  */
 package org.apache.iotdb;
 
+import org.apache.iotdb.jdbc.IoTDBSQLException;
+
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
@@ -26,15 +28,18 @@ import java.sql.SQLException;
 import java.sql.Statement;
 
 public class JDBCExample {
-
   public static void main(String[] args) throws ClassNotFoundException, 
SQLException {
     Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
     try (Connection connection = 
DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-         Statement statement = connection.createStatement()) {
-      statement.execute("SET STORAGE GROUP TO root.sg1");
-      statement.execute("CREATE TIMESERIES root.sg1.d1.s1 WITH DATATYPE=INT64, 
ENCODING=RLE");
-      statement.execute("CREATE TIMESERIES root.sg1.d1.s2 WITH DATATYPE=INT64, 
ENCODING=RLE");
-      statement.execute("CREATE TIMESERIES root.sg1.d1.s3 WITH DATATYPE=INT64, 
ENCODING=RLE");
+      Statement statement = connection.createStatement()) {
+      try {
+        statement.execute("SET STORAGE GROUP TO root.sg1");
+        statement.execute("CREATE TIMESERIES root.sg1.d1.s1 WITH 
DATATYPE=INT64, ENCODING=RLE, COMPRESSOR=SNAPPY");
+        statement.execute("CREATE TIMESERIES root.sg1.d1.s2 WITH 
DATATYPE=INT64, ENCODING=RLE, COMPRESSOR=SNAPPY");
+        statement.execute("CREATE TIMESERIES root.sg1.d1.s3 WITH 
DATATYPE=INT64, ENCODING=RLE, COMPRESSOR=SNAPPY");
+      } catch (IoTDBSQLException e) {
+        System.out.println(e.getMessage());
+      }
 
       for (int i = 0; i <= 100; i++) {
         statement.addBatch("insert into root.sg1.d1(timestamp, s1, s2, s3) 
values("+ i + "," + 1 + "," + 1 + "," + 1 + ")");
@@ -48,6 +53,8 @@ public class JDBCExample {
       outputResult(resultSet);
       resultSet = statement.executeQuery("select count(*) from root where time 
>= 1 and time <= 100 group by ([0, 100), 20ms, 20ms)");
       outputResult(resultSet);
+    } catch (IoTDBSQLException e){
+        System.out.println(e.getMessage());
     }
   }
 
diff --git a/example/kafka/src/main/java/org/apache/iotdb/kafka/Constant.java 
b/example/kafka/src/main/java/org/apache/iotdb/kafka/Constant.java
index 4a7915d..4901eec 100644
--- a/example/kafka/src/main/java/org/apache/iotdb/kafka/Constant.java
+++ b/example/kafka/src/main/java/org/apache/iotdb/kafka/Constant.java
@@ -28,8 +28,15 @@ public class Constant {
   public static final String IOTDB_CONNECTION_USER = "root";
   public static final String IOTDB_CONNECTION_PASSWORD = "root";
   public static final String STORAGE_GROUP = "root.vehicle";
-  public static final String[] ALL_TIMESERIES = {"root.vehicle.device.sensor1",
-      "root.vehicle.device.sensor2", "root.vehicle.device.sensor3", 
"root.vehicle.device.sensor4"};
+
+  /**
+   *  If you write level3 as device, timeseries will not be created because 
device is the keyword
+   */
+  public static final String[] ALL_TIMESERIES = {
+          "root.vehicle.deviceid.sensor1",
+          "root.vehicle.deviceid.sensor2",
+          "root.vehicle.deviceid.sensor3",
+          "root.vehicle.deviceid.sensor4"};
   public static final String[] ALL_DATA = {
       "sensor1,2017/10/24 19:30:00,606162908",
       "sensor2,2017/10/24 19:30:00,160161162",
diff --git 
a/example/kafka/src/main/java/org/apache/iotdb/kafka/KafkaConsumerThread.java 
b/example/kafka/src/main/java/org/apache/iotdb/kafka/KafkaConsumerThread.java
index 86be072..487d938 100644
--- 
a/example/kafka/src/main/java/org/apache/iotdb/kafka/KafkaConsumerThread.java
+++ 
b/example/kafka/src/main/java/org/apache/iotdb/kafka/KafkaConsumerThread.java
@@ -36,7 +36,7 @@ public class KafkaConsumerThread implements Runnable {
   private static boolean createTimeSeries = true;
   private String createStorageGroupSqlTemplate = "SET STORAGE GROUP TO %s";
   private String createTimeseriesSqlTemplate = "CREATE TIMESERIES %s WITH 
DATATYPE=TEXT, ENCODING=PLAIN";
-  private String insertDataSqlTemplate = "INSERT INTO 
root.vehicle.device(timestamp,%s) VALUES (%s,'%s')";
+  private String insertDataSqlTemplate = "INSERT INTO 
root.vehicle.deviceid(timestamp,%s) VALUES (%s,'%s')";
   private static final Logger logger = 
LoggerFactory.getLogger(KafkaConsumerThread.class);
 
   public KafkaConsumerThread(KafkaStream<String, String> stream) {

Reply via email to