LUCENE-5969: move blocktree stats -> stats api

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5969@1633441 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2014-10-21 19:49:24 +00:00
parent 03c67fece3
commit a6c26f84a8
9 changed files with 24 additions and 12 deletions

View File

@ -123,8 +123,7 @@ final class Lucene40FieldReader extends Terms implements Accountable {
}
/** For debugging -- used by CheckIndex too*/
// TODO: maybe push this into Terms?
public Lucene40Stats computeStats() throws IOException {
public Lucene40Stats getStats() throws IOException {
return new Lucene40SegmentTermsEnum(this).computeBlockStats();
}

View File

@ -29,7 +29,7 @@ import org.apache.lucene.util.IOUtils;
/**
* BlockTree statistics for a single field
* returned by {@link Lucene40FieldReader#computeStats()}.
* returned by {@link Lucene40FieldReader#getStats()}.
* @deprecated Only for 4.x backcompat
*/
@Deprecated

View File

@ -57,7 +57,7 @@ public class TestLucene40BlockFormat extends BasePostingsFormatTestCase {
assertEquals(1, r.leaves().size());
Lucene40FieldReader field = (Lucene40FieldReader) r.leaves().get(0).reader().fields().terms("field");
// We should see exactly two blocks: one root block (prefix empty string) and one block for z* terms (prefix z):
Lucene40Stats stats = field.computeStats();
Lucene40Stats stats = field.getStats();
assertEquals(0, stats.floorBlockCount);
assertEquals(2, stats.nonFloorBlockCount);
r.close();

View File

@ -120,8 +120,7 @@ public final class FieldReader extends Terms implements Accountable {
}
/** For debugging -- used by CheckIndex too*/
// TODO: maybe push this into Terms?
public Stats computeStats() throws IOException {
public Stats getStats() throws IOException {
return new SegmentTermsEnum(this).computeBlockStats();
}

View File

@ -29,7 +29,7 @@ import org.apache.lucene.util.IOUtils;
/**
* BlockTree statistics for a single field
* returned by {@link FieldReader#computeStats()}.
* returned by {@link FieldReader#getStats()}.
*/
public class Stats {
/** How many nodes in the index FST. */

View File

@ -151,6 +151,11 @@ public class FilterLeafReader extends LeafReader {
public boolean hasPayloads() {
return in.hasPayloads();
}
@Override
public Object getStats() throws IOException {
return in.getStats();
}
}
/** Base class for filtering {@link TermsEnum} implementations. */

View File

@ -194,8 +194,17 @@ public abstract class Terms {
}
}
public String getStats() {
// nocommit: add a meaningful default
return "";
/**
* Expert: returns additional information about this Terms instance
* for debugging purposes.
*/
public Object getStats() throws IOException {
StringBuilder sb = new StringBuilder();
sb.append("impl=" + getClass().getSimpleName());
sb.append(",size=" + size());
sb.append(",docCount=" + getDocCount());
sb.append(",sumTotalTermFreq=" + getSumTotalTermFreq());
sb.append(",sumDocFreq=" + getSumDocFreq());
return sb.toString();
}
}

View File

@ -57,7 +57,7 @@ public class TestBlockPostingsFormat extends BasePostingsFormatTestCase {
assertEquals(1, r.leaves().size());
FieldReader field = (FieldReader) r.leaves().get(0).reader().fields().terms("field");
// We should see exactly two blocks: one root block (prefix empty string) and one block for z* terms (prefix z):
Stats stats = field.computeStats();
Stats stats = field.getStats();
assertEquals(0, stats.floorBlockCount);
assertEquals(2, stats.nonFloorBlockCount);
r.close();

View File

@ -166,7 +166,7 @@ public class TestFilterLeafReader extends LuceneTestCase {
for (Method m : superClazz.getMethods()) {
final int mods = m.getModifiers();
if (Modifier.isStatic(mods) || Modifier.isAbstract(mods) || Modifier.isFinal(mods) || m.isSynthetic()
|| m.getName().equals("attributes")) {
|| m.getName().equals("attributes") || m.getName().equals("getStats")) {
continue;
}
// The point of these checks is to ensure that methods that have a default