|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.turbine.util.db.LargeSelect
This class can be used to retrieve a large result set from a database query. The query is started and then a small number of rows are returned at any one time. The LargeSelect is meant to be placed into the Session, so that it can be used in response to several related requests. It was written as an example in response to questions regarding Village's and Turbine's ability to handle large queries. The author hoped that the people who were asking for the feature would comment and improve the code, but has received no comments. As the author has had no need for such a class, it remains untested and in all likelihood contains several bugs.
Field Summary | |
private int |
blockBegin
|
private int |
blockEnd
|
private int |
currentlyFilledTo
|
private DBConnection |
db
|
private java.lang.String |
dbName
|
static java.lang.String |
DEFAULT_NAME
Key which may be used to store and retrieve the LargeSelect from the session. |
private boolean |
killThread
|
private int |
memoryLimit
|
private int |
miniblock
|
private java.lang.String |
name
|
private int |
position
|
private com.workingdogs.village.QueryDataSet |
qds
|
private java.lang.String |
query
|
private java.util.Vector |
results
|
private java.lang.Thread |
thread
|
Constructor Summary | |
LargeSelect(Criteria criteria,
int memoryLimit)
Creates a LargeSelect whose results are broken up into smaller chunks of approximately 1/100 the maximum number allowed in memory or 100, whichever is smaller. |
|
LargeSelect(Criteria criteria,
int memoryLimit,
int pageSize)
Creates a LargeSelect whose results are returned a page at a time. |
|
LargeSelect(java.lang.String name,
Criteria criteria,
int memoryLimit)
Creates a LargeSelect whose results are broken up into smaller chunks of approximately 1/100 the maximum number allowed in memory or 100, whichever is smaller. |
|
LargeSelect(java.lang.String name,
Criteria criteria,
int memoryLimit,
int pageSize)
Creates a LargeSelect whose results are returned a page at a time. |
Method Summary | |
java.util.Vector |
getNextResults()
Gets the next block of rows. |
java.util.Vector |
getPreviousResults()
Gets a block of rows which have previously been retrieved. |
java.util.Vector |
getResults(int start)
Gets a block of rows starting at a specified row. |
java.util.Vector |
getResults(int start,
int size)
Gets a block of rows starting at a specified row and containing a specified number of rows. |
private void |
init(java.lang.String name,
Criteria criteria,
int memoryLimit)
Called by the constructors to start the query. |
void |
run()
A background thread that retrieves the rows. |
private void |
startQuery(int initialSize)
Starts a new thread to retrieve the result set. |
private void |
stopQuery()
Used to stop filling the memory with the current block of results, if it has been determined that they are no longer relevant. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private int miniblock
private int memoryLimit
private java.lang.String name
private int blockBegin
private int blockEnd
private int currentlyFilledTo
private java.lang.String query
private java.lang.String dbName
private DBConnection db
private com.workingdogs.village.QueryDataSet qds
private java.util.Vector results
private java.lang.Thread thread
private boolean killThread
private int position
public static final java.lang.String DEFAULT_NAME
Constructor Detail |
public LargeSelect(Criteria criteria, int memoryLimit) throws java.lang.Exception
criteria
- Object used by BasePeer to build the query.memoryLimit
- Maximum number of rows to be in memory at
one time.Exception,
- a generic exception.public LargeSelect(java.lang.String name, Criteria criteria, int memoryLimit) throws java.lang.Exception
name
- Key used to store the LargeSelect in the session.criteria
- Object used by BasePeer to build the query.memoryLimit
- Maximum number of rows to be in memory at
one time.Exception,
- a generic exception.public LargeSelect(Criteria criteria, int memoryLimit, int pageSize) throws java.lang.Exception
criteria
- Object used by BasePeer to build the query.memoryLimit
- Maximum number of rows to be in memory at
one time.pageSize
- Number of rows to return in one block.Exception,
- a generic exception.public LargeSelect(java.lang.String name, Criteria criteria, int memoryLimit, int pageSize) throws java.lang.Exception
name
- Key used to store the LargeSelect in the session.criteria
- Object used by BasePeer to build the query.memoryLimit
- Maximum number of rows to be in memory at
one time.pageSize
- Number of rows to return in one block.Exception,
- a generic exception.Method Detail |
private void init(java.lang.String name, Criteria criteria, int memoryLimit) throws java.lang.Exception
name
- Key used to store the LargeSelect in the session.criteria
- Object used by BasePeer to build the query.memoryLimit
- Maximum number of rows to be in memory at
one time.Exception,
- a generic exception.public java.util.Vector getNextResults() throws java.lang.Exception
Exception,
- a generic exception.public java.util.Vector getPreviousResults() throws java.lang.Exception
Exception,
- a generic exception.public java.util.Vector getResults(int start) throws java.lang.Exception
start
- The starting row.Exception,
- a generic exception.public java.util.Vector getResults(int start, int size) throws java.lang.Exception
start
- The starting row.size
- The number of rows.Exception,
- a generic exception.public void run()
run
in interface java.lang.Runnable
private void startQuery(int initialSize) throws java.lang.Exception
initialSize
- The initial size for each block.Exception,
- a generic exception.private void stopQuery() throws java.lang.Exception
Exception,
- a generic exception.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |