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

marklau99 pushed a commit to branch IOTDB-4791
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/IOTDB-4791 by this push:
     new 2862074fc6 add a test
2862074fc6 is described below

commit 2862074fc6c18270f80eb890efdb59bce633ec40
Author: Liu Xuxin <[email protected]>
AuthorDate: Mon Oct 31 16:46:26 2022 +0800

    add a test
---
 .../iotdb/tsfile/write/writer/TsFileIOWriter.java  |  3 ++
 .../write/writer/TsFileIOWriterEndFileTest.java    | 49 ++++++++++++++++++++++
 2 files changed, 52 insertions(+)

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 cebef59af5..53ff109f50 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
@@ -299,6 +299,7 @@ public class TsFileIOWriter implements AutoCloseable {
    */
   @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity 
warning
   public void endFile() throws IOException {
+    long startTime = System.currentTimeMillis();
     checkInMemoryPathCount();
     readChunkMetadataAndConstructIndexTree();
 
@@ -322,6 +323,8 @@ public class TsFileIOWriter implements AutoCloseable {
       }
     }
     canWrite = false;
+    long cost = System.currentTimeMillis() - startTime;
+    logger.info("Time for flushing metadata is {} ms", cost);
   }
 
   private void checkInMemoryPathCount() {
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriterEndFileTest.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriterEndFileTest.java
new file mode 100644
index 0000000000..1e8fd25081
--- /dev/null
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriterEndFileTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.tsfile.write.writer;
+
+import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.tsfile.write.chunk.ChunkWriterImpl;
+import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
+
+import java.io.File;
+
+public class TsFileIOWriterEndFileTest {
+  public static void main(String[] args) throws Exception {
+    TsFileIOWriter writer = new TsFileIOWriter(new File("test.tsfile"));
+    for (int deviceIndex = 0; deviceIndex < 1000; deviceIndex++) {
+      writer.startChunkGroup("root.sg.d" + deviceIndex);
+      for (int seriesIndex = 0; seriesIndex < 1000; seriesIndex++) {
+        ChunkWriterImpl chunkWriter =
+            new ChunkWriterImpl(
+                new MeasurementSchema(
+                    "s" + seriesIndex, TSDataType.INT32, TSEncoding.RLE, 
CompressionType.GZIP));
+        for (long time = 0; time < 10; ++time) {
+          chunkWriter.write(time, 0);
+        }
+        chunkWriter.writeToFileWriter(writer);
+      }
+      writer.endChunkGroup();
+    }
+    writer.endFile();
+  }
+}

Reply via email to