mirror of https://github.com/apache/lucene.git
LUCENE-1339: make IndexReader incRef and decRef expert public methods
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@678716 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7198ead131
commit
7c842e3c34
|
@ -102,23 +102,38 @@ public abstract class IndexReader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Increments the refCount of this IndexReader instance. RefCounts are used to determine
|
||||
* when a reader can be closed safely, i. e. as soon as no other IndexReader is referencing
|
||||
* it anymore.
|
||||
* Expert: increments the refCount of this IndexReader
|
||||
* instance. RefCounts are used to determine when a
|
||||
* reader can be closed safely, i.e. as soon as there are
|
||||
* no more references. Be sure to always call a
|
||||
* corresponding {@link #decRef}, in a finally clause;
|
||||
* otherwise the reader may never be closed. Note that
|
||||
* {@link #close} simply calls decRef(), which means that
|
||||
* the IndexReader will not really be closed until {@link
|
||||
* #decRef} has been called for all outstanding
|
||||
* references.
|
||||
*
|
||||
* @see #decRef
|
||||
*/
|
||||
protected synchronized void incRef() {
|
||||
public synchronized void incRef() {
|
||||
assert refCount > 0;
|
||||
ensureOpen();
|
||||
refCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decreases the refCount of this IndexReader instance. If the refCount drops
|
||||
* to 0, then pending changes are committed to the index and this reader is closed.
|
||||
* Expert: decreases the refCount of this IndexReader
|
||||
* instance. If the refCount drops to 0, then pending
|
||||
* changes (if any) are committed to the index and this
|
||||
* reader is closed.
|
||||
*
|
||||
* @throws IOException in case an IOException occurs in commit() or doClose()
|
||||
*
|
||||
* @see #incRef
|
||||
*/
|
||||
protected synchronized void decRef() throws IOException {
|
||||
public synchronized void decRef() throws IOException {
|
||||
assert refCount > 0;
|
||||
ensureOpen();
|
||||
if (refCount == 1) {
|
||||
commit();
|
||||
doClose();
|
||||
|
|
|
@ -138,7 +138,7 @@ class SegmentReader extends DirectoryIndexReader {
|
|||
* Increments the RC of this reader, as well as
|
||||
* of all norms this reader is using
|
||||
*/
|
||||
protected synchronized void incRef() {
|
||||
public synchronized void incRef() {
|
||||
super.incRef();
|
||||
Iterator it = norms.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
|
@ -157,7 +157,7 @@ class SegmentReader extends DirectoryIndexReader {
|
|||
super.incRef();
|
||||
}
|
||||
|
||||
protected synchronized void decRef() throws IOException {
|
||||
public synchronized void decRef() throws IOException {
|
||||
super.decRef();
|
||||
Iterator it = norms.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
|
|
Loading…
Reference in New Issue