Skip to content

Commit c07614e

Browse files
committed
[core] Introduce 'compaction.small-file-ratio'
1 parent def22dc commit c07614e

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

docs/layouts/shortcodes/generated/core_configuration.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@
380380
<td>Integer</td>
381381
<td>Percentage flexibility while comparing sorted run size for changelog mode table. If the candidate sorted run(s) size is 1% smaller than the next sorted run's size, then include next sorted run into this candidate set.</td>
382382
</tr>
383+
<tr>
384+
<td><h5>compaction.small-file-ratio</h5></td>
385+
<td style="word-wrap: break-word;">0.7</td>
386+
<td>Double</td>
387+
<td>The ratio of target file size. Files whose size is smaller than target-file-size * compaction.small-file-ratio will be picked for compaction rewriting. This avoids compacting the same file repeatedly due to compression inaccuracy causing output files to be slightly smaller than the target size.</td>
388+
</tr>
383389
<tr>
384390
<td><h5>compaction.total-size-threshold</h5></td>
385391
<td style="word-wrap: break-word;">(none)</td>

paimon-api/src/main/java/org/apache/paimon/CoreOptions.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,17 @@ public InlineElement getDescription() {
722722
text("append table: the default value is 256 MB."))
723723
.build());
724724

725+
public static final ConfigOption<Double> COMPACTION_SMALL_FILE_RATIO =
726+
key("compaction.small-file-ratio")
727+
.doubleType()
728+
.defaultValue(0.7)
729+
.withDescription(
730+
"The ratio of target file size. Files whose size is smaller than "
731+
+ "target-file-size * compaction.small-file-ratio will be "
732+
+ "picked for compaction rewriting. This avoids compacting the same "
733+
+ "file repeatedly due to compression inaccuracy causing output files "
734+
+ "to be slightly smaller than the target size.");
735+
725736
public static final ConfigOption<MemorySize> BLOB_TARGET_FILE_SIZE =
726737
key("blob.target-file-size")
727738
.memoryType()
@@ -2962,7 +2973,7 @@ public long compactionFileSize(boolean hasPrimaryKey) {
29622973
// file size to join the compaction, we don't process on middle file size to avoid
29632974
// compact a same file twice (the compression is not calculate so accurately. the output
29642975
// file maybe be less than target file generated by rolling file write).
2965-
return targetFileSize(hasPrimaryKey) / 10 * 7;
2976+
return (long) (targetFileSize(hasPrimaryKey) * options.get(COMPACTION_SMALL_FILE_RATIO));
29662977
}
29672978

29682979
public int numSortedRunCompactionTrigger() {

0 commit comments

Comments
 (0)