mirror of https://github.com/apache/lucene.git
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:
parent
03c67fece3
commit
a6c26f84a8
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue