Source:
<code>private void copy() throws InterruptedException, IOException, StoreException { setupState(); List<String> logSegmentsUnderCompaction = compactionLog.getCompactionDetails().getLogSegmentsUnderCompaction(); Offset startOffsetOfLastIndexSegmentForDelete = getStartOffsetOfLastIndexSegmentForDelete(); FileSpan duplicateSearchSpan = null; if (compactionLog.getCurrentIdx() > 0) { <START> LogSegment logSegment = srcLog.getSegment(logSegmentsUnderCompaction.get(0)); <END> LogSegment prevSegment = srcLog.getPrevSegment(logSegment); if (prevSegment != null) { Offset startOffset = new Offset(prevSegment.getName(), prevSegment.getStartOffset()); Offset endOffset = new Offset(prevSegment.getName(), prevSegment.getEndOffset()); duplicateSearchSpan = new FileSpan(startOffset, endOffset); } } for (String logSegmentName : logSegmentsUnderCompaction) { LogSegment srcLogSegment = srcLog.getSegment(logSegmentName); Offset logSegmentEndOffset = new Offset(srcLogSegment.getName(), srcLogSegment.getEndOffset()); if (needsCopying(logSegmentEndOffset) && !copyDataByLogSegment(srcLogSegment, duplicateSearchSpan, startOffsetOfLastIndexSegmentForDelete)) { if (isActive) { compactionLog.splitCurrentCycle(logSegmentName); } break; } duplicateSearchSpan = null; } numSwapsUsed = tgtIndex.getLogSegmentCount(); tgtIndex.close(); tgtLog.close(); if (numSwapsUsed > 0) { tgtIndex.getIndexSegments().lastEntry().getValue().map(true); } else { File[] files = dataDir.listFiles(TEMP_LOG_SEGMENTS_FILTER); if (files != null) { for (File file : files) { if (!file.delete()) { throw new IllegalStateException("Could not delete segment file: " + file.getAbsolutePath()); } } } else { throw new StoreException("Could not list temp files in directory: " + dataDir, StoreErrorCodes.Unknown_Error); } } }</code><technical_language>rename this firstLogSegment</technical_language>

Target:
private void copy() throws InterruptedException, IOException, StoreException { setupState(); List<String> logSegmentsUnderCompaction = compactionLog.getCompactionDetails().getLogSegmentsUnderCompaction(); Offset startOffsetOfLastIndexSegmentForDeleteCheck = getStartOffsetOfLastIndexSegmentForDeleteCheck(); FileSpan duplicateSearchSpan = null; if (compactionLog.getCurrentIdx() > 0) { LogSegment firstLogSegment = srcLog.getSegment(logSegmentsUnderCompaction.get(0)); LogSegment prevSegment = srcLog.getPrevSegment(firstLogSegment); if (prevSegment != null) { Offset startOffset = new Offset(prevSegment.getName(), prevSegment.getStartOffset()); Offset endOffset = new Offset(prevSegment.getName(), prevSegment.getEndOffset()); duplicateSearchSpan = new FileSpan(startOffset, endOffset); } } for (String logSegmentName : logSegmentsUnderCompaction) { LogSegment srcLogSegment = srcLog.getSegment(logSegmentName); Offset logSegmentEndOffset = new Offset(srcLogSegment.getName(), srcLogSegment.getEndOffset()); if (needsCopying(logSegmentEndOffset) && !copyDataByLogSegment(srcLogSegment, duplicateSearchSpan, startOffsetOfLastIndexSegmentForDeleteCheck)) { if (isActive) { compactionLog.splitCurrentCycle(logSegmentName); } break; } duplicateSearchSpan = null; } numSwapsUsed = tgtIndex.getLogSegmentCount(); tgtIndex.close(); tgtLog.close(); if (numSwapsUsed > 0) { tgtIndex.getIndexSegments().lastEntry().getValue().map(true); } else { cleanupUnusedTempSegments(); } }