diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index fc3e37513c7..15ad31fbbf1 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -55,6 +55,12 @@ API Changes
* LUCENE-4307: Renamed IndexReader.getTopReaderContext to
IndexReader.getContext. (Robert Muir)
+* LUCENE-4316: Deprecate Fields.getUniqueTermCount and remove it from
+ AtomicReader. If you really want the unique term count across all
+ fields, just sum up Terms.size() across those fields. This method
+ only exists so that this statistic can be accessed for Lucene 3.x
+ segments, which don't support Terms.size(). (Uwe Schindler, Robert Muir)
+
Bug Fixes
* LUCENE-4297: BooleanScorer2 would multiply the coord() factor
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java
index 22d78b809fb..35d4a8ee501 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java
@@ -211,10 +211,6 @@ public class BloomFilteringPostingsFormat extends PostingsFormat {
return delegateFieldsProducer.size();
}
- public long getUniqueTermCount() throws IOException {
- return delegateFieldsProducer.getUniqueTermCount();
- }
-
class BloomFilteredTerms extends Terms {
private Terms delegateTerms;
private FuzzySet filter;
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
index fd17b10d68a..98e1a36ae85 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
@@ -144,15 +144,6 @@ public class DirectPostingsFormat extends PostingsFormat {
return fields.size();
}
- @Override
- public long getUniqueTermCount() {
- long numTerms = 0;
- for(DirectField field : fields.values()) {
- numTerms += field.terms.length;
- }
- return numTerms;
- }
-
@Override
public void close() {
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java b/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java
index a2ef5efbb73..2192447ba48 100644
--- a/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java
+++ b/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java
@@ -175,17 +175,6 @@ public abstract class AtomicReader extends IndexReader {
}
return null;
}
-
- /** Returns the number of unique terms (across all fields)
- * in this reader.
- */
- public final long getUniqueTermCount() throws IOException {
- final Fields fields = fields();
- if (fields == null) {
- return 0;
- }
- return fields.getUniqueTermCount();
- }
/**
* Returns {@link DocValues} for this field.
diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
index 4c8c35071ea..0daf83d1f07 100644
--- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
+++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
@@ -1112,21 +1112,6 @@ public class CheckIndex {
throw new RuntimeException("fieldCount mismatch " + fieldCount + " vs recomputed field count " + computedFieldCount);
}
}
-
- // for most implementations, this is boring (just the sum across all fields)
- // but codecs that don't work per-field like preflex actually implement this,
- // but don't implement it on Terms, so the check isn't redundant.
- long uniqueTermCountAllFields = fields.getUniqueTermCount();
-
- // this means something is seriously screwed, e.g. we are somehow getting enclosed in PFCW!!!!!!
-
- if (uniqueTermCountAllFields == -1) {
- throw new RuntimeException("invalid termCount: -1");
- }
-
- if (status.termCount != uniqueTermCountAllFields) {
- throw new RuntimeException("termCount mismatch " + uniqueTermCountAllFields + " vs " + (status.termCount));
- }
if (doPrint) {
msg("OK [" + status.termCount + " terms; " + status.totFreq + " terms/docs pairs; " + status.totPos + " tokens]");
diff --git a/lucene/core/src/java/org/apache/lucene/index/Fields.java b/lucene/core/src/java/org/apache/lucene/index/Fields.java
index 76af3cf9746..9af477d152b 100644
--- a/lucene/core/src/java/org/apache/lucene/index/Fields.java
+++ b/lucene/core/src/java/org/apache/lucene/index/Fields.java
@@ -38,26 +38,5 @@ public abstract class Fields implements Iterable