DocSet getPositiveDocSet(Query q, DocSetAwareCollector collector) throws IOException { DocSet answer; if (filterCache != null) { answer = (DocSet)filterCache.get(q); if (answer!=null) return answer; } answer = getDocSetNC(q, null, collector); if (filterCache != null) filterCache.put(q,answer); return answer; }
void close(){ log.debug(" ... close EntityCache for version {} (size: {} | description: {})", new Object[]{version, cache.size(),cache.getDescription()}); closed = true; cache.clear(); cache.close(); } }
public SolrEntityCache(Object version, SolrCache<Integer,Document> cache) { log.debug("> create {} for version {}", getClass().getSimpleName(), version); this.cache = cache; this.version = version; log.debug(" - initial Size: {}",cache.size()); log.debug(" - description: {}",cache.getDescription()); log.debug(" - statistics: {}", cache.getStatistics()); }
@Override public void put(final CacheKey cacheKey, final TermQueryCacheValue value) { if (!ignoreUpdates) { delegate.put(cacheKey, value); } }
@Override public Document get(Integer docId) { return !closed ? cache.get(docId) : null; }
public SolrCache newInstance() { try { SolrCache cache = (SolrCache)clazz.newInstance(); persistence[0] = cache.init(args, persistence[0], regenerator); return cache; } catch (Exception e) { SolrException.log(SolrCache.log,"Error instantiating cache",e); // we can carry on without a cache... but should we? // in some cases (like an OOM) we probably should try to continue. return null; } }
/** Register sub-objects such as caches */ public void register() { // register self core.getInfoRegistry().put("searcher", this); core.getInfoRegistry().put(name, this); for (SolrCache cache : cacheList) { cache.setState(SolrCache.State.LIVE); core.getInfoRegistry().put(cache.name(), cache); } registerTime=System.currentTimeMillis(); }
/** * Free's resources associated with this searcher. * * In particular, the underlying reader and any cache's in use are closed. */ public void close() throws IOException { if (cachingEnabled) { StringBuilder sb = new StringBuilder(); sb.append("Closing ").append(name); for (SolrCache cache : cacheList) { sb.append("\n\t"); sb.append(cache); } log.info(sb.toString()); } else { log.debug("Closing " + name); } core.getInfoRegistry().remove(name); // super.close(); // can't use super.close() since it just calls reader.close() and that may only be called once // per reader (even if incRef() was previously called). if (closeReader) reader.decRef(); for (SolrCache cache : cacheList) { cache.close(); } }
@Override public String toString() { return cache.getDescription(); }
@Override public String printStatistics() { return cache.getStatistics().toString(); }
if (userCacheConfig != null) cache = userCacheConfig.newInstance(); if (cache != null) { cacheMap.put(cache.name(), cache); clist.add(cache);
public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache, SolrCache oldCache, Object oldKey, Object oldVal) throws IOException { newCache.put(oldKey,oldVal); return true; } }
@Override public TermQueryCacheValue get(final CacheKey cacheKey) { return delegate.get(cacheKey); }
cache.init(config, null, regenerator); current = new RefCountedImpl(new SolrEntityCache(version, cache));
public static UnInvertedField getUnInvertedField(String field, SolrIndexSearcher searcher) throws IOException { SolrCache cache = searcher.getFieldValueCache(); if (cache == null) { return new UnInvertedField(field, searcher); } UnInvertedField uif = (UnInvertedField)cache.get(field); if (uif == null) { synchronized (cache) { uif = (UnInvertedField)cache.get(field); if (uif == null) { uif = new UnInvertedField(field, searcher); cache.put(field, uif); } } } return uif; }
/** * insert an entry in a generic cache */ public Object cacheInsert(String cacheName, Object key, Object val) { SolrCache cache = cacheMap.get(cacheName); return cache==null ? null : cache.put(key,val); }
/** * lookup an entry in a generic cache */ public Object cacheLookup(String cacheName, Object key) { SolrCache cache = cacheMap.get(cacheName); return cache==null ? null : cache.get(key); }
/** * Retrieve the {@link Document} instance corresponding to the document id. * * Note: The document will have all fields accessable, but if a field * filter is provided, only the provided fields will be loaded (the * remainder will be available lazily). */ public Document doc(int i, Set<String> fields) throws IOException { Document d; if (documentCache != null) { d = (Document)documentCache.get(i); if (d!=null) return d; } if(!enableLazyFieldLoading || fields == null) { d = getIndexReader().document(i); } else { d = getIndexReader().document(i, new SetNonLazyFieldSelector(fields)); } if (documentCache != null) { documentCache.put(i, d); } return d; }
@Override public void cache(Integer docId, Document doc) { if(!closed){ log.trace(" - cache id:{} | {}",docId, doc); cache.put(docId, doc); } }