Class LruTaxonomyWriterCache
LRU ITaxonomyWriterCache - good choice for huge taxonomies.
Note
This API is experimental and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Facet.Taxonomy.WriterCache
Assembly: Lucene.Net.Facet.dll
Syntax
public class LruTaxonomyWriterCache : ITaxonomyWriterCache, IDisposable
Constructors
LruTaxonomyWriterCache(int)
Creates this with LRU_HASHED method.
Declaration
public LruTaxonomyWriterCache(int cacheSize)
Parameters
Type | Name | Description |
---|---|---|
int | cacheSize |
LruTaxonomyWriterCache(int, LRUType)
Creates this with the specified method.
Declaration
public LruTaxonomyWriterCache(int cacheSize, LruTaxonomyWriterCache.LRUType lruType)
Parameters
Type | Name | Description |
---|---|---|
int | cacheSize | |
LruTaxonomyWriterCache.LRUType | lruType |
Properties
IsFull
Returns true if the cache is full, such that the next Put(FacetLabel, int) will evict entries from it, false otherwise.
Declaration
public virtual bool IsFull { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
Clear()
Clears the content of the cache. Unlike Dispose(), the caller can assume that the cache is still operable after this method returns.
Declaration
public virtual void Clear()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(bool)
LRU ITaxonomyWriterCache - good choice for huge taxonomies.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
Get(FacetLabel)
Lookup a category in the cache, returning its ordinal, or a negative number if the category is not in the cache.
It is up to the caller to remember what a negative response means: If the caller knows the cache is complete (it was initially fed with all the categories, and since then Put(FacetLabel, int) never returned true) it means the category does not exist. Otherwise, the category might still exist, but just be missing from the cache.
Declaration
public virtual int Get(FacetLabel categoryPath)
Parameters
Type | Name | Description |
---|---|---|
FacetLabel | categoryPath |
Returns
Type | Description |
---|---|
int |
Put(FacetLabel, int)
Add a category to the cache, with the given ordinal as the value.
If the implementation keeps only a partial cache (e.g., an LRU cache)
and finds that its cache is full, it should clear up part of the cache
and return true
. Otherwise, it should return
false
.
The reason why the caller needs to know if part of the cache was cleared is that in that case it will have to commit its on-disk index (so that all the latest category additions can be searched on disk, if we can't rely on the cache to contain them).
Ordinals should be non-negative. Currently there is no defined way to specify that a cache should remember a category does NOT exist. It doesn't really matter, because normally the next thing we do after finding that a category does not exist is to add it.
Declaration
public virtual bool Put(FacetLabel categoryPath, int ordinal)
Parameters
Type | Name | Description |
---|---|---|
FacetLabel | categoryPath | |
int | ordinal |
Returns
Type | Description |
---|---|
bool |