Java Code Examples for org.apache.lucene.index.IndexReader#incRef()
The following examples show how to use
org.apache.lucene.index.IndexReader#incRef() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterIndexReaderByStringId.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Apply the filter * * @param id String * @param reader IndexReader * @param deleteNodesOnly boolean */ public FilterIndexReaderByStringId(String id, IndexReader reader, Set<String> deletions, Set<String> containerDeletions, boolean deleteNodesOnly) { super(reader); reader.incRef(); this.id = id; this.deletions = deletions; this.containerDeletions = containerDeletions; this.deleteNodesOnly = deleteNodesOnly; if (s_logger.isDebugEnabled()) { s_logger.debug("Applying deletions FOR "+id +" (the index ito which these are applied is the previous one ...)"); } }
Example 2
Source File: BlurIndexSimpleWriter.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
public IndexSearcherCloseable getIndexSearcher(boolean security) throws IOException { final IndexReader indexReader; _indexRefreshReadLock.lock(); try { indexReader = _indexReader.get(); indexReader.incRef(); } finally { _indexRefreshReadLock.unlock(); } if (indexReader instanceof ExitableReader) { ((ExitableReader) indexReader).reset(); } if (security) { return getSecureIndexSearcher(indexReader); } else { return getInsecureIndexSearcher(indexReader); } }
Example 3
Source File: IndexInfo.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Get the main reader for committed index data * * @return IndexReader * @throws IOException */ public IndexReader getMainIndexReferenceCountingReadOnlyIndexReader() throws IOException { getReadLock(); try { // Check if we need to rebuild the main indexer as it is invalid. // (it is shared and quick version check fails) if (indexIsShared && !checkVersion()) { releaseReadLock(); getWriteLock(); try { if (mainIndexReader != null) { ((ReferenceCounting)mainIndexReader).setInvalidForReuse(); } mainIndexReader = null; } finally { getReadLock(); releaseWriteLock(); } } // Build if required if (mainIndexReader == null) { releaseReadLock(); getWriteLock(); try { if (mainIndexReader == null) { // Sync with disk image if required doWithFileLock(new LockWork<Object>() { public Object doWork() throws Exception { return null; } public boolean canRetry() { return true; } }); mainIndexReader = createMainIndexReader(); } } finally { getReadLock(); releaseWriteLock(); } } // Manage reference counting mainIndexReader.incRef(); if (s_logger.isDebugEnabled()) { s_logger.debug("Main index reader references = " + ((ReferenceCounting) mainIndexReader).getReferenceCount()); } // ALF-10040: Wrap with a one-off CachingIndexReader (with cache disabled) so that LeafScorer behaves and passes through SingleFieldSelectors to the main index readers IndexReader reader = ReferenceCountingReadOnlyIndexReaderFactory.createReader(MAIN_READER + GUID.generate(), mainIndexReader, false, config); ReferenceCounting refCounting = (ReferenceCounting) reader; reader.incRef(); refCounting.setInvalidForReuse(); return reader; } catch (RuntimeException e) { e.printStackTrace(); throw e; } finally { releaseReadLock(); } }