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 2021/02/15 03:17:36 UTC

[iotdb] branch spotless updated (c5a9382 -> 8e20570)

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

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


    from c5a9382  hide coverall token; only run coverall and sonar on apache/iotdb; allow manually run github action;
     new 2c0529a  IOTDB-1152 optimize regular data size in traversing
     new 8e20570  Apply spotless and Resolve your conflict

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:
 .../level/LevelCompactionTsFileManagement.java     | 43 ++--------------------
 .../engine/compaction/utils/CompactionUtils.java   | 42 +++++++--------------
 .../engine/storagegroup/StorageGroupProcessor.java |  6 +--
 .../org/apache/iotdb/db/service/MQTTService.java   |  4 +-
 .../db/engine/compaction/CompactionChunkTest.java  |  6 +--
 .../compaction/LevelCompactionRecoverTest.java     | 15 +++-----
 .../iotdb/tsfile/common/conf/TSFileDescriptor.java |  2 +-
 .../encoding/encoder/RegularDataEncoder.java       |  8 +++-
 .../regular/RegularDataEncoderIntegerTest.java     | 13 +++++++
 .../regular/RegularDataEncoderLongTest.java        | 13 +++++++
 10 files changed, 59 insertions(+), 93 deletions(-)


[iotdb] 02/02: Apply spotless and Resolve your conflict

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

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

commit 8e205708c59e81cdb19e1848e3fd2b575c9e5047
Author: sunjincheng121 <su...@gmail.com>
AuthorDate: Mon Feb 15 11:10:16 2021 +0800

    Apply spotless and Resolve your conflict
---
 .../level/LevelCompactionTsFileManagement.java     | 43 ++--------------------
 .../engine/compaction/utils/CompactionUtils.java   | 42 +++++++--------------
 .../engine/storagegroup/StorageGroupProcessor.java |  6 +--
 .../org/apache/iotdb/db/service/MQTTService.java   |  4 +-
 .../db/engine/compaction/CompactionChunkTest.java  |  6 +--
 .../compaction/LevelCompactionRecoverTest.java     | 15 +++-----
 .../iotdb/tsfile/common/conf/TSFileDescriptor.java |  2 +-
 .../regular/RegularDataEncoderIntegerTest.java     |  2 +-
 .../regular/RegularDataEncoderLongTest.java        |  2 +-
 9 files changed, 29 insertions(+), 93 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/compaction/level/LevelCompactionTsFileManagement.java b/server/src/main/java/org/apache/iotdb/db/engine/compaction/level/LevelCompactionTsFileManagement.java
index cfb2064..5af3788 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/compaction/level/LevelCompactionTsFileManagement.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/compaction/level/LevelCompactionTsFileManagement.java
@@ -46,8 +46,6 @@ import org.apache.iotdb.db.engine.compaction.TsFileManagement;
 import org.apache.iotdb.db.engine.compaction.utils.CompactionLogAnalyzer;
 import org.apache.iotdb.db.engine.compaction.utils.CompactionLogger;
 import org.apache.iotdb.db.engine.compaction.utils.CompactionUtils;
-import org.apache.iotdb.db.engine.modification.Modification;
-import org.apache.iotdb.db.engine.modification.ModificationFile;
 import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
 import org.apache.iotdb.db.exception.metadata.IllegalPathException;
 import org.apache.iotdb.db.query.control.FileReaderManager;
@@ -92,33 +90,6 @@ public class LevelCompactionTsFileManagement extends TsFileManagement {
     clear();
   }
 
