IQueryCache
Keywords: uk.ac.ic.doc.automed.qproc.cache.IQueryCache interface

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.ac.ic.doc.automed.qproc.cache
Interface IQueryCache

All Superinterfaces:
  Cacheable, java.util.Iterator, QueryRewritable

All Known Implementing Classes:
  DefaultQueryCache, QueryCache

    public interface IQueryCache

extends Cacheable, QueryRewritable

IQueryCache.java A public interface for query cache. It serves as the actual interface to query cache implementation by other projects.

Author:
  Duc M Le dmle@doc.ic.ac.uk Created on 20 April 2006 Department of Computing, Imperial College

Method Summary
`java.lang.String` | `addQuery(java.lang.String query, java.lang.Object metadata)` Store reference to the `AbstractQueryProcessor` object that processes this query so 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.
`java.util.List` | `getCachedQueries()` Return external queries of all cached items
`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.
`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

Methods inherited from interface uk.ac.ic.doc.automed.util.cache.Cacheable
`addListener, clear, getContentObject, notifyListeners, refresh`

Methods inherited from interface java.util.Iterator
`hasNext, next, remove`

Methods inherited from interface uk.ac.ic.doc.rodex.qproc.QueryRewritable
`rewrite`

Method Detail

### addQueryResult

    void addQueryResult(java.lang.String queryID,
                        java.lang.Object resultObj)
                        throws CacheIntegrityException

  Add a new query to cache. The query is used as the key and result object
  is the value. Often a query was pre-processed in query rewriting phase by an
  instance of `AbstractQueryProcessor` whose result was added to this cache. Query result is often retrieved and later added to the cache at the execution phase
  Hence, what we are doing here is to find the cache-item corresponding to the query and update it with

  Parameters:
    `queryID` - the unique query identifier (generated by `#addQuery(String query, String fQuery, String sQuery, String iQuery, Object metadata, Object qproc)` method
    `resultObj` - the result object from query execution
  Throws:
    `CacheIntegrityException`

### addSubQueryResult

    int addSubQueryResult(java.lang.String queryID,
                          java.lang.String subQuery,
                          java.lang.Object resultObj)
                          throws CacheIntegrityException

  Add result of a sub-query of a query in the cache. A query might have one or more intermediate results each of which is added as a sub_result item (`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}`

  Parameters:
    `queryID` - the id of the parent query
    `subQuery` - sub-query string
    `resultObj` - sub-query result object
  Returns:
    int the sub-result id of the query identified by queryID
  Throws:
    `CacheIntegrityException`

### addQuery

    java.lang.String addQuery(java.lang.String query,
                              java.lang.Object metadata)
                              throws CacheIntegrityException

  Store reference to the `AbstractQueryProcessor` object that processes this query
  so that we can in a later stage use the query analysis with query result
  to build a semantic cache entry for the query
  .
  A query processor object is constructed for each query in query rewriting phase carried out by the query mediator component.

  Parameters:
    `query` - the original (external) IQL query posed by user
    `fQuery` - the formulated query
    `sQuery` - the executional representation of the query
    `iQuery` - 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
  Returns:
    String the unique query identifier
  Throws:
    `CacheIntegrityException`

### getExactQuery

    ASG getExactQuery(java.lang.String query)

  Check in the cache for an exact query match. Note that this method operates on the internal IQL representation of the query which must only result in at most one matched entry. In any case, this method returns an array of the possible query results as `ASG`s.

  Parameters:
    `query` - the query string must be in internal format
  Returns:
    ASG[] array of possible query results found in the cache

### getExactSubQuery

    ASG getExactSubQuery(java.lang.String queryID,
                         java.lang.String subQuery)
                         throws CacheIntegrityException

  Check if result of the sub-query of a query already exists in the cache. This method only checks sub-query existence among sub-queries of a given query instead of all queries in the cache

  Parameters:
    `queryID` - the ID of query to which the sub-query is associated
    `subQuery` - sub-query to search for
  Returns:
    ASG sub-query result (or `null` if sub-query is not found
  Throws:
    `CacheIntegrityException`

### getExactSubQuery

    ASG getExactSubQuery(java.lang.String subQuery)

  Check sub-query existence in the whole cache. This method is preferred to `throws CacheIntegrityException`

  Parameters:
    `subQuery` - sub-query to search for
  Returns:
    ASG sub-query result (or `null` if sub-query is not found

### getQuery

    ASG[] getQuery(java.lang.String query)

  Check in the cache for a similar query match. Note that this method operates on the external IQL representation of the query which could result in more than one exact matches in the cache. In any case, this method returns an array of the possible query results as `ASG`s.

  Parameters:
    `query` - the query string must be in external format
  Returns:
    ASG[] array of possible query results found in the cache

### getCachedQueries

    java.util.List getCachedQueries()

  Return external queries of all cached items

  Returns:
    `List` a list of all metadata objects in the cache OR `null`
    if no queries are found

### getQueryMetadataObjects

    java.lang.Object[] getQueryMetadataObjects()

  Return an array of metadata objects associated to the query objects

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD