com.sun.mdm.index.query
Class QueryPipeLine

java.lang.Object
  extended bycom.sun.mdm.index.query.QueryPipeLine
All Implemented Interfaces:
AssemblerEngine

class QueryPipeLine
extends java.lang.Object
implements AssemblerEngine

Splits the QueryObject into multiple QueryObjects and invokes QueryManager to execute and return back QMIterator QueryPipeLine executes the query in these stages. • 1: create QueryObject to select only primary keys for primary object. Invoke QueryManager.execute() to get ids. • 2: Divide the ids received from step 1 into multiples of fetchsize and create Queryobjects based on the original queryobject received in step 1. Add IN condition containing fetch ids to the original queryobject and invoke QueryManager.executeAssemble. It replaces the AssemblerEngine in QMIterator received from QueryManager.execute by itself. Acting as AssemblerEngine, QueryPipeLine delegates its AssmblerEngine methods invocations to the original AssemblerEngine, specified in the QueryObject. So QueryPipeLine acts as lazy query executer that executes more queryobjects when set of data returned by previous QueryObject is exhausted.


Constructor Summary
(package private) QueryPipeLine()
           
 
Method Summary
 java.lang.Object clone()
          clones the AssemblerEngine
 void close()
          This will close the JDBC resultsets.
(package private)  QMIterator executeAssemble(QueryObject qobject)
          This method will execute the query(s) specified in QueryObject and also use FactoryEngine for creating composite objects.
(package private)  AssemblerEngine getOriginalAssemblerEngine(QMIterator iterator)
          An Iterator's assemblerEngine may be already susbstituted by QueryPipeLine(in case we get the QMIterator from QueryObjectCache).
 boolean hasNext()
          returns true or false if next object can be retrieved
 void initCompile(SQLDescriptor[] sqlDesc, AssembleDescriptor assDesc)
           
 void initRun(java.sql.Connection con, java.sql.ResultSet[] resultSets, java.sql.Statement[] statements, int maxRows)
           
 void initRun(java.sql.Connection con, java.sql.ResultSet[] resultSets, java.sql.Statement[] statements, int maxRows, boolean closeDbConnection)
          This method initializes the data structures that are used during run time and can be writeable.
 java.lang.Object next()
          This will retrieve next composite object constructed by AssemblerEngine.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryPipeLine

QueryPipeLine()
        throws CreateException
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
clones the AssemblerEngine

Specified by:
clone in interface AssemblerEngine
Returns:
clone of this engine
Throws:
java.lang.CloneNotSupportedException - CloneNotSupportedException

close

public void close()
           throws QMException
This will close the JDBC resultsets.

Specified by:
close in interface AssemblerEngine
Throws:
QMException - QMException

executeAssemble

QMIterator executeAssemble(QueryObject qobject)
                     throws QMException
This method will execute the query(s) specified in QueryObject and also use FactoryEngine for creating composite objects.

Parameters:
qobject - QueryObject that contains description of query
Returns:
QMIterator iterator that is used to fetch each composite object.
Throws:
QMException - QMException

getOriginalAssemblerEngine

AssemblerEngine getOriginalAssemblerEngine(QMIterator iterator)
An Iterator's assemblerEngine may be already susbstituted by QueryPipeLine(in case we get the QMIterator from QueryObjectCache). So we want to get the AssemblerEngine of an Iterator, that was set before replacement by QueryPipleLine. So we want to get AssemblerEngine that does the core Assembling process. Otherwise we might end up in an endless recursion of executing queries

Parameters:
iterator -
Returns:

hasNext

public boolean hasNext()
                throws QMException
returns true or false if next object can be retrieved

Specified by:
hasNext in interface AssemblerEngine
Returns:
true or false
Throws:
QMException - QMException

initCompile

public void initCompile(SQLDescriptor[] sqlDesc,
                        AssembleDescriptor assDesc)
                 throws QMException
Description copied from interface: AssemblerEngine
This is used during compilation and any data structures are cached. So the data strcutures should be read only and can be shared.

Specified by:
initCompile in interface AssemblerEngine
Parameters:
sqlDesc - SQLDescriptor[] that contains SQL statements and their meta data to be used for initialization.
assDesc - AssembleDescriptor
Throws:
QMException - QMException

initRun

public void initRun(java.sql.Connection con,
                    java.sql.ResultSet[] resultSets,
                    java.sql.Statement[] statements,
                    int maxRows)
             throws QMException
Description copied from interface: AssemblerEngine
This initialization is used during run time. QueryManager passes Connection and ResultSet[] to the AssemblerEngine so that AssemblerEngine can retrieve data from the database and compose the objects.

Specified by:
initRun in interface AssemblerEngine
Parameters:
con - Connection
resultSets - ResultSet[]
statements - Statement[]
Throws:
QMException - QMException

initRun

public void initRun(java.sql.Connection con,
                    java.sql.ResultSet[] resultSets,
                    java.sql.Statement[] statements,
                    int maxRows,
                    boolean closeDbConnection)
             throws QMException
This method initializes the data structures that are used during run time and can be writeable.

Specified by:
initRun in interface AssemblerEngine
Parameters:
con - Connection
resultSets - ResultSet[]
statements - Statement[]
maxRows - maximum number of rows
closeDbConnection - set to true if the database connection is to be closed by the AssemblerEngine, false if some other calling class is to close the database connection instead.
Throws:
QMException - QMException

next

public java.lang.Object next()
                      throws QMException
This will retrieve next composite object constructed by AssemblerEngine. The subclass of QMIterator should call super.next() to retrieve next composite object.

Specified by:
next in interface AssemblerEngine
Returns:
next Object
Throws:
QMException - QMException


Sun Microsystems, Inc.