mirror of https://github.com/apache/lucene.git
LUCENE-1923: further improvements to IndexReader.toString
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@892457 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
16eaa6198f
commit
9892d10205
|
@ -302,8 +302,17 @@ class DirectoryReader extends IndexReader implements Cloneable {
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final SegmentInfos infos = writer != null ? segmentInfosStart : segmentInfos;
|
final StringBuilder buffer = new StringBuilder();
|
||||||
return "DirectoryReader(" + infos.toString(directory) + ")";
|
if (hasChanges) {
|
||||||
|
buffer.append("*");
|
||||||
|
}
|
||||||
|
buffer.append(getClass().getSimpleName());
|
||||||
|
buffer.append('(');
|
||||||
|
for(SegmentReader r : subReaders) {
|
||||||
|
buffer.append(r);
|
||||||
|
}
|
||||||
|
buffer.append(')');
|
||||||
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(SegmentReader[] subReaders) {
|
private void initialize(SegmentReader[] subReaders) {
|
||||||
|
|
|
@ -148,13 +148,17 @@ public abstract class IndexReader implements Cloneable,Closeable {
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
|
final StringBuilder buffer = new StringBuilder();
|
||||||
|
if (hasChanges) {
|
||||||
|
buffer.append('*');
|
||||||
|
}
|
||||||
|
buffer.append(getClass().getSimpleName());
|
||||||
buffer.append('(');
|
buffer.append('(');
|
||||||
final IndexReader[] subReaders = getSequentialSubReaders();
|
final IndexReader[] subReaders = getSequentialSubReaders();
|
||||||
if ((subReaders != null) && (subReaders.length > 0)) {
|
if ((subReaders != null) && (subReaders.length > 0)) {
|
||||||
buffer.append(subReaders[0]);
|
buffer.append(subReaders[0]);
|
||||||
for (int i = 1; i < subReaders.length; ++i) {
|
for (int i = 1; i < subReaders.length; ++i) {
|
||||||
buffer.append(", ").append(subReaders[i]);
|
buffer.append(" ").append(subReaders[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer.append(')');
|
buffer.append(')');
|
||||||
|
|
|
@ -4484,7 +4484,7 @@ public class IndexWriter implements Closeable {
|
||||||
buffer.append(' ');
|
buffer.append(' ');
|
||||||
}
|
}
|
||||||
final SegmentInfo info = infos.info(i);
|
final SegmentInfo info = infos.info(i);
|
||||||
buffer.append(info.toString(directory));
|
buffer.append(info.toString(directory, 0));
|
||||||
if (info.dir != directory)
|
if (info.dir != directory)
|
||||||
buffer.append("**");
|
buffer.append("**");
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public abstract class MergePolicy implements java.io.Closeable {
|
||||||
final int numSegments = segments.size();
|
final int numSegments = segments.size();
|
||||||
for(int i=0;i<numSegments;i++) {
|
for(int i=0;i<numSegments;i++) {
|
||||||
if (i > 0) b.append(' ');
|
if (i > 0) b.append(' ');
|
||||||
b.append(segments.info(i).toString(dir));
|
b.append(segments.info(i).toString(dir, 0));
|
||||||
}
|
}
|
||||||
if (info != null)
|
if (info != null)
|
||||||
b.append(" into ").append(info.name);
|
b.append(" into ").append(info.name);
|
||||||
|
|
|
@ -681,7 +681,7 @@ public final class SegmentInfo {
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toString(dir);
|
return toString(dir, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used for debugging. Format may suddenly change.
|
/** Used for debugging. Format may suddenly change.
|
||||||
|
@ -695,7 +695,7 @@ public final class SegmentInfo {
|
||||||
* shared doc stores named <code>_1</code> (this part is
|
* shared doc stores named <code>_1</code> (this part is
|
||||||
* left off if doc stores are private).</p>
|
* left off if doc stores are private).</p>
|
||||||
*/
|
*/
|
||||||
public String toString(Directory dir) {
|
public String toString(Directory dir, int pendingDelCount) {
|
||||||
|
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
s.append(name).append(':');
|
s.append(name).append(':');
|
||||||
|
@ -723,6 +723,9 @@ public final class SegmentInfo {
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
delCount = -1;
|
delCount = -1;
|
||||||
}
|
}
|
||||||
|
if (delCount != -1) {
|
||||||
|
delCount += pendingDelCount;
|
||||||
|
}
|
||||||
if (delCount != 0) {
|
if (delCount != 0) {
|
||||||
s.append('/');
|
s.append('/');
|
||||||
if (delCount == -1) {
|
if (delCount == -1) {
|
||||||
|
|
|
@ -876,7 +876,7 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
||||||
buffer.append(' ');
|
buffer.append(' ');
|
||||||
}
|
}
|
||||||
final SegmentInfo info = info(i);
|
final SegmentInfo info = info(i);
|
||||||
buffer.append(info.toString(directory));
|
buffer.append(info.toString(directory, 0));
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,10 +682,10 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
||||||
clone.readOnly = openReadOnly;
|
clone.readOnly = openReadOnly;
|
||||||
clone.si = si;
|
clone.si = si;
|
||||||
clone.readBufferSize = readBufferSize;
|
clone.readBufferSize = readBufferSize;
|
||||||
|
clone.pendingDeleteCount = pendingDeleteCount;
|
||||||
|
|
||||||
if (!openReadOnly && hasChanges) {
|
if (!openReadOnly && hasChanges) {
|
||||||
// My pending changes transfer to the new reader
|
// My pending changes transfer to the new reader
|
||||||
clone.pendingDeleteCount = pendingDeleteCount;
|
|
||||||
clone.deletedDocsDirty = deletedDocsDirty;
|
clone.deletedDocsDirty = deletedDocsDirty;
|
||||||
clone.normsDirty = normsDirty;
|
clone.normsDirty = normsDirty;
|
||||||
clone.hasChanges = hasChanges;
|
clone.hasChanges = hasChanges;
|
||||||
|
@ -1201,7 +1201,12 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return si.toString();
|
final StringBuilder buffer = new StringBuilder();
|
||||||
|
if (hasChanges) {
|
||||||
|
buffer.append('*');
|
||||||
|
}
|
||||||
|
buffer.append(si.toString(core.dir, pendingDeleteCount));
|
||||||
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue