Skip to content

Commit

Permalink
Generate compaction target file with tier level (apache#12597)
Browse files Browse the repository at this point in the history
* generate compaction target file with tier level

* modify maxTierLevel to 0
  • Loading branch information
shuwenwei authored and SzyWilliam committed Nov 22, 2024
1 parent 8bbfe68 commit 2338c4d
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static String generateNewTsFilePathWithMkdir(
version,
innerSpaceCompactionCount,
crossSpaceCompactionCount,
0,
TsFileConstant.TSFILE_SUFFIX);
}

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -241,6 +245,7 @@ public static List<TsFileResource> getCrossCompactionTargetFileResources(
tsFileName.version,
tsFileName.innerCompactionCnt,
tsFileName.crossCompactionCnt,
resource.getTierLevel(),
IoTDBConstant.CROSS_COMPACTION_TMP_FILE_SUFFIX)),
TsFileResourceStatus.COMPACTING));
}
Expand All @@ -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 = 0;
for (TsFileResource resource : tsFileResources) {
TsFileName tsFileName = getTsFileName(resource.getTsFile().getName());
minTime = Math.min(tsFileName.time, minTime);
Expand All @@ -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 =
Expand All @@ -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(
Expand All @@ -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);
Expand Down

0 comments on commit 2338c4d

Please sign in to comment.