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/12/26 12:11:16 UTC

[incubator-iotdb] branch rel/0.9-load updated (6f26451 -> f280d49)

This is an automated email from the ASF dual-hosted git repository.

lta pushed a change to branch rel/0.9-load
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


    from 6f26451  update doc
     new 2cd481e  fix a bug of load external tsfile
     new f280d49  fix a bug of load external file

The 2 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.


Summary of changes:
 .../org/apache/iotdb/db/sql/parse/TqlLexer.g       |  5 --
 .../org/apache/iotdb/db/sql/parse/TqlParser.g      | 18 ++---
 .../iotdb/db/qp/strategy/LogicalGenerator.java     | 17 +++--
 .../integration/IoTDBLoadExternalTsfileTest.java   | 89 ----------------------
 .../apache/iotdb/db/qp/plan/PhysicalPlanTest.java  |  2 +-
 5 files changed, 19 insertions(+), 112 deletions(-)
 delete mode 100644 server/src/test/java/org/apache/iotdb/db/integration/IoTDBLoadExternalTsfileTest.java


[incubator-iotdb] 01/02: fix a bug of load external tsfile

Posted by lt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lta pushed a commit to branch rel/0.9-load
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 2cd481e65297760e113e58ddfc330a61fc5e4206
Author: lta <li...@163.com>
AuthorDate: Thu Dec 26 19:52:08 2019 +0800

    fix a bug of load external tsfile
---
 .../org/apache/iotdb/db/sql/parse/TqlLexer.g       |  5 --
 .../org/apache/iotdb/db/sql/parse/TqlParser.g      | 15 ++--
 .../iotdb/db/qp/strategy/LogicalGenerator.java     |  3 +-
 .../integration/IoTDBLoadExternalTsfileTest.java   | 89 ----------------------
 4 files changed, 9 insertions(+), 103 deletions(-)

diff --git a/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlLexer.g b/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlLexer.g
index 0217ec5..5fc365f 100644
--- a/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlLexer.g
+++ b/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlLexer.g
@@ -416,11 +416,6 @@ DATETIME
       (('+' | '-') INT ':' INT)?
     ;
 
-BOOLEAN_VALUE
-   : T R U E
-   | F A L S E
-   ;
-
 EXPONENT : INT ('e'|'E') ('+'|'-')? INT ;
 
     
diff --git a/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlParser.g b/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlParser.g
index 5944c0b..2d89c57 100644
--- a/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlParser.g
+++ b/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlParser.g
@@ -757,11 +757,11 @@ rootOrId
     ;
 
 /*
-****	****
-*************	*************
-TTL	Operate file
-*************	*************
-****	****
+****
+*************
+Operate file
+*************
+****
 */
 operateFileStatement
     : loadFiles
@@ -772,9 +772,8 @@ loadFiles
     ;
 
 autoCreateSchema
