vinothchandar commented on a change in pull request #1009: [HUDI-308] Avoid
Renames for tracking state transitions of all actions on dataset
URL: https://github.com/apache/incubator-hudi/pull/1009#discussion_r357127905
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieInstant.java
##########
@@ -32,7 +35,24 @@
*
* @see HoodieTimeline
*/
-public class HoodieInstant implements Serializable {
+public class HoodieInstant implements Serializable, Comparable<HoodieInstant> {
+
+ /**
+ * 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 = new
ImmutableMap.Builder<String, String>()
+ .put(HoodieTimeline.COMPACTION_ACTION,
HoodieTimeline.COMMIT_ACTION).build();
+
+ public static final Comparator<HoodieInstant> ACTION_COMPARATOR =
+ Comparator.<HoodieInstant, String>comparing(instant ->
getCompatibleAction(instant.getAction()));
+
+ public static final Comparator<HoodieInstant> COMPARATOR =
Comparator.comparing(HoodieInstant::getTimestamp)
+ .thenComparing(ACTION_COMPARATOR).thenComparing(HoodieInstant::getState);
+
+ public static final String getCompatibleAction(String action) {
Review comment:
consistent naming: compatible or comparable? lets pick one?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services