private static void close( Object object ) { if ( object == null ) { return; } try { if ( object instanceof IndexWriter ) { ((IndexWriter) object).close(); } else if ( object instanceof IndexReader ) { ((IndexReader) object).close(); } } catch ( IOException e ) { throw new RuntimeException( e ); } }
void disposeSearcher() throws IOException { if ( !searcherIsClosed ) { searcher.getIndexReader().close(); searcherIsClosed = true; } }
@Override public void close() { for (LuceneSearcher searcher : luceneSearcherMap.values()) { try { searcher.reader.close(); searcher.directory.close(); } catch (IOException e) { throw new RuntimeException(e); } } }
/** * Get number of documents in this index database. * @return number of documents * @throws IOException if I/O exception occurred */ public int getNumFiles() throws IOException { IndexReader ireader = null; int numDocs = 0; try { ireader = DirectoryReader.open(indexDirectory); // open existing index numDocs = ireader.numDocs(); } finally { if (ireader != null) { try { ireader.close(); } catch (IOException e) { LOGGER.log(Level.WARNING, "An error occurred while closing index reader", e); } } } return numDocs; }
@Override protected synchronized void doClose() throws IOException { IOException ioe = null; for (final IndexReader reader : completeReaderSet) { try { if (closeSubReaders) { reader.close(); } else { reader.decRef(); } } catch (IOException e) { if (ioe == null) ioe = e; } } // throw the first exception if (ioe != null) throw ioe; } }
private static void closeSearcher(IndexSearcher searcher) { IndexReader indexReader = searcher.getIndexReader(); try { searcher.close(); } catch(IOException ignore) {/**/} try { indexReader.close(); } catch(IOException ignore) {/**/} } }
/** * Closes the CPE Index. */ @Override public synchronized void close() { final int count = INSTANCE.usageCount.get() - 1; if (count <= 0) { INSTANCE.usageCount.set(0); if (searchingAnalyzer != null) { searchingAnalyzer.close(); searchingAnalyzer = null; } if (indexReader != null) { try { indexReader.close(); } catch (IOException ex) { LOGGER.trace("", ex); } indexReader = null; } queryParser = null; indexSearcher = null; if (index != null) { index.close(); index = null; } } }
@Override protected synchronized void doClose() throws IOException { IOException ioe = null; for (final IndexReader r : getSequentialSubReaders()) { try { if (closeSubReaders) { r.close(); } else { r.decRef(); } } catch (IOException e) { if (ioe == null) ioe = e; } } // throw the first exception if (ioe != null) throw ioe; } }
@AfterEach void after() throws Exception { if ( reader != null ) { reader.close(); } directory.close(); }
if (ir != null && closeOnDestroy) { try { ir.close(); } catch (IOException ex) { LOGGER.log(Level.WARNING, "Got exception while "
ireader.close();
sourceReader.close();
if (ireader != null) { try { ireader.close(); } catch (IOException e) { LOGGER.log(Level.WARNING, "An error occurred while closing index reader", e);
if (ireader != null) { try { ireader.close(); } catch (Exception ex) { LOGGER.log(Level.WARNING,
public void listTokens(int freq) throws IOException { IndexReader ireader = null; TermsEnum iter = null; Terms terms; try { ireader = DirectoryReader.open(indexDirectory); int numDocs = ireader.numDocs(); if (numDocs > 0) { Fields uFields = MultiFields.getFields(ireader);//reader.getTermVectors(0); terms = uFields.terms(QueryBuilder.DEFS); iter = terms.iterator(); // init uid iterator } while (iter != null && iter.term() != null) { //if (iter.term().field().startsWith("f")) { if (iter.docFreq() > 16 && iter.term().utf8ToString().length() > freq) { LOGGER.warning(iter.term().utf8ToString()); } BytesRef next = iter.next(); if (next==null) {iter=null;} } } finally { if (ireader != null) { try { ireader.close(); } catch (IOException e) { LOGGER.log(Level.WARNING, "An error occurred while closing index reader", e); } } } }
reader.close();
public static void closeReader(IndexReader reader) throws IOException { reader.close(); }
public static void closeReader(IndexReader reader) throws IOException { reader.close(); }
/** * Stores state to disk and closes all open resources. */ public void close() { if (directory == null) return; try { iwriter.close(); directory.close(); if (reader != null) reader.close(); } catch (IOException e) { throw new DukeException(e); } }
/** * Flushes all changes to disk. */ public void commit() { if (directory == null) return; try { if (reader != null) reader.close(); // it turns out that IndexWriter.optimize actually slows // searches down, because it invalidates the cache. therefore // not calling it any more. // http://www.searchworkings.org/blog/-/blogs/uwe-says%3A-is-your-reader-atomic // iwriter.optimize(); iwriter.commit(); openSearchers(); } catch (IOException e) { throw new DukeException(e); } }