-    :
-    | BOOLEAN_VALUE
-    | BOOLEAN_VALUE INT
+    : ID
+    | ID INT
     ;
 /*
 ****
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 4e820de..2c0ee1b 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
@@ -290,7 +290,8 @@ public class LogicalGenerator {
   }
 
   private void analyzeLoadFile(AstNode astNode){
-    if (!astNode.getChild(2).getChild(0).getText().equalsIgnoreCase("true") && !astNode.getChild(2)
+    if (astNode.getChild(2).getChild(0) != null && !astNode.getChild(2).getChild(0).getText()
+        .equalsIgnoreCase("true") && !astNode.getChild(2)
         .getChild(0).getText().equalsIgnoreCase("false")) {
       initializedOperator = new LoadFilesOperator(true,
           "Please check the statement: load [FILE] true/false [storage group level]");
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLoadExternalTsfileTest.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLoadExternalTsfileTest.java
deleted file mode 100644
index 8bb8f6d..0000000
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLoadExternalTsfileTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.apache.iotdb.db.integration;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-import org.apache.iotdb.db.engine.StorageEngine;
-import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.jdbc.Config;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IoTDBLoadExternalTsfileTest {
-
-  private static IoTDB daemon;
-  private static String[] sqls = new String[]{
-      "SET STORAGE GROUP TO root.vehicle",
-      "SET STORAGE GROUP TO root.test",
-      "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, ENCODING=RLE",
-      "CREATE TIMESERIES root.vehicle.d0.s1 WITH DATATYPE=TEXT, ENCODING=PLAIN",
-      "CREATE TIMESERIES root.vehicle.d1.s2 WITH DATATYPE=FLOAT, ENCODING=RLE",
-      "CREATE TIMESERIES root.vehicle.d1.s3 WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
-      "insert into root.vehicle.d0(timestamp,s0) values(10,100)",
-      "insert into root.vehicle.d0(timestamp,s0,s1) values(12,101,'102')",
-      "insert into root.vehicle.d0(timestamp,s1) values(19,'103')",
-      "insert into root.vehicle.d1(timestamp,s2) values(11,104.0)",
-      "insert into root.vehicle.d1(timestamp,s2,s3) values(15,105.0,true)",
-      "insert into root.vehicle.d1(timestamp,s3) values(17,false)",
-      "insert into root.vehicle.d0(timestamp,s0) values(20,1000)"
-  };
-
-  private static final String TIMESTAMP_STR = "Time";
-  private static final String TEMPERATURE_STR = "root.ln.wf01.wt01.temperature";
-  private static final String STATUS_STR = "root.ln.wf01.wt01.status";
-  private static final String HARDWARE_STR = "root.ln.wf01.wt01.hardware";
-
-  @Before
-  public void setUp() throws Exception {
-    EnvironmentUtils.closeStatMonitor();
-    daemon = IoTDB.getInstance();
-    daemon.active();
-    EnvironmentUtils.envSetUp();
-    Class.forName(Config.JDBC_DRIVER_NAME);
-    prepareData();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    daemon.stop();
-    EnvironmentUtils.cleanEnv();
-  }
-
-  @Test
-  public void LoadNewTsfileTest() throws SQLException {
-    try (Connection connection = DriverManager.
-        getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      statement.execute("flush");
-      List<TsFileResource> resources = StorageEngine.getInstance().getProcessor("root.vehicle")
-          .getSequenceFileList();
-      for(TsFileResource resource:resources){
-        System.out.println(resource.getFile().getAbsolutePath());
-      }
-    } catch (StorageEngineException e) {
-      e.printStackTrace();
-    }
-  }
-
-  private void prepareData() throws SQLException {
-    try (Connection connection = DriverManager
-        .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
-            "root");
-        Statement statement = connection.createStatement()) {
-
-
-      for (String sql : sqls) {
-        statement.execute(sql);
-      }
-
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-  }
-}
\ No newline at end of file


[incubator-iotdb] 02/02: fix a bug of load external file

Posted by lt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lta pushed a commit to branch rel/0.9-load
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit f280d49e6e29ab851ab0ca48dbeb686c6dffb7fa
Author: lta <li...@163.com>
AuthorDate: Thu Dec 26 20:10:56 2019 +0800

    fix a bug of load external file
---
 .../antlr3/org/apache/iotdb/db/sql/parse/TqlParser.g   |  3 ++-
 .../apache/iotdb/db/qp/strategy/LogicalGenerator.java  | 18 +++++++++---------
 .../org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java  |  2 +-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlParser.g b/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlParser.g
index 2d89c57..24c1dec 100644
--- a/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlParser.g
+++ b/server/src/main/antlr3/org/apache/iotdb/db/sql/parse/TqlParser.g
@@ -766,9 +766,10 @@ Operate file
 operateFileStatement
     : loadFiles
     ;
+
 loadFiles
     : K_LOAD path=FILE autoCreateSchema?
-    -> ^(TOK_LOAD_FILES $path)
+    -> ^(TOK_LOAD_FILES $path autoCreateSchema?)
     ;
 
 autoCreateSchema
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 2c0ee1b..7d4b99e 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
@@ -289,18 +289,18 @@ public class LogicalGenerator {
     }
   }
 
-  private void analyzeLoadFile(AstNode astNode){
-    if (astNode.getChild(2).getChild(0) != null && !astNode.getChild(2).getChild(0).getText()
-        .equalsIgnoreCase("true") && !astNode.getChild(2)
-        .getChild(0).getText().equalsIgnoreCase("false")) {
+  private void analyzeLoadFile(AstNode astNode) {
+    if (astNode.getChild(1) != null && !astNode.getChild(1).getText().equalsIgnoreCase("true") && !astNode.getChild(1).getText().equalsIgnoreCase("false")) {
       initializedOperator = new LoadFilesOperator(true,
           "Please check the statement: load [FILE] true/false [storage group level]");
     } else {
-      boolean createSchemaAutomatically = astNode.getChild(2).getChild(0) == null || Boolean
-          .parseBoolean(astNode.getChild(2).getChild(0).getText());
-      int sgLevel = astNode.getChild(2).getChild(1) == null ? IoTDBDescriptor.getInstance().getConfig()
-          .getDefaultStorageGroupLevel() : Integer.parseInt(astNode.getChild(2).getChild(1).getText());
-      initializedOperator = new LoadFilesOperator(new File(astNode.getChild(1).getText()),
+      boolean createSchemaAutomatically =
+          astNode.getChild(1) == null || Boolean
+              .parseBoolean(astNode.getChild(1).getText());
+      int sgLevel =
+          astNode.getChild(2) == null ? IoTDBDescriptor.getInstance().getConfig()
+          .getDefaultStorageGroupLevel() : Integer.parseInt(astNode.getChild(2).getText());
+      initializedOperator = new LoadFilesOperator(new File(astNode.getChild(0).getText()),
           createSchemaAutomatically, sgLevel);
     }
   }
diff --git a/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java b/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
index 1096389..4928522 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
@@ -494,7 +494,7 @@ public class PhysicalPlanTest {
     String metadata = String.format("load %s", filePath);
     QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
     OperateFilePlan plan = (OperateFilePlan) processor.parseSQLToPhysicalPlan(metadata);
-    assertEquals(String.format("OperateFilePlan{file=%s, targetDir= null, operatorType=LOAD_FILES}", filePath), plan.toString());
+    assertEquals(String.format("OperateFilePlan{file=%s, targetDir=null, autoCreateSchema=true, sgLevel=2}", filePath), plan.toString());
     metadata = String.format("load %s true", filePath);
     processor = new QueryProcessor(new MemIntQpExecutor());
     plan = (OperateFilePlan) processor.parseSQLToPhysicalPlan(metadata);