iotdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jackiet...@apache.org
Subject [iotdb] 04/07: fix conflicts
Date Fri, 12 Mar 2021 08:08:39 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit fe923645aa28737cac4979ee999e7d190a9992d1
Author: JackieTien97 <JackieTien@foxmail.com>
AuthorDate: Thu Mar 11 20:06:46 2021 +0800

    fix conflicts
---
 .../db/engine/cache/TimeSeriesMetadataCache.java   |  5 ++--
 .../iotdb/db/engine/merge/task/MergeFileTask.java  | 21 +++++++++--------
 .../iotdb/tsfile/file/metadata/IChunkMetadata.java |  4 ++++
 .../tsfile/file/metadata/TimeseriesMetadata.java   |  4 ++--
 .../tsfile/file/metadata/VectorChunkMetadata.java  |  6 +++++
 .../iotdb/tsfile/read/TsFileSequenceReader.java    | 27 +++++++++++++---------
 .../read/controller/MetadataQuerierByFileImpl.java | 23 +++++++++---------
 .../query/executor/ExecutorWithTimeGenerator.java  |  4 ++--
 .../tsfile/read/query/executor/TsFileExecutor.java |  4 ++--
 .../query/timegenerator/TsFileTimeGenerator.java   |  4 ++--
 .../tsfile/read/reader/page/TimePageReader.java    |  3 +--
 .../reader/series/AbstractFileSeriesReader.java    | 14 +++++------
 .../read/reader/series/EmptyFileSeriesReader.java  |  6 ++---
 .../read/reader/series/FileSeriesReader.java       |  9 ++++----
 .../reader/series/FileSeriesReaderByTimestamp.java | 13 ++++++-----
 .../tsfile/v2/read/TsFileSequenceReaderForV2.java  | 23 +++++++++---------
 .../write/writer/RestorableTsFileIOWriter.java     |  9 ++++----
 .../iotdb/tsfile/write/writer/TsFileIOWriter.java  | 17 +++++++-------
 .../query/timegenerator/ReaderByTimestampTest.java |  4 ++--
 19 files changed, 110 insertions(+), 90 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
b/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
index d6ad1f4..6a286c5 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.query.control.FileReaderManager;
 import org.apache.iotdb.db.utils.TestOnly;
 import org.apache.iotdb.tsfile.common.cache.Accountable;
+import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
 import org.apache.iotdb.tsfile.file.metadata.TimeseriesMetadata;
 import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
 import org.apache.iotdb.tsfile.read.common.Path;
