danny0405 commented on code in PR #11923:
URL: https://github.com/apache/hudi/pull/11923#discussion_r1830436236
##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieInstant.java:
##########
@@ -19,162 +19,44 @@
package org.apache.hudi.common.table.timeline;
import org.apache.hudi.common.util.StringUtils;
-import org.apache.hudi.common.util.ValidationUtils;
-import org.apache.hudi.storage.StoragePathInfo;
import java.io.Serializable;
import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Objects;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
/**
* A Hoodie Instant represents a action done on a hoodie table. All actions
start with a inflight instant and then
* create a completed instant after done.
- *
- * @see HoodieTimeline
*/
public class HoodieInstant implements Serializable, Comparable<HoodieInstant> {
- // Instant like 20230104152218702.commit.request, 20230104152218702.inflight
and 20230104152218702_20230104152630238.commit
- private static final Pattern NAME_FORMAT =
- Pattern.compile("^(\\d+(_\\d+)?)(\\.\\w+)(\\.\\D+)?$");
-
- private static final String DELIMITER = ".";
-
+ public static final String FILE_NAME_FORMAT_ERROR = "The provided file name
%s does not conform to the required format";
public static final String UNDERSCORE = "_";
-
- private static final String FILE_NAME_FORMAT_ERROR =
- "The provided file name %s does not conform to the required format";
-
- /**
- * A COMPACTION action eventually becomes COMMIT when completed. So, when
grouping instants
- * for state transitions, this needs to be taken into account.
- */
- private static final Map<String, String> COMPARABLE_ACTIONS =
createComparableActionsMap();
-
- public static final Comparator<HoodieInstant> ACTION_COMPARATOR =
- Comparator.comparing(instant ->
getComparableAction(instant.getAction()));
-
- public static final Comparator<HoodieInstant> INSTANT_TIME_COMPARATOR =
Comparator.comparing(HoodieInstant::getTimestamp)
- .thenComparing(ACTION_COMPARATOR).thenComparing(HoodieInstant::getState);
-
- public static final Comparator<HoodieInstant> COMPLETION_TIME_COMPARATOR =
- Comparator.comparing(HoodieInstant::getCompletionTime)
- .thenComparing(INSTANT_TIME_COMPARATOR);
-
- private static final String EMPTY_FILE_EXTENSION = "";
-
- public static String getComparableAction(String action) {
- return COMPARABLE_ACTIONS.getOrDefault(action, action);
- }
-
- public static String extractTimestamp(String fileName) throws
IllegalArgumentException {
- Matcher matcher = NAME_FORMAT.matcher(fileName);
- if (matcher.find()) {
- String timestamp = matcher.group(1);
- return timestamp.contains(UNDERSCORE) ? timestamp.split(UNDERSCORE)[0] :
timestamp;
- }
-
- throw new IllegalArgumentException("Failed to retrieve timestamp from
name: "
- + String.format(FILE_NAME_FORMAT_ERROR, fileName));
- }
-
- public static String getTimelineFileExtension(String fileName) {
- Objects.requireNonNull(fileName);
-
- Matcher matcher = NAME_FORMAT.matcher(fileName);
- if (matcher.find()) {
- return fileName.substring(matcher.group(1).length());
- }
-
- return EMPTY_FILE_EXTENSION;
- }
-
- /**
- * Instant State.
- */
- public enum State {
- // Requested State (valid state for Compaction)
- REQUESTED,
- // Inflight instant
- INFLIGHT,
- // Committed instant
- COMPLETED,
- // Invalid instant
- NIL
- }
+ public static final String EMPTY_FILE_EXTENSION = "";
private final State state;
private final String action;
- private final String timestamp;
+ private final String requestTime;
Review Comment:
Rename `requestTime` to `startTime`? `request` is kind of ambigious because
each access to Hudi table is a request. Since 1.x, we have unified the
incremental query semantics to include `start time` and `completion time`,
let's keep the naming convention here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]