|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectuk.ac.ic.doc.automed.qproc.cache.DefaultQueryCache
public class DefaultQueryCache
| Constructor Summary | |
|---|---|
protected |
DefaultQueryCache(long ageTime)
Creates a new instance of DefaultQueryCache (singleton) |
| Method Summary | |
|---|---|
void |
addListener(CacheListener cacheListener)
Register a listener for handling cache-related events |
java.lang.String |
addQuery(java.lang.String query,
java.lang.Object metadata)
Store reference to the AbstractQueryProcessor object that processes this queryso that we can in a later stage use the query analysis with query result to build a semantic cache entry for the query . |
void |
addQueryResult(java.lang.String queryID,
java.lang.Object resultObj)
Add a new query to cache. |
int |
addSubQueryResult(java.lang.String queryID,
java.lang.String subQuery,
java.lang.Object resultObj)
Add result of a sub-query of a query in the cache. |
void |
clear()
Clear the cache |
void |
deserialise()
Read content from disk (file or database) |
java.util.List |
getCachedQueries()
Return external queries of all cached items |
protected CacheContentDescription |
getContent()
Implements interface Cacheable. |
CacheContentDescription |
getContentObject()
Return the cache data bag |
ASG |
getExactQuery(java.lang.String query)
Check in the cache for an exact query match. |
ASG |
getExactSubQuery(java.lang.String subQuery)
Check sub-query existence in the whole cache. |
ASG |
getExactSubQuery(java.lang.String queryID,
java.lang.String subQuery)
Check if result of the sub-query of a query already exists in the cache. |
protected static DefaultQueryCache |
getInstance(long ageTime)
A singleton method to make sure that there is only one instance of query cache per peer |
AbstractObjectBinding |
getObjectBinding()
Return an instance of object binding for serialisation |
PersistentHandler |
getPersistentHandler()
|
java.util.List |
getQuery(ASG view)
|
ASG[] |
getQuery(java.lang.String query)
Check in the cache for a similar query match. |
java.lang.Object[] |
getQueryMetadataObjects()
Return an array of metadata objects associated to the query objects |
boolean |
hasNext()
Implements mandatory methods of the ListIterator interface |
boolean |
isEmpty()
|
java.lang.Object |
next()
Implements mandatory methods of the ListIterator interface
Returns the metadata object of the next cache item |
void |
notifyListeners(Cacheable cacheObj)
Notify listeners to handle a specific event |
void |
refresh()
refresh cache |
void |
remove()
Implements mandatory methods of the ListIterator interface |
QueryRewriterResult |
rewrite(ASG query,
Schema querySchema,
int type)
Rewrite a query associated to a schema s using the local query cache |
void |
serialise(java.lang.Object obj)
Save/synch a cache item object to disk (or database). |
void |
setPersistentHandler(PersistentHandler ph)
Implement this method for serialising cache content |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected DefaultQueryCache(long ageTime)
| Method Detail |
|---|
protected static DefaultQueryCache getInstance(long ageTime)
public void addQueryResult(java.lang.String queryID,
java.lang.Object resultObj)
throws CacheIntegrityException
AbstractQueryProcessor whose result was added to this cache.
Query result is often retrieved and later added to the cache at the execution phase
addQueryResult in interface IQueryCachequeryID - the unique query identifier (generated by #addQuery(String query, String fQuery, String sQuery,
String iQuery, Object metadata, Object qproc) methodresultObj - the result object from query execution
CacheIntegrityException
public int addSubQueryResult(java.lang.String queryID,
java.lang.String subQuery,
java.lang.Object resultObj)
throws CacheIntegrityException
List object)
of the query cache item.
Each query's sub result is represented as a two-dimensional array as follows:
Object[] subResult = new Object[] {subQuery, subQueryResult}
addSubQueryResult in interface IQueryCachequeryID - the id of the parent querysubQuery - sub-query stringresultObj - sub-query result object
CacheIntegrityException
public java.lang.String addQuery(java.lang.String query,
java.lang.Object metadata)
throws CacheIntegrityException
AbstractQueryProcessor object that processes this query
addQuery in interface IQueryCachequery - the original (external) IQL query posed by userfQuery - the formulated querysQuery - the executional representation of the queryiQuery - the internal representation of the query. This is the primary query id.metadata - the metadata object of the query (e.g. QueryAnalyser)qproc - the AbstractQueryProcessor object
CacheIntegrityExceptionpublic ASG getExactQuery(java.lang.String query)
ASGs.
getExactQuery in interface IQueryCachequery - the query string must be in internal format
public ASG getExactSubQuery(java.lang.String queryID,
java.lang.String subQuery)
throws CacheIntegrityException
getExactSubQuery in interface IQueryCachequeryID - the ID of query to which the sub-query is associatedsubQuery - sub-query to search for
null if sub-query is not found
CacheIntegrityExceptionpublic ASG getExactSubQuery(java.lang.String subQuery)
throws CacheIntegrityException
getExactSubQuery in interface IQueryCachesubQuery - sub-query to search for
null if sub-query is not foundpublic ASG[] getQuery(java.lang.String query)
ASGs.
getQuery in interface IQueryCachequery - the query string must be in external format
public java.util.List getQuery(ASG view)
public java.util.List getCachedQueries()
getCachedQueries in interface IQueryCacheList a list of all metadata objects in the cache OR null public java.lang.Object[] getQueryMetadataObjects()
getQueryMetadataObjects in interface IQueryCacheprotected CacheContentDescription getContent()
Cacheable.
Returns a List object of cache content. Each item in the list is HashMap object containing id, query, result and timestamp values
public CacheContentDescription getContentObject()
getContentObject in interface Cacheablepublic void setPersistentHandler(PersistentHandler ph)
Persistence
setPersistentHandler in interface Persistencepublic PersistentHandler getPersistentHandler()
public void serialise(java.lang.Object obj)
serialise in interface Persistencepublic void deserialise()
deserialise in interface Persistencepublic AbstractObjectBinding getObjectBinding()
Persistence
getObjectBinding in interface Persistencepublic void clear()
clear in interface Cacheablepublic void refresh()
refresh in interface Cacheablepublic void addListener(CacheListener cacheListener)
addListener in interface CacheablecacheListener - a CacheListener object to addpublic void notifyListeners(Cacheable cacheObj)
notifyListeners in interface CacheablecacheObj - the Cacheable object to be used by listener to handle eventpublic boolean hasNext()
ListIterator interface
hasNext in interface java.util.Iteratorpublic java.lang.Object next()
ListIterator interface
Returns the metadata object of the next cache item
next in interface java.util.Iteratorpublic void remove()
ListIterator interface
remove in interface java.util.Iterator
public QueryRewriterResult rewrite(ASG query,
Schema querySchema,
int type)
throws QueryRewriterException
rewrite in interface QueryRewritablequery - the ASG queryquerySchema - the source schema over which query is executedQueryAnalyser[] - an array of QueryAnalyser objects of the cached viewstype - specifies the type of query rewriting algorithm used (QueryRewriteProcessor
for list of types)
QueryRewriterExceptionpublic boolean isEmpty()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||