Source:
<code>private void setupState() throws InterruptedException, IOException, StoreException { CompactionDetails details = compactionLog.getCompactionDetails(); long highestGeneration = 0; for (String segmentName : details.getLogSegmentsUnderCompaction()) { highestGeneration = Math.max(highestGeneration, LogSegmentNameHelper.getGeneration(segmentName)); } List<Pair<String, String>> targetSegmentNamesAndFilenames = new ArrayList<>(); List<LogSegment> existingTargetLogSegments = new ArrayList<>(); for (String segmentName : details.getLogSegmentsUnderCompaction()) { long pos = LogSegmentNameHelper.getPosition(segmentName); String targetSegmentName = LogSegmentNameHelper.getName(pos, highestGeneration + 1); String targetSegmentFileName = LogSegmentNameHelper.nameToFilename(targetSegmentName) + TEMP_LOG_SEGMENT_NAME_SUFFIX; File targetSegmentFile = new File(dataDir, targetSegmentFileName); if (targetSegmentFile.exists()) { existingTargetLogSegments.add(new LogSegment(targetSegmentName, targetSegmentFile, metrics)); } else { targetSegmentNamesAndFilenames.add(new Pair<>(targetSegmentName, targetSegmentFileName)); } } long targetLogTotalCapacity = srcLog.getSegmentCapacity(); tgtLog = new Log(dataDir.getAbsolutePath(), targetLogTotalCapacity, srcLog.getSegmentCapacity(), metrics, true, existingTargetLogSegments, targetSegmentNamesAndFilenames.iterator()); Journal journal = new Journal(dataDir.getAbsolutePath(), 2 * config.storeIndexMaxNumberOfInmemElements, config.storeMaxNumberOfEntriesToReturnFromJournal); tgtIndex = new PersistentIndex(dataDir.getAbsolutePath(), scheduler, tgtLog, config, storeKeyFactory, recovery, null, metrics, journal, time, sessionId, incarnationId, TARGET_INDEX_CLEAN_SHUTDOWN_FILE_NAME); if (srcIndex.hardDeleter != null && !srcIndex.hardDeleter.isPaused()) { srcIndex.hardDeleter.pause(); } <START> } <END></code><technical_language>define a private method called getSwapSpaces(SegmentCapacity) return 1 for one. change impl DiskManager segment pooling</technical_language>

Target:
private void setupState() throws InterruptedException, IOException, StoreException { CompactionDetails details = compactionLog.getCompactionDetails(); long highestGeneration = 0; for (String segmentName : details.getLogSegmentsUnderCompaction()) { highestGeneration = Math.max(highestGeneration, LogSegmentNameHelper.getGeneration(segmentName)); } List<Pair<String, String>> targetSegmentNamesAndFilenames = new ArrayList<>(); List<LogSegment> existingTargetLogSegments = new ArrayList<>(); for (String segmentName : details.getLogSegmentsUnderCompaction()) { long pos = LogSegmentNameHelper.getPosition(segmentName); String targetSegmentName = LogSegmentNameHelper.getName(pos, highestGeneration + 1); String targetSegmentFileName = LogSegmentNameHelper.nameToFilename(targetSegmentName) + TEMP_LOG_SEGMENT_NAME_SUFFIX; File targetSegmentFile = new File(dataDir, targetSegmentFileName); if (targetSegmentFile.exists()) { existingTargetLogSegments.add(new LogSegment(targetSegmentName, targetSegmentFile, tgtMetrics)); } else { targetSegmentNamesAndFilenames.add(new Pair<>(targetSegmentName, targetSegmentFileName)); } } long targetLogTotalCapacity = srcLog.getSegmentCapacity(); tgtLog = new Log(dataDir.getAbsolutePath(), targetLogTotalCapacity, srcLog.getSegmentCapacity(), tgtMetrics, true, existingTargetLogSegments, targetSegmentNamesAndFilenames.iterator()); Journal journal = new Journal(dataDir.getAbsolutePath(), 2 * config.storeIndexMaxNumberOfInmemElements, config.storeMaxNumberOfEntriesToReturnFromJournal); tgtIndex = new PersistentIndex(dataDir.getAbsolutePath(), scheduler, tgtLog, config, storeKeyFactory, recovery, null, tgtMetrics, journal, time, sessionId, incarnationId, TARGET_INDEX_CLEAN_SHUTDOWN_FILE_NAME); if (srcIndex.hardDeleter != null && !srcIndex.hardDeleter.isPaused()) { srcIndex.hardDeleter.pause(); } }