/** Expert: This method is called by {@code IndexReader}s which wrap other readers * (e.g. {@link CompositeReader} or {@link FilterLeafReader}) to register the parent * at the child (this reader) on construction of the parent. When this reader is closed, * it will mark all registered parents as closed, too. The references to parent readers * are weak only, so they can be GCed once they are no longer in use. * @lucene.experimental */ public final void registerParentReader(IndexReader reader) { ensureOpen(); parentReaders.add(reader); }
/** * 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 * @see #tryIncRef */ public final void incRef() { if (!tryIncRef()) { ensureOpen(); } }
/** Expert: remove a previously added {@link ReaderClosedListener}. * * @lucene.experimental */ public final void removeReaderClosedListener(ReaderClosedListener listener) { ensureOpen(); readerClosedListeners.remove(listener); }
/** Expert: adds a {@link ReaderClosedListener}. The * provided listener will be invoked when this reader is closed. * At this point, it is safe for apps to evict this reader from * any caches keyed on {@link #getCombinedCoreAndDeletesKey()}. * * @lucene.experimental */ public final void addReaderClosedListener(ReaderClosedListener listener) { ensureOpen(); readerClosedListeners.add(listener); }
/** Expert: This method is called by {@code IndexReader}s which wrap other readers * (e.g. {@link CompositeReader} or {@link FilterLeafReader}) to register the parent * at the child (this reader) on construction of the parent. When this reader is closed, * it will mark all registered parents as closed, too. The references to parent readers * are weak only, so they can be GCed once they are no longer in use. * @lucene.experimental */ public final void registerParentReader(IndexReader reader) { ensureOpen(); parentReaders.add(reader); }
/** Expert: This method is called by {@code IndexReader}s which wrap other readers * (e.g. {@link CompositeReader} or {@link FilterLeafReader}) to register the parent * at the child (this reader) on construction of the parent. When this reader is closed, * it will mark all registered parents as closed, too. The references to parent readers * are weak only, so they can be GCed once they are no longer in use. * @lucene.experimental */ public final void registerParentReader(IndexReader reader) { ensureOpen(); parentReaders.add(reader); }
/** Expert: adds a {@link ReaderClosedListener}. The * provided listener will be invoked when this reader is closed. * At this point, it is safe for apps to evict this reader from * any caches keyed on {@link #getCombinedCoreAndDeletesKey()}. * * @lucene.experimental */ public final void addReaderClosedListener(ReaderClosedListener listener) { ensureOpen(); readerClosedListeners.add(listener); }
/** Expert: remove a previously added {@link ReaderClosedListener}. * * @lucene.experimental */ public final void removeReaderClosedListener(ReaderClosedListener listener) { ensureOpen(); readerClosedListeners.remove(listener); }
/** Expert: This method is called by {@code IndexReader}s which wrap other readers * (e.g. {@link CompositeReader} or {@link FilterLeafReader}) to register the parent * at the child (this reader) on construction of the parent. When this reader is closed, * it will mark all registered parents as closed, too. The references to parent readers * are weak only, so they can be GCed once they are no longer in use. * @lucene.experimental */ public final void registerParentReader(IndexReader reader) { ensureOpen(); parentReaders.add(reader); }
/** * Returns the directory associated with this index. The Default * implementation returns the directory specified by subclasses when * delegating to the IndexReader(Directory) constructor, or throws an * UnsupportedOperationException if one was not specified. * @throws UnsupportedOperationException if no directory */ public Directory directory() { ensureOpen(); if (null != directory) { return directory; } else { throw new UnsupportedOperationException("This reader does not support this method."); } }
/** * Returns the directory associated with this index. The Default * implementation returns the directory specified by subclasses when * delegating to the IndexReader(Directory) constructor, or throws an * UnsupportedOperationException if one was not specified. * @throws UnsupportedOperationException if no directory */ public Directory directory() { ensureOpen(); if (null != directory) { return directory; } else { throw new UnsupportedOperationException("This reader does not support this method."); } }
/** Returns the stored fields of the <code>n</code><sup>th</sup> <code>Document</code> in this index. * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error */ public Document document(int n) throws CorruptIndexException, IOException { ensureOpen(); return document(n, null); }
/** * * @throws IOException */ public final synchronized void flush() throws IOException { ensureOpen(); commit(); }
/** Returns the stored fields of the <code>n</code><sup>th</sup> <code>Document</code> in this index. * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error */ public Document document(int n) throws CorruptIndexException, IOException { ensureOpen(); return document(n, null); }
/** Returns true if there are norms stored for this field. */ public boolean hasNorms(String field) throws IOException { // backward compatible implementation. // SegmentReader has an efficient implementation. ensureOpen(); return norms(field) != null; }
/** Returns true if there are norms stored for this field. */ public boolean hasNorms(String field) throws IOException { // backward compatible implementation. // SegmentReader has an efficient implementation. ensureOpen(); return norms(field) != null; }
/** * * @throws IOException */ public final synchronized void flush() throws IOException { ensureOpen(); commit(); }
/** Undeletes all documents currently marked as deleted in this index. * * @throws StaleReaderException if the index has changed * since this reader was opened * @throws LockObtainFailedException if another writer * has this index open (<code>write.lock</code> could not * be obtained) * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error */ public synchronized void undeleteAll() throws StaleReaderException, CorruptIndexException, LockObtainFailedException, IOException { ensureOpen(); acquireWriteLock(); hasChanges = true; doUndeleteAll(); }
/** Returns an enumeration of all the documents which contain * <code>term</code>. For each document, the document number, the frequency of * the term in that document is also provided, for use in search scoring. * Thus, this method implements the mapping: * <p><ul> * Term => <docNum, freq><sup>*</sup> * </ul> * <p>The enumeration is ordered by document number. Each document number * is greater than all that precede it in the enumeration. * @throws IOException if there is a low-level IO error */ public TermDocs termDocs(Term term) throws IOException { ensureOpen(); TermDocs termDocs = termDocs(); termDocs.seek(term); return termDocs; }
/** Undeletes all documents currently marked as deleted in this index. * * @throws StaleReaderException if the index has changed * since this reader was opened * @throws LockObtainFailedException if another writer * has this index open (<code>write.lock</code> could not * be obtained) * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error */ public synchronized void undeleteAll() throws StaleReaderException, CorruptIndexException, LockObtainFailedException, IOException { ensureOpen(); acquireWriteLock(); hasChanges = true; doUndeleteAll(); }