add type to filter cache

This commit is contained in:
kimchy 2010-04-01 01:18:18 +03:00
parent dc1402597f
commit 0e3ca48aa9
5 changed files with 16 additions and 2 deletions

View File

@ -24,9 +24,11 @@ import org.elasticsearch.index.IndexComponent;
import org.elasticsearch.util.component.CloseableComponent;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
public interface FilterCache extends IndexComponent, CloseableComponent {
String type();
Filter cache(Filter filterToCache);
}

View File

@ -37,6 +37,10 @@ public class NoneFilterCache extends AbstractIndexComponent implements FilterCac
logger.debug("Using no filter cache");
}
@Override public String type() {
return "none";
}
@Override public void close() {
// nothing to do here
}

View File

@ -40,6 +40,10 @@ public class SoftFilterCache extends AbstractConcurrentMapFilterCache {
super(index, indexSettings, threadPool);
}
@Override public String type() {
return "soft";
}
@Override protected ConcurrentMap<Filter, DocIdSet> buildMap() {
return new MapMaker().softValues().makeMap();
}

View File

@ -54,7 +54,7 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp
this.readerCleanerSchedule = componentSettings.getAsTime("readerCleanerSchedule", TimeValue.timeValueMinutes(1));
logger.debug("Using weak filter cache with readerCleanerSchedule [{}]", readerCleanerSchedule);
logger.debug("Using [" + type() + "] filter cache with readerCleanerSchedule [{}]", readerCleanerSchedule);
this.cache = newConcurrentMap();
this.scheduleFuture = threadPool.scheduleWithFixedDelay(new IndexReaderCleaner(), readerCleanerSchedule);

View File

@ -40,6 +40,10 @@ public class WeakFilterCache extends AbstractConcurrentMapFilterCache {
super(index, indexSettings, threadPool);
}
@Override public String type() {
return "weak";
}
@Override protected ConcurrentMap<Filter, DocIdSet> buildMap() {
return new MapMaker().weakValues().makeMap();
}