MiniConQueryRewriter
Keywords: uk.ac.ic.doc.rodex.qproc.MiniConQueryRewriter class

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.rodex.qproc
Class MiniConQueryRewriter

    java.lang.Object
      uk.ac.ic.doc.rodex.qproc.QueryRewriter
          uk.ac.ic.doc.rodex.qproc.MiniConQueryRewriter

Direct Known Subclasses:
  MiniConQueryRewriterAdaptive, MiniConQueryRewriterNonConjunctive

    public class MiniConQueryRewriter

extends QueryRewriter

Nested Class Summary
`protected class` | `MiniConQueryRewriter.MiniConDescription` A private inner class to represent an MCD

Field Summary
`protected java.util.List` | `mcds`
`protected QueryAnalyser` | `queryAnalyser`
`protected QueryAnalyser[]` | `viewAnalysers`

Fields inherited from class uk.ac.ic.doc.rodex.qproc.QueryRewriter
`_qa, query, views`

Constructor Summary
`MiniConQueryRewriter(ASG query, java.util.List views)` Creates a new instance of MiniConQueryRewriter given only a list of cached views
`MiniConQueryRewriter(ASG query, QueryAnalyser[] viewMetadata)` Creates a new instance of MiniConQueryRewriter given a list of metadata objects of cached views

Method Summary
`QueryAnalyser` | `analyse()` Implements method in `QueryWriter` parent class Analyse query and view rules into head vars and sub-goals in order to prepare for the actual rewrite to take place
`protected java.util.Map` | `checkComparisonPredicates(QueryAnalyser qa, MiniConQueryRewriter.MiniConDescription mcd)` keep a mapping b/w pairs of query-view whose predicates have been checked
`protected java.util.Map` | `checkConstants(QueryAnalyser qa, MiniConQueryRewriter.MiniConDescription mcd)` Check if the current `MCD` support any constants in the query
`protected boolean` | `contains(java.util.List goalSet1, java.util.List goalSet2)` Check if a set of query sub-goals contains another set of sub-goals
`protected java.util.List` | `createConjunctiveQueries(java.util.List mcds, java.util.List qSubGoals)` Create the conjunctive queries from MCDs
`protected java.lang.String` | `createQueryFromSubGoals(java.util.List subGoals)`
`protected QuerySubGoal` | `getLeastRestrictiveMapping(QuerySubGoal querySubGoal, java.util.List viewSubGoals)` Check for sub-goal mapping between a query's sub-goal and a view.
`protected java.util.List` | `getMinimumCoverage(java.util.List sharedVars, QueryAnalyser view)` Check that a query contains certain variables in its head and if not it must contains all related sub-goals
`QueryAnalyser` | `getQueryAnalyser()` Return query analyser
`protected java.util.List` | `getSharedVariables(QuerySubGoal qsg)` Get all shared variables between a query and one of its sub-goal
`protected void` | `refineConjunctiveQueries(java.util.List conjQueries, QueryRewriterResult result)` Refine the conjunctive queries by, for example, removing duplicate views or sub-goals.
`QueryRewriterResult` | `rewrite()` Implements method in `QueryWriter` abstract parent class Rewrite query using views based on the MiniCon algorithm following a two-phase process:
`protected java.util.List` | `subtractList(java.util.List srcList, java.util.List fromList)`

Methods inherited from class uk.ac.ic.doc.rodex.qproc.QueryRewriter
`getQueryRewriterInstance, getQueryRewriterInstance, getQueryRewriterInstance, getQueryRewriterInstance`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### queryAnalyser

    protected QueryAnalyser queryAnalyser

### viewAnalysers

    protected QueryAnalyser[] viewAnalysers

### mcds

    protected java.util.List mcds

Constructor Detail

### MiniConQueryRewriter

    public MiniConQueryRewriter(ASG query,
                                java.util.List views)

  Creates a new instance of MiniConQueryRewriter given only a list of cached views

### MiniConQueryRewriter

    public MiniConQueryRewriter(ASG query,
                                QueryAnalyser[] viewMetadata)

  Creates a new instance of MiniConQueryRewriter given a list of metadata objects of cached views

Method Detail

### analyse

    public QueryAnalyser analyse()
                          throws QueryRewriterException,
                                 QueryIntegrityException

  Implements method in `QueryWriter` parent class
  Analyse query and view rules into head vars and sub-goals in order to prepare
  for the actual rewrite to take place

  Specified by:
    `analyse` in class `QueryRewriter`
  Returns:
    `QueryAnalysre` object that contains query's metadata
  Throws:
    `QueryRewriterException`
    `QueryIntegrityException`

