Source:
private long findRecoverySeq(List<Path> recoveryLogs, Set<String> tabletFiles, int tabletId) throws IOException { HashSet<String> suffixes = new HashSet<>(); for (String path : tabletFiles) suffixes.add(getPathSuffix(path)); long lastStart = 0; long lastFinish = 0; long recoverySeq = 0; try (RecoveryLogsIterator rli = new RecoveryLogsIterator(fs, recoveryLogs, minKey(COMPACTION_START, tabletId), maxKey(COMPACTION_START, tabletId))) { DeduplicatingIterator ddi = new DeduplicatingIterator(rli); String lastStartFile = null; LogEvents lastEvent = null; while (ddi.hasNext()) { LogFileKey key = ddi.next().getKey(); checkState(key.seq >= 0, "Unexpected negative seq %s for tabletId %s", key.seq, tabletId); checkState(key.tabletId == tabletId); if (key.event == COMPACTION_START) { checkState(key.seq >= lastStart); lastStart = key.seq; lastStartFile = key.filename; } else if (key.event == COMPACTION_FINISH) { checkState(key.seq >= lastFinish); checkState(key.seq > lastStart, "Compaction finish <= start %s %s %s", key.tabletId, key.seq, lastStart); checkState(lastEvent == null || lastEvent == COMPACTION_START, "Saw consecutive COMPACTION_FINISH events %s %s %s", key.tabletId, lastFinish, key.seq); lastFinish = key.seq; } else { throw new IllegalStateException("Non compaction event seen " + key.event); } lastEvent = key.event; } if (lastStart > lastFinish && lastStartFile != null && suffixes.contains(getPathSuffix(lastStartFile))) { log.debug("Considering compaction start finished because file in metadata table", tabletId, lastStart, getPathSuffix(lastStartFile)); recoverySeq = lastStart; } else { recoverySeq = Math.max(0, lastFinish - 1); } } return recoverySeq; }

Target:
private long findRecoverySeq(List<Path> recoveryLogs, Set<String> tabletFiles, int tabletId) throws IOException { HashSet<String> suffixes = new HashSet<>(); for (String path : tabletFiles) suffixes.add(getPathSuffix(path)); long lastStart = 0; long lastFinish = 0; long recoverySeq = 0; try (RecoveryLogsIterator rli = new RecoveryLogsIterator(fs, recoveryLogs, minKey(COMPACTION_START, tabletId), maxKey(COMPACTION_START, tabletId))) { DeduplicatingIterator ddi = new DeduplicatingIterator(rli); String lastStartFile = null; LogEvents lastEvent = null; while (ddi.hasNext()) { LogFileKey key = ddi.next().getKey(); checkState(key.seq >= 0, "Unexpected negative seq %s for tabletId %s", key.seq, tabletId); checkState(key.tabletId == tabletId); checkState(key.seq >= Math.max(lastFinish, lastStart)); switch (key.event) { case COMPACTION_START: lastStart = key.seq; lastStartFile = key.filename; break; case COMPACTION_FINISH: checkState(key.seq > lastStart, "Compaction finish <= start %s %s %s", key.tabletId, key.seq, lastStart); checkState(lastEvent != COMPACTION_FINISH, "Saw consecutive COMPACTION_FINISH events %s %s %s", key.tabletId, lastFinish, key.seq); lastFinish = key.seq; break; default: throw new IllegalStateException("Non compaction event seen " + key.event); } lastEvent = key.event; } if (lastEvent == COMPACTION_START && suffixes.contains(getPathSuffix(lastStartFile))) { log.debug("Considering compaction start finished because file in metadata table", tabletId, lastStart, getPathSuffix(lastStartFile)); recoverySeq = lastStart; } else { recoverySeq = Math.max(0, lastFinish - 1); } } return recoverySeq; }