mirror of https://github.com/apache/lucene.git
LUCENE-8609: Remove deprecated IW#numDocs() and IW#maxDoc() methdos
This commit is contained in:
parent
e974311d91
commit
5c5c42cc37
|
@ -102,6 +102,9 @@ API Changes
|
||||||
number of gaps between its component sub-intervals. This can be used in a
|
number of gaps between its component sub-intervals. This can be used in a
|
||||||
new filter available via Intervals.maxgaps(). (Alan Woodward)
|
new filter available via Intervals.maxgaps(). (Alan Woodward)
|
||||||
|
|
||||||
|
* LUCENE-8609: Remove IndexWriter#numDocs() and IndexWriter#maxDoc() in favor
|
||||||
|
of IndexWriter#getDocStats(). (Simon Willnauer)
|
||||||
|
|
||||||
Changes in Runtime Behavior
|
Changes in Runtime Behavior
|
||||||
|
|
||||||
* LUCENE-8333: Switch MoreLikeThis.setMaxDocFreqPct to use maxDoc instead of
|
* LUCENE-8333: Switch MoreLikeThis.setMaxDocFreqPct to use maxDoc instead of
|
||||||
|
|
|
@ -158,3 +158,9 @@ constant factor was removed from the numerator of the scoring formula.
|
||||||
Ordering of results is preserved unless scores are computed from multiple
|
Ordering of results is preserved unless scores are computed from multiple
|
||||||
fields using different similarities. The previous behaviour is now exposed
|
fields using different similarities. The previous behaviour is now exposed
|
||||||
by the LegacyBM25Similarity class which can be found in the lucene-misc jar.
|
by the LegacyBM25Similarity class which can be found in the lucene-misc jar.
|
||||||
|
|
||||||
|
## IndexWriter#maxDoc()/#numDocs() removed in favor of IndexWriter#getDocStats() ##
|
||||||
|
|
||||||
|
IndexWriter#getDocStats() should be used instead of #maxDoc() / #numDocs() which offers a consistent
|
||||||
|
view on document stats. Previously calling two methods in order ot get point in time stats was subject
|
||||||
|
to concurrent changes.
|
||||||
|
|
|
@ -1131,18 +1131,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable,
|
||||||
return analyzer;
|
return analyzer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns total number of docs in this index, including
|
|
||||||
* docs not yet flushed (still in the RAM buffer),
|
|
||||||
* not counting deletions.
|
|
||||||
* @see #numDocs
|
|
||||||
* @deprecated use {@link #getDocStats()} instead
|
|
||||||
* */
|
|
||||||
@Deprecated
|
|
||||||
public synchronized int maxDoc() {
|
|
||||||
ensureOpen();
|
|
||||||
return docWriter.getNumDocs() + segmentInfos.totalMaxDoc();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** If {@link SegmentInfos#getVersion} is below {@code newVersion} then update it to this value.
|
/** If {@link SegmentInfos#getVersion} is below {@code newVersion} then update it to this value.
|
||||||
*
|
*
|
||||||
* @lucene.internal */
|
* @lucene.internal */
|
||||||
|
@ -1154,24 +1142,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable,
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns total number of docs in this index, including
|
|
||||||
* docs not yet flushed (still in the RAM buffer), and
|
|
||||||
* including deletions. <b>NOTE:</b> buffered deletions
|
|
||||||
* are not counted. If you really need these to be
|
|
||||||
* counted you should call {@link #commit()} first.
|
|
||||||
* @see #maxDoc
|
|
||||||
* @deprecated use {@link #getDocStats()} instead
|
|
||||||
* */
|
|
||||||
@Deprecated
|
|
||||||
public synchronized int numDocs() {
|
|
||||||
ensureOpen();
|
|
||||||
int count = docWriter.getNumDocs();
|
|
||||||
for (final SegmentCommitInfo info : segmentInfos) {
|
|
||||||
count += info.info.maxDoc() - numDeletedDocs(info);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this index has deletions (including
|
* Returns true if this index has deletions (including
|
||||||
* buffered deletions). Note that this will return true
|
* buffered deletions). Note that this will return true
|
||||||
|
@ -5297,9 +5267,8 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns accurate {@link DocStats} form this writer. This is equivalent to calling {@link #numDocs()} and {@link #maxDoc()}
|
* Returns accurate {@link DocStats} form this writer. The numDoc for instance can change after maxDoc is fetched
|
||||||
* but is not subject to race-conditions. The numDoc for instance can change after maxDoc is fetched that causes numDocs to be
|
* that causes numDocs to be greater than maxDoc which makes it hard to get accurate document stats from IndexWriter.
|
||||||
* greater than maxDoc which makes it hard to get accurate document stats from IndexWriter.
|
|
||||||
*/
|
*/
|
||||||
public synchronized DocStats getDocStats() {
|
public synchronized DocStats getDocStats() {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
|
|
Loading…
Reference in New Issue