boost::any Cache::get(IndexReaderPtr reader, EntryPtr key) { MapEntryAny innerCache; boost::any value; LuceneObjectPtr readerKey(reader->getFieldCacheKey()); { SyncLock cacheLock(&readerCache); innerCache = readerCache.get(readerKey); if (!innerCache) { innerCache = MapEntryAny::newInstance(); readerCache.put(readerKey, innerCache); } else if (innerCache.contains(key)) value = innerCache[key]; if (VariantUtils::isNull(value)) { value = newLucene<CreationPlaceholder>(); innerCache.put(key, value); } } if (VariantUtils::typeOf<CreationPlaceholderPtr>(value)) { CreationPlaceholderPtr progress(VariantUtils::get<CreationPlaceholderPtr>(value)); SyncLock valueLock(progress); if (VariantUtils::isNull(progress->value)) { progress->value = createValue(reader, key); { SyncLock cacheLock(&readerCache); innerCache.put(key, progress->value); } FieldCachePtr wrapper(_wrapper); // Only check if key.custom (the parser) is non-null; else, we check twice for a single // call to FieldCache.getXXX if (!VariantUtils::isNull(key->custom) && wrapper) { InfoStreamPtr infoStream(wrapper->getInfoStream()); if (infoStream) printNewInsanity(infoStream, progress->value); } } return progress->value; } return value; }
void Cache::purge(IndexReaderPtr r) { LuceneObjectPtr readerKey(r->getFieldCacheKey()); SyncLock cacheLock(&readerCache); readerCache.remove(readerKey); }