### getQueryAnalyser

    public QueryAnalyser getQueryAnalyser()

  Return query analyser

  Specified by:
    `getQueryAnalyser` in class `QueryRewriter`

### rewrite

    public QueryRewriterResult rewrite()
                                throws QueryRewriterException

  Implements method in `QueryWriter` abstract parent class
  Rewrite query using views based on the MiniCon algorithm following a two-phase process:

  Phase 1: For each view we check to see if there is a mapping between any of the query
  subgoals and the view's. If a mapping exists and there are shared variables
  in the query subgoal which are also in the query's head but not in the view's head,
  a further check is carried out to find the mininum set of query sub-goals containing
  the shared variables that the view need to cover.

  If there are any comparison predicates in the query (e.g. >, <, = etc.) and they
  are mutually consistent with those found in a view mentioned above then an MCD can be created
  for that view.

  Phase 2: Identify disjoint sets of MCDs found in phase 1 with each set covering all query's subgoals.
  Combine MCDs in each set to produce a conjunctive rewriting of the query.
  The final query re-writing is the union of all conjunctive rewritten queries.

  Specified by:
    `rewrite` in class `QueryRewriter`
  Throws:
    `QueryRewriterException`

### getLeastRestrictiveMapping

    protected QuerySubGoal getLeastRestrictiveMapping(QuerySubGoal querySubGoal,
                                                      java.util.List viewSubGoals)

  Check for sub-goal mapping between a query's sub-goal and a view.

  Parameters:
    `querySubGoal` - an `QuerySubGoal` object in the query
    `viewSubGoals` - a `List` of `QuerySubGoal` objects in a view
  Returns:
    a `QuerySubGoal` object for least restrictive mapping
    between `query_sub_goal` and `view_sub_goal`.
    Return `null` if no mapping exists

### getSharedVariables

    protected java.util.List getSharedVariables(QuerySubGoal qsg)

  Get all shared variables between a query and one of its sub-goal

  Returns:
    `List` a list of sub-goals

### getMinimumCoverage

    protected java.util.List getMinimumCoverage(java.util.List sharedVars,
                                                QueryAnalyser view)

  Check that a query contains certain variables in its head and if not it
  must contains all related sub-goals

  Parameters:
    `sharedVars` - a `List` of shared variables to check
    `view` - a `QueryAnalyser` object containing having the data structure
    of the view that needs to be checked
  Returns:
    `List` a minimum list of view's sub-goals (if any) that cover
    the shared variables; `null` if view fails to cover.

### checkConstants

    protected java.util.Map checkConstants(QueryAnalyser qa,
                                           MiniConQueryRewriter.MiniConDescription mcd)

  Check if the current `MCD` support any constants in the query

  Parameters:
    `qa` - the `QueryAnalyser` object of the query
    `mcd` - the `MiniConQueryRewriter.MiniConDescription` object found
  Returns:
    `HashMap` object for storing matches found

### checkComparisonPredicates

    protected java.util.Map checkComparisonPredicates(QueryAnalyser qa,
                                                      MiniConQueryRewriter.MiniConDescription mcd)

  keep a mapping b/w pairs of query-view whose predicates have been checked

### createConjunctiveQueries

    protected java.util.List createConjunctiveQueries(java.util.List mcds,
                                                      java.util.List qSubGoals)

  Create the conjunctive queries from MCDs

  Parameters:
    `mcds` - a `List` of `MiniConQueryRewriter.MiniConDescription` objects
  Returns:
    `List` list of condidate queries

### refineConjunctiveQueries

    protected void refineConjunctiveQueries(java.util.List conjQueries,
                                            QueryRewriterResult result)

  Refine the conjunctive queries by, for example, removing duplicate views or
  sub-goals. These refinements are exclusive to IQL queries

  Parameters:
    `conjQueries` - a `List` of conjunctive queries resulted from rewriting operation
    `result` - the `QueryRewriterResult` object to update with refinements

### createQueryFromSubGoals

    protected java.lang.String createQueryFromSubGoals(java.util.List subGoals)
                                                throws QueryRewriterException

  Throws:
    `QueryRewriterException`

### contains

    protected boolean contains(java.util.List goalSet1,
                               java.util.List goalSet2)

  Check if a set of query sub-goals contains another set of sub-goals

  Parameters:
    `goalSet1` - a `List` of goals of the first set
    `goalSet2` - a `List` of goals of the second set
  Returns:
    boolean `true` if `goalSet1` contains
    `goalSet2`, `false` otherwise

### subtractList

    protected java.util.List subtractList(java.util.List srcList,
                                          java.util.List fromList)

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