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 2020/04/14 03:14:23 UTC

[incubator-iotdb] branch tyPageBug updated (0bae14c -> 3246312)

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

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


    from 0bae14c  add value filter
     new 631af2d  add IT
     new 3246312  modify IT and code

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:
 .../iotdb/db/query/reader/series/SeriesReader.java |   8 +-
 .../db/integration/IoTDBOverlappedPageIT.java      | 131 +++++++++++++++++++++
 2 files changed, 137 insertions(+), 2 deletions(-)
 create mode 100644 server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java


[incubator-iotdb] 02/02: modify IT and code

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

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

commit 3246312c02de4b0f2f90a8c0e74b81e4e6ea9d5a
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Tue Apr 14 11:14:09 2020 +0800

    modify IT and code
---
 .../iotdb/db/query/reader/series/SeriesReader.java |  8 +++++--
 .../db/integration/IoTDBOverlappedPageIT.java      | 25 +++-------------------
 2 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesReader.java b/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesReader.java
index 8ed9e86..5ee198c 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesReader.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesReader.java
@@ -274,7 +274,7 @@ class SeriesReader {
     if (hasCachedNextOverlappedPage) {
       return true;
     } else if (mergeReader.hasNextTimeValuePair()) {
-      while (hasNextOverlappedPage()) {
+      if (hasNextOverlappedPage()) {
         cachedBatchData = nextOverlappedPage();
         if (cachedBatchData != null && cachedBatchData.hasCurrent()) {
           hasCachedNextOverlappedPage = true;
@@ -311,7 +311,7 @@ class SeriesReader {
       /*
        * next page is overlapped, read overlapped data and cache it
        */
-      while (hasNextOverlappedPage()) {
+      if (hasNextOverlappedPage()) {
         cachedBatchData = nextOverlappedPage();
         if (cachedBatchData != null && cachedBatchData.hasCurrent()) {
           hasCachedNextOverlappedPage = true;
@@ -320,6 +320,10 @@ class SeriesReader {
       }
     }
 
+    // make sure firstPageReader won't be null while cachedPageReaders has more cached page readers
+    if (firstPageReader == null && !cachedPageReaders.isEmpty()) {
+      firstPageReader = cachedPageReaders.poll();
+    }
     return firstPageReader != null;
   }
 
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java
index 238855e..d6c3593 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java
@@ -68,16 +68,7 @@ public class IoTDBOverlappedPageIT {
 
   @Test
   public void selectOverlappedPageTest() {
-    String[] res = {"1,101",
-            "2,102",
-            "3,103",
-            "4,104",
-            "5,105",
-            "6,106",
-            "7,107",
-            "8,108",
-            "9,109",
-            "10,110",
+    String[] res = {
             "11,111",
             "12,112",
             "13,113",
@@ -88,22 +79,12 @@ public class IoTDBOverlappedPageIT {
             "18,118",
             "19,119",
             "20,120",
-            "100,100",
-            "101,101",
-            "102,102",
-            "103,103",
-            "104,104",
-            "105,105",
-            "106,106",
-            "107,107",
-            "108,108",
-            "109,109",
-            "110,110"};
+    };
 
     try (Connection connection = DriverManager
             .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
          Statement statement = connection.createStatement()) {
-      String sql = "select s0 from root.vehicle.d0 where time >= 1 and time <= 110 AND root.vehicle.d0.s0 > 3";
+      String sql = "select s0 from root.vehicle.d0 where time >= 1 and time <= 110 AND root.vehicle.d0.s0 > 110";
       ResultSet resultSet = statement.executeQuery(sql);
       int cnt = 0;
       while (resultSet.next()) {


[incubator-iotdb] 01/02: add IT

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

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

commit 631af2d04b2cbfe925a9e20c073be929f232f931
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Tue Apr 14 10:44:16 2020 +0800

    add IT
---
 .../db/integration/IoTDBOverlappedPageIT.java      | 150 +++++++++++++++++++++
 1 file changed, 150 insertions(+)

diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java
new file mode 100644
index 0000000..238855e
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java
@@ -0,0 +1,150 @@
+/*
+ * 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 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.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+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.TIMESTAMP_STR;
+import static org.junit.Assert.fail;
+
+/**
+ * Notice that, all test begins with "IoTDB" is integration test. All test which will start the
+ * IoTDB server should be defined as integration test.
+ */
+public class IoTDBOverlappedPageIT {
+
+  private static int beforeMaxNumberOfPointsInPage;
+  private static long beforeMemtableSizeThreshold;
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    EnvironmentUtils.closeStatMonitor();
+    beforeMemtableSizeThreshold = IoTDBDescriptor.getInstance().getConfig().getMemtableSizeThreshold();
+    IoTDBDescriptor.getInstance().getConfig().setMemtableSizeThreshold(1024 * 16);
+    // max_number_of_points_in_page = 10
+    beforeMaxNumberOfPointsInPage = TSFileDescriptor.getInstance().getConfig().getMaxNumberOfPointsInPage();
+    TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(10);
+    EnvironmentUtils.envSetUp();
+    Class.forName(Config.JDBC_DRIVER_NAME);
+    insertData();
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    // recovery value
+    TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(beforeMaxNumberOfPointsInPage);
+    EnvironmentUtils.cleanEnv();
+    IoTDBDescriptor.getInstance().getConfig().setMemtableSizeThreshold(beforeMemtableSizeThreshold);
+  }
+
+  @Test
+  public void selectOverlappedPageTest() {
+    String[] res = {"1,101",
+            "2,102",
+            "3,103",
+            "4,104",
+            "5,105",
+            "6,106",
+            "7,107",
+            "8,108",
+            "9,109",
+            "10,110",
+            "11,111",
+            "12,112",
+            "13,113",
+            "14,114",
+            "15,115",
+            "16,116",
+            "17,117",
+            "18,118",
+            "19,119",
+            "20,120",
+            "100,100",
+            "101,101",
+            "102,102",
+            "103,103",
+            "104,104",
+            "105,105",
+            "106,106",
+            "107,107",
+            "108,108",
+            "109,109",
+            "110,110"};
+
+    try (Connection connection = DriverManager
+            .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+         Statement statement = connection.createStatement()) {
+      String sql = "select s0 from root.vehicle.d0 where time >= 1 and time <= 110 AND root.vehicle.d0.s0 > 3";
+      ResultSet resultSet = statement.executeQuery(sql);
+      int cnt = 0;
+      while (resultSet.next()) {
+        String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString("root.vehicle.d0.s0");
+        Assert.assertEquals(res[cnt], ans);
+        cnt++;
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+  }
+
+  private static void insertData() {
+    try (Connection connection = DriverManager
+            .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+         Statement statement = connection.createStatement()) {
+
+      statement.execute("CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, ENCODING=RLE");
+
+      for (long time = 1; time <= 10; time++) {
+        String sql = String
+                .format("insert into root.vehicle.d0(timestamp,s0) values(%s,%s)", time, time);
+        statement.execute(sql);
+      }
+      statement.execute("flush");
+      for (long time = 100; time <= 120; time++) {
+        String sql = String
+                .format("insert into root.vehicle.d0(timestamp,s0) values(%s,%s)", time, time);
+        statement.execute(sql);
+      }
+      statement.execute("flush");
+      for (long time = 1; time <= 20; time++) {
+        String sql = String
+                .format("insert into root.vehicle.d0(timestamp,s0) values(%s,%s)", time, time+100);
+        statement.execute(sql);
+      }
+      statement.execute("flush");
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+  }
+}