From 10df8348fc4dd04fa1ab76b6de0608102fc054ca Mon Sep 17 00:00:00 2001 From: shuwenwei Date: Mon, 27 May 2024 11:53:54 +0800 Subject: [PATCH 1/2] generate compaction target file with tier level --- .../tsfile/generator/TsFileNameGenerator.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/generator/TsFileNameGenerator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/generator/TsFileNameGenerator.java index 70274fd57e36..30851e86f803 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/generator/TsFileNameGenerator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/generator/TsFileNameGenerator.java @@ -75,6 +75,7 @@ public static String generateNewTsFilePathWithMkdir( version, innerSpaceCompactionCount, crossSpaceCompactionCount, + 0, TsFileConstant.TSFILE_SUFFIX); } @@ -87,10 +88,12 @@ public static String generateNewTsFilePathWithMkdir( long version, int innerSpaceCompactionCount, int crossSpaceCompactionCount, + int tierLevel, String customSuffix) throws DiskSpaceInsufficientException { String tsFileDir = - generateTsFileDir(sequence, logicalStorageGroup, virtualStorageGroup, timePartitionId); + generateTsFileDir( + sequence, logicalStorageGroup, virtualStorageGroup, timePartitionId, tierLevel); fsFactory.getFile(tsFileDir).mkdirs(); return tsFileDir + File.separator @@ -102,10 +105,11 @@ public static String generateTsFileDir( boolean sequence, String logicalStorageGroup, String virtualStorageGroup, - long timePartitionId) + long timePartitionId, + int tierLevel) throws DiskSpaceInsufficientException { TierManager tierManager = TierManager.getInstance(); - String baseDir = tierManager.getNextFolderForTsFile(0, sequence); + String baseDir = tierManager.getNextFolderForTsFile(tierLevel, sequence); return baseDir + File.separator + logicalStorageGroup @@ -241,6 +245,7 @@ public static List getCrossCompactionTargetFileResources( tsFileName.version, tsFileName.innerCompactionCnt, tsFileName.crossCompactionCnt, + resource.getTierLevel(), IoTDBConstant.CROSS_COMPACTION_TMP_FILE_SUFFIX)), TsFileResourceStatus.COMPACTING)); } @@ -265,6 +270,7 @@ public static TsFileResource getInnerCompactionTargetFileResource( long maxVersion = Long.MIN_VALUE; long maxInnerMergeCount = Long.MIN_VALUE; long maxCrossMergeCount = Long.MIN_VALUE; + int maxTierLevel = Integer.MIN_VALUE; for (TsFileResource resource : tsFileResources) { TsFileName tsFileName = getTsFileName(resource.getTsFile().getName()); minTime = Math.min(tsFileName.time, minTime); @@ -273,6 +279,7 @@ public static TsFileResource getInnerCompactionTargetFileResource( maxVersion = Math.max(tsFileName.version, maxVersion); maxInnerMergeCount = Math.max(tsFileName.innerCompactionCnt, maxInnerMergeCount); maxCrossMergeCount = Math.max(tsFileName.crossCompactionCnt, maxCrossMergeCount); + maxTierLevel = Math.max(resource.getTierLevel(), maxTierLevel); } // set target resource to COMPACTING until the end of this task TsFileResource resource = @@ -288,6 +295,7 @@ public static TsFileResource getInnerCompactionTargetFileResource( minVersion, (int) maxInnerMergeCount + 1, (int) maxCrossMergeCount, + maxTierLevel, IoTDBConstant.INNER_COMPACTION_TMP_FILE_SUFFIX)), TsFileResourceStatus.COMPACTING) : new TsFileResource( @@ -301,6 +309,7 @@ public static TsFileResource getInnerCompactionTargetFileResource( maxVersion, (int) maxInnerMergeCount + 1, (int) maxCrossMergeCount, + maxTierLevel, IoTDBConstant.INNER_COMPACTION_TMP_FILE_SUFFIX)), TsFileResourceStatus.COMPACTING); resource.setSeq(sequence); From 574a750f2fb59f9020a9e6f551e369c1da52c50c Mon Sep 17 00:00:00 2001 From: shuwenwei Date: Thu, 30 May 2024 09:41:36 +0800 Subject: [PATCH 2/2] modify maxTierLevel to 0 --- .../dataregion/tsfile/generator/TsFileNameGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/generator/TsFileNameGenerator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/generator/TsFileNameGenerator.java index 30851e86f803..78d22da21efb 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/generator/TsFileNameGenerator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/generator/TsFileNameGenerator.java @@ -270,7 +270,7 @@ public static TsFileResource getInnerCompactionTargetFileResource( long maxVersion = Long.MIN_VALUE; long maxInnerMergeCount = Long.MIN_VALUE; long maxCrossMergeCount = Long.MIN_VALUE; - int maxTierLevel = Integer.MIN_VALUE; + int maxTierLevel = 0; for (TsFileResource resource : tsFileResources) { TsFileName tsFileName = getTsFileName(resource.getTsFile().getName()); minTime = Math.min(tsFileName.time, minTime);