SteveYurongSu commented on a change in pull request #2500:
URL: https://github.com/apache/iotdb/pull/2500#discussion_r559378791



##########
File path: 
server/src/test/java/org/apache/iotdb/db/integration/IoTDBSimpleQueryIT.java
##########
@@ -210,6 +213,57 @@ public void testSDTEncodingCompDev() throws 
ClassNotFoundException {
     }
   }
 
+  @Test
+  public void testSDTEncodingSelectFill() throws ClassNotFoundException {
+    Class.forName(Config.JDBC_DRIVER_NAME);
+
+    try (Connection connection = DriverManager
+        .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/",
+            "root", "root");
+        Statement statement = connection.createStatement()) {
+      statement.setFetchSize(5);
+      statement.execute("SET STORAGE GROUP TO root.sg1");
+      double compDev = 2;
+      //test set sdt property
+      statement
+          .execute(
+              "CREATE TIMESERIES root.sg1.d0.s0 WITH 
DATATYPE=INT32,ENCODING=PLAIN,LOSS=SDT,COMPDEV=" + compDev);
+
+      int[] originalValues = new int[1000];
+
+      Map<String, Integer> map = new HashMap<>();
+
+      Random rand = new Random();
+      for (int i = 1; i < originalValues.length; i++) {
+        originalValues[i] = rand.nextInt(500);
+        String sql = "insert into root.sg1.d0(timestamp,s0) values(" + i + "," 
+ originalValues[i] + ")";
+        statement.execute(sql);
+        map.put(i + "", originalValues[i]);
+      }
+      statement.execute("flush");
+
+      for (int i = 1; i < originalValues.length; i++) {
+        String sql = "select * from root where time = " + i
+            + " fill(int32 [linear, 20ms, 20ms])";
+        ResultSet resultSet = statement.executeQuery(sql);
+
+        while (resultSet.next()) {
+          String time = resultSet.getString("Time");
+          String value = resultSet.getString("root.sg1.d0.s0");
+          //last value is not stored, cannot linear fill
+          if (value == null) {
+            continue;
+          }
+          // sdt parallelogram's height is 2 * compDev, so after linear fill, 
the values will fall inside
+          // the parallelogram of two stored points
+          assertTrue(Math.abs(Integer.parseInt(value) - map.get(time)) <= 2 * 
compDev);
+        }
+      }
+    } catch (SQLException e) {
+      e.printStackTrace();

Review comment:
       ```suggestion
         fail();
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to