@@ -90,7 +91,7 @@ public class TimeSeriesMetadataCache {
                       + RamUsageEstimator.shallowSizeOf(value)
                       + RamUsageEstimator.sizeOf(value.getMeasurementId())
                       + RamUsageEstimator.shallowSizeOf(value.getStatistics())
-                      + (value.getChunkMetadataList().get(0).calculateRamSize()
+                      + (((ChunkMetadata) value.getChunkMetadataList().get(0)).calculateRamSize()
                               + RamUsageEstimator.NUM_BYTES_OBJECT_REF)
                           * value.getChunkMetadataList().size()
                       + RamUsageEstimator.shallowSizeOf(value.getChunkMetadataList());
@@ -106,7 +107,7 @@ public class TimeSeriesMetadataCache {
                       + RamUsageEstimator.shallowSizeOf(value)
                       + RamUsageEstimator.sizeOf(value.getMeasurementId())
                       + RamUsageEstimator.shallowSizeOf(value.getStatistics())
-                      + (value.getChunkMetadataList().get(0).calculateRamSize()
+                      + (((ChunkMetadata) value.getChunkMetadataList().get(0)).calculateRamSize()
                               + RamUsageEstimator.NUM_BYTES_OBJECT_REF)
                           * value.getChunkMetadataList().size()
                       + RamUsageEstimator.shallowSizeOf(value.getChunkMetadataList());
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/merge/task/MergeFileTask.java
b/server/src/main/java/org/apache/iotdb/db/engine/merge/task/MergeFileTask.java
index 0b209de..1f60fa1 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/merge/task/MergeFileTask.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/merge/task/MergeFileTask.java
@@ -30,6 +30,7 @@ import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.query.control.FileReaderManager;
 import org.apache.iotdb.tsfile.exception.write.TsFileNotCompleteException;
 import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.fileSystem.FSFactoryProducer;
 import org.apache.iotdb.tsfile.fileSystem.fsFactory.FSFactory;
 import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
@@ -173,16 +174,16 @@ class MergeFileTask {
       newFileWriter.close();
       try (TsFileSequenceReader newFileReader =
           new TsFileSequenceReader(newFileWriter.getFile().getPath())) {
-        Map<String, List<ChunkMetadata>> chunkMetadataListInChunkGroups =
+        Map<String, List<IChunkMetadata>> chunkMetadataListInChunkGroups =
             newFileWriter.getDeviceChunkMetadataMap();
         if (logger.isDebugEnabled()) {
           logger.debug(
               "{} find {} merged chunk groups", taskName, chunkMetadataListInChunkGroups.size());
         }
-        for (Map.Entry<String, List<ChunkMetadata>> entry :
+        for (Map.Entry<String, List<IChunkMetadata>> entry :
             chunkMetadataListInChunkGroups.entrySet()) {
           String deviceId = entry.getKey();
-          List<ChunkMetadata> chunkMetadataList = entry.getValue();
+          List<IChunkMetadata> chunkMetadataList = entry.getValue();
           writeMergedChunkGroup(chunkMetadataList, deviceId, newFileReader, oldFileWriter);
 
           if (Thread.interrupted()) {
@@ -210,10 +211,10 @@ class MergeFileTask {
 
   private void updateStartTimeAndEndTime(TsFileResource seqFile, TsFileIOWriter fileWriter)
{
     // TODO change to get one timeseries block each time
-    for (Entry<String, List<ChunkMetadata>> deviceChunkMetadataEntry :
+    for (Entry<String, List<IChunkMetadata>> deviceChunkMetadataEntry :
         fileWriter.getDeviceChunkMetadataMap().entrySet()) {
       String device = deviceChunkMetadataEntry.getKey();
-      for (ChunkMetadata chunkMetadata : deviceChunkMetadataEntry.getValue()) {
+      for (IChunkMetadata chunkMetadata : deviceChunkMetadataEntry.getValue()) {
         seqFile.updateStartTime(device, chunkMetadata.getStartTime());
         seqFile.updateEndTime(device, chunkMetadata.getEndTime());
       }
@@ -263,16 +264,16 @@ class MergeFileTask {
   }
 
   private void writeMergedChunkGroup(
-      List<ChunkMetadata> chunkMetadataList,
+      List<IChunkMetadata> chunkMetadataList,
       String device,
       TsFileSequenceReader reader,
       TsFileIOWriter fileWriter)
       throws IOException {
     fileWriter.startChunkGroup(device);
-    for (ChunkMetadata chunkMetaData : chunkMetadataList) {
-      Chunk chunk = reader.readMemChunk(chunkMetaData);
-      fileWriter.writeChunk(chunk, chunkMetaData);
-      context.incTotalPointWritten(chunkMetaData.getNumOfPoints());
+    for (IChunkMetadata chunkMetaData : chunkMetadataList) {
+      Chunk chunk = reader.readMemChunk((ChunkMetadata) chunkMetaData);
+      fileWriter.writeChunk(chunk, (ChunkMetadata) chunkMetaData);
+      context.incTotalPointWritten(((ChunkMetadata) chunkMetaData).getNumOfPoints());
     }
     fileWriter.endChunkGroup();
   }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/IChunkMetadata.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/IChunkMetadata.java
index 4e880e0..4dec6c7 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/IChunkMetadata.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/IChunkMetadata.java
@@ -23,6 +23,8 @@ import org.apache.iotdb.tsfile.file.metadata.statistics.Statistics;
 import org.apache.iotdb.tsfile.read.common.TimeRange;
 import org.apache.iotdb.tsfile.read.controller.IChunkLoader;
 
+import java.io.IOException;
+import java.io.OutputStream;
 import java.util.List;
 
 public interface IChunkMetadata {
@@ -64,4 +66,6 @@ public interface IChunkMetadata {
   void insertIntoSortedDeletions(long startTime, long endTime);
 
   List<TimeRange> getDeleteIntervalList();
+
+  int serializeTo(OutputStream outputStream, boolean serializeStatistic) throws IOException;
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/TimeseriesMetadata.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/TimeseriesMetadata.java
index 79f90fd..10efcb7 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/TimeseriesMetadata.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/TimeseriesMetadata.java
@@ -234,7 +234,7 @@ public class TimeseriesMetadata implements Accountable, ITimeSeriesMetadata
{
   }
 
   // For reading version-2 only
-  public void setChunkMetadataList(ArrayList<IChunkMetadata> chunkMetadataList) {
-    this.chunkMetadataList = chunkMetadataList;
+  public void setChunkMetadataList(ArrayList<ChunkMetadata> chunkMetadataList) {
+    this.chunkMetadataList = new ArrayList<>(chunkMetadataList);
   }
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/VectorChunkMetadata.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/VectorChunkMetadata.java
index 551938c..f44e3fb 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/VectorChunkMetadata.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/VectorChunkMetadata.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.tsfile.read.common.TimeRange;
 import org.apache.iotdb.tsfile.read.controller.IChunkLoader;
 
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -143,6 +144,11 @@ public class VectorChunkMetadata implements IChunkMetadata {
     return timeChunkMetadata.getDeleteIntervalList();
   }
 
+  @Override
+  public int serializeTo(OutputStream outputStream, boolean serializeStatistic) {
+    throw new UnsupportedOperationException("VectorChunkMetadata doesn't support serial method");
+  }
+
   public Chunk getTimeChunk() throws IOException {
     return timeChunkMetadata.getChunkLoader().loadChunk((ChunkMetadata) timeChunkMetadata);
   }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java
index ab3460d..85a8144 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java
@@ -540,17 +540,20 @@ public class TsFileSequenceReader implements AutoCloseable {
    * @return measurement -> ChunkMetadata list
    * @throws IOException io error
    */
-  public Map<String, List<IChunkMetadata>> readChunkMetadataInDevice(String device)
+  public Map<String, List<ChunkMetadata>> readChunkMetadataInDevice(String device)
       throws IOException {
     readFileMetadata();
     List<TimeseriesMetadata> timeseriesMetadataMap = getDeviceTimeseriesMetadata(device);
     if (timeseriesMetadataMap.isEmpty()) {
       return new HashMap<>();
     }
-    Map<String, List<IChunkMetadata>> seriesMetadata = new HashMap<>();
+    Map<String, List<ChunkMetadata>> seriesMetadata = new HashMap<>();
     for (TimeseriesMetadata timeseriesMetadata : timeseriesMetadataMap) {
       seriesMetadata.put(
-          timeseriesMetadata.getMeasurementId(), timeseriesMetadata.getChunkMetadataList());
+          timeseriesMetadata.getMeasurementId(),
+          timeseriesMetadata.getChunkMetadataList().stream()
+              .map(chunkMetadata -> ((ChunkMetadata) chunkMetadata))
+              .collect(Collectors.toList()));
     }
     return seriesMetadata;
   }
@@ -1145,12 +1148,12 @@ public class TsFileSequenceReader implements AutoCloseable {
    * @param path timeseries path
    * @return List of ChunkMetaData
    */
-  public List<IChunkMetadata> getChunkMetadataList(Path path) throws IOException {
+  public List<ChunkMetadata> getChunkMetadataList(Path path) throws IOException {
     TimeseriesMetadata timeseriesMetaData = readTimeseriesMetadata(path);
     if (timeseriesMetaData == null) {
       return Collections.emptyList();
     }
-    List<IChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetaData);
+    List<ChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetaData);
     chunkMetadataList.sort(Comparator.comparingLong(IChunkMetadata::getStartTime));
     return chunkMetadataList;
   }
@@ -1160,9 +1163,11 @@ public class TsFileSequenceReader implements AutoCloseable {
    *
    * @return List of ChunkMetaData
    */
-  public List<IChunkMetadata> readChunkMetaDataList(TimeseriesMetadata timeseriesMetaData)
+  public List<ChunkMetadata> readChunkMetaDataList(TimeseriesMetadata timeseriesMetaData)
       throws IOException {
-    return timeseriesMetaData.getChunkMetadataList();
+    return timeseriesMetaData.getChunkMetadataList().stream()
+        .map(chunkMetadata -> (ChunkMetadata) chunkMetadata)
+        .collect(Collectors.toList());
   }
 
   /**
@@ -1204,7 +1209,7 @@ public class TsFileSequenceReader implements AutoCloseable {
   public List<String> getDeviceNameInRange(long start, long end) throws IOException
{
     List<String> res = new ArrayList<>();
     for (String device : getAllDevices()) {
-      Map<String, List<IChunkMetadata>> seriesMetadataMap = readChunkMetadataInDevice(device);
+      Map<String, List<ChunkMetadata>> seriesMetadataMap = readChunkMetadataInDevice(device);
       if (hasDataInPartition(seriesMetadataMap, start, end)) {
         res.add(device);
       }
@@ -1220,9 +1225,9 @@ public class TsFileSequenceReader implements AutoCloseable {
    * @param end the end position of the space partition
    */
   private boolean hasDataInPartition(
-      Map<String, List<IChunkMetadata>> seriesMetadataMap, long start, long end)
{
-    for (List<IChunkMetadata> chunkMetadataList : seriesMetadataMap.values()) {
-      for (IChunkMetadata chunkMetadata : chunkMetadataList) {
+      Map<String, List<ChunkMetadata>> seriesMetadataMap, long start, long end)
{
+    for (List<ChunkMetadata> chunkMetadataList : seriesMetadataMap.values()) {
+      for (ChunkMetadata chunkMetadata : chunkMetadataList) {
         LocateStatus location =
             MetadataQuerierByFileImpl.checkLocateStatus(chunkMetadata, start, end);
         if (location == LocateStatus.in) {
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/controller/MetadataQuerierByFileImpl.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/controller/MetadataQuerierByFileImpl.java
index 3215eff..98d28b9 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/controller/MetadataQuerierByFileImpl.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/controller/MetadataQuerierByFileImpl.java
@@ -19,6 +19,7 @@
 package org.apache.iotdb.tsfile.read.controller;
 
 import org.apache.iotdb.tsfile.common.cache.LRUCache;
+import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
 import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.file.metadata.TimeseriesMetadata;
 import org.apache.iotdb.tsfile.file.metadata.TsFileMetadata;
@@ -47,7 +48,7 @@ public class MetadataQuerierByFileImpl implements IMetadataQuerier {
 
   private TsFileMetadata fileMetaData;
 
-  private LRUCache<Path, List<IChunkMetadata>> chunkMetaDataCache;
+  private LRUCache<Path, List<ChunkMetadata>> chunkMetaDataCache;
 
   private TsFileSequenceReader tsFileReader;
 
@@ -56,9 +57,9 @@ public class MetadataQuerierByFileImpl implements IMetadataQuerier {
     this.tsFileReader = tsFileReader;
     this.fileMetaData = tsFileReader.readFileMetadata();
     chunkMetaDataCache =
-        new LRUCache<Path, List<IChunkMetadata>>(CACHED_ENTRY_NUMBER) {
+        new LRUCache<Path, List<ChunkMetadata>>(CACHED_ENTRY_NUMBER) {
           @Override
-          public List<IChunkMetadata> loadObjectByKey(Path key) throws IOException
{
+          public List<ChunkMetadata> loadObjectByKey(Path key) throws IOException {
             return loadChunkMetadata(key);
           }
         };
@@ -66,7 +67,7 @@ public class MetadataQuerierByFileImpl implements IMetadataQuerier {
 
   @Override
   public List<IChunkMetadata> getChunkMetaDataList(Path path) throws IOException {
-    return chunkMetaDataCache.get(path);
+    return new ArrayList<>(chunkMetaDataCache.get(path));
   }
 
   @Override
@@ -98,7 +99,7 @@ public class MetadataQuerierByFileImpl implements IMetadataQuerier {
       deviceMeasurementsMap.get(path.getDevice()).add(path.getMeasurement());
     }
 
-    Map<Path, List<IChunkMetadata>> tempChunkMetaDatas = new HashMap<>();
+    Map<Path, List<ChunkMetadata>> tempChunkMetaDatas = new HashMap<>();
 
     int count = 0;
     boolean enough = false;
@@ -118,12 +119,12 @@ public class MetadataQuerierByFileImpl implements IMetadataQuerier {
 
       List<TimeseriesMetadata> timeseriesMetaDataList =
           tsFileReader.readTimeseriesMetadata(selectedDevice, selectedMeasurements);
-      List<IChunkMetadata> chunkMetadataList = new ArrayList<>();
+      List<ChunkMetadata> chunkMetadataList = new ArrayList<>();
       for (TimeseriesMetadata timeseriesMetadata : timeseriesMetaDataList) {
         chunkMetadataList.addAll(tsFileReader.readChunkMetaDataList(timeseriesMetadata));
       }
       // d1
-      for (IChunkMetadata chunkMetaData : chunkMetadataList) {
+      for (ChunkMetadata chunkMetaData : chunkMetadataList) {
         String currentMeasurement = chunkMetaData.getMeasurementUid();
 
         // s1
@@ -148,7 +149,7 @@ public class MetadataQuerierByFileImpl implements IMetadataQuerier {
       }
     }
 
-    for (Map.Entry<Path, List<IChunkMetadata>> entry : tempChunkMetaDatas.entrySet())
{
+    for (Map.Entry<Path, List<ChunkMetadata>> entry : tempChunkMetaDatas.entrySet())
{
       chunkMetaDataCache.put(entry.getKey(), entry.getValue());
     }
   }
@@ -162,7 +163,7 @@ public class MetadataQuerierByFileImpl implements IMetadataQuerier {
     return tsFileReader.getChunkMetadataList(path).get(0).getDataType();
   }
 
-  private List<IChunkMetadata> loadChunkMetadata(Path path) throws IOException {
+  private List<ChunkMetadata> loadChunkMetadata(Path path) throws IOException {
     return tsFileReader.getChunkMetadataList(path);
   }
 
@@ -193,10 +194,10 @@ public class MetadataQuerierByFileImpl implements IMetadataQuerier {
       Set<String> selectedMeasurements = deviceMeasurements.getValue();
 
       // measurement -> ChunkMetadata list
-      Map<String, List<IChunkMetadata>> seriesMetadatas =
+      Map<String, List<ChunkMetadata>> seriesMetadatas =
           tsFileReader.readChunkMetadataInDevice(selectedDevice);
 
-      for (Entry<String, List<IChunkMetadata>> seriesMetadata : seriesMetadatas.entrySet())
{
+      for (Entry<String, List<ChunkMetadata>> seriesMetadata : seriesMetadatas.entrySet())
{
 
         if (!selectedMeasurements.contains(seriesMetadata.getKey())) {
           continue;
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/executor/ExecutorWithTimeGenerator.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/executor/ExecutorWithTimeGenerator.java
index 90e41d4..bfb8ea5 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/executor/ExecutorWithTimeGenerator.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/executor/ExecutorWithTimeGenerator.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.tsfile.read.query.executor;
 
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.read.common.Path;
 import org.apache.iotdb.tsfile.read.controller.IChunkLoader;
@@ -76,7 +76,7 @@ public class ExecutorWithTimeGenerator implements QueryExecutor {
       boolean cachedValue = cachedIterator.next();
       Path selectedPath = selectedPathIterator.next();
 
-      List<ChunkMetadata> chunkMetadataList = metadataQuerier.getChunkMetaDataList(selectedPath);
+      List<IChunkMetadata> chunkMetadataList = metadataQuerier.getChunkMetaDataList(selectedPath);
       if (chunkMetadataList.size() != 0) {
         dataTypes.add(chunkMetadataList.get(0).getDataType());
         if (cachedValue) {
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/executor/TsFileExecutor.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/executor/TsFileExecutor.java
index 788d541..a530cb3 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/executor/TsFileExecutor.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/executor/TsFileExecutor.java
@@ -20,7 +20,7 @@ package org.apache.iotdb.tsfile.read.query.executor;
 
 import org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
 import org.apache.iotdb.tsfile.exception.write.NoMeasurementException;
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.read.common.Path;
 import org.apache.iotdb.tsfile.read.common.TimeRange;
@@ -176,7 +176,7 @@ public class TsFileExecutor implements QueryExecutor {
     List<TSDataType> dataTypes = new ArrayList<>();
 
     for (Path path : selectedPathList) {
-      List<ChunkMetadata> chunkMetadataList = metadataQuerier.getChunkMetaDataList(path);
+      List<IChunkMetadata> chunkMetadataList = metadataQuerier.getChunkMetaDataList(path);
       AbstractFileSeriesReader seriesReader;
       if (chunkMetadataList.isEmpty()) {
         seriesReader = new EmptyFileSeriesReader();
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/timegenerator/TsFileTimeGenerator.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/timegenerator/TsFileTimeGenerator.java
index c68fc74..571f70a 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/timegenerator/TsFileTimeGenerator.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/timegenerator/TsFileTimeGenerator.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.tsfile.read.query.timegenerator;
 
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.read.controller.IChunkLoader;
 import org.apache.iotdb.tsfile.read.controller.IMetadataQuerier;
 import org.apache.iotdb.tsfile.read.expression.IExpression;
@@ -46,7 +46,7 @@ public class TsFileTimeGenerator extends TimeGenerator {
   @Override
   protected IBatchReader generateNewBatchReader(SingleSeriesExpression expression)
       throws IOException {
-    List<ChunkMetadata> chunkMetadataList =
+    List<IChunkMetadata> chunkMetadataList =
         metadataQuerier.getChunkMetaDataList(expression.getSeriesPath());
     return new FileSeriesReader(chunkLoader, chunkMetadataList, expression.getFilter());
   }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/TimePageReader.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/TimePageReader.java
index 6bb7e74..aa39832 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/TimePageReader.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/TimePageReader.java
@@ -23,10 +23,9 @@ import org.apache.iotdb.tsfile.file.header.PageHeader;
 import org.apache.iotdb.tsfile.file.metadata.statistics.TimeStatistics;
 import org.apache.iotdb.tsfile.read.common.TimeRange;
 
-import com.sun.tools.javac.util.List;
-
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.util.List;
 
 public class TimePageReader {
 
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/AbstractFileSeriesReader.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/AbstractFileSeriesReader.java
index 52489a4..e0e4444 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/AbstractFileSeriesReader.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/AbstractFileSeriesReader.java
@@ -19,7 +19,7 @@
 
 package org.apache.iotdb.tsfile.read.reader.series;
 
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.read.common.BatchData;
 import org.apache.iotdb.tsfile.read.controller.IChunkLoader;
 import org.apache.iotdb.tsfile.read.filter.basic.Filter;
@@ -33,7 +33,7 @@ import java.util.List;
 public abstract class AbstractFileSeriesReader implements IBatchReader {
 
   protected IChunkLoader chunkLoader;
-  protected List<ChunkMetadata> chunkMetadataList;
+  protected List<IChunkMetadata> chunkMetadataList;
   protected ChunkReader chunkReader;
   private int chunkToRead;
 
@@ -41,7 +41,7 @@ public abstract class AbstractFileSeriesReader implements IBatchReader {
 
   /** constructor of FileSeriesReader. */
   public AbstractFileSeriesReader(
-      IChunkLoader chunkLoader, List<ChunkMetadata> chunkMetadataList, Filter filter)
{
+      IChunkLoader chunkLoader, List<IChunkMetadata> chunkMetadataList, Filter filter)
{
     this.chunkLoader = chunkLoader;
     this.chunkMetadataList = chunkMetadataList;
     this.filter = filter;
@@ -59,7 +59,7 @@ public abstract class AbstractFileSeriesReader implements IBatchReader {
     // current chunk does not have additional batch, init new chunk reader
     while (chunkToRead < chunkMetadataList.size()) {
 
-      ChunkMetadata chunkMetaData = nextChunkMeta();
+      IChunkMetadata chunkMetaData = nextChunkMeta();
       if (chunkSatisfied(chunkMetaData)) {
         // chunk metadata satisfy the condition
         initChunkReader(chunkMetaData);
@@ -77,16 +77,16 @@ public abstract class AbstractFileSeriesReader implements IBatchReader
{
     return chunkReader.nextPageData();
   }
 
-  protected abstract void initChunkReader(ChunkMetadata chunkMetaData) throws IOException;
+  protected abstract void initChunkReader(IChunkMetadata chunkMetaData) throws IOException;
 
-  protected abstract boolean chunkSatisfied(ChunkMetadata chunkMetaData);
+  protected abstract boolean chunkSatisfied(IChunkMetadata chunkMetaData);
 
   @Override
   public void close() throws IOException {
     chunkLoader.close();
   }
 
-  private ChunkMetadata nextChunkMeta() {
+  private IChunkMetadata nextChunkMeta() {
     return chunkMetadataList.get(chunkToRead++);
   }
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/EmptyFileSeriesReader.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/EmptyFileSeriesReader.java
index 527d6c3..0316987 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/EmptyFileSeriesReader.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/EmptyFileSeriesReader.java
@@ -19,7 +19,7 @@
 
 package org.apache.iotdb.tsfile.read.reader.series;
 
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.read.common.BatchData;
 
 /** this is for those series which has no data points */
@@ -31,12 +31,12 @@ public class EmptyFileSeriesReader extends AbstractFileSeriesReader {
   }
 
   @Override
-  protected void initChunkReader(ChunkMetadata chunkMetaData) {
+  protected void initChunkReader(IChunkMetadata chunkMetaData) {
     // do nothing
   }
 
   @Override
-  protected boolean chunkSatisfied(ChunkMetadata chunkMetaData) {
+  protected boolean chunkSatisfied(IChunkMetadata chunkMetaData) {
     return false;
   }
 
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/FileSeriesReader.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/FileSeriesReader.java
index e48dca7..10dde36 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/FileSeriesReader.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/FileSeriesReader.java
@@ -19,6 +19,7 @@
 package org.apache.iotdb.tsfile.read.reader.series;
 
 import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.read.common.Chunk;
 import org.apache.iotdb.tsfile.read.controller.IChunkLoader;
 import org.apache.iotdb.tsfile.read.filter.basic.Filter;
@@ -34,18 +35,18 @@ import java.util.List;
 public class FileSeriesReader extends AbstractFileSeriesReader {
 
   public FileSeriesReader(
-      IChunkLoader chunkLoader, List<ChunkMetadata> chunkMetadataList, Filter filter)
{
+      IChunkLoader chunkLoader, List<IChunkMetadata> chunkMetadataList, Filter filter)
{
     super(chunkLoader, chunkMetadataList, filter);
   }
 
   @Override
-  protected void initChunkReader(ChunkMetadata chunkMetaData) throws IOException {
-    Chunk chunk = chunkLoader.loadChunk(chunkMetaData);
+  protected void initChunkReader(IChunkMetadata chunkMetaData) throws IOException {
+    Chunk chunk = chunkLoader.loadChunk((ChunkMetadata) chunkMetaData);
     this.chunkReader = new ChunkReader(chunk, filter);
   }
 
   @Override
-  protected boolean chunkSatisfied(ChunkMetadata chunkMetaData) {
+  protected boolean chunkSatisfied(IChunkMetadata chunkMetaData) {
     return filter == null || filter.satisfy(chunkMetaData.getStatistics());
   }
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/FileSeriesReaderByTimestamp.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/FileSeriesReaderByTimestamp.java
index 504aad9..482a192 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/FileSeriesReaderByTimestamp.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/series/FileSeriesReaderByTimestamp.java
@@ -19,6 +19,7 @@
 package org.apache.iotdb.tsfile.read.reader.series;
 
 import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.read.common.BatchData;
 import org.apache.iotdb.tsfile.read.common.Chunk;
@@ -36,7 +37,7 @@ import java.util.List;
 public class FileSeriesReaderByTimestamp {
 
   protected IChunkLoader chunkLoader;
-  protected List<ChunkMetadata> chunkMetadataList;
+  protected List<IChunkMetadata> chunkMetadataList;
   private int currentChunkIndex = 0;
 
   private ChunkReader chunkReader;
@@ -45,7 +46,7 @@ public class FileSeriesReaderByTimestamp {
 
   /** init with chunkLoader and chunkMetaDataList. */
   public FileSeriesReaderByTimestamp(
-      IChunkLoader chunkLoader, List<ChunkMetadata> chunkMetadataList) {
+      IChunkLoader chunkLoader, List<IChunkMetadata> chunkMetadataList) {
     this.chunkLoader = chunkLoader;
     this.chunkMetadataList = chunkMetadataList;
     currentTimestamp = Long.MIN_VALUE;
@@ -133,7 +134,7 @@ public class FileSeriesReaderByTimestamp {
 
   private boolean constructNextSatisfiedChunkReader() throws IOException {
     while (currentChunkIndex < chunkMetadataList.size()) {
-      ChunkMetadata chunkMetaData = chunkMetadataList.get(currentChunkIndex++);
+      IChunkMetadata chunkMetaData = chunkMetadataList.get(currentChunkIndex++);
       if (chunkSatisfied(chunkMetaData)) {
         initChunkReader(chunkMetaData);
         ((ChunkReaderByTimestamp) chunkReader).setCurrentTimestamp(currentTimestamp);
@@ -143,12 +144,12 @@ public class FileSeriesReaderByTimestamp {
     return false;
   }
 
-  private void initChunkReader(ChunkMetadata chunkMetaData) throws IOException {
-    Chunk chunk = chunkLoader.loadChunk(chunkMetaData);
+  private void initChunkReader(IChunkMetadata chunkMetaData) throws IOException {
+    Chunk chunk = chunkLoader.loadChunk((ChunkMetadata) chunkMetaData);
     this.chunkReader = new ChunkReaderByTimestamp(chunk);
   }
 
-  private boolean chunkSatisfied(ChunkMetadata chunkMetaData) {
+  private boolean chunkSatisfied(IChunkMetadata chunkMetaData) {
     return chunkMetaData.getEndTime() >= currentTimestamp;
   }
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/v2/read/TsFileSequenceReaderForV2.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/v2/read/TsFileSequenceReaderForV2.java
index dc584cd..9247a72 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/v2/read/TsFileSequenceReaderForV2.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/v2/read/TsFileSequenceReaderForV2.java
@@ -23,7 +23,6 @@ import org.apache.iotdb.tsfile.file.header.ChunkGroupHeader;
 import org.apache.iotdb.tsfile.file.header.ChunkHeader;
 import org.apache.iotdb.tsfile.file.header.PageHeader;
 import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
-import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.file.metadata.MetadataIndexEntry;
 import org.apache.iotdb.tsfile.file.metadata.MetadataIndexNode;
 import org.apache.iotdb.tsfile.file.metadata.TimeseriesMetadata;
@@ -183,7 +182,7 @@ public class TsFileSequenceReaderForV2 extends TsFileSequenceReader implements
A
     buffer = readData(metadataIndexPair.left.getOffset(), metadataIndexPair.right);
     while (buffer.hasRemaining()) {
       TimeseriesMetadata timeseriesMetadata = TimeseriesMetadataV2.deserializeFrom(buffer);
-      ArrayList<IChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetadata);
+      ArrayList<ChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetadata);
       timeseriesMetadata.setChunkMetadataList(chunkMetadataList);
       timeseriesMetadataList.add(timeseriesMetadata);
     }
@@ -223,7 +222,7 @@ public class TsFileSequenceReaderForV2 extends TsFileSequenceReader implements
A
     while (buffer.hasRemaining()) {
       TimeseriesMetadata timeseriesMetadata;
       timeseriesMetadata = TimeseriesMetadataV2.deserializeFrom(buffer);
-      ArrayList<IChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetadata);
+      ArrayList<ChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetadata);
       timeseriesMetadata.setChunkMetadataList(chunkMetadataList);
       if (allSensors.contains(timeseriesMetadata.getMeasurementId())) {
         timeseriesMetadataList.add(timeseriesMetadata);
@@ -272,7 +271,7 @@ public class TsFileSequenceReaderForV2 extends TsFileSequenceReader implements
A
               measurementMetadataIndexPair.left.getOffset(), measurementMetadataIndexPair.right);
       while (buffer.hasRemaining()) {
         TimeseriesMetadata timeseriesMetadata = TimeseriesMetadataV2.deserializeFrom(buffer);
-        ArrayList<IChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetadata);
+        ArrayList<ChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetadata);
         timeseriesMetadata.setChunkMetadataList(chunkMetadataList);
         timeseriesMetadataList.add(timeseriesMetadata);
       }
@@ -339,7 +338,7 @@ public class TsFileSequenceReaderForV2 extends TsFileSequenceReader implements
A
    * @throws IOException io error
    */
   @Override
-  public Map<String, List<IChunkMetadata>> readChunkMetadataInDevice(String device)
+  public Map<String, List<ChunkMetadata>> readChunkMetadataInDevice(String device)
       throws IOException {
     if (tsFileMetaData == null) {
       readFileMetadata();
@@ -356,7 +355,7 @@ public class TsFileSequenceReaderForV2 extends TsFileSequenceReader implements
A
     }
     // read buffer of all ChunkMetadatas of this device
     ByteBuffer buffer = readData(start, size);
-    Map<String, List<IChunkMetadata>> seriesMetadata = new HashMap<>();
+    Map<String, List<ChunkMetadata>> seriesMetadata = new HashMap<>();
     while (buffer.hasRemaining()) {
       ChunkMetadata chunkMetadata = ChunkMetadataV2.deserializeFrom(buffer);
       seriesMetadata
@@ -364,7 +363,7 @@ public class TsFileSequenceReaderForV2 extends TsFileSequenceReader implements
A
           .add(chunkMetadata);
     }
     // set version in ChunkMetadata
-    for (Entry<String, List<IChunkMetadata>> entry : seriesMetadata.entrySet())
{
+    for (Entry<String, List<ChunkMetadata>> entry : seriesMetadata.entrySet())
{
       applyVersion(entry.getValue());
     }
     return seriesMetadata;
@@ -411,7 +410,7 @@ public class TsFileSequenceReaderForV2 extends TsFileSequenceReader implements
A
         List<TimeseriesMetadata> timeseriesMetadataList = new ArrayList<>();
         while (buffer.hasRemaining()) {
           TimeseriesMetadata timeseriesMetadata = TimeseriesMetadataV2.deserializeFrom(buffer);
-          ArrayList<IChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetadata);
+          ArrayList<ChunkMetadata> chunkMetadataList = readChunkMetaDataList(timeseriesMetadata);
           timeseriesMetadata.setChunkMetadataList(chunkMetadataList);
           timeseriesMetadataList.add(timeseriesMetadata);
         }
@@ -585,10 +584,10 @@ public class TsFileSequenceReaderForV2 extends TsFileSequenceReader
implements A
    *
    * @return List of ChunkMetaData
    */
-  public ArrayList<IChunkMetadata> readChunkMetaDataList(TimeseriesMetadata timeseriesMetaData)
+  public ArrayList<ChunkMetadata> readChunkMetaDataList(TimeseriesMetadata timeseriesMetaData)
       throws IOException {
     readFileMetadata();
-    ArrayList<IChunkMetadata> chunkMetadataList = new ArrayList<>();
+    ArrayList<ChunkMetadata> chunkMetadataList = new ArrayList<>();
     long startOffsetOfChunkMetadataList = timeseriesMetaData.getOffsetOfChunkMetaDataList();
     int dataSizeOfChunkMetadataList = timeseriesMetaData.getDataSizeOfChunkMetaDataList();
 
@@ -603,12 +602,12 @@ public class TsFileSequenceReaderForV2 extends TsFileSequenceReader
implements A
     return chunkMetadataList;
   }
 
-  private void applyVersion(List<IChunkMetadata> chunkMetadataList) {
+  private void applyVersion(List<ChunkMetadata> chunkMetadataList) {
     if (versionInfo == null || versionInfo.isEmpty()) {
       return;
     }
     int versionIndex = 0;
-    for (IChunkMetadata chunkMetadata : chunkMetadataList) {
+    for (ChunkMetadata chunkMetadata : chunkMetadataList) {
 
       while (chunkMetadata.getOffsetOfChunkHeader() >= versionInfo.get(versionIndex).left)
{
         versionIndex++;
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/RestorableTsFileIOWriter.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/RestorableTsFileIOWriter.java
index 26f8494..eaa078d 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/RestorableTsFileIOWriter.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/RestorableTsFileIOWriter.java
@@ -22,6 +22,7 @@ package org.apache.iotdb.tsfile.write.writer;
 import org.apache.iotdb.tsfile.exception.NotCompatibleTsFileException;
 import org.apache.iotdb.tsfile.file.metadata.ChunkGroupMetadata;
 import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.fileSystem.FSFactoryProducer;
 import org.apache.iotdb.tsfile.read.TsFileCheckStatus;
@@ -166,12 +167,12 @@ public class RestorableTsFileIOWriter extends TsFileIOWriter {
     List<ChunkMetadata> chunkMetadataList = new ArrayList<>();
     if (metadatasForQuery.containsKey(deviceId)
         && metadatasForQuery.get(deviceId).containsKey(measurementId)) {
-      for (ChunkMetadata chunkMetaData : metadatasForQuery.get(deviceId).get(measurementId))
{
+      for (IChunkMetadata chunkMetaData : metadatasForQuery.get(deviceId).get(measurementId))
{
         // filter: if a device'measurement is defined as float type, and data has been persistent.
         // Then someone deletes the timeseries and recreate it with Int type. We have to
ignore
         // all the stale data.
         if (dataType == null || dataType.equals(chunkMetaData.getDataType())) {
-          chunkMetadataList.add(chunkMetaData);
+          chunkMetadataList.add((ChunkMetadata) chunkMetaData);
         }
       }
     }
@@ -193,7 +194,7 @@ public class RestorableTsFileIOWriter extends TsFileIOWriter {
         List<ChunkMetadata> rowMetaDataList = chunkGroupMetadata.getChunkMetadataList();
 
         String device = chunkGroupMetadata.getDevice();
-        for (ChunkMetadata chunkMetaData : rowMetaDataList) {
+        for (IChunkMetadata chunkMetaData : rowMetaDataList) {
           String measurementId = chunkMetaData.getMeasurementUid();
           if (!metadatasForQuery.containsKey(device)) {
             metadatasForQuery.put(device, new HashMap<>());
@@ -201,7 +202,7 @@ public class RestorableTsFileIOWriter extends TsFileIOWriter {
           if (!metadatasForQuery.get(device).containsKey(measurementId)) {
             metadatasForQuery.get(device).put(measurementId, new ArrayList<>());
           }
-          metadatasForQuery.get(device).get(measurementId).add(chunkMetaData);
+          metadatasForQuery.get(device).get(measurementId).add((ChunkMetadata) chunkMetaData);
         }
       }
     }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
index c68c78b..dd0cd4a 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.tsfile.file.header.ChunkGroupHeader;
 import org.apache.iotdb.tsfile.file.header.ChunkHeader;
 import org.apache.iotdb.tsfile.file.metadata.ChunkGroupMetadata;
 import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.file.metadata.MetadataIndexConstructor;
 import org.apache.iotdb.tsfile.file.metadata.MetadataIndexNode;
 import org.apache.iotdb.tsfile.file.metadata.TimeseriesMetadata;
@@ -239,9 +240,9 @@ public class TsFileIOWriter {
     ReadWriteIOUtils.write(MetaMarker.SEPARATOR, out.wrapAsStream());
 
     // group ChunkMetadata by series
-    Map<Path, List<ChunkMetadata>> chunkMetadataListMap = new TreeMap<>();
+    Map<Path, List<IChunkMetadata>> chunkMetadataListMap = new TreeMap<>();
     for (ChunkGroupMetadata chunkGroupMetadata : chunkGroupMetadataList) {
-      for (ChunkMetadata chunkMetadata : chunkGroupMetadata.getChunkMetadataList()) {
+      for (IChunkMetadata chunkMetadata : chunkGroupMetadata.getChunkMetadataList()) {
         Path series = new Path(chunkGroupMetadata.getDevice(), chunkMetadata.getMeasurementUid());
         chunkMetadataListMap.computeIfAbsent(series, k -> new ArrayList<>()).add(chunkMetadata);
       }
@@ -288,13 +289,13 @@ public class TsFileIOWriter {
    *
    * @return MetadataIndexEntry list in TsFileMetadata
    */
-  private MetadataIndexNode flushMetadataIndex(Map<Path, List<ChunkMetadata>>
chunkMetadataListMap)
+  private MetadataIndexNode flushMetadataIndex(Map<Path, List<IChunkMetadata>>
chunkMetadataListMap)
       throws IOException {
 
     // convert ChunkMetadataList to this field
     deviceTimeseriesMetadataMap = new LinkedHashMap<>();
     // create device -> TimeseriesMetaDataList Map
-    for (Map.Entry<Path, List<ChunkMetadata>> entry : chunkMetadataListMap.entrySet())
{
+    for (Map.Entry<Path, List<IChunkMetadata>> entry : chunkMetadataListMap.entrySet())
{
       Path path = entry.getKey();
       String device = path.getDevice();
 
@@ -306,7 +307,7 @@ public class TsFileIOWriter {
       int chunkMetadataListLength = 0;
       boolean serializeStatistic = (entry.getValue().size() > 1);
       // flush chunkMetadataList one by one
-      for (ChunkMetadata chunkMetadata : entry.getValue()) {
+      for (IChunkMetadata chunkMetadata : entry.getValue()) {
         if (!chunkMetadata.getDataType().equals(dataType)) {
           continue;
         }
@@ -341,8 +342,8 @@ public class TsFileIOWriter {
   }
 
   // device -> ChunkMetadataList
-  public Map<String, List<ChunkMetadata>> getDeviceChunkMetadataMap() {
-    Map<String, List<ChunkMetadata>> deviceChunkMetadataMap = new HashMap<>();
+  public Map<String, List<IChunkMetadata>> getDeviceChunkMetadataMap() {
+    Map<String, List<IChunkMetadata>> deviceChunkMetadataMap = new HashMap<>();
 
     for (ChunkGroupMetadata chunkGroupMetadata : chunkGroupMetadataList) {
       deviceChunkMetadataMap
@@ -402,7 +403,7 @@ public class TsFileIOWriter {
       Iterator<ChunkMetadata> chunkMetaDataIterator =
           chunkGroupMetaData.getChunkMetadataList().iterator();
       while (chunkMetaDataIterator.hasNext()) {
-        ChunkMetadata chunkMetaData = chunkMetaDataIterator.next();
+        IChunkMetadata chunkMetaData = chunkMetaDataIterator.next();
         Path path = new Path(deviceId, chunkMetaData.getMeasurementUid());
         int startTimeIdx = startTimeIdxes.get(path);
 
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/read/query/timegenerator/ReaderByTimestampTest.java
b/tsfile/src/test/java/org/apache/iotdb/tsfile/read/query/timegenerator/ReaderByTimestampTest.java
index 7ae6252..45d1d05 100644
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/read/query/timegenerator/ReaderByTimestampTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/read/query/timegenerator/ReaderByTimestampTest.java
@@ -19,7 +19,7 @@
 package org.apache.iotdb.tsfile.read.query.timegenerator;
 
 import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.IChunkMetadata;
 import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
 import org.apache.iotdb.tsfile.read.common.BatchData;
 import org.apache.iotdb.tsfile.read.common.Path;
@@ -62,7 +62,7 @@ public class ReaderByTimestampTest {
   @Test
   public void readByTimestamp() throws IOException {
     CachedChunkLoaderImpl seriesChunkLoader = new CachedChunkLoaderImpl(fileReader);
-    List<ChunkMetadata> chunkMetadataList =
+    List<IChunkMetadata> chunkMetadataList =
         metadataQuerierByFile.getChunkMetaDataList(new Path("d1", "s1"));
     AbstractFileSeriesReader seriesReader =
         new FileSeriesReader(seriesChunkLoader, chunkMetadataList, null);


Mime
View raw message