|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.webSvr.util.SearchResultSimpleCache
public final class SearchResultSimpleCache
Bean for cached search results. Uses SearchUtils.doRelatedExhibitsSearch() to compute results lazily and caches the results.
Cache size is limited at most by the number of exhibits (keyed from their names plus canonicalised forms of those names for shared results) and may be capped to a fixed ceiling below that to retain only the most popular results.
| Field Summary | |
|---|---|
static int |
ABS_MAX_RESULTS
Absolute maximum number of results to store/cache per exhibit. |
private static DataSourceBean.AEPLinkedKey |
fullSearchCacheKey
Private lookup key for full searches of similar items; never null. |
private MemoryTools.SimpleLRUMap<Name,java.util.List<Name.ExhibitFull>> |
searchResults
Map from full exhibit name (and from canonicalised search term) to immutable ordered list of full-name results, best match first. |
| Constructor Summary | |
|---|---|
SearchResultSimpleCache()
|
|
| Method Summary | |
|---|---|
static Name |
computeRawSearchTermFromExhibitName(Name.ExhibitFull exhibitFullName)
Compute the (immutable) raw core lookup term in the by-word index from text in the exhibit name itself; never null. |
static java.util.List<Name.ExhibitFull> |
doCachedCatPageSimilarItems(DataSourceBean dsb,
Name.ExhibitFull exhibitName,
int maxToShow)
Do cached lookup for cat page "similar items"; never null. |
static java.util.concurrent.Future<java.util.List<Name.ExhibitFull>> |
doCachedCatPageSimilarItemsFuture(DataSourceBean dsb,
Name.ExhibitFull exhibitFullName,
int maxResults)
Do cached search lookup as for doCachedCatPageSimilarItems() but asynchronously; never null. |
java.util.List<Name.ExhibitFull> |
getRelatedExhibits(DataSourceBean dataSource,
Name.ExhibitFull exhibitFullName,
int maxResults)
Do cached search lookup on given full exhibit name returning full exhibit name results; never null. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final MemoryTools.SimpleLRUMap<Name,java.util.List<Name.ExhibitFull>> searchResults
Capped size to minimise memory footprint while still giving good performance. Falling through the cache and doing the query from scratch shouldn't be that slow anyway.
Since the actual cached items are small (even compared to the MapEntry overheads), a relatively large number can be cached and it is not worth a complex high-overhead scheme, eg using SoftReferences, to manage them.
Note also that the penalty of a cache miss is not that high, merely involving a slightly-slow lookup in the underlying in-memory by-word index.
public static final int ABS_MAX_RESULTS
If the catalogue page logic actually uses this value as the maximum request size then we should get optimal CPU and memory use, and minimal heap churn.
private static final DataSourceBean.AEPLinkedKey fullSearchCacheKey
| Constructor Detail |
|---|
public SearchResultSimpleCache()
| Method Detail |
|---|
public java.util.List<Name.ExhibitFull> getRelatedExhibits(DataSourceBean dataSource,
Name.ExhibitFull exhibitFullName,
int maxResults)
throws java.io.IOException
The (immutable) results are limited to at most ABS_MAX_RESULTS items.
Excludes the exhibit itself and variants of the exhibit (same main words stem, etc, giving same canonicalised search term) on the assumption that they may already have been shown in other ways.
This allows potentially-redundant requests to execute in parallel at the risk of a little wasted work so as to maximise potential concurrency.
We do NOT cache any results if we don't believe the index to be up-to-date (eg to avoid cacheing stale/empty values).
java.io.IOExceptionpublic static Name computeRawSearchTermFromExhibitName(Name.ExhibitFull exhibitFullName)
This keeps the constituent words in the order supplied, and always retains the first word (later duplicates may be discarded for example) as earlier words are taken to be more important.
public static java.util.List<Name.ExhibitFull> doCachedCatPageSimilarItems(DataSourceBean dsb,
Name.ExhibitFull exhibitName,
int maxToShow)
public static java.util.concurrent.Future<java.util.List<Name.ExhibitFull>> doCachedCatPageSimilarItemsFuture(DataSourceBean dsb,
Name.ExhibitFull exhibitFullName,
int maxResults)
|
DHD Multimedia Gallery V1.53.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||