Skip to content

Commit

Permalink
Convert to internal config
Browse files Browse the repository at this point in the history
  • Loading branch information
vinishjail97 committed Feb 13, 2025
1 parent b3647d3 commit 071ac60
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@
import static org.apache.hudi.common.table.timeline.InstantComparison.LESSER_THAN;
import static org.apache.hudi.common.table.timeline.InstantComparison.LESSER_THAN_OR_EQUALS;
import static org.apache.hudi.common.table.timeline.InstantComparison.compareTimestamps;
import static org.apache.hudi.config.HoodieArchivalConfig.ARCHIVE_LIMIT_INSTANTS;

/**
* Archiver to bound the growth of files under .hoodie meta path.
*/
public class TimelineArchiverV1<T extends HoodieAvroPayload, I, K, O> implements HoodieTimelineArchiver<T, I, K, O> {

public static final String ARCHIVE_LIMIT_INSTANTS = "hoodie.archive.limit.instants";
private static final Logger LOG = LoggerFactory.getLogger(TimelineArchiverV1.class);

private final StoragePath archiveFilePath;
Expand Down Expand Up @@ -355,7 +355,7 @@ private List<HoodieInstant> getInstantsToArchive() throws IOException {

return instantsToArchive.stream()
.sorted()
.limit(config.getLongOrDefault(ARCHIVE_LIMIT_INSTANTS))
.limit(config.getProps().getLong(ARCHIVE_LIMIT_INSTANTS, Long.MAX_VALUE))
.flatMap(hoodieInstant ->
groupByTsAction.getOrDefault(Pair.of(hoodieInstant.requestedTime(),
InstantComparatorV1.getComparableAction(hoodieInstant.getAction())), Collections.emptyList()).stream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ public class HoodieArchivalConfig extends HoodieConfig {
.withDocumentation("If enabled, archival will proceed beyond savepoint, skipping savepoint commits."
+ " If disabled, archival will stop at the earliest savepoint commit.");

public static final ConfigProperty<Long> ARCHIVE_LIMIT_INSTANTS = ConfigProperty
.key("hoodie.archive.limit.instants")
.defaultValue(Long.MAX_VALUE)
.markAdvanced()
.sinceVersion("0.16.0")
.withDocumentation("If enabled, archival will limit the instants upto this value."
+ "This is useful when a large timeline containing tens of thousands instants that need to archived");

/**
* @deprecated Use {@link #MAX_COMMITS_TO_KEEP} and its methods instead
*/
Expand Down Expand Up @@ -201,11 +193,6 @@ public Builder withArchiveBeyondSavepoint(boolean archiveBeyondSavepoint) {
return this;
}

public Builder withArchiveLimitInstants(long limitInstants) {
archivalConfig.setValue(ARCHIVE_LIMIT_INSTANTS, String.valueOf(limitInstants));
return this;
}

public HoodieArchivalConfig build() {
archivalConfig.setDefaults(HoodieArchivalConfig.class.getName());
return archivalConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.apache.hudi.client.timeline;

import org.apache.hudi.client.timeline.versioning.v1.TimelineArchiverV1;
import org.apache.hudi.common.config.TypedProperties;
import org.apache.hudi.common.engine.HoodieEngineContext;
import org.apache.hudi.common.engine.HoodieLocalEngineContext;
import org.apache.hudi.common.table.timeline.versioning.v1.ActiveTimelineV1;
Expand Down Expand Up @@ -56,14 +57,16 @@ void setUp() throws Exception {

@Test
void archiveIfRequired_instantsAreArchived() throws Exception {
TypedProperties advanceProperties = new TypedProperties();
advanceProperties.put(TimelineArchiverV1.ARCHIVE_LIMIT_INSTANTS, 1L);
HoodieWriteConfig writeConfig = HoodieWriteConfig
.newBuilder()
.withPath(tempDir.toString())
.withArchivalConfig(HoodieArchivalConfig.newBuilder()
.archiveCommitsWith(2, 3)
.withArchiveLimitInstants(1)
.build())
.withMarkersType("DIRECT")
.withProperties(advanceProperties)
.build();
HoodieEngineContext context = new HoodieLocalEngineContext(metaClient.getStorageConf());
HoodieStorage hoodieStorage = new HoodieHadoopStorage(basePath, metaClient.getStorageConf());
Expand Down

0 comments on commit 071ac60

Please sign in to comment.