@Override public HoodieTimeline filterInflights() { return new HoodieDefaultTimeline(instants.stream().filter(HoodieInstant::isInflight), details); }
@Override public Optional<HoodieInstant> lastInstant() { return empty() ? Optional.empty() : nthInstant(countInstants() - 1); }
@Override public Optional<HoodieInstant> nthFromLastInstant(int n) { if (countInstants() < n + 1) { return Optional.empty(); } return nthInstant(countInstants() - 1 - n); }
@Override public Optional<HoodieInstant> nthInstant(int n) { if (empty() || n >= countInstants()) { return Optional.empty(); } return Optional.of(instants.get(n)); }
@Override public boolean containsOrBeforeTimelineStarts(String instant) { return instants.stream().anyMatch(s -> s.getTimestamp().equals(instant)) || isBeforeTimelineStarts(instant); }
@Override public boolean isBeforeTimelineStarts(String instant) { Optional<HoodieInstant> firstCommit = firstInstant(); return firstCommit.isPresent() && HoodieTimeline.compareTimestamps(instant, firstCommit.get().getTimestamp(), LESSER); }
/** * Get only the delta commits (inflight and completed) in the active timeline */ public HoodieTimeline getDeltaCommitTimeline() { return new HoodieDefaultTimeline(filterInstantsByAction(DELTA_COMMIT_ACTION), (Function<HoodieInstant, Optional<byte[]>> & Serializable) this::getInstantDetails); }
/** * Get only the rollback action (inflight and completed) in the active timeline */ public HoodieTimeline getRollbackTimeline() { return new HoodieDefaultTimeline(filterInstantsByAction(ROLLBACK_ACTION), (Function<HoodieInstant, Optional<byte[]>> & Serializable) this::getInstantDetails); }
/** * Get a timeline of a specific set of actions. useful to create a merged timeline of multiple * actions * * @param actions actions allowed in the timeline */ public HoodieTimeline getTimelineOfActions(Set<String> actions) { return new HoodieDefaultTimeline(instants.stream().filter(s -> actions.contains(s.getAction())), (Function<HoodieInstant, Optional<byte[]>> & Serializable) this::getInstantDetails); }
/** * Get only the cleaner action (inflight and completed) in the active timeline */ public HoodieTimeline getCleanerTimeline() { return new HoodieDefaultTimeline(filterInstantsByAction(CLEAN_ACTION), (Function<HoodieInstant, Optional<byte[]>> & Serializable) this::getInstantDetails); }
/** * Get only the save point action (inflight and completed) in the active timeline */ public HoodieTimeline getSavePointTimeline() { return new HoodieDefaultTimeline(filterInstantsByAction(SAVEPOINT_ACTION), (Function<HoodieInstant, Optional<byte[]>> & Serializable) this::getInstantDetails); }
@Override public HoodieTimeline filterPendingCompactionTimeline() { return new HoodieDefaultTimeline( instants.stream().filter(s -> s.getAction().equals(HoodieTimeline.COMPACTION_ACTION)), details); }
@Override public HoodieTimeline filterCompletedInstants() { return new HoodieDefaultTimeline(instants.stream().filter(s -> !s.isInflight()), details); }
@Override public HoodieTimeline filterCompletedAndCompactionInstants() { return new HoodieDefaultTimeline(instants.stream().filter(s -> { return !s.isInflight() || s.getAction().equals(HoodieTimeline.COMPACTION_ACTION); }), details); }
@Override public HoodieDefaultTimeline findInstantsAfter(String commitTime, int numCommits) { return new HoodieDefaultTimeline( instants.stream() .filter(s -> HoodieTimeline.compareTimestamps(s.getTimestamp(), commitTime, GREATER)) .limit(numCommits), details); }
@Override public HoodieTimeline filterInflightsExcludingCompaction() { return new HoodieDefaultTimeline(instants.stream().filter(instant -> { return instant.isInflight() && (!instant.getAction().equals(HoodieTimeline.COMPACTION_ACTION)); }), details); }
@Override public HoodieDefaultTimeline findInstantsInRange(String startTs, String endTs) { return new HoodieDefaultTimeline(instants.stream().filter( s -> HoodieTimeline.compareTimestamps(s.getTimestamp(), startTs, GREATER) && HoodieTimeline.compareTimestamps( s.getTimestamp(), endTs, LESSER_OR_EQUAL)), details); }
HoodieTimeline filteredTimeline = new HoodieDefaultTimeline(instantsStream, (Function<HoodieInstant, Optional<byte[]>> & Serializable) metaClient.getActiveTimeline()::getInstantDetails); return new HoodieTableFileSystemView(metaClient, filteredTimeline, statuses);