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/05/21 10:32:57 UTC

[iotdb] branch GroupByBug12 created (now 189fe66)

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

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


      at 189fe66  format code

This branch includes the following new commits:

     new 693b50c  Fix group by bug
     new 08c8c0f  add some comments
     new 189fe66  format code

The 3 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] 03/03: format code

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

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

commit 189fe66d9aa84f848527436cd2cfe83621c8deb3
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Fri May 21 18:32:21 2021 +0800

    format code
---
 .../iotdb/db/integration/IoTDBGroupByUnseqIT.java  | 96 +++++++++++-----------
 1 file changed, 48 insertions(+), 48 deletions(-)

diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java
index 746b004..c8c69b3 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java
@@ -18,72 +18,72 @@
  */
 package org.apache.iotdb.db.integration;
 
-import static org.apache.iotdb.db.constant.TestConstant.count;
-import static org.junit.Assert.fail;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.Statement;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.apache.iotdb.jdbc.Config;
 import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
+
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import static org.apache.iotdb.db.constant.TestConstant.count;
+import static org.junit.Assert.fail;
+
 /**
- * This test contains one seq file and one unseq file.
- * In the seq file, it contains two pages: 1,2,3,4 in one page, 8,10,11,12 in another page.
- * In the unseq file, it only contains one page: 7, 9.
- * The unseq page is overlapped with the second seq page.
+ * This test contains one seq file and one unseq file. In the seq file, it contains two pages:
+ * 1,2,3,4 in one page, 8,10,11,12 in another page. In the unseq file, it only contains one page: 7,
+ * 9. The unseq page is overlapped with the second seq page.
  */
 public class IoTDBGroupByUnseqIT {
 
-  private static String[] dataSet1 = new String[]{
-      "SET STORAGE GROUP TO root.sg1",
-      "CREATE TIMESERIES root.sg1.d1.s1 WITH DATATYPE=INT32, ENCODING=PLAIN",
-      "INSERT INTO root.sg1.d1(time,s1) values(1, 1)",
-      "INSERT INTO root.sg1.d1(time,s1) values(2, 2)",
-      "INSERT INTO root.sg1.d1(time,s1) values(3, 3)",
-      "INSERT INTO root.sg1.d1(time,s1) values(4, 4)",
-      "INSERT INTO root.sg1.d1(time,s1) values(8, 8)",
-      "INSERT INTO root.sg1.d1(time,s1) values(10, 10)",
-      "INSERT INTO root.sg1.d1(time,s1) values(11, 11)",
-      "INSERT INTO root.sg1.d1(time,s1) values(12, 12)",
-      "flush",
-      "INSERT INTO root.sg1.d1(time,s1) values(7, 7)",
-      "INSERT INTO root.sg1.d1(time,s1) values(9, 9)",
-      "flush"
-  };
+  private static String[] dataSet1 =
+      new String[] {
+        "SET STORAGE GROUP TO root.sg1",
+        "CREATE TIMESERIES root.sg1.d1.s1 WITH DATATYPE=INT32, ENCODING=PLAIN",
+        "INSERT INTO root.sg1.d1(time,s1) values(1, 1)",
+        "INSERT INTO root.sg1.d1(time,s1) values(2, 2)",
+        "INSERT INTO root.sg1.d1(time,s1) values(3, 3)",
+        "INSERT INTO root.sg1.d1(time,s1) values(4, 4)",
+        "INSERT INTO root.sg1.d1(time,s1) values(8, 8)",
+        "INSERT INTO root.sg1.d1(time,s1) values(10, 10)",
+        "INSERT INTO root.sg1.d1(time,s1) values(11, 11)",
+        "INSERT INTO root.sg1.d1(time,s1) values(12, 12)",
+        "flush",
+        "INSERT INTO root.sg1.d1(time,s1) values(7, 7)",
+        "INSERT INTO root.sg1.d1(time,s1) values(9, 9)",
+        "flush"
+      };
 
   private static final String TIMESTAMP_STR = "Time";
 
   private boolean enableUnseqCompaction;
   private int maxNumberOfPointsInPage;
 
-
   @Before
   public void setUp() throws Exception {
     EnvironmentUtils.closeStatMonitor();
     enableUnseqCompaction = IoTDBDescriptor.getInstance().getConfig().isEnableUnseqCompaction();
     IoTDBDescriptor.getInstance().getConfig().setEnableUnseqCompaction(false);
-    maxNumberOfPointsInPage = TSFileDescriptor.getInstance().getConfig()
-        .getMaxNumberOfPointsInPage();
+    maxNumberOfPointsInPage =
+        TSFileDescriptor.getInstance().getConfig().getMaxNumberOfPointsInPage();
     TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(4);
     EnvironmentUtils.envSetUp();
     Class.forName(Config.JDBC_DRIVER_NAME);
     prepareData();
   }
 
-
   private void prepareData() {
-    try (Connection connection = DriverManager
-        .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
-            "root");
-        Statement statement = connection.createStatement();) {
+    try (Connection connection =
+            DriverManager.getConnection(
+                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+        Statement statement = connection.createStatement(); ) {
 
       for (String sql : dataSet1) {
         statement.execute(sql);
@@ -103,26 +103,26 @@ public class IoTDBGroupByUnseqIT {
 
   @Test
   public void test1() {
-    String[] retArray1 = new String[]{
-        "1,3",
-        "4,1",
-        "7,3",
-        "10,3",
-    };
-
-    try (Connection connection = DriverManager.
-        getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
+    String[] retArray1 =
+        new String[] {
+          "1,3", "4,1", "7,3", "10,3",
+        };
+
+    try (Connection connection =
+            DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
         Statement statement = connection.createStatement()) {
-      boolean hasResultSet = statement.execute(
-          "select count(s1) from root.sg1.d1 group by ([1, 13), 3ms)");
+      boolean hasResultSet =
+          statement.execute("select count(s1) from root.sg1.d1 group by ([1, 13), 3ms)");
 
       Assert.assertTrue(hasResultSet);
       int cnt;
       try (ResultSet resultSet = statement.getResultSet()) {
         cnt = 0;
         while (resultSet.next()) {
-          String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
-              .getString(count("root.sg1.d1.s1"));
+          String ans =
+              resultSet.getString(TIMESTAMP_STR)
+                  + ","
+                  + resultSet.getString(count("root.sg1.d1.s1"));
           Assert.assertEquals(retArray1[cnt], ans);
           cnt++;
         }

[iotdb] 02/03: add some comments

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

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

commit 08c8c0f7016715b45d8e8f0bf392813adec7348b
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Fri May 21 16:19:20 2021 +0800

    add some comments
---
 .../java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java   | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java
index a00c27e..746b004 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java
@@ -34,6 +34,12 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+/**
+ * This test contains one seq file and one unseq file.
+ * In the seq file, it contains two pages: 1,2,3,4 in one page, 8,10,11,12 in another page.
+ * In the unseq file, it only contains one page: 7, 9.
+ * The unseq page is overlapped with the second seq page.
+ */
 public class IoTDBGroupByUnseqIT {
 
   private static String[] dataSet1 = new String[]{

[iotdb] 01/03: Fix group by bug

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

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

commit 693b50c0a68a14a740f99709df775db2659e1dd4
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Thu May 20 19:06:48 2021 +0800

    Fix group by bug
---
 .../dataset/groupby/LocalGroupByExecutor.java      |   3 +
 .../iotdb/db/integration/IoTDBGroupByUnseqIT.java  | 130 +++++++++++++++++++++
 2 files changed, 133 insertions(+)

diff --git a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor.java b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor.java
index 3a4200d..b8cec3d 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor.java
@@ -331,6 +331,9 @@ public class LocalGroupByExecutor implements GroupByExecutor {
       // stop calc and cached current batchData
       if (ascending && batchData.currentTime() >= curEndTime) {
         preCachedData = batchData;
+        // reset the last position to current Index
+        lastReadCurArrayIndex = batchData.getReadCurArrayIndex();
+        lastReadCurListIndex = batchData.getReadCurListIndex();
         return true;
       }
 
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java
new file mode 100644
index 0000000..a00c27e
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByUnseqIT.java
@@ -0,0 +1,130 @@
+/*
+ * 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.integration;
+
+import static org.apache.iotdb.db.constant.TestConstant.count;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.jdbc.Config;
+import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class IoTDBGroupByUnseqIT {
+
+  private static String[] dataSet1 = new String[]{
+      "SET STORAGE GROUP TO root.sg1",
+      "CREATE TIMESERIES root.sg1.d1.s1 WITH DATATYPE=INT32, ENCODING=PLAIN",
+      "INSERT INTO root.sg1.d1(time,s1) values(1, 1)",
+      "INSERT INTO root.sg1.d1(time,s1) values(2, 2)",
+      "INSERT INTO root.sg1.d1(time,s1) values(3, 3)",
+      "INSERT INTO root.sg1.d1(time,s1) values(4, 4)",
+      "INSERT INTO root.sg1.d1(time,s1) values(8, 8)",
+      "INSERT INTO root.sg1.d1(time,s1) values(10, 10)",
+      "INSERT INTO root.sg1.d1(time,s1) values(11, 11)",
+      "INSERT INTO root.sg1.d1(time,s1) values(12, 12)",
+      "flush",
+      "INSERT INTO root.sg1.d1(time,s1) values(7, 7)",
+      "INSERT INTO root.sg1.d1(time,s1) values(9, 9)",
+      "flush"
+  };
+
+  private static final String TIMESTAMP_STR = "Time";
+
+  private boolean enableUnseqCompaction;
+  private int maxNumberOfPointsInPage;
+
+
+  @Before
+  public void setUp() throws Exception {
+    EnvironmentUtils.closeStatMonitor();
+    enableUnseqCompaction = IoTDBDescriptor.getInstance().getConfig().isEnableUnseqCompaction();
+    IoTDBDescriptor.getInstance().getConfig().setEnableUnseqCompaction(false);
+    maxNumberOfPointsInPage = TSFileDescriptor.getInstance().getConfig()
+        .getMaxNumberOfPointsInPage();
+    TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(4);
+    EnvironmentUtils.envSetUp();
+    Class.forName(Config.JDBC_DRIVER_NAME);
+    prepareData();
+  }
+
+
+  private void prepareData() {
+    try (Connection connection = DriverManager
+        .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
+            "root");
+        Statement statement = connection.createStatement();) {
+
+      for (String sql : dataSet1) {
+        statement.execute(sql);
+      }
+
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    EnvironmentUtils.cleanEnv();
+    IoTDBDescriptor.getInstance().getConfig().setEnableUnseqCompaction(enableUnseqCompaction);
+    TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(maxNumberOfPointsInPage);
+  }
+
+  @Test
+  public void test1() {
+    String[] retArray1 = new String[]{
+        "1,3",
+        "4,1",
+        "7,3",
+        "10,3",
+    };
+
+    try (Connection connection = DriverManager.
+        getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
+        Statement statement = connection.createStatement()) {
+      boolean hasResultSet = statement.execute(
+          "select count(s1) from root.sg1.d1 group by ([1, 13), 3ms)");
+
+      Assert.assertTrue(hasResultSet);
+      int cnt;
+      try (ResultSet resultSet = statement.getResultSet()) {
+        cnt = 0;
+        while (resultSet.next()) {
+          String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
+              .getString(count("root.sg1.d1.s1"));
+          Assert.assertEquals(retArray1[cnt], ans);
+          cnt++;
+        }
+        Assert.assertEquals(retArray1.length, cnt);
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+  }
+}