You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2019/01/21 02:34:16 UTC

[incubator-iotdb] branch delete_dev3 updated: add some test

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

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


The following commit(s) were added to refs/heads/delete_dev3 by this push:
     new 7e19ded  add some test
7e19ded is described below

commit 7e19ded59fd83a8b2f997ebf9b9f08a2d4000fb5
Author: 江天 <jt...@163.com>
AuthorDate: Mon Jan 21 10:33:33 2019 +0800

    add some test
---
 .../iotdb/db/qp/strategy/PhysicalGenerator.java    |  47 +++--
 .../db/engine/modification/DeletionQueryTest.java  | 222 +++++++++++++++++++++
 .../iotdb/db/integration/IoTDBCompleteTest.java    |   1 +
 .../iotdb/db/integration/IoTDBDeletionTest.java    | 202 +++++++++++++++++++
 .../read/reader/chunk/ChunkReaderByTimestamp.java  |   2 +-
 .../reader/series/SeriesReaderByTimestamp.java     |   1 -
 6 files changed, 451 insertions(+), 24 deletions(-)

diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
index b201989..630b787 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
@@ -1,6 +1,6 @@
 /**
  * Copyright © 2019 Apache IoTDB(incubating) (dev@iotdb.apache.org)
- *
+ * <p>
  * 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
@@ -8,9 +8,9 @@
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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.
@@ -20,6 +20,7 @@
 package org.apache.iotdb.db.qp.strategy;
 
 import java.util.List;
+
 import org.apache.iotdb.db.auth.AuthException;
 import org.apache.iotdb.db.exception.ProcessorException;
 import org.apache.iotdb.db.exception.qp.LogicalOperatorException;
@@ -27,6 +28,7 @@ import org.apache.iotdb.db.exception.qp.QueryProcessorException;
 import org.apache.iotdb.db.qp.executor.QueryProcessExecutor;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.logical.crud.BasicFunctionOperator;
+import org.apache.iotdb.db.qp.logical.crud.DeleteOperator;
 import org.apache.iotdb.db.qp.logical.crud.FilterOperator;
 import org.apache.iotdb.db.qp.logical.crud.InsertOperator;
 import org.apache.iotdb.db.qp.logical.crud.QueryOperator;
@@ -36,6 +38,7 @@ import org.apache.iotdb.db.qp.logical.sys.MetadataOperator;
 import org.apache.iotdb.db.qp.logical.sys.PropertyOperator;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.db.qp.physical.crud.AggregationPlan;
+import org.apache.iotdb.db.qp.physical.crud.DeletePlan;
 import org.apache.iotdb.db.qp.physical.crud.FillQueryPlan;
 import org.apache.iotdb.db.qp.physical.crud.GroupByPlan;
 import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
@@ -62,15 +65,15 @@ public class PhysicalGenerator {
   }
 
   public PhysicalPlan transformToPhysicalPlan(Operator operator)
-      throws QueryProcessorException, ProcessorException {
+          throws QueryProcessorException, ProcessorException {
     List<Path> paths;
     switch (operator.getType()) {
       case AUTHOR:
         AuthorOperator author = (AuthorOperator) operator;
         try {
           return new AuthorPlan(author.getAuthorType(), author.getUserName(), author.getRoleName(),
-              author.getPassWord(), author.getNewPassword(), author.getPrivilegeList(),
-              author.getNodeName());
+                  author.getPassWord(), author.getNewPassword(), author.getPrivilegeList(),
+                  author.getNodeName());
         } catch (AuthException e) {
           throw new QueryProcessorException(e.getMessage());
         }
@@ -82,32 +85,32 @@ public class PhysicalGenerator {
       case METADATA:
         MetadataOperator metadata = (MetadataOperator) operator;
         return new MetadataPlan(metadata.getNamespaceType(), metadata.getPath(),
-            metadata.getDataType(),
-            metadata.getEncoding(), metadata.getEncodingArgs(), metadata.getDeletePathList());
+                metadata.getDataType(),
+                metadata.getEncoding(), metadata.getEncodingArgs(), metadata.getDeletePathList());
       case PROPERTY:
         PropertyOperator property = (PropertyOperator) operator;
         return new PropertyPlan(property.getPropertyType(), property.getPropertyPath(),
-            property.getMetadataPath());
-      // case DELETE:
-      // DeleteOperator delete = (DeleteOperator) operator;
-      // paths = delete.getSelectedPaths();
-      // if (delete.getTime() <= 0) {
-      // throw new LogicalOperatorException("For Delete command, time must greater than 0.");
-      // }
-      // return new DeletePlan(delete.getTime(), paths);
+                property.getMetadataPath());
+      case DELETE:
+        DeleteOperator delete = (DeleteOperator) operator;
+        paths = delete.getSelectedPaths();
+        if (delete.getTime() <= 0) {
+          throw new LogicalOperatorException("For Delete command, time must greater than 0.");
+        }
+        return new DeletePlan(delete.getTime(), paths);
       case INSERT:
         InsertOperator Insert = (InsertOperator) operator;
         paths = Insert.getSelectedPaths();
         if (paths.size() != 1) {
           throw new LogicalOperatorException(
-              "For Insert command, cannot specified more than one seriesPath:" + paths);
+                  "For Insert command, cannot specified more than one seriesPath:" + paths);
         }
         if (Insert.getTime() <= 0) {
           throw new LogicalOperatorException("For Insert command, time must greater than 0.");
         }
         return new InsertPlan(paths.get(0).getFullPath(), Insert.getTime(),
-            Insert.getMeasurementList(),
-            Insert.getValueList());
+                Insert.getMeasurementList(),
+                Insert.getValueList());
       // case UPDATE:
       // UpdateOperator update = (UpdateOperator) operator;
       // UpdatePlan updatePlan = new UpdatePlan();
@@ -231,7 +234,7 @@ public class PhysicalGenerator {
   // }
 
   private PhysicalPlan transformQuery(QueryOperator queryOperator)
-      throws QueryProcessorException, ProcessorException {
+          throws QueryProcessorException, ProcessorException {
 
     QueryPlan queryPlan;
 
@@ -252,7 +255,7 @@ public class PhysicalGenerator {
     } else if (queryOperator.hasAggregation()) { // ordinary query
       queryPlan = new AggregationPlan();
       ((AggregationPlan) queryPlan)
-          .setAggregations(queryOperator.getSelectOperator().getAggregations());
+              .setAggregations(queryOperator.getSelectOperator().getAggregations());
     } else {
       queryPlan = new QueryPlan();
     }
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/modification/DeletionQueryTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/modification/DeletionQueryTest.java
new file mode 100644
index 0000000..0efa2d7
--- /dev/null
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/modification/DeletionQueryTest.java
@@ -0,0 +1,222 @@
+/**
+ * Copyright © 2019 Apache IoTDB(incubating) (dev@iotdb.apache.org)
+ * <p>
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.engine.modification;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.iotdb.db.engine.filenode.FileNodeManager;
+import org.apache.iotdb.db.exception.FileNodeManagerException;
+import org.apache.iotdb.db.exception.MetadataArgsErrorException;
+import org.apache.iotdb.db.exception.PathErrorException;
+import org.apache.iotdb.db.metadata.MManager;
+import org.apache.iotdb.db.query.executor.EngineQueryRouter;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.tsfile.read.common.Path;
+import org.apache.iotdb.tsfile.read.expression.QueryExpression;
+import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
+import org.apache.iotdb.tsfile.write.record.TSRecord;
+import org.apache.iotdb.tsfile.write.record.datapoint.DoubleDataPoint;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class DeletionQueryTest {
+  private String processorName = "root.test";
+
+  private static String[] measurements = new String[10];
+  private String dataType = TSDataType.DOUBLE.toString();
+  private String encoding = TSEncoding.PLAIN.toString();
+  private String[] args = new String[0];
+  private EngineQueryRouter router = new EngineQueryRouter();
+
+  static {
+    for (int i = 0; i < 10; i++) {
+      measurements[i] = "m" + i;
+    }
+  }
+
+  @Before
+  public void setup() throws MetadataArgsErrorException,
+          PathErrorException, IOException, FileNodeManagerException {
+    MManager.getInstance().setStorageLevelToMTree(processorName);
+    for (int i = 0; i < 10; i++) {
+      MManager.getInstance().addPathToMTree(processorName + "." + measurements[i], dataType,
+              encoding, args);
+      FileNodeManager.getInstance().addTimeSeries(new Path(processorName, measurements[i]), dataType,
+              encoding, args);
+    }
+  }
+
+  @After
+  public void teardown() throws IOException, FileNodeManagerException {
+    EnvironmentUtils.cleanEnv();
+  }
+
+  @Test
+  public void testDeleteInBufferWriteCache() throws
+          FileNodeManagerException, IOException {
+
+    for (int i = 1; i <= 100; i++) {
+      TSRecord record = new TSRecord(i, processorName);
+      for (int j = 0; j < 10; j++) {
+        record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
+      }
+      FileNodeManager.getInstance().insert(record, false);
+    }
+
+    FileNodeManager.getInstance().delete(processorName, measurements[3], 50);
+    FileNodeManager.getInstance().delete(processorName, measurements[4], 50);
+    FileNodeManager.getInstance().delete(processorName, measurements[5], 30);
+    FileNodeManager.getInstance().delete(processorName, measurements[5], 50);
+
+    List<Path> pathList = new ArrayList<>();
+    pathList.add(new Path(processorName, measurements[3]));
+    pathList.add(new Path(processorName, measurements[4]));
+    pathList.add(new Path(processorName, measurements[5]));
+
+    QueryExpression queryExpression = QueryExpression.create(pathList, null);
+    QueryDataSet dataSet = router.query(queryExpression);
+
+    int count = 0;
+    while (dataSet.hasNext()) {
+      dataSet.next();
+      count++;
+    }
+    assertEquals(count, 50);
+  }
+
+  @Test
+  public void testDeleteInBufferWriteFile() throws FileNodeManagerException, IOException {
+    for (int i = 1; i <= 100; i++) {
+      TSRecord record = new TSRecord(i, processorName);
+      for (int j = 0; j < 10; j++) {
+        record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
+      }
+      FileNodeManager.getInstance().insert(record, false);
+    }
+    FileNodeManager.getInstance().closeAll();
+
+    FileNodeManager.getInstance().delete(processorName, measurements[5], 50);
+    FileNodeManager.getInstance().delete(processorName, measurements[4], 40);
+    FileNodeManager.getInstance().delete(processorName, measurements[3], 30);
+
+    List<Path> pathList = new ArrayList<>();
+    pathList.add(new Path(processorName, measurements[3]));
+    pathList.add(new Path(processorName, measurements[4]));
+    pathList.add(new Path(processorName, measurements[5]));
+
+    QueryExpression queryExpression = QueryExpression.create(pathList, null);
+    QueryDataSet dataSet = router.query(queryExpression);
+
+    int count = 0;
+    while (dataSet.hasNext()) {
+      dataSet.next();
+      count++;
+    }
+    assertEquals(count, 70);
+  }
+
+  @Test
+  public void testDeleteInOverflowCache() throws FileNodeManagerException, IOException {
+    // insert into BufferWrite
+    for (int i = 101; i <= 200; i++) {
+      TSRecord record = new TSRecord(i, processorName);
+      for (int j = 0; j < 10; j++) {
+        record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
+      }
+      FileNodeManager.getInstance().insert(record, false);
+    }
+    FileNodeManager.getInstance().closeAll();
+
+    // insert into Overflow
+    for (int i = 1; i <= 100; i++) {
+      TSRecord record = new TSRecord(i, processorName);
+      for (int j = 0; j < 10; j++) {
+        record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
+      }
+      FileNodeManager.getInstance().insert(record, false);
+    }
+
+    FileNodeManager.getInstance().delete(processorName, measurements[3], 50);
+    FileNodeManager.getInstance().delete(processorName, measurements[4], 50);
+    FileNodeManager.getInstance().delete(processorName, measurements[5], 30);
+    FileNodeManager.getInstance().delete(processorName, measurements[5], 50);
+
+    List<Path> pathList = new ArrayList<>();
+    pathList.add(new Path(processorName, measurements[3]));
+    pathList.add(new Path(processorName, measurements[4]));
+    pathList.add(new Path(processorName, measurements[5]));
+
+    QueryExpression queryExpression = QueryExpression.create(pathList, null);
+    QueryDataSet dataSet = router.query(queryExpression);
+
+    int count = 0;
+    while (dataSet.hasNext()) {
+      dataSet.next();
+      count++;
+    }
+    assertEquals(count, 150);
+  }
+
+  @Test
+  public void testDeleteInOverflowFile() throws FileNodeManagerException, IOException {
+    // insert into BufferWrite
+    for (int i = 101; i <= 200; i++) {
+      TSRecord record = new TSRecord(i, processorName);
+      for (int j = 0; j < 10; j++) {
+        record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
+      }
+      FileNodeManager.getInstance().insert(record, false);
+    }
+    FileNodeManager.getInstance().closeAll();
+
+    // insert into Overflow
+    for (int i = 1; i <= 100; i++) {
+      TSRecord record = new TSRecord(i, processorName);
+      for (int j = 0; j < 10; j++) {
+        record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
+      }
+      FileNodeManager.getInstance().insert(record, false);
+    }
+    FileNodeManager.getInstance().closeAll();
+
+    FileNodeManager.getInstance().delete(processorName, measurements[5], 50);
+    FileNodeManager.getInstance().delete(processorName, measurements[4], 40);
+    FileNodeManager.getInstance().delete(processorName, measurements[3], 30);
+
+    List<Path> pathList = new ArrayList<>();
+    pathList.add(new Path(processorName, measurements[3]));
+    pathList.add(new Path(processorName, measurements[4]));
+    pathList.add(new Path(processorName, measurements[5]));
+
+    QueryExpression queryExpression = QueryExpression.create(pathList, null);
+    QueryDataSet dataSet = router.query(queryExpression);
+
+    int count = 0;
+    while (dataSet.hasNext()) {
+      dataSet.next();
+      count++;
+    }
+    assertEquals(count, 170);
+  }
+}
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBCompleteTest.java b/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBCompleteTest.java
index 0e19837..f687864 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBCompleteTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBCompleteTest.java
@@ -65,6 +65,7 @@ public class IoTDBCompleteTest {
     SimpleTest();
     InsertTest();
     SelectTest();
+    DeleteTest();
   }
 
   public void SimpleTest() throws ClassNotFoundException, SQLException {
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBDeletionTest.java b/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBDeletionTest.java
new file mode 100644
index 0000000..86cceaf
--- /dev/null
+++ b/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBDeletionTest.java
@@ -0,0 +1,202 @@
+/**
+ * Copyright © 2019 Apache IoTDB(incubating) (dev@iotdb.apache.org)
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.iotdb.db.service.IoTDB;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.jdbc.Config;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class IoTDBDeletionTest {
+  private static IoTDB deamon;
+
+  private static String[] creationSqls = new String[]{
+          "SET STORAGE GROUP TO root.vehicle.d0", "SET STORAGE GROUP TO root.vehicle.d1",
+
+          "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, ENCODING=RLE",
+          "CREATE TIMESERIES root.vehicle.d0.s1 WITH DATATYPE=INT64, ENCODING=RLE",
+          "CREATE TIMESERIES root.vehicle.d0.s2 WITH DATATYPE=FLOAT, ENCODING=RLE",
+          "CREATE TIMESERIES root.vehicle.d0.s3 WITH DATATYPE=TEXT, ENCODING=PLAIN",
+          "CREATE TIMESERIES root.vehicle.d0.s4 WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
+  };
+
+  private static String intertTemplate = "INSERT INTO root.vehicle.d0(timestamp,s0,s1,s2,s3,s4"
+          + ") VALUES(%d,%d,%d,%f,%s,%b)";
+  private static String deleteAllTemplate = "DELETE FROM root.vehicle.d0.* WHERE time <= 10000";
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    EnvironmentUtils.closeStatMonitor();
+    EnvironmentUtils.closeMemControl();
+    deamon = IoTDB.getInstance();
+    deamon.active();
+    EnvironmentUtils.envSetUp();
+    Class.forName(Config.JDBC_DRIVER_NAME);
+    prepareSeries();
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    deamon.stop();
+    Thread.sleep(5000);
+
+    EnvironmentUtils.cleanEnv();
+  }
+
+  @Before
+  public void prepare() throws SQLException {
+    prepareData();
+  }
+
+  @After
+  public void cleanup() throws SQLException {
+    cleanData();
+  }
+
+  @Test
+  public void test() throws SQLException {
+    Connection connection = null;
+    try {
+      connection = DriverManager
+              .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
+                      "root");
+      Statement statement = connection.createStatement();
+      statement.execute("DELETE FROM root.vehicle.d0.s0  WHERE time <= 300");
+      statement.execute("DELETE FROM root.vehicle.d0.s1,root.vehicle.d0.s2,root.vehicle.d0.s3"
+              + " WHERE time <= 350");
+      statement.execute("DELETE FROM root.vehicle.d0.* WHERE time <= 150");
+
+      ResultSet set = statement.executeQuery("SELECT * FROM root.vehicle.d0");
+      int cnt = 0;
+      while (set.next()) {
+        cnt ++;
+      }
+      assertEquals(250, cnt);
+
+      set = statement.executeQuery("SELECT s0 FROM root.vehicle.d0");
+      cnt = 0;
+      while (set.next()) {
+        cnt ++;
+      }
+      assertEquals(100, cnt);
+
+      set = statement.executeQuery("SELECT s1,s2,s3 FROM root.vehicle.d0");
+      cnt = 0;
+      while (set.next()) {
+        cnt ++;
+      }
+      assertEquals(50, cnt);
+
+      statement.close();
+    } finally {
+      if (connection != null) {
+        connection.close();
+      }
+    }
+  }
+
+  public static void prepareSeries() throws SQLException {
+    Connection connection = null;
+    try {
+      connection = DriverManager
+              .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
+                      "root");
+      Statement statement = connection.createStatement();
+      for (String sql : creationSqls) {
+        statement.execute(sql);
+      }
+      statement.close();
+    } catch (Exception e) {
+      e.printStackTrace();
+    } finally {
+      if (connection != null) {
+        connection.close();
+      }
+    }
+  }
+
+  public void prepareData() throws SQLException {
+    Connection connection = null;
+    try {
+      connection = DriverManager
+              .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
+                      "root");
+      Statement statement = connection.createStatement();
+      // prepare BufferWrite file
+      for (int i = 201; i <= 300; i++) {
+        statement.execute(String.format(intertTemplate, i, i, i, (double) i, "\'" + i + "\'",
+                i % 2 == 0));
+      }
+      statement.execute("merge");
+      // prepare Overflow file
+      for (int i = 1; i <= 100; i++) {
+        statement.execute(String.format(intertTemplate, i, i, i, (double) i, "\'" + i + "\'",
+                i % 2 == 0));
+      }
+      statement.execute("merge");
+      // prepare BufferWrite cache
+      for (int i = 301; i <= 400; i++) {
+        statement.execute(String.format(intertTemplate, i, i, i, (double) i, "\'" + i + "\'",
+                i % 2 == 0));
+      }
+      // prepare Overflow cache
+      for (int i = 101; i <= 200; i++) {
+        statement.execute(String.format(intertTemplate, i, i, i, (double) i, "\'" + i + "\'",
+                i % 2 == 0));
+      }
+
+      statement.close();
+    } finally {
+      if (connection != null) {
+        connection.close();
+      }
+    }
+  }
+
+  public void cleanData() throws SQLException {
+    Connection connection = null;
+    try {
+      connection = DriverManager
+              .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
+                      "root");
+      Statement statement = connection.createStatement();
+      statement.execute(deleteAllTemplate);
+
+      statement.close();
+    } finally {
+      if (connection != null) {
+        connection.close();
+      }
+    }
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/chunk/ChunkReaderByTimestamp.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/chunk/ChunkReaderByTimestamp.java
index c69cb4b..02618f6 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/chunk/ChunkReaderByTimestamp.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/chunk/ChunkReaderByTimestamp.java
@@ -34,7 +34,7 @@ public class ChunkReaderByTimestamp extends ChunkReader {
   public boolean pageSatisfied(PageHeader pageHeader) {
     long maxTimestamp = pageHeader.getMax_timestamp();
     // if maxTimestamp > currentTimestamp, this page should NOT be skipped
-    return maxTimestamp >= currentTimestamp && maxTimestamp >= getMaxTombstoneTime();
+    return maxTimestamp >= currentTimestamp && maxTimestamp > deletedAt;
   }
 
   public void setCurrentTimestamp(long currentTimestamp) {
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/SeriesReaderByTimestamp.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/SeriesReaderByTimestamp.java
index 26503bf..f8911ff 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/SeriesReaderByTimestamp.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/SeriesReaderByTimestamp.java
@@ -118,7 +118,6 @@ public class SeriesReaderByTimestamp {
   private void initChunkReader(ChunkMetaData chunkMetaData) throws IOException {
     Chunk chunk = chunkLoader.getChunk(chunkMetaData);
     this.chunkReader = new ChunkReaderByTimestamp(chunk);
-    this.chunkReader.setMaxTombstoneTime(chunkMetaData.getMaxTombstoneTime());
   }
 
   private boolean chunkSatisfied(ChunkMetaData chunkMetaData) {