You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2020/03/05 12:07:26 UTC

[GitHub] [incubator-iotdb] liutaohua commented on a change in pull request #855: New TsFile

liutaohua commented on a change in pull request #855: New TsFile
URL: https://github.com/apache/incubator-iotdb/pull/855#discussion_r388190958
 
 

 ##########
 File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
 ##########
 @@ -261,64 +264,55 @@ public void endFile(Schema schema) throws IOException {
       resourceLogger.info("{} writer is closed.", file.getName());
     }
     canWrite = false;
+    chunkMetadataListMap = new TreeMap<>();
     logger.info("output stream is closed");
   }
 
   /**
-   * 1. group chunkGroupMetaDataList to TsDeviceMetadata 2. flush TsDeviceMetadata 3. get
-   * TsDeviceMetadataIndex
-   *
-   * @param chunkGroupMetaDataList all chunk group metadata in memory
-   * @return TsDeviceMetadataIndex in TsFileMetaData
+   * Flush ChunkMetadataList and TimeseriesMetaData
+   * @return DeviceMetaDataMap in TsFileMetaData
    */
-  private Map<String, TsDeviceMetadataIndex> flushTsDeviceMetaDataAndGetIndex(
-      List<ChunkGroupMetaData> chunkGroupMetaDataList) throws IOException {
-
-    Map<String, TsDeviceMetadataIndex> tsDeviceMetadataIndexMap = new HashMap<>();
-
-    long offset; /* offset for the flushing TsDeviceMetadata */
-
-    TsDeviceMetadata currentTsDeviceMetadata;
-
-    // flush TsDeviceMetadata by string order of deviceId
-    for (Map.Entry<String, TsDeviceMetadata> entry : getAllTsDeviceMetadata(chunkGroupMetaDataList)
-        .entrySet()) {
-      // update statistics in TsDeviceMetadata
-      currentTsDeviceMetadata = entry.getValue();
-
-      // flush tsChunkGroupBlockMetaData
-      offset = out.getPosition();
-      int size = currentTsDeviceMetadata.serializeTo(out.wrapAsStream());
-
-      TsDeviceMetadataIndex tsDeviceMetadataIndex = new TsDeviceMetadataIndex(offset, size,
-          currentTsDeviceMetadata);
-      tsDeviceMetadataIndexMap.put(entry.getKey(), tsDeviceMetadataIndex);
+  private Map<String, Pair<Long, Integer>> flushAllChunkMetadataList() throws IOException {
+
+    // convert ChunkMetadataList to this field
+    Map<String, List<TimeseriesMetaData>> deviceTimeseriesMetadataMap = new LinkedHashMap<>();
+    // create device -> TimeseriesMetaDataList Map
+    for (Map.Entry<Path, List<ChunkMetaData>> entry : chunkMetadataListMap.entrySet()) {
+      Path path = entry.getKey();
+      String deviceId = path.getDevice();
+      // create TimeseriesMetaData
+      TimeseriesMetaData timeseriesMetaData = new TimeseriesMetaData();
+      timeseriesMetaData.setMeasurementId(path.getMeasurement());
+      timeseriesMetaData.setTSDataType(entry.getValue().get(0).getDataType());
+      timeseriesMetaData.setOffsetOfChunkMetaDataList(out.getPosition());
+      Statistics<?> statistics = entry.getValue().get(0).getStatistics();
 
 Review comment:
   Repeat merge the statistics information

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services