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

rong pushed a commit to branch pipe-parallel-connector
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit e22e3d7ab036b19bfe586531b5b994398976fdb3
Author: Steve Yurong Su <[email protected]>
AuthorDate: Sun Jun 11 03:54:22 2023 +0800

    Revert "TsFileInsertionDataContain: release file when exception occurred"
    
    This reverts commit 266d251c7bc2e1a693e85cc695b70d91a2c07cac.
---
 .../tsfile/TsFileInsertionDataContainer.java       | 42 ++++++++--------------
 1 file changed, 15 insertions(+), 27 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/TsFileInsertionDataContainer.java
 
b/server/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/TsFileInsertionDataContainer.java
index c56c33fc035..6426e8dccad 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/TsFileInsertionDataContainer.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/TsFileInsertionDataContainer.java
@@ -54,16 +54,11 @@ public class TsFileInsertionDataContainer implements 
AutoCloseable {
   public TsFileInsertionDataContainer(File tsFile, String pattern) throws 
IOException {
     this.pattern = pattern;
 
-    try {
-      tsFileSequenceReader = new 
TsFileSequenceReader(tsFile.getAbsolutePath());
-      tsFileReader = new TsFileReader(tsFileSequenceReader);
-
-      deviceMeasurementsMapIterator = 
filterDeviceMeasurementsMapByPattern().entrySet().iterator();
-      measurementDataTypeMap = tsFileSequenceReader.getFullPathDataTypeMap();
-    } catch (IOException e) {
-      close();
-      throw e;
-    }
+    tsFileSequenceReader = new TsFileSequenceReader(tsFile.getAbsolutePath());
+    tsFileReader = new TsFileReader(tsFileSequenceReader);
+
+    deviceMeasurementsMapIterator = 
filterDeviceMeasurementsMapByPattern().entrySet().iterator();
+    measurementDataTypeMap = tsFileSequenceReader.getFullPathDataTypeMap();
   }
 
   private Map<String, List<String>> filterDeviceMeasurementsMapByPattern() 
throws IOException {
@@ -121,13 +116,11 @@ public class TsFileInsertionDataContainer implements 
AutoCloseable {
           @Override
           public TabletInsertionEvent next() {
             if (!hasNext()) {
-              close();
               throw new NoSuchElementException();
             }
 
             while (tabletIterator == null || !tabletIterator.hasNext()) {
               if (!deviceMeasurementsMapIterator.hasNext()) {
-                close();
                 throw new NoSuchElementException();
               }
 
@@ -138,7 +131,6 @@ public class TsFileInsertionDataContainer implements 
AutoCloseable {
                     new TsFileInsertionDataTabletIterator(
                         tsFileReader, measurementDataTypeMap, entry.getKey(), 
entry.getValue());
               } catch (IOException e) {
-                close();
                 throw new PipeException("failed to create 
TsFileInsertionDataTabletIterator", e);
               }
             }
@@ -147,7 +139,11 @@ public class TsFileInsertionDataContainer implements 
AutoCloseable {
                 new PipeRawTabletInsertionEvent(tabletIterator.next());
 
             if (!hasNext()) {
-              close();
+              try {
+                close();
+              } catch (Exception e) {
+                LOGGER.warn("Failed to close TsFileInsertionDataContainer", e);
+              }
             }
 
             return next;
@@ -156,20 +152,12 @@ public class TsFileInsertionDataContainer implements 
AutoCloseable {
   }
 
   @Override
-  public void close() {
-    try {
-      if (tsFileReader != null) {
-        tsFileReader.close();
-      }
-    } catch (IOException e) {
-      LOGGER.warn("Failed to close TsFileReader", e);
+  public void close() throws Exception {
+    if (tsFileReader != null) {
+      tsFileReader.close();
     }
-    try {
-      if (tsFileSequenceReader != null) {
-        tsFileSequenceReader.close();
-      }
-    } catch (IOException e) {
-      LOGGER.warn("Failed to close TsFileSequenceReader", e);
+    if (tsFileSequenceReader != null) {
+      tsFileSequenceReader.close();
     }
   }
 }

Reply via email to