@Override public void put(final CacheKey cacheKey, final TermQueryCacheValue value) { if (!ignoreUpdates) { delegate.put(cacheKey, value); } }
public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache, SolrCache oldCache, Object oldKey, Object oldVal) throws IOException { newCache.put(oldKey,oldVal); return true; } }
/** * 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); }
@Override public void cache(Integer docId, Document doc) { if(!closed){ log.trace(" - cache id:{} | {}",docId, doc); cache.put(docId, doc); } }
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; }
filterCache.put(query,optionalAnswer);
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; }
/** * 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; }
filterCache.put(absQ, absAnswer);
/** * Returns the set of document ids matching both the query and the filter. * This method is cache-aware and attempts to retrieve the answer from the cache if possible. * If the answer was not cached, it may have been inserted into the cache as a result of this call. * <p> * * @param query * @param filter may be null * @return DocSet meeting the specified criteria, should <b>not</b> be modified by the caller. */ public DocSet getDocSet(Query query, DocSet filter, DocSetAwareCollector collector) throws IOException { if (filter==null) return getDocSet(query, collector); // Negative query if absolute value different from original Query absQ = QueryUtils.getAbs(query); boolean positive = absQ==query; DocSet first; if (filterCache != null) { first = (DocSet)filterCache.get(absQ); if (first==null) { first = getDocSetNC(absQ,null); filterCache.put(absQ,first); } return positive ? first.intersection(filter) : filter.andNot(first); } // If there isn't a cache, then do a single filtered query if positive. return positive ? getDocSetNC(absQ,filter,collector) : filter.andNot(getPositiveDocSet(absQ, collector)); }