jt2594838 commented on code in PR #16048:
URL: https://github.com/apache/iotdb/pull/16048#discussion_r2238138913


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/estimator/AbstractCompactionEstimator.java:
##########
@@ -100,30 +132,37 @@ private FileInfo getFileInfoFromCache(TsFileResource 
resource) throws IOExceptio
     if (fileInfoCache.containsKey(resource)) {
       return fileInfoCache.get(resource);
     }
-    File file = new File(resource.getTsFilePath());
+    TsFileID tsFileID = resource.getTsFileID();
     synchronized (globalFileInfoCacheForFailedCompaction) {
-      if (globalFileInfoCacheForFailedCompaction.containsKey(file)) {
-        FileInfo fileInfo = globalFileInfoCacheForFailedCompaction.get(file);
+      FileInfo fileInfo = globalFileInfoCacheForFailedCompaction.get(tsFileID);
+      if (fileInfo != null) {
         fileInfoCache.put(resource, fileInfo);
         return fileInfo;
       }
     }
     try (TsFileSequenceReader reader = getReader(resource.getTsFilePath())) {
       FileInfo fileInfo = CompactionEstimateUtils.calculateFileInfo(reader);
       fileInfoCache.put(resource, fileInfo);
-      synchronized (globalFileInfoCacheForFailedCompaction) {
-        globalFileInfoCacheForFailedCompaction.put(file, fileInfo);
+      if (globalFileInfoCacheEnabled) {
+        synchronized (globalFileInfoCacheForFailedCompaction) {
+          globalFileInfoCacheForFailedCompaction.put(tsFileID, fileInfo);
+        }
+        synchronized (globalRoughInfoCacheForCompaction) {
+          globalRoughInfoCacheForCompaction.put(tsFileID, 
fileInfo.getSimpleFileInfo());
+        }

Review Comment:
   Now that you have used `Collections.synchronizedMap()`, I suppose that it is 
unnecessary to add another synchronization.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to