You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/04/28 07:20:50 UTC

[iotdb] branch SessionInsertDebug created (now fe6d473160)

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

haonan pushed a change to branch SessionInsertDebug
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at fe6d473160 debug

This branch includes the following new commits:

     new fe6d473160 debug

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.



[iotdb] 01/01: debug

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

haonan pushed a commit to branch SessionInsertDebug
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit fe6d4731606df85d600f0a3228a013eefd1409f5
Author: HTHou <hh...@outlook.com>
AuthorDate: Thu Apr 28 15:20:37 2022 +0800

    debug
---
 .../main/java/org/apache/iotdb/SessionExample.java | 138 +++++++++++----------
 .../db/mpp/sql/parser/StatementGenerator.java      |   3 +-
 .../mpp/sql/statement/crud/InsertRowStatement.java |   1 +
 3 files changed, 73 insertions(+), 69 deletions(-)

diff --git a/example/session/src/main/java/org/apache/iotdb/SessionExample.java b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
index b86a4cbcf7..3dbd4c9b1c 100644
--- a/example/session/src/main/java/org/apache/iotdb/SessionExample.java
+++ b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
@@ -69,18 +69,18 @@ public class SessionExample {
 
     // set session fetchSize
     session.setFetchSize(10000);
+    //session.executeNonQueryStatement("set storage group to root.sg1");
 
-    try {
-      session.setStorageGroup("root.sg1");
-    } catch (StatementExecutionException e) {
-      if (e.getStatusCode() != TSStatusCode.PATH_ALREADY_EXIST_ERROR.getStatusCode()) {
-        throw e;
-      }
-    }
+//    try {
+//      session.setStorageGroup("root.sg1");
+//    } catch (StatementExecutionException e) {
+//      if (e.getStatusCode() != TSStatusCode.PATH_ALREADY_EXIST_ERROR.getStatusCode()) {
+//        throw e;
+//      }
+//    }
 
     // createTemplate();
-    createTimeseries();
-    createMultiTimeseries();
+    //createTimeseries();
     insertRecord();
     insertTablet();
     //    insertTabletWithNullValues();
@@ -98,16 +98,16 @@ public class SessionExample {
     //    deleteTimeseries();
     //    setTimeout();
 
-    sessionEnableRedirect = new Session(LOCAL_HOST, 6667, "root", "root");
-    sessionEnableRedirect.setEnableQueryRedirection(true);
-    sessionEnableRedirect.open(false);
-
-    // set session fetchSize
-    sessionEnableRedirect.setFetchSize(10000);
-
-    insertRecord4Redirect();
-    query4Redirect();
-    sessionEnableRedirect.close();
+//    sessionEnableRedirect = new Session(LOCAL_HOST, 6667, "root", "root");
+//    sessionEnableRedirect.setEnableQueryRedirection(true);
+//    sessionEnableRedirect.open(false);
+//
+//    // set session fetchSize
+//    sessionEnableRedirect.setFetchSize(10000);
+//
+//    insertRecord4Redirect();
+//    query4Redirect();
+//    sessionEnableRedirect.close();
     session.close();
   }
 
@@ -133,56 +133,60 @@ public class SessionExample {
 
   private static void createTimeseries()
       throws IoTDBConnectionException, StatementExecutionException {
-
-    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S1)) {
-      session.createTimeseries(
-          ROOT_SG1_D1_S1, TSDataType.INT64, TSEncoding.RLE, CompressionType.SNAPPY);
-    }
-    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S2)) {
-      session.createTimeseries(
-          ROOT_SG1_D1_S2, TSDataType.INT64, TSEncoding.RLE, CompressionType.SNAPPY);
-    }
-    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S3)) {
-      session.createTimeseries(
-          ROOT_SG1_D1_S3, TSDataType.INT64, TSEncoding.RLE, CompressionType.SNAPPY);
-    }
-
-    // create timeseries with tags and attributes
-    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S4)) {
-      Map<String, String> tags = new HashMap<>();
-      tags.put("tag1", "v1");
-      Map<String, String> attributes = new HashMap<>();
-      attributes.put("description", "v1");
-      session.createTimeseries(
-          ROOT_SG1_D1_S4,
-          TSDataType.INT64,
-          TSEncoding.RLE,
-          CompressionType.SNAPPY,
-          null,
-          tags,
-          attributes,
-          "temperature");
-    }
+    session.executeNonQueryStatement("create timeseries root.sg1.d1.s1 with datatype=int64");
+    session.executeNonQueryStatement("create timeseries root.sg1.d1.s2 with datatype=int64");
+    session.executeNonQueryStatement("create timeseries root.sg1.d1.s3 with datatype=int64");
+
+
+//    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S1)) {
+//      session.createTimeseries(
+//          ROOT_SG1_D1_S1, TSDataType.INT64, TSEncoding.RLE, CompressionType.SNAPPY);
+////    }
+////    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S2)) {
+//      session.createTimeseries(
+//          ROOT_SG1_D1_S2, TSDataType.INT64, TSEncoding.RLE, CompressionType.SNAPPY);
+////    }
+////    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S3)) {
+//      session.createTimeseries(
+//          ROOT_SG1_D1_S3, TSDataType.INT64, TSEncoding.RLE, CompressionType.SNAPPY);
+////    }
+
+//    // create timeseries with tags and attributes
+//    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S4)) {
+//      Map<String, String> tags = new HashMap<>();
+//      tags.put("tag1", "v1");
+//      Map<String, String> attributes = new HashMap<>();
+//      attributes.put("description", "v1");
+//      session.createTimeseries(
+//          ROOT_SG1_D1_S4,
+//          TSDataType.INT64,
+//          TSEncoding.RLE,
+//          CompressionType.SNAPPY,
+//          null,
+//          tags,
+//          attributes,
+//          "temperature");
+//    }
 
     // create timeseries with SDT property, SDT will take place when flushing
