From 8607f7650357aeee329ab4f243f0adad7b2ebd5d Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 20 Feb 2015 18:11:44 +0000 Subject: [PATCH] LUCENE-6266: Remove unnecessary Directory parameters from SIS/SIPC/SI git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1661172 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 ++ .../lucene/index/BufferedUpdatesStream.java | 2 +- .../apache/lucene/index/IndexFileDeleter.java | 8 ++--- .../org/apache/lucene/index/IndexWriter.java | 10 +++--- .../lucene/index/SegmentCommitInfo.java | 15 ++++++-- .../org/apache/lucene/index/SegmentInfo.java | 18 +++++++--- .../org/apache/lucene/index/SegmentInfos.java | 34 +++++++++++++------ .../apache/lucene/index/SegmentReader.java | 2 +- .../lucene/index/StandardDirectoryReader.java | 2 +- .../index/TestDemoParallelLeafReader.java | 2 +- .../lucene/store/MockDirectoryWrapper.java | 2 +- .../org/apache/solr/handler/SnapPuller.java | 2 +- 12 files changed, 67 insertions(+), 33 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index ae2f9f98228..167649c7841 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -134,6 +134,9 @@ API Changes * LUCENE-6268: Replace FieldValueFilter and DocValuesRangeFilter with equivalent queries that support approximations. (Adrien Grand) +* LUCENE-6266: Remove unnecessary Directory params from SegmentInfo.toString, + SegmentInfos.files/toString, and SegmentCommitInfo.toString. (Robert Muir) + Other * LUCENE-6248: Remove unused odd constants from StandardSyntaxParser.jj diff --git a/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java b/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java index 4f8c9b5101a..e78533989f9 100644 --- a/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java +++ b/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java @@ -334,7 +334,7 @@ class BufferedUpdatesStream implements Accountable { } else { dir = null; } - infoStream.message("BD", "prune sis=" + segmentInfos.toString(dir) + " minGen=" + minGen + " packetCount=" + updates.size()); + infoStream.message("BD", "prune sis=" + segmentInfos + " minGen=" + minGen + " packetCount=" + updates.size()); } final int limit = updates.size(); for(int delIDX=0;delIDX getIndexFileNames() throws IOException { - return segmentInfos.files(directory, true); + return segmentInfos.files(true); } // for test purpose @@ -2689,7 +2689,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { // we are trying to sync all referenced files, a // merge completes which would otherwise have // removed the files we are now syncing. - filesToCommit = toCommit.files(directory, false); + filesToCommit = toCommit.files(false); deleter.incRef(filesToCommit); } success = true; @@ -4137,7 +4137,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { * * @lucene.internal */ public synchronized String segString(SegmentCommitInfo info) { - return info.toString(info.info.dir, numDeletedDocs(info) - info.getDelCount()); + return info.toString(numDeletedDocs(info) - info.getDelCount()); } private synchronized void doWait() { @@ -4170,7 +4170,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { // called only from assert private boolean filesExist(SegmentInfos toSync) throws IOException { - Collection files = toSync.files(directory, false); + Collection files = toSync.files(false); for(final String fileName: files) { assert slowFileExists(directory, fileName): "file " + fileName + " does not exist; files=" + Arrays.toString(directory.listAll()); // If this trips it means we are missing a call to @@ -4275,7 +4275,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { boolean success = false; final Collection filesToSync; try { - filesToSync = toSync.files(directory, false); + filesToSync = toSync.files(false); directory.sync(filesToSync); success = true; } finally { diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentCommitInfo.java b/lucene/core/src/java/org/apache/lucene/index/SegmentCommitInfo.java index e12dfad479b..994ffd1d0ca 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentCommitInfo.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentCommitInfo.java @@ -317,10 +317,19 @@ public class SegmentCommitInfo { } this.delCount = delCount; } + + /** + * Returns a description of this segment. + * @deprecated Use {@link #toString(int)} instead. + */ + @Deprecated + public String toString(Directory dir, int pendingDelCount) { + return toString(pendingDelCount); + } /** Returns a description of this segment. */ - public String toString(Directory dir, int pendingDelCount) { - String s = info.toString(dir, delCount + pendingDelCount); + public String toString(int pendingDelCount) { + String s = info.toString(delCount + pendingDelCount); if (delGen != -1) { s += ":delGen=" + delGen; } @@ -335,7 +344,7 @@ public class SegmentCommitInfo { @Override public String toString() { - return toString(info.dir, 0); + return toString(0); } @Override diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java index 6970602edfe..2d445356965 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java @@ -169,7 +169,18 @@ public final class SegmentInfo { @Override public String toString() { - return toString(dir, 0); + return toString(0); + } + + + /** + * Used for debugging. + * + * @deprecated Use {@link #toString(int)} instead. + */ + @Deprecated + public String toString(Directory dir, int delCount) { + return toString(delCount); } /** Used for debugging. Format may suddenly change. @@ -182,15 +193,12 @@ public final class SegmentInfo { * has 45 documents; it has 4 deletions (this part is * left off when there are no deletions).

*/ - public String toString(Directory dir, int delCount) { + public String toString(int delCount) { StringBuilder s = new StringBuilder(); s.append(name).append('(').append(version == null ? "?" : version).append(')').append(':'); char cfs = getUseCompoundFile() ? 'c' : 'C'; s.append(cfs); - if (this.dir != dir) { - s.append('x'); - } s.append(docCount); if (delCount != 0) { diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java index b92bfe99133..5a211953ae9 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java @@ -621,13 +621,20 @@ public final class SegmentInfos implements Cloneable, Iterable files(Directory dir, boolean includeSegmentsFile) throws IOException { + return files(includeSegmentsFile); + } - /** Returns all file names referenced by SegmentInfo - * instances matching the provided Directory (ie files - * associated with any "external" segments are skipped). + /** Returns all file names referenced by SegmentInfo. * The returned collection is recomputed on each * invocation. */ - public Collection files(Directory dir, boolean includeSegmentsFile) throws IOException { + public Collection files(boolean includeSegmentsFile) throws IOException { HashSet files = new HashSet<>(); if (includeSegmentsFile) { final String segmentFileName = getSegmentsFileName(); @@ -638,10 +645,7 @@ public final class SegmentInfos implements Cloneable, Iterable