@Override public void close() throws IOException { referenceManager.release( indexSearcher ); } }
private synchronized void swapReference(G newReference) throws IOException { ensureOpen(); final G oldReference = current; current = newReference; release(oldReference); }
return lookupFromSearcher(s, id); } finally { mgr.release(s);
if (released.compareAndSet(false, true)) { try { referenceManager.release(acquire); } finally { store.decRef();
public void release(IndexSearcher searcher) throws IOException { if (searcher != null) { searcherManager.release(searcher); } }
private synchronized void swapReference(G newReference) throws IOException { ensureOpen(); final G oldReference = current; current = newReference; release(oldReference); }
private synchronized void swapReference(G newReference) throws IOException { ensureOpen(); final G oldReference = current; current = newReference; release(oldReference); }
private synchronized void swapReference(G newReference) throws IOException { ensureOpen(); final G oldReference = current; current = newReference; release(oldReference); }
private List<Document> search(final Query query, final int limit) throws IOException { IndexSearcher searcher = null; try { searcher = manager.acquire(); final TopDocs docs = searcher.search(query, null, limit, Sort.INDEXORDER, false, false); final ImmutableList.Builder<Document> resultBuilder = ImmutableList.builder(); for (final ScoreDoc scoreDoc : docs.scoreDocs) { resultBuilder.add(searcher.doc(scoreDoc.doc)); } return resultBuilder.build(); } finally { if (null != searcher) { manager.release(searcher); } } }
@Override final public <T> T search(final SearchAction<T> action) throws IOException { final ReferenceManager<IndexSearcher> sm = Objects.requireNonNull(searcherManager, "No SearchManager available"); final IndexSearcher searcher = sm.acquire(); try { return action.apply(searcher, null); } finally { sm.release(searcher); } }
@Override public void close() { if (!released.compareAndSet(false, true)) { /* In general, searchers should never be released twice or this would break reference counting. There is one rare case * when it might happen though: when the request and the Reaper thread would both try to release it in a very short amount * of time, this is why we only log a warning instead of throwing an exception. */ logger.warn("Searcher was released twice", new IllegalStateException("Double release")); return; } try { referenceManager.release(searcher()); } catch (IOException e) { throw new IllegalStateException("Cannot close", e); } catch (AlreadyClosedException e) { // This means there's a bug somewhere: don't suppress it throw new AssertionError(e); } finally { store.decRef(); } } }
private int getHitCount(final Query query) throws IOException { IndexSearcher searcher = null; try { searcher = manager.acquire(); final TotalHitCountCollector collector = new TotalHitCountCollector(); searcher.search(query, collector); return collector.getTotalHits(); } finally { if (null != searcher) { manager.release(searcher); } } }
return lookupFromSearcher(s, id); } finally { mgr.release(s);
return lookupFromSearcher(s, id); } finally { mgr.release(s);
return lookupFromSearcher(s, id); } finally { mgr.release(s);
manager.release(searcher);