-  public void renameLevelFilesMods(
-      Collection<Modification> filterModification,
-      Collection<TsFileResource> mergeTsFiles,
-      TsFileResource targetTsFile)
-      throws IOException {
-    logger.debug("{} [compaction] merge starts to rename real file's mod", storageGroupName);
-    List<Modification> modifications = new ArrayList<>();
-    for (TsFileResource mergeTsFile : mergeTsFiles) {
-      try (ModificationFile sourceModificationFile =
-          new ModificationFile(mergeTsFile.getTsFilePath() + ModificationFile.FILE_SUFFIX)) {
-        modifications.addAll(sourceModificationFile.getModifications());
-        if (sourceModificationFile.exists()) {
-          sourceModificationFile.remove();
-        }
-      }
-    }
-    modifications.removeAll(filterModification);
-    if (!modifications.isEmpty()) {
-      try (ModificationFile modificationFile =
-          new ModificationFile(targetTsFile.getTsFilePath() + ModificationFile.FILE_SUFFIX)) {
-        for (Modification modification : modifications) {
-          modificationFile.write(modification);
-        }
-      }
-    }
-  }
-
   private void deleteLevelFilesInDisk(Collection<TsFileResource> mergeTsFiles) {
     logger.debug("{} [compaction] merge starts to delete real file", storageGroupName);
     for (TsFileResource mergeTsFile : mergeTsFiles) {
@@ -409,15 +380,13 @@ public class LevelCompactionTsFileManagement extends TsFileManagement {
             writer.close();
             CompactionLogger compactionLogger =
                 new CompactionLogger(storageGroupDir, storageGroupName);
-            List<Modification> modifications = new ArrayList<>();
             CompactionUtils.merge(
                 targetTsFileResource,
                 getTsFileList(isSeq),
                 storageGroupName,
                 compactionLogger,
                 deviceSet,
-                isSeq,
-                modifications);
+                isSeq);
             compactionLogger.close();
           } else {
             writer.close();
@@ -443,15 +412,13 @@ public class LevelCompactionTsFileManagement extends TsFileManagement {
             writer.close();
             CompactionLogger compactionLogger =
                 new CompactionLogger(storageGroupDir, storageGroupName);
-            List<Modification> modifications = new ArrayList<>();
             CompactionUtils.merge(
                 targetResource,
                 sourceTsFileResources,
                 storageGroupName,
                 compactionLogger,
                 deviceSet,
-                isSeq,
-                modifications);
+                isSeq);
             // complete compaction and delete source file
             writeLock();
             try {
@@ -468,7 +435,6 @@ public class LevelCompactionTsFileManagement extends TsFileManagement {
               writeUnlock();
             }
             deleteLevelFilesInDisk(sourceTsFileResources);
-            renameLevelFilesMods(modifications, sourceTsFileResources, targetResource);
             compactionLogger.close();
           } else {
             writer.close();
@@ -619,7 +585,6 @@ public class LevelCompactionTsFileManagement extends TsFileManagement {
             }
 
             TsFileResource newResource = new TsFileResource(newLevelFile);
-            List<Modification> modifications = new ArrayList<>();
             // merge, read from source files and write to target file
             CompactionUtils.merge(
                 newResource,
@@ -627,8 +592,7 @@ public class LevelCompactionTsFileManagement extends TsFileManagement {
                 storageGroupName,
                 compactionLogger,
                 new HashSet<>(),
-                sequence,
-                modifications);
+                sequence);
             logger.info(
                 "{} [Compaction] merged level-{}'s {} TsFiles to next level, and start to delete old files",
                 storageGroupName,
@@ -649,7 +613,6 @@ public class LevelCompactionTsFileManagement extends TsFileManagement {
               writeUnlock();
             }
             deleteLevelFilesInDisk(toMergeTsFiles);
-            renameLevelFilesMods(modifications, toMergeTsFiles, newResource);
             compactionLogger.close();
             File logFile =
                 FSFactoryProducer.getFSFactory()
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/compaction/utils/CompactionUtils.java b/server/src/main/java/org/apache/iotdb/db/engine/compaction/utils/CompactionUtils.java
index 6aec3fb..e7d7e7d 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/compaction/utils/CompactionUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/compaction/utils/CompactionUtils.java
@@ -71,8 +71,7 @@ public class CompactionUtils {
   private static Pair<ChunkMetadata, Chunk> readByAppendMerge(
       Map<TsFileSequenceReader, List<ChunkMetadata>> readerChunkMetadataMap,
       Map<String, List<Modification>> modificationCache,
-      PartialPath seriesPath,
-      List<Modification> modifications)
+      PartialPath seriesPath)
       throws IOException {
     ChunkMetadata newChunkMetadata = null;
     Chunk newChunk = null;
@@ -80,8 +79,7 @@ public class CompactionUtils {
         readerChunkMetadataMap.entrySet()) {
       TsFileSequenceReader reader = entry.getKey();
       List<ChunkMetadata> chunkMetadataList = entry.getValue();
-      modifyChunkMetaDataWithCache(
-          reader, chunkMetadataList, modificationCache, seriesPath, modifications);
+      modifyChunkMetaDataWithCache(reader, chunkMetadataList, modificationCache, seriesPath);
       for (ChunkMetadata chunkMetadata : chunkMetadataList) {
         Chunk chunk = reader.readMemChunk(chunkMetadata);
         if (newChunkMetadata == null) {
@@ -101,15 +99,13 @@ public class CompactionUtils {
       long maxVersion,
       Map<Long, TimeValuePair> timeValuePairMap,
       Map<String, List<Modification>> modificationCache,
-      PartialPath seriesPath,
-      List<Modification> modifications)
+      PartialPath seriesPath)
       throws IOException {
     for (Entry<TsFileSequenceReader, List<ChunkMetadata>> entry :
         readerChunkMetadataMap.entrySet()) {
       TsFileSequenceReader reader = entry.getKey();
       List<ChunkMetadata> chunkMetadataList = entry.getValue();
-      modifyChunkMetaDataWithCache(
-          reader, chunkMetadataList, modificationCache, seriesPath, modifications);
+      modifyChunkMetaDataWithCache(reader, chunkMetadataList, modificationCache, seriesPath);
       for (ChunkMetadata chunkMetadata : chunkMetadataList) {
         maxVersion = Math.max(chunkMetadata.getVersion(), maxVersion);
         IChunkReader chunkReader = new ChunkReaderByTimestamp(reader.readMemChunk(chunkMetadata));
@@ -132,15 +128,11 @@ public class CompactionUtils {
       Entry<String, Map<TsFileSequenceReader, List<ChunkMetadata>>> entry,
       TsFileResource targetResource,
       RestorableTsFileIOWriter writer,
-      Map<String, List<Modification>> modificationCache,
-      List<Modification> modifications)
+      Map<String, List<Modification>> modificationCache)
       throws IOException, IllegalPathException {
     Pair<ChunkMetadata, Chunk> chunkPair =
         readByAppendMerge(
-            entry.getValue(),
-            modificationCache,
-            new PartialPath(device, entry.getKey()),
-            modifications);
+            entry.getValue(), modificationCache, new PartialPath(device, entry.getKey()));
     ChunkMetadata newChunkMetadata = chunkPair.left;
     Chunk newChunk = chunkPair.right;
     if (newChunkMetadata != null && newChunk != null) {
@@ -163,8 +155,7 @@ public class CompactionUtils {
       Entry<String, Map<TsFileSequenceReader, List<ChunkMetadata>>> entry,
       TsFileResource targetResource,
       RestorableTsFileIOWriter writer,
-      Map<String, List<Modification>> modificationCache,
-      List<Modification> modifications)
+      Map<String, List<Modification>> modificationCache)
       throws IOException, IllegalPathException {
     Map<Long, TimeValuePair> timeValuePairMap = new TreeMap<>();
     Map<TsFileSequenceReader, List<ChunkMetadata>> readerChunkMetadataMap = entry.getValue();
@@ -174,8 +165,7 @@ public class CompactionUtils {
             maxVersion,
             timeValuePairMap,
             modificationCache,
-            new PartialPath(device, entry.getKey()),
-            modifications);
+            new PartialPath(device, entry.getKey()));
     boolean isChunkMetadataEmpty = true;
     for (List<ChunkMetadata> chunkMetadataList : readerChunkMetadataMap.values()) {
       if (!chunkMetadataList.isEmpty()) {
@@ -238,8 +228,7 @@ public class CompactionUtils {
       String storageGroup,
       CompactionLogger compactionLogger,
       Set<String> devices,
-      boolean sequence,
-      List<Modification> modifications)
+      boolean sequence)
       throws IOException, IllegalPathException {
     RestorableTsFileIOWriter writer = new RestorableTsFileIOWriter(targetResource.getTsFile());
     Map<String, TsFileSequenceReader> tsFileSequenceReaderMap = new HashMap<>();
@@ -297,8 +286,7 @@ public class CompactionUtils {
                   entry,
                   targetResource,
                   writer,
-                  modificationCache,
-                  modifications);
+                  modificationCache);
         }
         writer.endChunkGroup();
       } else {
@@ -326,8 +314,7 @@ public class CompactionUtils {
                     entry,
                     targetResource,
                     writer,
-                    modificationCache,
-                    modifications);
+                    modificationCache);
           } else {
             logger.debug("{} [Compaction] page too small, use deserialize merge", storageGroup);
             // we have to deserialize chunks to merge pages
@@ -339,8 +326,7 @@ public class CompactionUtils {
                     entry,
                     targetResource,
                     writer,
-                    modificationCache,
-                    modifications);
+                    modificationCache);
           }
         }
         writer.endChunkGroup();
@@ -390,8 +376,7 @@ public class CompactionUtils {
       TsFileSequenceReader reader,
       List<ChunkMetadata> chunkMetadataList,
       Map<String, List<Modification>> modificationCache,
-      PartialPath seriesPath,
-      List<Modification> usedModifications) {
+      PartialPath seriesPath) {
     List<Modification> modifications =
         modificationCache.computeIfAbsent(
             reader.getFileName(),
@@ -403,7 +388,6 @@ public class CompactionUtils {
     for (Modification modification : modifications) {
       if (modification.getPath().matchFullPath(seriesPath)) {
         seriesModifications.add(modification);
-        usedModifications.add(modification);
       }
     }
     modifyChunkMetaData(chunkMetadataList, seriesModifications);
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index 816f0f1..494bc58 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -517,8 +517,7 @@ public class StorageGroupProcessor {
         logger.error(
             "{} - {} compaction submit task failed",
             logicalStorageGroupName,
-            virtualStorageGroupId,
-            e);
+            virtualStorageGroupId);
       }
     } else {
       logger.error(
@@ -1955,8 +1954,7 @@ public class StorageGroupProcessor {
         this.closeCompactionMergeCallBack();
         logger.error(
             "{} compaction submit task failed",
-            logicalStorageGroupName + "-" + virtualStorageGroupId,
-            e);
+            logicalStorageGroupName + "-" + virtualStorageGroupId);
       }
     } else {
       logger.info(
diff --git a/server/src/main/java/org/apache/iotdb/db/service/MQTTService.java b/server/src/main/java/org/apache/iotdb/db/service/MQTTService.java
index 3a80919..d33b78a 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/MQTTService.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/MQTTService.java
@@ -40,8 +40,6 @@ public class MQTTService implements IService {
   private static final Logger LOG = LoggerFactory.getLogger(MQTTService.class);
   private Server server = new Server();
 
-  private MQTTService() {}
-
   @Override
   public void start() throws StartupException {
     startup();
@@ -101,7 +99,7 @@ public class MQTTService implements IService {
     return ServiceType.MQTT_SERVICE;
   }
 
-  public static MQTTService getInstance() {
+  public static final MQTTService getInstance() {
     return MQTTServiceHolder.INSTANCE;
   }
 
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/compaction/CompactionChunkTest.java b/server/src/test/java/org/apache/iotdb/db/engine/compaction/CompactionChunkTest.java
index 0f21455..c245d3d 100644
--- a/server/src/test/java/org/apache/iotdb/db/engine/compaction/CompactionChunkTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/engine/compaction/CompactionChunkTest.java
@@ -123,8 +123,7 @@ public class CompactionChunkTest extends LevelCompactionTest {
             entry,
             targetTsfileResource,
             writer,
-            new HashMap<>(),
-            new ArrayList<>());
+            new HashMap<>());
       }
       reader.close();
     }
@@ -207,8 +206,7 @@ public class CompactionChunkTest extends LevelCompactionTest {
             entry,
             targetTsfileResource,
             writer,
-            new HashMap<>(),
-            new ArrayList<>());
+            new HashMap<>());
       }
       reader.close();
     }
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/compaction/LevelCompactionRecoverTest.java b/server/src/test/java/org/apache/iotdb/db/engine/compaction/LevelCompactionRecoverTest.java
index fe48f24..eafdb7b 100644
--- a/server/src/test/java/org/apache/iotdb/db/engine/compaction/LevelCompactionRecoverTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/engine/compaction/LevelCompactionRecoverTest.java
@@ -132,8 +132,7 @@ public class LevelCompactionRecoverTest extends LevelCompactionTest {
         COMPACTION_TEST_SG,
         compactionLogger,
         new HashSet<>(),
-        true,
-        new ArrayList<>());
+        true);
     compactionLogger.close();
     levelCompactionTsFileManagement.addRecover(targetTsFileResource, true);
     levelCompactionTsFileManagement.recover();
@@ -221,8 +220,7 @@ public class LevelCompactionRecoverTest extends LevelCompactionTest {
         COMPACTION_TEST_SG,
         compactionLogger,
         new HashSet<>(),
-        true,
-        new ArrayList<>());
+        true);
     compactionLogger.close();
 
     BufferedReader logReader =
@@ -334,8 +332,7 @@ public class LevelCompactionRecoverTest extends LevelCompactionTest {
         COMPACTION_TEST_SG,
         compactionLogger,
         new HashSet<>(),
-        true,
-        new ArrayList<>());
+        true);
     compactionLogger.close();
 
     BufferedReader logReader =
@@ -453,8 +450,7 @@ public class LevelCompactionRecoverTest extends LevelCompactionTest {
         COMPACTION_TEST_SG,
         compactionLogger,
         new HashSet<>(),
-        false,
-        new ArrayList<>());
+        false);
     compactionLogger.close();
     levelCompactionTsFileManagement.addRecover(targetTsFileResource, false);
     levelCompactionTsFileManagement.recover();
@@ -655,8 +651,7 @@ public class LevelCompactionRecoverTest extends LevelCompactionTest {
         COMPACTION_TEST_SG,
         compactionLogger,
         new HashSet<>(),
-        true,
-        new ArrayList<>());
+        true);
     levelCompactionTsFileManagement.addRecover(targetTsFileResource, true);
     compactionLogger.close();
     levelCompactionTsFileManagement.recover();
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java
index 4654e98..c335c88 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java
@@ -42,7 +42,7 @@ public class TSFileDescriptor {
     loadProps();
   }
 
