You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2021/11/11 12:18:04 UTC

[iotdb] branch new_vector updated: [To new_vector] Fix InsertPlan template testcase (#4360)

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

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


The following commit(s) were added to refs/heads/new_vector by this push:
     new 327051e  [To new_vector] Fix InsertPlan template testcase (#4360)
327051e is described below

commit 327051ef41be7ddd2436ce2d89e7d20984bd8851
Author: Marcos_Zyk <38...@users.noreply.github.com>
AuthorDate: Thu Nov 11 20:17:13 2021 +0800

    [To new_vector] Fix InsertPlan template testcase (#4360)
---
 .../org/apache/iotdb/db/metadata/mtree/MTree.java  |   4 +-
 .../iotdb/db/qp/physical/InsertRowPlanTest.java    | 112 +++++++++------------
 .../iotdb/db/qp/physical/InsertTabletPlanTest.java |  54 ++++------
 3 files changed, 69 insertions(+), 101 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java
index 03a53bb..4da6cbe 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java
@@ -410,7 +410,9 @@ public class MTree implements Serializable {
         }
       }
 
-      if (cur.isEntity() && !cur.getAsEntityMNode().isAligned()) {
+      if (cur.isEntity()
+          && !cur.getAsEntityMNode().isAligned()
+          && (!cur.getChildren().isEmpty() || cur.isUseTemplate())) {
         throw new AlignedTimeseriesException(
             "Aligned timeseries cannot be created under this entity", devicePath.getFullPath());
       }
diff --git a/server/src/test/java/org/apache/iotdb/db/qp/physical/InsertRowPlanTest.java b/server/src/test/java/org/apache/iotdb/db/qp/physical/InsertRowPlanTest.java
index b37337d..7ce8e27 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/physical/InsertRowPlanTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/physical/InsertRowPlanTest.java
@@ -71,32 +71,7 @@ public class InsertRowPlanTest {
   public void testInsertRowPlan()
       throws QueryProcessException, MetadataException, InterruptedException,
           QueryFilterOptimizationException, StorageEngineException, IOException {
-    long time = 110L;
-    TSDataType[] dataTypes =
-        new TSDataType[] {
-          TSDataType.DOUBLE,
-          TSDataType.FLOAT,
-          TSDataType.INT64,
-          TSDataType.INT32,
-          TSDataType.BOOLEAN,
-          TSDataType.TEXT
-        };
-
-    String[] columns = new String[6];
-    columns[0] = 1.0 + "";
-    columns[1] = 2 + "";
-    columns[2] = 10000 + "";
-    columns[3] = 100 + "";
-    columns[4] = false + "";
-    columns[5] = "hh" + 0;
-
-    InsertRowPlan rowPlan =
-        new InsertRowPlan(
-            new PartialPath("root.isp.d1"),
-            time,
-            new String[] {"s1", "s2", "s3", "s4", "s5", "s6"},
-            dataTypes,
-            columns);
+    InsertRowPlan rowPlan = getInsertRowPlan();
 
     PlanExecutor executor = new PlanExecutor();
     executor.insert(rowPlan);
@@ -136,50 +111,32 @@ public class InsertRowPlanTest {
       throws QueryProcessException, MetadataException, InterruptedException,
           QueryFilterOptimizationException, StorageEngineException, IOException {
     List<List<String>> measurementList = new ArrayList<>();
-    List<String> v1 = new ArrayList<>();
-    v1.add("s1");
-    v1.add("s2");
-    v1.add("s3");
-    measurementList.add(v1);
-    List<String> v2 = new ArrayList<>();
-    v2.add("s4");
-    v2.add("s5");
-    measurementList.add(v2);
-    measurementList.add(Collections.singletonList("s6"));
+    for (int i = 1; i <= 6; i++) {
+      measurementList.add(Collections.singletonList("s" + i));
+    }
 
     List<List<TSDataType>> dataTypesList = new ArrayList<>();
-    List<TSDataType> d1 = new ArrayList<>();
-    d1.add(TSDataType.DOUBLE);
-    d1.add(TSDataType.FLOAT);
-    d1.add(TSDataType.INT64);
-    dataTypesList.add(d1);
-    List<TSDataType> d2 = new ArrayList<>();
-    d2.add(TSDataType.INT32);
-    d2.add(TSDataType.BOOLEAN);
-    dataTypesList.add(d2);
+    dataTypesList.add(Collections.singletonList(TSDataType.DOUBLE));
+    dataTypesList.add(Collections.singletonList(TSDataType.FLOAT));
+    dataTypesList.add(Collections.singletonList(TSDataType.INT64));
+    dataTypesList.add(Collections.singletonList(TSDataType.INT32));
+    dataTypesList.add(Collections.singletonList(TSDataType.BOOLEAN));
     dataTypesList.add(Collections.singletonList(TSDataType.TEXT));
 
     List<List<TSEncoding>> encodingList = new ArrayList<>();
-    List<TSEncoding> e1 = new ArrayList<>();
-    e1.add(TSEncoding.PLAIN);
-    e1.add(TSEncoding.PLAIN);
-    e1.add(TSEncoding.PLAIN);
-    encodingList.add(e1);
-    List<TSEncoding> e2 = new ArrayList<>();
-    e2.add(TSEncoding.PLAIN);
-    e2.add(TSEncoding.PLAIN);
-    encodingList.add(e2);
-    encodingList.add(Collections.singletonList(TSEncoding.PLAIN));
+    for (int i = 1; i <= 6; i++) {
+      encodingList.add(Collections.singletonList(TSEncoding.PLAIN));
+    }
 
     List<CompressionType> compressionTypes = new ArrayList<>();
-    for (int i = 0; i < 3; i++) {
+    for (int i = 1; i <= 6; i++) {
       compressionTypes.add(CompressionType.SNAPPY);
     }
 
     List<String> schemaNames = new ArrayList<>();
-    schemaNames.add("vector");
-    schemaNames.add("vector2");
-    schemaNames.add("s6");
+    for (int i = 1; i <= 6; i++) {
+      schemaNames.add("s" + i);
+    }
 
     CreateTemplatePlan plan =
         new CreateTemplatePlan(
@@ -195,18 +152,17 @@ public class InsertRowPlanTest {
 
     IoTDBDescriptor.getInstance().getConfig().setAutoCreateSchemaEnabled(false);
 
-    InsertRowPlan rowPlan = getInsertAlignedRowPlan();
+    InsertRowPlan rowPlan = getInsertRowPlan();
 
     PlanExecutor executor = new PlanExecutor();
     executor.insert(rowPlan);
 
-    QueryPlan queryPlan =
-        (QueryPlan) processor.parseSQLToPhysicalPlan("select * from root.isp.d1.vector");
+    QueryPlan queryPlan = (QueryPlan) processor.parseSQLToPhysicalPlan("select * from root.isp.d1");
     QueryDataSet dataSet = executor.processQuery(queryPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-    Assert.assertEquals(1, dataSet.getPaths().size());
+    Assert.assertEquals(6, dataSet.getPaths().size());
     while (dataSet.hasNext()) {
       RowRecord record = dataSet.next();
-      Assert.assertEquals(3, record.getFields().size());
+      Assert.assertEquals(6, record.getFields().size());
     }
   }
 
@@ -230,6 +186,34 @@ public class InsertRowPlanTest {
     Assert.assertEquals(plan1, plan2);
   }
 
+  private InsertRowPlan getInsertRowPlan() throws IllegalPathException {
+    long time = 110L;
+    TSDataType[] dataTypes =
+        new TSDataType[] {
+          TSDataType.DOUBLE,
+          TSDataType.FLOAT,
+          TSDataType.INT64,
+          TSDataType.INT32,
+          TSDataType.BOOLEAN,
+          TSDataType.TEXT
+        };
+
+    String[] columns = new String[6];
+    columns[0] = 1.0 + "";
+    columns[1] = 2 + "";
+    columns[2] = 10000 + "";
+    columns[3] = 100 + "";
+    columns[4] = false + "";
+    columns[5] = "hh" + 0;
+
+    return new InsertRowPlan(
+        new PartialPath("root.isp.d1"),
+        time,
+        new String[] {"s1", "s2", "s3", "s4", "s5", "s6"},
+        dataTypes,
+        columns);
+  }
+
   private InsertRowPlan getInsertAlignedRowPlan() throws IllegalPathException {
     long time = 110L;
     TSDataType[] dataTypes =
diff --git a/server/src/test/java/org/apache/iotdb/db/qp/physical/InsertTabletPlanTest.java b/server/src/test/java/org/apache/iotdb/db/qp/physical/InsertTabletPlanTest.java
index c32976e..262d712 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/physical/InsertTabletPlanTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/physical/InsertTabletPlanTest.java
@@ -262,7 +262,7 @@ public class InsertTabletPlanTest {
 
     queryPlan = (QueryPlan) processor.parseSQLToPhysicalPlan("select ** from root.isp");
     dataSet = executor.processQuery(queryPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-    Assert.assertEquals(3, dataSet.getPaths().size());
+    Assert.assertEquals(6, dataSet.getPaths().size());
     while (dataSet.hasNext()) {
       RowRecord record = dataSet.next();
       Assert.assertEquals(6, record.getFields().size());
@@ -271,50 +271,32 @@ public class InsertTabletPlanTest {
 
   private CreateTemplatePlan getCreateTemplatePlan() {
     List<List<String>> measurementList = new ArrayList<>();
-    List<String> v1 = new ArrayList<>();
-    v1.add("s1");
-    v1.add("s2");
-    v1.add("s3");
-    measurementList.add(v1);
-    List<String> v2 = new ArrayList<>();
-    v2.add("s4");
-    v2.add("s5");
-    measurementList.add(v2);
-    measurementList.add(Collections.singletonList("s6"));
+    for (int i = 1; i <= 6; i++) {
+      measurementList.add(Collections.singletonList("s" + i));
+    }
 
     List<List<TSDataType>> dataTypesList = new ArrayList<>();
-    List<TSDataType> d1 = new ArrayList<>();
-    d1.add(TSDataType.DOUBLE);
-    d1.add(TSDataType.FLOAT);
-    d1.add(TSDataType.INT64);
-    dataTypesList.add(d1);
-    List<TSDataType> d2 = new ArrayList<>();
-    d2.add(TSDataType.INT32);
-    d2.add(TSDataType.BOOLEAN);
-    dataTypesList.add(d2);
+    dataTypesList.add(Collections.singletonList(TSDataType.DOUBLE));
+    dataTypesList.add(Collections.singletonList(TSDataType.FLOAT));
+    dataTypesList.add(Collections.singletonList(TSDataType.INT64));
+    dataTypesList.add(Collections.singletonList(TSDataType.INT32));
+    dataTypesList.add(Collections.singletonList(TSDataType.BOOLEAN));
     dataTypesList.add(Collections.singletonList(TSDataType.TEXT));
 
     List<List<TSEncoding>> encodingList = new ArrayList<>();
-    List<TSEncoding> e1 = new ArrayList<>();
-    e1.add(TSEncoding.PLAIN);
-    e1.add(TSEncoding.PLAIN);
-    e1.add(TSEncoding.PLAIN);
-    encodingList.add(e1);
-    List<TSEncoding> e2 = new ArrayList<>();
-    e2.add(TSEncoding.PLAIN);
-    e2.add(TSEncoding.PLAIN);
-    encodingList.add(e2);
-    encodingList.add(Collections.singletonList(TSEncoding.PLAIN));
+    for (int i = 1; i <= 6; i++) {
+      encodingList.add(Collections.singletonList(TSEncoding.PLAIN));
+    }
 
     List<CompressionType> compressionTypes = new ArrayList<>();
-    for (int i = 0; i < 3; i++) {
+    for (int i = 0; i < 6; i++) {
       compressionTypes.add(CompressionType.SNAPPY);
     }
 
     List<String> schemaNames = new ArrayList<>();
-    schemaNames.add("vector");
-    schemaNames.add("vector2");
-    schemaNames.add("s6");
+    for (int i = 1; i <= 6; i++) {
+      schemaNames.add("s" + i);
+    }
 
     return new CreateTemplatePlan(
         "template1", schemaNames, measurementList, dataTypesList, encodingList, compressionTypes);
@@ -336,7 +318,7 @@ public class InsertTabletPlanTest {
     QueryPlan queryPlan =
         (QueryPlan) processor.parseSQLToPhysicalPlan("select ** from root.isp.d1");
     QueryDataSet dataSet = executor.processQuery(queryPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-    Assert.assertEquals(3, dataSet.getPaths().size());
+    Assert.assertEquals(6, dataSet.getPaths().size());
     while (dataSet.hasNext()) {
       RowRecord record = dataSet.next();
       Assert.assertEquals(6, record.getFields().size());
@@ -356,7 +338,7 @@ public class InsertTabletPlanTest {
 
     queryPlan = (QueryPlan) processor.parseSQLToPhysicalPlan("select ** from root.isp.d1");
     dataSet = executor.processQuery(queryPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-    Assert.assertEquals(3, dataSet.getPaths().size());
+    Assert.assertEquals(6, dataSet.getPaths().size());
     while (dataSet.hasNext()) {
       RowRecord record = dataSet.next();
       Assert.assertEquals(6, record.getFields().size());