Skip to content

Commit

Permalink
rename to force-lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
liming30 committed Aug 7, 2024
1 parent 4bb0eab commit 9338ec9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 60 deletions.
12 changes: 6 additions & 6 deletions docs/layouts/shortcodes/generated/core_configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@
<td>Integer</td>
<td>The maximal fan-in for external merge sort. It limits the number of file handles. If it is too small, may cause intermediate merging. But if it is too large, it will cause too many files opened at the same time, consume memory and lead to random reading.</td>
</tr>
<tr>
<td><h5>force-lookup</h5></td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
<td>Whether to force the use of lookup for compaction.</td>
</tr>
<tr>
<td><h5>lookup-wait</h5></td>
<td style="word-wrap: break-word;">true</td>
Expand Down Expand Up @@ -467,12 +473,6 @@
<td>Integer</td>
<td>Total level number, for example, there are 3 levels, including 0,1,2 levels.</td>
</tr>
<tr>
<td><h5>prefer-compaction-strategy</h5></td>
<td style="word-wrap: break-word;">universal</td>
<td>Enum</td>
<td>By default, universal compaction strategy is used. Note: This is just a suggestion for paimon to use this compaction strategy. Paimon will automatically decide which compaction strategy to use. For example, when 'changelog-producer' is set to 'lookup', paimon will automatically use the lookup compaction strategy.<br /><br />Possible values:<ul><li>"universal": Universal compaction strategy, mainly triggered by the number of sorted runs, space amplification, etc.</li><li>"lookup": When the L0 file is generated, compaction will be triggered as soon as possible.</li></ul></td>
</tr>
<tr>
<td><h5>num-sorted-run.compaction-trigger</h5></td>
<td style="word-wrap: break-word;">5</td>
Expand Down
54 changes: 10 additions & 44 deletions paimon-common/src/main/java/org/apache/paimon/CoreOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,17 +454,6 @@ public class CoreOptions implements Serializable {
text("append table: the default value is 256 MB."))
.build());

@Immutable
public static final ConfigOption<CompactionStrategy> PREFER_COMPACTION_STRATEGY =
key("prefer-compaction-strategy")
.enumType(CompactionStrategy.class)
.defaultValue(CompactionStrategy.UNIVERSAL)
.withDescription(
"By default, universal compaction strategy is used. Note: This is just a suggestion "
+ "for paimon to use this compaction strategy. Paimon will automatically decide "
+ "which compaction strategy to use. For example, when 'changelog-producer' is set "
+ "to 'lookup', paimon will automatically use the lookup compaction strategy.");

public static final ConfigOption<Integer> NUM_SORTED_RUNS_COMPACTION_TRIGGER =
key("num-sorted-run.compaction-trigger")
.intType()
Expand Down Expand Up @@ -1262,6 +1251,13 @@ public class CoreOptions implements Serializable {
.noDefaultValue()
.withDescription("Specifies the commit user prefix.");

@Immutable
public static final ConfigOption<Boolean> FORCE_LOOKUP =
key("force-lookup")
.booleanType()
.defaultValue(false)
.withDescription("Whether to force the use of lookup for compaction.");

public static final ConfigOption<Boolean> LOOKUP_WAIT =
key("lookup-wait")
.booleanType()
Expand Down Expand Up @@ -1703,7 +1699,7 @@ public LookupStrategy lookupStrategy() {
mergeEngine().equals(MergeEngine.FIRST_ROW),
changelogProducer().equals(ChangelogProducer.LOOKUP),
deletionVectorsEnabled(),
preferCompactionStrategy().equals(CompactionStrategy.LOOKUP));
forLookup());
}

public boolean changelogRowDeduplicate() {
Expand Down Expand Up @@ -2036,8 +2032,8 @@ public boolean metadataIcebergCompatible() {
return options.get(METADATA_ICEBERG_COMPATIBLE);
}

public CompactionStrategy preferCompactionStrategy() {
return options.get(PREFER_COMPACTION_STRATEGY);
public boolean forLookup() {
return options.get(FORCE_LOOKUP);
}

/** Specifies the merge engine for table with primary key. */
Expand Down Expand Up @@ -2648,34 +2644,4 @@ public InlineElement getDescription() {
return text(description);
}
}

/** The compaction strategy of the LSM tree. */
public enum CompactionStrategy implements DescribedEnum {
UNIVERSAL(
"universal",
"Universal compaction strategy, mainly triggered by the number of sorted runs, space amplification, etc."),

LOOKUP(
"lookup",
"When the L0 file is generated, compaction will be triggered as soon as possible.");

private final String value;

private final String description;

CompactionStrategy(String value, String description) {
this.value = value;
this.description = description;
}

@Override
public String toString() {
return value;
}

@Override
public InlineElement getDescription() {
return text(description);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ private LookupStrategy(
boolean isFirstRow,
boolean produceChangelog,
boolean deletionVector,
boolean preferLookup) {
boolean forceLookup) {
this.isFirstRow = isFirstRow;
this.produceChangelog = produceChangelog;
this.deletionVector = deletionVector;
this.needLookup = produceChangelog || deletionVector || isFirstRow || preferLookup;
this.needLookup = produceChangelog || deletionVector || isFirstRow || forceLookup;
}

public static LookupStrategy from(
boolean isFirstRow,
boolean produceChangelog,
boolean deletionVector,
boolean preferLookup) {
return new LookupStrategy(isFirstRow, produceChangelog, deletionVector, preferLookup);
boolean forceLookup) {
return new LookupStrategy(isFirstRow, produceChangelog, deletionVector, forceLookup);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import org.apache.paimon.CoreOptions;
import org.apache.paimon.CoreOptions.ChangelogProducer;
import org.apache.paimon.CoreOptions.CompactionStrategy;
import org.apache.paimon.CoreOptions.LookupLocalFileType;
import org.apache.paimon.Snapshot;
import org.apache.paimon.data.BinaryString;
Expand Down Expand Up @@ -1681,8 +1680,7 @@ public void testRollbackToTagWithChangelogDecoupled(String changelogProducer) th

@ParameterizedTest
@EnumSource(CoreOptions.MergeEngine.class)
public void testPreferLookupCompactionStrategy(CoreOptions.MergeEngine mergeEngine)
throws Exception {
public void testForceLookupCompaction(CoreOptions.MergeEngine mergeEngine) throws Exception {
Map<MergeEngine, Pair<Long, Long>> testData = new HashMap<>();
testData.put(DEDUPLICATE, Pair.of(50L, 100L));
testData.put(PARTIAL_UPDATE, Pair.of(null, 100L));
Expand All @@ -1693,9 +1691,7 @@ public void testPreferLookupCompactionStrategy(CoreOptions.MergeEngine mergeEngi
FileStoreTable table =
createFileStoreTable(
options -> {
options.set(
CoreOptions.PREFER_COMPACTION_STRATEGY,
CompactionStrategy.LOOKUP);
options.set(CoreOptions.FORCE_LOOKUP, true);
options.set(MERGE_ENGINE, mergeEngine);
if (mergeEngine == AGGREGATE) {
options.set("fields.b.aggregate-function", "sum");
Expand Down

0 comments on commit 9338ec9

Please sign in to comment.