/** * Checks recursively if all subreaders are up to date. */ public boolean isCurrent() throws CorruptIndexException, IOException { for (int i = 0; i < subReaders.length; i++) { if (!subReaders[i].isCurrent()) { return false; } } // all subreaders are up to date return true; }
public boolean isCurrent() throws CorruptIndexException, IOException { return reader.isCurrent(); }
/** * Checks recursively if all subreaders are up to date. */ public boolean isCurrent() throws CorruptIndexException, IOException { for (int i = 0; i < subReaders.length; i++) { if (!subReaders[i].isCurrent()) { return false; } } // all subreaders are up to date return true; }
@Override public boolean isCurrent() throws CorruptIndexException, IOException { return in.isCurrent(); }
@Override public boolean isCurrent() throws IOException { return this.delegate.isCurrent(); }
/** * Checks recursively if all subreaders are up to date. */ public boolean isCurrent() throws CorruptIndexException, IOException { for (int i = 0; i < readers.size(); i++) { if (!((IndexReader)readers.get(i)).isCurrent()) { return false; } } // all subreaders are up to date return true; }
/** * Checks recursively if all subreaders are up to date. */ public boolean isCurrent() throws CorruptIndexException, IOException { for (int i = 0; i < readers.size(); i++) { if (!((IndexReader)readers.get(i)).isCurrent()) { return false; } } // all subreaders are up to date return true; }
public boolean isCurrent() throws CorruptIndexException, IOException { ensureOpen(); return in.isCurrent(); }
public boolean isCurrent() throws CorruptIndexException, IOException { ensureOpen(); return in.isCurrent(); }
private IndexReader indexReader() throws CorruptIndexException, IOException { if (_reader == null) { _reader = IndexReader.open(indexDirectory(), true); // ^^^ readOnly _searcher = new IndexSearcher(_reader); } if (!_reader.isCurrent()) { _reader = _reader.reopen(); _searcher = new IndexSearcher(_reader); } return _reader; }
public IndexReader getIndexReader() throws IOException { synchronized ( indexLock ) { if ( indexReader == null || ( !indexReader.isCurrent() && !isIndexWriterDirty() ) ) { if ( indexReader != null ) { indexReader.close(); } indexReader = IndexReader.open( indexDirectory ); } return indexReader; } }
public void preQuery() throws IndexerException{ if (searcher == null){ try { searcher = new IndexSearcher(location); } catch (IOException e) { log.error(this, e); throw new IndexerException(e); } } else { if (log.isWarnEnabled()){ log.warn("searcher already exists"); } try { if (! searcher.getIndexReader().isCurrent()){ log.info("Index is not current, closing and re-opening searcher to refresh."); searcher.close(); searcher = new IndexSearcher(location); } } catch (IOException e) { log.error( this, e); throw new IndexerException(e); } } }
public void refresh(String subIndex) throws SearchEngineException { checkIfStarted(); synchronized (indexLocks.get(subIndex)) { IndexReader reader = readerMap.get(subIndex); if (reader != null) { try { if (reader.isCurrent()) { return; } } catch (IOException e) { throw new SearchEngineException("Failed to check if spell index is current for sub index [" + subIndex + "]", e); } } try { reader = IndexReader.open(spellCheckStore.openDirectory(spellIndexSubContext, subIndex)); readerMap.put(subIndex, reader); searcherMap.put(subIndex, new IndexSearcher(reader)); } catch (IOException e) { throw new SearchEngineException("Failed to open spell index searcher for sub index [" + subIndex + "]", e); } } }
private synchronized List<RefreshableIndexSearcher> getReadSession() { /** refresh the searcher, index might have been modified by the writers **/ for(int i = 1; i < searchers.size(); i++) { RefreshableIndexSearcher searcher = searchers.get(i); IndexReader reader =searcher.getIndexReader(); try { if(!reader.isCurrent()) { reader =reader.reopen(); searcher.stale = true; searcher = new RefreshableIndexSearcher(reader); searchers.set(i, searcher); } searcher.useCount++; } catch (Exception e) { LoggingUtil.info("number of readers = " + searchers.size()); throw new SearchException("Error while reopening the searchers, this instance" + "of Searching map may not work as expected, better to shutdown it and start afresh", e); } } return searchers; }
/** * {@inheritDoc} */ public IndexReader getIndexReader() throws IndexException { try { if (this.indexReader == null) { this.indexReader = IndexReader.open(this.indexDirectiry); } else if (!this.indexReader.isCurrent()) { this.indexReader = this.indexReader.reopen(); } } catch (final CorruptIndexException e) { throw new IndexException(e.getLocalizedMessage(), e); } catch (final IOException e) { throw new IndexException(e.getLocalizedMessage(), e); } return this.indexReader; }
if ((indexReader != null && !indexReader.isCurrent()))
/** * @throws IndexException * @see org.xcmis.search.lucene.AbstractLuceneQueryableIndexStorage#getIndexReader() */ @Override protected IndexReader getIndexReader() throws IndexException { try { // reopen if need if (this.indexReader == null) { this.indexReader = IndexReader.open(this.ramDirectory); } else if (!this.indexReader.isCurrent()) { this.indexReader = this.indexReader.reopen(); } } catch (CorruptIndexException e) { throw new IndexException(e.getLocalizedMessage(), e); } catch (IOException e) { throw new IndexException(e.getLocalizedMessage(), e); } return indexReader; }
else if (!this.indexReader.isCurrent())
indexHolder.markLastCacheInvalidation(); try { if (!indexHolder.getIndexReader().isCurrent()) { return true;
public static SimpleOrderedMap<Object> getIndexInfo( IndexReader reader, boolean countTerms ) throws IOException { Directory dir = reader.directory(); SimpleOrderedMap<Object> indexInfo = new SimpleOrderedMap<Object>(); indexInfo.add("numDocs", reader.numDocs()); indexInfo.add("maxDoc", reader.maxDoc()); if( countTerms ) { TermEnum te = null; try{ te = reader.terms(); int numTerms = 0; while (te.next()) { numTerms++; } indexInfo.add("numTerms", numTerms ); } finally{ if( te != null ) te.close(); } } indexInfo.add("version", reader.getVersion()); // TODO? Is this different then: IndexReader.getCurrentVersion( dir )? indexInfo.add("optimized", reader.isOptimized() ); indexInfo.add("current", reader.isCurrent() ); indexInfo.add("hasDeletions", reader.hasDeletions() ); indexInfo.add("directory", dir ); indexInfo.add("lastModified", new Date(IndexReader.lastModified(dir)) ); return indexInfo; }