jixuan1989 commented on a change in pull request #2353:
URL: https://github.com/apache/iotdb/pull/2353#discussion_r549978448



##########
File path: 
server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
##########
@@ -1006,50 +1006,49 @@ private TsFileProcessor 
getOrCreateTsFileProcessorIntern(long timeRangeId,
 
   private TsFileProcessor createTsFileProcessor(boolean sequence, long 
timePartitionId)
       throws IOException, DiskSpaceInsufficientException {
-    String baseDir;
-    if (sequence) {
-      baseDir = DirectoryManager.getInstance().getNextFolderForSequenceFile();
-    } else {
-      baseDir = 
DirectoryManager.getInstance().getNextFolderForUnSequenceFile();
-    }
+    DirectoryManager directoryManager = DirectoryManager.getInstance();
+    String baseDir = sequence ? directoryManager.getNextFolderForSequenceFile()
+        : directoryManager.getNextFolderForUnSequenceFile();
+
     fsFactory.getFile(baseDir, storageGroupName).mkdirs();
 
     String filePath =
         baseDir + File.separator + storageGroupName + File.separator + 
timePartitionId
             + File.separator
             + getNewTsFileName(timePartitionId);
 
-    TsFileProcessor tsFileProcessor;
     VersionController versionController = 
getVersionControllerByTimePartitionId(timePartitionId);
+    TsFileProcessor tsFileProcessor = getTsFileProcessor(sequence, filePath, 
versionController);
+    tsFileProcessor.addCloseFileListeners(customCloseFileListeners);
+    tsFileProcessor.addFlushListeners(customFlushListeners);
+
+    tsFileProcessor.setTimeRangeId(timePartitionId);
+    return tsFileProcessor;
+  }
+
+  private TsFileProcessor getTsFileProcessor(boolean sequence, String filePath,

Review comment:
       `newTsFileProcess()` is better.
   And,  I think the following should also be in the method.
   ```
       tsFileProcessor.addCloseFileListeners(customCloseFileListeners);
       tsFileProcessor.addFlushListeners(customFlushListeners);
   
       tsFileProcessor.setTimeRangeId(timePartitionId);
   ```




----------------------------------------------------------------
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:
[email protected]


Reply via email to