public class CachedRider extends Object implements Resolver<CachedTerm,CachedIListPage>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PAGE_SIZE
Default maximum number of items an inverted list page should store.
|
Constructor and Description |
---|
CachedRider(Cache<CachedTerm,CachedIListPage> cache)
Constructor for the CachedRider object.
|
CachedRider(Cache<CachedTerm,CachedIListPage> cache,
int pageSize)
Constructor for the CachedRider object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(CachedTerm term)
Checks whether the specified term is cached.
|
CachedIListPage |
get(CachedTerm term)
Gets the inverted list page associated with the specified term from the cache if the term is cached, or the inverted list page returned by the resolver.
|
Cache<CachedTerm,CachedIListPage> |
getCache()
Gets the actual cache used for storing inverted list pages.
|
long |
getCachedPostings()
Returns the actual number of cached postings.
|
long |
getPostings()
Returns the number of postings that the cached pages occupy.
|
float |
hitRatio()
Returns the hits/requests ratio in percents.
|
long |
hits()
Returns the number of all hits.
|
long |
misses()
Returns the number of all misses.
|
IListReader |
openIList(Barrel barrel,
String term)
Gets a cached inverted list reader for the specified barrel and term.
|
CachedIListPage |
put(CachedTerm term,
CachedIListPage page)
Adds a new inverted list page for the specified term to the cache.
|
CachedIListPage |
remove(CachedTerm term)
Removes the specified term and its page from the cache.
|
long |
requests()
Returns the number of all submitted requests.
|
void |
resetCounters()
Sets hits and misses counters to zero.
|
CachedIListPage |
resolve(CachedTerm term)
Return a new cached inverted list page of the specified term.
|
int |
size()
Returns the number of cached inverted list pages.
|
CachedIListPage |
update(CachedTerm term,
CachedIListPage page)
Updates the inverted list page associated with the specified term in the cache if a cached page exists for the term.
|
public static int DEFAULT_PAGE_SIZE
public CachedRider(Cache<CachedTerm,CachedIListPage> cache)
cache
- actual cache used for storing inverted list pagespublic CachedRider(Cache<CachedTerm,CachedIListPage> cache, int pageSize)
cache
- actual cache used for storing inverted list pagespageSize
- maximum size of an inverted list pagepublic CachedIListPage resolve(CachedTerm term)
resolve
in interface Resolver<CachedTerm,CachedIListPage>
term
- term to create the inverted list page forpublic CachedIListPage put(CachedTerm term, CachedIListPage page)
term
- term to add to the cachepage
- inverted list page to map the term topublic CachedIListPage get(CachedTerm term)
term
- term to get the result forpublic CachedIListPage remove(CachedTerm term)
term
- term to remove from the cache.public CachedIListPage update(CachedTerm term, CachedIListPage page)
term
- term to change the result forpage
- new inverted list page associated with the keypublic boolean containsKey(CachedTerm term)
term
- term to checkpublic IListReader openIList(Barrel barrel, String term)
barrel
- barrel to get the inverted list fromterm
- term owning the requested inverted listpublic Cache<CachedTerm,CachedIListPage> getCache()
public long hits()
public long misses()
public float hitRatio()
public long requests()
public void resetCounters()
public int size()
public long getPostings()
public long getCachedPostings()
Copyright © 2016 Egothor. All Rights Reserved.