Source:
<code>private void removeFiles(String location, ValidWriteIdList writeIdList, CompactionInfo ci) throws IOException, HiveException { Path locPath = new Path(location); AcidUtils.Directory dir = AcidUtils.getAcidState(locPath, conf, writeIdList); List<FileStatus> obsoleteDirs = dir.getObsolete(); List<Path> filesToDelete = new ArrayList<Path>(obsoleteDirs.size()); StringBuilder extraDebugInfo = new StringBuilder("["); for (FileStatus stat : obsoleteDirs) { filesToDelete.add(stat.getPath()); extraDebugInfo.append(stat.getPath().getName()).append(","); if(!FileUtils.isPathWithinSubtree(stat.getPath(), locPath)) { LOG.info(idWatermark(ci) + " found unexpected file: " + stat.getPath()); } } extraDebugInfo.setCharAt(extraDebugInfo.length() - 1, ']'); List<Long> compactIds = new ArrayList<>(compactId2CompactInfoMap.keySet()); Collections.sort(compactIds); extraDebugInfo.append("compactId2CompactInfoMap.keySet(").append(compactIds).append(")"); LOG.info(idWatermark(ci) + " About to remove " + filesToDelete.size() + " obsolete directories from " + location + ". " + extraDebugInfo.toString()); if (filesToDelete.size() < 1) { LOG.warn("Hmm, nothing to delete in the cleaner for directory " + location + ", that hardly seems right."); return; } FileSystem fs = filesToDelete.get(0).getFileSystem(conf); for (Path dead : filesToDelete) { LOG.debug("Going to delete path " + dead.toString()); <START> if (ReplChangeManager.isReplPolicySet(Hive.get().getDatabase(ci.dbname))) { <END> replChangeManager.recycle(dead, ReplChangeManager.RecycleType.MOVE, true); } fs.delete(dead, true); } }</code><technical_language>get database object loop store in local variable</technical_language>

Target:
private void removeFiles(String location, ValidWriteIdList writeIdList, CompactionInfo ci) throws IOException, HiveException { Path locPath = new Path(location); AcidUtils.Directory dir = AcidUtils.getAcidState(locPath, conf, writeIdList); List<FileStatus> obsoleteDirs = dir.getObsolete(); List<Path> filesToDelete = new ArrayList<Path>(obsoleteDirs.size()); StringBuilder extraDebugInfo = new StringBuilder("["); for (FileStatus stat : obsoleteDirs) { filesToDelete.add(stat.getPath()); extraDebugInfo.append(stat.getPath().getName()).append(","); if(!FileUtils.isPathWithinSubtree(stat.getPath(), locPath)) { LOG.info(idWatermark(ci) + " found unexpected file: " + stat.getPath()); } } extraDebugInfo.setCharAt(extraDebugInfo.length() - 1, ']'); List<Long> compactIds = new ArrayList<>(compactId2CompactInfoMap.keySet()); Collections.sort(compactIds); extraDebugInfo.append("compactId2CompactInfoMap.keySet(").append(compactIds).append(")"); LOG.info(idWatermark(ci) + " About to remove " + filesToDelete.size() + " obsolete directories from " + location + ". " + extraDebugInfo.toString()); if (filesToDelete.size() < 1) { LOG.warn("Hmm, nothing to delete in the cleaner for directory " + location + ", that hardly seems right."); return; } FileSystem fs = filesToDelete.get(0).getFileSystem(conf); Database db = Hive.get().getDatabase(ci.dbname); for (Path dead : filesToDelete) { LOG.debug("Going to delete path " + dead.toString()); if (ReplChangeManager.isSourceOfReplication(db)) { replChangeManager.recycle(dead, ReplChangeManager.RecycleType.MOVE, true); } fs.delete(dead, true); } }