-    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S5)) {
-      // COMPDEV is required
-      // COMPMAXTIME and COMPMINTIME are optional and their unit is ms
-      Map<String, String> props = new HashMap<>();
-      props.put("LOSS", "sdt");
-      props.put("COMPDEV", "0.01");
-      props.put("COMPMINTIME", "2");
-      props.put("COMPMAXTIME", "10");
-      session.createTimeseries(
-          ROOT_SG1_D1_S5,
-          TSDataType.INT64,
-          TSEncoding.RLE,
-          CompressionType.SNAPPY,
-          props,
-          null,
-          null,
-          null);
-    }
+//    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S5)) {
+//      // COMPDEV is required
+//      // COMPMAXTIME and COMPMINTIME are optional and their unit is ms
+//      Map<String, String> props = new HashMap<>();
+//      props.put("LOSS", "sdt");
+//      props.put("COMPDEV", "0.01");
+//      props.put("COMPMINTIME", "2");
+//      props.put("COMPMAXTIME", "10");
+//      session.createTimeseries(
+//          ROOT_SG1_D1_S5,
+//          TSDataType.INT64,
+//          TSEncoding.RLE,
+//          CompressionType.SNAPPY,
+//          props,
+//          null,
+//          null,
+//          null);
+//    }
   }
 
   private static void createMultiTimeseries()
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/parser/StatementGenerator.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/parser/StatementGenerator.java
index 5545e169e7..92d3bf2d0d 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/parser/StatementGenerator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/parser/StatementGenerator.java
@@ -165,10 +165,9 @@ public class StatementGenerator {
     InsertRowStatement insertStatement = new InsertRowStatement();
     insertStatement.setDevicePath(new PartialPath(insertRecordReq.getPrefixPath()));
     insertStatement.setTime(insertRecordReq.getTimestamp());
-
-    insertStatement.fillValues(insertRecordReq.values);
     insertStatement.setMeasurements(insertRecordReq.getMeasurements().toArray(new String[0]));
     insertStatement.setAligned(insertRecordReq.isAligned);
+    insertStatement.fillValues(insertRecordReq.values);
     return insertStatement;
   }
 
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/statement/crud/InsertRowStatement.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/statement/crud/InsertRowStatement.java
index 72dfed7322..39f9a0ac56 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/statement/crud/InsertRowStatement.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/statement/crud/InsertRowStatement.java
@@ -71,6 +71,7 @@ public class InsertRowStatement extends InsertBaseStatement {
 
   public void fillValues(ByteBuffer buffer) throws QueryProcessException {
     this.values = new Object[measurements.length];
+    this.dataTypes = new TSDataType[measurements.length];
     for (int i = 0; i < dataTypes.length; i++) {
       // types are not determined, the situation mainly occurs when the plan uses string values
       // and is forwarded to other nodes