-  public static TSFileDescriptor getInstance() {
+  public static final TSFileDescriptor getInstance() {
     return TsfileDescriptorHolder.INSTANCE;
   }
 
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderIntegerTest.java b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderIntegerTest.java
index 8baf651..8b091ab 100644
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderIntegerTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderIntegerTest.java
@@ -104,7 +104,7 @@ public class RegularDataEncoderIntegerTest {
     byte[] page = out.toByteArray();
     buffer = ByteBuffer.wrap(page);
     int i = 0;
-    while(regularDataDecoder.hasNext(buffer)) {
+    while (regularDataDecoder.hasNext(buffer)) {
       assertEquals(originalData[i++], regularDataDecoder.readInt(buffer));
     }
   }
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java
index 34efa48..5e7748b 100644
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java
@@ -145,7 +145,7 @@ public class RegularDataEncoderLongTest {
     byte[] page = out.toByteArray();
     buffer = ByteBuffer.wrap(page);
     int i = 0;
-    while(regularDataDecoder.hasNext(buffer)) {
+    while (regularDataDecoder.hasNext(buffer)) {
       assertEquals(originalData[i++], regularDataDecoder.readLong(buffer));
     }
   }


[iotdb] 01/02: IOTDB-1152 optimize regular data size in traversing

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

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

commit 2c0529ac9b6e25ed52391d449284f61817a86546
Author: wangchao316 <57...@qq.com>
AuthorDate: Tue Feb 9 22:04:18 2021 +0800

    IOTDB-1152 optimize regular data size in traversing
---
 .../iotdb/tsfile/encoding/encoder/RegularDataEncoder.java   |  8 ++++++--
 .../decoder/regular/RegularDataEncoderIntegerTest.java      | 13 +++++++++++++
 .../decoder/regular/RegularDataEncoderLongTest.java         | 13 +++++++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RegularDataEncoder.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RegularDataEncoder.java
index 492e8eb..19502a8 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RegularDataEncoder.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RegularDataEncoder.java
@@ -49,6 +49,8 @@ public abstract class RegularDataEncoder extends Encoder {
 
   protected int writeIndex = -1;
 
+  protected int dataTotal;
+
   /**
    * constructor of RegularDataEncoder.
    *
@@ -183,6 +185,7 @@ public abstract class RegularDataEncoder extends Encoder {
       }
       firstValue = data[0];
       if (isMissingPoint) {
+        dataTotal = writeIndex;
         newBlockSize = ((data[writeIndex - 1] - data[0]) / minDeltaBase) + 1;
         writeIndex = newBlockSize;
       }
@@ -218,7 +221,7 @@ public abstract class RegularDataEncoder extends Encoder {
       bitmap = new BitSet(newBlockSize);
       bitmap.flip(0, newBlockSize);
       int offset = 0;
-      for (int i = 1; i < missingPointData.length; i++) {
+      for (int i = 1; i < dataTotal; i++) {
         int delta = missingPointData[i] - missingPointData[i - 1];
         if (delta != minDeltaBase) {
           int missingPointNum = (int) (delta / minDeltaBase) - 1;
@@ -309,6 +312,7 @@ public abstract class RegularDataEncoder extends Encoder {
       }
       firstValue = data[0];
       if (isMissingPoint) {
+        dataTotal = writeIndex;
         newBlockSize = (int) (((data[writeIndex - 1] - data[0]) / minDeltaBase) + 1);
         writeIndex = newBlockSize;
       }
@@ -344,7 +348,7 @@ public abstract class RegularDataEncoder extends Encoder {
       bitmap = new BitSet(newBlockSize);
       bitmap.flip(0, newBlockSize);
       int offset = 0;
-      for (int i = 1; i < missingPointData.length; i++) {
+      for (int i = 1; i < dataTotal; i++) {
         long delta = missingPointData[i] - missingPointData[i - 1];
         if (delta != minDeltaBase) {
           int missingPointNum = (int) (delta / minDeltaBase) - 1;
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderIntegerTest.java b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderIntegerTest.java
index be08915..8baf651 100644
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderIntegerTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderIntegerTest.java
@@ -96,6 +96,19 @@ public class RegularDataEncoderIntegerTest {
     shouldReadAndWrite(data, ROW_NUM);
   }
 
+  @Test
+  public void testMissingPointsDataSize() throws IOException {
+    int[] originalData = new int[] {1000, 1100, 1200, 1300, 1500, 2000};
+    out = new ByteArrayOutputStream();
+    writeData(originalData, 6);
+    byte[] page = out.toByteArray();
+    buffer = ByteBuffer.wrap(page);
+    int i = 0;
+    while(regularDataDecoder.hasNext(buffer)) {
+      assertEquals(originalData[i++], regularDataDecoder.readInt(buffer));
+    }
+  }
+
   private int[] getMissingPointData(int dataSize, int missingPointInterval) {
     ROW_NUM = dataSize;
 
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java
index aaec9a3..34efa48 100644
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java
@@ -137,6 +137,19 @@ public class RegularDataEncoderLongTest {
     shouldReadAndWrite(data, ROW_NUM);
   }
 
+  @Test
+  public void testMissingPointsDataSize() throws IOException {
+    long[] originalData = new long[] {1000, 1100, 1200, 1300, 1500, 2000};
+    out = new ByteArrayOutputStream();
+    writeData(originalData, 6);
+    byte[] page = out.toByteArray();
+    buffer = ByteBuffer.wrap(page);
+    int i = 0;
+    while(regularDataDecoder.hasNext(buffer)) {
+      assertEquals(originalData[i++], regularDataDecoder.readLong(buffer));
+    }
+  }
+
   private long[] getMissingPointData(List<String> originalData, int missingPointInterval) {
     List<String> dates = originalData;