Source:
<code>Pair<SortedMap<Interval, String>, Map<Interval, List<DataSegment>>> checkSegments() { Pair<Map<Interval, String>, Map<Interval, List<DataSegment>>> derivativeSegmentsSnapshot = getVersionAndBaseSegments( metadataStorageCoordinator.getUsedSegmentsForInterval( dataSource, ALL_INTERVAL ) ); Pair<Map<Interval, String>, Map<Interval, List<DataSegment>>> baseSegmentsSnapshot = getMaxCreateDateAndBaseSegments( metadataStorageCoordinator.getUsedSegmentAndCreatedDateForInterval( spec.getBaseDataSource(), ALL_INTERVAL ) ); Map<Interval, List<DataSegment>> baseSegments = baseSegmentsSnapshot.rhs; Map<Interval, List<DataSegment>> derivativeSegments = derivativeSegmentsSnapshot.rhs; Map<Interval, String> maxCreatedDate = baseSegmentsSnapshot.lhs; Map<Interval, String> derivativeVersion = derivativeSegmentsSnapshot.lhs; SortedMap<Interval, String> sortedToBuildInterval = new TreeMap<>(Comparators.intervalsByStartThenEnd().reversed()); MapDifference<Interval, String> difference = Maps.difference(maxCreatedDate, derivativeVersion); Map<Interval, String> toBuildInterval = new HashMap<>(difference.entriesOnlyOnLeft()); Map<Interval, String> toDropInterval = new HashMap<>(difference.entriesOnlyOnRight()); <START> for (Map.Entry<Interval, String> entry : runningVersion.entrySet()) { <END> Interval interval = entry.getKey(); if (toBuildInterval.containsKey(interval) && toBuildInterval.get(interval).equals(runningVersion.get(interval)) ) { toBuildInterval.remove(interval); } else if ( toBuildInterval.containsKey(interval) && !toBuildInterval.get(interval).equals(runningVersion.get(interval)) ) { if (taskMaster.getTaskQueue().isPresent()) { taskMaster.getTaskQueue().get().shutdown(runningTasks.get(interval).getId(), "version mismatch"); runningTasks.remove(interval); } } } for (Map.Entry<Interval, String> entry : toDropInterval.entrySet()) { Interval interval = entry.getKey(); for (DataSegment segment : derivativeSegments.get(interval)) { segmentManager.removeSegment(segment.getId()); } } sortedToBuildInterval.putAll(toBuildInterval); return new Pair<>(sortedToBuildInterval, baseSegments); }</code><technical_language>purpose of this change</technical_language>

Target:
Pair<SortedMap<Interval, String>, Map<Interval, List<DataSegment>>> checkSegments() { Pair<Map<Interval, String>, Map<Interval, List<DataSegment>>> derivativeSegmentsSnapshot = getVersionAndBaseSegments( metadataStorageCoordinator.getUsedSegmentsForInterval( dataSource, ALL_INTERVAL ) ); Pair<Map<Interval, String>, Map<Interval, List<DataSegment>>> baseSegmentsSnapshot = getMaxCreateDateAndBaseSegments( metadataStorageCoordinator.getUsedSegmentAndCreatedDateForInterval( spec.getBaseDataSource(), ALL_INTERVAL ) ); Map<Interval, List<DataSegment>> baseSegments = baseSegmentsSnapshot.rhs; Map<Interval, List<DataSegment>> derivativeSegments = derivativeSegmentsSnapshot.rhs; Map<Interval, String> maxCreatedDate = baseSegmentsSnapshot.lhs; Map<Interval, String> derivativeVersion = derivativeSegmentsSnapshot.lhs; SortedMap<Interval, String> sortedToBuildInterval = new TreeMap<>(Comparators.intervalsByStartThenEnd().reversed()); MapDifference<Interval, String> difference = Maps.difference(maxCreatedDate, derivativeVersion); Map<Interval, String> toBuildInterval = new HashMap<>(difference.entriesOnlyOnLeft()); Map<Interval, String> toDropInterval = new HashMap<>(difference.entriesOnlyOnRight()); for (Interval interval : runningVersion.keySet()) { if (toBuildInterval.containsKey(interval) && toBuildInterval.get(interval).equals(runningVersion.get(interval)) ) { toBuildInterval.remove(interval); } else if ( toBuildInterval.containsKey(interval) && !toBuildInterval.get(interval).equals(runningVersion.get(interval)) ) { if (taskMaster.getTaskQueue().isPresent()) { taskMaster.getTaskQueue().get().shutdown(runningTasks.get(interval).getId(), "version mismatch"); runningTasks.remove(interval); } } } for (Interval interval : toDropInterval.keySet()) { for (DataSegment segment : derivativeSegments.get(interval)) { segmentManager.removeSegment(segment.getId()); } } sortedToBuildInterval.putAll(toBuildInterval); return new Pair<>(sortedToBuildInterval, baseSegments); }