Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,12 @@ private List<String> getPartitionPathsForIncrementalCleaning(HoodieCleanMetadata
+ "since last cleaned at " + cleanMetadata.getEarliestCommitToRetain()
+ ". New Instant to retain : " + newInstantToRetain);
return hoodieTable.getCompletedCommitsTimeline().getInstantsAsStream().filter(
instant -> HoodieTimeline.compareTimestamps(instant.getTimestamp(), HoodieTimeline.GREATER_THAN_OR_EQUALS,
cleanMetadata.getEarliestCommitToRetain()) && HoodieTimeline.compareTimestamps(instant.getTimestamp(),
instant -> (HoodieTimeline.compareTimestamps(instant.getTimestamp(), HoodieTimeline.GREATER_THAN_OR_EQUALS,
cleanMetadata.getEarliestCommitToRetain())
|| (instant.getMarkerFileAccessTimestamp().isPresent()
&& (HoodieTimeline.compareTimestamps(instant.getMarkerFileAccessTimestamp().get(), HoodieTimeline.GREATER_THAN_OR_EQUALS,
cleanMetadata.getStartCleanTime()))))
&& HoodieTimeline.compareTimestamps(instant.getTimestamp(),
HoodieTimeline.LESSER_THAN, newInstantToRetain.get().getTimestamp())).flatMap(instant -> {
try {
if (HoodieTimeline.REPLACE_COMMIT_ACTION.equals(instant.getAction())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.apache.hudi.common.table.timeline;

import org.apache.hudi.common.util.Option;

import org.apache.hadoop.fs.FileStatus;

import java.io.Serializable;
Expand Down Expand Up @@ -73,6 +75,7 @@ public enum State {
private State state = State.COMPLETED;
private String action;
private String timestamp;
private Option<String> markerFileAccessTimestamp;

/**
* Load the instant from the meta FileStatus.
Expand All @@ -82,6 +85,7 @@ public HoodieInstant(FileStatus fileStatus) {
String fileName = fileStatus.getPath().getName();
String fileExtension = getTimelineFileExtension(fileName);
timestamp = fileName.replace(fileExtension, "");
markerFileAccessTimestamp = Option.ofNullable(HoodieInstantTimeGenerator.parseTimeMillisToInstantTime(fileStatus.getAccessTime()));

// Next read the action for this marker
action = fileExtension.replaceFirst(".", "");
Expand All @@ -104,12 +108,14 @@ public HoodieInstant(boolean isInflight, String action, String timestamp) {
this.state = isInflight ? State.INFLIGHT : State.COMPLETED;
this.action = action;
this.timestamp = timestamp;
this.markerFileAccessTimestamp = Option.ofNullable(null);
}

public HoodieInstant(State state, String action, String timestamp) {
this.state = state;
this.action = action;
this.timestamp = timestamp;
this.markerFileAccessTimestamp = Option.ofNullable(null);
}

public boolean isCompleted() {
Expand All @@ -132,6 +138,10 @@ public String getTimestamp() {
return timestamp;
}

public Option<String> getMarkerFileAccessTimestamp() {
return markerFileAccessTimestamp;
}

/**
* Get the filename for this instant.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public static String createNewInstantTime(long milliseconds) {
});
}

public static String parseTimeMillisToInstantTime(long milliseconds) {
try {
Date d = new Date(milliseconds);
return MILLIS_INSTANT_TIME_FORMATTER.format(convertDateToTemporalAccessor(d));
} catch (DateTimeParseException e) {
throw e;
}
}

public static Date parseDateFromInstantTime(String timestamp) throws ParseException {
try {
// Enables backwards compatibility with non-millisecond granularity instants
Expand Down