lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r892457 - in /lucene/java/trunk/src/java/org/apache/lucene/index: DirectoryReader.java IndexReader.java IndexWriter.java MergePolicy.java SegmentInfo.java SegmentInfos.java SegmentReader.java
Date Sat, 19 Dec 2009 10:45:01 GMT
Author: mikemccand
Date: Sat Dec 19 10:45:00 2009
New Revision: 892457

URL: http://svn.apache.org/viewvc?rev=892457&view=rev
Log:
LUCENE-1923: further improvements to IndexReader.toString

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/trunk/src/java/org/apache/lucene/index/MergePolicy.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java?rev=892457&r1=892456&r2=892457&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java Sat Dec 19 10:45:00
2009
@@ -302,8 +302,17 @@
   /** {@inheritDoc} */
   @Override
   public String toString() {
-    final SegmentInfos infos = writer != null ? segmentInfosStart : segmentInfos;
-    return "DirectoryReader(" + infos.toString(directory) + ")";
+    final StringBuilder buffer = new StringBuilder();
+    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) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java?rev=892457&r1=892456&r2=892457&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java Sat Dec 19 10:45:00
2009
@@ -148,13 +148,17 @@
   /** {@inheritDoc} */
   @Override
   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('(');
     final IndexReader[] subReaders = getSequentialSubReaders();
     if ((subReaders != null) && (subReaders.length > 0)) {
       buffer.append(subReaders[0]);
       for (int i = 1; i < subReaders.length; ++i) {
-        buffer.append(", ").append(subReaders[i]);
+        buffer.append(" ").append(subReaders[i]);
       }
     }
     buffer.append(')');

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java?rev=892457&r1=892456&r2=892457&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java Sat Dec 19 10:45:00
2009
@@ -4484,7 +4484,7 @@
         buffer.append(' ');
       }
       final SegmentInfo info = infos.info(i);
-      buffer.append(info.toString(directory));
+      buffer.append(info.toString(directory, 0));
       if (info.dir != directory)
         buffer.append("**");
     }

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/MergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/MergePolicy.java?rev=892457&r1=892456&r2=892457&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/MergePolicy.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/MergePolicy.java Sat Dec 19 10:45:00
2009
@@ -127,7 +127,7 @@
       final int numSegments = segments.size();
       for(int i=0;i<numSegments;i++) {
         if (i > 0) b.append(' ');
-        b.append(segments.info(i).toString(dir));
+        b.append(segments.info(i).toString(dir, 0));
       }
       if (info != null)
         b.append(" into ").append(info.name);

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java?rev=892457&r1=892456&r2=892457&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java Sat Dec 19 10:45:00
2009
@@ -681,7 +681,7 @@
   /** {@inheritDoc} */
   @Override
   public String toString() {
-    return toString(dir);
+    return toString(dir, 0);
   }
 
   /** Used for debugging.  Format may suddenly change.
@@ -695,7 +695,7 @@
    *  shared doc stores named <code>_1</code> (this part is
    *  left off if doc stores are private).</p>
    */
-  public String toString(Directory dir) {
+  public String toString(Directory dir, int pendingDelCount) {
 
     StringBuilder s = new StringBuilder();
     s.append(name).append(':');
@@ -723,6 +723,9 @@
     } catch (IOException ioe) {
       delCount = -1;
     }
+    if (delCount != -1) {
+      delCount += pendingDelCount;
+    }
     if (delCount != 0) {
       s.append('/');
       if (delCount == -1) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java?rev=892457&r1=892456&r2=892457&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java Sat Dec 19 10:45:00
2009
@@ -876,7 +876,7 @@
         buffer.append(' ');
       }
       final SegmentInfo info = info(i);
-      buffer.append(info.toString(directory));
+      buffer.append(info.toString(directory, 0));
     }
     return buffer.toString();
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java?rev=892457&r1=892456&r2=892457&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Sat Dec 19 10:45:00
2009
@@ -682,10 +682,10 @@
       clone.readOnly = openReadOnly;
       clone.si = si;
       clone.readBufferSize = readBufferSize;
+      clone.pendingDeleteCount = pendingDeleteCount;
 
       if (!openReadOnly && hasChanges) {
         // My pending changes transfer to the new reader
-        clone.pendingDeleteCount = pendingDeleteCount;
         clone.deletedDocsDirty = deletedDocsDirty;
         clone.normsDirty = normsDirty;
         clone.hasChanges = hasChanges;
@@ -1201,7 +1201,12 @@
   /** {@inheritDoc} */
   @Override
   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();
   }
 
   /**



Mime
View raw message